-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.js
94 lines (79 loc) · 2.6 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* wpcollab-plugin-skeleton
* https://github.com/WPCollab/wpcollab-plugin-skeleton
*
* Copyright (C) 2014 WPCollab Team (https://github.com/WPCollab/wpcollab-plugin-skeleton/graphs/contributors)
* Licensed under the MIT License
*
* based on grunt-wp-boilerplate (https://github.com/fooplugins/grunt-wp-boilerplate) by Brad Vincent, FooPlugins LLC
*/
/**
* @todo STRINGS
*
* dev = 'WPCollab'
* dev_long = '%dev Team'
* dev_lowercase = %dev + make lowercase
*
* title
* title_underscores = %title + make spaces into underscores
* title_camel_capital = %title + remove spaces
* title_camel_lowercase = %title + remove spaces and make lowercase
*
* homepage
* description
* slug
* github_repo
*/
'use strict';
var internalVariables = {
dev: 'WPCollab',
dev_long: 'WPCollab Team'
};
// Basic template description
// @todo exports.description = 'Create a ' %dev ' plugin skeleton!'; // @todo how to do this?
// Template-specific notes to be displayed after the question prompts.
exports.after = 'The plugin skeleton has been generated. Start coding!';
// 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: '0.0.1'
},
init.prompt('homepage', 'http://wordpress.org/plugins'),
// init.prompt('author_name'),
// init.prompt('author_email'),
// init.prompt('author_url'),
init.prompt('github_repo')
],
function(err, props) {
props.dev = internalVariables.dev;
props.dev_long = internalVariables.dev_long;
props.dev_lowercase = props.dev.toLowerCase();
props.title_underscores = props.title.replace(/[\W_]+/g, '_');
props.title_camel_capital = props.title.replace(/[\W_]+/g, ''); // @todo working?
props.title_camel_lowercase = ( props.title.replace(/[\W_]+/g, '_') ).toLowerCase(); // @todo lowercase-ing - Is this right?
// 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();
}
);
};