create-arkstack 0.4.3 → 0.5.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/package.json +6 -3
- package/bin/run.cjs +0 -475
- package/bin/run.cjs.map +0 -1
- package/bin/run.d.cts +0 -1
- package/bin/run.d.ts +0 -1
- package/bin/run.js +0 -441
- package/bin/run.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-arkstack",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"description": "Create new Arkstack framework applications on Express or H3 runtime drivers",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
7
7
|
"repository": {
|
|
@@ -62,12 +62,15 @@
|
|
|
62
62
|
"@inquirer/core": "^10.2.2",
|
|
63
63
|
"giget": "^2.0.0",
|
|
64
64
|
"inquirer": "^12.9.6",
|
|
65
|
-
"
|
|
65
|
+
"dotenv": "^17.4.2",
|
|
66
|
+
"tsdown": "^0.22.0",
|
|
67
|
+
"unrun": "^0.3.0"
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
70
|
"@changesets/cli": "^2.29.5",
|
|
69
71
|
"eslint": "^9.32.0",
|
|
70
|
-
"ts-node": "^10.9.2"
|
|
72
|
+
"ts-node": "^10.9.2",
|
|
73
|
+
"typescript": "^6.0.0"
|
|
71
74
|
},
|
|
72
75
|
"scripts": {
|
|
73
76
|
"test": "vitest run",
|
package/bin/run.cjs
DELETED
|
@@ -1,475 +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 Runtime Template",
|
|
68
|
-
alias: "express",
|
|
69
|
-
hint: "An Arkstack application running on Express",
|
|
70
|
-
source: "github:arkstack-hq/arkstack"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "Express Lean Runtime Template",
|
|
74
|
-
alias: "express-lean",
|
|
75
|
-
hint: "A minimal Arkstack application running on Express",
|
|
76
|
-
source: "github:arkstack-hq/arkstack",
|
|
77
|
-
lean: true,
|
|
78
|
-
baseAlias: "express"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "H3 Runtime Template",
|
|
82
|
-
alias: "h3",
|
|
83
|
-
hint: "An Arkstack application running on H3",
|
|
84
|
-
source: "github:arkstack-hq/arkstack"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: "H3 Lean Runtime Template",
|
|
88
|
-
alias: "h3-lean",
|
|
89
|
-
hint: "A minimal Arkstack application running on H3",
|
|
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.4.3" };
|
|
128
|
-
const depsList = {
|
|
129
|
-
"@arkstack/http": "^0.4.3",
|
|
130
|
-
"@arkstack/view": "^0.4.3",
|
|
131
|
-
"@arkstack/auth": "^0.4.3",
|
|
132
|
-
"@arkstack/common": "^0.4.3",
|
|
133
|
-
"@arkstack/console": "^0.4.3",
|
|
134
|
-
"@arkstack/contract": "^0.4.3",
|
|
135
|
-
"@arkstack/driver-h3": "^0.4.3",
|
|
136
|
-
"@arkstack/filesystem": "^0.4.3",
|
|
137
|
-
"@arkstack/driver-express": "^0.4.3",
|
|
138
|
-
"@arkstack/notifications": "^0.4.3"
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/actions.ts
|
|
143
|
-
var actions_default = class {
|
|
144
|
-
skipInstallation;
|
|
145
|
-
constructor(location, appName, description) {
|
|
146
|
-
this.location = location;
|
|
147
|
-
this.appName = appName;
|
|
148
|
-
this.description = description;
|
|
149
|
-
if (!this.location) this.location = (0, node_path.join)(process.cwd(), ".temp");
|
|
150
|
-
}
|
|
151
|
-
async pm() {
|
|
152
|
-
return await (0, __antfu_install_pkg.detectPackageManager)() ?? "npm";
|
|
153
|
-
}
|
|
154
|
-
async runCmd(npx = false) {
|
|
155
|
-
if (npx) return "npx";
|
|
156
|
-
const pm = await this.pm();
|
|
157
|
-
return pm === "npm" ? "npm run" : pm;
|
|
158
|
-
}
|
|
159
|
-
async download(template, install = false, auth, overwrite = false) {
|
|
160
|
-
if (this.location?.includes(".temp") || overwrite && (0, node_fs.existsSync)(this.location)) await (0, node_fs_promises.rm)(this.location, {
|
|
161
|
-
force: true,
|
|
162
|
-
recursive: true
|
|
163
|
-
});
|
|
164
|
-
else if ((0, node_fs.existsSync)(this.location)) {
|
|
165
|
-
if ((await (0, node_fs_promises.readdir)(this.location ?? "./"))?.length > 0) {
|
|
166
|
-
console.log("\n");
|
|
167
|
-
__h3ravel_shared.Logger.parse([
|
|
168
|
-
[" ERROR ", "bgRed"],
|
|
169
|
-
[this.location, ["gray", "italic"]],
|
|
170
|
-
["is not empty.", "white"]
|
|
171
|
-
], " ");
|
|
172
|
-
console.log("");
|
|
173
|
-
process.exit(0);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
this.skipInstallation = !install;
|
|
177
|
-
this.removeLockFile();
|
|
178
|
-
return await (0, giget.downloadTemplate)(template, {
|
|
179
|
-
dir: this.location,
|
|
180
|
-
auth,
|
|
181
|
-
provider: "github",
|
|
182
|
-
registry: await this.pm(),
|
|
183
|
-
forceClean: false
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Installs the project dependencies using the detected package manager.
|
|
188
|
-
* If a specific package name is provided, it will install that package
|
|
189
|
-
* instead of all dependencies.
|
|
190
|
-
*
|
|
191
|
-
* @param name
|
|
192
|
-
* @param args
|
|
193
|
-
* @returns
|
|
194
|
-
*/
|
|
195
|
-
async installPackage(name, args = []) {
|
|
196
|
-
const bcmd = await __h3ravel_shared.Resolver.getPakageInstallCommand() + (name ? ` ${name}` : "");
|
|
197
|
-
const cmd = bcmd.split(" ")[0];
|
|
198
|
-
if (bcmd.includes(" ")) args.unshift(...bcmd.split(" ").slice(1));
|
|
199
|
-
const child = (0, node_child_process.spawnSync)(cmd, args, {
|
|
200
|
-
cwd: process.cwd(),
|
|
201
|
-
stdio: "ignore"
|
|
202
|
-
});
|
|
203
|
-
if (child.error) return child.status;
|
|
204
|
-
return 0;
|
|
205
|
-
}
|
|
206
|
-
async complete(install = false) {
|
|
207
|
-
let installed = false;
|
|
208
|
-
if (install) installed = await this.installPackage() === 0;
|
|
209
|
-
console.log("");
|
|
210
|
-
const installPath = "./" + (0, node_path.relative)(process.cwd(), this.location);
|
|
211
|
-
try {
|
|
212
|
-
(0, node_process.chdir)(node_path.default.join(process.cwd(), installPath));
|
|
213
|
-
} catch {}
|
|
214
|
-
__h3ravel_shared.Logger.success("Your Arkstack project has been created successfully");
|
|
215
|
-
__h3ravel_shared.Logger.parse([
|
|
216
|
-
["cd", "cyan"],
|
|
217
|
-
[installPath, "yellow"],
|
|
218
|
-
installPath === process.cwd() ? ["✔", "green"] : ["", "green"]
|
|
219
|
-
], " ");
|
|
220
|
-
if (!installed) __h3ravel_shared.Logger.parse([[await __h3ravel_shared.Resolver.getPakageInstallCommand(), "cyan"]]);
|
|
221
|
-
__h3ravel_shared.Logger.parse([[await this.runCmd(), "cyan"], ["dev", "yellow"]], " ");
|
|
222
|
-
__h3ravel_shared.Logger.parse([["Open", "cyan"], ["http://localhost:3000", "yellow"]]);
|
|
223
|
-
console.log("");
|
|
224
|
-
__h3ravel_shared.Logger.parse([["Have any questions", "white"]]);
|
|
225
|
-
__h3ravel_shared.Logger.parse([["Checkout our other projects -", "white"], ["https://toneflix.net/open-source", "yellow"]]);
|
|
226
|
-
}
|
|
227
|
-
async cleanup(kit) {
|
|
228
|
-
const pkgPath = (0, node_path.join)(this.location, "package.json");
|
|
229
|
-
const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
|
|
230
|
-
delete pkg.packageManager;
|
|
231
|
-
delete pkg.scripts.predev;
|
|
232
|
-
delete pkg.scripts.prebuild;
|
|
233
|
-
delete pkg.scripts.precmd;
|
|
234
|
-
delete pkg.scripts.cmd;
|
|
235
|
-
pkg.scripts.dev = "ark dev";
|
|
236
|
-
pkg.scripts.build = "ark build";
|
|
237
|
-
pkg.scripts.postinstall = "prepare";
|
|
238
|
-
pkg.name = __h3ravel_support.Str.slugify(this.appName ?? (0, node_path.basename)(this.location).replace(".", ""), "-");
|
|
239
|
-
if (this.description) pkg.description = this.description;
|
|
240
|
-
for (const [name, version] of Object.entries(depsList)) {
|
|
241
|
-
if (name.includes("@arkstack/driver")) continue;
|
|
242
|
-
pkg.dependencies[name] = version;
|
|
243
|
-
}
|
|
244
|
-
pkg.dependencies["@arkstack/driver-" + kit] = depsList["@arkstack/driver-" + kit];
|
|
245
|
-
await Promise.allSettled([
|
|
246
|
-
(0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2)),
|
|
247
|
-
this.removeLockFile(),
|
|
248
|
-
(0, node_fs_promises.rm)((0, node_path.join)(this.location, "pnpm-workspace.yaml"), { force: true }),
|
|
249
|
-
(0, node_fs_promises.rm)((0, node_path.join)(this.location, ".github"), {
|
|
250
|
-
force: true,
|
|
251
|
-
recursive: true
|
|
252
|
-
})
|
|
253
|
-
]);
|
|
254
|
-
}
|
|
255
|
-
async removeLockFile() {
|
|
256
|
-
if (!this.skipInstallation) return;
|
|
257
|
-
await Promise.allSettled([
|
|
258
|
-
(0, node_fs_promises.unlink)((0, node_path.join)(this.location, "package-lock.json")),
|
|
259
|
-
(0, node_fs_promises.unlink)((0, node_path.join)(this.location, "yarn.lock")),
|
|
260
|
-
(0, node_fs_promises.unlink)((0, node_path.join)(this.location, "pnpm-lock.yaml"))
|
|
261
|
-
]);
|
|
262
|
-
}
|
|
263
|
-
async getBanner() {
|
|
264
|
-
return await (0, node_fs_promises.readFile)((0, node_path.join)(process.cwd(), "./logo.txt"), "utf-8");
|
|
265
|
-
}
|
|
266
|
-
async copyExampleEnv() {
|
|
267
|
-
const envPath = (0, node_path.join)(this.location, ".env");
|
|
268
|
-
const exampleEnvPath = (0, node_path.join)(this.location, ".env.example");
|
|
269
|
-
if ((0, node_fs.existsSync)(exampleEnvPath)) await (0, node_fs_promises.copyFile)(exampleEnvPath, envPath);
|
|
270
|
-
}
|
|
271
|
-
async makeLeanProfile(_kit) {
|
|
272
|
-
await Promise.allSettled(filesToRemove.map((file) => (0, node_fs_promises.rm)((0, node_path.join)(this.location, file), {
|
|
273
|
-
force: true,
|
|
274
|
-
recursive: true
|
|
275
|
-
})));
|
|
276
|
-
const pkgPath = (0, node_path.join)(this.location, "package.json");
|
|
277
|
-
if ((0, node_fs.existsSync)(pkgPath)) {
|
|
278
|
-
const pkg = await (0, node_fs_promises.readFile)(pkgPath, "utf-8").then(JSON.parse);
|
|
279
|
-
for (const dep of fullDependencies) {
|
|
280
|
-
delete pkg.dependencies?.[dep];
|
|
281
|
-
delete pkg.devDependencies?.[dep];
|
|
282
|
-
}
|
|
283
|
-
for (const [name, version] of Object.entries(leanDependencies)) pkg.dependencies[name] = version;
|
|
284
|
-
await (0, node_fs_promises.writeFile)(pkgPath, JSON.stringify(pkg, null, 2));
|
|
285
|
-
}
|
|
286
|
-
for (const file of [
|
|
287
|
-
"src/core/app.ts",
|
|
288
|
-
"src/core/router.ts",
|
|
289
|
-
"src/core/bootstrap.ts"
|
|
290
|
-
]) {
|
|
291
|
-
const filePath = (0, node_path.join)(this.location, file);
|
|
292
|
-
if (!(0, node_fs.existsSync)(filePath)) continue;
|
|
293
|
-
let content = await (0, node_fs_promises.readFile)(filePath, "utf-8");
|
|
294
|
-
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 ");
|
|
295
|
-
await (0, node_fs_promises.writeFile)(filePath, content, "utf-8");
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
//#endregion
|
|
301
|
-
//#region src/utils.ts
|
|
302
|
-
/**
|
|
303
|
-
* Removes all files in dirPath except the one specified by keepFileName
|
|
304
|
-
*
|
|
305
|
-
* @param dirPath
|
|
306
|
-
* @param keepFileName
|
|
307
|
-
*/
|
|
308
|
-
async function cleanDirectoryExcept(dirPath, keepFileName) {
|
|
309
|
-
const files = await (0, node_fs_promises.readdir)(dirPath);
|
|
310
|
-
for (const file of files) {
|
|
311
|
-
if (file === keepFileName) continue;
|
|
312
|
-
await (0, node_fs_promises.rm)(node_path.default.join(dirPath, file), {
|
|
313
|
-
recursive: true,
|
|
314
|
-
force: true
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Moves all files from dirPath to parent directory and removes dirPath
|
|
320
|
-
*
|
|
321
|
-
* @param dirPath
|
|
322
|
-
* @param parent
|
|
323
|
-
*/
|
|
324
|
-
async function hoistDirectoryContents(parent, dirPath) {
|
|
325
|
-
const source = node_path.default.isAbsolute(dirPath) ? dirPath : node_path.default.join(process.cwd(), dirPath);
|
|
326
|
-
const targetParent = node_path.default.isAbsolute(parent) ? parent : node_path.default.join(process.cwd(), parent);
|
|
327
|
-
if (!source.startsWith(targetParent)) throw new Error("Source must be inside the parent directory");
|
|
328
|
-
const entries = await (0, node_fs_promises.readdir)(source);
|
|
329
|
-
for (const entry of entries) await (0, node_fs_promises.rename)(node_path.default.join(source, entry), node_path.default.join(targetParent, entry));
|
|
330
|
-
await (0, node_fs_promises.rm)(source, { recursive: true });
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
//#endregion
|
|
334
|
-
//#region src/Commands/CreateArkstackCommand.ts
|
|
335
|
-
var CreateArkstackCommand = class extends __h3ravel_musket.Command {
|
|
336
|
-
signature = `create-arkstack
|
|
337
|
-
{location?: The location where this project should be created relative to the current dir.}
|
|
338
|
-
{--n|name?: The name of your project.}
|
|
339
|
-
{--i|install: Install node_modules right away}
|
|
340
|
-
{--t|token?: Kit repo authentication token.}
|
|
341
|
-
{--d|desc?: Project Description.}
|
|
342
|
-
{--k|kit?: Runtime template.}
|
|
343
|
-
{--p|pre: Download prerelease version if available.}
|
|
344
|
-
{--o|overwrite: Overwrite the installation directory if it is not empty.}
|
|
345
|
-
`;
|
|
346
|
-
description = "Display a personalized greeting.";
|
|
347
|
-
async handle() {
|
|
348
|
-
const options = this.options();
|
|
349
|
-
const pathName = this.argument("location");
|
|
350
|
-
console.log(altLogo, "font-family: monospace");
|
|
351
|
-
let { template } = await inquirer.default.prompt([{
|
|
352
|
-
type: "list",
|
|
353
|
-
name: "template",
|
|
354
|
-
message: "Choose runtime template:",
|
|
355
|
-
choices: templates.map((e) => ({
|
|
356
|
-
name: e.name,
|
|
357
|
-
value: e.alias,
|
|
358
|
-
disabled: !e.source ? "(Unavailable at this time)" : false
|
|
359
|
-
})),
|
|
360
|
-
default: "full",
|
|
361
|
-
when: () => !options.kit
|
|
362
|
-
}]).catch((err) => {
|
|
363
|
-
if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
|
|
364
|
-
this.info("Thanks for trying out Arkstack.");
|
|
365
|
-
process.exit(0);
|
|
366
|
-
}
|
|
367
|
-
return err;
|
|
368
|
-
});
|
|
369
|
-
let { appName, description } = await inquirer.default.prompt([{
|
|
370
|
-
type: "input",
|
|
371
|
-
name: "appName",
|
|
372
|
-
message: "What is the name of your project:",
|
|
373
|
-
default: `arkstack-${template}`,
|
|
374
|
-
when: () => !options.name
|
|
375
|
-
}, {
|
|
376
|
-
type: "input",
|
|
377
|
-
name: "description",
|
|
378
|
-
message: "Project Description:",
|
|
379
|
-
default: `Simple ${__h3ravel_support.Str.of(template).ucfirst()}.js project created with Arkstack.`,
|
|
380
|
-
when: () => !options.desc
|
|
381
|
-
}]).catch((err) => {
|
|
382
|
-
if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
|
|
383
|
-
this.info("Thanks for trying out Arkstack.");
|
|
384
|
-
process.exit(0);
|
|
385
|
-
}
|
|
386
|
-
return err;
|
|
387
|
-
});
|
|
388
|
-
let { location } = await inquirer.default.prompt([{
|
|
389
|
-
type: "input",
|
|
390
|
-
name: "location",
|
|
391
|
-
message: "Installation location relative to the current dir:",
|
|
392
|
-
default: __h3ravel_support.Str.slugify(options.name ?? appName ?? (0, node_path.basename)(process.cwd()), "-"),
|
|
393
|
-
when: () => !pathName
|
|
394
|
-
}]).catch((err) => {
|
|
395
|
-
if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
|
|
396
|
-
this.info("Thanks for trying out Arkstack.");
|
|
397
|
-
process.exit(0);
|
|
398
|
-
}
|
|
399
|
-
return err;
|
|
400
|
-
});
|
|
401
|
-
/**
|
|
402
|
-
* Find selected template kit
|
|
403
|
-
*/
|
|
404
|
-
const kit = templates.find((e) => e.alias === template);
|
|
405
|
-
let { install, token, pre } = await inquirer.default.prompt([
|
|
406
|
-
{
|
|
407
|
-
type: "confirm",
|
|
408
|
-
name: "pre",
|
|
409
|
-
message: `An alpha version of the ${kit.name.replace(/\s*template$/i, "").trim()} template is available. Would you like to use it instead?`,
|
|
410
|
-
default: false,
|
|
411
|
-
when: () => kit.prereleaseSource && !options.pre
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
type: "input",
|
|
415
|
-
name: "token",
|
|
416
|
-
message: "Authentication token:",
|
|
417
|
-
when: () => options.kit && !options.token
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
type: "confirm",
|
|
421
|
-
name: "install",
|
|
422
|
-
message: "Would you like to install node_modules right away?:",
|
|
423
|
-
default: true,
|
|
424
|
-
when: () => !options.install
|
|
425
|
-
}
|
|
426
|
-
]).catch((err) => {
|
|
427
|
-
if (err instanceof __inquirer_core.AbortPromptError || err instanceof __inquirer_core.ExitPromptError) {
|
|
428
|
-
this.info("Thanks for trying out Arkstack.");
|
|
429
|
-
process.exit(0);
|
|
430
|
-
}
|
|
431
|
-
return err;
|
|
432
|
-
});
|
|
433
|
-
pre = options.pre ?? pre;
|
|
434
|
-
token = options.token ?? token;
|
|
435
|
-
appName = options.name ?? appName;
|
|
436
|
-
install = options.install ?? install;
|
|
437
|
-
template = options.kit ?? template;
|
|
438
|
-
location = pathName ?? location;
|
|
439
|
-
description = options.description ?? description;
|
|
440
|
-
/**
|
|
441
|
-
* Validate selected kit
|
|
442
|
-
*/
|
|
443
|
-
if (kit && !kit.source) {
|
|
444
|
-
this.error(`ERROR: The ${kit.name} kit is not currently available`);
|
|
445
|
-
process.exit(1);
|
|
446
|
-
}
|
|
447
|
-
const kitName = (kit.baseAlias ?? kit.alias).replace(/-lean$/i, "");
|
|
448
|
-
const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
|
|
449
|
-
const actions = new actions_default((0, node_path.join)(process.cwd(), location), appName, description);
|
|
450
|
-
const spinner = this.spinner("Loading Template...").start();
|
|
451
|
-
const result = await actions.download(source, install, token, options.overwrite);
|
|
452
|
-
if (result.dir && kitName) {
|
|
453
|
-
await cleanDirectoryExcept(result.dir, kitName);
|
|
454
|
-
await hoistDirectoryContents(result.dir, (0, node_path.join)(result.dir, kitName));
|
|
455
|
-
}
|
|
456
|
-
if (kit.lean) {
|
|
457
|
-
spinner.info(__h3ravel_shared.Logger.parse([["Applying lean profile...", "green"]], "", false)).start();
|
|
458
|
-
await actions.makeLeanProfile(kitName);
|
|
459
|
-
}
|
|
460
|
-
spinner.info(__h3ravel_shared.Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
|
|
461
|
-
await actions.cleanup(kitName);
|
|
462
|
-
spinner.info(__h3ravel_shared.Logger.parse([["Initializing Project...", "green"]], "", false)).start();
|
|
463
|
-
await actions.copyExampleEnv();
|
|
464
|
-
await actions.complete(install);
|
|
465
|
-
spinner.succeed(__h3ravel_shared.Logger.parse([["Project initialization complete!", "green"]], "", false));
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region src/run.ts
|
|
471
|
-
var Application = class {};
|
|
472
|
-
__h3ravel_musket.Kernel.init(new Application(), { rootCommand: CreateArkstackCommand });
|
|
473
|
-
|
|
474
|
-
//#endregion
|
|
475
|
-
//# 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 Runtime Template',\n alias: 'express',\n hint: 'An Arkstack application running on Express',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'Express Lean Runtime Template',\n alias: 'express-lean',\n hint: 'A minimal Arkstack application running on Express',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'express',\n },\n {\n name: 'H3 Runtime Template',\n alias: 'h3',\n hint: 'An Arkstack application running on H3',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'H3 Lean Runtime Template',\n alias: 'h3-lean',\n hint: 'A minimal Arkstack application running on H3',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'h3',\n },\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.4.3',\n}\n\nexport const depsList: Record<string, string> = {\n '@arkstack/http': '^0.4.3',\n '@arkstack/view': '^0.4.3',\n '@arkstack/auth': '^0.4.3',\n '@arkstack/common': '^0.4.3',\n '@arkstack/console': '^0.4.3',\n '@arkstack/contract': '^0.4.3',\n '@arkstack/driver-h3': '^0.4.3',\n '@arkstack/filesystem': '^0.4.3',\n '@arkstack/driver-express': '^0.4.3',\n '@arkstack/notifications': '^0.4.3',\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?: Runtime template.}\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 runtime template:',\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 Arkstack.')\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 Arkstack.')\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 Arkstack.')\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*template$/i, '').trim()} template 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 Arkstack.')\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":";;;;;;;;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AO,yBAAU,OAAO,KAAK,QAAQ,CAAC;;AAGrE,MAAI,IAAI,MAAM;AACZ,WAAQ,KAAKC,wBAAO,MAAM,CAAC,CACzB,4BACA,QACD,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AACvB,SAAM,QAAQ,gBAAgB,QAAQ;;AAGxC,UAAQ,KAAKA,wBAAO,MAAM,CAAC,CAAC,kBAAkB,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AAE5E,QAAM,QAAQ,QAAQ,QAAQ;AAE9B,UAAQ,KAAKA,wBAAO,MAAM,CAAC,CAAC,2BAA2B,QAAQ,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,OAAO;AAErF,QAAM,QAAQ,gBAAgB;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,441 +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 Runtime Template",
|
|
33
|
-
alias: "express",
|
|
34
|
-
hint: "An Arkstack application running on Express",
|
|
35
|
-
source: "github:arkstack-hq/arkstack"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "Express Lean Runtime Template",
|
|
39
|
-
alias: "express-lean",
|
|
40
|
-
hint: "A minimal Arkstack application running on Express",
|
|
41
|
-
source: "github:arkstack-hq/arkstack",
|
|
42
|
-
lean: true,
|
|
43
|
-
baseAlias: "express"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: "H3 Runtime Template",
|
|
47
|
-
alias: "h3",
|
|
48
|
-
hint: "An Arkstack application running on H3",
|
|
49
|
-
source: "github:arkstack-hq/arkstack"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: "H3 Lean Runtime Template",
|
|
53
|
-
alias: "h3-lean",
|
|
54
|
-
hint: "A minimal Arkstack application running on H3",
|
|
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.4.3" };
|
|
93
|
-
const depsList = {
|
|
94
|
-
"@arkstack/http": "^0.4.3",
|
|
95
|
-
"@arkstack/view": "^0.4.3",
|
|
96
|
-
"@arkstack/auth": "^0.4.3",
|
|
97
|
-
"@arkstack/common": "^0.4.3",
|
|
98
|
-
"@arkstack/console": "^0.4.3",
|
|
99
|
-
"@arkstack/contract": "^0.4.3",
|
|
100
|
-
"@arkstack/driver-h3": "^0.4.3",
|
|
101
|
-
"@arkstack/filesystem": "^0.4.3",
|
|
102
|
-
"@arkstack/driver-express": "^0.4.3",
|
|
103
|
-
"@arkstack/notifications": "^0.4.3"
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/actions.ts
|
|
108
|
-
var actions_default = class {
|
|
109
|
-
skipInstallation;
|
|
110
|
-
constructor(location, appName, description) {
|
|
111
|
-
this.location = location;
|
|
112
|
-
this.appName = appName;
|
|
113
|
-
this.description = description;
|
|
114
|
-
if (!this.location) this.location = join(process.cwd(), ".temp");
|
|
115
|
-
}
|
|
116
|
-
async pm() {
|
|
117
|
-
return await detectPackageManager() ?? "npm";
|
|
118
|
-
}
|
|
119
|
-
async runCmd(npx = false) {
|
|
120
|
-
if (npx) return "npx";
|
|
121
|
-
const pm = await this.pm();
|
|
122
|
-
return pm === "npm" ? "npm run" : pm;
|
|
123
|
-
}
|
|
124
|
-
async download(template, install = false, auth, overwrite = false) {
|
|
125
|
-
if (this.location?.includes(".temp") || overwrite && existsSync(this.location)) await rm(this.location, {
|
|
126
|
-
force: true,
|
|
127
|
-
recursive: true
|
|
128
|
-
});
|
|
129
|
-
else if (existsSync(this.location)) {
|
|
130
|
-
if ((await readdir(this.location ?? "./"))?.length > 0) {
|
|
131
|
-
console.log("\n");
|
|
132
|
-
Logger.parse([
|
|
133
|
-
[" ERROR ", "bgRed"],
|
|
134
|
-
[this.location, ["gray", "italic"]],
|
|
135
|
-
["is not empty.", "white"]
|
|
136
|
-
], " ");
|
|
137
|
-
console.log("");
|
|
138
|
-
process.exit(0);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
this.skipInstallation = !install;
|
|
142
|
-
this.removeLockFile();
|
|
143
|
-
return await downloadTemplate(template, {
|
|
144
|
-
dir: this.location,
|
|
145
|
-
auth,
|
|
146
|
-
provider: "github",
|
|
147
|
-
registry: await this.pm(),
|
|
148
|
-
forceClean: false
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Installs the project dependencies using the detected package manager.
|
|
153
|
-
* If a specific package name is provided, it will install that package
|
|
154
|
-
* instead of all dependencies.
|
|
155
|
-
*
|
|
156
|
-
* @param name
|
|
157
|
-
* @param args
|
|
158
|
-
* @returns
|
|
159
|
-
*/
|
|
160
|
-
async installPackage(name, args = []) {
|
|
161
|
-
const bcmd = await Resolver.getPakageInstallCommand() + (name ? ` ${name}` : "");
|
|
162
|
-
const cmd = bcmd.split(" ")[0];
|
|
163
|
-
if (bcmd.includes(" ")) args.unshift(...bcmd.split(" ").slice(1));
|
|
164
|
-
const child = spawnSync(cmd, args, {
|
|
165
|
-
cwd: process.cwd(),
|
|
166
|
-
stdio: "ignore"
|
|
167
|
-
});
|
|
168
|
-
if (child.error) return child.status;
|
|
169
|
-
return 0;
|
|
170
|
-
}
|
|
171
|
-
async complete(install = false) {
|
|
172
|
-
let installed = false;
|
|
173
|
-
if (install) installed = await this.installPackage() === 0;
|
|
174
|
-
console.log("");
|
|
175
|
-
const installPath = "./" + relative(process.cwd(), this.location);
|
|
176
|
-
try {
|
|
177
|
-
chdir(path.join(process.cwd(), installPath));
|
|
178
|
-
} catch {}
|
|
179
|
-
Logger.success("Your Arkstack project has been created successfully");
|
|
180
|
-
Logger.parse([
|
|
181
|
-
["cd", "cyan"],
|
|
182
|
-
[installPath, "yellow"],
|
|
183
|
-
installPath === process.cwd() ? ["✔", "green"] : ["", "green"]
|
|
184
|
-
], " ");
|
|
185
|
-
if (!installed) Logger.parse([[await Resolver.getPakageInstallCommand(), "cyan"]]);
|
|
186
|
-
Logger.parse([[await this.runCmd(), "cyan"], ["dev", "yellow"]], " ");
|
|
187
|
-
Logger.parse([["Open", "cyan"], ["http://localhost:3000", "yellow"]]);
|
|
188
|
-
console.log("");
|
|
189
|
-
Logger.parse([["Have any questions", "white"]]);
|
|
190
|
-
Logger.parse([["Checkout our other projects -", "white"], ["https://toneflix.net/open-source", "yellow"]]);
|
|
191
|
-
}
|
|
192
|
-
async cleanup(kit) {
|
|
193
|
-
const pkgPath = join(this.location, "package.json");
|
|
194
|
-
const pkg = await readFile(pkgPath, "utf-8").then(JSON.parse);
|
|
195
|
-
delete pkg.packageManager;
|
|
196
|
-
delete pkg.scripts.predev;
|
|
197
|
-
delete pkg.scripts.prebuild;
|
|
198
|
-
delete pkg.scripts.precmd;
|
|
199
|
-
delete pkg.scripts.cmd;
|
|
200
|
-
pkg.scripts.dev = "ark dev";
|
|
201
|
-
pkg.scripts.build = "ark build";
|
|
202
|
-
pkg.scripts.postinstall = "prepare";
|
|
203
|
-
pkg.name = Str.slugify(this.appName ?? basename(this.location).replace(".", ""), "-");
|
|
204
|
-
if (this.description) pkg.description = this.description;
|
|
205
|
-
for (const [name, version] of Object.entries(depsList)) {
|
|
206
|
-
if (name.includes("@arkstack/driver")) continue;
|
|
207
|
-
pkg.dependencies[name] = version;
|
|
208
|
-
}
|
|
209
|
-
pkg.dependencies["@arkstack/driver-" + kit] = depsList["@arkstack/driver-" + kit];
|
|
210
|
-
await Promise.allSettled([
|
|
211
|
-
writeFile(pkgPath, JSON.stringify(pkg, null, 2)),
|
|
212
|
-
this.removeLockFile(),
|
|
213
|
-
rm(join(this.location, "pnpm-workspace.yaml"), { force: true }),
|
|
214
|
-
rm(join(this.location, ".github"), {
|
|
215
|
-
force: true,
|
|
216
|
-
recursive: true
|
|
217
|
-
})
|
|
218
|
-
]);
|
|
219
|
-
}
|
|
220
|
-
async removeLockFile() {
|
|
221
|
-
if (!this.skipInstallation) return;
|
|
222
|
-
await Promise.allSettled([
|
|
223
|
-
unlink(join(this.location, "package-lock.json")),
|
|
224
|
-
unlink(join(this.location, "yarn.lock")),
|
|
225
|
-
unlink(join(this.location, "pnpm-lock.yaml"))
|
|
226
|
-
]);
|
|
227
|
-
}
|
|
228
|
-
async getBanner() {
|
|
229
|
-
return await readFile(join(process.cwd(), "./logo.txt"), "utf-8");
|
|
230
|
-
}
|
|
231
|
-
async copyExampleEnv() {
|
|
232
|
-
const envPath = join(this.location, ".env");
|
|
233
|
-
const exampleEnvPath = join(this.location, ".env.example");
|
|
234
|
-
if (existsSync(exampleEnvPath)) await copyFile(exampleEnvPath, envPath);
|
|
235
|
-
}
|
|
236
|
-
async makeLeanProfile(_kit) {
|
|
237
|
-
await Promise.allSettled(filesToRemove.map((file) => rm(join(this.location, file), {
|
|
238
|
-
force: true,
|
|
239
|
-
recursive: true
|
|
240
|
-
})));
|
|
241
|
-
const pkgPath = join(this.location, "package.json");
|
|
242
|
-
if (existsSync(pkgPath)) {
|
|
243
|
-
const pkg = await readFile(pkgPath, "utf-8").then(JSON.parse);
|
|
244
|
-
for (const dep of fullDependencies) {
|
|
245
|
-
delete pkg.dependencies?.[dep];
|
|
246
|
-
delete pkg.devDependencies?.[dep];
|
|
247
|
-
}
|
|
248
|
-
for (const [name, version] of Object.entries(leanDependencies)) pkg.dependencies[name] = version;
|
|
249
|
-
await writeFile(pkgPath, JSON.stringify(pkg, null, 2));
|
|
250
|
-
}
|
|
251
|
-
for (const file of [
|
|
252
|
-
"src/core/app.ts",
|
|
253
|
-
"src/core/router.ts",
|
|
254
|
-
"src/core/bootstrap.ts"
|
|
255
|
-
]) {
|
|
256
|
-
const filePath = join(this.location, file);
|
|
257
|
-
if (!existsSync(filePath)) continue;
|
|
258
|
-
let content = await readFile(filePath, "utf-8");
|
|
259
|
-
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 ");
|
|
260
|
-
await writeFile(filePath, content, "utf-8");
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
//#endregion
|
|
266
|
-
//#region src/utils.ts
|
|
267
|
-
/**
|
|
268
|
-
* Removes all files in dirPath except the one specified by keepFileName
|
|
269
|
-
*
|
|
270
|
-
* @param dirPath
|
|
271
|
-
* @param keepFileName
|
|
272
|
-
*/
|
|
273
|
-
async function cleanDirectoryExcept(dirPath, keepFileName) {
|
|
274
|
-
const files = await readdir(dirPath);
|
|
275
|
-
for (const file of files) {
|
|
276
|
-
if (file === keepFileName) continue;
|
|
277
|
-
await rm(path.join(dirPath, file), {
|
|
278
|
-
recursive: true,
|
|
279
|
-
force: true
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Moves all files from dirPath to parent directory and removes dirPath
|
|
285
|
-
*
|
|
286
|
-
* @param dirPath
|
|
287
|
-
* @param parent
|
|
288
|
-
*/
|
|
289
|
-
async function hoistDirectoryContents(parent, dirPath) {
|
|
290
|
-
const source = path.isAbsolute(dirPath) ? dirPath : path.join(process.cwd(), dirPath);
|
|
291
|
-
const targetParent = path.isAbsolute(parent) ? parent : path.join(process.cwd(), parent);
|
|
292
|
-
if (!source.startsWith(targetParent)) throw new Error("Source must be inside the parent directory");
|
|
293
|
-
const entries = await readdir(source);
|
|
294
|
-
for (const entry of entries) await rename(path.join(source, entry), path.join(targetParent, entry));
|
|
295
|
-
await rm(source, { recursive: true });
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/Commands/CreateArkstackCommand.ts
|
|
300
|
-
var CreateArkstackCommand = class extends Command {
|
|
301
|
-
signature = `create-arkstack
|
|
302
|
-
{location?: The location where this project should be created relative to the current dir.}
|
|
303
|
-
{--n|name?: The name of your project.}
|
|
304
|
-
{--i|install: Install node_modules right away}
|
|
305
|
-
{--t|token?: Kit repo authentication token.}
|
|
306
|
-
{--d|desc?: Project Description.}
|
|
307
|
-
{--k|kit?: Runtime template.}
|
|
308
|
-
{--p|pre: Download prerelease version if available.}
|
|
309
|
-
{--o|overwrite: Overwrite the installation directory if it is not empty.}
|
|
310
|
-
`;
|
|
311
|
-
description = "Display a personalized greeting.";
|
|
312
|
-
async handle() {
|
|
313
|
-
const options = this.options();
|
|
314
|
-
const pathName = this.argument("location");
|
|
315
|
-
console.log(altLogo, "font-family: monospace");
|
|
316
|
-
let { template } = await inquirer.prompt([{
|
|
317
|
-
type: "list",
|
|
318
|
-
name: "template",
|
|
319
|
-
message: "Choose runtime template:",
|
|
320
|
-
choices: templates.map((e) => ({
|
|
321
|
-
name: e.name,
|
|
322
|
-
value: e.alias,
|
|
323
|
-
disabled: !e.source ? "(Unavailable at this time)" : false
|
|
324
|
-
})),
|
|
325
|
-
default: "full",
|
|
326
|
-
when: () => !options.kit
|
|
327
|
-
}]).catch((err) => {
|
|
328
|
-
if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
|
|
329
|
-
this.info("Thanks for trying out Arkstack.");
|
|
330
|
-
process.exit(0);
|
|
331
|
-
}
|
|
332
|
-
return err;
|
|
333
|
-
});
|
|
334
|
-
let { appName, description } = await inquirer.prompt([{
|
|
335
|
-
type: "input",
|
|
336
|
-
name: "appName",
|
|
337
|
-
message: "What is the name of your project:",
|
|
338
|
-
default: `arkstack-${template}`,
|
|
339
|
-
when: () => !options.name
|
|
340
|
-
}, {
|
|
341
|
-
type: "input",
|
|
342
|
-
name: "description",
|
|
343
|
-
message: "Project Description:",
|
|
344
|
-
default: `Simple ${Str.of(template).ucfirst()}.js project created with Arkstack.`,
|
|
345
|
-
when: () => !options.desc
|
|
346
|
-
}]).catch((err) => {
|
|
347
|
-
if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
|
|
348
|
-
this.info("Thanks for trying out Arkstack.");
|
|
349
|
-
process.exit(0);
|
|
350
|
-
}
|
|
351
|
-
return err;
|
|
352
|
-
});
|
|
353
|
-
let { location } = await inquirer.prompt([{
|
|
354
|
-
type: "input",
|
|
355
|
-
name: "location",
|
|
356
|
-
message: "Installation location relative to the current dir:",
|
|
357
|
-
default: Str.slugify(options.name ?? appName ?? basename(process.cwd()), "-"),
|
|
358
|
-
when: () => !pathName
|
|
359
|
-
}]).catch((err) => {
|
|
360
|
-
if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
|
|
361
|
-
this.info("Thanks for trying out Arkstack.");
|
|
362
|
-
process.exit(0);
|
|
363
|
-
}
|
|
364
|
-
return err;
|
|
365
|
-
});
|
|
366
|
-
/**
|
|
367
|
-
* Find selected template kit
|
|
368
|
-
*/
|
|
369
|
-
const kit = templates.find((e) => e.alias === template);
|
|
370
|
-
let { install, token, pre } = await inquirer.prompt([
|
|
371
|
-
{
|
|
372
|
-
type: "confirm",
|
|
373
|
-
name: "pre",
|
|
374
|
-
message: `An alpha version of the ${kit.name.replace(/\s*template$/i, "").trim()} template is available. Would you like to use it instead?`,
|
|
375
|
-
default: false,
|
|
376
|
-
when: () => kit.prereleaseSource && !options.pre
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
type: "input",
|
|
380
|
-
name: "token",
|
|
381
|
-
message: "Authentication token:",
|
|
382
|
-
when: () => options.kit && !options.token
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
type: "confirm",
|
|
386
|
-
name: "install",
|
|
387
|
-
message: "Would you like to install node_modules right away?:",
|
|
388
|
-
default: true,
|
|
389
|
-
when: () => !options.install
|
|
390
|
-
}
|
|
391
|
-
]).catch((err) => {
|
|
392
|
-
if (err instanceof AbortPromptError || err instanceof ExitPromptError) {
|
|
393
|
-
this.info("Thanks for trying out Arkstack.");
|
|
394
|
-
process.exit(0);
|
|
395
|
-
}
|
|
396
|
-
return err;
|
|
397
|
-
});
|
|
398
|
-
pre = options.pre ?? pre;
|
|
399
|
-
token = options.token ?? token;
|
|
400
|
-
appName = options.name ?? appName;
|
|
401
|
-
install = options.install ?? install;
|
|
402
|
-
template = options.kit ?? template;
|
|
403
|
-
location = pathName ?? location;
|
|
404
|
-
description = options.description ?? description;
|
|
405
|
-
/**
|
|
406
|
-
* Validate selected kit
|
|
407
|
-
*/
|
|
408
|
-
if (kit && !kit.source) {
|
|
409
|
-
this.error(`ERROR: The ${kit.name} kit is not currently available`);
|
|
410
|
-
process.exit(1);
|
|
411
|
-
}
|
|
412
|
-
const kitName = (kit.baseAlias ?? kit.alias).replace(/-lean$/i, "");
|
|
413
|
-
const source = pre && kit.prereleaseSource ? kit.prereleaseSource : kit.source;
|
|
414
|
-
const actions = new actions_default(join(process.cwd(), location), appName, description);
|
|
415
|
-
const spinner = this.spinner("Loading Template...").start();
|
|
416
|
-
const result = await actions.download(source, install, token, options.overwrite);
|
|
417
|
-
if (result.dir && kitName) {
|
|
418
|
-
await cleanDirectoryExcept(result.dir, kitName);
|
|
419
|
-
await hoistDirectoryContents(result.dir, join(result.dir, kitName));
|
|
420
|
-
}
|
|
421
|
-
if (kit.lean) {
|
|
422
|
-
spinner.info(Logger.parse([["Applying lean profile...", "green"]], "", false)).start();
|
|
423
|
-
await actions.makeLeanProfile(kitName);
|
|
424
|
-
}
|
|
425
|
-
spinner.info(Logger.parse([["Cleaning Up...", "green"]], "", false)).start();
|
|
426
|
-
await actions.cleanup(kitName);
|
|
427
|
-
spinner.info(Logger.parse([["Initializing Project...", "green"]], "", false)).start();
|
|
428
|
-
await actions.copyExampleEnv();
|
|
429
|
-
await actions.complete(install);
|
|
430
|
-
spinner.succeed(Logger.parse([["Project initialization complete!", "green"]], "", false));
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
|
|
434
|
-
//#endregion
|
|
435
|
-
//#region src/run.ts
|
|
436
|
-
var Application = class {};
|
|
437
|
-
Kernel.init(new Application(), { rootCommand: CreateArkstackCommand });
|
|
438
|
-
|
|
439
|
-
//#endregion
|
|
440
|
-
export { };
|
|
441
|
-
//# 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 Runtime Template',\n alias: 'express',\n hint: 'An Arkstack application running on Express',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'Express Lean Runtime Template',\n alias: 'express-lean',\n hint: 'A minimal Arkstack application running on Express',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'express',\n },\n {\n name: 'H3 Runtime Template',\n alias: 'h3',\n hint: 'An Arkstack application running on H3',\n source: 'github:arkstack-hq/arkstack',\n },\n {\n name: 'H3 Lean Runtime Template',\n alias: 'h3-lean',\n hint: 'A minimal Arkstack application running on H3',\n source: 'github:arkstack-hq/arkstack',\n lean: true,\n baseAlias: 'h3',\n },\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.4.3',\n}\n\nexport const depsList: Record<string, string> = {\n '@arkstack/http': '^0.4.3',\n '@arkstack/view': '^0.4.3',\n '@arkstack/auth': '^0.4.3',\n '@arkstack/common': '^0.4.3',\n '@arkstack/console': '^0.4.3',\n '@arkstack/contract': '^0.4.3',\n '@arkstack/driver-h3': '^0.4.3',\n '@arkstack/filesystem': '^0.4.3',\n '@arkstack/driver-express': '^0.4.3',\n '@arkstack/notifications': '^0.4.3',\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?: Runtime template.}\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 runtime template:',\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 Arkstack.')\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 Arkstack.')\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 Arkstack.')\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*template$/i, '').trim()} template 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 Arkstack.')\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;CACA;CACH;AAED,MAAa,mBAAmB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACH;AAED,MAAa,mBAAmB,EAC5B,0BAA0B,UAC7B;AAED,MAAaC,WAAmC;CAC5C,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAClB,oBAAoB;CACpB,qBAAqB;CACrB,sBAAsB;CACtB,uBAAuB;CACvB,wBAAwB;CACxB,4BAA4B;CAC5B,2BAA2B;CAC9B;;;;AChCD,4BAAqB;CACnB;CAEA,YACE,AAAQC,UACR,AAAQC,SACR,AAAQC,aACR;EAHQ;EACA;EACA;AAER,MAAI,CAAC,KAAK,SACR,MAAK,WAAW,KAAK,QAAQ,KAAK,EAAE,QAAQ;;CAIhD,MAAM,KAAM;AACV,SAAQ,MAAM,sBAAsB,IAAK;;CAG3C,MAAM,OAAQ,MAAe,OAAO;AAClC,MAAI,IAAK,QAAO;EAEhB,MAAM,KAAK,MAAM,KAAK,IAAI;AAE1B,SAAO,OAAO,QAAQ,YAAY;;CAGpC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