-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.js
79 lines (67 loc) · 2.48 KB
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* grunt-wp-theme-foundation
* https://github.com/10up/grunt-wp-theme-foundation
*
* Copyright (c) 2013 Eric Mann, 10up, Tanner Moushey
* Licensed under the MIT License
*/
'use strict';
// Basic template description
exports.description = 'Create a WordPress theme.';
// Template-specific notes to be displayed before question prompts.
exports.notes = '';
// Template-specific notes to be displayed after the question prompts.
exports.after = '';
// Any existing file or directory matching this wildcard will cause a warning.
exports.warnOn = '*';
// The actual init template
exports.template = function( grunt, init, done ) {
init.process( {}, [
// Prompt for these values.
init.prompt( 'title', 'WP Foundation' ),
{
name : 'prefix',
message: 'PHP function prefix (alpha and underscore characters only)',
default: 'wpfoundation'
},
init.prompt( 'description', 'Starter theme based on Foundation' ),
init.prompt( 'homepage', 'http://wordpress.org/themes' ),
init.prompt( 'author_name' ),
init.prompt( 'author_email' ),
init.prompt( 'author_url' )
], function( err, props ) {
props.keywords = [];
props.version = '0.1.0';
props.devDependencies = {
'grunt': '~0.4.1',
'matchdep': '~0.1.2',
'grunt-contrib-concat': '~0.1.2',
'grunt-contrib-uglify': '~0.1.1',
'grunt-contrib-cssmin': '~0.6.0',
'grunt-contrib-jshint': '~0.1.1',
'grunt-contrib-nodeunit': '~0.1.2',
'grunt-contrib-watch': '~0.2.0',
'grunt-contrib-sass': '~0.2.2'
};
// Sanitize names where we need to for PHP/JS
props.name = props.title.replace( /\s+/g, '-' ).toLowerCase();
// Development prefix (i.e. to prefix PHP function names, variables)
props.prefix = props.prefix.replace('/[^a-z_]/i', '').toLowerCase();
// Development prefix in all caps (e.g. for constants)
props.prefix_caps = props.prefix.toUpperCase();
// An additional value, safe to use as a JavaScript identifier.
props.js_safe_name = props.name.replace(/[\W_]+/g, '_').replace(/^(\d)/, '_$1');
// An additional value that won't conflict with NodeUnit unit tests.
props.js_test_safe_name = props.js_safe_name === 'test' ? 'myTest' : props.js_safe_name;
props.js_safe_name_caps = props.js_safe_name.toUpperCase();
// Files to copy and process
var files = init.filesToCopy( props );
console.log( files );
// Actually copy and process files
init.copyAndProcess( files, props );
// Generate package.json file
init.writePackageJSON( 'package.json', props );
// Done!
done();
});
};