milkee 2.4.0-dev.1 → 2.4.0-dev.2
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 +47 -4
- package/package.json +1 -1
- package/temp/plugin/README.md +33 -0
- package/temp/plugin/main.coffee +1 -1
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, initPackageJson, path, plugin, updatePackageJson,
|
|
2
|
+
var CONFIG_FILE, CWD, PLUGIN_KEYWORDS, TEMPLATES, TEMPLATE_DIR, confirmContinue, consola, copyTemplate, ensureDir, execSync, fs, generateReadme, initPackageJson, path, plugin, updatePackageJson,
|
|
3
3
|
indexOf = [].indexOf;
|
|
4
4
|
|
|
5
5
|
fs = require('fs');
|
|
@@ -115,7 +115,7 @@ initPackageJson = function() {
|
|
|
115
115
|
if (!fs.existsSync(pkgPath)) {
|
|
116
116
|
consola.start("Initializing package.json...");
|
|
117
117
|
try {
|
|
118
|
-
execSync('npm init
|
|
118
|
+
execSync('npm init', {
|
|
119
119
|
cwd: CWD,
|
|
120
120
|
stdio: 'inherit'
|
|
121
121
|
});
|
|
@@ -129,16 +129,43 @@ initPackageJson = function() {
|
|
|
129
129
|
return true;
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
// Generate README.md
|
|
133
|
+
generateReadme = function() {
|
|
134
|
+
var description, error, name, pkg, pkgPath, readme, readmePath, templatePath;
|
|
135
|
+
pkgPath = path.join(CWD, 'package.json');
|
|
136
|
+
readmePath = path.join(CWD, 'README.md');
|
|
137
|
+
templatePath = path.join(TEMPLATE_DIR, 'README.md');
|
|
138
|
+
try {
|
|
139
|
+
if (!fs.existsSync(templatePath)) {
|
|
140
|
+
consola.error(`Template file not found: ${templatePath}`);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
144
|
+
name = pkg.name || 'your-plugin-name';
|
|
145
|
+
description = pkg.description || 'A Milkee plugin.';
|
|
146
|
+
readme = fs.readFileSync(templatePath, 'utf-8');
|
|
147
|
+
readme = readme.replace(/\{\{name\}\}/g, name);
|
|
148
|
+
readme = readme.replace(/\{\{description\}\}/g, description);
|
|
149
|
+
fs.writeFileSync(readmePath, readme);
|
|
150
|
+
consola.success("Created `README.md`");
|
|
151
|
+
return true;
|
|
152
|
+
} catch (error1) {
|
|
153
|
+
error = error1;
|
|
154
|
+
consola.error("Failed to create README.md:", error);
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
132
159
|
// Main plugin setup function
|
|
133
160
|
plugin = async function() {
|
|
134
|
-
var confirmed, destPath, error, i, j, len, len1, overwrite, pkgPath, template;
|
|
161
|
+
var confirmed, destPath, error, i, j, len, len1, overwrite, pkgPath, readmePath, template;
|
|
135
162
|
consola.box("Milkee Plugin Setup");
|
|
136
163
|
consola.info("This will set up your project as a Milkee plugin.");
|
|
137
164
|
consola.info("");
|
|
138
165
|
consola.info("The following actions will be performed:");
|
|
139
166
|
pkgPath = path.join(CWD, 'package.json');
|
|
140
167
|
if (!fs.existsSync(pkgPath)) {
|
|
141
|
-
consola.info(" 0. Initialize package.json (npm init
|
|
168
|
+
consola.info(" 0. Initialize package.json (npm init)");
|
|
142
169
|
}
|
|
143
170
|
consola.info(" 1. Install dependencies (consola, coffeescript, milkee)");
|
|
144
171
|
consola.info(" 2. Create template files:");
|
|
@@ -147,6 +174,7 @@ plugin = async function() {
|
|
|
147
174
|
consola.info(` - ${template.dest}`);
|
|
148
175
|
}
|
|
149
176
|
consola.info(" 3. Update package.json (main, scripts, keywords)");
|
|
177
|
+
consola.info(" 4. Generate README.md");
|
|
150
178
|
consola.info("");
|
|
151
179
|
// Confirm before proceeding
|
|
152
180
|
confirmed = (await confirmContinue());
|
|
@@ -197,6 +225,21 @@ plugin = async function() {
|
|
|
197
225
|
consola.start("Updating package.json...");
|
|
198
226
|
updatePackageJson();
|
|
199
227
|
consola.info("");
|
|
228
|
+
// Generate README.md
|
|
229
|
+
readmePath = path.join(CWD, 'README.md');
|
|
230
|
+
if (fs.existsSync(readmePath)) {
|
|
231
|
+
overwrite = (await consola.prompt("README.md already exists. Overwrite?", {
|
|
232
|
+
type: "confirm"
|
|
233
|
+
}));
|
|
234
|
+
if (overwrite) {
|
|
235
|
+
generateReadme();
|
|
236
|
+
} else {
|
|
237
|
+
consola.info("Skipped `README.md`");
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
generateReadme();
|
|
241
|
+
}
|
|
242
|
+
consola.info("");
|
|
200
243
|
consola.success("Milkee plugin setup complete!");
|
|
201
244
|
consola.info("");
|
|
202
245
|
consola.info("Next steps:");
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# {{name}}
|
|
2
|
+
|
|
3
|
+
This is a plugin for [milkee](https://www.npmjs.com/package/milkee) .
|
|
4
|
+
|
|
5
|
+
{{description}}
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### setup
|
|
10
|
+
|
|
11
|
+
#### coffee.config.cjs
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
const plugin = require('{{name}}');
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
// ...
|
|
18
|
+
milkee: {
|
|
19
|
+
plugins: [
|
|
20
|
+
plugin(),
|
|
21
|
+
// ...
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Run
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
milkee
|
|
31
|
+
# or
|
|
32
|
+
npx milkee
|
|
33
|
+
```
|
package/temp/plugin/main.coffee
CHANGED
|
@@ -17,7 +17,7 @@ for method in ['log', 'info', 'success', 'warn', 'error', 'debug', 'start', 'box
|
|
|
17
17
|
# Main plugin function
|
|
18
18
|
main = (compilationResult) ->
|
|
19
19
|
{ config, compiledFiles, stdout, stderr } = compilationResult
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
c.info "Compiled #{compiledFiles.length} file(s)"
|
|
22
22
|
for file in compiledFiles
|
|
23
23
|
c.log " - #{file}"
|