milkee 0.0.2 → 0.0.4

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/bin/milkee.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require("../dist/main");
package/dist/main.js ADDED
@@ -0,0 +1,123 @@
1
+ // Generated by CoffeeScript 2.7.0
2
+ (function() {
3
+ var CONFIG_FILE, CONFIG_PATH, CWD, argv, compile, consola, exec, fs, hideBin, path, pkg, setup, yargs;
4
+
5
+ yargs = require('yargs');
6
+
7
+ ({hideBin} = require('yargs/helpers'));
8
+
9
+ consola = require('consola');
10
+
11
+ fs = require('fs');
12
+
13
+ path = require('path');
14
+
15
+ ({exec} = require('child_process'));
16
+
17
+ pkg = require('../package.json');
18
+
19
+ CWD = process.cwd();
20
+
21
+ CONFIG_FILE = 'coffee.config.js';
22
+
23
+ CONFIG_PATH = path.join(CWD, CONFIG_FILE);
24
+
25
+ setup = function() {
26
+ var CONFIG_TEMPLATE, TEMPLATE_PATH, error;
27
+ if (fs.existsSync(CONFIG_PATH)) {
28
+ consola.warn(`\`${CONFIG_FILE}\` already exists in this directory.`);
29
+ return;
30
+ }
31
+ try {
32
+ TEMPLATE_PATH = path.join(__dirname, '..', 'temp', 'coffee.config.js');
33
+ CONFIG_TEMPLATE = fs.readFileSync(TEMPLATE_PATH, 'utf-8');
34
+ fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE);
35
+ return consola.success(`Successfully created \`${CONFIG_FILE}\`.`);
36
+ } catch (error1) {
37
+ error = error1;
38
+ consola.error(`Failed to create \`${CONFIG_FILE}\`:`, error);
39
+ return consola.info(`Template file may be missing from the package installation at \`${TEMPLATE_PATH}\``);
40
+ }
41
+ };
42
+
43
+ compile = function() {
44
+ var command, commandParts, config, error, key, options, otherOptionStrings, value;
45
+ if (!fs.existsSync(CONFIG_PATH)) {
46
+ consola.error(`\`${CONFIG_FILE}\` not found in this directory: ${CWD}`);
47
+ consola.info('Please run `milkee --setup` to create a configuration file.');
48
+ process.exit(1);
49
+ }
50
+ try {
51
+ config = require(CONFIG_PATH);
52
+ if (!(config.entry && config.output)) {
53
+ consola.error('`entry` and `output` properties are required in your configuration.');
54
+ process.exit(1);
55
+ }
56
+ options = config.options || {};
57
+ commandParts = ['coffee'];
58
+ if (options.join) {
59
+ commandParts.push('--join');
60
+ commandParts.push(`\"${config.output}\"`);
61
+ } else {
62
+ commandParts.push('--output');
63
+ commandParts.push(`\"${config.output}\"`);
64
+ }
65
+ delete options.join;
66
+ otherOptionStrings = [];
67
+ for (key in options) {
68
+ value = options[key];
69
+ if (value === true) {
70
+ otherOptionStrings.push(`--${key}`);
71
+ } else if (value !== false) {
72
+ otherOptionStrings.push(`--${key} \"${value}\"`);
73
+ }
74
+ }
75
+ if (otherOptionStrings.length > 0) {
76
+ commandParts.push(otherOptionStrings.join(' '));
77
+ }
78
+ commandParts.push('--compile');
79
+ commandParts.push(`\"${config.entry}\"`);
80
+ command = commandParts.filter(Boolean).join(' ');
81
+ consola.start(`Compiling from \`${config.entry}\` to \`${config.output}\`...`);
82
+ consola.info(`Executing: ${command}`);
83
+ return exec(command, function(error, stdout, stderr) {
84
+ if (error) {
85
+ consola.error('Compilation failed:', error);
86
+ if (stderr) {
87
+ process.stderr.write(stderr);
88
+ }
89
+ process.exit(1);
90
+ return;
91
+ }
92
+ consola.success('Compilation completed successfully!');
93
+ if (stdout) {
94
+ process.stdout.write(stdout);
95
+ }
96
+ if (stderr) {
97
+ return process.stderr.write(stderr);
98
+ }
99
+ });
100
+ } catch (error1) {
101
+ error = error1;
102
+ consola.error('Failed to load or execute configuration:', error);
103
+ return process.exit(1);
104
+ }
105
+ };
106
+
107
+ argv = yargs(hideBin(process.argv)).scriptName('milkee').usage('$0 [command]').option('setup', {
108
+ alias: 's',
109
+ describe: 'Generate a default coffee.config.js',
110
+ type: 'boolean'
111
+ }).option('compile', {
112
+ alias: 'c',
113
+ describe: 'Compile CoffeeScript based on coffee.config.js (default)',
114
+ type: 'boolean'
115
+ }).version('version', pkg.version).alias('v', 'version').help('help').alias('h', 'help').argv;
116
+
117
+ if (argv.setup) {
118
+ setup();
119
+ } else {
120
+ compile();
121
+ }
122
+
123
+ }).call(this);
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "milkee",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "A simple CoffeeScript build tool with coffee.config.js",
5
- "main": "dist/cli.js",
5
+ "main": "dist/main.js",
6
6
  "bin": {
7
- "milkee": "dist/cli.js"
7
+ "milkee": "bin/milkee.js"
8
8
  },
9
9
  "scripts": {
10
10
  "test": "echo \"No test specified\" && exit 0",
11
- "build": "coffee --bare --no-header --output dist/ --compile src/"
11
+ "build": "coffee --output dist/ --compile src/"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
package/dist/bin.js DELETED
@@ -1,122 +0,0 @@
1
- #!/usr/bin/env node;
2
- var CONFIG_FILE, CONFIG_PATH, CWD, TEMPLATE_PATH, argv, compile, consola, exec, fs, hideBin, path, pkg, setup, yargs;
3
-
4
- yargs = require('yargs');
5
-
6
- ({hideBin} = require('yargs/helpers'));
7
-
8
- consola = require('consola');
9
-
10
- fs = require('fs');
11
-
12
- path = require('path');
13
-
14
- ({exec} = require('child_process'));
15
-
16
- pkg = require('../package.json');
17
-
18
- CWD = process.cwd();
19
-
20
- CONFIG_FILE = 'coffee.config.js';
21
-
22
- CONFIG_PATH = path.join(CWD, CONFIG_FILE);
23
-
24
- TEMPLATE_PATH = path.join(__dirname, '..', 'temp', 'coffee.config.js');
25
-
26
- setup = function() {
27
- var error;
28
- if (fs.existsSync(CONFIG_PATH)) {
29
- consola.warn(`\`${CONFIG_FILE}\` already exists in this directory.`);
30
- return;
31
- }
32
- try {
33
- fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE);
34
- return consola.success(`Successfully created \`${CONFIG_FILE}\`.`);
35
- } catch (error1) {
36
- error = error1;
37
- return consola.error(`Failed to create \`${CONFIG_FILE}\`:`, error);
38
- }
39
- };
40
-
41
- compile = async(async function() {
42
- var command, commandParts, config, configPathUrl, error, key, options, otherOptionStrings, value;
43
- if (!fs.existsSync(CONFIG_PATH)) {
44
- consola.error(`\`${CONFIG_FILE}\` not found.`);
45
- consola.info('Please run `milkee --setup` to create a configuration file.');
46
- process.exit(1);
47
- }
48
- try {
49
- configPathUrl = path.toFileUrl(CONFIG_PATH).href;
50
- ({
51
- default: config
52
- } = (await import(configPathUrl)));
53
- if (!(config.entry && config.output)) {
54
- consola.error('`entry` and `output` properties are required in your configuration.');
55
- process.exit(1);
56
- }
57
- options = config.options || {};
58
- commandParts = ['coffee'];
59
- if (options.join) {
60
- commandParts.push('--join');
61
- commandParts.push(`\"${config.output}\"`);
62
- } else {
63
- commandParts.push('--output');
64
- commandParts.push(`\"${config.output}\"`);
65
- }
66
- delete options.join;
67
- otherOptionStrings = [];
68
- for (key in options) {
69
- value = options[key];
70
- if (value === true) {
71
- otherOptionStrings.push(`--${key}`);
72
- } else if (value !== false) {
73
- otherOptionStrings.push(`--${key} \"${value}\"`);
74
- }
75
- }
76
- if (otherOptionStrings.length > 0) {
77
- commandParts.push(otherOptionStrings.join(' '));
78
- }
79
- commandParts.push('--compile');
80
- commandParts.push(`\"${config.entry}\"`);
81
- command = commandParts.filter(Boolean).join(' ');
82
- consola.start(`Compiling from \`${config.entry}\` to \`${config.output}\`...`);
83
- consola.info(`Executing: ${command}`);
84
- return exec(command, function(error, stdout, stderr) {
85
- if (error) {
86
- consola.error('Compilation failed:', error);
87
- if (stderr) {
88
- process.stderr.write(stderr);
89
- }
90
- process.exit(1);
91
- return;
92
- }
93
- consola.success('Compilation completed successfully!');
94
- if (stdout) {
95
- process.stdout.write(stdout);
96
- }
97
- if (stderr) {
98
- return process.stderr.write(stderr);
99
- }
100
- });
101
- } catch (error1) {
102
- error = error1;
103
- consola.error('Failed to load or execute configuration:', error);
104
- return process.exit(1);
105
- }
106
- });
107
-
108
- argv = yargs(hideBin(process.argv)).scriptName('milkee').usage('$0 [command]').option('setup', {
109
- alias: 's',
110
- describe: 'Generate a default coffee.config.js',
111
- type: 'boolean'
112
- }).option('compile', {
113
- alias: 'c',
114
- describe: 'Compile CoffeeScript based on coffee.config.js (default)',
115
- type: 'boolean'
116
- }).version('version', pkg.version).alias('v', 'version').help('help').alias('h', 'help').argv;
117
-
118
- if (argv.setup) {
119
- setup();
120
- } else {
121
- compile();
122
- }