milkee 0.0.0

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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ *.coffee linguist-language=CoffeeScript
2
+ dist/* linguist-generated
@@ -0,0 +1,41 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
11
+ runs-on: ${{ matrix.os }}
12
+ timeout-minutes: 10
13
+ strategy:
14
+ matrix:
15
+ node-version: [20.x]
16
+ os: [ubuntu-latest]
17
+
18
+ permissions:
19
+ contents: read
20
+ id-token: write
21
+
22
+ steps:
23
+ - name: Checkout ๐Ÿ””
24
+ uses: actions/checkout@v4
25
+
26
+ - name: Setup Node.js ${{ matrix.node-version }} ๐Ÿ”ง
27
+ uses: actions/setup-node@v4
28
+ with:
29
+ node-version: ${{ matrix.node-version }}
30
+ registry-url: 'https://registry.npmjs.org'
31
+
32
+ - name: Install dependencies ๐Ÿงน
33
+ run: npm ci
34
+
35
+ - name: Build ๐Ÿ”จ
36
+ run: npm run build
37
+
38
+ - name: Publish ๐ŸŽ
39
+ run: npm publish --provenance --access public
40
+ env:
41
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 [otoneko.]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/bin.js ADDED
@@ -0,0 +1,126 @@
1
+ // Generated by CoffeeScript 2.7.0
2
+ (function() {
3
+ //!/usr/bin/env node
4
+ var CONFIG_FILE, CONFIG_PATH, CWD, TEMPLATE_PATH, argv, compile, consola, exec, fs, hideBin, path, pkg, setup, yargs;
5
+
6
+ yargs = require('yargs');
7
+
8
+ ({hideBin} = require('yargs/helpers'));
9
+
10
+ consola = require('consola');
11
+
12
+ fs = require('fs');
13
+
14
+ path = require('path');
15
+
16
+ ({exec} = require('child_process'));
17
+
18
+ pkg = require('../package.json');
19
+
20
+ CWD = process.cwd();
21
+
22
+ CONFIG_FILE = 'coffee.config.js';
23
+
24
+ CONFIG_PATH = path.join(CWD, CONFIG_FILE);
25
+
26
+ TEMPLATE_PATH = path.join(__dirname, '..', 'temp', 'coffee.config.js');
27
+
28
+ setup = function() {
29
+ var error;
30
+ if (fs.existsSync(CONFIG_PATH)) {
31
+ consola.warn(`\`${CONFIG_FILE}\` already exists in this directory.`);
32
+ return;
33
+ }
34
+ try {
35
+ fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE);
36
+ return consola.success(`Successfully created \`${CONFIG_FILE}\`.`);
37
+ } catch (error1) {
38
+ error = error1;
39
+ return consola.error(`Failed to create \`${CONFIG_FILE}\`:`, error);
40
+ }
41
+ };
42
+
43
+ compile = async(async function() {
44
+ var command, commandParts, config, configPathUrl, error, key, options, otherOptionStrings, value;
45
+ if (!fs.existsSync(CONFIG_PATH)) {
46
+ consola.error(`\`${CONFIG_FILE}\` not found.`);
47
+ consola.info('Please run `milkee --setup` to create a configuration file.');
48
+ process.exit(1);
49
+ }
50
+ try {
51
+ configPathUrl = path.toFileUrl(CONFIG_PATH).href;
52
+ ({
53
+ default: config
54
+ } = (await import(configPathUrl)));
55
+ if (!(config.entry && config.output)) {
56
+ consola.error('`entry` and `output` properties are required in your configuration.');
57
+ process.exit(1);
58
+ }
59
+ options = config.options || {};
60
+ commandParts = ['coffee'];
61
+ if (options.join) {
62
+ commandParts.push('--join');
63
+ commandParts.push(`\"${config.output}\"`);
64
+ } else {
65
+ commandParts.push('--output');
66
+ commandParts.push(`\"${config.output}\"`);
67
+ }
68
+ delete options.join;
69
+ otherOptionStrings = [];
70
+ for (key in options) {
71
+ value = options[key];
72
+ if (value === true) {
73
+ otherOptionStrings.push(`--${key}`);
74
+ } else if (value !== false) {
75
+ otherOptionStrings.push(`--${key} \"${value}\"`);
76
+ }
77
+ }
78
+ if (otherOptionStrings.length > 0) {
79
+ commandParts.push(otherOptionStrings.join(' '));
80
+ }
81
+ commandParts.push('--compile');
82
+ commandParts.push(`\"${config.entry}\"`);
83
+ command = commandParts.filter(Boolean).join(' ');
84
+ consola.start(`Compiling from \`${config.entry}\` to \`${config.output}\`...`);
85
+ consola.info(`Executing: ${command}`);
86
+ return exec(command, function(error, stdout, stderr) {
87
+ if (error) {
88
+ consola.error('Compilation failed:', error);
89
+ if (stderr) {
90
+ process.stderr.write(stderr);
91
+ }
92
+ process.exit(1);
93
+ return;
94
+ }
95
+ consola.success('Compilation completed successfully!');
96
+ if (stdout) {
97
+ process.stdout.write(stdout);
98
+ }
99
+ if (stderr) {
100
+ return process.stderr.write(stderr);
101
+ }
102
+ });
103
+ } catch (error1) {
104
+ error = error1;
105
+ consola.error('Failed to load or execute configuration:', error);
106
+ return process.exit(1);
107
+ }
108
+ });
109
+
110
+ argv = yargs(hideBin(process.argv)).scriptName('milkee').usage('$0 [command]').option('setup', {
111
+ alias: 's',
112
+ describe: 'Generate a default coffee.config.js',
113
+ type: 'boolean'
114
+ }).option('compile', {
115
+ alias: 'c',
116
+ describe: 'Compile CoffeeScript based on coffee.config.js (default)',
117
+ type: 'boolean'
118
+ }).version('version', pkg.version).alias('v', 'version').help('help').alias('h', 'help').argv;
119
+
120
+ if (argv.setup) {
121
+ setup();
122
+ } else {
123
+ compile();
124
+ }
125
+
126
+ }).call(this);
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "milkee",
3
+ "version": "0.0.0",
4
+ "description": "A simple CoffeeScript build tool with coffee.config.js",
5
+ "main": "dist/cli.js",
6
+ "bin": {
7
+ "milkee": "dist/cli.js"
8
+ },
9
+ "scripts": {
10
+ "build": "coffee --output dist/ --compile src/",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/otoneko1102/coffeescript-milkee.git"
16
+ },
17
+ "keywords": [
18
+ "coffee",
19
+ "coffeescript",
20
+ "build",
21
+ "builder",
22
+ "compile",
23
+ "compiler",
24
+ "tool",
25
+ "cli"
26
+ ],
27
+ "author": "otoneko.",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/otoneko1102/coffeescript-milkee/issues"
31
+ },
32
+ "homepage": "https://github.com/otoneko1102/coffeescript-milkee#readme",
33
+ "dependencies": {
34
+ "consola": "^3.4.2",
35
+ "yargs": "^18.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "coffeescript": "^2.7.0"
39
+ }
40
+ }
package/src/bin.coffee ADDED
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env node
2
+
3
+ yargs = require 'yargs'
4
+ { hideBin } = require 'yargs/helpers'
5
+ consola = require 'consola'
6
+ fs = require 'fs'
7
+ path = require 'path'
8
+ { exec } = require 'child_process'
9
+
10
+ pkg = require '../package.json'
11
+ CWD = process.cwd()
12
+ CONFIG_FILE = 'coffee.config.js'
13
+ CONFIG_PATH = path.join(CWD, CONFIG_FILE)
14
+
15
+ TEMPLATE_PATH = path.join(__dirname, '..', 'temp', 'coffee.config.js')
16
+
17
+ setup = () ->
18
+ if fs.existsSync(CONFIG_PATH)
19
+ consola.warn "`#{CONFIG_FILE}` already exists in this directory."
20
+ return
21
+
22
+ try
23
+ fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE)
24
+ consola.success "Successfully created `#{CONFIG_FILE}`."
25
+ catch error
26
+ consola.error "Failed to create `#{CONFIG_FILE}`:", error
27
+
28
+ compile = async () ->
29
+ unless fs.existsSync(CONFIG_PATH)
30
+ consola.error "`#{CONFIG_FILE}` not found."
31
+ consola.info 'Please run `milkee --setup` to create a configuration file.'
32
+ process.exit(1)
33
+
34
+ try
35
+ configPathUrl = path.toFileUrl(CONFIG_PATH).href
36
+ { default: config } = await import(configPathUrl)
37
+
38
+ unless config.entry and config.output
39
+ consola.error '`entry` and `output` properties are required in your configuration.'
40
+ process.exit(1)
41
+
42
+ options = config.options or {}
43
+ commandParts = ['coffee']
44
+
45
+ if options.join
46
+ commandParts.push('--join')
47
+ commandParts.push("\"#{config.output}\"")
48
+ else
49
+ commandParts.push('--output')
50
+ commandParts.push("\"#{config.output}\"")
51
+
52
+ delete options.join
53
+
54
+ otherOptionStrings = []
55
+ for key, value of options
56
+ if value is true
57
+ otherOptionStrings.push("--#{key}")
58
+ else if value isnt false
59
+ otherOptionStrings.push("--#{key} \"#{value}\"")
60
+
61
+ if otherOptionStrings.length > 0
62
+ commandParts.push(otherOptionStrings.join(' '))
63
+
64
+ commandParts.push('--compile')
65
+ commandParts.push("\"#{config.entry}\"")
66
+
67
+ command = commandParts.filter(Boolean).join(' ')
68
+
69
+ consola.start "Compiling from `#{config.entry}` to `#{config.output}`..."
70
+ consola.info "Executing: #{command}"
71
+
72
+ exec command, (error, stdout, stderr) ->
73
+ if error
74
+ consola.error 'Compilation failed:', error
75
+ if stderr then process.stderr.write stderr
76
+ process.exit(1)
77
+ return
78
+
79
+ consola.success 'Compilation completed successfully!'
80
+ if stdout then process.stdout.write stdout
81
+ if stderr then process.stderr.write stderr
82
+
83
+ catch error
84
+ consola.error 'Failed to load or execute configuration:', error
85
+ process.exit(1)
86
+
87
+ argv = yargs(hideBin(process.argv))
88
+ .scriptName('milkee')
89
+ .usage('$0 [command]')
90
+ .option('setup', {
91
+ alias: 's',
92
+ describe: 'Generate a default coffee.config.js',
93
+ type: 'boolean'
94
+ })
95
+ .option('compile', {
96
+ alias: 'c',
97
+ describe: 'Compile CoffeeScript based on coffee.config.js (default)',
98
+ type: 'boolean'
99
+ })
100
+ .version('version', pkg.version)
101
+ .alias('v', 'version')
102
+ .help('help')
103
+ .alias('h', 'help')
104
+ .argv
105
+
106
+ if argv.setup
107
+ setup()
108
+ else
109
+ compile()
@@ -0,0 +1,23 @@
1
+ module.exports = {
2
+ // The entry point for compilation.
3
+ // This can be a single file or a directory.
4
+ entry: 'src',
5
+
6
+ // The output for the compiled JavaScript files.
7
+ // If 'join' is true, this should be a single file path (e.g., 'dist/app.js').
8
+ // If 'join' is false, this should be a directory (e.g., 'dist').
9
+ output: 'dist',
10
+
11
+ // (Optional) Additional options for the CoffeeScript compiler.
12
+ // See `coffee --help` for all available options.
13
+ options: {
14
+ // Join all scripts into a single file.
15
+ // join: false,
16
+
17
+ // Add a header to the top of the compiled JavaScript.
18
+ // header: false,
19
+
20
+ // Compile without the top-level function wrapper.
21
+ // bare: true
22
+ }
23
+ };