create-arkstack 0.3.17 → 0.4.1

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/README.md CHANGED
@@ -3,14 +3,14 @@
3
3
 
4
4
  # About Create Arkstack
5
5
 
6
- Scaffold new applications using any of the Arkstack templates and starter kits.
6
+ Create new Arkstack framework applications using an official runtime template.
7
7
 
8
- ## Starter kits
8
+ ## Runtime Templates
9
9
 
10
- You can choose between one of the following official starter kits
10
+ You can choose between one of the following official runtime templates:
11
11
 
12
- - `express` : An Express.js app scaffolded with Tonelix's Arkstack
13
- - `h3` : An H3.js app scaffolded with Tonelix's Arkstack
12
+ - `express` : An Arkstack app running on the Express driver
13
+ - `h3` : An Arkstack app running on the H3 driver
14
14
  - More coming soon...
15
15
 
16
16
  ## Usage
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "create-arkstack",
3
3
  "type": "module",
4
- "version": "0.3.17",
5
- "description": "Scaffold new H3.js or Express.js applications using Toneflix's arkstack templates and starter kits",
4
+ "version": "0.4.1",
5
+ "description": "Create new Arkstack framework applications on Express or H3 runtime drivers",
6
6
  "homepage": "https://arkstack.toneflix.net",
7
7
  "repository": {
8
8
  "type": "git",
@@ -16,7 +16,7 @@
16
16
  "express",
17
17
  "scaffold",
18
18
  "template",
19
- "starter kit",
19
+ "backend framework",
20
20
  "cli",
21
21
  "generator",
22
22
  "boilerplate",
package/bin/run.cjs DELETED
@@ -1,474 +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 node_process = require("node:process");
40
- node_process = __toESM(node_process);
41
- let __antfu_install_pkg = require("@antfu/install-pkg");
42
- __antfu_install_pkg = __toESM(__antfu_install_pkg);
43
- let giget = require("giget");
44
- giget = __toESM(giget);
45
- let node_fs = require("node:fs");
46
- node_fs = __toESM(node_fs);
47
- let node_child_process = require("node:child_process");
48
- node_child_process = __toESM(node_child_process);
49
-
50
- //#region src/logo.ts
51
- const altLogo = String.raw`%c
52
- _ __ _ _
53
- /_\ _ __ ___/ _\ |_ __ _ ___| | __
54
- //_\\| '__/ __\ \| __/ _\ |/ __| |/ /
55
- / _ \ | | (___\ \ || (_| | (__| <
56
- \_/ \_/_| \___\__/\__\__,_|\___|_|\_\
57
-
58
- `;
59
-
60
- //#endregion
61
- //#region src/templates.ts
62
- /**
63
- * List of first party templates
64
- */
65
- const templates = [
66
- {
67
- name: "Express Starter Kit",
68
- alias: "express",
69
- hint: "An Express application starter kit",
70
- source: "github:arkstack-hq/arkstack"
71
- },
72
- {
73
- name: "Express Lean Starter Kit",
74
- alias: "express-lean",
75
- hint: "A minimal Express application starter kit",
76
- source: "github:arkstack-hq/arkstack",
77
- lean: true,
78
- baseAlias: "express"
79
- },
80
- {
81
- name: "H3 Starter Kit",
82
- alias: "h3",
83
- hint: "A H3 application starter kit",
84
- source: "github:arkstack-hq/arkstack"
85
- },
86
- {
87
- name: "H3 Lean Starter Kit",
88
- alias: "h3-lean",
89
- hint: "A minimal H3 application starter kit",
90
- source: "github:arkstack-hq/arkstack",
91
- lean: true,
92
- baseAlias: "h3"
93
- }
94
- ];
95
-
96
- //#endregion
97
- //#region src/data.ts
98
- const filesToRemove = [
99
- "src/app/http/controllers",
100
- "src/app/http/resources",
101
- "src/models",
102
- "src/app/models",
103
- "database",
104
- "src/routes/api.ts",
105
- "src/database",
106
- "src/core/database.ts",
107
- "src/core/utils/drivers/ValidatorDBDriver.ts",
108
- "prisma",
109
- "prisma.config.ts",
110
- "arkorm.config.ts",
111
- "arkormx.config.ts",
112
- "arkorm.config.js",
113
- "arkormx.config.js",
114
- "arkorm.config.mjs",
115
- "arkormx.config.mjs"
116
- ];
117
- const fullDependencies = [
118
- "@prisma/adapter-pg",
119
- "@arkstack/console",
120
- "@prisma/client",
121
- "@types/pg",
122
- "pg",
123
- "kysely",
124
- "prisma",
125
- "arkormx"
126
- ];
127
- const leanDependencies = { "@arkstack/console-slim": "^0.3.17" };
128
- const depsList = {
129
- "@arkstack/http": "^0.3.17",
130
- "@arkstack/auth": "^0.3.17",
131
- "@arkstack/common": "^0.3.17",
132
- "@arkstack/console": "^0.3.17",
133
- "@arkstack/contract": "^0.3.17",
134
- "@arkstack/driver-h3": "^0.3.17",
135
- "@arkstack/filesystem": "^0.3.17",
136
- "@arkstack/driver-express": "^0.3.17",
137
- "@arkstack/notifications": "^0.3.17"
138
- };
139
-
140
- //#endregion
141
- //#region src/actions.ts
142
- var actions_default = class {
143
- skipInstallation;
144
- constructor(location, appName, description) {
145
- this.location = location;
146
- this.appName = appName;
147
- this.description = description;
148
- if (!this.location) this.location = (0, node_path.join)(process.cwd(), ".temp");
149
- }
150
- async pm() {
151
- return await (0, __antfu_install_pkg.detectPackageManager)() ?? "npm";
152
- }
153
- async runCmd(npx = false) {
154
- if (npx) return "npx";
155
- const pm = await this.pm();
156
- return pm === "npm" ? "npm run" : pm;
157
- }
158
- async download(template, install = false, auth, overwrite = false) {
159
- if (this.location?.includes(".temp") || overwrite && (0, node_fs.existsSync)(this.location)) await (0, node_fs_promises.rm)(this.location, {
160
- force: true,
161
- recursive: true
162
- });
163
- else if ((0, node_fs.existsSync)(this.location)) {
164
- if ((await (0, node_fs_promises.readdir)(this.location ?? "./"))?.length > 0) {
165
- console.log("\n");
166
- __h3ravel_shared.Logger.parse([
167
- [" ERROR ", "bgRed"],
168
- [this.location, ["gray", "italic"]],
169
- ["is not empty.", "white"]
170
- ], " ");
171
- console.log("");
172
- process.exit(0);
173
- }
174
- }
175
- this.skipInstallation = !install;
176
- this.removeLockFile();
177
- return await (0, giget.downloadTemplate)(template, {
178
- dir: this.location,
179
- auth,
180
- provider: "github",
181
- registry: await this.pm(),
182
- forceClean: false
183
- });
184
- }
185
- /**
186
- * Installs the project dependencies using the detected package manager.
187
- * If a specific package name is provided, it will install that package
188
- * instead of all dependencies.
189
- *
190
- * @param name
191
- * @param args
192
- * @returns
193
- */
194
- async installPackage(name, args = []) {
195
- const bcmd = await __h3ravel_shared.Resolver.getPakageInstallCommand() + (name ? ` ${name}` : "");
196
- const cmd = bcmd.split(" ")[0];
197
- if (bcmd.includes(" ")) args.unshift(...bcmd.split(" ").slice(1));
198
- const child = (0, node_child_process.spawnSync)(cmd, args, {
199
- cwd: process.cwd(),
200
- stdio: "ignore"
201
- });
202
- if (child.error) return child.status;
203
- return 0;
204
- }
205
- async complete(install = false) {
206
- let installed = false;
207
- if (install) installed = await this.installPackage() === 0;
208
- console.log("");
209
- const installPath = "./" + (0, node_path.relative)(process.cwd(), this.location);
210
- try {
211
- (0, node_process.chdir)(node_path.default.join(process.cwd(), installPath));
212
- } catch {}
213
- __h3ravel_shared.Logger.success("Your Arkstack project has been created successfully");
214
- __h3ravel_shared.Logger.parse([
215
- ["cd", "cyan"],
216
- [installPath, "yellow"],
217
- installPath === process.cwd() ? ["✔", "green"] : ["", "green"]
218
- ], " ");
219
- if (!installed) __h3ravel_shared.Logger.parse([[await __h3ravel_shared.Resolver.getPakageInstallCommand(), "cyan"]]);
220
- __h3ravel_shared.Logger.parse([[await this.runCmd(), "cyan"], ["dev", "yellow"]], " ");
221
- __h3ravel_shared.Logger.parse([["Open", "cyan"], ["http://localhost:3000", "yellow"]]);
222
- console.log("");
223
- __h3ravel_shared.Logger.parse([["Have any questions", "white"]]);
224
- __h3ravel_shared.Logger.parse([["Checkout our other projects -", "white"], ["https://toneflix.net/open-source", "yellow"]]);
225
- }
226
- async cleanup(kit) {
227
- const pkgPath = (0, node_path.join)(this.location, "package.json");
228
- const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
229
- delete pkg.packageManager;
230
- delete pkg.scripts.predev;
231
- delete pkg.scripts.prebuild;
232
- delete pkg.scripts.precmd;
233
- delete pkg.scripts.cmd;
234
- pkg.scripts.dev = "ark dev";
235
- pkg.scripts.build = "ark build";
236
- pkg.scripts.postinstall = "prepare";
237
- pkg.name = __h3ravel_support.Str.slugify(this.appName ?? (0, node_path.basename)(this.location).replace(".", ""), "-");
238
- if (this.description) pkg.description = this.description;
239
- for (const [name, version] of Object.entries(depsList)) {
240
- if (name.includes("@arkstack/driver")) continue;
241
- pkg.dependencies[name] = version;
242
- }
243
- pkg.dependencies["@arkstack/driver-" + kit] = depsList["@arkstack/driver-" + kit];
244
- await Promise.allSettled([
245
- (0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2)),
246
- this.removeLockFile(),
247
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, "pnpm-workspace.yaml"), { force: true }),
248
- (0, node_fs_promises.rm)((0, node_path.join)(this.location, ".github"), {
249
- force: true,
250
- recursive: true
251
- })
252
- ]);
253
- }
254
- async removeLockFile() {
255
- if (!this.skipInstallation) return;
256
- await Promise.allSettled([
257
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "package-lock.json")),
258
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "yarn.lock")),
259
- (0, node_fs_promises.unlink)((0, node_path.join)(this.location, "pnpm-lock.yaml"))
260
- ]);
261
- }
262
- async getBanner() {
263
- return await (0, node_fs_promises.readFile)((0, node_path.join)(process.cwd(), "./logo.txt"), "utf-8");
264
- }
265
- async copyExampleEnv() {
266
- const envPath = (0, node_path.join)(this.location, ".env");
267
- const exampleEnvPath = (0, node_path.join)(this.location, ".env.example");
268
- if ((0, node_fs.existsSync)(exampleEnvPath)) await (0, node_fs_promises.copyFile)(exampleEnvPath, envPath);
269
- }
270
- async makeLeanProfile(_kit) {
271
- await Promise.allSettled(filesToRemove.map((file) => (0, node_fs_promises.rm)((0, node_path.join)(this.location, file), {
272
- force: true,
273
- recursive: true
274
- })));
275
- const pkgPath = (0, node_path.join)(this.location, "package.json");
276
- if ((0, node_fs.existsSync)(pkgPath)) {
277
- const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
278
- for (const dep of fullDependencies) {
279
- delete pkg.dependencies?.[dep];
280
- delete pkg.devDependencies?.[dep];
281
- }
282
- for (const [name, version] of Object.entries(leanDependencies)) pkg.dependencies[name] = version;
283
- await (0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2));
284
- }
285
- for (const file of [
286
- "src/core/app.ts",
287
- "src/core/router.ts",
288
- "src/core/bootstrap.ts"
289
- ]) {
290
- const filePath = (0, node_path.join)(this.location, file);
291
- if (!(0, node_fs.existsSync)(filePath)) continue;
292
- let content = await (0, node_fs_promises.readFile)(filePath, "utf-8");
293
- content = content.replace("import { ValidatorDBDriver } from './utils/drivers/ValidatorDBDriver'\n", "").replace("import { ModelNotFoundException } from 'arkormx'\n", "").replace("import { prisma } from 'src/core/database'\n", "").replace("import { Prisma } from '@prisma/client'\n", "").replace("Validator.useDatabase(new ValidatorDBDriver())", "").replace(" async shutdown () {\n await prisma.$disconnect()\n process.exit(0)\n }", " async shutdown () {\n process.exit(0)\n }").replace(" * Shuts down the application by disconnecting from the database and exiting the process.", " * Shuts down the application and exits the process.").replace(/\n\s*if \((?:err|cause) instanceof Prisma\.PrismaClientKnownRequestError && (?:err|cause)\.code === "P2025"\) \{\n\s*error\.code = 404\n\s*error\.message = `\$\{(?:err|cause)\.meta\?\.modelName\} not found!`\n\s*\}\n/g, "\n").replace(/\n\s*if \((?:err|cause) instanceof ModelNotFoundException\) \{\n\s*error\.code = 404\n\s*error\.message = `\$\{(?:err|cause)\.getModelName\(\)\} not found!`\n\s*\}\n/g, "\n").replace(/if \(!\(err instanceof ValidationException\) &&\n\s*!\(err instanceof ModelNotFoundException\)\) {/g, "if (!(err instanceof ValidationException)) {").replace(/\s*\/\/ Register API routes\s*await ClearRouter\.group\('\/api', async \(\) => \{\s*await importFile\(join\(process\.cwd\(\), 'src\/routes\/api\.ts'\)\)\s*\}\)\s*/g, "\n\n ");
294
- await (0, node_fs_promises.writeFile)(filePath, content, "utf-8");
295
- }
296
- }
297
- };
298
-
299
- //#endregion
300
- //#region src/utils.ts
301
- /**
302
- * Removes all files in dirPath except the one specified by keepFileName
303
- *
304
- * @param dirPath
305
- * @param keepFileName
306
- */
307
- async function cleanDirectoryExcept(dirPath, keepFileName) {
308
- const files = await (0, node_fs_promises.readdir)(dirPath);
309
- for (const file of files) {
310
- if (file === keepFileName) continue;
311
- await (0, node_fs_promises.rm)(node_path.default.join(dirPath, file), {
312
- recursive: true,
313
- force: true
314
- });
315
- }
316
- }
317
- /**
318
- * Moves all files from dirPath to parent directory and removes dirPath
319
- *
320
- * @param dirPath
321
- * @param parent
322
- */
323
- async function hoistDirectoryContents(parent, dirPath) {
324
- const source = node_path.default.isAbsolute(dirPath) ? dirPath : node_path.default.join(process.cwd(), dirPath);
325
- const targetParent = node_path.default.isAbsolute(parent) ? parent : node_path.default.join(process.cwd(), parent);
326
- if (!source.startsWith(targetParent)) throw new Error("Source must be inside the parent directory");
327
- const entries = await (0, node_fs_promises.readdir)(source);
328
- for (const entry of entries) await (0, node_fs_promises.rename)(node_path.default.join(source, entry), node_path.default.join(targetParent, entry));
329
- await (0, node_fs_promises.rm)(source, { recursive: true });
330
- }
331
-
332
- //#endregion
333
- //#region src/Commands/CreateArkstackCommand.ts
334
- var CreateArkstackCommand = class extends __h3ravel_musket.Command {
335
- signature = `create-arkstack
336
- {location?: The location where this project should be created relative to the current dir.}
337
- {--n|name?: The name of your project.}
338
- {--i|install: Install node_modules right away}
339
- {--t|token?: Kit repo authentication token.}
340
- {--d|desc?: Project Description.}
341
- {--k|kit?: Starter template kit.}
342
- {--p|pre: Download prerelease version if available.}
343
- {--o|overwrite: Overwrite the installation directory if it is not empty.}
344
- `;
345
- description = "Display a personalized greeting.";
346
- async handle() {
347
- const options = this.options();
348
- const pathName = this.argument("location");
349
- console.log(altLogo, "font-family: monospace");
350
- let { template } = await inquirer.default.prompt([{
351
- type: "list",
352
- name: "template",
353
- message: "Choose starter template kit:",
354
- choices: templates.map((e) => ({
355
- name: e.name,
356
- value: e.alias,
357
- disabled: !e.source ? "(Unavailable at this time)" : false
358
- })),
359
- default: "full",
360
- when: () => !options.kit
361
- }]).catch((err) => {
362
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
363
- this.info("Thanks for trying out our starter kit.");
364
- process.exit(0);
365
- }
366
- return err;
367
- });
368
- let { appName, description } = await inquirer.default.prompt([{
369
- type: "input",
370
- name: "appName",
371
- message: "What is the name of your project:",
372
- default: `arkstack-${template}`,
373
- when: () => !options.name
374
- }, {
375
- type: "input",
376
- name: "description",
377
- message: "Project Description:",
378
- default: `Simple ${__h3ravel_support.Str.of(template).ucfirst()}.js project created with Arkstack.`,
379
- when: () => !options.desc
380
- }]).catch((err) => {
381
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
382
- this.info("Thanks for trying out our starter kit.");
383
- process.exit(0);
384
- }
385
- return err;
386
- });
387
- let { location } = await inquirer.default.prompt([{
388
- type: "input",
389
- name: "location",
390
- message: "Installation location relative to the current dir:",
391
- default: __h3ravel_support.Str.slugify(options.name ?? appName ?? (0, node_path.basename)(process.cwd()), "-"),
392
- when: () => !pathName
393
- }]).catch((err) => {
394
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
395
- this.info("Thanks for trying out our starter kit.");
396
- process.exit(0);
397
- }
398
- return err;
399
- });
400
- /**
401
- * Find selected template kit
402
- */
403
- const kit = templates.find((e) => e.alias === template);
404
- let { install, token, pre } = await inquirer.default.prompt([
405
- {
406
- type: "confirm",
407
- name: "pre",
408
- message: `An alpha version of the ${kit.name.replace(/\s*kit$/i, "").trim()} kit is available. Would you like to use it instead?`,
409
- default: false,
410
- when: () => kit.prereleaseSource && !options.pre
411
- },
412
- {
413
- type: "input",
414
- name: "token",
415
- message: "Authentication token:",
416
- when: () => options.kit && !options.token
417
- },
418
- {
419
- type: "confirm",
420
- name: "install",
421
- message: "Would you like to install node_modules right away?:",
422
- default: true,
423
- when: () => !options.install
424
- }
425
- ]).catch((err) => {
426
- if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
427
- this.info("Thanks for trying out our starter kit.");
428
- process.exit(0);
429
- }
430
- return err;
431
- });
432
- pre = options.pre ?? pre;
433
- token = options.token ?? token;
434
- appName = options.name ?? appName;
435
- install = options.install ?? install;
436
- template = options.kit ?? template;
437
- location = pathName ?? location;
438
- description = options.description ?? description;
439
- /**
440
- * Validate selected kit
441
- */
442
- if (kit && !kit.source) {
443
- this.error(`ERROR: The ${kit.name} kit is not currently available`);
444
- process.exit(1);
445
- }
446
- const kitName = (kit.baseAlias ?? kit.alias).replace(/-lean$/i, "");
447
- const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
448
- const actions = new actions_default((0, node_path.join)(process.cwd(), location), appName, description);
449
- const spinner = this.spinner("Loading Template...").start();
450
- const result = await actions.download(source, install, token, options.overwrite);
451
- if (result.dir && kitName) {
452
- await cleanDirectoryExcept(result.dir, kitName);
453
- await hoistDirectoryContents(result.dir, (0, node_path.join)(result.dir, kitName));
454
- }
455
- if (kit.lean) {
456
- spinner.info(__h3ravel_shared.Logger.parse([["Applying lean profile...", "green"]], "", false)).start();
457
- await actions.makeLeanProfile(kitName);
458
- }
459
- spinner.info(__h3ravel_shared.Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
460
- await actions.cleanup(kitName);
461
- spinner.info(__h3ravel_shared.Logger.parse([["Initializing Project...", "green"]], "", false)).start();
462
- await actions.copyExampleEnv();
463
- await actions.complete(install);
464
- spinner.succeed(__h3ravel_shared.Logger.parse([["Project initialization complete!", "green"]], "", false));
465
- }
466
- };
467
-
468
- //#endregion
469
- //#region src/run.ts
470
- var Application = class {};
471
- __h3ravel_musket.Kernel.init(new Application(), { rootCommand: CreateArkstackCommand });
472
-
473
- //#endregion
474
- //# sourceMappingURL=run.cjs.map
package/bin/run.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.cjs","names":["templates: Template[]","depsList: Record<string, string>","location?: string","appName?: string","description?: string","Resolver","path","Str","path","Command","AbortPromptError","ExitPromptError","Str","source: string","Actions","Logger","Kernel"],"sources":["../src/logo.ts","../src/templates.ts","../src/data.ts","../src/actions.ts","../src/utils.ts","../src/Commands/CreateArkstackCommand.ts","../src/run.ts"],"sourcesContent":["export const altLogo = String.raw`%c\n _ __ _ _ \n /_\\ _ __ ___/ _\\ |_ __ _ ___| | __\n //_\\\\| '__/ __\\ \\| __/ _\\ |/ __| |/ /\n/ _ \\ | | (___\\ \\ || (_| | (__| < \n\\_/ \\_/_| \\___\\__/\\__\\__,_|\\___|_|\\_\\\n \n`\n","/*\n * create-arkstack - A CLI tool to create Arkstack applications\n *\n * (c) Toneflix\n *\n * The Arkstack framework and all its base packages unless otherwise stated, are\n * open-sourced software licensed under the MIT license.\n */\nimport { Template } from './types'\n\n/**\n * List of first party templates\n */\nexport const templates: Template[] = [\n {\n name: 'Express Starter Kit',\n alias: 'express',\n hint: 'An Express application starter kit',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'Express Lean Starter Kit',\n alias: 'express-lean',\n hint: 'A minimal Express application starter kit',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'express',\n },\n {\n name: 'H3 Starter Kit',\n alias: 'h3',\n hint: 'A H3 application starter kit',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'H3 Lean Starter Kit',\n alias: 'h3-lean',\n hint: 'A minimal H3 application starter kit',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'h3',\n },\n]","export const filesToRemove = [\n 'src/app/http/controllers',\n 'src/app/http/resources',\n 'src/models',\n 'src/app/models',\n 'database',\n 'src/routes/api.ts',\n 'src/database',\n 'src/core/database.ts',\n 'src/core/utils/drivers/ValidatorDBDriver.ts',\n 'prisma',\n 'prisma.config.ts',\n 'arkorm.config.ts',\n 'arkormx.config.ts',\n 'arkorm.config.js',\n 'arkormx.config.js',\n 'arkorm.config.mjs',\n 'arkormx.config.mjs',\n]\n\nexport const fullDependencies = [\n '@prisma/adapter-pg',\n '@arkstack/console',\n '@prisma/client',\n '@types/pg',\n 'pg',\n 'kysely',\n 'prisma',\n 'arkormx',\n]\n\nexport const leanDependencies = {\n '@arkstack/console-slim': '^0.3.17',\n}\n\nexport const depsList: Record<string, string> = {\n '@arkstack/http': '^0.3.17',\n '@arkstack/auth': '^0.3.17',\n '@arkstack/common': '^0.3.17',\n '@arkstack/console': '^0.3.17',\n '@arkstack/contract': '^0.3.17',\n '@arkstack/driver-h3': '^0.3.17',\n '@arkstack/filesystem': '^0.3.17',\n '@arkstack/driver-express': '^0.3.17',\n '@arkstack/notifications': '^0.3.17',\n}\n","import { Logger, Resolver } from '@h3ravel/shared'\nimport { copyFile, readFile, readdir, rm, unlink, writeFile } from 'node:fs/promises'\nimport { filesToRemove, fullDependencies, leanDependencies } from './data'\nimport path, { basename, join, relative } from 'node:path'\n\nimport type { KitName } from './types'\nimport { Str } from '@h3ravel/support'\nimport { chdir } from 'node:process'\nimport { depsList } from './data'\nimport { detectPackageManager } from '@antfu/install-pkg'\nimport { downloadTemplate } from 'giget'\nimport { existsSync } from 'node:fs'\nimport { spawnSync } from 'node:child_process'\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(\n private location?: string,\n private appName?: string,\n private description?: string,\n ) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async pm () {\n return (await detectPackageManager()) ?? 'npm'\n }\n\n async runCmd (npx: boolean = false) {\n if (npx) return 'npx'\n\n const pm = await this.pm()\n\n return pm === 'npm' ? 'npm run' : pm\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 const files = await readdir(this.location ?? './')\n if (files?.length > 0) {\n console.log('\\n')\n Logger.parse(\n [\n [' ERROR ', 'bgRed'],\n [this.location!, ['gray', 'italic']],\n ['is not empty.', 'white'],\n ],\n ' ',\n )\n console.log('')\n process.exit(0)\n }\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n const status = await downloadTemplate(template, {\n dir: this.location,\n auth,\n provider: 'github',\n registry: await this.pm(),\n forceClean: false,\n })\n\n return status\n }\n\n /**\n * Installs the project dependencies using the detected package manager. \n * If a specific package name is provided, it will install that package \n * instead of all dependencies.\n * \n * @param name \n * @param args \n * @returns \n */\n async installPackage (name?: string, args: string[] = []) {\n const bcmd = await Resolver.getPakageInstallCommand() + (name ? ` ${name}` : '')\n const cmd = bcmd.split(' ')[0]\n if (bcmd.includes(' ')) {\n args.unshift(...bcmd.split(' ').slice(1))\n }\n\n const child = spawnSync(cmd, args, {\n cwd: process.cwd(),\n stdio: 'ignore',\n })\n\n if (child.error) {\n return child.status\n }\n\n return 0\n }\n\n async complete (install = false) {\n let installed = false\n if (install) {\n installed = await this.installPackage() === 0\n }\n\n console.log('')\n\n const installPath = './' + relative(process.cwd(), this.location!)\n\n try {\n chdir(path.join(process.cwd(), installPath))\n } catch {\n /** */\n }\n\n Logger.success('Your Arkstack project has been created successfully')\n Logger.parse(\n [\n ['cd', 'cyan'],\n [installPath, 'yellow'],\n installPath === process.cwd() ? ['✔', 'green'] : ['', 'green'],\n ],\n ' ',\n )\n\n if (!installed) {\n Logger.parse([[await Resolver.getPakageInstallCommand(), 'cyan']])\n }\n\n Logger.parse(\n [\n [await this.runCmd(), 'cyan'],\n ['dev', 'yellow'],\n ],\n ' ',\n )\n Logger.parse([\n ['Open', 'cyan'],\n ['http://localhost:3000', 'yellow'],\n ])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n // Logger.parse([\n // [\"Join our Discord server -\", \"white\"],\n // [\"https://discord.gg/hsG2A8PuGb\", \"yellow\"],\n // ]);\n Logger.parse([\n ['Checkout our other projects -', 'white'],\n ['https://toneflix.net/open-source', 'yellow'],\n ])\n }\n\n async cleanup (kit: KitName) {\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 delete pkg.scripts.predev\n delete pkg.scripts.prebuild\n delete pkg.scripts.precmd\n delete pkg.scripts.cmd\n\n pkg.scripts.dev = 'ark dev'\n pkg.scripts.build = 'ark build'\n pkg.scripts.postinstall = 'prepare'\n\n pkg.name = Str.slugify(\n this.appName ?? basename(this.location!).replace('.', ''), '-'\n )\n\n if (this.description) {\n pkg.description = this.description\n }\n\n for (const [name, version] of Object.entries(depsList)) {\n if (name.includes('@arkstack/driver')) continue\n pkg.dependencies[name] = version\n }\n\n pkg.dependencies['@arkstack/driver-' + kit] = depsList[('@arkstack/driver-' + kit)]\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!, '.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 makeLeanProfile (_kit: KitName) {\n await Promise.allSettled(\n filesToRemove.map((file) => rm(join(this.location!, file), { force: true, recursive: true })),\n )\n\n const pkgPath = join(this.location!, 'package.json')\n if (existsSync(pkgPath)) {\n const pkg = await readFile(pkgPath, 'utf-8').then(JSON.parse)\n\n for (const dep of fullDependencies) {\n delete pkg.dependencies?.[dep]\n delete pkg.devDependencies?.[dep]\n }\n\n for (const [name, version] of Object.entries(leanDependencies)) {\n pkg.dependencies[name] = version\n }\n\n await writeFile(pkgPath, JSON.stringify(pkg, null, 2))\n }\n\n const filesToPatch = [\n 'src/core/app.ts',\n 'src/core/router.ts',\n 'src/core/bootstrap.ts',\n ]\n\n for (const file of filesToPatch) {\n const filePath = join(this.location!, file)\n\n if (!existsSync(filePath)) {\n continue\n }\n\n let content = await readFile(filePath, 'utf-8')\n\n content = content\n .replace('import { ValidatorDBDriver } from \\'./utils/drivers/ValidatorDBDriver\\'\\n', '')\n .replace('import { ModelNotFoundException } from \\'arkormx\\'\\n', '')\n .replace('import { prisma } from \\'src/core/database\\'\\n', '')\n .replace('import { Prisma } from \\'@prisma/client\\'\\n', '')\n .replace('Validator.useDatabase(new ValidatorDBDriver())', '')\n .replace(' async shutdown () {\\n await prisma.$disconnect()\\n process.exit(0)\\n }', ' async shutdown () {\\n process.exit(0)\\n }')\n .replace(\n ' * Shuts down the application by disconnecting from the database and exiting the process.',\n ' * Shuts down the application and exits the process.',\n )\n .replace(\n /\\n\\s*if \\((?:err|cause) instanceof Prisma\\.PrismaClientKnownRequestError && (?:err|cause)\\.code === \"P2025\"\\) \\{\\n\\s*error\\.code = 404\\n\\s*error\\.message = `\\$\\{(?:err|cause)\\.meta\\?\\.modelName\\} not found!`\\n\\s*\\}\\n/g,\n '\\n',\n )\n .replace(\n /\\n\\s*if \\((?:err|cause) instanceof ModelNotFoundException\\) \\{\\n\\s*error\\.code = 404\\n\\s*error\\.message = `\\$\\{(?:err|cause)\\.getModelName\\(\\)\\} not found!`\\n\\s*\\}\\n/g,\n '\\n',\n )\n .replace(\n /if \\(!\\(err instanceof ValidationException\\) &&\\n\\s*!\\(err instanceof ModelNotFoundException\\)\\) {/g,\n 'if (!(err instanceof ValidationException)) {'\n )\n .replace(\n /\\s*\\/\\/ Register API routes\\s*await ClearRouter\\.group\\('\\/api', async \\(\\) => \\{\\s*await importFile\\(join\\(process\\.cwd\\(\\), 'src\\/routes\\/api\\.ts'\\)\\)\\s*\\}\\)\\s*/g,\n '\\n\\n ',\n )\n\n await writeFile(filePath, content, 'utf-8')\n }\n\n }\n}\n","import { readdir, rename, rm } from 'node:fs/promises'\n\nimport path from 'node:path'\n\n/**\n * Removes all files in dirPath except the one specified by keepFileName\n *\n * @param dirPath\n * @param keepFileName\n */\nexport async function cleanDirectoryExcept (dirPath: string, keepFileName: string) {\n const files = await readdir(dirPath)\n\n for (const file of files) {\n if (file === keepFileName) continue\n\n const fullPath = path.join(dirPath, file)\n\n await rm(fullPath, { recursive: true, force: true })\n }\n}\n\n/**\n * Moves all files from dirPath to parent directory and removes dirPath\n *\n * @param dirPath\n * @param parent\n */\nexport async function hoistDirectoryContents (parent: string, dirPath: string) {\n const source = path.isAbsolute(dirPath) ? dirPath : path.join(process.cwd(), dirPath)\n\n const targetParent = path.isAbsolute(parent) ? parent : path.join(process.cwd(), parent)\n\n if (!source.startsWith(targetParent)) {\n throw new Error('Source must be inside the parent directory')\n }\n\n const entries = await readdir(source)\n\n for (const entry of entries) {\n const from = path.join(source, entry)\n const to = path.join(targetParent, entry)\n\n await rename(from, to)\n }\n\n await rm(source, { recursive: true })\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 { Logger } from '@h3ravel/shared'\nimport { cleanDirectoryExcept, hoistDirectoryContents } from 'src/utils'\nimport type { KitName } from 'src/types'\n\nexport class CreateArkstackCommand extends Command {\n protected signature = `create-arkstack\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 // const defaultName = pathName ? Str.of(pathName).afterLast(\"/\") : undefined;\n\n console.log(altLogo, 'font-family: monospace')\n\n let { template } = await inquirer\n .prompt([\n {\n type: 'list',\n name: 'template',\n message: 'Choose starter template kit:',\n choices: <never>templates.map((e) => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n ])\n .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\n\n return err\n })\n\n let { appName, description } = await inquirer\n .prompt([\n {\n type: 'input',\n name: 'appName',\n message: 'What is the name of your project:',\n default: `arkstack-${template}`,\n // default: defaultName ?? `arkstack-${template}`,\n when: () => !options.name,\n },\n {\n type: 'input',\n name: 'description',\n message: 'Project Description:',\n default: `Simple ${Str.of(template).ucfirst()}.js project created with Arkstack.`,\n when: () => !options.desc,\n },\n ])\n .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\n\n return err\n })\n\n let { location } = await inquirer\n .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 .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\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\n .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 like to install node_modules right away?:',\n default: true,\n when: () => !options.install,\n },\n ])\n .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\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 kitName = (kit.baseAlias ?? kit.alias).replace(/-lean$/i, '') as KitName\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 = this.spinner('Loading Template...').start()\n\n const result = await actions.download(source, install, token, options.overwrite)\n\n if (result.dir && kitName) {\n await cleanDirectoryExcept(result.dir, kitName)\n await hoistDirectoryContents(result.dir, join(result.dir, kitName))\n }\n\n if (kit.lean) {\n spinner.info(Logger.parse([[\n 'Applying lean profile...',\n 'green',\n ]], '', false)).start()\n await actions.makeLeanProfile(kitName)\n }\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start()\n\n await actions.cleanup(kitName)\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start()\n\n await actions.copyExampleEnv()\n\n await actions.complete(install)\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n }\n}\n","#!/usr/bin/env node\n\nimport { CreateArkstackCommand } from './Commands/CreateArkstackCommand'\nimport { Kernel } from '@h3ravel/musket'\n\nclass Application { }\n\nKernel.init(new Application(), {\n rootCommand: CreateArkstackCommand,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAa,UAAU,OAAO,GAAG;;;;;;;;;;;;;;ACajC,MAAaA,YAAwB;CACnC;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACT;CACD;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,MAAM;EACN,WAAW;EACZ;CACD;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACT;CACD;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,MAAM;EACN,WAAW;EACZ;CACF;;;;AC1CD,MAAa,gBAAgB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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AAE9B,QAAM,QAAQ,SAAS,QAAQ;AAE/B,UAAQ,QAAQA,wBAAO,MAAM,CAAC,CAAC,oCAAoC,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC;;;;;;ACpL7F,IAAM,cAAN,MAAkB;AAElBC,wBAAO,KAAK,IAAI,aAAa,EAAE,EAC7B,aAAa,uBACd,CAAC"}
package/bin/run.d.cts DELETED
@@ -1 +0,0 @@
1
- export { };
package/bin/run.d.ts DELETED
@@ -1 +0,0 @@
1
- export { };
package/bin/run.js DELETED
@@ -1,440 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command, Kernel } from "@h3ravel/musket";
3
- import inquirer from "inquirer";
4
- import { AbortPromptError, ExitPromptError } from "@inquirer/core";
5
- import path, { basename, join, relative } from "node:path";
6
- import { Str } from "@h3ravel/support";
7
- import { Logger, Resolver } from "@h3ravel/shared";
8
- import { copyFile, readFile, readdir, rename, rm, unlink, writeFile } from "node:fs/promises";
9
- import { chdir } from "node:process";
10
- import { detectPackageManager } from "@antfu/install-pkg";
11
- import { downloadTemplate } from "giget";
12
- import { existsSync } from "node:fs";
13
- import { spawnSync } from "node:child_process";
14
-
15
- //#region src/logo.ts
16
- const altLogo = String.raw`%c
17
- _ __ _ _
18
- /_\ _ __ ___/ _\ |_ __ _ ___| | __
19
- //_\\| '__/ __\ \| __/ _\ |/ __| |/ /
20
- / _ \ | | (___\ \ || (_| | (__| <
21
- \_/ \_/_| \___\__/\__\__,_|\___|_|\_\
22
-
23
- `;
24
-
25
- //#endregion
26
- //#region src/templates.ts
27
- /**
28
- * List of first party templates
29
- */
30
- const templates = [
31
- {
32
- name: "Express Starter Kit",
33
- alias: "express",
34
- hint: "An Express application starter kit",
35
- source: "github:arkstack-hq/arkstack"
36
- },
37
- {
38
- name: "Express Lean Starter Kit",
39
- alias: "express-lean",
40
- hint: "A minimal Express application starter kit",
41
- source: "github:arkstack-hq/arkstack",
42
- lean: true,
43
- baseAlias: "express"
44
- },
45
- {
46
- name: "H3 Starter Kit",
47
- alias: "h3",
48
- hint: "A H3 application starter kit",
49
- source: "github:arkstack-hq/arkstack"
50
- },
51
- {
52
- name: "H3 Lean Starter Kit",
53
- alias: "h3-lean",
54
- hint: "A minimal H3 application starter kit",
55
- source: "github:arkstack-hq/arkstack",
56
- lean: true,
57
- baseAlias: "h3"
58
- }
59
- ];
60
-
61
- //#endregion
62
- //#region src/data.ts
63
- const filesToRemove = [
64
- "src/app/http/controllers",
65
- "src/app/http/resources",
66
- "src/models",
67
- "src/app/models",
68
- "database",
69
- "src/routes/api.ts",
70
- "src/database",
71
- "src/core/database.ts",
72
- "src/core/utils/drivers/ValidatorDBDriver.ts",
73
- "prisma",
74
- "prisma.config.ts",
75
- "arkorm.config.ts",
76
- "arkormx.config.ts",
77
- "arkorm.config.js",
78
- "arkormx.config.js",
79
- "arkorm.config.mjs",
80
- "arkormx.config.mjs"
81
- ];
82
- const fullDependencies = [
83
- "@prisma/adapter-pg",
84
- "@arkstack/console",
85
- "@prisma/client",
86
- "@types/pg",
87
- "pg",
88
- "kysely",
89
- "prisma",
90
- "arkormx"
91
- ];
92
- const leanDependencies = { "@arkstack/console-slim": "^0.3.17" };
93
- const depsList = {
94
- "@arkstack/http": "^0.3.17",
95
- "@arkstack/auth": "^0.3.17",
96
- "@arkstack/common": "^0.3.17",
97
- "@arkstack/console": "^0.3.17",
98
- "@arkstack/contract": "^0.3.17",
99
- "@arkstack/driver-h3": "^0.3.17",
100
- "@arkstack/filesystem": "^0.3.17",
101
- "@arkstack/driver-express": "^0.3.17",
102
- "@arkstack/notifications": "^0.3.17"
103
- };
104
-
105
- //#endregion
106
- //#region src/actions.ts
107
- var actions_default = class {
108
- skipInstallation;
109
- constructor(location, appName, description) {
110
- this.location = location;
111
- this.appName = appName;
112
- this.description = description;
113
- if (!this.location) this.location = join(process.cwd(), ".temp");
114
- }
115
- async pm() {
116
- return await detectPackageManager() ?? "npm";
117
- }
118
- async runCmd(npx = false) {
119
- if (npx) return "npx";
120
- const pm = await this.pm();
121
- return pm === "npm" ? "npm run" : pm;
122
- }
123
- async download(template, install = false, auth, overwrite = false) {
124
- if (this.location?.includes(".temp") || overwrite && existsSync(this.location)) await rm(this.location, {
125
- force: true,
126
- recursive: true
127
- });
128
- else if (existsSync(this.location)) {
129
- if ((await readdir(this.location ?? "./"))?.length > 0) {
130
- console.log("\n");
131
- Logger.parse([
132
- [" ERROR ", "bgRed"],
133
- [this.location, ["gray", "italic"]],
134
- ["is not empty.", "white"]
135
- ], " ");
136
- console.log("");
137
- process.exit(0);
138
- }
139
- }
140
- this.skipInstallation = !install;
141
- this.removeLockFile();
142
- return await downloadTemplate(template, {
143
- dir: this.location,
144
- auth,
145
- provider: "github",
146
- registry: await this.pm(),
147
- forceClean: false
148
- });
149
- }
150
- /**
151
- * Installs the project dependencies using the detected package manager.
152
- * If a specific package name is provided, it will install that package
153
- * instead of all dependencies.
154
- *
155
- * @param name
156
- * @param args
157
- * @returns
158
- */
159
- async installPackage(name, args = []) {
160
- const bcmd = await Resolver.getPakageInstallCommand() + (name ? ` ${name}` : "");
161
- const cmd = bcmd.split(" ")[0];
162
- if (bcmd.includes(" ")) args.unshift(...bcmd.split(" ").slice(1));
163
- const child = spawnSync(cmd, args, {
164
- cwd: process.cwd(),
165
- stdio: "ignore"
166
- });
167
- if (child.error) return child.status;
168
- return 0;
169
- }
170
- async complete(install = false) {
171
- let installed = false;
172
- if (install) installed = await this.installPackage() === 0;
173
- console.log("");
174
- const installPath = "./" + relative(process.cwd(), this.location);
175
- try {
176
- chdir(path.join(process.cwd(), installPath));
177
- } catch {}
178
- Logger.success("Your Arkstack project has been created successfully");
179
- Logger.parse([
180
- ["cd", "cyan"],
181
- [installPath, "yellow"],
182
- installPath === process.cwd() ? ["✔", "green"] : ["", "green"]
183
- ], " ");
184
- if (!installed) Logger.parse([[await Resolver.getPakageInstallCommand(), "cyan"]]);
185
- Logger.parse([[await this.runCmd(), "cyan"], ["dev", "yellow"]], " ");
186
- Logger.parse([["Open", "cyan"], ["http://localhost:3000", "yellow"]]);
187
- console.log("");
188
- Logger.parse([["Have any questions", "white"]]);
189
- Logger.parse([["Checkout our other projects -", "white"], ["https://toneflix.net/open-source", "yellow"]]);
190
- }
191
- async cleanup(kit) {
192
- const pkgPath = join(this.location, "package.json");
193
- const pkg = await readFile(pkgPath, "utf-8").then(JSON.parse);
194
- delete pkg.packageManager;
195
- delete pkg.scripts.predev;
196
- delete pkg.scripts.prebuild;
197
- delete pkg.scripts.precmd;
198
- delete pkg.scripts.cmd;
199
- pkg.scripts.dev = "ark dev";
200
- pkg.scripts.build = "ark build";
201
- pkg.scripts.postinstall = "prepare";
202
- pkg.name = Str.slugify(this.appName ?? basename(this.location).replace(".", ""), "-");
203
- if (this.description) pkg.description = this.description;
204
- for (const [name, version] of Object.entries(depsList)) {
205
- if (name.includes("@arkstack/driver")) continue;
206
- pkg.dependencies[name] = version;
207
- }
208
- pkg.dependencies["@arkstack/driver-" + kit] = depsList["@arkstack/driver-" + kit];
209
- await Promise.allSettled([
210
- writeFile(pkgPath, JSON.stringify(pkg, null, 2)),
211
- this.removeLockFile(),
212
- rm(join(this.location, "pnpm-workspace.yaml"), { force: true }),
213
- rm(join(this.location, ".github"), {
214
- force: true,
215
- recursive: true
216
- })
217
- ]);
218
- }
219
- async removeLockFile() {
220
- if (!this.skipInstallation) return;
221
- await Promise.allSettled([
222
- unlink(join(this.location, "package-lock.json")),
223
- unlink(join(this.location, "yarn.lock")),
224
- unlink(join(this.location, "pnpm-lock.yaml"))
225
- ]);
226
- }
227
- async getBanner() {
228
- return await readFile(join(process.cwd(), "./logo.txt"), "utf-8");
229
- }
230
- async copyExampleEnv() {
231
- const envPath = join(this.location, ".env");
232
- const exampleEnvPath = join(this.location, ".env.example");
233
- if (existsSync(exampleEnvPath)) await copyFile(exampleEnvPath, envPath);
234
- }
235
- async makeLeanProfile(_kit) {
236
- await Promise.allSettled(filesToRemove.map((file) => rm(join(this.location, file), {
237
- force: true,
238
- recursive: true
239
- })));
240
- const pkgPath = join(this.location, "package.json");
241
- if (existsSync(pkgPath)) {
242
- const pkg = await readFile(pkgPath, "utf-8").then(JSON.parse);
243
- for (const dep of fullDependencies) {
244
- delete pkg.dependencies?.[dep];
245
- delete pkg.devDependencies?.[dep];
246
- }
247
- for (const [name, version] of Object.entries(leanDependencies)) pkg.dependencies[name] = version;
248
- await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
249
- }
250
- for (const file of [
251
- "src/core/app.ts",
252
- "src/core/router.ts",
253
- "src/core/bootstrap.ts"
254
- ]) {
255
- const filePath = join(this.location, file);
256
- if (!existsSync(filePath)) continue;
257
- let content = await readFile(filePath, "utf-8");
258
- content = content.replace("import { ValidatorDBDriver } from './utils/drivers/ValidatorDBDriver'\n", "").replace("import { ModelNotFoundException } from 'arkormx'\n", "").replace("import { prisma } from 'src/core/database'\n", "").replace("import { Prisma } from '@prisma/client'\n", "").replace("Validator.useDatabase(new ValidatorDBDriver())", "").replace(" async shutdown () {\n await prisma.$disconnect()\n process.exit(0)\n }", " async shutdown () {\n process.exit(0)\n }").replace(" * Shuts down the application by disconnecting from the database and exiting the process.", " * Shuts down the application and exits the process.").replace(/\n\s*if \((?:err|cause) instanceof Prisma\.PrismaClientKnownRequestError && (?:err|cause)\.code === "P2025"\) \{\n\s*error\.code = 404\n\s*error\.message = `\$\{(?:err|cause)\.meta\?\.modelName\} not found!`\n\s*\}\n/g, "\n").replace(/\n\s*if \((?:err|cause) instanceof ModelNotFoundException\) \{\n\s*error\.code = 404\n\s*error\.message = `\$\{(?:err|cause)\.getModelName\(\)\} not found!`\n\s*\}\n/g, "\n").replace(/if \(!\(err instanceof ValidationException\) &&\n\s*!\(err instanceof ModelNotFoundException\)\) {/g, "if (!(err instanceof ValidationException)) {").replace(/\s*\/\/ Register API routes\s*await ClearRouter\.group\('\/api', async \(\) => \{\s*await importFile\(join\(process\.cwd\(\), 'src\/routes\/api\.ts'\)\)\s*\}\)\s*/g, "\n\n ");
259
- await writeFile(filePath, content, "utf-8");
260
- }
261
- }
262
- };
263
-
264
- //#endregion
265
- //#region src/utils.ts
266
- /**
267
- * Removes all files in dirPath except the one specified by keepFileName
268
- *
269
- * @param dirPath
270
- * @param keepFileName
271
- */
272
- async function cleanDirectoryExcept(dirPath, keepFileName) {
273
- const files = await readdir(dirPath);
274
- for (const file of files) {
275
- if (file === keepFileName) continue;
276
- await rm(path.join(dirPath, file), {
277
- recursive: true,
278
- force: true
279
- });
280
- }
281
- }
282
- /**
283
- * Moves all files from dirPath to parent directory and removes dirPath
284
- *
285
- * @param dirPath
286
- * @param parent
287
- */
288
- async function hoistDirectoryContents(parent, dirPath) {
289
- const source = path.isAbsolute(dirPath) ? dirPath : path.join(process.cwd(), dirPath);
290
- const targetParent = path.isAbsolute(parent) ? parent : path.join(process.cwd(), parent);
291
- if (!source.startsWith(targetParent)) throw new Error("Source must be inside the parent directory");
292
- const entries = await readdir(source);
293
- for (const entry of entries) await rename(path.join(source, entry), path.join(targetParent, entry));
294
- await rm(source, { recursive: true });
295
- }
296
-
297
- //#endregion
298
- //#region src/Commands/CreateArkstackCommand.ts
299
- var CreateArkstackCommand = class extends Command {
300
- signature = `create-arkstack
301
- {location?: The location where this project should be created relative to the current dir.}
302
- {--n|name?: The name of your project.}
303
- {--i|install: Install node_modules right away}
304
- {--t|token?: Kit repo authentication token.}
305
- {--d|desc?: Project Description.}
306
- {--k|kit?: Starter template kit.}
307
- {--p|pre: Download prerelease version if available.}
308
- {--o|overwrite: Overwrite the installation directory if it is not empty.}
309
- `;
310
- description = "Display a personalized greeting.";
311
- async handle() {
312
- const options = this.options();
313
- const pathName = this.argument("location");
314
- console.log(altLogo, "font-family: monospace");
315
- let { template } = await inquirer.prompt([{
316
- type: "list",
317
- name: "template",
318
- message: "Choose starter template kit:",
319
- choices: templates.map((e) => ({
320
- name: e.name,
321
- value: e.alias,
322
- disabled: !e.source ? "(Unavailable at this time)" : false
323
- })),
324
- default: "full",
325
- when: () => !options.kit
326
- }]).catch((err) => {
327
- if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
328
- this.info("Thanks for trying out our starter kit.");
329
- process.exit(0);
330
- }
331
- return err;
332
- });
333
- let { appName, description } = await inquirer.prompt([{
334
- type: "input",
335
- name: "appName",
336
- message: "What is the name of your project:",
337
- default: `arkstack-${template}`,
338
- when: () => !options.name
339
- }, {
340
- type: "input",
341
- name: "description",
342
- message: "Project Description:",
343
- default: `Simple ${Str.of(template).ucfirst()}.js project created with Arkstack.`,
344
- when: () => !options.desc
345
- }]).catch((err) => {
346
- if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
347
- this.info("Thanks for trying out our starter kit.");
348
- process.exit(0);
349
- }
350
- return err;
351
- });
352
- let { location } = await inquirer.prompt([{
353
- type: "input",
354
- name: "location",
355
- message: "Installation location relative to the current dir:",
356
- default: Str.slugify(options.name ?? appName ?? basename(process.cwd()), "-"),
357
- when: () => !pathName
358
- }]).catch((err) => {
359
- if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
360
- this.info("Thanks for trying out our starter kit.");
361
- process.exit(0);
362
- }
363
- return err;
364
- });
365
- /**
366
- * Find selected template kit
367
- */
368
- const kit = templates.find((e) => e.alias === template);
369
- let { install, token, pre } = await inquirer.prompt([
370
- {
371
- type: "confirm",
372
- name: "pre",
373
- message: `An alpha version of the ${kit.name.replace(/\s*kit$/i, "").trim()} kit is available. Would you like to use it instead?`,
374
- default: false,
375
- when: () => kit.prereleaseSource && !options.pre
376
- },
377
- {
378
- type: "input",
379
- name: "token",
380
- message: "Authentication token:",
381
- when: () => options.kit && !options.token
382
- },
383
- {
384
- type: "confirm",
385
- name: "install",
386
- message: "Would you like to install node_modules right away?:",
387
- default: true,
388
- when: () => !options.install
389
- }
390
- ]).catch((err) => {
391
- if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
392
- this.info("Thanks for trying out our starter kit.");
393
- process.exit(0);
394
- }
395
- return err;
396
- });
397
- pre = options.pre ?? pre;
398
- token = options.token ?? token;
399
- appName = options.name ?? appName;
400
- install = options.install ?? install;
401
- template = options.kit ?? template;
402
- location = pathName ?? location;
403
- description = options.description ?? description;
404
- /**
405
- * Validate selected kit
406
- */
407
- if (kit && !kit.source) {
408
- this.error(`ERROR: The ${kit.name} kit is not currently available`);
409
- process.exit(1);
410
- }
411
- const kitName = (kit.baseAlias ?? kit.alias).replace(/-lean$/i, "");
412
- const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
413
- const actions = new actions_default(join(process.cwd(), location), appName, description);
414
- const spinner = this.spinner("Loading Template...").start();
415
- const result = await actions.download(source, install, token, options.overwrite);
416
- if (result.dir && kitName) {
417
- await cleanDirectoryExcept(result.dir, kitName);
418
- await hoistDirectoryContents(result.dir, join(result.dir, kitName));
419
- }
420
- if (kit.lean) {
421
- spinner.info(Logger.parse([["Applying lean profile...", "green"]], "", false)).start();
422
- await actions.makeLeanProfile(kitName);
423
- }
424
- spinner.info(Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
425
- await actions.cleanup(kitName);
426
- spinner.info(Logger.parse([["Initializing Project...", "green"]], "", false)).start();
427
- await actions.copyExampleEnv();
428
- await actions.complete(install);
429
- spinner.succeed(Logger.parse([["Project initialization complete!", "green"]], "", false));
430
- }
431
- };
432
-
433
- //#endregion
434
- //#region src/run.ts
435
- var Application = class {};
436
- Kernel.init(new Application(), { rootCommand: CreateArkstackCommand });
437
-
438
- //#endregion
439
- export { };
440
- //# sourceMappingURL=run.js.map
package/bin/run.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.js","names":["templates: Template[]","depsList: Record<string, string>","location?: string","appName?: string","description?: string","source: string","Actions"],"sources":["../src/logo.ts","../src/templates.ts","../src/data.ts","../src/actions.ts","../src/utils.ts","../src/Commands/CreateArkstackCommand.ts","../src/run.ts"],"sourcesContent":["export const altLogo = String.raw`%c\n _ __ _ _ \n /_\\ _ __ ___/ _\\ |_ __ _ ___| | __\n //_\\\\| '__/ __\\ \\| __/ _\\ |/ __| |/ /\n/ _ \\ | | (___\\ \\ || (_| | (__| < \n\\_/ \\_/_| \\___\\__/\\__\\__,_|\\___|_|\\_\\\n \n`\n","/*\n * create-arkstack - A CLI tool to create Arkstack applications\n *\n * (c) Toneflix\n *\n * The Arkstack framework and all its base packages unless otherwise stated, are\n * open-sourced software licensed under the MIT license.\n */\nimport { Template } from './types'\n\n/**\n * List of first party templates\n */\nexport const templates: Template[] = [\n {\n name: 'Express Starter Kit',\n alias: 'express',\n hint: 'An Express application starter kit',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'Express Lean Starter Kit',\n alias: 'express-lean',\n hint: 'A minimal Express application starter kit',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'express',\n },\n {\n name: 'H3 Starter Kit',\n alias: 'h3',\n hint: 'A H3 application starter kit',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'H3 Lean Starter Kit',\n alias: 'h3-lean',\n hint: 'A minimal H3 application starter kit',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'h3',\n },\n]","export const filesToRemove = [\n 'src/app/http/controllers',\n 'src/app/http/resources',\n 'src/models',\n 'src/app/models',\n 'database',\n 'src/routes/api.ts',\n 'src/database',\n 'src/core/database.ts',\n 'src/core/utils/drivers/ValidatorDBDriver.ts',\n 'prisma',\n 'prisma.config.ts',\n 'arkorm.config.ts',\n 'arkormx.config.ts',\n 'arkorm.config.js',\n 'arkormx.config.js',\n 'arkorm.config.mjs',\n 'arkormx.config.mjs',\n]\n\nexport const fullDependencies = [\n '@prisma/adapter-pg',\n '@arkstack/console',\n '@prisma/client',\n '@types/pg',\n 'pg',\n 'kysely',\n 'prisma',\n 'arkormx',\n]\n\nexport const leanDependencies = {\n '@arkstack/console-slim': '^0.3.17',\n}\n\nexport const depsList: Record<string, string> = {\n '@arkstack/http': '^0.3.17',\n '@arkstack/auth': '^0.3.17',\n '@arkstack/common': '^0.3.17',\n '@arkstack/console': '^0.3.17',\n '@arkstack/contract': '^0.3.17',\n '@arkstack/driver-h3': '^0.3.17',\n '@arkstack/filesystem': '^0.3.17',\n '@arkstack/driver-express': '^0.3.17',\n '@arkstack/notifications': '^0.3.17',\n}\n","import { Logger, Resolver } from '@h3ravel/shared'\nimport { copyFile, readFile, readdir, rm, unlink, writeFile } from 'node:fs/promises'\nimport { filesToRemove, fullDependencies, leanDependencies } from './data'\nimport path, { basename, join, relative } from 'node:path'\n\nimport type { KitName } from './types'\nimport { Str } from '@h3ravel/support'\nimport { chdir } from 'node:process'\nimport { depsList } from './data'\nimport { detectPackageManager } from '@antfu/install-pkg'\nimport { downloadTemplate } from 'giget'\nimport { existsSync } from 'node:fs'\nimport { spawnSync } from 'node:child_process'\n\nexport default class {\n skipInstallation?: boolean\n\n constructor(\n private location?: string,\n private appName?: string,\n private description?: string,\n ) {\n if (!this.location) {\n this.location = join(process.cwd(), '.temp')\n }\n }\n\n async pm () {\n return (await detectPackageManager()) ?? 'npm'\n }\n\n async runCmd (npx: boolean = false) {\n if (npx) return 'npx'\n\n const pm = await this.pm()\n\n return pm === 'npm' ? 'npm run' : pm\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 const files = await readdir(this.location ?? './')\n if (files?.length > 0) {\n console.log('\\n')\n Logger.parse(\n [\n [' ERROR ', 'bgRed'],\n [this.location!, ['gray', 'italic']],\n ['is not empty.', 'white'],\n ],\n ' ',\n )\n console.log('')\n process.exit(0)\n }\n }\n\n this.skipInstallation = !install\n this.removeLockFile()\n\n const status = await downloadTemplate(template, {\n dir: this.location,\n auth,\n provider: 'github',\n registry: await this.pm(),\n forceClean: false,\n })\n\n return status\n }\n\n /**\n * Installs the project dependencies using the detected package manager. \n * If a specific package name is provided, it will install that package \n * instead of all dependencies.\n * \n * @param name \n * @param args \n * @returns \n */\n async installPackage (name?: string, args: string[] = []) {\n const bcmd = await Resolver.getPakageInstallCommand() + (name ? ` ${name}` : '')\n const cmd = bcmd.split(' ')[0]\n if (bcmd.includes(' ')) {\n args.unshift(...bcmd.split(' ').slice(1))\n }\n\n const child = spawnSync(cmd, args, {\n cwd: process.cwd(),\n stdio: 'ignore',\n })\n\n if (child.error) {\n return child.status\n }\n\n return 0\n }\n\n async complete (install = false) {\n let installed = false\n if (install) {\n installed = await this.installPackage() === 0\n }\n\n console.log('')\n\n const installPath = './' + relative(process.cwd(), this.location!)\n\n try {\n chdir(path.join(process.cwd(), installPath))\n } catch {\n /** */\n }\n\n Logger.success('Your Arkstack project has been created successfully')\n Logger.parse(\n [\n ['cd', 'cyan'],\n [installPath, 'yellow'],\n installPath === process.cwd() ? ['✔', 'green'] : ['', 'green'],\n ],\n ' ',\n )\n\n if (!installed) {\n Logger.parse([[await Resolver.getPakageInstallCommand(), 'cyan']])\n }\n\n Logger.parse(\n [\n [await this.runCmd(), 'cyan'],\n ['dev', 'yellow'],\n ],\n ' ',\n )\n Logger.parse([\n ['Open', 'cyan'],\n ['http://localhost:3000', 'yellow'],\n ])\n\n console.log('')\n\n Logger.parse([['Have any questions', 'white']])\n // Logger.parse([\n // [\"Join our Discord server -\", \"white\"],\n // [\"https://discord.gg/hsG2A8PuGb\", \"yellow\"],\n // ]);\n Logger.parse([\n ['Checkout our other projects -', 'white'],\n ['https://toneflix.net/open-source', 'yellow'],\n ])\n }\n\n async cleanup (kit: KitName) {\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 delete pkg.scripts.predev\n delete pkg.scripts.prebuild\n delete pkg.scripts.precmd\n delete pkg.scripts.cmd\n\n pkg.scripts.dev = 'ark dev'\n pkg.scripts.build = 'ark build'\n pkg.scripts.postinstall = 'prepare'\n\n pkg.name = Str.slugify(\n this.appName ?? basename(this.location!).replace('.', ''), '-'\n )\n\n if (this.description) {\n pkg.description = this.description\n }\n\n for (const [name, version] of Object.entries(depsList)) {\n if (name.includes('@arkstack/driver')) continue\n pkg.dependencies[name] = version\n }\n\n pkg.dependencies['@arkstack/driver-' + kit] = depsList[('@arkstack/driver-' + kit)]\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!, '.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 makeLeanProfile (_kit: KitName) {\n await Promise.allSettled(\n filesToRemove.map((file) => rm(join(this.location!, file), { force: true, recursive: true })),\n )\n\n const pkgPath = join(this.location!, 'package.json')\n if (existsSync(pkgPath)) {\n const pkg = await readFile(pkgPath, 'utf-8').then(JSON.parse)\n\n for (const dep of fullDependencies) {\n delete pkg.dependencies?.[dep]\n delete pkg.devDependencies?.[dep]\n }\n\n for (const [name, version] of Object.entries(leanDependencies)) {\n pkg.dependencies[name] = version\n }\n\n await writeFile(pkgPath, JSON.stringify(pkg, null, 2))\n }\n\n const filesToPatch = [\n 'src/core/app.ts',\n 'src/core/router.ts',\n 'src/core/bootstrap.ts',\n ]\n\n for (const file of filesToPatch) {\n const filePath = join(this.location!, file)\n\n if (!existsSync(filePath)) {\n continue\n }\n\n let content = await readFile(filePath, 'utf-8')\n\n content = content\n .replace('import { ValidatorDBDriver } from \\'./utils/drivers/ValidatorDBDriver\\'\\n', '')\n .replace('import { ModelNotFoundException } from \\'arkormx\\'\\n', '')\n .replace('import { prisma } from \\'src/core/database\\'\\n', '')\n .replace('import { Prisma } from \\'@prisma/client\\'\\n', '')\n .replace('Validator.useDatabase(new ValidatorDBDriver())', '')\n .replace(' async shutdown () {\\n await prisma.$disconnect()\\n process.exit(0)\\n }', ' async shutdown () {\\n process.exit(0)\\n }')\n .replace(\n ' * Shuts down the application by disconnecting from the database and exiting the process.',\n ' * Shuts down the application and exits the process.',\n )\n .replace(\n /\\n\\s*if \\((?:err|cause) instanceof Prisma\\.PrismaClientKnownRequestError && (?:err|cause)\\.code === \"P2025\"\\) \\{\\n\\s*error\\.code = 404\\n\\s*error\\.message = `\\$\\{(?:err|cause)\\.meta\\?\\.modelName\\} not found!`\\n\\s*\\}\\n/g,\n '\\n',\n )\n .replace(\n /\\n\\s*if \\((?:err|cause) instanceof ModelNotFoundException\\) \\{\\n\\s*error\\.code = 404\\n\\s*error\\.message = `\\$\\{(?:err|cause)\\.getModelName\\(\\)\\} not found!`\\n\\s*\\}\\n/g,\n '\\n',\n )\n .replace(\n /if \\(!\\(err instanceof ValidationException\\) &&\\n\\s*!\\(err instanceof ModelNotFoundException\\)\\) {/g,\n 'if (!(err instanceof ValidationException)) {'\n )\n .replace(\n /\\s*\\/\\/ Register API routes\\s*await ClearRouter\\.group\\('\\/api', async \\(\\) => \\{\\s*await importFile\\(join\\(process\\.cwd\\(\\), 'src\\/routes\\/api\\.ts'\\)\\)\\s*\\}\\)\\s*/g,\n '\\n\\n ',\n )\n\n await writeFile(filePath, content, 'utf-8')\n }\n\n }\n}\n","import { readdir, rename, rm } from 'node:fs/promises'\n\nimport path from 'node:path'\n\n/**\n * Removes all files in dirPath except the one specified by keepFileName\n *\n * @param dirPath\n * @param keepFileName\n */\nexport async function cleanDirectoryExcept (dirPath: string, keepFileName: string) {\n const files = await readdir(dirPath)\n\n for (const file of files) {\n if (file === keepFileName) continue\n\n const fullPath = path.join(dirPath, file)\n\n await rm(fullPath, { recursive: true, force: true })\n }\n}\n\n/**\n * Moves all files from dirPath to parent directory and removes dirPath\n *\n * @param dirPath\n * @param parent\n */\nexport async function hoistDirectoryContents (parent: string, dirPath: string) {\n const source = path.isAbsolute(dirPath) ? dirPath : path.join(process.cwd(), dirPath)\n\n const targetParent = path.isAbsolute(parent) ? parent : path.join(process.cwd(), parent)\n\n if (!source.startsWith(targetParent)) {\n throw new Error('Source must be inside the parent directory')\n }\n\n const entries = await readdir(source)\n\n for (const entry of entries) {\n const from = path.join(source, entry)\n const to = path.join(targetParent, entry)\n\n await rename(from, to)\n }\n\n await rm(source, { recursive: true })\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 { Logger } from '@h3ravel/shared'\nimport { cleanDirectoryExcept, hoistDirectoryContents } from 'src/utils'\nimport type { KitName } from 'src/types'\n\nexport class CreateArkstackCommand extends Command {\n protected signature = `create-arkstack\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 // const defaultName = pathName ? Str.of(pathName).afterLast(\"/\") : undefined;\n\n console.log(altLogo, 'font-family: monospace')\n\n let { template } = await inquirer\n .prompt([\n {\n type: 'list',\n name: 'template',\n message: 'Choose starter template kit:',\n choices: <never>templates.map((e) => ({\n name: e.name,\n value: e.alias,\n disabled: !e.source ? '(Unavailable at this time)' : false,\n })),\n default: 'full',\n when: () => !options.kit,\n },\n ])\n .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\n\n return err\n })\n\n let { appName, description } = await inquirer\n .prompt([\n {\n type: 'input',\n name: 'appName',\n message: 'What is the name of your project:',\n default: `arkstack-${template}`,\n // default: defaultName ?? `arkstack-${template}`,\n when: () => !options.name,\n },\n {\n type: 'input',\n name: 'description',\n message: 'Project Description:',\n default: `Simple ${Str.of(template).ucfirst()}.js project created with Arkstack.`,\n when: () => !options.desc,\n },\n ])\n .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\n\n return err\n })\n\n let { location } = await inquirer\n .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 .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\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\n .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 like to install node_modules right away?:',\n default: true,\n when: () => !options.install,\n },\n ])\n .catch((err) => {\n if (err instanceof AbortPromptError || err instanceof ExitPromptError) {\n this.info('Thanks for trying out our starter kit.')\n process.exit(0)\n }\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 kitName = (kit.baseAlias ?? kit.alias).replace(/-lean$/i, '') as KitName\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 = this.spinner('Loading Template...').start()\n\n const result = await actions.download(source, install, token, options.overwrite)\n\n if (result.dir && kitName) {\n await cleanDirectoryExcept(result.dir, kitName)\n await hoistDirectoryContents(result.dir, join(result.dir, kitName))\n }\n\n if (kit.lean) {\n spinner.info(Logger.parse([[\n 'Applying lean profile...',\n 'green',\n ]], '', false)).start()\n await actions.makeLeanProfile(kitName)\n }\n\n spinner.info(Logger.parse([['Cleaning Up...', 'green']], '', false)).start()\n\n await actions.cleanup(kitName)\n\n spinner.info(Logger.parse([['Initializing Project...', 'green']], '', false)).start()\n\n await actions.copyExampleEnv()\n\n await actions.complete(install)\n\n spinner.succeed(Logger.parse([['Project initialization complete!', 'green']], '', false))\n }\n}\n","#!/usr/bin/env node\n\nimport { CreateArkstackCommand } from './Commands/CreateArkstackCommand'\nimport { Kernel } from '@h3ravel/musket'\n\nclass Application { }\n\nKernel.init(new Application(), {\n rootCommand: CreateArkstackCommand,\n})\n"],"mappings":";;;;;;;;;;;;;;;AAAA,MAAa,UAAU,OAAO,GAAG;;;;;;;;;;;;;;ACajC,MAAaA,YAAwB;CACnC;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACT;CACD;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,MAAM;EACN,WAAW;EACZ;CACD;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACT;CACD;EACE,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,MAAM;EACN,WAAW;EACZ;CACF;;;;AC1CD,MAAa,gBAAgB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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