milkee 0.1.0 → 0.2.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/README.md +122 -0
- package/dist/main.js +7 -6
- package/package.json +3 -2
- package/temp/{coffee.config.js → coffee.config.cjs} +1 -1
package/README.md
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
# Milkee
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
A simple CoffeeScript build tool with [coffee.config.cjs](./temp/coffee.config.cjs)
|
6
|
+
|
7
|
+
## How to get started
|
8
|
+
|
9
|
+
### Install
|
10
|
+
|
11
|
+
Install Milkee:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
# global installation
|
15
|
+
npm i -g milkee
|
16
|
+
|
17
|
+
# or local installation
|
18
|
+
npm i -D milkee
|
19
|
+
```
|
20
|
+
|
21
|
+
CoffeeScript & @babel/core are required.
|
22
|
+
|
23
|
+
> [!TIP]
|
24
|
+
> `@babel/core` is required if `options.transpile` is `true` .
|
25
|
+
|
26
|
+
```bash
|
27
|
+
# global installation
|
28
|
+
npm i -g coffeescript @babel/core
|
29
|
+
|
30
|
+
# or local installation
|
31
|
+
npm i -D coffeescript @babel/core
|
32
|
+
```
|
33
|
+
|
34
|
+
### Setup
|
35
|
+
|
36
|
+
Run `-s` (`--setup`) command, generate [coffee.config.cjs](./temp/coffee.config.cjs)!
|
37
|
+
|
38
|
+
```bash
|
39
|
+
# global
|
40
|
+
milkee -s
|
41
|
+
|
42
|
+
# or local
|
43
|
+
npx milkee -s
|
44
|
+
```
|
45
|
+
|
46
|
+
#### coffee.config.cjs
|
47
|
+
|
48
|
+
```js
|
49
|
+
/** @type {import('@milkee/d').Config} */
|
50
|
+
|
51
|
+
module.exports = {
|
52
|
+
// The entry point for compilation.
|
53
|
+
// This can be a single file or a directory (e.g., 'src/' or 'src/app.coffee').
|
54
|
+
entry: 'src',
|
55
|
+
// The output for the compiled JavaScript files.
|
56
|
+
// If 'options.join' is true, this should be a single file path (e.g., 'dist/app.js').
|
57
|
+
// If 'options.join' is false, this should be a directory (e.g., 'dist').
|
58
|
+
output: 'dist',
|
59
|
+
// (Optional) Additional options for the CoffeeScript compiler.
|
60
|
+
// See `coffee --help` for all available options.
|
61
|
+
// Web: https://coffeescript.org/annotated-source/command.html
|
62
|
+
options: {
|
63
|
+
// The following options are supported:
|
64
|
+
// bare: false,
|
65
|
+
// join: false,
|
66
|
+
// map: false,
|
67
|
+
// inlineMap: false,
|
68
|
+
// noHeader: false,
|
69
|
+
// transpile: false,
|
70
|
+
// literate: false,
|
71
|
+
// watch: false,
|
72
|
+
},
|
73
|
+
// (Optional) Additional options/plugins for the Milkee builder.
|
74
|
+
milkee: {
|
75
|
+
options: {
|
76
|
+
// Before compiling, reset the directory.
|
77
|
+
// refresh: false,
|
78
|
+
// Before compiling, confirm "Do you want to Continue?"
|
79
|
+
// confirm: false,
|
80
|
+
},
|
81
|
+
plugins: []
|
82
|
+
},
|
83
|
+
};
|
84
|
+
```
|
85
|
+
|
86
|
+
##### `options` (CoffeeScript Compiler Options)
|
87
|
+
|
88
|
+
These options are passed directly to the `coffee` compiler.
|
89
|
+
|
90
|
+
| Option | Type | Default | Description |
|
91
|
+
| :---------- | :-------- | :------ | :------------------------------------------------------ |
|
92
|
+
| `bare` | `boolean` | `false` | compile without a top-level function wrapper |
|
93
|
+
| `join` | `boolean` | `false` | concatenate the source CoffeeScript before compiling |
|
94
|
+
| `map` | `boolean` | `false` | generate source map and save as `.js.map` files |
|
95
|
+
| `inlineMap` | `boolean` | `false` | generate source map and include it directly in output |
|
96
|
+
| `noHeader` | `boolean` | `false` | suppress the "Generated by" header |
|
97
|
+
| `transpile` | `boolean` | `false` | pipe generated JavaScript through Babel |
|
98
|
+
| `literate` | `boolean` | `false` | treat stdio as literate style coffeescript |
|
99
|
+
| `watch` | `boolean` | `false` | watch scripts for changes and rerun commands |
|
100
|
+
|
101
|
+
##### `milkee.options` (Milkee Specific Options)
|
102
|
+
|
103
|
+
These options control Milkee's behavior.
|
104
|
+
|
105
|
+
| Option | Type | Default | Description |
|
106
|
+
| :-------- | :-------- | :------ | :----------------------------------------------------- |
|
107
|
+
| `refresh` | `boolean` | `false` | Before compiling, reset the output directory. |
|
108
|
+
| `confirm` | `boolean` | `false` | Before compiling, prompt "Do you want to Continue?". |
|
109
|
+
|
110
|
+
[CoffeeScript - command.coffee](https://coffeescript.org/annotated-source/command.html)
|
111
|
+
|
112
|
+
### Compile
|
113
|
+
|
114
|
+
Milkee will automatically read `coffee.config.cjs`, assemble the command from your `options`, and start compilation!
|
115
|
+
|
116
|
+
```bash
|
117
|
+
# global
|
118
|
+
milkee
|
119
|
+
|
120
|
+
# or local
|
121
|
+
npx milkee
|
122
|
+
```
|
package/dist/main.js
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
CWD = process.cwd();
|
20
20
|
|
21
|
-
CONFIG_FILE = 'coffee.config.
|
21
|
+
CONFIG_FILE = 'coffee.config.cjs';
|
22
22
|
|
23
23
|
CONFIG_PATH = path.join(CWD, CONFIG_FILE);
|
24
24
|
|
@@ -53,7 +53,7 @@
|
|
53
53
|
stat = "create";
|
54
54
|
if (fs.existsSync(CONFIG_PATH)) {
|
55
55
|
consola.warn(`\`${CONFIG_FILE}\` already exists in this directory.`);
|
56
|
-
check = (await consola.prompt(
|
56
|
+
check = (await consola.prompt(`Do you want to reset \`${CONFIG_FILE}\`?`, {
|
57
57
|
type: "confirm"
|
58
58
|
}));
|
59
59
|
if (!check) {
|
@@ -69,7 +69,7 @@
|
|
69
69
|
}
|
70
70
|
}
|
71
71
|
try {
|
72
|
-
TEMPLATE_PATH = path.join(__dirname, '..', 'temp',
|
72
|
+
TEMPLATE_PATH = path.join(__dirname, '..', 'temp', CONFIG_FILE);
|
73
73
|
CONFIG_TEMPLATE = fs.readFileSync(TEMPLATE_PATH, 'utf-8');
|
74
74
|
fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE);
|
75
75
|
return consola.success(`Successfully ${pstat} \`${CONFIG_FILE}\`!`);
|
@@ -121,7 +121,7 @@
|
|
121
121
|
});
|
122
122
|
otherOptionStrings = [];
|
123
123
|
if (options.bare) {
|
124
|
-
otherOptionStrings.push(
|
124
|
+
otherOptionStrings.push('--bare');
|
125
125
|
}
|
126
126
|
// consola.info "Option `bare` is selected."
|
127
127
|
if (options.map) {
|
@@ -159,6 +159,7 @@
|
|
159
159
|
type: "confirm"
|
160
160
|
}));
|
161
161
|
if (!toContinue) {
|
162
|
+
consola.info("Canceled.");
|
162
163
|
return;
|
163
164
|
}
|
164
165
|
}
|
@@ -222,11 +223,11 @@
|
|
222
223
|
|
223
224
|
argv = yargs(hideBin(process.argv)).scriptName('milkee').usage('$0 [command]').option('setup', {
|
224
225
|
alias: 's',
|
225
|
-
describe:
|
226
|
+
describe: `Generate a default ${CONFIG_FILE}`,
|
226
227
|
type: 'boolean'
|
227
228
|
}).option('compile', {
|
228
229
|
alias: 'c',
|
229
|
-
describe:
|
230
|
+
describe: `Compile CoffeeScript based on ${CONFIG_FILE} (default)`,
|
230
231
|
type: 'boolean'
|
231
232
|
}).version('version', pkg.version).alias('v', 'version').help('help').alias('h', 'help').argv;
|
232
233
|
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "milkee",
|
3
|
-
"version": "0.1
|
4
|
-
"description": "A simple CoffeeScript build tool with coffee.config.
|
3
|
+
"version": "0.2.1",
|
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"
|
@@ -17,6 +17,7 @@
|
|
17
17
|
"keywords": [
|
18
18
|
"coffee",
|
19
19
|
"coffeescript",
|
20
|
+
"milkee",
|
20
21
|
"build",
|
21
22
|
"builder",
|
22
23
|
"compile",
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module.exports = {
|
4
4
|
// The entry point for compilation.
|
5
|
-
// This can be a single file or a directory.
|
5
|
+
// This can be a single file or a directory (e.g., 'src/' or 'src/app.coffee').
|
6
6
|
entry: 'src',
|
7
7
|
// The output for the compiled JavaScript files.
|
8
8
|
// If 'options.join' is true, this should be a single file path (e.g., 'dist/app.js').
|