@granite-js/cli 0.1.10 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @granite-js/cli
2
2
 
3
+ ## 0.1.12
4
+
5
+ ### Patch Changes
6
+
7
+ - d1e6585: fix module resolutions
8
+ - Updated dependencies [d1e6585]
9
+ - Updated dependencies [1e99fe1]
10
+ - @granite-js/mpack@0.1.12
11
+ - @granite-js/plugin-core@0.1.12
12
+ - @granite-js/utils@0.1.12
13
+
14
+ ## 0.1.11
15
+
16
+ ### Patch Changes
17
+
18
+ - 12f568f: improve error handler
19
+ - Updated dependencies [12f568f]
20
+ - Updated dependencies [d3a2b58]
21
+ - @granite-js/mpack@0.1.11
22
+ - @granite-js/plugin-core@0.1.11
23
+ - @granite-js/utils@0.1.11
24
+
3
25
  ## 0.1.10
4
26
 
5
27
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -40,6 +40,20 @@ var import_mpack = require("@granite-js/mpack");
40
40
  var import_plugins = require("@granite-js/mpack/plugins");
41
41
  var import_plugin_core = require("@granite-js/plugin-core");
42
42
  var import_clipanion = require("clipanion");
43
+
44
+ // src/utils/command.ts
45
+ var import_chalk = __toESM(require("chalk"), 1);
46
+ function errorHandler(error) {
47
+ const label = import_chalk.default.red("Error");
48
+ if (error instanceof Error) {
49
+ console.error(label, error.message);
50
+ } else {
51
+ console.error(label, "Unknown error", (error ?? "")?.toString());
52
+ }
53
+ return 1 /* ERROR */;
54
+ }
55
+
56
+ // src/commands/BuildCommand/BuildCommand.ts
43
57
  var BuildCommand = class extends import_clipanion.Command {
44
58
  static paths = [[`build`]];
45
59
  static usage = import_clipanion.Command.Usage({
@@ -71,17 +85,16 @@ var BuildCommand = class extends import_clipanion.Command {
71
85
  outfile: `bundle.${platform}.js`
72
86
  }));
73
87
  await import_mpack.BuildUtils.buildAll(options, { config, plugins: [import_plugins.statusPlugin] });
74
- return 0;
88
+ return 0 /* SUCCESS */;
75
89
  } catch (error) {
76
- console.error(error);
77
- return 1;
90
+ return errorHandler(error);
78
91
  }
79
92
  }
80
93
  };
81
94
 
82
95
  // src/commands/HermesCommand/HermesCommand.ts
83
96
  var import_path2 = __toESM(require("path"), 1);
84
- var import_chalk = __toESM(require("chalk"), 1);
97
+ var import_chalk2 = __toESM(require("chalk"), 1);
85
98
  var import_clipanion2 = require("clipanion");
86
99
 
87
100
  // src/utils/compileHbc.ts
@@ -150,14 +163,13 @@ var HermesCommand = class extends import_clipanion2.Command {
150
163
  const rootDir = process.cwd();
151
164
  const filePath = import_path2.default.resolve(rootDir, this.jsBundleFile);
152
165
  const { outfile, sourcemapOutfile } = await compileHbc({ rootDir, filePath, sourcemap: this.sourcemap });
153
- console.log(`\u2705 \uCEF4\uD30C\uC77C \uC644\uB8CC: ${import_chalk.default.gray(outfile)}`);
166
+ console.log(`\u2705 Compiled successfully: ${import_chalk2.default.gray(outfile)}`);
154
167
  if (sourcemapOutfile) {
155
- console.log(`\u2705 \uC18C\uC2A4\uB9F5 \uC0DD\uC131 \uC644\uB8CC: ${import_chalk.default.gray(sourcemapOutfile)}`);
168
+ console.log(`\u2705 Source map generated successfully: ${import_chalk2.default.gray(sourcemapOutfile)}`);
156
169
  }
157
- return 0;
170
+ return 0 /* SUCCESS */;
158
171
  } catch (error) {
159
- console.error(error.stack);
160
- return 1;
172
+ return errorHandler(error);
161
173
  }
162
174
  }
163
175
  };
@@ -205,12 +217,9 @@ var DevCommand = class extends import_clipanion3.Command {
205
217
  ...serverOptions
206
218
  });
207
219
  }
220
+ return 0 /* SUCCESS */;
208
221
  } catch (error) {
209
- console.log(`ERROR OCCURRED`);
210
- console.log(error);
211
- console.log(error.message);
212
- console.error(error.stack);
213
- process.exit(1);
222
+ return errorHandler(error);
214
223
  }
215
224
  }
216
225
  };
package/dist/index.js CHANGED
@@ -14,6 +14,20 @@ import { BuildUtils } from "@granite-js/mpack";
14
14
  import { statusPlugin } from "@granite-js/mpack/plugins";
15
15
  import { loadConfig } from "@granite-js/plugin-core";
16
16
  import { Command, Option } from "clipanion";
17
+
18
+ // src/utils/command.ts
19
+ import chalk from "chalk";
20
+ function errorHandler(error) {
21
+ const label = chalk.red("Error");
22
+ if (error instanceof Error) {
23
+ console.error(label, error.message);
24
+ } else {
25
+ console.error(label, "Unknown error", (error ?? "")?.toString());
26
+ }
27
+ return 1 /* ERROR */;
28
+ }
29
+
30
+ // src/commands/BuildCommand/BuildCommand.ts
17
31
  var BuildCommand = class extends Command {
18
32
  static paths = [[`build`]];
19
33
  static usage = Command.Usage({
@@ -45,17 +59,16 @@ var BuildCommand = class extends Command {
45
59
  outfile: `bundle.${platform}.js`
46
60
  }));
47
61
  await BuildUtils.buildAll(options, { config, plugins: [statusPlugin] });
48
- return 0;
62
+ return 0 /* SUCCESS */;
49
63
  } catch (error) {
50
- console.error(error);
51
- return 1;
64
+ return errorHandler(error);
52
65
  }
53
66
  }
54
67
  };
55
68
 
56
69
  // src/commands/HermesCommand/HermesCommand.ts
57
70
  import path2 from "path";
58
- import chalk from "chalk";
71
+ import chalk2 from "chalk";
59
72
  import { Command as Command2, Option as Option2 } from "clipanion";
60
73
 
61
74
  // src/utils/compileHbc.ts
@@ -124,14 +137,13 @@ var HermesCommand = class extends Command2 {
124
137
  const rootDir = process.cwd();
125
138
  const filePath = path2.resolve(rootDir, this.jsBundleFile);
126
139
  const { outfile, sourcemapOutfile } = await compileHbc({ rootDir, filePath, sourcemap: this.sourcemap });
127
- console.log(`\u2705 \uCEF4\uD30C\uC77C \uC644\uB8CC: ${chalk.gray(outfile)}`);
140
+ console.log(`\u2705 Compiled successfully: ${chalk2.gray(outfile)}`);
128
141
  if (sourcemapOutfile) {
129
- console.log(`\u2705 \uC18C\uC2A4\uB9F5 \uC0DD\uC131 \uC644\uB8CC: ${chalk.gray(sourcemapOutfile)}`);
142
+ console.log(`\u2705 Source map generated successfully: ${chalk2.gray(sourcemapOutfile)}`);
130
143
  }
131
- return 0;
144
+ return 0 /* SUCCESS */;
132
145
  } catch (error) {
133
- console.error(error.stack);
134
- return 1;
146
+ return errorHandler(error);
135
147
  }
136
148
  }
137
149
  };
@@ -179,12 +191,9 @@ var DevCommand = class extends Command3 {
179
191
  ...serverOptions
180
192
  });
181
193
  }
194
+ return 0 /* SUCCESS */;
182
195
  } catch (error) {
183
- console.log(`ERROR OCCURRED`);
184
- console.log(error);
185
- console.log(error.message);
186
- console.error(error.stack);
187
- process.exit(1);
196
+ return errorHandler(error);
188
197
  }
189
198
  }
190
199
  };
package/package.json CHANGED
@@ -1,16 +1,21 @@
1
1
  {
2
2
  "name": "@granite-js/cli",
3
3
  "type": "module",
4
- "version": "0.1.10",
4
+ "version": "0.1.12",
5
5
  "description": "The Granite CLI",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/index.d.ts",
12
- "require": "./dist/index.cjs",
13
- "import": "./dist/index.js"
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
14
19
  },
15
20
  "./package.json": "./package.json"
16
21
  },
@@ -44,9 +49,9 @@
44
49
  "vitest": "^3.0.7"
45
50
  },
46
51
  "dependencies": {
47
- "@granite-js/mpack": "0.1.10",
48
- "@granite-js/plugin-core": "0.1.10",
49
- "@granite-js/utils": "0.1.10",
52
+ "@granite-js/mpack": "0.1.12",
53
+ "@granite-js/plugin-core": "0.1.12",
54
+ "@granite-js/utils": "0.1.12",
50
55
  "@inquirer/prompts": "^7.2.3",
51
56
  "@shopify/semaphore": "^3.1.0",
52
57
  "chalk": "^4",