create-h3ravel 0.2.1 → 0.2.3

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,311 +1,329 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
2
+ //#region rolldown:runtime
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
9
  var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
17
18
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
26
23
 
27
- // src/run.ts
28
- var import_commander = require("commander");
29
- var import_chalk2 = __toESM(require("chalk"), 1);
30
- var import_inquirer = __toESM(require("inquirer"), 1);
24
+ //#endregion
25
+ let commander = require("commander");
26
+ commander = __toESM(commander);
27
+ let inquirer = require("inquirer");
28
+ inquirer = __toESM(inquirer);
29
+ let ora = require("ora");
30
+ ora = __toESM(ora);
31
+ let node_path = require("node:path");
32
+ node_path = __toESM(node_path);
33
+ let node_fs_promises = require("node:fs/promises");
34
+ node_fs_promises = __toESM(node_fs_promises);
35
+ let __antfu_install_pkg = require("@antfu/install-pkg");
36
+ __antfu_install_pkg = __toESM(__antfu_install_pkg);
37
+ let __h3ravel_shared = require("@h3ravel/shared");
38
+ __h3ravel_shared = __toESM(__h3ravel_shared);
39
+ let giget = require("giget");
40
+ giget = __toESM(giget);
41
+ let node_fs = require("node:fs");
42
+ node_fs = __toESM(node_fs);
43
+ let __h3ravel_support = require("@h3ravel/support");
44
+ __h3ravel_support = __toESM(__h3ravel_support);
45
+ let __inquirer_core = require("@inquirer/core");
46
+ __inquirer_core = __toESM(__inquirer_core);
31
47
 
32
- // src/templates.ts
33
- var templates = [
34
- {
35
- name: "Full Starter Kit",
36
- alias: "full",
37
- hint: "A full H3ravel application with everything possible",
38
- source: "github:h3ravel/h3ravel"
39
- },
40
- {
41
- name: "Lean Starter Kit",
42
- alias: "lean",
43
- hint: "A lean H3ravel application with just the framework core",
44
- source: null
45
- },
46
- {
47
- name: "API Starter Kit",
48
- alias: "api",
49
- hint: "Creates a H3ravel application for building JSON APIs",
50
- source: null
51
- },
52
- {
53
- name: "Web Starter Kit",
54
- alias: "web",
55
- hint: "Creates a H3ravel application for building a server rendered app",
56
- source: null
57
- },
58
- {
59
- name: "Inertia Starter Kit",
60
- alias: "inertia",
61
- hint: "Inertia application with a frontend framework of your choice",
62
- source: null
63
- }
48
+ //#region src/templates.ts
49
+ /**
50
+ * List of first party templates
51
+ */
52
+ const templates = [
53
+ {
54
+ name: "Full Starter Kit",
55
+ alias: "full",
56
+ hint: "A full H3ravel application with everything possible",
57
+ source: "github:h3ravel/h3ravel"
58
+ },
59
+ {
60
+ name: "Lean Starter Kit",
61
+ alias: "lean",
62
+ hint: "A lean H3ravel application with just the framework core",
63
+ source: null
64
+ },
65
+ {
66
+ name: "API Starter Kit",
67
+ alias: "api",
68
+ hint: "Creates a H3ravel application for building JSON APIs",
69
+ source: null
70
+ },
71
+ {
72
+ name: "Web Starter Kit",
73
+ alias: "web",
74
+ hint: "Creates a H3ravel application for building a server rendered app",
75
+ source: null
76
+ },
77
+ {
78
+ name: "Inertia Starter Kit",
79
+ alias: "inertia",
80
+ hint: "Inertia application with a frontend framework of your choice",
81
+ source: null
82
+ }
64
83
  ];
65
84
 
66
- // src/run.ts
67
- var import_ora = __toESM(require("ora"), 1);
68
-
69
- // src/tsconfig.ts
70
- var mainTsconfig = {
71
- extends: "@h3ravel/shared/tsconfig.json",
72
- compilerOptions: {
73
- baseUrl: ".",
74
- outDir: "dist",
75
- paths: {
76
- "src/*": [
77
- "./../src/*"
78
- ],
79
- "App/*": [
80
- "./../src/app/*"
81
- ],
82
- "root/*": [
83
- "./../*"
84
- ],
85
- "routes/*": [
86
- "./../src/routes/*"
87
- ],
88
- "config/*": [
89
- "./../src/config/*"
90
- ],
91
- "resources/*": [
92
- "./../src/resources/*"
93
- ]
94
- },
95
- target: "es2022",
96
- module: "es2022",
97
- moduleResolution: "Node",
98
- esModuleInterop: true,
99
- strict: true,
100
- allowJs: true,
101
- skipLibCheck: true,
102
- resolveJsonModule: true,
103
- noEmit: true,
104
- experimentalDecorators: true,
105
- emitDecoratorMetadata: true
106
- },
107
- include: [
108
- "./**/*.d.ts",
109
- "./../**/*"
110
- ],
111
- exclude: [
112
- "./dist",
113
- "./node_modules"
114
- ]
115
- };
116
- var baseTsconfig = {
117
- extends: "./.h3ravel/tsconfig.json"
85
+ //#endregion
86
+ //#region src/tsconfig.ts
87
+ const mainTsconfig = {
88
+ extends: "@h3ravel/shared/tsconfig.json",
89
+ compilerOptions: {
90
+ baseUrl: ".",
91
+ outDir: "dist",
92
+ paths: {
93
+ "src/*": ["./../src/*"],
94
+ "App/*": ["./../src/app/*"],
95
+ "root/*": ["./../*"],
96
+ "routes/*": ["./../src/routes/*"],
97
+ "config/*": ["./../src/config/*"],
98
+ "resources/*": ["./../src/resources/*"]
99
+ },
100
+ target: "es2022",
101
+ module: "es2022",
102
+ moduleResolution: "Node",
103
+ esModuleInterop: true,
104
+ strict: true,
105
+ allowJs: true,
106
+ skipLibCheck: true,
107
+ resolveJsonModule: true,
108
+ noEmit: true,
109
+ experimentalDecorators: true,
110
+ emitDecoratorMetadata: true
111
+ },
112
+ include: ["./**/*.d.ts", "./../**/*"],
113
+ exclude: ["./dist", "./node_modules"]
118
114
  };
115
+ const baseTsconfig = { extends: "./.h3ravel/tsconfig.json" };
119
116
 
120
- // src/actions.ts
121
- var import_node_path = require("path");
122
- var import_promises = require("fs/promises");
123
- var import_install_pkg = require("@antfu/install-pkg");
124
- var import_chalk = __toESM(require("chalk"), 1);
125
- var import_giget = require("giget");
126
- var import_node_fs = require("fs");
127
- var import_support = require("@h3ravel/support");
128
- var import_promises2 = require("fs/promises");
117
+ //#endregion
118
+ //#region src/actions.ts
129
119
  var actions_default = class {
130
- static {
131
- __name(this, "default");
132
- }
133
- location;
134
- appName;
135
- description;
136
- skipInstallation;
137
- constructor(location, appName, description) {
138
- this.location = location;
139
- this.appName = appName;
140
- this.description = description;
141
- if (!this.location) {
142
- this.location = (0, import_node_path.join)(process.cwd(), ".temp");
143
- }
144
- }
145
- async download(template, install = false, auth) {
146
- if (this.location?.includes(".temp")) {
147
- await (0, import_promises.rm)(this.location, {
148
- force: true,
149
- recursive: true
150
- });
151
- }
152
- this.skipInstallation = !install;
153
- this.removeLockFile();
154
- return await (0, import_giget.downloadTemplate)(template, {
155
- dir: this.location,
156
- auth,
157
- install,
158
- registry: await (0, import_install_pkg.detectPackageManager)() ?? "npm",
159
- forceClean: false
160
- });
161
- }
162
- async installPackage(name) {
163
- await (0, import_install_pkg.installPackage)(name, {
164
- cwd: this.location,
165
- silent: true
166
- });
167
- }
168
- async complete() {
169
- const packageManager = await (0, import_install_pkg.detectPackageManager)() ?? "npm";
170
- console.log("");
171
- console.log("Your h3ravel project has been created successfully!");
172
- console.log(import_chalk.default.cyan("cd " + (0, import_node_path.relative)(process.cwd(), this.location)));
173
- console.log(import_chalk.default.cyan(`${packageManager} run dev`));
174
- console.log(import_chalk.default.cyan("Open http://localhost:4444"));
175
- console.log("");
176
- console.log(`Have any questions?`);
177
- console.log(`Join our Discord server - ${import_chalk.default.yellow("https://discord.gg/hsG2A8PuGb")}`);
178
- console.log(`Checkout the documentation - ${import_chalk.default.yellow("https://h3ravel.toneflix.net")}`);
179
- }
180
- async cleanup() {
181
- const pkgPath = (0, import_node_path.join)(this.location, "package.json");
182
- const pkg = await (0, import_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
183
- delete pkg.packageManager;
184
- pkg.name = (0, import_support.slugify)(this.appName ?? (0, import_node_path.basename)(this.location).replace(".", ""), "-");
185
- if (this.description) {
186
- pkg.description = this.description;
187
- }
188
- await Promise.allSettled([
189
- (0, import_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2)),
190
- this.removeLockFile(),
191
- (0, import_promises.rm)((0, import_node_path.join)(this.location, "pnpm-workspace.yaml"), {
192
- force: true
193
- }),
194
- (0, import_promises.rm)((0, import_node_path.join)(this.location, "README.md"), {
195
- force: true
196
- }),
197
- (0, import_promises.rm)((0, import_node_path.join)(this.location, ".github"), {
198
- force: true,
199
- recursive: true
200
- })
201
- ]);
202
- }
203
- async removeLockFile() {
204
- if (!this.skipInstallation) {
205
- return;
206
- }
207
- await Promise.allSettled([
208
- (0, import_promises2.unlink)((0, import_node_path.join)(this.location, "package-lock.json")),
209
- (0, import_promises2.unlink)((0, import_node_path.join)(this.location, "yarn.lock")),
210
- (0, import_promises2.unlink)((0, import_node_path.join)(this.location, "pnpm-lock.yaml"))
211
- ]);
212
- }
213
- async getBanner() {
214
- return await (0, import_promises.readFile)((0, import_node_path.join)(process.cwd(), "./logo.txt"), "utf-8");
215
- }
216
- async copyExampleEnv() {
217
- const envPath = (0, import_node_path.join)(this.location, ".env");
218
- const exampleEnvPath = (0, import_node_path.join)(this.location, ".env.example");
219
- if ((0, import_node_fs.existsSync)(exampleEnvPath)) {
220
- await (0, import_promises.copyFile)(exampleEnvPath, envPath);
221
- }
222
- }
223
- async createTsConfig() {
224
- const tscPath = (0, import_node_path.join)(this.location, ".h3ravel");
225
- await (0, import_promises.mkdir)(tscPath, {
226
- recursive: true
227
- });
228
- await (0, import_promises.writeFile)((0, import_node_path.join)(tscPath, "tsconfig.json"), JSON.stringify(mainTsconfig, null, 2));
229
- await (0, import_promises.writeFile)((0, import_node_path.join)(this.location, "tsconfig.json"), JSON.stringify(baseTsconfig, null, 2));
230
- }
120
+ skipInstallation;
121
+ constructor(location, appName, description) {
122
+ this.location = location;
123
+ this.appName = appName;
124
+ this.description = description;
125
+ if (!this.location) this.location = (0, node_path.join)(process.cwd(), ".temp");
126
+ }
127
+ async download(template, install = false, auth) {
128
+ if (this.location?.includes(".temp")) await (0, node_fs_promises.rm)(this.location, {
129
+ force: true,
130
+ recursive: true
131
+ });
132
+ this.skipInstallation = !install;
133
+ this.removeLockFile();
134
+ return await (0, giget.downloadTemplate)(template, {
135
+ dir: this.location,
136
+ auth,
137
+ install,
138
+ registry: await (0, __antfu_install_pkg.detectPackageManager)() ?? "npm",
139
+ forceClean: false
140
+ });
141
+ }
142
+ async installPackage(name) {
143
+ await (0, __antfu_install_pkg.installPackage)(name, {
144
+ cwd: this.location,
145
+ silent: true
146
+ });
147
+ }
148
+ async complete() {
149
+ const packageManager = await (0, __antfu_install_pkg.detectPackageManager)() ?? "npm";
150
+ console.log("");
151
+ __h3ravel_shared.Logger.success("Your h3ravel project has been created successfully");
152
+ __h3ravel_shared.Logger.parse([["cd " + (0, node_path.relative)(process.cwd(), this.location), "cyan"]]);
153
+ __h3ravel_shared.Logger.parse([[`${packageManager} run dev`, "cyan"]]);
154
+ __h3ravel_shared.Logger.parse([["Open http://localhost:4444", "cyan"]]);
155
+ console.log("");
156
+ __h3ravel_shared.Logger.parse([["Have any questions", "white"]]);
157
+ __h3ravel_shared.Logger.parse([["Join our Discord server -", "white"], ["https://discord.gg/hsG2A8PuGb", "yellow"]]);
158
+ __h3ravel_shared.Logger.parse([["Checkout the documentation -", "white"], ["https://h3ravel.toneflix.net", "yellow"]]);
159
+ }
160
+ async cleanup() {
161
+ const pkgPath = (0, node_path.join)(this.location, "package.json");
162
+ const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
163
+ delete pkg.packageManager;
164
+ pkg.name = (0, __h3ravel_support.slugify)(this.appName ?? (0, node_path.basename)(this.location).replace(".", ""), "-");
165
+ if (this.description) pkg.description = this.description;
166
+ await Promise.allSettled([
167
+ (0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2)),
168
+ this.removeLockFile(),
169
+ (0, node_fs_promises.rm)((0, node_path.join)(this.location, "pnpm-workspace.yaml"), { force: true }),
170
+ (0, node_fs_promises.rm)((0, node_path.join)(this.location, "README.md"), { force: true }),
171
+ (0, node_fs_promises.rm)((0, node_path.join)(this.location, ".github"), {
172
+ force: true,
173
+ recursive: true
174
+ })
175
+ ]);
176
+ }
177
+ async removeLockFile() {
178
+ if (!this.skipInstallation) return;
179
+ await Promise.allSettled([
180
+ (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "package-lock.json")),
181
+ (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "yarn.lock")),
182
+ (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "pnpm-lock.yaml"))
183
+ ]);
184
+ }
185
+ async getBanner() {
186
+ return await (0, node_fs_promises.readFile)((0, node_path.join)(process.cwd(), "./logo.txt"), "utf-8");
187
+ }
188
+ async copyExampleEnv() {
189
+ const envPath = (0, node_path.join)(this.location, ".env");
190
+ const exampleEnvPath = (0, node_path.join)(this.location, ".env.example");
191
+ if ((0, node_fs.existsSync)(exampleEnvPath)) await (0, node_fs_promises.copyFile)(exampleEnvPath, envPath);
192
+ }
193
+ async createTsConfig() {
194
+ const tscPath = (0, node_path.join)(this.location, ".h3ravel");
195
+ await (0, node_fs_promises.mkdir)(tscPath, { recursive: true });
196
+ await (0, node_fs_promises.writeFile)((0, node_path.join)(tscPath, "tsconfig.json"), JSON.stringify(mainTsconfig, null, 2));
197
+ await (0, node_fs_promises.writeFile)((0, node_path.join)(this.location, "tsconfig.json"), JSON.stringify(baseTsconfig, null, 2));
198
+ }
231
199
  };
232
200
 
233
- // src/run.ts
234
- var import_node_path2 = require("path");
235
- var import_support2 = require("@h3ravel/support");
236
- var program = new import_commander.Command();
237
- program.name("create-h3ravel").description("CLI to create new h3ravel app").version("0.1.0");
238
- program.option("-n, --name <string>", "The name of your project.").option("-i, --install", "Install node_modules right away.").option("-t, --token <string>", "Kit repo authentication token.").option("-d, --desc <string>", "Project Description.").option('-k, --kit <string>", "Starter template kit').addArgument(new import_commander.Argument("[location]", "The location where this project should be created relative to the current dir.")).action(async (pathName, options) => {
239
- let { appName, description } = await import_inquirer.default.prompt([
240
- {
241
- type: "input",
242
- name: "appName",
243
- message: "What is the name of your project:",
244
- default: "h3ravel",
245
- when: /* @__PURE__ */ __name(() => !options.name, "when")
246
- },
247
- {
248
- type: "input",
249
- name: "description",
250
- message: "Project Description:",
251
- when: /* @__PURE__ */ __name(() => !options.desc, "when")
252
- }
253
- ]);
254
- let { template, install, location, token } = await import_inquirer.default.prompt([
255
- {
256
- type: "input",
257
- name: "location",
258
- message: "Installation location relative to the current dir:",
259
- default: (0, import_support2.slugify)(options.name ?? appName ?? (0, import_node_path2.basename)(process.cwd()), "-"),
260
- when: /* @__PURE__ */ __name(() => !pathName, "when")
261
- },
262
- {
263
- type: "list",
264
- name: "template",
265
- message: "Choose starter template kit:",
266
- choices: templates.map((e) => ({
267
- name: e.name,
268
- value: e.alias,
269
- disabled: !e.source ? "(Unavailable at this time)" : false
270
- })),
271
- default: "full",
272
- when: /* @__PURE__ */ __name(() => !options.kit, "when")
273
- },
274
- {
275
- type: "input",
276
- name: "token",
277
- message: "Authentication token:",
278
- when: /* @__PURE__ */ __name(() => options.kit && !options.token, "when")
279
- },
280
- {
281
- type: "confirm",
282
- name: "install",
283
- message: "Would you want to install node_modules right away:",
284
- default: true,
285
- when: /* @__PURE__ */ __name(() => !options.install, "when")
286
- }
287
- ]);
288
- token = options.token ?? token;
289
- appName = options.name ?? appName;
290
- install = options.install ?? install;
291
- template = options.kit ?? template;
292
- location = pathName ?? location;
293
- description = options.description ?? description;
294
- const kit = templates.find((e) => e.alias === template);
295
- if (kit && !kit.source) {
296
- console.log(import_chalk2.default.bgRed(" Error: "), import_chalk2.default.red(`The ${kit.name} kit is not currently available`));
297
- process.exit(1);
298
- }
299
- const actions = new actions_default((0, import_node_path2.join)(process.cwd(), location), appName, description);
300
- const spinner = (0, import_ora.default)(`Loading Template...`).start();
301
- await actions.download(kit?.source ?? template, install);
302
- spinner.info(import_chalk2.default.green("Cleaning Up...")).start();
303
- await actions.cleanup();
304
- spinner.info(import_chalk2.default.green("Initializing Project...")).start();
305
- await actions.copyExampleEnv();
306
- await actions.createTsConfig();
307
- spinner.succeed(import_chalk2.default.green("Project initialized successfully!"));
308
- await actions.complete();
309
- });
310
- program.parse();
201
+ //#endregion
202
+ //#region src/logo.ts
203
+ const logo = String.raw`
204
+ 111
205
+ 111111111
206
+ 1111111111 111111
207
+ 111111 111 111111
208
+ 111111 111 111111
209
+ 11111 111 11111
210
+ 1111111 111 1111111
211
+ 111 11111 111 111111 111 1111 1111 11111111 1111
212
+ 111 11111 1111 111111 111 1111 1111 1111 11111 1111
213
+ 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
214
+ 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
215
+ 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
216
+ 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
217
+ 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
218
+ 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
219
+ 11011 111111 11 11111
220
+ 111111 11101 111111
221
+ 111111 111 111111
222
+ 111111 111 111111
223
+ 111111111
224
+ 110
225
+ `;
226
+ const altLogo = String.raw`%c
227
+ _ _ _____ _
228
+ | | | |___ / _ __ __ ___ _____| |
229
+ | |_| | |_ \| '__/ _ \ \ / / _ \ |
230
+ | _ |___) | | | (_| |\ V / __/ |
231
+ |_| |_|____/|_| \__,_| \_/ \___|_|
232
+
233
+ `;
234
+
235
+ //#endregion
236
+ //#region src/run.ts
237
+ async function main() {
238
+ const program = new commander.Command();
239
+ program.name("create-h3ravel").description("CLI to create new h3ravel app").version("0.1.0");
240
+ program.option("-n, --name <string>", "The name of your project.").option("-i, --install", "Install node_modules right away.").option("-t, --token <string>", "Kit repo authentication token.").option("-d, --desc <string>", "Project Description.").option("-k, --kit <string>\", \"Starter template kit").addArgument(new commander.Argument("[location]", "The location where this project should be created relative to the current dir.")).action(async (pathName, options) => {
241
+ console.log(altLogo, `font-family: monospace`);
242
+ let { appName, description } = await inquirer.default.prompt([{
243
+ type: "input",
244
+ name: "appName",
245
+ message: "What is the name of your project:",
246
+ default: "h3ravel",
247
+ when: () => !options.name
248
+ }, {
249
+ type: "input",
250
+ name: "description",
251
+ message: "Project Description:",
252
+ default: "Modern TypeScript runtime-agnostic web framework built on top of H3.",
253
+ when: () => !options.desc
254
+ }]).catch((err) => {
255
+ if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
256
+ __h3ravel_shared.Logger.info("Thanks for trying out H3ravel.");
257
+ process.exit(0);
258
+ }
259
+ return err;
260
+ });
261
+ let { template, install, location, token } = await inquirer.default.prompt([
262
+ {
263
+ type: "input",
264
+ name: "location",
265
+ message: "Installation location relative to the current dir:",
266
+ default: (0, __h3ravel_support.slugify)(options.name ?? appName ?? (0, node_path.basename)(process.cwd()), "-"),
267
+ when: () => !pathName
268
+ },
269
+ {
270
+ type: "list",
271
+ name: "template",
272
+ message: "Choose starter template kit:",
273
+ choices: templates.map((e) => ({
274
+ name: e.name,
275
+ value: e.alias,
276
+ disabled: !e.source ? "(Unavailable at this time)" : false
277
+ })),
278
+ default: "full",
279
+ when: () => !options.kit
280
+ },
281
+ {
282
+ type: "input",
283
+ name: "token",
284
+ message: "Authentication token:",
285
+ when: () => options.kit && !options.token
286
+ },
287
+ {
288
+ type: "confirm",
289
+ name: "install",
290
+ message: "Would you want to install node_modules right away:",
291
+ default: true,
292
+ when: () => !options.install
293
+ }
294
+ ]).catch((err) => {
295
+ if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
296
+ __h3ravel_shared.Logger.info("Thanks for trying out H3ravel.");
297
+ process.exit(0);
298
+ }
299
+ return err;
300
+ });
301
+ token = options.token ?? token;
302
+ appName = options.name ?? appName;
303
+ install = options.install ?? install;
304
+ template = options.kit ?? template;
305
+ location = pathName ?? location;
306
+ description = options.description ?? description;
307
+ const kit = templates.find((e) => e.alias === template);
308
+ if (kit && !kit.source) {
309
+ __h3ravel_shared.Logger.error(`ERROR: The ${kit.name} kit is not currently available`);
310
+ process.exit(1);
311
+ }
312
+ const actions = new actions_default((0, node_path.join)(process.cwd(), location), appName, description);
313
+ const spinner = (0, ora.default)(`Loading Template...`).start();
314
+ await actions.download(kit?.source ?? template, install);
315
+ spinner.info(__h3ravel_shared.Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
316
+ await actions.cleanup();
317
+ spinner.info(__h3ravel_shared.Logger.parse([["Initializing Project...", "green"]], "", false)).start();
318
+ await actions.copyExampleEnv();
319
+ await actions.createTsConfig();
320
+ spinner.succeed(__h3ravel_shared.Logger.parse([["Project initialization complete!", "green"]], "", false));
321
+ await actions.complete();
322
+ });
323
+ program.parse();
324
+ process.on("SIGINT", () => {});
325
+ }
326
+ main();
327
+
328
+ //#endregion
311
329
  //# sourceMappingURL=run.cjs.map