milkee 0.0.10 → 0.0.12

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.
Files changed (2) hide show
  1. package/dist/main.js +81 -39
  2. package/package.json +3 -1
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,9 +22,33 @@
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;
51
+ checkCoffee();
28
52
  pstat = "created";
29
53
  stat = "create";
30
54
  if (fs.existsSync(CONFIG_PATH)) {
@@ -32,7 +56,7 @@
32
56
  check = (await consola.prompt("Do you want to reset `coffee.config.js`?", {
33
57
  type: "confirm"
34
58
  }));
35
- if (check !== true) {
59
+ if (!check) {
36
60
  consola.info("Cancelled.");
37
61
  return;
38
62
  } else {
@@ -57,7 +81,8 @@
57
81
  };
58
82
 
59
83
  compile = async function() {
60
- var command, commandParts, compilerProcess, config, error, i, item, itemPath, items, len, milkee, milkeeOptions, options, otherOptionStrings, targetDir, toContinue;
84
+ var command, commandParts, compilerProcess, config, enabledOptons, enabledOptonsList, error, i, item, itemPath, items, len, milkee, milkeeOptions, options, otherOptionStrings, summary, targetDir, toContinue;
85
+ checkCoffee();
61
86
  if (!fs.existsSync(CONFIG_PATH)) {
62
87
  consola.error(`\`${CONFIG_FILE}\` not found in this directory: ${CWD}`);
63
88
  consola.info('Please run `milkee --setup` to create a configuration file.');
@@ -73,61 +98,48 @@
73
98
  milkee = config.milkee || {};
74
99
  milkeeOptions = config.milkee.options || {};
75
100
  commandParts = ['coffee'];
76
- if (options.join) {
77
- commandParts.push('--join');
78
- commandParts.push(`\"${config.output}\"`);
79
- } else {
80
- commandParts.push('--output');
81
- commandParts.push(`\"${config.output}\"`);
82
- }
83
- otherOptionStrings = [];
84
- if (milkeeOptions.refresh) {
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
- }
101
+ summary = [];
102
+ summary.push(`Entry: \`${config.entry}\``);
103
+ summary.push(`Output: \`${config.output}\``);
104
+ enabledOptons = Object.keys(options).filter(function(key) {
105
+ return options[key];
106
+ });
107
+ if (enabledOptons.length > 0) {
108
+ enabledOptonsList = enabledOptions.join(',');
109
+ summary.push(`Options: ${enabledOptionsList}`);
102
110
  }
111
+ consola.box({
112
+ title: "Milkee Compilation Summary",
113
+ message: summary.join('\n')
114
+ });
103
115
  if (options.bare) {
104
116
  otherOptionStrings.push("--bare");
105
- consola.info("Option `bare` is selected.");
106
117
  }
118
+ // consola.info "Option `bare` is selected."
107
119
  if (options.map) {
108
120
  otherOptionStrings.push('--map');
109
- consola.info("Option `map` is selected.");
110
121
  }
122
+ // consola.info "Option `map` is selected."
111
123
  if (options.inlineMap) {
112
124
  otherOptionStrings.push('--inline-map');
113
- consola.info("Option `inline-map` is selected.");
114
125
  }
126
+ // consola.info "Option `inline-map` is selected."
115
127
  if (options.noHeader) {
116
128
  otherOptionStrings.push('--no-header');
117
- consola.info("Option `no-header` is selected.");
118
129
  }
130
+ // consola.info "Option `no-header` is selected."
119
131
  if (options.transpile) {
120
132
  otherOptionStrings.push('--transpile');
121
- consola.info("Option `transpile` is selected.");
122
133
  }
134
+ // consola.info "Option `transpile` is selected."
123
135
  if (options.literate) {
124
136
  otherOptionStrings.push('--literate');
125
- consola.info("Option `literate` is selected.");
126
137
  }
138
+ // consola.info "Option `literate` is selected."
127
139
  if (options.watch) {
128
- consola.info("Option `watch` is selected.");
129
140
  otherOptionStrings.push('--watch');
130
141
  }
142
+ // consola.info "Option `watch` is selected."
131
143
  if (otherOptionStrings.length > 0) {
132
144
  commandParts.push(otherOptionStrings.join(' '));
133
145
  }
@@ -138,10 +150,38 @@
138
150
  toContinue = (await consola.prompt("Do you want to continue?", {
139
151
  type: "confirm"
140
152
  }));
141
- if (toContinue !== true) {
153
+ if (!toContinue) {
142
154
  return;
143
155
  }
144
156
  }
157
+ if (options.join) {
158
+ commandParts.push('--join');
159
+ commandParts.push(`\"${config.output}\"`);
160
+ } else {
161
+ commandParts.push('--output');
162
+ commandParts.push(`\"${config.output}\"`);
163
+ }
164
+ delete options.join;
165
+ otherOptionStrings = [];
166
+ if (milkeeOptions.refresh) {
167
+ targetDir = path.join(CWD, config.output);
168
+ if (!fs.existsSync(targetDir)) {
169
+ consola.info("Refresh skipped.");
170
+ } else {
171
+ consola.info("Executing: Refresh");
172
+ // Refresh
173
+ items = fs.readdirSync(targetDir);
174
+ for (i = 0, len = items.length; i < len; i++) {
175
+ item = items[i];
176
+ itemPath = path.join(targetDir, item);
177
+ fs.rmSync(itemPath, {
178
+ recursive: true,
179
+ force: true
180
+ });
181
+ }
182
+ consola.success("Refreshed!");
183
+ }
184
+ }
145
185
  if (options.watch) {
146
186
  consola.start(`Watching for changes in \`${config.entry}\`...`);
147
187
  } else {
@@ -153,7 +193,7 @@
153
193
  if (error) {
154
194
  consola.error('Compilation failed:', error);
155
195
  if (stderr) {
156
- process.stderr.write(stderr);
196
+ consola.error(stderr.toString().trim());
157
197
  }
158
198
  process.exit(1);
159
199
  return;
@@ -169,7 +209,9 @@
169
209
  });
170
210
  if (options.watch) {
171
211
  compilerProcess.stdout.pipe(process.stdout);
172
- return compilerProcess.stderr.pipe(process.stderr);
212
+ return compilerProcess.stderr.on('data', function(data) {
213
+ return consola.error(data.toString().trim());
214
+ });
173
215
  }
174
216
  } catch (error1) {
175
217
  error = error1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milkee",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
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
  }