milkee 0.0.7 → 0.0.9

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,26 +22,42 @@
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, pstat, stat;
28
+ pstat = "created";
29
+ stat = "create";
27
30
  if (fs.existsSync(CONFIG_PATH)) {
28
31
  consola.warn(`\`${CONFIG_FILE}\` already exists in this directory.`);
29
- return;
32
+ check = (await consola.prompt("Do you want to reset `coffee.config.js`?", {
33
+ type: "confirm"
34
+ }));
35
+ if (check !== true) {
36
+ consola.info("Cancelled.");
37
+ return;
38
+ } else {
39
+ fs.rmSync(CONFIG_PATH, {
40
+ recursive: true,
41
+ force: true
42
+ });
43
+ pstat = "reset";
44
+ stat = "reset";
45
+ }
30
46
  }
31
47
  try {
32
48
  TEMPLATE_PATH = path.join(__dirname, '..', 'temp', 'coffee.config.js');
33
49
  CONFIG_TEMPLATE = fs.readFileSync(TEMPLATE_PATH, 'utf-8');
34
50
  fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE);
35
- return consola.success(`Successfully created \`${CONFIG_FILE}\`.`);
51
+ return consola.success(`Successfully ${pstat} \`${CONFIG_FILE}\`!`);
36
52
  } catch (error1) {
37
53
  error = error1;
38
- consola.error(`Failed to create \`${CONFIG_FILE}\`:`, error);
54
+ consola.error(`Failed to ${stat} \`${CONFIG_FILE}\`:`, error);
39
55
  return consola.info(`Template file may be missing from the package installation at \`${TEMPLATE_PATH}\``);
40
56
  }
41
57
  };
42
58
 
43
- compile = function() {
44
- var command, commandParts, compilerProcess, config, error, i, item, itemPath, items, len, milkee, milkeeOptions, options, otherOptionStrings, targetDir;
59
+ compile = async function() {
60
+ var command, commandParts, compilerProcess, config, error, i, item, itemPath, items, len, milkee, milkeeOptions, options, otherOptionStrings, targetDir, toContinue;
45
61
  if (!fs.existsSync(CONFIG_PATH)) {
46
62
  consola.error(`\`${CONFIG_FILE}\` not found in this directory: ${CWD}`);
47
63
  consola.info('Please run `milkee --setup` to create a configuration file.');
@@ -70,6 +86,8 @@
70
86
  if (!fs.existsSync(targetDir)) {
71
87
  consola.info("Refresh skipped.");
72
88
  } else {
89
+ consola.info("Executing: Refresh");
90
+ // Refresh
73
91
  items = fs.readdirSync(targetDir);
74
92
  for (i = 0, len = items.length; i < len; i++) {
75
93
  item = items[i];
@@ -84,23 +102,30 @@
84
102
  }
85
103
  if (options.bare) {
86
104
  otherOptionStrings.push("--bare");
105
+ consola.info("Option `bare` is selected.");
87
106
  }
88
107
  if (options.map) {
89
108
  otherOptionStrings.push('--map');
109
+ consola.info("Option `map` is selected.");
90
110
  }
91
111
  if (options.inlineMap) {
92
112
  otherOptionStrings.push('--inline-map');
113
+ consola.info("Option `inline-map` is selected.");
93
114
  }
94
115
  if (options.noHeader) {
95
116
  otherOptionStrings.push('--no-header');
117
+ consola.info("Option `no-header` is selected.");
96
118
  }
97
119
  if (options.transpile) {
98
120
  otherOptionStrings.push('--transpile');
121
+ consola.info("Option `transpile` is selected.");
99
122
  }
100
123
  if (options.literate) {
101
124
  otherOptionStrings.push('--literate');
125
+ consola.info("Option `literate` is selected.");
102
126
  }
103
127
  if (options.watch) {
128
+ consola.info("Option `watch` is selected.");
104
129
  otherOptionStrings.push('--watch');
105
130
  }
106
131
  if (otherOptionStrings.length > 0) {
@@ -109,6 +134,12 @@
109
134
  commandParts.push('--compile');
110
135
  commandParts.push(`\"${config.entry}\"`);
111
136
  command = commandParts.filter(Boolean).join(' ');
137
+ if (milkeeOptions.confirm) {
138
+ toContinue = (await consola.prompt("Do you want to continue?"));
139
+ if (toContinue !== true) {
140
+ return;
141
+ }
142
+ }
112
143
  if (options.watch) {
113
144
  consola.start(`Watching for changes in \`${config.entry}\`...`);
114
145
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "milkee",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "A simple CoffeeScript build tool with coffee.config.js",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
@@ -25,6 +25,8 @@ module.exports = {
25
25
  options: {
26
26
  // Before compiling, reset the directory.
27
27
  // refresh: false,
28
+ // Before compiling, confirm "Do you want to Continue?"
29
+ // confirm: false
28
30
  },
29
31
  plugins: []
30
32
  },
@@ -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"