milkee 0.0.6 → 0.0.8

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 CHANGED
@@ -22,17 +22,23 @@
22
22
 
23
23
  CONFIG_PATH = path.join(CWD, CONFIG_FILE);
24
24
 
25
- setup = function() {
26
- var CONFIG_TEMPLATE, TEMPLATE_PATH, error;
25
+ // async
26
+ setup = async function() {
27
+ var CONFIG_TEMPLATE, TEMPLATE_PATH, check, error;
27
28
  if (fs.existsSync(CONFIG_PATH)) {
28
29
  consola.warn(`\`${CONFIG_FILE}\` already exists in this directory.`);
29
- return;
30
+ check = (await consola.prompt("Do you want to reset `coffee.config.js`?", {
31
+ type: "confirm"
32
+ }));
33
+ if (check !== true) {
34
+ return;
35
+ }
30
36
  }
31
37
  try {
32
38
  TEMPLATE_PATH = path.join(__dirname, '..', 'temp', 'coffee.config.js');
33
39
  CONFIG_TEMPLATE = fs.readFileSync(TEMPLATE_PATH, 'utf-8');
34
40
  fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE);
35
- return consola.success(`Successfully created \`${CONFIG_FILE}\`.`);
41
+ return consola.success(`Successfully created \`${CONFIG_FILE}\`!`);
36
42
  } catch (error1) {
37
43
  error = error1;
38
44
  consola.error(`Failed to create \`${CONFIG_FILE}\`:`, error);
@@ -40,8 +46,8 @@
40
46
  }
41
47
  };
42
48
 
43
- compile = function() {
44
- var command, commandParts, compilerProcess, config, error, i, item, itemPath, items, len, options, otherOptionStrings, targetDir;
49
+ compile = async function() {
50
+ var command, commandParts, compilerProcess, config, error, i, item, itemPath, items, len, milkee, milkeeOptions, options, otherOptionStrings, targetDir, toContinue;
45
51
  if (!fs.existsSync(CONFIG_PATH)) {
46
52
  consola.error(`\`${CONFIG_FILE}\` not found in this directory: ${CWD}`);
47
53
  consola.info('Please run `milkee --setup` to create a configuration file.');
@@ -54,6 +60,8 @@
54
60
  process.exit(1);
55
61
  }
56
62
  options = config.options || {};
63
+ milkee = config.milkee || {};
64
+ milkeeOptions = config.milkee.options || {};
57
65
  commandParts = ['coffee'];
58
66
  if (options.join) {
59
67
  commandParts.push('--join');
@@ -62,13 +70,14 @@
62
70
  commandParts.push('--output');
63
71
  commandParts.push(`\"${config.output}\"`);
64
72
  }
65
- delete options.join;
66
73
  otherOptionStrings = [];
67
- if (options.refresh) {
74
+ if (milkeeOptions.refresh) {
68
75
  targetDir = path.join(CWD, config.output);
69
76
  if (!fs.existsSync(targetDir)) {
70
77
  consola.info("Refresh skipped.");
71
78
  } else {
79
+ consola.info("Executing: Refresh");
80
+ // Refresh
72
81
  items = fs.readdirSync(targetDir);
73
82
  for (i = 0, len = items.length; i < len; i++) {
74
83
  item = items[i];
@@ -83,23 +92,30 @@
83
92
  }
84
93
  if (options.bare) {
85
94
  otherOptionStrings.push("--bare");
95
+ consola.info("Option `bare` is selected.");
86
96
  }
87
97
  if (options.map) {
88
98
  otherOptionStrings.push('--map');
99
+ consola.info("Option `map` is selected.");
89
100
  }
90
101
  if (options.inlineMap) {
91
102
  otherOptionStrings.push('--inline-map');
103
+ consola.info("Option `inline-map` is selected.");
92
104
  }
93
105
  if (options.noHeader) {
94
106
  otherOptionStrings.push('--no-header');
107
+ consola.info("Option `no-header` is selected.");
95
108
  }
96
109
  if (options.transpile) {
97
110
  otherOptionStrings.push('--transpile');
111
+ consola.info("Option `transpile` is selected.");
98
112
  }
99
113
  if (options.literate) {
100
114
  otherOptionStrings.push('--literate');
115
+ consola.info("Option `literate` is selected.");
101
116
  }
102
117
  if (options.watch) {
118
+ consola.info("Option `watch` is selected.");
103
119
  otherOptionStrings.push('--watch');
104
120
  }
105
121
  if (otherOptionStrings.length > 0) {
@@ -108,6 +124,12 @@
108
124
  commandParts.push('--compile');
109
125
  commandParts.push(`\"${config.entry}\"`);
110
126
  command = commandParts.filter(Boolean).join(' ');
127
+ if (milkeeOptions.confirm) {
128
+ toContinue = (await consola.prompt("Do you want to continue?"));
129
+ if (toContinue !== true) {
130
+ return;
131
+ }
132
+ }
111
133
  if (options.watch) {
112
134
  consola.start(`Watching for changes in \`${config.entry}\`...`);
113
135
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milkee",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "A simple CoffeeScript build tool with coffee.config.js",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
@@ -2,12 +2,10 @@ module.exports = {
2
2
  // The entry point for compilation.
3
3
  // This can be a single file or a directory.
4
4
  entry: 'src',
5
-
6
5
  // The output for the compiled JavaScript files.
7
6
  // If 'join' is true, this should be a single file path (e.g., 'dist/app.js').
8
7
  // If 'join' is false, this should be a directory (e.g., 'dist').
9
8
  output: 'dist',
10
-
11
9
  // (Optional) Additional options for the CoffeeScript compiler.
12
10
  // See `coffee --help` for all available options.
13
11
  // Web: https://coffeescript.org/annotated-source/command.html
@@ -22,4 +20,14 @@ module.exports = {
22
20
  // literate: false,
23
21
  // watch: false,
24
22
  },
23
+ // (Optional) Additional options/plugins for the Milkee builder.
24
+ milkee: {
25
+ options: {
26
+ // Before compiling, reset the directory.
27
+ // refresh: false,
28
+ // Before compiling, confirm "Do you want to Continue?"
29
+ // confirm: false
30
+ },
31
+ plugins: []
32
+ },
25
33
  };
@@ -1,47 +0,0 @@
1
- name: Manual Publish to npm
2
-
3
- on:
4
- workflow_dispatch:
5
-
6
- jobs:
7
- publish-npm:
8
- runs-on: ubuntu-latest
9
- permissions:
10
- id-token: write
11
- contents: write
12
- steps:
13
- - name: Checkout repository
14
- uses: actions/checkout@v4
15
-
16
- - name: Setup Node.js
17
- uses: actions/setup-node@v4
18
- with:
19
- node-version: "20.x"
20
- registry-url: "https://registry.npmjs.org"
21
-
22
- - name: Install, Build, and Test
23
- run: |
24
- npm ci
25
- npm run build
26
- npm test
27
-
28
- - name: Commit dist directory (if changed)
29
- run: |
30
- git config --global user.name "github-actions[bot]"
31
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
32
- git add dist
33
- # The following command creates a commit ONLY if there are staged changes.
34
- git diff --staged --quiet || git commit -m "chore: update build artifacts"
35
- git push
36
-
37
- - name: Publish to npm
38
- run: npm publish --provenance --access public
39
- env:
40
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41
-
42
- - name: Create and Push Git Tag
43
- run: |
44
- # This step now runs after the dist commit, ensuring the tag points to the correct commit.
45
- VERSION=$(node -p "require('./package.json').version")
46
- git tag "v$VERSION"
47
- git push origin "v$VERSION"