milkee 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/plugin.js +57 -6
- package/package.json +1 -1
- package/temp/plugin/_gitignore +1 -0
package/dist/commands/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
|
2
|
-
var CONFIG_FILE, CWD, PLUGIN_KEYWORDS, TEMPLATES, TEMPLATE_DIR, confirmContinue, consola, copyTemplate, ensureDir, execSync, fs, generateReadme, initPackageJson, path, plugin, updatePackageJson,
|
|
2
|
+
var CONFIG_FILE, CWD, DOCS, DOCS_DIR, PLUGIN_KEYWORDS, TEMPLATES, TEMPLATE_DIR, confirmContinue, consola, copyDocs, copyTemplate, ensureDir, execSync, fs, generateReadme, initPackageJson, path, plugin, updatePackageJson,
|
|
3
3
|
indexOf = [].indexOf;
|
|
4
4
|
|
|
5
5
|
fs = require('fs');
|
|
@@ -16,6 +16,8 @@ confirmContinue = require('../options/confirm');
|
|
|
16
16
|
|
|
17
17
|
TEMPLATE_DIR = path.join(__dirname, '..', '..', 'temp', 'plugin');
|
|
18
18
|
|
|
19
|
+
DOCS_DIR = path.join(__dirname, '..', '..', 'docs');
|
|
20
|
+
|
|
19
21
|
TEMPLATES = [
|
|
20
22
|
{
|
|
21
23
|
src: 'main.coffee',
|
|
@@ -43,6 +45,17 @@ TEMPLATES = [
|
|
|
43
45
|
}
|
|
44
46
|
];
|
|
45
47
|
|
|
48
|
+
DOCS = [
|
|
49
|
+
{
|
|
50
|
+
src: 'PLUGIN.md',
|
|
51
|
+
dest: 'docs/PLUGIN.md'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
src: 'PLUGIN-ja.md',
|
|
55
|
+
dest: 'docs/PLUGIN-ja.md'
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
|
|
46
59
|
// Create directory if not exists
|
|
47
60
|
ensureDir = function(filePath) {
|
|
48
61
|
var dir;
|
|
@@ -70,6 +83,22 @@ copyTemplate = function(src, dest) {
|
|
|
70
83
|
return true;
|
|
71
84
|
};
|
|
72
85
|
|
|
86
|
+
// Copy docs file
|
|
87
|
+
copyDocs = function(src, dest) {
|
|
88
|
+
var content, destPath, srcPath;
|
|
89
|
+
srcPath = path.join(DOCS_DIR, src);
|
|
90
|
+
destPath = path.join(CWD, dest);
|
|
91
|
+
if (!fs.existsSync(srcPath)) {
|
|
92
|
+
consola.error(`Docs file not found: ${srcPath}`);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
ensureDir(destPath);
|
|
96
|
+
content = fs.readFileSync(srcPath, 'utf-8');
|
|
97
|
+
fs.writeFileSync(destPath, content);
|
|
98
|
+
consola.success(`Created \`${dest}\``);
|
|
99
|
+
return true;
|
|
100
|
+
};
|
|
101
|
+
|
|
73
102
|
PLUGIN_KEYWORDS = ['milkee', 'coffeescript', 'coffee', 'ext', 'plugin', 'milkee-plugin'];
|
|
74
103
|
|
|
75
104
|
// Update package.json
|
|
@@ -158,7 +187,7 @@ generateReadme = function() {
|
|
|
158
187
|
|
|
159
188
|
// Main plugin setup function
|
|
160
189
|
plugin = async function() {
|
|
161
|
-
var confirmed, destPath, error, i, j, len, len1, overwrite, pkgPath, readmePath, template;
|
|
190
|
+
var confirmed, destPath, doc, error, i, j, k, l, len, len1, len2, len3, overwrite, pkgPath, readmePath, template;
|
|
162
191
|
consola.box("Milkee Plugin Setup");
|
|
163
192
|
consola.info("This will set up your project as a Milkee plugin.");
|
|
164
193
|
consola.info("");
|
|
@@ -173,8 +202,13 @@ plugin = async function() {
|
|
|
173
202
|
template = TEMPLATES[i];
|
|
174
203
|
consola.info(` - ${template.dest}`);
|
|
175
204
|
}
|
|
176
|
-
consola.info(" 3.
|
|
177
|
-
|
|
205
|
+
consola.info(" 3. Copy docs:");
|
|
206
|
+
for (j = 0, len1 = DOCS.length; j < len1; j++) {
|
|
207
|
+
doc = DOCS[j];
|
|
208
|
+
consola.info(` - ${doc.dest}`);
|
|
209
|
+
}
|
|
210
|
+
consola.info(" 4. Update package.json (main, scripts, keywords)");
|
|
211
|
+
consola.info(" 5. Generate README.md");
|
|
178
212
|
consola.info("");
|
|
179
213
|
// Confirm before proceeding
|
|
180
214
|
confirmed = (await confirmContinue());
|
|
@@ -206,8 +240,8 @@ plugin = async function() {
|
|
|
206
240
|
consola.info("");
|
|
207
241
|
// Create template files
|
|
208
242
|
consola.start("Creating template files...");
|
|
209
|
-
for (
|
|
210
|
-
template = TEMPLATES[
|
|
243
|
+
for (k = 0, len2 = TEMPLATES.length; k < len2; k++) {
|
|
244
|
+
template = TEMPLATES[k];
|
|
211
245
|
destPath = path.join(CWD, template.dest);
|
|
212
246
|
if (fs.existsSync(destPath)) {
|
|
213
247
|
overwrite = (await consola.prompt(`${template.dest} already exists. Overwrite?`, {
|
|
@@ -221,6 +255,23 @@ plugin = async function() {
|
|
|
221
255
|
copyTemplate(template.src, template.dest);
|
|
222
256
|
}
|
|
223
257
|
consola.info("");
|
|
258
|
+
// Copy docs
|
|
259
|
+
consola.start("Copying docs...");
|
|
260
|
+
for (l = 0, len3 = DOCS.length; l < len3; l++) {
|
|
261
|
+
doc = DOCS[l];
|
|
262
|
+
destPath = path.join(CWD, doc.dest);
|
|
263
|
+
if (fs.existsSync(destPath)) {
|
|
264
|
+
overwrite = (await consola.prompt(`${doc.dest} already exists. Overwrite?`, {
|
|
265
|
+
type: "confirm"
|
|
266
|
+
}));
|
|
267
|
+
if (!overwrite) {
|
|
268
|
+
consola.info(`Skipped \`${doc.dest}\``);
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
copyDocs(doc.src, doc.dest);
|
|
273
|
+
}
|
|
274
|
+
consola.info("");
|
|
224
275
|
// Update package.json
|
|
225
276
|
consola.start("Updating package.json...");
|
|
226
277
|
updatePackageJson();
|
package/package.json
CHANGED
package/temp/plugin/_gitignore
CHANGED