create-h3ravel 0.6.1 → 0.6.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/run.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- //#region rolldown:runtime
2
+ //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -20,33 +20,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
-
24
23
  //#endregion
25
- let __h3ravel_musket = require("@h3ravel/musket");
26
- __h3ravel_musket = __toESM(__h3ravel_musket);
24
+ let _h3ravel_musket = require("@h3ravel/musket");
27
25
  let inquirer = require("inquirer");
28
- inquirer = __toESM(inquirer);
29
- let __inquirer_core = require("@inquirer/core");
30
- __inquirer_core = __toESM(__inquirer_core);
26
+ inquirer = __toESM(inquirer, 1);
27
+ let _inquirer_core = require("@inquirer/core");
31
28
  let node_path = require("node:path");
32
- node_path = __toESM(node_path);
33
- let __h3ravel_support = require("@h3ravel/support");
34
- __h3ravel_support = __toESM(__h3ravel_support);
35
- let __h3ravel_shared = require("@h3ravel/shared");
36
- __h3ravel_shared = __toESM(__h3ravel_shared);
29
+ let _h3ravel_support = require("@h3ravel/support");
30
+ let _h3ravel_shared = require("@h3ravel/shared");
37
31
  let node_fs_promises = require("node:fs/promises");
38
- node_fs_promises = __toESM(node_fs_promises);
39
- let __antfu_install_pkg = require("@antfu/install-pkg");
40
- __antfu_install_pkg = __toESM(__antfu_install_pkg);
32
+ let _antfu_install_pkg = require("@antfu/install-pkg");
41
33
  let giget = require("giget");
42
- giget = __toESM(giget);
43
34
  let node_fs = require("node:fs");
44
- node_fs = __toESM(node_fs);
45
35
  let ora = require("ora");
46
- ora = __toESM(ora);
47
-
48
- //#region src/logo.ts
49
- const logo = String.raw`
36
+ ora = __toESM(ora, 1);
37
+ String.raw`
50
38
  111
51
39
  111111111
52
40
  1111111111 111111
@@ -77,7 +65,6 @@ const altLogo = String.raw`%c
77
65
  |_| |_|____/|_| \__,_| \_/ \___|_|
78
66
 
79
67
  `;
80
-
81
68
  //#endregion
82
69
  //#region src/templates.ts
83
70
  /**
@@ -88,37 +75,44 @@ const templates = [
88
75
  name: "Full Starter Kit",
89
76
  alias: "full",
90
77
  hint: "A full H3ravel application with everything possible",
91
- source: "github:h3ravel/h3ravel"
78
+ source: "github:h3ravel/h3ravel#3fbb538",
79
+ prereleaseSource: "github:h3ravel/h3ravel#fe175fa"
92
80
  },
93
81
  {
94
82
  name: "Lean Starter Kit",
95
83
  alias: "lean",
96
84
  hint: "A lean H3ravel application with just the framework core",
97
- source: null
85
+ source: void 0,
86
+ prereleaseSource: void 0
98
87
  },
99
88
  {
100
89
  name: "API Starter Kit",
101
90
  alias: "api",
102
91
  hint: "Creates a H3ravel application for building JSON APIs",
103
- source: null
92
+ source: void 0,
93
+ prereleaseSource: void 0
104
94
  },
105
95
  {
106
96
  name: "Web Starter Kit",
107
97
  alias: "web",
108
98
  hint: "Creates a H3ravel application for building a server rendered app",
109
- source: null
99
+ source: void 0,
100
+ prereleaseSource: void 0
110
101
  },
111
102
  {
112
103
  name: "Inertia Starter Kit",
113
104
  alias: "inertia",
114
105
  hint: "Inertia application with a frontend framework of your choice",
115
- source: null
106
+ source: void 0,
107
+ prereleaseSource: void 0
116
108
  }
117
109
  ];
118
-
119
110
  //#endregion
120
111
  //#region src/actions.ts
121
112
  var actions_default = class {
113
+ location;
114
+ appName;
115
+ description;
122
116
  skipInstallation;
123
117
  constructor(location, appName, description) {
124
118
  this.location = location;
@@ -133,7 +127,7 @@ var actions_default = class {
133
127
  });
134
128
  else if ((0, node_fs.existsSync)(this.location)) {
135
129
  console.log("\n");
136
- __h3ravel_shared.Logger.parse([
130
+ _h3ravel_shared.Logger.parse([
137
131
  [" ERROR ", "bgRed"],
138
132
  [this.location, ["gray", "italic"]],
139
133
  ["is not empty.", "white"]
@@ -147,34 +141,35 @@ var actions_default = class {
147
141
  dir: this.location,
148
142
  auth,
149
143
  install,
150
- registry: await (0, __antfu_install_pkg.detectPackageManager)() ?? "npm",
144
+ registry: await (0, _antfu_install_pkg.detectPackageManager)() ?? "npm",
151
145
  forceClean: false
152
146
  });
153
147
  }
154
148
  async installPackage(name) {
155
- await (0, __antfu_install_pkg.installPackage)(name, {
149
+ await (0, _antfu_install_pkg.installPackage)(name, {
156
150
  cwd: this.location,
157
151
  silent: true
158
152
  });
159
153
  }
160
154
  async complete(installed = false) {
161
155
  console.log("");
162
- __h3ravel_shared.Logger.success("Your h3ravel project has been created successfully");
163
- __h3ravel_shared.Logger.parse([["cd", "cyan"], ["./" + (0, node_path.relative)(process.cwd(), this.location), "green"]]);
164
- if (!installed) __h3ravel_shared.Logger.parse([[await __h3ravel_shared.Resolver.getPakageInstallCommand(), "cyan"]]);
165
- __h3ravel_shared.Logger.parse([["npx", "cyan"], ["musket fire", "green"]], " ");
166
- __h3ravel_shared.Logger.parse([["Open http://localhost:3000", "cyan"]]);
156
+ _h3ravel_shared.Logger.success("Your h3ravel project has been created successfully");
157
+ _h3ravel_shared.Logger.parse([["cd", "cyan"], ["./" + (0, node_path.relative)(process.cwd(), this.location), "green"]]);
158
+ if (!installed) _h3ravel_shared.Logger.parse([[await _h3ravel_shared.Resolver.getPakageInstallCommand(), "cyan"]]);
159
+ _h3ravel_shared.Logger.parse([["npx", "cyan"], ["prepare", "green"]], " ");
160
+ _h3ravel_shared.Logger.parse([["npx", "cyan"], ["musket fire", "green"]], " ");
161
+ _h3ravel_shared.Logger.parse([["Open http://localhost:3000", "cyan"]]);
167
162
  console.log("");
168
- __h3ravel_shared.Logger.parse([["Have any questions", "white"]]);
169
- __h3ravel_shared.Logger.parse([["Join our Discord server -", "white"], ["https://discord.gg/hsG2A8PuGb", "yellow"]]);
170
- __h3ravel_shared.Logger.parse([["Checkout the documentation -", "white"], ["https://h3ravel.toneflix.net", "yellow"]]);
163
+ _h3ravel_shared.Logger.parse([["Have any questions", "white"]]);
164
+ _h3ravel_shared.Logger.parse([["Join our Discord server -", "white"], ["https://discord.gg/hsG2A8PuGb", "yellow"]]);
165
+ _h3ravel_shared.Logger.parse([["Checkout the documentation -", "white"], ["https://h3ravel.toneflix.net", "yellow"]]);
171
166
  }
172
167
  async cleanup() {
173
168
  const pkgPath = (0, node_path.join)(this.location, "package.json");
174
169
  const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
175
170
  delete pkg.packageManager;
176
- pkg.name = __h3ravel_support.Str.slugify(this.appName ?? (0, node_path.basename)(this.location).replace(".", ""), "-");
177
- pkg.scripts = __h3ravel_shared.packageJsonScript;
171
+ pkg.name = _h3ravel_support.Str.slugify(this.appName ?? (0, node_path.basename)(this.location).replace(".", ""), "-");
172
+ pkg.scripts = _h3ravel_shared.packageJsonScript;
178
173
  if (this.description) pkg.description = this.description;
179
174
  await Promise.allSettled([
180
175
  (0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2)),
@@ -206,15 +201,14 @@ var actions_default = class {
206
201
  async createTsConfig() {
207
202
  const tscPath = (0, node_path.join)(this.location, ".h3ravel");
208
203
  await (0, node_fs_promises.mkdir)(tscPath, { recursive: true });
209
- await (0, node_fs_promises.writeFile)((0, node_path.join)(tscPath, "tsconfig.json"), JSON.stringify(__h3ravel_shared.mainTsconfig, null, 2));
210
- await (0, node_fs_promises.writeFile)((0, node_path.join)(this.location, "tsconfig.json"), JSON.stringify(__h3ravel_shared.baseTsconfig, null, 2));
204
+ await (0, node_fs_promises.writeFile)((0, node_path.join)(tscPath, "tsconfig.json"), JSON.stringify(_h3ravel_shared.mainTsconfig, null, 2));
205
+ await (0, node_fs_promises.writeFile)((0, node_path.join)(this.location, "tsconfig.json"), JSON.stringify(_h3ravel_shared.baseTsconfig, null, 2));
211
206
  if (!(0, node_fs.existsSync)((0, node_path.join)(this.location, "src/database/db.sqlite"))) await (0, node_fs_promises.writeFile)((0, node_path.join)(this.location, "src/database/db.sqlite"), "");
212
207
  }
213
208
  };
214
-
215
209
  //#endregion
216
210
  //#region src/Commands/CreateH3ravelCommand.ts
217
- var CreateH3ravelCommand = class extends __h3ravel_musket.Command {
211
+ var CreateH3ravelCommand = class extends _h3ravel_musket.Command {
218
212
  signature = `create-h3ravel
219
213
  {location?: The location where this project should be created relative to the current dir.}
220
214
  {--n|name?: The name of your project.}
@@ -222,6 +216,7 @@ var CreateH3ravelCommand = class extends __h3ravel_musket.Command {
222
216
  {--t|token?: Kit repo authentication token.}
223
217
  {--d|desc?: Project Description.}
224
218
  {--k|kit?: Starter template kit.}
219
+ {--p|pre: Download prerelease version if available.}
225
220
  {--o|overwrite: Overwrite the installation directory if it is not empty.}
226
221
  `;
227
222
  description = "Display a personalized greeting.";
@@ -242,31 +237,47 @@ var CreateH3ravelCommand = class extends __h3ravel_musket.Command {
242
237
  default: "Modern TypeScript runtime-agnostic web framework built on top of H3.",
243
238
  when: () => !options.desc
244
239
  }]).catch((err) => {
245
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
240
+ if (err instanceof _inquirer_core.AbortPromptError || err instanceof _inquirer_core.ExitPromptError) {
246
241
  this.info("Thanks for trying out H3ravel.");
247
242
  process.exit(0);
248
243
  }
249
244
  return err;
250
245
  });
251
- let { template, install, location, token } = await inquirer.default.prompt([
252
- {
253
- type: "input",
254
- name: "location",
255
- message: "Installation location relative to the current dir:",
256
- default: __h3ravel_support.Str.slugify(options.name ?? appName ?? (0, node_path.basename)(process.cwd()), "-"),
257
- when: () => !pathName
258
- },
246
+ let { location, template } = await inquirer.default.prompt([{
247
+ type: "input",
248
+ name: "location",
249
+ message: "Installation location relative to the current dir:",
250
+ default: _h3ravel_support.Str.slugify(options.name ?? appName ?? (0, node_path.basename)(process.cwd()), "-"),
251
+ when: () => !pathName
252
+ }, {
253
+ type: "list",
254
+ name: "template",
255
+ message: "Choose starter template kit:",
256
+ choices: templates.map((e) => ({
257
+ name: e.name,
258
+ value: e.alias,
259
+ disabled: !e.source ? "(Unavailable at this time)" : false
260
+ })),
261
+ default: "full",
262
+ when: () => !options.kit
263
+ }]).catch((err) => {
264
+ if (err instanceof _inquirer_core.AbortPromptError || err instanceof _inquirer_core.ExitPromptError) {
265
+ this.info("Thanks for trying out H3ravel.");
266
+ process.exit(0);
267
+ }
268
+ return err;
269
+ });
270
+ /**
271
+ * Find selected template kit
272
+ */
273
+ const kit = templates.find((e) => e.alias === template);
274
+ let { install, token, pre } = await inquirer.default.prompt([
259
275
  {
260
- type: "list",
261
- name: "template",
262
- message: "Choose starter template kit:",
263
- choices: templates.map((e) => ({
264
- name: e.name,
265
- value: e.alias,
266
- disabled: !e.source ? "(Unavailable at this time)" : false
267
- })),
268
- default: "full",
269
- when: () => !options.kit
276
+ type: "confirm",
277
+ name: "pre",
278
+ message: `An alpha version of the ${kit.name.replace(/\s*kit$/i, "").trim()} kit is available. Would you like to use it instead?`,
279
+ default: false,
280
+ when: () => kit.prereleaseSource && !options.pre
270
281
  },
271
282
  {
272
283
  type: "input",
@@ -282,40 +293,41 @@ var CreateH3ravelCommand = class extends __h3ravel_musket.Command {
282
293
  when: () => !options.install
283
294
  }
284
295
  ]).catch((err) => {
285
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
296
+ if (err instanceof _inquirer_core.AbortPromptError || err instanceof _inquirer_core.ExitPromptError) {
286
297
  this.info("Thanks for trying out H3ravel.");
287
298
  process.exit(0);
288
299
  }
289
300
  return err;
290
301
  });
302
+ pre = options.pre ?? pre;
291
303
  token = options.token ?? token;
292
304
  appName = options.name ?? appName;
293
305
  install = options.install ?? install;
294
306
  template = options.kit ?? template;
295
307
  location = pathName ?? location;
296
308
  description = options.description ?? description;
297
- const kit = templates.find((e) => e.alias === template);
309
+ /**
310
+ * Validate selected kit
311
+ */
298
312
  if (kit && !kit.source) {
299
313
  this.error(`ERROR: The ${kit.name} kit is not currently available`);
300
314
  process.exit(1);
301
315
  }
316
+ const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
302
317
  const actions = new actions_default((0, node_path.join)(process.cwd(), location), appName, description);
303
318
  const spinner = (0, ora.default)(`Loading Template...`).start();
304
- await actions.download(kit?.source ?? template, install, void 0, options.overwrite);
305
- spinner.info(__h3ravel_shared.Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
319
+ await actions.download(source, install, void 0, options.overwrite);
320
+ spinner.info(_h3ravel_shared.Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
306
321
  await actions.cleanup();
307
- spinner.info(__h3ravel_shared.Logger.parse([["Initializing Project...", "green"]], "", false)).start();
322
+ spinner.info(_h3ravel_shared.Logger.parse([["Initializing Project...", "green"]], "", false)).start();
308
323
  await actions.copyExampleEnv();
309
324
  await actions.createTsConfig();
310
- spinner.succeed(__h3ravel_shared.Logger.parse([["Project initialization complete!", "green"]], "", false));
325
+ spinner.succeed(_h3ravel_shared.Logger.parse([["Project initialization complete!", "green"]], "", false));
311
326
  await actions.complete(install);
312
327
  }
313
328
  };
314
-
315
329
  //#endregion
316
330
  //#region src/run.ts
317
331
  var Application = class {};
318
- __h3ravel_musket.Kernel.init(new Application(), { rootCommand: CreateH3ravelCommand });
319
-
332
+ _h3ravel_musket.Kernel.init(new Application(), { rootCommand: CreateH3ravelCommand });
320
333
  //#endregion
321
- //# sourceMappingURL=run.cjs.map
@@ -10,9 +10,7 @@ import { detectPackageManager, installPackage } from "@antfu/install-pkg";
10
10
  import { downloadTemplate } from "giget";
11
11
  import { existsSync } from "node:fs";
12
12
  import ora from "ora";
13
-
14
- //#region src/logo.ts
15
- const logo = String.raw`
13
+ String.raw`
16
14
  111
17
15
  111111111
18
16
  1111111111 111111
@@ -43,7 +41,6 @@ const altLogo = String.raw`%c
43
41
  |_| |_|____/|_| \__,_| \_/ \___|_|
44
42
 
45
43
  `;
46
-
47
44
  //#endregion
48
45
  //#region src/templates.ts
49
46
  /**
@@ -54,37 +51,44 @@ const templates = [
54
51
  name: "Full Starter Kit",
55
52
  alias: "full",
56
53
  hint: "A full H3ravel application with everything possible",
57
- source: "github:h3ravel/h3ravel"
54
+ source: "github:h3ravel/h3ravel#3fbb538",
55
+ prereleaseSource: "github:h3ravel/h3ravel#fe175fa"
58
56
  },
59
57
  {
60
58
  name: "Lean Starter Kit",
61
59
  alias: "lean",
62
60
  hint: "A lean H3ravel application with just the framework core",
63
- source: null
61
+ source: void 0,
62
+ prereleaseSource: void 0
64
63
  },
65
64
  {
66
65
  name: "API Starter Kit",
67
66
  alias: "api",
68
67
  hint: "Creates a H3ravel application for building JSON APIs",
69
- source: null
68
+ source: void 0,
69
+ prereleaseSource: void 0
70
70
  },
71
71
  {
72
72
  name: "Web Starter Kit",
73
73
  alias: "web",
74
74
  hint: "Creates a H3ravel application for building a server rendered app",
75
- source: null
75
+ source: void 0,
76
+ prereleaseSource: void 0
76
77
  },
77
78
  {
78
79
  name: "Inertia Starter Kit",
79
80
  alias: "inertia",
80
81
  hint: "Inertia application with a frontend framework of your choice",
81
- source: null
82
+ source: void 0,
83
+ prereleaseSource: void 0
82
84
  }
83
85
  ];
84
-
85
86
  //#endregion
86
87
  //#region src/actions.ts
87
88
  var actions_default = class {
89
+ location;
90
+ appName;
91
+ description;
88
92
  skipInstallation;
89
93
  constructor(location, appName, description) {
90
94
  this.location = location;
@@ -128,6 +132,7 @@ var actions_default = class {
128
132
  Logger.success("Your h3ravel project has been created successfully");
129
133
  Logger.parse([["cd", "cyan"], ["./" + relative(process.cwd(), this.location), "green"]]);
130
134
  if (!installed) Logger.parse([[await Resolver.getPakageInstallCommand(), "cyan"]]);
135
+ Logger.parse([["npx", "cyan"], ["prepare", "green"]], " ");
131
136
  Logger.parse([["npx", "cyan"], ["musket fire", "green"]], " ");
132
137
  Logger.parse([["Open http://localhost:3000", "cyan"]]);
133
138
  console.log("");
@@ -177,7 +182,6 @@ var actions_default = class {
177
182
  if (!existsSync(join(this.location, "src/database/db.sqlite"))) await writeFile(join(this.location, "src/database/db.sqlite"), "");
178
183
  }
179
184
  };
180
-
181
185
  //#endregion
182
186
  //#region src/Commands/CreateH3ravelCommand.ts
183
187
  var CreateH3ravelCommand = class extends Command {
@@ -188,6 +192,7 @@ var CreateH3ravelCommand = class extends Command {
188
192
  {--t|token?: Kit repo authentication token.}
189
193
  {--d|desc?: Project Description.}
190
194
  {--k|kit?: Starter template kit.}
195
+ {--p|pre: Download prerelease version if available.}
191
196
  {--o|overwrite: Overwrite the installation directory if it is not empty.}
192
197
  `;
193
198
  description = "Display a personalized greeting.";
@@ -214,25 +219,41 @@ var CreateH3ravelCommand = class extends Command {
214
219
  }
215
220
  return err;
216
221
  });
217
- let { template, install, location, token } = await inquirer.prompt([
218
- {
219
- type: "input",
220
- name: "location",
221
- message: "Installation location relative to the current dir:",
222
- default: Str.slugify(options.name ?? appName ?? basename(process.cwd()), "-"),
223
- when: () => !pathName
224
- },
222
+ let { location, template } = await inquirer.prompt([{
223
+ type: "input",
224
+ name: "location",
225
+ message: "Installation location relative to the current dir:",
226
+ default: Str.slugify(options.name ?? appName ?? basename(process.cwd()), "-"),
227
+ when: () => !pathName
228
+ }, {
229
+ type: "list",
230
+ name: "template",
231
+ message: "Choose starter template kit:",
232
+ choices: templates.map((e) => ({
233
+ name: e.name,
234
+ value: e.alias,
235
+ disabled: !e.source ? "(Unavailable at this time)" : false
236
+ })),
237
+ default: "full",
238
+ when: () => !options.kit
239
+ }]).catch((err) => {
240
+ if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
241
+ this.info("Thanks for trying out H3ravel.");
242
+ process.exit(0);
243
+ }
244
+ return err;
245
+ });
246
+ /**
247
+ * Find selected template kit
248
+ */
249
+ const kit = templates.find((e) => e.alias === template);
250
+ let { install, token, pre } = await inquirer.prompt([
225
251
  {
226
- type: "list",
227
- name: "template",
228
- message: "Choose starter template kit:",
229
- choices: templates.map((e) => ({
230
- name: e.name,
231
- value: e.alias,
232
- disabled: !e.source ? "(Unavailable at this time)" : false
233
- })),
234
- default: "full",
235
- when: () => !options.kit
252
+ type: "confirm",
253
+ name: "pre",
254
+ message: `An alpha version of the ${kit.name.replace(/\s*kit$/i, "").trim()} kit is available. Would you like to use it instead?`,
255
+ default: false,
256
+ when: () => kit.prereleaseSource && !options.pre
236
257
  },
237
258
  {
238
259
  type: "input",
@@ -254,20 +275,24 @@ var CreateH3ravelCommand = class extends Command {
254
275
  }
255
276
  return err;
256
277
  });
278
+ pre = options.pre ?? pre;
257
279
  token = options.token ?? token;
258
280
  appName = options.name ?? appName;
259
281
  install = options.install ?? install;
260
282
  template = options.kit ?? template;
261
283
  location = pathName ?? location;
262
284
  description = options.description ?? description;
263
- const kit = templates.find((e) => e.alias === template);
285
+ /**
286
+ * Validate selected kit
287
+ */
264
288
  if (kit && !kit.source) {
265
289
  this.error(`ERROR: The ${kit.name} kit is not currently available`);
266
290
  process.exit(1);
267
291
  }
292
+ const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
268
293
  const actions = new actions_default(join(process.cwd(), location), appName, description);
269
294
  const spinner = ora(`Loading Template...`).start();
270
- await actions.download(kit?.source ?? template, install, void 0, options.overwrite);
295
+ await actions.download(source, install, void 0, options.overwrite);
271
296
  spinner.info(Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
272
297
  await actions.cleanup();
273
298
  spinner.info(Logger.parse([["Initializing Project...", "green"]], "", false)).start();
@@ -277,12 +302,9 @@ var CreateH3ravelCommand = class extends Command {
277
302
  await actions.complete(install);
278
303
  }
279
304
  };
280
-
281
305
  //#endregion
282
306
  //#region src/run.ts
283
307
  var Application = class {};
284
308
  Kernel.init(new Application(), { rootCommand: CreateH3ravelCommand });
285
-
286
309
  //#endregion
287
- export { };
288
- //# sourceMappingURL=run.js.map
310
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-h3ravel",
3
3
  "type": "module",
4
- "version": "0.6.1",
4
+ "version": "0.6.4",
5
5
  "description": "Scaffold a new H3ravel applications using templates and starter kits",
6
6
  "main": "build/index.js",
7
7
  "private": false,
@@ -25,25 +25,25 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@antfu/install-pkg": "1.1.0",
28
- "@h3ravel/musket": "^0.2.0",
29
- "@h3ravel/shared": "^0.22.2",
30
- "@h3ravel/support": "^0.14.1",
28
+ "@h3ravel/collect.js": "^5.3.7",
29
+ "@h3ravel/musket": "^0.10.1",
30
+ "@h3ravel/shared": "^0.28.4",
31
+ "@h3ravel/support": "^0.16.1",
31
32
  "@inquirer/core": "^10.2.2",
32
33
  "giget": "^2.0.0",
33
34
  "inquirer": "^12.9.6",
34
35
  "ora": "^9.0.0"
35
36
  },
36
37
  "devDependencies": {
37
- "@changesets/cli": "^2.29.5",
38
- "@swc/core": "^1.6.1",
39
- "@types/node": "^20.14.5",
40
- "eslint": "^9.32.0",
38
+ "@changesets/cli": "^2.31.0",
39
+ "@swc/core": "^1.15.41",
40
+ "@types/node": "^25.9.3",
41
+ "eslint": "^10.4.1",
41
42
  "ts-node": "^10.9.2",
42
- "tsdown": "^0.15.4",
43
- "tsx": "^4.20.3",
44
- "typescript": "^5.4.5",
45
- "vite-tsconfig-paths": "^5.1.4",
46
- "vitest": "^3.2.4"
43
+ "tsdown": "^0.22.2",
44
+ "tsx": "^4.22.4",
45
+ "typescript": "^6.0.3",
46
+ "vitest": "^4.1.8"
47
47
  },
48
48
  "scripts": {
49
49
  "quick:test": "pnpm vitest",
package/bin/run.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.cjs","names":["location?: string","appName?: string","description?: string","Resolver","Str","packageJsonScript","mainTsconfig","baseTsconfig","Command","AbortPromptError","ExitPromptError","Str","Actions","Logger","Kernel"],"sources":["../src/logo.ts","../src/templates.ts","../src/actions.ts","../src/Commands/CreateH3ravelCommand.ts","../src/run.ts"],"sourcesContent":["export const logo = String.raw`\n 111 \n 111111111 \n 1111111111 111111 \n 111111 111 111111 \n 111111 111 111111 \n11111 111 11111 \n1111111 111 1111111 \n111 11111 111 111111 111 1111 1111 11111111 1111\n111 11111 1111 111111 111 1111 1111 1111 11111 1111\n111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111\n111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111\n111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101\n111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111\n111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111\n1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111\n11011 111111 11 11111 \n 111111 11101 111111 \n 111111 111 111111 \n 111111 111 111111 \n 111111111 \n 110 \n`\n\nexport const altLogo = String.raw`%c\n _ _ _____ _ \n| | | |___ / _ __ __ ___ _____| |\n| |_| | |_ \\| '__/ _ \\ \\ / / _ \\ |\n| _ |___) | | | (_| |\\ V / __/ |\n|_| |_|____/|_| \\__,_| \\_/ \\___|_|\n\n`\n","/*\n * create-h3ravel\n *\n * (c) H3ravel Framework\n *\n * The H3ravel framework and all it's base packages are \n * open-sourced software licensed under the MIT license.\n */\n\n/**\n * List of first party templates\n */\nexport const templates = [\n {\n name: 'Full Starter Kit',\n alias: 'full',\n hint: 'A full H3ravel application with everything possible',\n source: 'github:h3ravel/h3ravel',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: null,\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: null\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: null\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: null\n },\n]\n","import { Logger, Resolver, baseTsconfig, mainTsconfig, packageJsonScript } from \"@h3ravel/shared\";\nimport { basename, join, relative } from \"node:path\";\nimport { copyFile, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport { Str } from \"@h3ravel/support\";\nimport { downloadTemplate } from \"giget\";\nimport { existsSync } from \"node:fs\";\nimport { unlink } from \"node:fs/promises\";\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(private location?: string, private appName?: string, private description?: string) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async download (template: string, install = false, auth?: string, overwrite = false) {\n if (this.location?.includes('.temp') || (overwrite && existsSync(this.location!))) {\n await rm(this.location!, { force: true, recursive: true })\n } else if (existsSync(this.location!)) {\n console.log('\\n')\n Logger.parse([[' ERROR ', 'bgRed'], [this.location!, ['gray', 'italic']], ['is not empty.', 'white']], ' ')\n console.log('')\n process.exit(0)\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n return await downloadTemplate(template, {\n dir: this.location,\n auth,\n install,\n registry: (await detectPackageManager()) ?? 'npm',\n forceClean: false\n });\n }\n\n async installPackage (name: string) {\n await installPackage(name, {\n cwd: this.location,\n silent: true,\n })\n }\n\n async complete (installed = false) {\n console.log('')\n\n Logger.success('Your h3ravel project has been created successfully')\n Logger.parse([['cd', 'cyan'], ['./' + relative(process.cwd(), this.location!), 'green']])\n if (!installed) {\n Logger.parse([[await Resolver.getPakageInstallCommand(), 'cyan']])\n }\n Logger.parse([['npx', 'cyan'], ['musket fire', 'green']], ' ')\n Logger.parse([['Open http://localhost:3000', 'cyan']])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n Logger.parse([['Join our Discord server -', 'white'], ['https://discord.gg/hsG2A8PuGb', 'yellow']])\n Logger.parse([['Checkout the documentation -', 'white'], ['https://h3ravel.toneflix.net', 'yellow']])\n }\n\n async cleanup () {\n const pkgPath = join(this.location!, 'package.json')\n const pkg = await readFile(pkgPath!, 'utf-8').then(JSON.parse)\n\n delete pkg.packageManager\n pkg.name = Str.slugify(this.appName ?? basename(this.location!).replace('.', ''), '-')\n pkg.scripts = packageJsonScript\n if (this.description) {\n pkg.description = this.description\n }\n\n await Promise.allSettled([\n writeFile(pkgPath, JSON.stringify(pkg, null, 2)),\n this.removeLockFile(),\n rm(join(this.location!, 'pnpm-workspace.yaml'), { force: true }),\n rm(join(this.location!, 'README.md'), { force: true }),\n rm(join(this.location!, '.github'), { force: true, recursive: true }),\n ])\n }\n\n async removeLockFile () {\n if (!this.skipInstallation) {\n return\n }\n\n await Promise.allSettled([\n unlink(join(this.location!, 'package-lock.json')),\n unlink(join(this.location!, 'yarn.lock')),\n unlink(join(this.location!, 'pnpm-lock.yaml')),\n ])\n }\n\n async getBanner () {\n return await readFile(join(process.cwd(), './logo.txt'), 'utf-8')\n }\n\n async copyExampleEnv () {\n const envPath = join(this.location!, '.env')\n const exampleEnvPath = join(this.location!, '.env.example')\n\n if (existsSync(exampleEnvPath)) {\n await copyFile(exampleEnvPath, envPath)\n }\n }\n\n async createTsConfig () {\n const tscPath = join(this.location!, '.h3ravel')\n\n await mkdir(tscPath, { recursive: true })\n await writeFile(join(tscPath, 'tsconfig.json'), JSON.stringify(mainTsconfig, null, 2))\n await writeFile(join(this.location!, 'tsconfig.json'), JSON.stringify(baseTsconfig, null, 2))\n if (!existsSync(join(this.location!, 'src/database/db.sqlite'))) {\n await writeFile(join(this.location!, 'src/database/db.sqlite'), '')\n }\n }\n}\n","import { Command } from \"@h3ravel/musket\";\nimport { altLogo } from \"src/logo\";\nimport inquirer from \"inquirer\";\nimport { AbortPromptError, ExitPromptError } from \"@inquirer/core\";\nimport { basename, join } from \"node:path\";\nimport { templates } from \"src/templates\";\nimport { Str } from \"@h3ravel/support\";\nimport Actions from 'src/actions';\nimport ora from \"ora\";\nimport { Logger } from \"@h3ravel/shared\";\n\nexport class CreateH3ravelCommand extends Command {\n protected signature = `create-h3ravel\n {location?: The location where this project should be created relative to the current dir.}\n {--n|name?: The name of your project.}\n {--i|install: Install node_modules right away}\n {--t|token?: Kit repo authentication token.}\n {--d|desc?: Project Description.}\n {--k|kit?: Starter template kit.}\n {--o|overwrite: Overwrite the installation directory if it is not empty.}\n `;\n protected description = 'Display a personalized greeting.';\n\n async handle () {\n const options = this.options();\n const pathName = this.argument('location');\n\n console.log(altLogo, `font-family: monospace`)\n\n let { appName, description } = await inquirer.prompt([\n {\n type: \"input\",\n name: \"appName\",\n message: \"What is the name of your project:\",\n default: 'h3ravel',\n when: () => !options.name,\n },\n {\n type: \"input\",\n name: \"description\",\n message: \"Project Description:\",\n default: 'Modern TypeScript runtime-agnostic web framework built on top of H3.',\n when: () => !options.desc,\n }]\n ).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n let { template, install, location, token } = await inquirer.prompt([{\n type: \"input\",\n name: \"location\",\n message: \"Installation location relative to the current dir:\",\n default: Str.slugify(options.name ?? appName ?? basename(process.cwd()), '-'),\n when: () => !pathName,\n },\n {\n type: \"list\",\n name: \"template\",\n message: \"Choose starter template kit:\",\n choices: <never>templates.map(e => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n {\n type: \"input\",\n name: \"token\",\n message: \"Authentication token:\",\n when: () => options.kit && !options.token,\n },\n {\n type: 'confirm',\n name: \"install\",\n message: \"Would you want to install node_modules right away:\",\n default: true,\n when: () => !options.install,\n }]).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n token = options.token ?? token\n appName = options.name ?? appName\n install = options.install ?? install\n template = options.kit ?? template\n location = pathName ?? location\n description = options.description ?? description\n\n const kit = templates.find(e => e.alias === template)!\n\n if (kit && !kit.source) {\n this.error(`ERROR: The ${kit.name} kit is not currently available`)\n process.exit(1)\n }\n\n const actions = new Actions(join(process.cwd(), location), appName, description);\n\n const spinner = ora(`Loading Template...`).start();\n await actions.download(kit?.source ?? template, install, undefined, options.overwrite);\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start();\n await actions.cleanup()\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n\n await actions.complete(install)\n }\n}\n","#!/usr/bin/env node\n\nimport { CreateH3ravelCommand } from './Commands/CreateH3ravelCommand';\nimport { Kernel } from '@h3ravel/musket';\n\nclass Application { }\n\nKernel.init(new Application(), {\n rootCommand: CreateH3ravelCommand\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAa,OAAO,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;AAwB9B,MAAa,UAAU,OAAO,GAAG;;;;;;;;;;;;;;ACZjC,MAAa,YAAY;CACrB;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACJ;;;;ACjCD,4BAAqB;CACjB;CAEA,YAAY,AAAQA,UAAmB,AAAQC,SAAkB,AAAQC,aAAsB;EAA3E;EAA2B;EAA0B;AACrE,MAAI,CAAC,KAAK,SACN,MAAK,+BAAgB,QAAQ,KAAK,EAAE,QAAQ;;CAIpD,MAAM,SAAU,UAAkB,UAAU,OAAO,MAAe,YAAY,OAAO;AACjF,MAAI,KAAK,UAAU,SAAS,QAAQ,IAAK,qCAAwB,KAAK,SAAU,CAC5E,gCAAS,KAAK,UAAW;GAAE,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?: string","Actions"],"sources":["../src/logo.ts","../src/templates.ts","../src/actions.ts","../src/Commands/CreateH3ravelCommand.ts","../src/run.ts"],"sourcesContent":["export const logo = String.raw`\n 111 \n 111111111 \n 1111111111 111111 \n 111111 111 111111 \n 111111 111 111111 \n11111 111 11111 \n1111111 111 1111111 \n111 11111 111 111111 111 1111 1111 11111111 1111\n111 11111 1111 111111 111 1111 1111 1111 11111 1111\n111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111\n111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111\n111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101\n111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111\n111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111\n1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111\n11011 111111 11 11111 \n 111111 11101 111111 \n 111111 111 111111 \n 111111 111 111111 \n 111111111 \n 110 \n`\n\nexport const altLogo = String.raw`%c\n _ _ _____ _ \n| | | |___ / _ __ __ ___ _____| |\n| |_| | |_ \\| '__/ _ \\ \\ / / _ \\ |\n| _ |___) | | | (_| |\\ V / __/ |\n|_| |_|____/|_| \\__,_| \\_/ \\___|_|\n\n`\n","/*\n * create-h3ravel\n *\n * (c) H3ravel Framework\n *\n * The H3ravel framework and all it's base packages are \n * open-sourced software licensed under the MIT license.\n */\n\n/**\n * List of first party templates\n */\nexport const templates = [\n {\n name: 'Full Starter Kit',\n alias: 'full',\n hint: 'A full H3ravel application with everything possible',\n source: 'github:h3ravel/h3ravel',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: null,\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: null\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: null\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: null\n },\n]\n","import { Logger, Resolver, baseTsconfig, mainTsconfig, packageJsonScript } from \"@h3ravel/shared\";\nimport { basename, join, relative } from \"node:path\";\nimport { copyFile, mkdir, readFile, rm, writeFile } from \"node:fs/promises\";\nimport { detectPackageManager, installPackage } from \"@antfu/install-pkg\";\n\nimport { Str } from \"@h3ravel/support\";\nimport { downloadTemplate } from \"giget\";\nimport { existsSync } from \"node:fs\";\nimport { unlink } from \"node:fs/promises\";\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(private location?: string, private appName?: string, private description?: string) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async download (template: string, install = false, auth?: string, overwrite = false) {\n if (this.location?.includes('.temp') || (overwrite && existsSync(this.location!))) {\n await rm(this.location!, { force: true, recursive: true })\n } else if (existsSync(this.location!)) {\n console.log('\\n')\n Logger.parse([[' ERROR ', 'bgRed'], [this.location!, ['gray', 'italic']], ['is not empty.', 'white']], ' ')\n console.log('')\n process.exit(0)\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n return await downloadTemplate(template, {\n dir: this.location,\n auth,\n install,\n registry: (await detectPackageManager()) ?? 'npm',\n forceClean: false\n });\n }\n\n async installPackage (name: string) {\n await installPackage(name, {\n cwd: this.location,\n silent: true,\n })\n }\n\n async complete (installed = false) {\n console.log('')\n\n Logger.success('Your h3ravel project has been created successfully')\n Logger.parse([['cd', 'cyan'], ['./' + relative(process.cwd(), this.location!), 'green']])\n if (!installed) {\n Logger.parse([[await Resolver.getPakageInstallCommand(), 'cyan']])\n }\n Logger.parse([['npx', 'cyan'], ['musket fire', 'green']], ' ')\n Logger.parse([['Open http://localhost:3000', 'cyan']])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n Logger.parse([['Join our Discord server -', 'white'], ['https://discord.gg/hsG2A8PuGb', 'yellow']])\n Logger.parse([['Checkout the documentation -', 'white'], ['https://h3ravel.toneflix.net', 'yellow']])\n }\n\n async cleanup () {\n const pkgPath = join(this.location!, 'package.json')\n const pkg = await readFile(pkgPath!, 'utf-8').then(JSON.parse)\n\n delete pkg.packageManager\n pkg.name = Str.slugify(this.appName ?? basename(this.location!).replace('.', ''), '-')\n pkg.scripts = packageJsonScript\n if (this.description) {\n pkg.description = this.description\n }\n\n await Promise.allSettled([\n writeFile(pkgPath, JSON.stringify(pkg, null, 2)),\n this.removeLockFile(),\n rm(join(this.location!, 'pnpm-workspace.yaml'), { force: true }),\n rm(join(this.location!, 'README.md'), { force: true }),\n rm(join(this.location!, '.github'), { force: true, recursive: true }),\n ])\n }\n\n async removeLockFile () {\n if (!this.skipInstallation) {\n return\n }\n\n await Promise.allSettled([\n unlink(join(this.location!, 'package-lock.json')),\n unlink(join(this.location!, 'yarn.lock')),\n unlink(join(this.location!, 'pnpm-lock.yaml')),\n ])\n }\n\n async getBanner () {\n return await readFile(join(process.cwd(), './logo.txt'), 'utf-8')\n }\n\n async copyExampleEnv () {\n const envPath = join(this.location!, '.env')\n const exampleEnvPath = join(this.location!, '.env.example')\n\n if (existsSync(exampleEnvPath)) {\n await copyFile(exampleEnvPath, envPath)\n }\n }\n\n async createTsConfig () {\n const tscPath = join(this.location!, '.h3ravel')\n\n await mkdir(tscPath, { recursive: true })\n await writeFile(join(tscPath, 'tsconfig.json'), JSON.stringify(mainTsconfig, null, 2))\n await writeFile(join(this.location!, 'tsconfig.json'), JSON.stringify(baseTsconfig, null, 2))\n if (!existsSync(join(this.location!, 'src/database/db.sqlite'))) {\n await writeFile(join(this.location!, 'src/database/db.sqlite'), '')\n }\n }\n}\n","import { Command } from \"@h3ravel/musket\";\nimport { altLogo } from \"src/logo\";\nimport inquirer from \"inquirer\";\nimport { AbortPromptError, ExitPromptError } from \"@inquirer/core\";\nimport { basename, join } from \"node:path\";\nimport { templates } from \"src/templates\";\nimport { Str } from \"@h3ravel/support\";\nimport Actions from 'src/actions';\nimport ora from \"ora\";\nimport { Logger } from \"@h3ravel/shared\";\n\nexport class CreateH3ravelCommand extends Command {\n protected signature = `create-h3ravel\n {location?: The location where this project should be created relative to the current dir.}\n {--n|name?: The name of your project.}\n {--i|install: Install node_modules right away}\n {--t|token?: Kit repo authentication token.}\n {--d|desc?: Project Description.}\n {--k|kit?: Starter template kit.}\n {--o|overwrite: Overwrite the installation directory if it is not empty.}\n `;\n protected description = 'Display a personalized greeting.';\n\n async handle () {\n const options = this.options();\n const pathName = this.argument('location');\n\n console.log(altLogo, `font-family: monospace`)\n\n let { appName, description } = await inquirer.prompt([\n {\n type: \"input\",\n name: \"appName\",\n message: \"What is the name of your project:\",\n default: 'h3ravel',\n when: () => !options.name,\n },\n {\n type: \"input\",\n name: \"description\",\n message: \"Project Description:\",\n default: 'Modern TypeScript runtime-agnostic web framework built on top of H3.',\n when: () => !options.desc,\n }]\n ).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n let { template, install, location, token } = await inquirer.prompt([{\n type: \"input\",\n name: \"location\",\n message: \"Installation location relative to the current dir:\",\n default: Str.slugify(options.name ?? appName ?? basename(process.cwd()), '-'),\n when: () => !pathName,\n },\n {\n type: \"list\",\n name: \"template\",\n message: \"Choose starter template kit:\",\n choices: <never>templates.map(e => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n {\n type: \"input\",\n name: \"token\",\n message: \"Authentication token:\",\n when: () => options.kit && !options.token,\n },\n {\n type: 'confirm',\n name: \"install\",\n message: \"Would you want to install node_modules right away:\",\n default: true,\n when: () => !options.install,\n }]).catch(err => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out H3ravel.')\n process.exit(0)\n }\n return err\n })\n\n token = options.token ?? token\n appName = options.name ?? appName\n install = options.install ?? install\n template = options.kit ?? template\n location = pathName ?? location\n description = options.description ?? description\n\n const kit = templates.find(e => e.alias === template)!\n\n if (kit && !kit.source) {\n this.error(`ERROR: The ${kit.name} kit is not currently available`)\n process.exit(1)\n }\n\n const actions = new Actions(join(process.cwd(), location), appName, description);\n\n const spinner = ora(`Loading Template...`).start();\n await actions.download(kit?.source ?? template, install, undefined, options.overwrite);\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start();\n await actions.cleanup()\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start();\n await actions.copyExampleEnv()\n await actions.createTsConfig()\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n\n await actions.complete(install)\n }\n}\n","#!/usr/bin/env node\n\nimport { CreateH3ravelCommand } from './Commands/CreateH3ravelCommand';\nimport { Kernel } from '@h3ravel/musket';\n\nclass Application { }\n\nKernel.init(new Application(), {\n rootCommand: CreateH3ravelCommand\n})\n"],"mappings":";;;;;;;;;;;;;;AAAA,MAAa,OAAO,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;AAwB9B,MAAa,UAAU,OAAO,GAAG;;;;;;;;;;;;;;ACZjC,MAAa,YAAY;CACrB;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACX;CACJ;;;;ACjCD,4BAAqB;CACjB;CAEA,YAAY,AAAQA,UAAmB,AAAQC,SAAkB,AAAQC,aAAsB;EAA3E;EAA2B;EAA0B;AACrE,MAAI,CAAC,KAAK,SACN,MAAK,WAAW,KAAK,QAAQ,KAAK,EAAE,QAAQ;;CAIpD,MAAM,SAAU,UAAkB,UAAU,OAAO,MAAe,YAAY,OAAO;AACjF,MAAI,K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