create-h3ravel 0.6.4 → 2.1.2

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.mjs CHANGED
@@ -52,7 +52,7 @@ const templates = [
52
52
  alias: "full",
53
53
  hint: "A full H3ravel application with everything possible",
54
54
  source: "github:h3ravel/h3ravel#3fbb538",
55
- prereleaseSource: "github:h3ravel/h3ravel#fe175fa"
55
+ prereleaseSource: "github:h3ravel/h3ravel#45d7678"
56
56
  },
57
57
  {
58
58
  name: "Lean Starter Kit",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-h3ravel",
3
3
  "type": "module",
4
- "version": "0.6.4",
4
+ "version": "2.1.2",
5
5
  "description": "Scaffold a new H3ravel applications using templates and starter kits",
6
6
  "main": "build/index.js",
7
7
  "private": false,
@@ -26,9 +26,9 @@
26
26
  "dependencies": {
27
27
  "@antfu/install-pkg": "1.1.0",
28
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",
29
+ "@h3ravel/musket": "^2.0.0",
30
+ "@h3ravel/shared": "^2.1.2",
31
+ "@h3ravel/support": "^2.1.2",
32
32
  "@inquirer/core": "^10.2.2",
33
33
  "giget": "^2.0.0",
34
34
  "inquirer": "^12.9.6",
@@ -36,19 +36,21 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@changesets/cli": "^2.31.0",
39
+ "@eslint/js": "^10.0.1",
39
40
  "@swc/core": "^1.15.41",
40
41
  "@types/node": "^25.9.3",
41
42
  "eslint": "^10.4.1",
43
+ "globals": "^17.6.0",
42
44
  "ts-node": "^10.9.2",
43
45
  "tsdown": "^0.22.2",
44
- "tsx": "^4.22.4",
45
46
  "typescript": "^6.0.3",
47
+ "typescript-eslint": "^8.61.0",
46
48
  "vitest": "^4.1.8"
47
49
  },
48
50
  "scripts": {
49
51
  "quick:test": "pnpm vitest",
50
52
  "test": "pnpm run quick:test",
51
- "runner": "tsx --experimental-specifier-resolution=node src/run.ts",
53
+ "runner": "pnpm build && node bin/run.mjs",
52
54
  "build": "tsdown",
53
55
  "version": "pnpm run build",
54
56
  "unlink": "npm unlink -g create-h3ravel",
package/bin/run.cjs DELETED
@@ -1,333 +0,0 @@
1
- #!/usr/bin/env node
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
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;
18
- };
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));
23
- //#endregion
24
- let _h3ravel_musket = require("@h3ravel/musket");
25
- let inquirer = require("inquirer");
26
- inquirer = __toESM(inquirer, 1);
27
- let _inquirer_core = require("@inquirer/core");
28
- let node_path = require("node:path");
29
- let _h3ravel_support = require("@h3ravel/support");
30
- let _h3ravel_shared = require("@h3ravel/shared");
31
- let node_fs_promises = require("node:fs/promises");
32
- let _antfu_install_pkg = require("@antfu/install-pkg");
33
- let giget = require("giget");
34
- let node_fs = require("node:fs");
35
- let ora = require("ora");
36
- ora = __toESM(ora, 1);
37
- String.raw`
38
- 111
39
- 111111111
40
- 1111111111 111111
41
- 111111 111 111111
42
- 111111 111 111111
43
- 11111 111 11111
44
- 1111111 111 1111111
45
- 111 11111 111 111111 111 1111 1111 11111111 1111
46
- 111 11111 1111 111111 111 1111 1111 1111 11111 1111
47
- 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
48
- 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
49
- 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
50
- 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
51
- 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
52
- 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
53
- 11011 111111 11 11111
54
- 111111 11101 111111
55
- 111111 111 111111
56
- 111111 111 111111
57
- 111111111
58
- 110
59
- `;
60
- const altLogo = String.raw`%c
61
- _ _ _____ _
62
- | | | |___ / _ __ __ ___ _____| |
63
- | |_| | |_ \| '__/ _ \ \ / / _ \ |
64
- | _ |___) | | | (_| |\ V / __/ |
65
- |_| |_|____/|_| \__,_| \_/ \___|_|
66
-
67
- `;
68
- //#endregion
69
- //#region src/templates.ts
70
- /**
71
- * List of first party templates
72
- */
73
- const templates = [
74
- {
75
- name: "Full Starter Kit",
76
- alias: "full",
77
- hint: "A full H3ravel application with everything possible",
78
- source: "github:h3ravel/h3ravel#3fbb538",
79
- prereleaseSource: "github:h3ravel/h3ravel#fe175fa"
80
- },
81
- {
82
- name: "Lean Starter Kit",
83
- alias: "lean",
84
- hint: "A lean H3ravel application with just the framework core",
85
- source: void 0,
86
- prereleaseSource: void 0
87
- },
88
- {
89
- name: "API Starter Kit",
90
- alias: "api",
91
- hint: "Creates a H3ravel application for building JSON APIs",
92
- source: void 0,
93
- prereleaseSource: void 0
94
- },
95
- {
96
- name: "Web Starter Kit",
97
- alias: "web",
98
- hint: "Creates a H3ravel application for building a server rendered app",
99
- source: void 0,
100
- prereleaseSource: void 0
101
- },
102
- {
103
- name: "Inertia Starter Kit",
104
- alias: "inertia",
105
- hint: "Inertia application with a frontend framework of your choice",
106
- source: void 0,
107
- prereleaseSource: void 0
108
- }
109
- ];
110
- //#endregion
111
- //#region src/actions.ts
112
- var actions_default = class {
113
- location;
114
- appName;
115
- description;
116
- skipInstallation;
117
- constructor(location, appName, description) {
118
- this.location = location;
119
- this.appName = appName;
120
- this.description = description;
121
- if (!this.location) this.location = (0, node_path.join)(process.cwd(), ".temp");
122
- }
123
- async download(template, install = false, auth, overwrite = false) {
124
- if (this.location?.includes(".temp") || overwrite && (0, node_fs.existsSync)(this.location)) await (0, node_fs_promises.rm)(this.location, {
125
- force: true,
126
- recursive: true
127
- });
128
- else if ((0, node_fs.existsSync)(this.location)) {
129
- console.log("\n");
130
- _h3ravel_shared.Logger.parse([
131
- [" ERROR ", "bgRed"],
132
- [this.location, ["gray", "italic"]],
133
- ["is not empty.", "white"]
134
- ], " ");
135
- console.log("");
136
- process.exit(0);
137
- }
138
- this.skipInstallation = !install;
139
- this.removeLockFile();
140
- return await (0, giget.downloadTemplate)(template, {
141
- dir: this.location,
142
- auth,
143
- install,
144
- registry: await (0, _antfu_install_pkg.detectPackageManager)() ?? "npm",
145
- forceClean: false
146
- });
147
- }
148
- async installPackage(name) {
149
- await (0, _antfu_install_pkg.installPackage)(name, {
150
- cwd: this.location,
151
- silent: true
152
- });
153
- }
154
- async complete(installed = false) {
155
- console.log("");
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"]]);
162
- console.log("");
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"]]);
166
- }
167
- async cleanup() {
168
- const pkgPath = (0, node_path.join)(this.location, "package.json");
169
- const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
170
- delete pkg.packageManager;
171
- pkg.name = _h3ravel_support.Str.slugify(this.appName ?? (0, node_path.basename)(this.location).replace(".", ""), "-");
172
- pkg.scripts = _h3ravel_shared.packageJsonScript;
173
- if (this.description) pkg.description = this.description;
174
- await Promise.allSettled([
175
- (0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2)),
176
- this.removeLockFile(),
177
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, "pnpm-workspace.yaml"), { force: true }),
178
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, "README.md"), { force: true }),
179
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, ".github"), {
180
- force: true,
181
- recursive: true
182
- })
183
- ]);
184
- }
185
- async removeLockFile() {
186
- if (!this.skipInstallation) return;
187
- await Promise.allSettled([
188
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "package-lock.json")),
189
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "yarn.lock")),
190
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "pnpm-lock.yaml"))
191
- ]);
192
- }
193
- async getBanner() {
194
- return await (0, node_fs_promises.readFile)((0, node_path.join)(process.cwd(), "./logo.txt"), "utf-8");
195
- }
196
- async copyExampleEnv() {
197
- const envPath = (0, node_path.join)(this.location, ".env");
198
- const exampleEnvPath = (0, node_path.join)(this.location, ".env.example");
199
- if ((0, node_fs.existsSync)(exampleEnvPath)) await (0, node_fs_promises.copyFile)(exampleEnvPath, envPath);
200
- }
201
- async createTsConfig() {
202
- const tscPath = (0, node_path.join)(this.location, ".h3ravel");
203
- await (0, node_fs_promises.mkdir)(tscPath, { recursive: true });
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));
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"), "");
207
- }
208
- };
209
- //#endregion
210
- //#region src/Commands/CreateH3ravelCommand.ts
211
- var CreateH3ravelCommand = class extends _h3ravel_musket.Command {
212
- signature = `create-h3ravel
213
- {location?: The location where this project should be created relative to the current dir.}
214
- {--n|name?: The name of your project.}
215
- {--i|install: Install node_modules right away}
216
- {--t|token?: Kit repo authentication token.}
217
- {--d|desc?: Project Description.}
218
- {--k|kit?: Starter template kit.}
219
- {--p|pre: Download prerelease version if available.}
220
- {--o|overwrite: Overwrite the installation directory if it is not empty.}
221
- `;
222
- description = "Display a personalized greeting.";
223
- async handle() {
224
- const options = this.options();
225
- const pathName = this.argument("location");
226
- console.log(altLogo, `font-family: monospace`);
227
- let { appName, description } = await inquirer.default.prompt([{
228
- type: "input",
229
- name: "appName",
230
- message: "What is the name of your project:",
231
- default: "h3ravel",
232
- when: () => !options.name
233
- }, {
234
- type: "input",
235
- name: "description",
236
- message: "Project Description:",
237
- default: "Modern TypeScript runtime-agnostic web framework built on top of H3.",
238
- when: () => !options.desc
239
- }]).catch((err) => {
240
- if (err instanceof _inquirer_core.AbortPromptError || err instanceof _inquirer_core.ExitPromptError) {
241
- this.info("Thanks for trying out H3ravel.");
242
- process.exit(0);
243
- }
244
- return err;
245
- });
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([
275
- {
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
281
- },
282
- {
283
- type: "input",
284
- name: "token",
285
- message: "Authentication token:",
286
- when: () => options.kit && !options.token
287
- },
288
- {
289
- type: "confirm",
290
- name: "install",
291
- message: "Would you want to install node_modules right away:",
292
- default: true,
293
- when: () => !options.install
294
- }
295
- ]).catch((err) => {
296
- if (err instanceof _inquirer_core.AbortPromptError || err instanceof _inquirer_core.ExitPromptError) {
297
- this.info("Thanks for trying out H3ravel.");
298
- process.exit(0);
299
- }
300
- return err;
301
- });
302
- pre = options.pre ?? pre;
303
- token = options.token ?? token;
304
- appName = options.name ?? appName;
305
- install = options.install ?? install;
306
- template = options.kit ?? template;
307
- location = pathName ?? location;
308
- description = options.description ?? description;
309
- /**
310
- * Validate selected kit
311
- */
312
- if (kit && !kit.source) {
313
- this.error(`ERROR: The ${kit.name} kit is not currently available`);
314
- process.exit(1);
315
- }
316
- const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
317
- const actions = new actions_default((0, node_path.join)(process.cwd(), location), appName, description);
318
- const spinner = (0, ora.default)(`Loading Template...`).start();
319
- await actions.download(source, install, void 0, options.overwrite);
320
- spinner.info(_h3ravel_shared.Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
321
- await actions.cleanup();
322
- spinner.info(_h3ravel_shared.Logger.parse([["Initializing Project...", "green"]], "", false)).start();
323
- await actions.copyExampleEnv();
324
- await actions.createTsConfig();
325
- spinner.succeed(_h3ravel_shared.Logger.parse([["Project initialization complete!", "green"]], "", false));
326
- await actions.complete(install);
327
- }
328
- };
329
- //#endregion
330
- //#region src/run.ts
331
- var Application = class {};
332
- _h3ravel_musket.Kernel.init(new Application(), { rootCommand: CreateH3ravelCommand });
333
- //#endregion
package/bin/run.d.cts DELETED
@@ -1 +0,0 @@
1
- export { };