create-h3ravel 0.6.3 → 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.
@@ -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
  /**
@@ -55,7 +52,7 @@ const templates = [
55
52
  alias: "full",
56
53
  hint: "A full H3ravel application with everything possible",
57
54
  source: "github:h3ravel/h3ravel#3fbb538",
58
- prereleaseSource: "github:h3ravel/h3ravel#2eec534"
55
+ prereleaseSource: "github:h3ravel/h3ravel#45d7678"
59
56
  },
60
57
  {
61
58
  name: "Lean Starter Kit",
@@ -86,10 +83,12 @@ const templates = [
86
83
  prereleaseSource: void 0
87
84
  }
88
85
  ];
89
-
90
86
  //#endregion
91
87
  //#region src/actions.ts
92
88
  var actions_default = class {
89
+ location;
90
+ appName;
91
+ description;
93
92
  skipInstallation;
94
93
  constructor(location, appName, description) {
95
94
  this.location = location;
@@ -183,7 +182,6 @@ var actions_default = class {
183
182
  if (!existsSync(join(this.location, "src/database/db.sqlite"))) await writeFile(join(this.location, "src/database/db.sqlite"), "");
184
183
  }
185
184
  };
186
-
187
185
  //#endregion
188
186
  //#region src/Commands/CreateH3ravelCommand.ts
189
187
  var CreateH3ravelCommand = class extends Command {
@@ -304,12 +302,9 @@ var CreateH3ravelCommand = class extends Command {
304
302
  await actions.complete(install);
305
303
  }
306
304
  };
307
-
308
305
  //#endregion
309
306
  //#region src/run.ts
310
307
  var Application = class {};
311
308
  Kernel.init(new Application(), { rootCommand: CreateH3ravelCommand });
312
-
313
309
  //#endregion
314
- export { };
315
- //# 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.3",
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,
@@ -25,31 +25,32 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@antfu/install-pkg": "1.1.0",
28
- "@h3ravel/collect.js": "^5.3.4",
29
- "@h3ravel/musket": "^0.6.12",
30
- "@h3ravel/shared": "^0.28.4",
31
- "@h3ravel/support": "^0.16.1",
28
+ "@h3ravel/collect.js": "^5.3.7",
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",
35
35
  "ora": "^9.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@changesets/cli": "^2.29.5",
39
- "@swc/core": "^1.6.1",
40
- "@types/node": "^20.14.5",
41
- "eslint": "^9.32.0",
38
+ "@changesets/cli": "^2.31.0",
39
+ "@eslint/js": "^10.0.1",
40
+ "@swc/core": "^1.15.41",
41
+ "@types/node": "^25.9.3",
42
+ "eslint": "^10.4.1",
43
+ "globals": "^17.6.0",
42
44
  "ts-node": "^10.9.2",
43
- "tsdown": "^0.15.4",
44
- "tsx": "^4.20.3",
45
- "typescript": "^5.4.5",
46
- "vite-tsconfig-paths": "^5.1.4",
47
- "vitest": "^3.2.4"
45
+ "tsdown": "^0.22.2",
46
+ "typescript": "^6.0.3",
47
+ "typescript-eslint": "^8.61.0",
48
+ "vitest": "^4.1.8"
48
49
  },
49
50
  "scripts": {
50
51
  "quick:test": "pnpm vitest",
51
52
  "test": "pnpm run quick:test",
52
- "runner": "tsx --experimental-specifier-resolution=node src/run.ts",
53
+ "runner": "pnpm build && node bin/run.mjs",
53
54
  "build": "tsdown",
54
55
  "version": "pnpm run build",
55
56
  "unlink": "npm unlink -g create-h3ravel",
package/bin/run.cjs DELETED
@@ -1,348 +0,0 @@
1
- #!/usr/bin/env node
2
- //#region rolldown:runtime
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
-
24
- //#endregion
25
- let __h3ravel_musket = require("@h3ravel/musket");
26
- __h3ravel_musket = __toESM(__h3ravel_musket);
27
- let inquirer = require("inquirer");
28
- inquirer = __toESM(inquirer);
29
- let __inquirer_core = require("@inquirer/core");
30
- __inquirer_core = __toESM(__inquirer_core);
31
- 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);
37
- 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);
41
- let giget = require("giget");
42
- giget = __toESM(giget);
43
- let node_fs = require("node:fs");
44
- node_fs = __toESM(node_fs);
45
- let ora = require("ora");
46
- ora = __toESM(ora);
47
-
48
- //#region src/logo.ts
49
- const logo = String.raw`
50
- 111
51
- 111111111
52
- 1111111111 111111
53
- 111111 111 111111
54
- 111111 111 111111
55
- 11111 111 11111
56
- 1111111 111 1111111
57
- 111 11111 111 111111 111 1111 1111 11111111 1111
58
- 111 11111 1111 111111 111 1111 1111 1111 11111 1111
59
- 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
60
- 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
61
- 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
62
- 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
63
- 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
64
- 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
65
- 11011 111111 11 11111
66
- 111111 11101 111111
67
- 111111 111 111111
68
- 111111 111 111111
69
- 111111111
70
- 110
71
- `;
72
- const altLogo = String.raw`%c
73
- _ _ _____ _
74
- | | | |___ / _ __ __ ___ _____| |
75
- | |_| | |_ \| '__/ _ \ \ / / _ \ |
76
- | _ |___) | | | (_| |\ V / __/ |
77
- |_| |_|____/|_| \__,_| \_/ \___|_|
78
-
79
- `;
80
-
81
- //#endregion
82
- //#region src/templates.ts
83
- /**
84
- * List of first party templates
85
- */
86
- const templates = [
87
- {
88
- name: "Full Starter Kit",
89
- alias: "full",
90
- hint: "A full H3ravel application with everything possible",
91
- source: "github:h3ravel/h3ravel#3fbb538",
92
- prereleaseSource: "github:h3ravel/h3ravel#2eec534"
93
- },
94
- {
95
- name: "Lean Starter Kit",
96
- alias: "lean",
97
- hint: "A lean H3ravel application with just the framework core",
98
- source: void 0,
99
- prereleaseSource: void 0
100
- },
101
- {
102
- name: "API Starter Kit",
103
- alias: "api",
104
- hint: "Creates a H3ravel application for building JSON APIs",
105
- source: void 0,
106
- prereleaseSource: void 0
107
- },
108
- {
109
- name: "Web Starter Kit",
110
- alias: "web",
111
- hint: "Creates a H3ravel application for building a server rendered app",
112
- source: void 0,
113
- prereleaseSource: void 0
114
- },
115
- {
116
- name: "Inertia Starter Kit",
117
- alias: "inertia",
118
- hint: "Inertia application with a frontend framework of your choice",
119
- source: void 0,
120
- prereleaseSource: void 0
121
- }
122
- ];
123
-
124
- //#endregion
125
- //#region src/actions.ts
126
- var actions_default = class {
127
- skipInstallation;
128
- constructor(location, appName, description) {
129
- this.location = location;
130
- this.appName = appName;
131
- this.description = description;
132
- if (!this.location) this.location = (0, node_path.join)(process.cwd(), ".temp");
133
- }
134
- async download(template, install = false, auth, overwrite = false) {
135
- if (this.location?.includes(".temp") || overwrite && (0, node_fs.existsSync)(this.location)) await (0, node_fs_promises.rm)(this.location, {
136
- force: true,
137
- recursive: true
138
- });
139
- else if ((0, node_fs.existsSync)(this.location)) {
140
- console.log("\n");
141
- __h3ravel_shared.Logger.parse([
142
- [" ERROR ", "bgRed"],
143
- [this.location, ["gray", "italic"]],
144
- ["is not empty.", "white"]
145
- ], " ");
146
- console.log("");
147
- process.exit(0);
148
- }
149
- this.skipInstallation = !install;
150
- this.removeLockFile();
151
- return await (0, giget.downloadTemplate)(template, {
152
- dir: this.location,
153
- auth,
154
- install,
155
- registry: await (0, __antfu_install_pkg.detectPackageManager)() ?? "npm",
156
- forceClean: false
157
- });
158
- }
159
- async installPackage(name) {
160
- await (0, __antfu_install_pkg.installPackage)(name, {
161
- cwd: this.location,
162
- silent: true
163
- });
164
- }
165
- async complete(installed = false) {
166
- console.log("");
167
- __h3ravel_shared.Logger.success("Your h3ravel project has been created successfully");
168
- __h3ravel_shared.Logger.parse([["cd", "cyan"], ["./" + (0, node_path.relative)(process.cwd(), this.location), "green"]]);
169
- if (!installed) __h3ravel_shared.Logger.parse([[await __h3ravel_shared.Resolver.getPakageInstallCommand(), "cyan"]]);
170
- __h3ravel_shared.Logger.parse([["npx", "cyan"], ["prepare", "green"]], " ");
171
- __h3ravel_shared.Logger.parse([["npx", "cyan"], ["musket fire", "green"]], " ");
172
- __h3ravel_shared.Logger.parse([["Open http://localhost:3000", "cyan"]]);
173
- console.log("");
174
- __h3ravel_shared.Logger.parse([["Have any questions", "white"]]);
175
- __h3ravel_shared.Logger.parse([["Join our Discord server -", "white"], ["https://discord.gg/hsG2A8PuGb", "yellow"]]);
176
- __h3ravel_shared.Logger.parse([["Checkout the documentation -", "white"], ["https://h3ravel.toneflix.net", "yellow"]]);
177
- }
178
- async cleanup() {
179
- const pkgPath = (0, node_path.join)(this.location, "package.json");
180
- const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
181
- delete pkg.packageManager;
182
- pkg.name = __h3ravel_support.Str.slugify(this.appName ?? (0, node_path.basename)(this.location).replace(".", ""), "-");
183
- pkg.scripts = __h3ravel_shared.packageJsonScript;
184
- if (this.description) pkg.description = this.description;
185
- await Promise.allSettled([
186
- (0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2)),
187
- this.removeLockFile(),
188
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, "pnpm-workspace.yaml"), { force: true }),
189
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, "README.md"), { force: true }),
190
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, ".github"), {
191
- force: true,
192
- recursive: true
193
- })
194
- ]);
195
- }
196
- async removeLockFile() {
197
- if (!this.skipInstallation) return;
198
- await Promise.allSettled([
199
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "package-lock.json")),
200
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "yarn.lock")),
201
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "pnpm-lock.yaml"))
202
- ]);
203
- }
204
- async getBanner() {
205
- return await (0, node_fs_promises.readFile)((0, node_path.join)(process.cwd(), "./logo.txt"), "utf-8");
206
- }
207
- async copyExampleEnv() {
208
- const envPath = (0, node_path.join)(this.location, ".env");
209
- const exampleEnvPath = (0, node_path.join)(this.location, ".env.example");
210
- if ((0, node_fs.existsSync)(exampleEnvPath)) await (0, node_fs_promises.copyFile)(exampleEnvPath, envPath);
211
- }
212
- async createTsConfig() {
213
- const tscPath = (0, node_path.join)(this.location, ".h3ravel");
214
- await (0, node_fs_promises.mkdir)(tscPath, { recursive: true });
215
- await (0, node_fs_promises.writeFile)((0, node_path.join)(tscPath, "tsconfig.json"), JSON.stringify(__h3ravel_shared.mainTsconfig, null, 2));
216
- await (0, node_fs_promises.writeFile)((0, node_path.join)(this.location, "tsconfig.json"), JSON.stringify(__h3ravel_shared.baseTsconfig, null, 2));
217
- 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"), "");
218
- }
219
- };
220
-
221
- //#endregion
222
- //#region src/Commands/CreateH3ravelCommand.ts
223
- var CreateH3ravelCommand = class extends __h3ravel_musket.Command {
224
- signature = `create-h3ravel
225
- {location?: The location where this project should be created relative to the current dir.}
226
- {--n|name?: The name of your project.}
227
- {--i|install: Install node_modules right away}
228
- {--t|token?: Kit repo authentication token.}
229
- {--d|desc?: Project Description.}
230
- {--k|kit?: Starter template kit.}
231
- {--p|pre: Download prerelease version if available.}
232
- {--o|overwrite: Overwrite the installation directory if it is not empty.}
233
- `;
234
- description = "Display a personalized greeting.";
235
- async handle() {
236
- const options = this.options();
237
- const pathName = this.argument("location");
238
- console.log(altLogo, `font-family: monospace`);
239
- let { appName, description } = await inquirer.default.prompt([{
240
- type: "input",
241
- name: "appName",
242
- message: "What is the name of your project:",
243
- default: "h3ravel",
244
- when: () => !options.name
245
- }, {
246
- type: "input",
247
- name: "description",
248
- message: "Project Description:",
249
- default: "Modern TypeScript runtime-agnostic web framework built on top of H3.",
250
- when: () => !options.desc
251
- }]).catch((err) => {
252
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
253
- this.info("Thanks for trying out H3ravel.");
254
- process.exit(0);
255
- }
256
- return err;
257
- });
258
- let { location, template } = await inquirer.default.prompt([{
259
- type: "input",
260
- name: "location",
261
- message: "Installation location relative to the current dir:",
262
- default: __h3ravel_support.Str.slugify(options.name ?? appName ?? (0, node_path.basename)(process.cwd()), "-"),
263
- when: () => !pathName
264
- }, {
265
- type: "list",
266
- name: "template",
267
- message: "Choose starter template kit:",
268
- choices: templates.map((e) => ({
269
- name: e.name,
270
- value: e.alias,
271
- disabled: !e.source ? "(Unavailable at this time)" : false
272
- })),
273
- default: "full",
274
- when: () => !options.kit
275
- }]).catch((err) => {
276
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
277
- this.info("Thanks for trying out H3ravel.");
278
- process.exit(0);
279
- }
280
- return err;
281
- });
282
- /**
283
- * Find selected template kit
284
- */
285
- const kit = templates.find((e) => e.alias === template);
286
- let { install, token, pre } = await inquirer.default.prompt([
287
- {
288
- type: "confirm",
289
- name: "pre",
290
- message: `An alpha version of the ${kit.name.replace(/\s*kit$/i, "").trim()} kit is available. Would you like to use it instead?`,
291
- default: false,
292
- when: () => kit.prereleaseSource && !options.pre
293
- },
294
- {
295
- type: "input",
296
- name: "token",
297
- message: "Authentication token:",
298
- when: () => options.kit && !options.token
299
- },
300
- {
301
- type: "confirm",
302
- name: "install",
303
- message: "Would you want to install node_modules right away:",
304
- default: true,
305
- when: () => !options.install
306
- }
307
- ]).catch((err) => {
308
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
309
- this.info("Thanks for trying out H3ravel.");
310
- process.exit(0);
311
- }
312
- return err;
313
- });
314
- pre = options.pre ?? pre;
315
- token = options.token ?? token;
316
- appName = options.name ?? appName;
317
- install = options.install ?? install;
318
- template = options.kit ?? template;
319
- location = pathName ?? location;
320
- description = options.description ?? description;
321
- /**
322
- * Validate selected kit
323
- */
324
- if (kit && !kit.source) {
325
- this.error(`ERROR: The ${kit.name} kit is not currently available`);
326
- process.exit(1);
327
- }
328
- const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
329
- const actions = new actions_default((0, node_path.join)(process.cwd(), location), appName, description);
330
- const spinner = (0, ora.default)(`Loading Template...`).start();
331
- await actions.download(source, install, void 0, options.overwrite);
332
- spinner.info(__h3ravel_shared.Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
333
- await actions.cleanup();
334
- spinner.info(__h3ravel_shared.Logger.parse([["Initializing Project...", "green"]], "", false)).start();
335
- await actions.copyExampleEnv();
336
- await actions.createTsConfig();
337
- spinner.succeed(__h3ravel_shared.Logger.parse([["Project initialization complete!", "green"]], "", false));
338
- await actions.complete(install);
339
- }
340
- };
341
-
342
- //#endregion
343
- //#region src/run.ts
344
- var Application = class {};
345
- __h3ravel_musket.Kernel.init(new Application(), { rootCommand: CreateH3ravelCommand });
346
-
347
- //#endregion
348
- //# sourceMappingURL=run.cjs.map
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","source: string","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#3fbb538',\n prereleaseSource: 'github:h3ravel/h3ravel#2eec534',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: undefined,\n prereleaseSource: undefined\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: undefined,\n prereleaseSource: undefined\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: undefined,\n prereleaseSource: undefined\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: undefined,\n prereleaseSource: undefined\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'], ['prepare', 'green']], ' ')\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 {--p|pre: Download prerelease version if available.}\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 { location, template } = await inquirer.prompt([\n {\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 ]).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 /**\n * Find selected template kit\n */\n const kit = templates.find(e => e.alias === template)!\n\n let { install, token, pre } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"pre\",\n message: `An alpha version of the ${kit.name.replace(/\\s*kit$/i, '').trim()} kit is available. Would you like to use it instead?`,\n default: false,\n when: () => kit.prereleaseSource && !options.pre,\n } as never,\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 }\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 pre = options.pre ?? pre\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 /**\n * Validate selected kit\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 source: string = pre && kit.prereleaseSource ? kit.prereleaseSource! : kit.source\n const actions = new Actions(join(process.cwd(), location), appName, description);\n const spinner = ora(`Loading Template...`).start();\n\n await actions.download(source, 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;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,kBAAkB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AAiC;AACnE,WAAQ,KAAK,EAAE;;EAGnB,MAAME,SAAiB,OAAO,IAAI,mBAAmB,IAAI,mBAAoB,IAAI;EACjF,MAAM,UAAU,IAAIC,oCAAa,QAAQ,KAAK,EAAE,SAAS,EAAE,SAAS,YAAY;EAChF,MAAM,2BAAc,sBAAsB,CAAC,OAAO;AAElD,QAAM,QAAQ,SAAS,QAAQ,SAAS,QAAW,QAAQ,UAAU;AAErE,UAAQ,KAAKC,wBAAO,MAAM,CAAC,CAAC,kBAAkB,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AAC5E,QAAM,QAAQ,SAAS;AAEvB,UAAQ,KAAKA,wBAAO,MAAM,CAAC,CAAC,2BAA2B,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AACrF,QAAM,QAAQ,gBAAgB;AAC9B,QAAM,QAAQ,gBAAgB;AAE9B,UAAQ,QAAQA,wBAAO,MAAM,CAAC,CAAC,oCAAoC,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC;AAEzF,QAAM,QAAQ,SAAS,QAAQ;;;;;;AC7IvC,IAAM,cAAN,MAAkB;AAElBC,wBAAO,KAAK,IAAI,aAAa,EAAE,EAC3B,aAAa,sBAChB,CAAC"}
package/bin/run.d.ts DELETED
@@ -1 +0,0 @@
1
- export { };
package/bin/run.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.js","names":["location?: string","appName?: string","description?: string","source: 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#3fbb538',\n prereleaseSource: 'github:h3ravel/h3ravel#2eec534',\n },\n {\n name: 'Lean Starter Kit',\n alias: 'lean',\n hint: 'A lean H3ravel application with just the framework core',\n source: undefined,\n prereleaseSource: undefined\n },\n {\n name: 'API Starter Kit',\n alias: 'api',\n hint: 'Creates a H3ravel application for building JSON APIs',\n source: undefined,\n prereleaseSource: undefined\n },\n {\n name: 'Web Starter Kit',\n alias: 'web',\n hint: 'Creates a H3ravel application for building a server rendered app',\n source: undefined,\n prereleaseSource: undefined\n },\n {\n name: 'Inertia Starter Kit',\n alias: 'inertia',\n hint: 'Inertia application with a frontend framework of your choice',\n source: undefined,\n prereleaseSource: undefined\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'], ['prepare', 'green']], ' ')\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 {--p|pre: Download prerelease version if available.}\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 { location, template } = await inquirer.prompt([\n {\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 ]).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 /**\n * Find selected template kit\n */\n const kit = templates.find(e => e.alias === template)!\n\n let { install, token, pre } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"pre\",\n message: `An alpha version of the ${kit.name.replace(/\\s*kit$/i, '').trim()} kit is available. Would you like to use it instead?`,\n default: false,\n when: () => kit.prereleaseSource && !options.pre,\n } as never,\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 }\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 pre = options.pre ?? pre\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 /**\n * Validate selected kit\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 source: string = pre && kit.prereleaseSource ? kit.prereleaseSource! : kit.source\n const actions = new Actions(join(process.cwd(), location), appName, description);\n const spinner = ora(`Loading Template...`).start();\n\n await actions.download(source, 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;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,kBAAkB;EACrB;CACD;EACI,MAAM;EACN,OAAO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