milkee 3.3.0 → 4.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # Milkee
2
2
 
3
3
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
4
- [![Vitest](https://github.com/otoneko1102/coffeescript-milkee/actions/workflows/test.yml/badge.svg)](https://github.com/otoneko1102/coffeescript-milkee/actions)
4
+ [![Vitest](https://github.com/otnc/coffeescript-milkee/actions/workflows/test.yml/badge.svg)](https://github.com/otnc/coffeescript-milkee/actions)
5
5
  [![npm version](https://img.shields.io/npm/v/milkee.svg)](https://www.npmjs.com/package/milkee)
6
6
  [![Downloads](https://img.shields.io/npm/dw/milkee.svg)](https://www.npmjs.com/package/milkee)
7
7
  [![License](https://img.shields.io/npm/l/milkee.svg)](./LICENSE)
@@ -21,11 +21,18 @@
21
21
  Milkee をインストールします:
22
22
 
23
23
  ```bash
24
- # グローバルインストール
24
+ # npm
25
25
  npm i -g milkee
26
-
27
- # ローカルインストール
26
+ # pnpm
27
+ pnpm add -g milkee
28
+ # yarn
29
+ yarn global add milkee
30
+ # bun
31
+ bun add -g milkee
32
+
33
+ # ローカルインストールの場合
28
34
  npm i -D milkee
35
+ pnpm add -D milkee
29
36
  ```
30
37
 
31
38
  CoffeeScript と `@babel/core` が必要です。
@@ -82,6 +89,9 @@ module.exports = {
82
89
  },
83
90
  // (任意) Milkee ビルダーの追加オプション / プラグイン。
84
91
  milkee: {
92
+ // 使用するパッケージマネージャー。ロックファイルや package.json から自動検出されます。
93
+ // 対応: 'npm' | 'pnpm' | 'yarn' | 'bun' | 'aube' | 'nub' | 'vlt' | 'bower'
94
+ // packageManager: 'npm',
85
95
  options: {
86
96
  // アップデート通知を無視します。
87
97
  // ignoreUpdate: false,
@@ -114,6 +124,19 @@ module.exports = {
114
124
 
115
125
  [CoffeeScript - command.coffee](https://coffeescript.org/annotated-source/command.html)
116
126
 
127
+ ##### `milkee.packageManager` (パッケージマネージャー)
128
+
129
+ Milkee はロックファイルや `package.json` の `packageManager` フィールドからパッケージマネージャーを自動検出します。明示的に指定することもできます。
130
+
131
+ | 検出元 | 優先度 |
132
+ | :--- | :--- |
133
+ | `coffee.config.cjs` の `milkee.packageManager` | 1位(最高) |
134
+ | `package.json` の `packageManager` フィールド | 2位 |
135
+ | ロックファイル(`pnpm-lock.yaml`、`yarn.lock`、`bun.lockb`、`vlt-lock.json`、`bower.json`) | 3位 |
136
+ | デフォルト | `npm` |
137
+
138
+ 対応する値: `'npm'` `'pnpm'` `'yarn'` `'bun'` `'aube'` `'nub'` `'vlt'` `'bower'`
139
+
117
140
  ##### `milkee.options` (Milkee 固有オプション)
118
141
 
119
142
  これらのオプションは Milkee の動作を制御します。
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Milkee
2
2
 
3
3
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
4
- [![Vitest](https://github.com/otoneko1102/coffeescript-milkee/actions/workflows/test.yml/badge.svg)](https://github.com/otoneko1102/coffeescript-milkee/actions)
4
+ [![Vitest](https://github.com/otnc/coffeescript-milkee/actions/workflows/test.yml/badge.svg)](https://github.com/otnc/coffeescript-milkee/actions)
5
5
  [![npm version](https://img.shields.io/npm/v/milkee.svg)](https://www.npmjs.com/package/milkee)
6
6
  [![Downloads](https://img.shields.io/npm/dw/milkee.svg)](https://www.npmjs.com/package/milkee)
7
7
  [![License](https://img.shields.io/npm/l/milkee.svg)](./LICENSE)
@@ -21,11 +21,18 @@ Official site: https://milkee.org
21
21
  Install Milkee:
22
22
 
23
23
  ```bash
24
- # global installation
24
+ # npm
25
25
  npm i -g milkee
26
+ # pnpm
27
+ pnpm add -g milkee
28
+ # yarn
29
+ yarn global add milkee
30
+ # bun
31
+ bun add -g milkee
26
32
 
27
33
  # or local installation
28
34
  npm i -D milkee
35
+ pnpm add -D milkee
29
36
  ```
30
37
 
31
38
  CoffeeScript & @babel/core are required.
@@ -82,6 +89,9 @@ module.exports = {
82
89
  },
83
90
  // (Optional) Additional options/plugins for the Milkee builder.
84
91
  milkee: {
92
+ // Package manager used in this project. Auto-detected from lock files and package.json.
93
+ // Supported: 'npm' | 'pnpm' | 'yarn' | 'bun' | 'aube' | 'nub' | 'vlt' | 'bower'
94
+ // packageManager: 'npm',
85
95
  options: {
86
96
  // Ignore update notifications.
87
97
  // ignoreUpdate: false,
@@ -114,6 +124,19 @@ These options are passed directly to the `coffee` compiler.
114
124
 
115
125
  [CoffeeScript - command.coffee](https://coffeescript.org/annotated-source/command.html)
116
126
 
127
+ ##### `milkee.packageManager` (Package Manager)
128
+
129
+ Milkee auto-detects the package manager from lock files and the `packageManager` field in `package.json`. You can override it explicitly.
130
+
131
+ | Detection source | Priority |
132
+ | :--- | :--- |
133
+ | `milkee.packageManager` in `coffee.config.cjs` | 1st (highest) |
134
+ | `packageManager` field in `package.json` | 2nd |
135
+ | Lock file (`pnpm-lock.yaml`, `yarn.lock`, `bun.lockb`, `vlt-lock.json`, `bower.json`) | 3rd |
136
+ | Default | `npm` |
137
+
138
+ Supported values: `'npm'` `'pnpm'` `'yarn'` `'bun'` `'aube'` `'nub'` `'vlt'` `'bower'`
139
+
117
140
  ##### `milkee.options` (Milkee Specific Options)
118
141
 
119
142
  These options control Milkee's behavior.
@@ -1,5 +1,5 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
- var CONFIG_FILE, CONFIG_PATH, CWD, checkCoffee, checkLatest, checkVersion, clearBackups, compile, confirmContinue, consola, crypto, exec, executeCopy, executeRefresh, fs, path, restoreBackups, runPlugins, spawn;
2
+ var CONFIG_FILE, CONFIG_PATH, CWD, checkCoffee, checkLatest, checkVersion, clearBackups, compile, confirmContinue, consola, crypto, detectPackageManager, exec, executeCopy, executeRefresh, fs, getInstallCommand, path, restoreBackups, runPlugins, spawn;
3
3
 
4
4
  fs = require('fs');
5
5
 
@@ -17,6 +17,8 @@ consola = require('consola');
17
17
 
18
18
  ({runPlugins} = require('../lib/plugins'));
19
19
 
20
+ ({detectPackageManager, getInstallCommand} = require('../lib/package-manager'));
21
+
20
22
  confirmContinue = require('../options/confirm');
21
23
 
22
24
  ({executeRefresh, restoreBackups, clearBackups} = require('../options/refresh'));
@@ -24,10 +26,13 @@ confirmContinue = require('../options/confirm');
24
26
  executeCopy = require('../options/copy');
25
27
 
26
28
  // async
27
- checkVersion = async function() {
28
- var action, cl, installCmd;
29
+ checkVersion = async function(config) {
30
+ var action, cl, globalCmd, installCmd, localCmd, pm;
29
31
  cl = (await checkLatest());
30
32
  if (cl) {
33
+ pm = detectPackageManager(CWD, config);
34
+ globalCmd = getInstallCommand(pm, 'milkee@latest', false, true);
35
+ localCmd = getInstallCommand(pm, 'milkee@latest', true, false);
31
36
  action = (await consola.prompt('Do you want to update now?', {
32
37
  type: 'select',
33
38
  options: [
@@ -39,17 +44,17 @@ checkVersion = async function() {
39
44
  {
40
45
  label: 'Yes (Global)',
41
46
  value: 'global',
42
- hint: 'npm i -g milkee@latest'
47
+ hint: globalCmd
43
48
  },
44
49
  {
45
50
  label: 'Yes (Local)',
46
51
  value: 'local',
47
- hint: 'npm i -D milkee@latest'
52
+ hint: localCmd
48
53
  }
49
54
  ]
50
55
  }));
51
56
  if (action && action !== 'skip') {
52
- installCmd = action === 'global' ? 'npm i -g milkee@latest' : 'npm i -D milkee@latest';
57
+ installCmd = action === 'global' ? globalCmd : localCmd;
53
58
  consola.start('Updating milkee...');
54
59
  await new Promise(function(resolve) {
55
60
  var cp;
@@ -88,7 +93,7 @@ compile = async function() {
88
93
  milkee = config.milkee || {};
89
94
  milkeeOptions = config.milkee.options || {};
90
95
  if (!milkeeOptions.ignoreUpdate) {
91
- await checkVersion();
96
+ await checkVersion(config);
92
97
  }
93
98
  execCommandParts = ['coffee'];
94
99
  if (options.join) {
@@ -1,5 +1,5 @@
1
1
  // Generated by CoffeeScript 2.7.0
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,
2
+ var CONFIG_FILE, CWD, DOCS, DOCS_DIR, PLUGIN_KEYWORDS, TEMPLATES, TEMPLATE_DIR, confirmContinue, consola, copyDocs, copyTemplate, detectPackageManager, ensureDir, execSync, fs, generateReadme, getCiSetupStep, getInitCommand, getInstallCommand, getInstallFrozenCommand, getRunCommand, initPackageJson, path, plugin, updatePackageJson,
3
3
  indexOf = [].indexOf;
4
4
 
5
5
  fs = require('fs');
@@ -12,6 +12,8 @@ consola = require('consola');
12
12
 
13
13
  ({CWD, CONFIG_FILE} = require('../lib/constants'));
14
14
 
15
+ ({detectPackageManager, getInstallCommand, getInitCommand, getRunCommand, getInstallFrozenCommand, getCiSetupStep} = require('../lib/package-manager'));
16
+
15
17
  confirmContinue = require('../options/confirm');
16
18
 
17
19
  TEMPLATE_DIR = path.join(__dirname, '..', '..', 'temp', 'plugin');
@@ -68,8 +70,8 @@ ensureDir = function(filePath) {
68
70
  };
69
71
 
70
72
  // Copy template file
71
- copyTemplate = function(src, dest) {
72
- var content, destPath, srcPath;
73
+ copyTemplate = function(src, dest, replacements = {}) {
74
+ var content, destPath, key, srcPath, value;
73
75
  srcPath = path.join(TEMPLATE_DIR, src);
74
76
  destPath = path.join(CWD, dest);
75
77
  if (!fs.existsSync(srcPath)) {
@@ -78,6 +80,10 @@ copyTemplate = function(src, dest) {
78
80
  }
79
81
  ensureDir(destPath);
80
82
  content = fs.readFileSync(srcPath, 'utf-8');
83
+ for (key in replacements) {
84
+ value = replacements[key];
85
+ content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), value);
86
+ }
81
87
  fs.writeFileSync(destPath, content);
82
88
  consola.success(`Created \`${dest}\``);
83
89
  return true;
@@ -138,13 +144,13 @@ updatePackageJson = function() {
138
144
  };
139
145
 
140
146
  // Initialize package.json if not exists
141
- initPackageJson = function() {
147
+ initPackageJson = function(pm) {
142
148
  var error, pkgPath;
143
149
  pkgPath = path.join(CWD, 'package.json');
144
150
  if (!fs.existsSync(pkgPath)) {
145
151
  consola.start('Initializing package.json...');
146
152
  try {
147
- execSync('npm init', {
153
+ execSync(getInitCommand(pm), {
148
154
  cwd: CWD,
149
155
  stdio: 'inherit'
150
156
  });
@@ -159,7 +165,7 @@ initPackageJson = function() {
159
165
  };
160
166
 
161
167
  // Generate README.md
162
- generateReadme = function() {
168
+ generateReadme = function(pm) {
163
169
  var description, error, name, pkg, pkgPath, readme, readmePath, templatePath;
164
170
  pkgPath = path.join(CWD, 'package.json');
165
171
  readmePath = path.join(CWD, 'README.md');
@@ -187,14 +193,15 @@ generateReadme = function() {
187
193
 
188
194
  // Main plugin setup function
189
195
  plugin = async function() {
190
- var confirmed, destPath, doc, error, i, j, k, l, len, len1, len2, len3, overwrite, pkgPath, readmePath, template;
196
+ var confirmed, destPath, doc, error, i, j, k, l, len, len1, len2, len3, overwrite, pkgPath, pm, readmePath, replacements, template;
197
+ pm = detectPackageManager(CWD);
191
198
  consola.box('Milkee Plugin Setup');
192
199
  consola.info('This will set up your project as a Milkee plugin.');
193
200
  consola.info('');
194
201
  consola.info('The following actions will be performed:');
195
202
  pkgPath = path.join(CWD, 'package.json');
196
203
  if (!fs.existsSync(pkgPath)) {
197
- consola.info(' 0. Initialize package.json (npm init)');
204
+ consola.info(` 0. Initialize package.json (${getInitCommand(pm)})`);
198
205
  }
199
206
  consola.info(' 1. Install dependencies (consola, coffeescript, milkee)');
200
207
  consola.info(' 2. Create template files:');
@@ -217,17 +224,17 @@ plugin = async function() {
217
224
  }
218
225
  consola.info('');
219
226
  // Initialize package.json if not exists
220
- if (!initPackageJson()) {
227
+ if (!initPackageJson(pm)) {
221
228
  return;
222
229
  }
223
230
  try {
224
231
  // Install dependencies
225
232
  consola.start('Installing dependencies...');
226
- execSync('npm install consola', {
233
+ execSync(getInstallCommand(pm, 'consola'), {
227
234
  cwd: CWD,
228
235
  stdio: 'inherit'
229
236
  });
230
- execSync('npm install -D coffeescript milkee', {
237
+ execSync(getInstallCommand(pm, 'coffeescript milkee', true), {
231
238
  cwd: CWD,
232
239
  stdio: 'inherit'
233
240
  });
@@ -252,7 +259,24 @@ plugin = async function() {
252
259
  continue;
253
260
  }
254
261
  }
255
- copyTemplate(template.src, template.dest);
262
+ replacements = (function() {
263
+ switch (template.src) {
264
+ case 'coffee.config.cjs':
265
+ return {
266
+ packageManager: pm
267
+ };
268
+ case 'publish.yml':
269
+ return {
270
+ setupPmStep: getCiSetupStep(pm),
271
+ installFrozen: getInstallFrozenCommand(pm),
272
+ runBuild: getRunCommand(pm, 'build'),
273
+ runTest: getRunCommand(pm, 'test')
274
+ };
275
+ default:
276
+ return {};
277
+ }
278
+ })();
279
+ copyTemplate(template.src, template.dest, replacements);
256
280
  }
257
281
  consola.info('');
258
282
  // Copy docs
@@ -283,19 +307,19 @@ plugin = async function() {
283
307
  type: 'confirm'
284
308
  }));
285
309
  if (overwrite) {
286
- generateReadme();
310
+ generateReadme(pm);
287
311
  } else {
288
312
  consola.info('Skipped `README.md`');
289
313
  }
290
314
  } else {
291
- generateReadme();
315
+ generateReadme(pm);
292
316
  }
293
317
  consola.info('');
294
318
  consola.success('Milkee plugin setup complete!');
295
319
  consola.info('');
296
320
  consola.info('Next steps:');
297
321
  consola.info(' 1. Edit `src/main.coffee` to implement your plugin');
298
- consola.info(' 2. Run `npm run build` to compile');
322
+ consola.info(` 2. Run \`${getRunCommand(pm, 'build')}\` to compile`);
299
323
  return consola.info(' 3. Test your plugin locally');
300
324
  };
301
325
 
@@ -1,5 +1,5 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
- var CONFIG_FILE, CWD, SETUP_KEYWORDS, TEMPLATES, TEMPLATE_DIR, confirmContinue, consola, copyTemplate, ensureDir, execSync, fs, generateReadme, initPackageJson, path, setup, updatePackageJson,
2
+ var CONFIG_FILE, CWD, SETUP_KEYWORDS, TEMPLATES, TEMPLATE_DIR, confirmContinue, consola, copyTemplate, detectPackageManager, ensureDir, execSync, fs, generateReadme, getInitCommand, getInstallCommand, getRunCommand, initPackageJson, path, setup, updatePackageJson,
3
3
  indexOf = [].indexOf;
4
4
 
5
5
  fs = require('fs');
@@ -12,6 +12,8 @@ consola = require('consola');
12
12
 
13
13
  ({CWD, CONFIG_FILE} = require('../lib/constants'));
14
14
 
15
+ ({detectPackageManager, getInstallCommand, getInitCommand, getRunCommand} = require('../lib/package-manager'));
16
+
15
17
  confirmContinue = require('../options/confirm');
16
18
 
17
19
  TEMPLATE_DIR = path.join(__dirname, '..', '..', 'temp', 'setup');
@@ -47,8 +49,8 @@ ensureDir = function(filePath) {
47
49
  };
48
50
 
49
51
  // Copy template file
50
- copyTemplate = function(src, dest) {
51
- var content, destPath, srcPath;
52
+ copyTemplate = function(src, dest, replacements = {}) {
53
+ var content, destPath, key, srcPath, value;
52
54
  srcPath = path.join(TEMPLATE_DIR, src);
53
55
  destPath = path.join(CWD, dest);
54
56
  if (!fs.existsSync(srcPath)) {
@@ -57,6 +59,10 @@ copyTemplate = function(src, dest) {
57
59
  }
58
60
  ensureDir(destPath);
59
61
  content = fs.readFileSync(srcPath, 'utf-8');
62
+ for (key in replacements) {
63
+ value = replacements[key];
64
+ content = content.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), value);
65
+ }
60
66
  fs.writeFileSync(destPath, content);
61
67
  consola.success(`Created \`${dest}\``);
62
68
  return true;
@@ -101,13 +107,13 @@ updatePackageJson = function() {
101
107
  };
102
108
 
103
109
  // Initialize package.json if not exists
104
- initPackageJson = function() {
110
+ initPackageJson = function(pm) {
105
111
  var error, pkgPath;
106
112
  pkgPath = path.join(CWD, 'package.json');
107
113
  if (!fs.existsSync(pkgPath)) {
108
114
  consola.start('Initializing package.json...');
109
115
  try {
110
- execSync('npm init', {
116
+ execSync(getInitCommand(pm), {
111
117
  cwd: CWD,
112
118
  stdio: 'inherit'
113
119
  });
@@ -122,7 +128,7 @@ initPackageJson = function() {
122
128
  };
123
129
 
124
130
  // Generate README.md
125
- generateReadme = function() {
131
+ generateReadme = function(pm) {
126
132
  var description, error, name, pkg, pkgPath, readme, readmePath, templatePath;
127
133
  pkgPath = path.join(CWD, 'package.json');
128
134
  readmePath = path.join(CWD, 'README.md');
@@ -138,6 +144,7 @@ generateReadme = function() {
138
144
  readme = fs.readFileSync(templatePath, 'utf-8');
139
145
  readme = readme.replace(/\{\{name\}\}/g, name);
140
146
  readme = readme.replace(/\{\{description\}\}/g, description);
147
+ readme = readme.replace(/\{\{runBuild\}\}/g, getRunCommand(pm, 'build'));
141
148
  fs.writeFileSync(readmePath, readme);
142
149
  consola.success('Created `README.md`');
143
150
  return true;
@@ -150,14 +157,15 @@ generateReadme = function() {
150
157
 
151
158
  // Main setup function
152
159
  setup = async function() {
153
- var confirmed, destPath, error, i, j, len, len1, overwrite, pkgPath, readmePath, template;
160
+ var confirmed, destPath, error, i, j, len, len1, overwrite, pkgPath, pm, readmePath, replacements, template;
161
+ pm = detectPackageManager(CWD);
154
162
  consola.box('Milkee Project Setup');
155
163
  consola.info('This will set up your project as a Milkee project.');
156
164
  consola.info('');
157
165
  consola.info('The following actions will be performed:');
158
166
  pkgPath = path.join(CWD, 'package.json');
159
167
  if (!fs.existsSync(pkgPath)) {
160
- consola.info(' 0. Initialize package.json (npm init)');
168
+ consola.info(` 0. Initialize package.json (${getInitCommand(pm)})`);
161
169
  }
162
170
  consola.info(' 1. Install dependencies (coffeescript, milkee)');
163
171
  consola.info(' 2. Create template files:');
@@ -179,13 +187,13 @@ setup = async function() {
179
187
  }
180
188
  consola.info('');
181
189
  // Initialize package.json if not exists
182
- if (!initPackageJson()) {
190
+ if (!initPackageJson(pm)) {
183
191
  return;
184
192
  }
185
193
  try {
186
194
  // Install dependencies
187
195
  consola.start('Installing dependencies...');
188
- execSync('npm install -D coffeescript milkee', {
196
+ execSync(getInstallCommand(pm, 'coffeescript milkee', true), {
189
197
  cwd: CWD,
190
198
  stdio: 'inherit'
191
199
  });
@@ -210,7 +218,10 @@ setup = async function() {
210
218
  continue;
211
219
  }
212
220
  }
213
- copyTemplate(template.src, template.dest);
221
+ replacements = template.src === 'coffee.config.cjs' ? {
222
+ packageManager: pm
223
+ } : {};
224
+ copyTemplate(template.src, template.dest, replacements);
214
225
  }
215
226
  consola.info('');
216
227
  // Update package.json
@@ -224,19 +235,19 @@ setup = async function() {
224
235
  type: 'confirm'
225
236
  }));
226
237
  if (overwrite) {
227
- generateReadme();
238
+ generateReadme(pm);
228
239
  } else {
229
240
  consola.info('Skipped `README.md`');
230
241
  }
231
242
  } else {
232
- generateReadme();
243
+ generateReadme(pm);
233
244
  }
234
245
  consola.info('');
235
246
  consola.success('Milkee project setup complete!');
236
247
  consola.info('');
237
248
  consola.info('Next steps:');
238
249
  consola.info(' 1. Edit `src/main.coffee` to implement your code');
239
- consola.info(' 2. Run `npm run build` to compile');
250
+ consola.info(` 2. Run \`${getRunCommand(pm, 'build')}\` to compile`);
240
251
  return consola.info(' 3. Test your project locally');
241
252
  };
242
253
 
@@ -1,5 +1,5 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
- var CWD, checkCoffee, checkLatest, consola, exec, fs, isPackageLatest, path, pkg;
2
+ var CWD, checkCoffee, checkLatest, consola, detectPackageManager, exec, fs, getInstallCommand, isPackageLatest, path, pkg;
3
3
 
4
4
  fs = require('fs');
5
5
 
@@ -13,15 +13,20 @@ consola = require('consola');
13
13
 
14
14
  ({pkg, CWD} = require('./constants'));
15
15
 
16
+ ({detectPackageManager, getInstallCommand} = require('./package-manager'));
17
+
16
18
  // async
17
19
  checkLatest = async function() {
18
- var res;
20
+ var globalCmd, localCmd, pm, res;
19
21
  try {
20
22
  res = (await isPackageLatest(pkg));
21
23
  if (res.success && !res.isLatest) {
24
+ pm = detectPackageManager(CWD);
25
+ globalCmd = getInstallCommand(pm, 'milkee@latest', false, true);
26
+ localCmd = getInstallCommand(pm, 'milkee@latest', true, false);
22
27
  consola.box({
23
28
  title: 'A new version is now available!',
24
- message: `${res.currentVersion} --> \`${res.latestVersion}\`\n\n# global installation\n\`npm i -g milkee@latest\`\n# or local installation\n\`npm i -D milkee@latest\``
29
+ message: `${res.currentVersion} --> \`${res.latestVersion}\`\n\n# global installation\n\`${globalCmd}\`\n# or local installation\n\`${localCmd}\``
25
30
  });
26
31
  return true;
27
32
  } else {
@@ -48,9 +53,12 @@ checkCoffee = function() {
48
53
  }
49
54
  }
50
55
  return exec('coffee --version', function(error) {
56
+ var installCmd, pm;
51
57
  if (error) {
58
+ pm = detectPackageManager(CWD);
59
+ installCmd = getInstallCommand(pm, 'coffeescript', true);
52
60
  consola.warn('CoffeeScript is not found in local dependencies (`dependencies`, `devDependencies`) or globally.');
53
- return consola.info('Please install it via `npm install --save-dev coffeescript` to continue.');
61
+ return consola.info(`Please install it via \`${installCmd}\` to continue.`);
54
62
  }
55
63
  });
56
64
  };
@@ -0,0 +1,184 @@
1
+ // Generated by CoffeeScript 2.7.0
2
+ var SUPPORTED, detectPackageManager, fs, getCiSetupStep, getInitCommand, getInstallCommand, getInstallFrozenCommand, getRunCommand, path,
3
+ indexOf = [].indexOf;
4
+
5
+ fs = require('fs');
6
+
7
+ path = require('path');
8
+
9
+ SUPPORTED = ['npm', 'pnpm', 'yarn', 'bun', 'aube', 'nub', 'vlt', 'bower'];
10
+
11
+ detectPackageManager = function(cwd, config = null) {
12
+ var name, pkg, pkgPath, pm, ref;
13
+ if (config != null ? (ref = config.milkee) != null ? ref.packageManager : void 0 : void 0) {
14
+ pm = config.milkee.packageManager;
15
+ if (indexOf.call(SUPPORTED, pm) >= 0) {
16
+ return pm;
17
+ }
18
+ }
19
+ pkgPath = path.join(cwd, 'package.json');
20
+ if (fs.existsSync(pkgPath)) {
21
+ try {
22
+ pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
23
+ if (pkg.packageManager) {
24
+ name = pkg.packageManager.split('@')[0].trim();
25
+ if (indexOf.call(SUPPORTED, name) >= 0) {
26
+ return name;
27
+ }
28
+ }
29
+ } catch (error) {
30
+
31
+ }
32
+ }
33
+ if (fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))) {
34
+ return 'pnpm';
35
+ }
36
+ if (fs.existsSync(path.join(cwd, 'yarn.lock'))) {
37
+ return 'yarn';
38
+ }
39
+ if (fs.existsSync(path.join(cwd, 'bun.lockb')) || fs.existsSync(path.join(cwd, 'bun.lock'))) {
40
+ return 'bun';
41
+ }
42
+ if (fs.existsSync(path.join(cwd, 'vlt-lock.json'))) {
43
+ return 'vlt';
44
+ }
45
+ if (fs.existsSync(path.join(cwd, 'bower.json'))) {
46
+ return 'bower';
47
+ }
48
+ return 'npm';
49
+ };
50
+
51
+ getInstallCommand = function(pm, packages, dev = false, global = false) {
52
+ var flag;
53
+ switch (pm) {
54
+ case 'pnpm':
55
+ flag = global ? ' -g' : dev ? ' -D' : '';
56
+ return `pnpm add${flag} ${packages}`;
57
+ case 'yarn':
58
+ if (global) {
59
+ return `yarn global add ${packages}`;
60
+ } else {
61
+ flag = dev ? ' -D' : '';
62
+ return `yarn add${flag} ${packages}`;
63
+ }
64
+ break;
65
+ case 'bun':
66
+ flag = global ? ' -g' : dev ? ' -D' : '';
67
+ return `bun add${flag} ${packages}`;
68
+ case 'aube':
69
+ flag = global ? ' -g' : dev ? ' -D' : '';
70
+ return `aube add${flag} ${packages}`;
71
+ case 'nub':
72
+ if (global) {
73
+ return `npm i -g ${packages}`;
74
+ } else {
75
+ flag = dev ? ' -D' : '';
76
+ return `nub add${flag} ${packages}`;
77
+ }
78
+ break;
79
+ case 'vlt':
80
+ if (global) {
81
+ return `npm i -g ${packages}`;
82
+ } else {
83
+ flag = dev ? ' --save-dev' : '';
84
+ return `vlt install${flag} ${packages}`;
85
+ }
86
+ break;
87
+ case 'bower':
88
+ if (global) {
89
+ return `npm i -g ${packages}`;
90
+ } else {
91
+ flag = dev ? ' --save-dev' : ' --save';
92
+ return `bower install ${packages}${flag}`;
93
+ }
94
+ break;
95
+ default:
96
+ if (global) {
97
+ return `npm i -g ${packages}`;
98
+ } else {
99
+ flag = dev ? ' -D' : '';
100
+ return `npm install${flag} ${packages}`;
101
+ }
102
+ }
103
+ };
104
+
105
+ getInitCommand = function(pm) {
106
+ switch (pm) {
107
+ case 'pnpm':
108
+ return 'pnpm init';
109
+ case 'yarn':
110
+ return 'yarn init';
111
+ case 'bun':
112
+ return 'bun init';
113
+ case 'aube':
114
+ return 'aube init';
115
+ case 'nub':
116
+ return 'nub install';
117
+ case 'vlt':
118
+ return 'vlt init';
119
+ case 'bower':
120
+ return 'bower init';
121
+ default:
122
+ return 'npm init';
123
+ }
124
+ };
125
+
126
+ getRunCommand = function(pm, script) {
127
+ switch (pm) {
128
+ case 'pnpm':
129
+ return `pnpm ${script}`;
130
+ case 'yarn':
131
+ return `yarn ${script}`;
132
+ case 'bun':
133
+ return `bun run ${script}`;
134
+ case 'aube':
135
+ return `aube run ${script}`;
136
+ case 'nub':
137
+ return `nub run ${script}`;
138
+ case 'vlt':
139
+ return `vlt run ${script}`;
140
+ case 'bower':
141
+ return `npm run ${script}`;
142
+ default:
143
+ return `npm run ${script}`;
144
+ }
145
+ };
146
+
147
+ getInstallFrozenCommand = function(pm) {
148
+ switch (pm) {
149
+ case 'pnpm':
150
+ return 'pnpm install --frozen-lockfile';
151
+ case 'yarn':
152
+ return 'yarn install --frozen-lockfile';
153
+ case 'bun':
154
+ return 'bun install';
155
+ case 'aube':
156
+ return 'aube install --frozen-lockfile';
157
+ case 'nub':
158
+ return 'nub ci';
159
+ case 'vlt':
160
+ return 'vlt install --frozen-lockfile';
161
+ default:
162
+ return 'npm ci';
163
+ }
164
+ };
165
+
166
+ // Returns an extra YAML step block (with leading newline) for CI setup, or empty string.
167
+ getCiSetupStep = function(pm) {
168
+ switch (pm) {
169
+ case 'pnpm':
170
+ return `
171
+ - name: Setup pnpm
172
+ uses: pnpm/action-setup@v4
173
+ with:
174
+ run_install: false`;
175
+ case 'bun':
176
+ return `
177
+ - name: Setup Bun
178
+ uses: oven-sh/setup-bun@v2`;
179
+ default:
180
+ return '';
181
+ }
182
+ };
183
+
184
+ module.exports = {SUPPORTED, detectPackageManager, getInstallCommand, getInitCommand, getRunCommand, getInstallFrozenCommand, getCiSetupStep};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milkee",
3
- "version": "3.3.0",
3
+ "version": "4.0.0",
4
4
  "description": "A simple CoffeeScript build tool with coffee.config.cjs ☕",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "git+https://github.com/otoneko1102/coffeescript-milkee.git"
20
+ "url": "git+https://github.com/otnc/coffeescript-milkee.git"
21
21
  },
22
22
  "keywords": [
23
23
  "coffee",
@@ -33,25 +33,28 @@
33
33
  "author": "otoneko.",
34
34
  "license": "MIT",
35
35
  "bugs": {
36
- "url": "https://github.com/otoneko1102/coffeescript-milkee/issues"
36
+ "url": "https://github.com/otnc/coffeescript-milkee/issues"
37
37
  },
38
38
  "homepage": "https://milkee.org",
39
+ "engines": {
40
+ "node": ">=20.0.0"
41
+ },
39
42
  "dependencies": {
40
- "@milkee/d": "^0.3.0",
43
+ "@milkee/d": "^0.4.0",
41
44
  "consola": "^3.4.2",
42
- "is-package-latest": "^2.0.0",
45
+ "is-package-latest": "^2.0.3",
43
46
  "yargs": "^18.0.0"
44
47
  },
45
48
  "devDependencies": {
46
- "@babel/core": "^7.28.6",
49
+ "@babel/core": "^7.29.0",
47
50
  "@types/coffeescript": "^2.5.7",
48
- "@vitest/coverage-v8": "^4.0.18",
51
+ "@vitest/coverage-v8": "^4.1.0",
49
52
  "coffee-fmt": "^0.12.0",
50
53
  "coffeescript": "^2.7.0",
51
- "dotenv": "^17.2.3",
54
+ "dotenv": "^17.3.1",
52
55
  "execa": "^9.6.1",
53
56
  "milkee-plugin-prettier": "^1.0.0",
54
- "npm-check-updates": "^19.3.1",
57
+ "npm-check-updates": "^19.6.6",
55
58
  "vitest": "^4.0.18"
56
59
  }
57
60
  }
@@ -24,6 +24,9 @@ module.exports = {
24
24
  },
25
25
  // (Optional) Additional options/plugins for the Milkee builder.
26
26
  milkee: {
27
+ // Package manager used in this project. Auto-detected, but can be overridden.
28
+ // Supported: 'npm' | 'pnpm' | 'yarn' | 'bun' | 'aube' | 'nub' | 'vlt' | 'bower'
29
+ packageManager: '{{packageManager}}',
27
30
  options: {
28
31
  // Ignore update notifications.
29
32
  // ignoreUpdate: false,
@@ -17,13 +17,13 @@ jobs:
17
17
  uses: actions/setup-node@v4
18
18
  with:
19
19
  node-version: "20.x"
20
- registry-url: "https://registry.npmjs.org"
20
+ registry-url: "https://registry.npmjs.org"{{setupPmStep}}
21
21
 
22
22
  - name: Install, Build, and Test
23
23
  run: |
24
- npm ci
25
- npm run build
26
- npm test
24
+ {{installFrozen}}
25
+ {{runBuild}}
26
+ {{runTest}}
27
27
 
28
28
  - name: Commit dist directory (if changed)
29
29
  run: |
@@ -5,5 +5,5 @@
5
5
  ## Usage
6
6
 
7
7
  ```sh
8
- npm run build
8
+ {{runBuild}}
9
9
  ```
@@ -24,6 +24,9 @@ module.exports = {
24
24
  },
25
25
  // (Optional) Additional options/plugins for the Milkee builder.
26
26
  milkee: {
27
+ // Package manager used in this project. Auto-detected, but can be overridden.
28
+ // Supported: 'npm' | 'pnpm' | 'yarn' | 'bun' | 'aube' | 'nub' | 'vlt' | 'bower'
29
+ packageManager: '{{packageManager}}',
27
30
  options: {
28
31
  // Ignore update notifications.
29
32
  // ignoreUpdate: false,