milkee 2.4.0-dev.0 → 2.4.0-dev.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 +3 -3
- package/package.json +1 -1
- package/temp/plugin/_gitattributes +2 -0
- package/temp/plugin/_gitignore +2 -0
- package/temp/plugin/_npmignore +4 -0
- package/temp/plugin/coffee.config.cjs +35 -0
- package/docs/PLUGIN-ja.md +0 -143
- package/docs/PLUGIN.md +0 -143
package/dist/commands/plugin.js
CHANGED
|
@@ -30,15 +30,15 @@ TEMPLATES = [
|
|
|
30
30
|
dest: '.github/workflows/publish.yml'
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
src: '
|
|
33
|
+
src: '_gitignore',
|
|
34
34
|
dest: '.gitignore'
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
src: '
|
|
37
|
+
src: '_gitattributes',
|
|
38
38
|
dest: '.gitattributes'
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
src: '
|
|
41
|
+
src: '_npmignore',
|
|
42
42
|
dest: '.npmignore'
|
|
43
43
|
}
|
|
44
44
|
];
|
package/package.json
CHANGED
|
@@ -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
|
+
};
|
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
|
-
```
|