create-h3ravel 0.2.1 → 0.2.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 +310 -292
- package/bin/run.cjs.map +1 -1
- package/bin/run.d.cts +1 -1
- package/bin/run.d.ts +1 -1
- package/bin/run.js +284 -277
- package/bin/run.js.map +1 -1
- package/package.json +4 -3
- package/bin/logo.txt +0 -21
package/bin/run.cjs
CHANGED
|
@@ -1,311 +1,329 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
121
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
})
|
|
310
|
-
|
|
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
|