forked from fooplugins/grunt-wp-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.js
74 lines (60 loc) · 2.13 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
/**
* grunt-wp-boilerplate
* https://github.com/fooplugins/grunt-wp-boilerplate
*
* Copyright (c) 2014 Brad Vincent, FooPlugins LLC
* Copyright (c) 2016 Álvaro Martínez Majado <[email protected]>
* Licensed under the MIT License
*/
'use strict';
// Basic template description
exports.description = 'Create a WordPress plugin!';
// Template-specific notes to be displayed before question prompts.
exports.notes = 'The generated plugin is based off the WordPress Plugin Boilerplate created by Tom McFarlin.';
// Template-specific notes to be displayed after the question prompts.
exports.after = 'Your plugin has been generated. Enjoy!';
// 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', 'Plugin title' ),
init.prompt( 'slug', 'Plugin slug / textdomain (no spaces)' ),
init.prompt( 'description', 'An awesome plugin that does awesome things' ),
{
name: 'version',
message: 'Plugin Version',
default: '1.0.0'
},
init.prompt( 'homepage', 'http://wordpress.org/plugins' ),
init.prompt( 'author_name' ),
{
name: 'copyright_year',
message: 'Copyright year',
default: '1970'
},
init.prompt( 'author_email' ),
init.prompt( 'author_url' ),
{
name: 'github_repo',
message: 'Github repo',
default: ''
},
], function( err, props ) {
props.safe_name = props.title.replace(/[\W_]+/g, '_');
props.slug = props.slug.replace(/[\W_]+/g, '-');
props.slug = props.slug.toLowerCase();
// Files to copy and process
var files = init.filesToCopy( props );
//delete a file if necessary :
//delete files[ 'public/assets/js/public.js'];
console.log( files );
// Actually copy and process files
init.copyAndProcess( files, props, {noProcess: 'assets/**' } );
// Generate package.json file
//init.writePackageJSON( 'package.json', props );
// Done!
done();
});
};