milkee 0.0.9 → 0.0.11
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/main.js +82 -40
- package/package.json +3 -1
- package/temp/coffee.config.js +3 -3
package/dist/main.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
// Generated by CoffeeScript 2.7.0
|
2
2
|
(function() {
|
3
|
-
var CONFIG_FILE, CONFIG_PATH, CWD, argv, compile, consola, exec, fs, hideBin, path, pkg, setup, yargs;
|
3
|
+
var CONFIG_FILE, CONFIG_PATH, CWD, argv, checkCoffee, compile, consola, exec, fs, hideBin, path, pkg, setup, yargs;
|
4
4
|
|
5
5
|
yargs = require('yargs');
|
6
6
|
|
@@ -22,6 +22,29 @@
|
|
22
22
|
|
23
23
|
CONFIG_PATH = path.join(CWD, CONFIG_FILE);
|
24
24
|
|
25
|
+
checkCoffee = function() {
|
26
|
+
var error, pkgData, pkgFile, ref, ref1;
|
27
|
+
PKG_PATH(path.join(CWD, 'package.json'));
|
28
|
+
if (fs.existsSync(PKG_PATH)) {
|
29
|
+
try {
|
30
|
+
pkgFile = fs.readFileSync(PKG_PATH, 'utf-8');
|
31
|
+
pkgData = JSON.parse(pkgFile);
|
32
|
+
if (((ref = pkgData.dependencies) != null ? ref.coffeescript : void 0) || ((ref1 = pkgData.devDependencies) != null ? ref1.coffeescript : void 0)) {
|
33
|
+
return resolve(true);
|
34
|
+
}
|
35
|
+
} catch (error1) {
|
36
|
+
error = error1;
|
37
|
+
consola.warn(`Could not parse \`package.json\`: ${error.message}`);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return exec('coffee --version', function(error) {
|
41
|
+
if (error) {
|
42
|
+
consola.warn('CoffeeScript is not found in local dependencies (`dependencies`, `devDependencies`) or globally.');
|
43
|
+
return consola.info('Please install it via `npm install --save-dev coffeescript` to continue.');
|
44
|
+
}
|
45
|
+
});
|
46
|
+
};
|
47
|
+
|
25
48
|
// async
|
26
49
|
setup = async function() {
|
27
50
|
var CONFIG_TEMPLATE, TEMPLATE_PATH, check, error, pstat, stat;
|
@@ -32,7 +55,7 @@
|
|
32
55
|
check = (await consola.prompt("Do you want to reset `coffee.config.js`?", {
|
33
56
|
type: "confirm"
|
34
57
|
}));
|
35
|
-
if (check
|
58
|
+
if (!check) {
|
36
59
|
consola.info("Cancelled.");
|
37
60
|
return;
|
38
61
|
} else {
|
@@ -57,7 +80,7 @@
|
|
57
80
|
};
|
58
81
|
|
59
82
|
compile = async function() {
|
60
|
-
var command, commandParts, compilerProcess, config, error, i, item, itemPath, items, len, milkee, milkeeOptions, options, otherOptionStrings, targetDir, toContinue;
|
83
|
+
var command, commandParts, compilerProcess, config, enabledOptons, enabledOptonsList, error, i, item, itemPath, items, len, milkee, milkeeOptions, options, otherOptionStrings, summary, targetDir, toContinue;
|
61
84
|
if (!fs.existsSync(CONFIG_PATH)) {
|
62
85
|
consola.error(`\`${CONFIG_FILE}\` not found in this directory: ${CWD}`);
|
63
86
|
consola.info('Please run `milkee --setup` to create a configuration file.');
|
@@ -73,61 +96,48 @@
|
|
73
96
|
milkee = config.milkee || {};
|
74
97
|
milkeeOptions = config.milkee.options || {};
|
75
98
|
commandParts = ['coffee'];
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
targetDir = path.join(CWD, config.output);
|
86
|
-
if (!fs.existsSync(targetDir)) {
|
87
|
-
consola.info("Refresh skipped.");
|
88
|
-
} else {
|
89
|
-
consola.info("Executing: Refresh");
|
90
|
-
// Refresh
|
91
|
-
items = fs.readdirSync(targetDir);
|
92
|
-
for (i = 0, len = items.length; i < len; i++) {
|
93
|
-
item = items[i];
|
94
|
-
itemPath = path.join(targetDir, item);
|
95
|
-
fs.rmSync(itemPath, {
|
96
|
-
recursive: true,
|
97
|
-
force: true
|
98
|
-
});
|
99
|
-
}
|
100
|
-
consola.success("Refreshed!");
|
101
|
-
}
|
99
|
+
summary = [];
|
100
|
+
summary.push(`Entry: \`${config.entry}\``);
|
101
|
+
summary.push(`Output: \`${config.output}\``);
|
102
|
+
enabledOptons = Object.keys(options).filter(function(key) {
|
103
|
+
return options[key];
|
104
|
+
});
|
105
|
+
if (enabledOptons.length > 0) {
|
106
|
+
enabledOptonsList = enabledOptions.join(',');
|
107
|
+
summary.push(`Options: ${enabledOptionsList}`);
|
102
108
|
}
|
109
|
+
consola.box({
|
110
|
+
title: "Milkee Compilation Summary",
|
111
|
+
message: summary.join('\n')
|
112
|
+
});
|
103
113
|
if (options.bare) {
|
104
114
|
otherOptionStrings.push("--bare");
|
105
|
-
consola.info("Option `bare` is selected.");
|
106
115
|
}
|
116
|
+
// consola.info "Option `bare` is selected."
|
107
117
|
if (options.map) {
|
108
118
|
otherOptionStrings.push('--map');
|
109
|
-
consola.info("Option `map` is selected.");
|
110
119
|
}
|
120
|
+
// consola.info "Option `map` is selected."
|
111
121
|
if (options.inlineMap) {
|
112
122
|
otherOptionStrings.push('--inline-map');
|
113
|
-
consola.info("Option `inline-map` is selected.");
|
114
123
|
}
|
124
|
+
// consola.info "Option `inline-map` is selected."
|
115
125
|
if (options.noHeader) {
|
116
126
|
otherOptionStrings.push('--no-header');
|
117
|
-
consola.info("Option `no-header` is selected.");
|
118
127
|
}
|
128
|
+
// consola.info "Option `no-header` is selected."
|
119
129
|
if (options.transpile) {
|
120
130
|
otherOptionStrings.push('--transpile');
|
121
|
-
consola.info("Option `transpile` is selected.");
|
122
131
|
}
|
132
|
+
// consola.info "Option `transpile` is selected."
|
123
133
|
if (options.literate) {
|
124
134
|
otherOptionStrings.push('--literate');
|
125
|
-
consola.info("Option `literate` is selected.");
|
126
135
|
}
|
136
|
+
// consola.info "Option `literate` is selected."
|
127
137
|
if (options.watch) {
|
128
|
-
consola.info("Option `watch` is selected.");
|
129
138
|
otherOptionStrings.push('--watch');
|
130
139
|
}
|
140
|
+
// consola.info "Option `watch` is selected."
|
131
141
|
if (otherOptionStrings.length > 0) {
|
132
142
|
commandParts.push(otherOptionStrings.join(' '));
|
133
143
|
}
|
@@ -135,11 +145,41 @@
|
|
135
145
|
commandParts.push(`\"${config.entry}\"`);
|
136
146
|
command = commandParts.filter(Boolean).join(' ');
|
137
147
|
if (milkeeOptions.confirm) {
|
138
|
-
toContinue = (await consola.prompt("Do you want to continue?"
|
139
|
-
|
148
|
+
toContinue = (await consola.prompt("Do you want to continue?", {
|
149
|
+
type: "confirm"
|
150
|
+
}));
|
151
|
+
if (!toContinue) {
|
140
152
|
return;
|
141
153
|
}
|
142
154
|
}
|
155
|
+
if (options.join) {
|
156
|
+
commandParts.push('--join');
|
157
|
+
commandParts.push(`\"${config.output}\"`);
|
158
|
+
} else {
|
159
|
+
commandParts.push('--output');
|
160
|
+
commandParts.push(`\"${config.output}\"`);
|
161
|
+
}
|
162
|
+
delete options.join;
|
163
|
+
otherOptionStrings = [];
|
164
|
+
if (milkeeOptions.refresh) {
|
165
|
+
targetDir = path.join(CWD, config.output);
|
166
|
+
if (!fs.existsSync(targetDir)) {
|
167
|
+
consola.info("Refresh skipped.");
|
168
|
+
} else {
|
169
|
+
consola.info("Executing: Refresh");
|
170
|
+
// Refresh
|
171
|
+
items = fs.readdirSync(targetDir);
|
172
|
+
for (i = 0, len = items.length; i < len; i++) {
|
173
|
+
item = items[i];
|
174
|
+
itemPath = path.join(targetDir, item);
|
175
|
+
fs.rmSync(itemPath, {
|
176
|
+
recursive: true,
|
177
|
+
force: true
|
178
|
+
});
|
179
|
+
}
|
180
|
+
consola.success("Refreshed!");
|
181
|
+
}
|
182
|
+
}
|
143
183
|
if (options.watch) {
|
144
184
|
consola.start(`Watching for changes in \`${config.entry}\`...`);
|
145
185
|
} else {
|
@@ -151,7 +191,7 @@
|
|
151
191
|
if (error) {
|
152
192
|
consola.error('Compilation failed:', error);
|
153
193
|
if (stderr) {
|
154
|
-
|
194
|
+
consola.error(stderr.toString().trim());
|
155
195
|
}
|
156
196
|
process.exit(1);
|
157
197
|
return;
|
@@ -167,7 +207,9 @@
|
|
167
207
|
});
|
168
208
|
if (options.watch) {
|
169
209
|
compilerProcess.stdout.pipe(process.stdout);
|
170
|
-
return compilerProcess.stderr.
|
210
|
+
return compilerProcess.stderr.on('data', function(data) {
|
211
|
+
return consola.error(data.toString().trim());
|
212
|
+
});
|
171
213
|
}
|
172
214
|
} catch (error1) {
|
173
215
|
error = error1;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "milkee",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.11",
|
4
4
|
"description": "A simple CoffeeScript build tool with coffee.config.js",
|
5
5
|
"main": "dist/main.js",
|
6
6
|
"bin": {
|
@@ -35,6 +35,8 @@
|
|
35
35
|
"yargs": "^18.0.0"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
|
+
"@babel/core": "^7.28.4",
|
39
|
+
"@types/coffeescript": "^2.5.7",
|
38
40
|
"coffeescript": "^2.7.0"
|
39
41
|
}
|
40
42
|
}
|
package/temp/coffee.config.js
CHANGED
@@ -3,8 +3,8 @@ module.exports = {
|
|
3
3
|
// This can be a single file or a directory.
|
4
4
|
entry: 'src',
|
5
5
|
// The output for the compiled JavaScript files.
|
6
|
-
// If 'join' is true, this should be a single file path (e.g., 'dist/app.js').
|
7
|
-
// If 'join' is false, this should be a directory (e.g., 'dist').
|
6
|
+
// If 'options.join' is true, this should be a single file path (e.g., 'dist/app.js').
|
7
|
+
// If 'options.join' is false, this should be a directory (e.g., 'dist').
|
8
8
|
output: 'dist',
|
9
9
|
// (Optional) Additional options for the CoffeeScript compiler.
|
10
10
|
// See `coffee --help` for all available options.
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
26
26
|
// Before compiling, reset the directory.
|
27
27
|
// refresh: false,
|
28
28
|
// Before compiling, confirm "Do you want to Continue?"
|
29
|
-
// confirm: false
|
29
|
+
// confirm: false,
|
30
30
|
},
|
31
31
|
plugins: []
|
32
32
|
},
|