milkee 2.4.0-dev.0 → 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.
@@ -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');
@@ -30,15 +30,15 @@ TEMPLATES = [
30
30
  dest: '.github/workflows/publish.yml'
31
31
  },
32
32
  {
33
- src: '.gitignore',
33
+ src: '_gitignore',
34
34
  dest: '.gitignore'
35
35
  },
36
36
  {
37
- src: '.gitattributes',
37
+ src: '_gitattributes',
38
38
  dest: '.gitattributes'
39
39
  },
40
40
  {
41
- src: '.npmignore',
41
+ src: '_npmignore',
42
42
  dest: '.npmignore'
43
43
  }
44
44
  ];
@@ -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 -y', {
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 -y)");
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milkee",
3
- "version": "2.4.0-dev.0",
3
+ "version": "2.4.0-dev.2",
4
4
  "description": "A simple CoffeeScript build tool with coffee.config.cjs",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
@@ -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
+ ```
@@ -0,0 +1,2 @@
1
+ *.coffee linguist-language=CoffeeScript
2
+ dist/* linguist-generated
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ .env
@@ -0,0 +1,4 @@
1
+ .github/
2
+ src/
3
+ .gitattributes
4
+ coffee.config.cjs
@@ -0,0 +1,35 @@
1
+ /** @type {import('@milkee/d').Config} */
2
+
3
+ module.exports = {
4
+ // The entry point for compilation.
5
+ // This can be a single file or a directory (e.g., 'src/' or 'src/app.coffee').
6
+ entry: 'src',
7
+ // The output for the compiled JavaScript files.
8
+ // If 'options.join' is true, this should be a single file path (e.g., 'dist/app.js').
9
+ // If 'options.join' is false, this should be a directory (e.g., 'dist').
10
+ output: 'dist',
11
+ // (Optional) Additional options for the CoffeeScript compiler.
12
+ // See `coffee --help` for all available options.
13
+ // Web: https://coffeescript.org/annotated-source/command.html
14
+ options: {
15
+ // The following options are supported:
16
+ bare: true,
17
+ // join: false,
18
+ // map: false,
19
+ // inlineMap: false,
20
+ // noHeader: false,
21
+ // transpile: false,
22
+ // literate: false,
23
+ // watch: false,
24
+ },
25
+ // (Optional) Additional options/plugins for the Milkee builder.
26
+ milkee: {
27
+ options: {
28
+ // Before compiling, reset the directory.
29
+ // refresh: false,
30
+ // Before compiling, confirm "Do you want to Continue?"
31
+ // confirm: false,
32
+ },
33
+ plugins: []
34
+ },
35
+ };
@@ -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}"
package/docs/PLUGIN-ja.md DELETED
@@ -1,143 +0,0 @@
1
- # Milkee プラグインの作成
2
-
3
- カスタムプラグインで Milkee の機能を拡張できます。
4
-
5
- ## クイックスタート
6
-
7
- `-p` (`--plugin`) コマンドでプラグインプロジェクトをセットアップ:
8
-
9
- ```bash
10
- # グローバル
11
- milkee -p
12
-
13
- # ローカル
14
- npx milkee -p
15
- ```
16
-
17
- 以下が実行されます:
18
- 1. `package.json` の初期化(必要な場合)
19
- 2. 依存関係のインストール (`consola`, `coffeescript`, `milkee`)
20
- 3. テンプレートファイルの作成
21
- 4. `package.json` の更新 (`main`, `scripts`, `keywords`)
22
-
23
- ## プロジェクト構造
24
-
25
- ```
26
- your-plugin/
27
- src/
28
- main.coffee # プラグインのソース
29
- dist/
30
- main.js # コンパイル後の出力
31
- .github/
32
- workflows/
33
- publish.yml # npm公開ワークフロー
34
- coffee.config.cjs
35
- package.json
36
- ```
37
-
38
- ## プラグインの書き方
39
-
40
- ### 基本テンプレート
41
-
42
- ```coffee
43
- fs = require 'fs'
44
- path = require 'path'
45
- consola = require 'consola'
46
-
47
- pkg = require '../package.json'
48
- PREFIX = "[#{pkg.name}]"
49
-
50
- # プレフィックス付きカスタムロガー
51
- c = {}
52
- for method in ['log', 'info', 'success', 'warn', 'error', 'debug', 'start', 'box']
53
- do (method) ->
54
- c[method] = (args...) ->
55
- if typeof args[0] is 'string'
56
- args[0] = "#{PREFIX} #{args[0]}"
57
- consola[method] args...
58
-
59
- # メインプラグイン関数
60
- main = (compilationResult) ->
61
- { config, compiledFiles, stdout, stderr } = compilationResult
62
-
63
- c.info "#{compiledFiles.length} ファイルをコンパイルしました"
64
- for file in compiledFiles
65
- c.log " - #{file}"
66
-
67
- module.exports = main
68
- ```
69
-
70
- ### コンパイル結果
71
-
72
- Milkee はコンパイル後にこのオブジェクトをプラグインに渡します:
73
-
74
- | プロパティ | 型 | 説明 |
75
- | :-------------- | :--------- | :--------------------------------------------- |
76
- | `config` | `object` | `coffee.config.cjs` の設定オブジェクト |
77
- | `compiledFiles` | `string[]` | コンパイルされた `.js` と `.js.map` のパス |
78
- | `stdout` | `string` | コンパイラの標準出力 |
79
- | `stderr` | `string` | コンパイラの標準エラー |
80
-
81
- ### coffee.config.cjs での使用
82
-
83
- ```js
84
- const myPlugin = require('your-plugin-name');
85
-
86
- module.exports = {
87
- entry: 'src',
88
- output: 'dist',
89
- milkee: {
90
- plugins: [
91
- myPlugin({ customOption: 'value' }),
92
- ]
93
- }
94
- };
95
- ```
96
-
97
- ## ビルド & テスト
98
-
99
- ```bash
100
- # プラグインをビルド
101
- npm run build
102
-
103
- # ローカルテスト用にリンク
104
- npm link
105
-
106
- # 別のプロジェクトで
107
- npm link your-plugin-name
108
- ```
109
-
110
- ## 公開
111
-
112
- ### GitHub Actions を使用
113
-
114
- 同梱のワークフローで npm に手動公開:
115
-
116
- 1. リポジトリに `NPM_TOKEN` シークレットを追加
117
- 2. **Actions** → **Manual Publish to npm** に移動
118
- 3. **Run workflow** をクリック
119
-
120
- ### 手動
121
-
122
- ```bash
123
- npm run build
124
- npm publish --access public
125
- ```
126
-
127
- ## ベストプラクティス
128
-
129
- ### 命名規則 & キーワード
130
-
131
- - 名前: `milkee-plugin-xxx` または `@yourname/milkee-plugin-xxx`
132
- - キーワード(自動追加): `milkee`, `coffeescript`, `coffee`, `ext`, `plugin`, `milkee-plugin`
133
-
134
- ### エラーハンドリング
135
-
136
- ```coffee
137
- main = (compilationResult) ->
138
- try
139
- # ロジック
140
- catch error
141
- c.error "失敗:", error.message
142
- throw error
143
- ```
package/docs/PLUGIN.md DELETED
@@ -1,143 +0,0 @@
1
- # Creating a Milkee Plugin
2
-
3
- Extend Milkee's functionality with custom plugins.
4
-
5
- ## Quick Start
6
-
7
- Run `-p` (`--plugin`) command to set up your plugin project:
8
-
9
- ```bash
10
- # global
11
- milkee -p
12
-
13
- # or local
14
- npx milkee -p
15
- ```
16
-
17
- This will:
18
- 1. Initialize `package.json` (if needed)
19
- 2. Install dependencies (`consola`, `coffeescript`, `milkee`)
20
- 3. Create template files
21
- 4. Update `package.json` (`main`, `scripts`, `keywords`)
22
-
23
- ## Project Structure
24
-
25
- ```
26
- your-plugin/
27
- src/
28
- main.coffee # Your plugin source
29
- dist/
30
- main.js # Compiled output
31
- .github/
32
- workflows/
33
- publish.yml # npm publish workflow
34
- coffee.config.cjs
35
- package.json
36
- ```
37
-
38
- ## Writing Your Plugin
39
-
40
- ### Basic Template
41
-
42
- ```coffee
43
- fs = require 'fs'
44
- path = require 'path'
45
- consola = require 'consola'
46
-
47
- pkg = require '../package.json'
48
- PREFIX = "[#{pkg.name}]"
49
-
50
- # Custom logger with prefix
51
- c = {}
52
- for method in ['log', 'info', 'success', 'warn', 'error', 'debug', 'start', 'box']
53
- do (method) ->
54
- c[method] = (args...) ->
55
- if typeof args[0] is 'string'
56
- args[0] = "#{PREFIX} #{args[0]}"
57
- consola[method] args...
58
-
59
- # Main plugin function
60
- main = (compilationResult) ->
61
- { config, compiledFiles, stdout, stderr } = compilationResult
62
-
63
- c.info "Compiled #{compiledFiles.length} file(s)"
64
- for file in compiledFiles
65
- c.log " - #{file}"
66
-
67
- module.exports = main
68
- ```
69
-
70
- ### Compilation Result
71
-
72
- Milkee passes this object to your plugin after compilation:
73
-
74
- | Property | Type | Description |
75
- | :-------------- | :--------- | :--------------------------------------------- |
76
- | `config` | `object` | Full config from `coffee.config.cjs` |
77
- | `compiledFiles` | `string[]` | Paths to compiled `.js` and `.js.map` files |
78
- | `stdout` | `string` | Compiler standard output |
79
- | `stderr` | `string` | Compiler standard error |
80
-
81
- ### Using in coffee.config.cjs
82
-
83
- ```js
84
- const myPlugin = require('your-plugin-name');
85
-
86
- module.exports = {
87
- entry: 'src',
88
- output: 'dist',
89
- milkee: {
90
- plugins: [
91
- myPlugin({ customOption: 'value' }),
92
- ]
93
- }
94
- };
95
- ```
96
-
97
- ## Build & Test
98
-
99
- ```bash
100
- # Build your plugin
101
- npm run build
102
-
103
- # Link for local testing
104
- npm link
105
-
106
- # In another project
107
- npm link your-plugin-name
108
- ```
109
-
110
- ## Publishing
111
-
112
- ### Using GitHub Actions
113
-
114
- The included workflow publishes to npm manually:
115
-
116
- 1. Add `NPM_TOKEN` secret to your repository
117
- 2. Go to **Actions** → **Manual Publish to npm**
118
- 3. Click **Run workflow**
119
-
120
- ### Manual
121
-
122
- ```bash
123
- npm run build
124
- npm publish --access public
125
- ```
126
-
127
- ## Best Practices
128
-
129
- ### Naming & Keywords
130
-
131
- - Name: `milkee-plugin-xxx` or `@yourname/milkee-plugin-xxx`
132
- - Keywords (auto-added): `milkee`, `coffeescript`, `coffee`, `ext`, `plugin`, `milkee-plugin`
133
-
134
- ### Error Handling
135
-
136
- ```coffee
137
- main = (compilationResult) ->
138
- try
139
- # Your logic
140
- catch error
141
- c.error "Failed:", error.message
142
- throw error
143
- ```