milkee 3.2.3 → 3.3.0-dev.0
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/README-ja.md +3 -3
- package/README.md +3 -3
- package/dist/commands/compile.js +9 -1
- package/dist/commands/setup.js +223 -29
- package/package.json +2 -2
- package/temp/setup/README.md +9 -0
- package/temp/setup/_gitattributes +3 -0
- package/temp/setup/_gitignore +3 -0
- package/temp/setup/main.coffee +1 -0
- /package/temp/{coffee.config.cjs → setup/coffee.config.cjs} +0 -0
package/README-ja.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[](https://milkee.org)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
[coffee.config.cjs](./temp/setup/coffee.config.cjs) を使ったシンプルな CoffeeScript ビルドツール ☕
|
|
14
14
|
|
|
15
15
|
公式サイト: https://milkee.org
|
|
16
16
|
|
|
@@ -43,7 +43,7 @@ npm i -D coffeescript @babel/core
|
|
|
43
43
|
|
|
44
44
|
### セットアップ
|
|
45
45
|
|
|
46
|
-
`-s` (`--setup`)
|
|
46
|
+
`-s` (`--setup`) コマンドを実行すると、[coffee.config.cjs](./temp/setup/coffee.config.cjs) が生成されます!
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
# グローバル
|
|
@@ -148,7 +148,7 @@ module.exports = {
|
|
|
148
148
|
|
|
149
149
|
### コンパイル
|
|
150
150
|
|
|
151
|
-
Milkee は自動で
|
|
151
|
+
Milkee は自動で [coffee.config.cjs](./temp/setup/coffee.config.cjs) を読み、`options` からコマンドを組み立ててコンパイルを開始します!
|
|
152
152
|
|
|
153
153
|
```bash
|
|
154
154
|
# グローバル
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[](https://milkee.org)
|
|
12
12
|
|
|
13
|
-
A simple CoffeeScript build tool with [coffee.config.cjs](./temp/coffee.config.cjs)
|
|
13
|
+
A simple CoffeeScript build tool with [coffee.config.cjs](./temp/setup/coffee.config.cjs) ☕
|
|
14
14
|
|
|
15
15
|
Official site: https://milkee.org
|
|
16
16
|
|
|
@@ -43,7 +43,7 @@ npm i -D coffeescript @babel/core
|
|
|
43
43
|
|
|
44
44
|
### Setup
|
|
45
45
|
|
|
46
|
-
Run `-s` (`--setup`) command, generate [coffee.config.cjs](./temp/coffee.config.cjs)!
|
|
46
|
+
Run `-s` (`--setup`) command, generate [coffee.config.cjs](./temp/setup/coffee.config.cjs)!
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
49
|
# global
|
|
@@ -148,7 +148,7 @@ module.exports = {
|
|
|
148
148
|
|
|
149
149
|
### Compile
|
|
150
150
|
|
|
151
|
-
Milkee will automatically read
|
|
151
|
+
Milkee will automatically read [coffee.config.cjs](./temp/setup/coffee.config.cjs), assemble the command from your `options`, and start compilation!
|
|
152
152
|
|
|
153
153
|
```bash
|
|
154
154
|
# global
|
package/dist/commands/compile.js
CHANGED
|
@@ -216,7 +216,15 @@ compile = async function() {
|
|
|
216
216
|
if (debounceTimeout) {
|
|
217
217
|
clearTimeout(debounceTimeout);
|
|
218
218
|
}
|
|
219
|
-
return debounceTimeout = setTimeout(function() {
|
|
219
|
+
return debounceTimeout = setTimeout(async function() {
|
|
220
|
+
if (milkeeOptions.copy) {
|
|
221
|
+
try {
|
|
222
|
+
await executeCopy(config);
|
|
223
|
+
} catch (error1) {
|
|
224
|
+
error = error1;
|
|
225
|
+
consola.error('Failed to copy non-coffee files');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
220
228
|
if (lastError) {
|
|
221
229
|
consola.warn('Compilation failed, plugins skipped.');
|
|
222
230
|
} else {
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,49 +1,243 @@
|
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
|
2
|
-
var CONFIG_FILE,
|
|
2
|
+
var CONFIG_FILE, CWD, SETUP_KEYWORDS, TEMPLATES, TEMPLATE_DIR, confirmContinue, consola, copyTemplate, ensureDir, execSync, fs, generateReadme, initPackageJson, path, setup, updatePackageJson,
|
|
3
|
+
indexOf = [].indexOf;
|
|
3
4
|
|
|
4
5
|
fs = require('fs');
|
|
5
6
|
|
|
6
7
|
path = require('path');
|
|
7
8
|
|
|
9
|
+
({execSync} = require('child_process'));
|
|
10
|
+
|
|
8
11
|
consola = require('consola');
|
|
9
12
|
|
|
10
|
-
({
|
|
13
|
+
({CWD, CONFIG_FILE} = require('../lib/constants'));
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
confirmContinue = require('../options/confirm');
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
TEMPLATE_DIR = path.join(__dirname, '..', '..', 'temp', 'setup');
|
|
18
|
+
|
|
19
|
+
TEMPLATES = [
|
|
20
|
+
{
|
|
21
|
+
src: 'main.coffee',
|
|
22
|
+
dest: 'src/main.coffee'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
src: 'coffee.config.cjs',
|
|
26
|
+
dest: CONFIG_FILE
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
src: '_gitignore',
|
|
30
|
+
dest: '.gitignore'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
src: '_gitattributes',
|
|
34
|
+
dest: '.gitattributes'
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
// Create directory if not exists
|
|
39
|
+
ensureDir = function(filePath) {
|
|
40
|
+
var dir;
|
|
41
|
+
dir = path.dirname(filePath);
|
|
42
|
+
if (!fs.existsSync(dir)) {
|
|
43
|
+
return fs.mkdirSync(dir, {
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Copy template file
|
|
50
|
+
copyTemplate = function(src, dest) {
|
|
51
|
+
var content, destPath, srcPath;
|
|
52
|
+
srcPath = path.join(TEMPLATE_DIR, src);
|
|
53
|
+
destPath = path.join(CWD, dest);
|
|
54
|
+
if (!fs.existsSync(srcPath)) {
|
|
55
|
+
consola.error(`Template file not found: ${srcPath}`);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
ensureDir(destPath);
|
|
59
|
+
content = fs.readFileSync(srcPath, 'utf-8');
|
|
60
|
+
fs.writeFileSync(destPath, content);
|
|
61
|
+
consola.success(`Created \`${dest}\``);
|
|
62
|
+
return true;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
SETUP_KEYWORDS = ['milkee', 'coffeescript', 'coffee'];
|
|
66
|
+
|
|
67
|
+
// Update package.json
|
|
68
|
+
updatePackageJson = function() {
|
|
69
|
+
var base, error, i, keyword, len, pkg, pkgPath;
|
|
70
|
+
pkgPath = path.join(CWD, 'package.json');
|
|
71
|
+
try {
|
|
72
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
73
|
+
// Update main
|
|
74
|
+
pkg.main = 'dist/main.js';
|
|
75
|
+
// Update scripts
|
|
76
|
+
if (pkg.scripts == null) {
|
|
77
|
+
pkg.scripts = {};
|
|
78
|
+
}
|
|
79
|
+
if ((base = pkg.scripts).test == null) {
|
|
80
|
+
base.test = 'echo "Error: no test specified" && exit 0';
|
|
81
|
+
}
|
|
82
|
+
pkg.scripts.build = 'milkee';
|
|
83
|
+
// Update keywords
|
|
84
|
+
if (pkg.keywords == null) {
|
|
85
|
+
pkg.keywords = [];
|
|
86
|
+
}
|
|
87
|
+
for (i = 0, len = SETUP_KEYWORDS.length; i < len; i++) {
|
|
88
|
+
keyword = SETUP_KEYWORDS[i];
|
|
89
|
+
if (indexOf.call(pkg.keywords, keyword) < 0) {
|
|
90
|
+
pkg.keywords.push(keyword);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
94
|
+
consola.success('Updated `package.json`');
|
|
95
|
+
return true;
|
|
96
|
+
} catch (error1) {
|
|
97
|
+
error = error1;
|
|
98
|
+
consola.error('Failed to update package.json:', error);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Initialize package.json if not exists
|
|
104
|
+
initPackageJson = function() {
|
|
105
|
+
var error, pkgPath;
|
|
106
|
+
pkgPath = path.join(CWD, 'package.json');
|
|
107
|
+
if (!fs.existsSync(pkgPath)) {
|
|
108
|
+
consola.start('Initializing package.json...');
|
|
109
|
+
try {
|
|
110
|
+
execSync('npm init', {
|
|
111
|
+
cwd: CWD,
|
|
112
|
+
stdio: 'inherit'
|
|
32
113
|
});
|
|
33
|
-
|
|
34
|
-
|
|
114
|
+
consola.success('Created `package.json`');
|
|
115
|
+
} catch (error1) {
|
|
116
|
+
error = error1;
|
|
117
|
+
consola.error('Failed to create package.json:', error);
|
|
118
|
+
return false;
|
|
35
119
|
}
|
|
36
120
|
}
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Generate README.md
|
|
125
|
+
generateReadme = function() {
|
|
126
|
+
var description, error, name, pkg, pkgPath, readme, readmePath, templatePath;
|
|
127
|
+
pkgPath = path.join(CWD, 'package.json');
|
|
128
|
+
readmePath = path.join(CWD, 'README.md');
|
|
129
|
+
templatePath = path.join(TEMPLATE_DIR, 'README.md');
|
|
37
130
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
131
|
+
if (!fs.existsSync(templatePath)) {
|
|
132
|
+
consola.error(`Template file not found: ${templatePath}`);
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
136
|
+
name = pkg.name || 'your-project-name';
|
|
137
|
+
description = pkg.description || 'A Milkee project.';
|
|
138
|
+
readme = fs.readFileSync(templatePath, 'utf-8');
|
|
139
|
+
readme = readme.replace(/\{\{name\}\}/g, name);
|
|
140
|
+
readme = readme.replace(/\{\{description\}\}/g, description);
|
|
141
|
+
fs.writeFileSync(readmePath, readme);
|
|
142
|
+
consola.success('Created `README.md`');
|
|
143
|
+
return true;
|
|
42
144
|
} catch (error1) {
|
|
43
145
|
error = error1;
|
|
44
|
-
consola.error(
|
|
45
|
-
return
|
|
146
|
+
consola.error('Failed to create README.md:', error);
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// Main setup function
|
|
152
|
+
setup = async function() {
|
|
153
|
+
var confirmed, destPath, error, i, j, len, len1, overwrite, pkgPath, readmePath, template;
|
|
154
|
+
consola.box('Milkee Project Setup');
|
|
155
|
+
consola.info('This will set up your project as a Milkee project.');
|
|
156
|
+
consola.info('');
|
|
157
|
+
consola.info('The following actions will be performed:');
|
|
158
|
+
pkgPath = path.join(CWD, 'package.json');
|
|
159
|
+
if (!fs.existsSync(pkgPath)) {
|
|
160
|
+
consola.info(' 0. Initialize package.json (npm init)');
|
|
161
|
+
}
|
|
162
|
+
consola.info(' 1. Install dependencies (coffeescript, milkee)');
|
|
163
|
+
consola.info(' 2. Create template files:');
|
|
164
|
+
for (i = 0, len = TEMPLATES.length; i < len; i++) {
|
|
165
|
+
template = TEMPLATES[i];
|
|
166
|
+
consola.info(` - ${template.dest}`);
|
|
167
|
+
}
|
|
168
|
+
consola.info(' 3. Update package.json (main, scripts, keywords)');
|
|
169
|
+
consola.info(' 4. Generate README.md');
|
|
170
|
+
consola.info('');
|
|
171
|
+
// Confirm before proceeding (skip prompt in non-interactive environments)
|
|
172
|
+
if (process.stdin && !process.stdin.isTTY) {
|
|
173
|
+
confirmed = true;
|
|
174
|
+
} else {
|
|
175
|
+
confirmed = (await confirmContinue());
|
|
176
|
+
}
|
|
177
|
+
if (!confirmed) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
consola.info('');
|
|
181
|
+
// Initialize package.json if not exists
|
|
182
|
+
if (!initPackageJson()) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
// Install dependencies
|
|
187
|
+
consola.start('Installing dependencies...');
|
|
188
|
+
execSync('npm install -D coffeescript milkee', {
|
|
189
|
+
cwd: CWD,
|
|
190
|
+
stdio: 'inherit'
|
|
191
|
+
});
|
|
192
|
+
consola.success('Dependencies installed!');
|
|
193
|
+
} catch (error1) {
|
|
194
|
+
error = error1;
|
|
195
|
+
consola.error('Failed to install dependencies:', error);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
consola.info('');
|
|
199
|
+
// Create template files
|
|
200
|
+
consola.start('Creating template files...');
|
|
201
|
+
for (j = 0, len1 = TEMPLATES.length; j < len1; j++) {
|
|
202
|
+
template = TEMPLATES[j];
|
|
203
|
+
destPath = path.join(CWD, template.dest);
|
|
204
|
+
if (fs.existsSync(destPath)) {
|
|
205
|
+
overwrite = (await consola.prompt(`${template.dest} already exists. Overwrite?`, {
|
|
206
|
+
type: 'confirm'
|
|
207
|
+
}));
|
|
208
|
+
if (!overwrite) {
|
|
209
|
+
consola.info(`Skipped \`${template.dest}\``);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
copyTemplate(template.src, template.dest);
|
|
214
|
+
}
|
|
215
|
+
consola.info('');
|
|
216
|
+
// Update package.json
|
|
217
|
+
consola.start('Updating package.json...');
|
|
218
|
+
updatePackageJson();
|
|
219
|
+
consola.info('');
|
|
220
|
+
// Generate README.md
|
|
221
|
+
readmePath = path.join(CWD, 'README.md');
|
|
222
|
+
if (fs.existsSync(readmePath)) {
|
|
223
|
+
overwrite = (await consola.prompt('README.md already exists. Overwrite?', {
|
|
224
|
+
type: 'confirm'
|
|
225
|
+
}));
|
|
226
|
+
if (overwrite) {
|
|
227
|
+
generateReadme();
|
|
228
|
+
} else {
|
|
229
|
+
consola.info('Skipped `README.md`');
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
generateReadme();
|
|
46
233
|
}
|
|
234
|
+
consola.info('');
|
|
235
|
+
consola.success('Milkee project setup complete!');
|
|
236
|
+
consola.info('');
|
|
237
|
+
consola.info('Next steps:');
|
|
238
|
+
consola.info(' 1. Edit `src/main.coffee` to implement your code');
|
|
239
|
+
consola.info(' 2. Run `npm run build` to compile');
|
|
240
|
+
return consola.info(' 3. Test your project locally');
|
|
47
241
|
};
|
|
48
242
|
|
|
49
243
|
module.exports = setup;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "milkee",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "A simple CoffeeScript build tool with coffee.config.cjs",
|
|
3
|
+
"version": "3.3.0-dev.0",
|
|
4
|
+
"description": "A simple CoffeeScript build tool with coffee.config.cjs ☕",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"milkee": "bin/milkee.js"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log "Hello World!"
|
|
File without changes
|