create-arkos 0.0.26-beta → 0.0.28-beta
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 +6 -7
- package/dist/index.js +21 -32
- package/dist/index.js.map +1 -1
- package/dist/utils/helpers/hbs-tester.helpers.js +2 -11
- package/dist/utils/helpers/hbs-tester.helpers.js.map +1 -1
- package/dist/utils/helpers/index.js +6 -17
- package/dist/utils/helpers/index.js.map +1 -1
- package/dist/utils/project-config-inquirer.js +161 -169
- package/dist/utils/project-config-inquirer.js.map +1 -1
- package/dist/utils/template-compiler.js +71 -74
- package/dist/utils/template-compiler.js.map +1 -1
- package/package.json +3 -1
- package/templates/basic/prisma/schema/user.prisma.hbs +2 -0
- package/templates/basic/src/modules/auth/auth.query.ts.hbs +28 -1
- package/templates/basic/src/modules/auth-permission/auth-permission.auth.ts.hbs +25 -0
- package/templates/basic/src/modules/auth-permission/auth-permission.query.ts.hbs +30 -0
- package/templates/basic/src/modules/auth-permission/auth-permission.service.ts.hbs +12 -0
- package/templates/basic/src/modules/auth-role/auth-role.auth.ts.hbs +25 -0
- package/templates/basic/src/modules/auth-role/auth-role.query.ts.hbs +30 -0
- package/templates/basic/src/modules/auth-role/auth-role.service.ts.hbs +12 -0
- package/templates/basic/src/modules/file-upload/file-upload.auth.ts.hbs +25 -0
- package/templates/basic/src/modules/user/user.auth.ts.hbs +25 -0
- package/templates/basic/src/modules/user/user.query.ts.hbs +42 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The official CLI tool to quickly scaffold new Arkos.js API projects with interac
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
`create-arkos` is the scaffolding tool for the Arkos.js framework (v1.2.
|
|
7
|
+
`create-arkos` is the scaffolding tool for the Arkos.js framework (v1.2.13-beta). It provides an interactive setup experience to generate a complete, production-ready RESTful API project with automatic CRUD operations, authentication, validation, and more - all built on top of Express.js and Prisma.
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
@@ -29,7 +29,7 @@ pnpm create arkos
|
|
|
29
29
|
The CLI will guide you through an interactive setup process:
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
> create-arkos@1.0
|
|
32
|
+
> create-arkos@1.0
|
|
33
33
|
|
|
34
34
|
? What is the name of your project? my-arkos-project
|
|
35
35
|
? Would you like to use TypeScript? Yes
|
|
@@ -109,7 +109,6 @@ my-arkos-project/
|
|
|
109
109
|
|
|
110
110
|
```bash
|
|
111
111
|
npx prisma db push
|
|
112
|
-
npx prisma generate
|
|
113
112
|
```
|
|
114
113
|
|
|
115
114
|
4. **Start development**:
|
|
@@ -138,7 +137,7 @@ DATABASE_URL="mongodb://localhost:27017/mydb"
|
|
|
138
137
|
DATABASE_URL="mysql://username:password@localhost:3306/mydb"
|
|
139
138
|
|
|
140
139
|
# SQLite
|
|
141
|
-
DATABASE_URL="file
|
|
140
|
+
DATABASE_URL="file:../../file.db"
|
|
142
141
|
```
|
|
143
142
|
|
|
144
143
|
## Authentication Setup
|
|
@@ -179,7 +178,7 @@ arkos generate component-name -m model-name # generate components like controlle
|
|
|
179
178
|
|
|
180
179
|
## Version
|
|
181
180
|
|
|
182
|
-
|
|
181
|
+
Arkos.js version used on this `create-arkos` cli: v1.2.13-beta
|
|
183
182
|
|
|
184
183
|
## License
|
|
185
184
|
|
|
@@ -187,6 +186,6 @@ MIT License
|
|
|
187
186
|
|
|
188
187
|
---
|
|
189
188
|
|
|
190
|
-
**Built with ❤️ by the Arkos.js
|
|
189
|
+
**Built with ❤️ by Uanela Como and the Arkos.js Contribuitors**
|
|
191
190
|
|
|
192
|
-
_From the Greek "ἀρχή" (Arkhē) - your foundation for backend development_
|
|
191
|
+
_From the Greek "ἀρχή" (Arkhē) - your foundation for Express and Prisma backend development_
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
5
|
};
|
|
@@ -24,28 +15,27 @@ const helpers_1 = require("./utils/helpers");
|
|
|
24
15
|
const npm_helpers_1 = require("./utils/helpers/npm.helpers");
|
|
25
16
|
handlebars_1.default.registerHelper("eq", (a, b) => a === b);
|
|
26
17
|
handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
|
|
27
|
-
function main() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.info(`
|
|
18
|
+
async function main() {
|
|
19
|
+
const config = await project_config_inquirer_1.default.run();
|
|
20
|
+
const projectPath = config.projectPath;
|
|
21
|
+
fs_1.default.mkdirSync(projectPath, { recursive: true });
|
|
22
|
+
console.info(`\nCreating a new ${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project under ${chalk_1.default.green(`./${config.projectName}`)}`);
|
|
23
|
+
const templatesDir = path_1.default.join(__dirname, `../templates/basic`);
|
|
24
|
+
await template_compiler_1.default.compile(templatesDir, config);
|
|
25
|
+
process.chdir(projectPath);
|
|
26
|
+
const packageManager = (0, npm_helpers_1.detectPackageManagerFromUserAgent)();
|
|
27
|
+
const { dependencies, devDependencies } = (0, helpers_1.getProcjetPackageJsonDependecies)(projectPath);
|
|
28
|
+
console.info(chalk_1.default.bold("\ndependencies:"));
|
|
29
|
+
dependencies.forEach((dependency) => console.info(`- ${dependency}`));
|
|
30
|
+
console.info(chalk_1.default.bold("\ndevDependencies:"));
|
|
31
|
+
devDependencies.forEach((devDependency) => console.info(`- ${devDependency}`));
|
|
32
|
+
console.info(chalk_1.default.bold("\nInstalling dependencies..."));
|
|
33
|
+
console.info(`Using ${packageManager}.\n`);
|
|
34
|
+
(0, child_process_1.execSync)(`${packageManager} install`, { stdio: "inherit" });
|
|
35
|
+
process.chdir(projectPath);
|
|
36
|
+
console.info("\nRunning npx prisma generate...");
|
|
37
|
+
(0, child_process_1.execSync)(`npx prisma generate`, { stdio: "inherit" });
|
|
38
|
+
console.info(`
|
|
49
39
|
${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project created successfully!
|
|
50
40
|
|
|
51
41
|
Next steps:
|
|
@@ -54,7 +44,6 @@ function main() {
|
|
|
54
44
|
3. npx prisma db push
|
|
55
45
|
4. ${packageManager} run dev
|
|
56
46
|
`);
|
|
57
|
-
});
|
|
58
47
|
}
|
|
59
48
|
main().catch(console.error);
|
|
60
49
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,iDAAyC;AACzC,8FAAoE;AACpE,kFAAyD;AACzD,4DAAoC;AACpC,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I,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/C,eAAe,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE,CACxC,OAAO,CAAC,IAAI,CAAC,KAAK,aAAa,EAAE,CAAC,CACnC,CAAC;IAEF,OAAO,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,SAAS,cAAc,KAAK,CAAC,CAAC;IAE3C,IAAA,wBAAQ,EAAC,GAAG,cAAc,UAAU,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAE5D,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACjD,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEtD,OAAO,CAAC,IAAI,CAAC;IACX,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;;UAG5B,MAAM,CAAC,WAAW;kBACV,eAAK,CAAC,IAAI,CAAC,cAAc,CAAC;;OAErC,cAAc;KAChB,CAAC,CAAC;AACP,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport fs from \"fs\";\nimport path from \"path\";\nimport chalk from \"chalk\";\nimport { execSync } from \"child_process\";\nimport projectConfigInquirer from \"./utils/project-config-inquirer\";\nimport templateCompiler from \"./utils/template-compiler\";\nimport Handlebars from \"handlebars\";\nimport { getProcjetPackageJsonDependecies } from \"./utils/helpers\";\nimport { detectPackageManagerFromUserAgent } from \"./utils/helpers/npm.helpers\";\n\nHandlebars.registerHelper(\"eq\", (a, b) => a === b);\nHandlebars.registerHelper(\"neq\", (a, b) => a !== b);\n\nasync function main() {\n const config = await projectConfigInquirer.run();\n\n const projectPath = config.projectPath;\n\n fs.mkdirSync(projectPath, { recursive: true });\n\n console.info(\n `\\nCreating a new ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project under ${chalk.green(`./${config.projectName}`)}`\n );\n\n const templatesDir = path.join(__dirname, `../templates/basic`);\n await templateCompiler.compile(templatesDir, config);\n\n process.chdir(projectPath);\n\n const packageManager = detectPackageManagerFromUserAgent();\n const { dependencies, devDependencies } =\n getProcjetPackageJsonDependecies(projectPath);\n\n console.info(chalk.bold(\"\\ndependencies:\"));\n dependencies.forEach((dependency) => console.info(`- ${dependency}`));\n\n console.info(chalk.bold(\"\\ndevDependencies:\"));\n devDependencies.forEach((devDependency) =>\n console.info(`- ${devDependency}`)\n );\n\n console.info(chalk.bold(\"\\nInstalling dependencies...\"));\n console.info(`Using ${packageManager}.\\n`);\n\n execSync(`${packageManager} install`, { stdio: \"inherit\" });\n\n process.chdir(projectPath);\n console.info(\"\\nRunning npx prisma generate...\");\n execSync(`npx prisma generate`, { stdio: \"inherit\" });\n\n console.info(`\n ${chalk.bold(chalk.cyan(\"Arkos.js\"))} project created successfully!\n\n Next steps:\n 1. cd ${config.projectName}\n 2. setup your ${chalk.cyan(\"DATABASE_URL\")} under .env\n 3. npx prisma db push\n 4. ${packageManager} run dev\n `);\n}\n\nmain().catch(console.error);\n"]}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -39,7 +30,7 @@ handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
|
|
|
39
30
|
projectPath: outputDir,
|
|
40
31
|
};
|
|
41
32
|
function processTemplates(dir, relativeDir = "") {
|
|
42
|
-
fs_1.default.readdirSync(dir, { withFileTypes: true }).forEach((dirent) =>
|
|
33
|
+
fs_1.default.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {
|
|
43
34
|
const fullPath = path_1.default.join(dir, dirent.name);
|
|
44
35
|
const relativePath = path_1.default.join(relativeDir, dirent.name);
|
|
45
36
|
if (dirent.isDirectory()) {
|
|
@@ -56,7 +47,7 @@ handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
|
|
|
56
47
|
fs_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true });
|
|
57
48
|
fs_1.default.writeFileSync(outputPath, content);
|
|
58
49
|
}
|
|
59
|
-
})
|
|
50
|
+
});
|
|
60
51
|
}
|
|
61
52
|
processTemplates(templatesDir);
|
|
62
53
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hbs-tester.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/hbs-tester.helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hbs-tester.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/hbs-tester.helpers.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,4DAAoC;AAEpC,oBAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACnD,oBAAU,CAAC,cAAc,CAAC,KAAK,EAAE,CA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AAC,YAAY,EAAE,MAAM,CAAC,CACtC,CAAC;gBAEF,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACjC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;gBAE9C,IAAI,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;gBACxE,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;oBACjC,UAAU,GAAG,cAAI,CAAC,IAAI,CACpB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;gBAEJ,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC5D,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;aACvC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACjC,CAAC,CAAC,EAAE,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport handlebars from \"handlebars\";\nimport { ProjectConfig } from \"../project-config-inquirer\";\nhandlebars.registerHelper(\"eq\", (a, b) => a === b);\nhandlebars.registerHelper(\"neq\", (a, b) => a !== b);\n\n(() => {\n const templatesDir = `${process.cwd()}/cache/handlebars/templates`;\n const outputDir = `${process.cwd()}/cache/handlebars/output`;\n const config: ProjectConfig = {\n projectName: \"arkos-project\",\n typescript: true,\n validation: {\n type: \"zod\",\n },\n authentication: {\n type: \"dynamic\",\n usernameField: \"email\",\n multipleRoles: true,\n },\n prisma: {\n provider: \"mongodb\",\n idDatabaseType: \"@db @default(uuid())\",\n defaultDBurl: \"@db @default(uuid())\",\n },\n projectPath: outputDir,\n };\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n const fullPath = path.join(dir, dirent.name);\n const relativePath = path.join(relativeDir, dirent.name);\n\n if (dirent.isDirectory()) {\n processTemplates(fullPath, relativePath);\n } else if (dirent.name.endsWith(\".hbs\")) {\n const templatePath = fullPath;\n const template = handlebars.compile(\n fs.readFileSync(templatePath, \"utf8\")\n );\n\n const content = template(config);\n const ext = config.typescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(outputDir, relativePath.replace(\".hbs\", \"\"));\n if (dirent.name.endsWith(\".ts.hbs\"))\n outputPath = path.join(\n outputDir,\n relativePath.replace(\".ts.hbs\", ext)\n );\n\n fs.mkdirSync(path.dirname(outputPath), { recursive: true });\n fs.writeFileSync(outputPath, content);\n }\n });\n }\n\n processTemplates(templatesDir);\n})();\n"]}
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.getProcjetPackageJsonDependecies = exports.getLatestVersion = void 0;
|
|
16
7
|
const fs_1 = __importDefault(require("fs"));
|
|
17
|
-
function getLatestVersion(packageName) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return data["dist-tags"].latest;
|
|
24
|
-
});
|
|
8
|
+
async function getLatestVersion(packageName) {
|
|
9
|
+
const res = await fetch(`https://registry.npmjs.org/${packageName}`);
|
|
10
|
+
if (!res.ok)
|
|
11
|
+
throw new Error(`Failed to fetch: ${res.status}`);
|
|
12
|
+
const data = await res.json();
|
|
13
|
+
return data["dist-tags"].latest;
|
|
25
14
|
}
|
|
26
15
|
exports.getLatestVersion = getLatestVersion;
|
|
27
16
|
function getProcjetPackageJsonDependecies(projectPath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/helpers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/helpers/index.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEb,KAAK,UAAU,gBAAgB,CAAC,WAAmB;IACxD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,8BAA8B,WAAW,EAAE,CAAC,CAAC;IACrE,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAE/D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;AAClC,CAAC;AAND,4CAMC;AAED,SAAgB,gCAAgC,CAAC,WAAmB;IAIlE,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,GAAG,WAAW,eAAe,EAAE;QAC7D,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,MAAM,WAAW,GAGb,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACxB,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC3D,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IAEjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAC;AAC3C,CAAC;AAhBD,4EAgBC","sourcesContent":["import fs from \"fs\";\n\nexport async function getLatestVersion(packageName: string) {\n const res = await fetch(`https://registry.npmjs.org/${packageName}`);\n if (!res.ok) throw new Error(`Failed to fetch: ${res.status}`);\n\n const data = await res.json();\n return data[\"dist-tags\"].latest;\n}\n\nexport function getProcjetPackageJsonDependecies(projectPath: string): {\n dependencies: string[];\n devDependencies: string[];\n} {\n const content = fs.readFileSync(`${projectPath}/package.json`, {\n encoding: \"utf8\",\n });\n\n const packageJson: {\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n } = JSON.parse(content);\n const dependencies = Object.keys(packageJson.dependencies);\n const devDependencies = Object.keys(packageJson.devDependencies);\n\n return { dependencies, devDependencies };\n}\n"]}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,47 +10,46 @@ class ProjectConfigInquirer {
|
|
|
19
10
|
constructor() {
|
|
20
11
|
this.config = {};
|
|
21
12
|
}
|
|
22
|
-
run() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.config.projectPath =
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
async run() {
|
|
14
|
+
await this.promptProjectName();
|
|
15
|
+
await this.promptTypescript();
|
|
16
|
+
await this.promptPrismaProvider();
|
|
17
|
+
await this.promptValidation();
|
|
18
|
+
await this.promptAuthentication();
|
|
19
|
+
if (this.config.projectName === ".") {
|
|
20
|
+
this.config.projectName = path_1.default.basename(process.cwd());
|
|
21
|
+
this.config.projectPath = path_1.default.resolve(process.cwd());
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
this.config.projectPath = path_1.default.resolve(process.cwd(), this.config.projectName);
|
|
25
|
+
return this.config;
|
|
33
26
|
}
|
|
34
|
-
promptProjectName() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const validation = this.validateProjectName(projectName);
|
|
54
|
-
if (validation !== true) {
|
|
55
|
-
console.error(chalk_1.default.red(`Error: ${validation}`));
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
27
|
+
async promptProjectName() {
|
|
28
|
+
let projectName = process.argv[2];
|
|
29
|
+
if (!projectName) {
|
|
30
|
+
const result = await inquirer_1.default.prompt([
|
|
31
|
+
{
|
|
32
|
+
type: "input",
|
|
33
|
+
name: "projectName",
|
|
34
|
+
message: "What is the name of your project?",
|
|
35
|
+
default: "my-arkos-project",
|
|
36
|
+
validate: this.validateProjectName,
|
|
37
|
+
},
|
|
38
|
+
]);
|
|
39
|
+
projectName = result.projectName;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const validation = this.validateProjectName(projectName);
|
|
43
|
+
if (validation !== true) {
|
|
44
|
+
console.error(chalk_1.default.red(`\nError: ${validation}`));
|
|
45
|
+
process.exit(1);
|
|
58
46
|
}
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
}
|
|
48
|
+
this.config.projectName = projectName;
|
|
61
49
|
}
|
|
62
50
|
validateProjectName(input) {
|
|
51
|
+
if (input === ".")
|
|
52
|
+
return true;
|
|
63
53
|
if (!input || input.length === 0) {
|
|
64
54
|
return "Project name cannot be empty";
|
|
65
55
|
}
|
|
@@ -81,86 +71,83 @@ class ProjectConfigInquirer {
|
|
|
81
71
|
}
|
|
82
72
|
return true;
|
|
83
73
|
}
|
|
84
|
-
promptTypescript() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.config.typescript = typescript;
|
|
95
|
-
});
|
|
74
|
+
async promptTypescript() {
|
|
75
|
+
const { typescript } = await inquirer_1.default.prompt([
|
|
76
|
+
{
|
|
77
|
+
type: "confirm",
|
|
78
|
+
name: "typescript",
|
|
79
|
+
message: `Would you like to use ${chalk_1.default.blue("TypeScript")}?`,
|
|
80
|
+
default: false,
|
|
81
|
+
},
|
|
82
|
+
]);
|
|
83
|
+
this.config.typescript = typescript;
|
|
96
84
|
}
|
|
97
|
-
promptPrismaProvider() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
default
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
};
|
|
150
|
-
});
|
|
85
|
+
async promptPrismaProvider() {
|
|
86
|
+
const { prismaProvider } = await inquirer_1.default.prompt([
|
|
87
|
+
{
|
|
88
|
+
type: "list",
|
|
89
|
+
name: "prismaProvider",
|
|
90
|
+
message: `What db provider will be used for ${chalk_1.default.blue("Prisma")}?`,
|
|
91
|
+
choices: [
|
|
92
|
+
"postgresql",
|
|
93
|
+
"mongodb",
|
|
94
|
+
"mysql",
|
|
95
|
+
"sqlite",
|
|
96
|
+
"sqlserver",
|
|
97
|
+
"cockroachdb",
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
]);
|
|
101
|
+
let idDatabaseType;
|
|
102
|
+
let defaultDBurl;
|
|
103
|
+
switch (prismaProvider) {
|
|
104
|
+
case "mongodb":
|
|
105
|
+
idDatabaseType = '@id @default(auto()) @map("_id") @db.ObjectId';
|
|
106
|
+
defaultDBurl = `mongodb://localhost:27017/${this.config.projectName}`;
|
|
107
|
+
break;
|
|
108
|
+
case "sqlite":
|
|
109
|
+
idDatabaseType = "@id @default(cuid())";
|
|
110
|
+
defaultDBurl = "file:../../file.db";
|
|
111
|
+
break;
|
|
112
|
+
case "mysql":
|
|
113
|
+
idDatabaseType = "@id @default(uuid())";
|
|
114
|
+
defaultDBurl = `mysql://username:password@localhost:3306/${this.config.projectName}`;
|
|
115
|
+
break;
|
|
116
|
+
case "postgresql":
|
|
117
|
+
idDatabaseType = "@id @default(uuid())";
|
|
118
|
+
defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;
|
|
119
|
+
break;
|
|
120
|
+
case "sqlserver":
|
|
121
|
+
idDatabaseType = "@id @default(uuid())";
|
|
122
|
+
defaultDBurl = `sqlserver://localhost:1433;database=${this.config.projectName};username=sa;password=password;encrypt=DANGER_PLAINTEXT`;
|
|
123
|
+
break;
|
|
124
|
+
case "cockroachdb":
|
|
125
|
+
idDatabaseType = "@id @default(uuid())";
|
|
126
|
+
defaultDBurl = `postgresql://username:password@localhost:26257/${this.config.projectName}?sslmode=require`;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
idDatabaseType = "@id @default(uuid())";
|
|
130
|
+
defaultDBurl = `postgresql://username:password@localhost:5432/${this.config.projectName}`;
|
|
131
|
+
}
|
|
132
|
+
this.config.prisma = {
|
|
133
|
+
provider: prismaProvider,
|
|
134
|
+
idDatabaseType: idDatabaseType,
|
|
135
|
+
defaultDBurl: defaultDBurl,
|
|
136
|
+
};
|
|
151
137
|
}
|
|
152
|
-
promptValidation() {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
138
|
+
async promptValidation() {
|
|
139
|
+
const { useValidation } = await inquirer_1.default.prompt([
|
|
140
|
+
{
|
|
141
|
+
type: "confirm",
|
|
142
|
+
name: "useValidation",
|
|
143
|
+
message: `Would you like to set up ${chalk_1.default.blue("Validation")}?`,
|
|
144
|
+
default: true,
|
|
145
|
+
},
|
|
146
|
+
]);
|
|
147
|
+
if (useValidation) {
|
|
148
|
+
let validationTypeResponse = { validationType: "zod" };
|
|
149
|
+
if (this.config.typescript)
|
|
150
|
+
validationTypeResponse = await inquirer_1.default.prompt([
|
|
164
151
|
{
|
|
165
152
|
type: "list",
|
|
166
153
|
name: "validationType",
|
|
@@ -168,62 +155,67 @@ class ProjectConfigInquirer {
|
|
|
168
155
|
choices: ["zod", "class-validator"],
|
|
169
156
|
},
|
|
170
157
|
]);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
};
|
|
158
|
+
else {
|
|
159
|
+
console.info(`Validation library set as ${chalk_1.default.cyan("zod")}, (class-validator is not supported on JavaScript).`);
|
|
174
160
|
}
|
|
175
|
-
|
|
161
|
+
this.config.validation = {
|
|
162
|
+
type: validationTypeResponse.validationType,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
else if (!this.config.typescript) {
|
|
166
|
+
}
|
|
176
167
|
}
|
|
177
|
-
promptAuthentication() {
|
|
178
|
-
|
|
179
|
-
|
|
168
|
+
async promptAuthentication() {
|
|
169
|
+
const { useAuthentication } = await inquirer_1.default.prompt([
|
|
170
|
+
{
|
|
171
|
+
type: "confirm",
|
|
172
|
+
name: "useAuthentication",
|
|
173
|
+
message: `Would you like to set up ${chalk_1.default.blue("Authentication")}?`,
|
|
174
|
+
default: true,
|
|
175
|
+
},
|
|
176
|
+
]);
|
|
177
|
+
if (useAuthentication) {
|
|
178
|
+
const { authenticationType } = await inquirer_1.default.prompt([
|
|
180
179
|
{
|
|
181
|
-
type: "
|
|
182
|
-
name: "
|
|
183
|
-
message:
|
|
184
|
-
|
|
180
|
+
type: "list",
|
|
181
|
+
name: "authenticationType",
|
|
182
|
+
message: "Choose authentication type:",
|
|
183
|
+
choices: ["static", "dynamic", "define later"],
|
|
185
184
|
},
|
|
186
185
|
]);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
186
|
+
const { usernameField } = await inquirer_1.default.prompt([
|
|
187
|
+
{
|
|
188
|
+
type: "list",
|
|
189
|
+
name: "usernameField",
|
|
190
|
+
message: "Choose default username field for login:",
|
|
191
|
+
choices: ["email", "username", "define later"],
|
|
192
|
+
},
|
|
193
|
+
]);
|
|
194
|
+
this.config.authentication = {
|
|
195
|
+
type: authenticationType,
|
|
196
|
+
usernameField: usernameField === "define later" ? "custom" : usernameField,
|
|
197
|
+
multipleRoles: false,
|
|
198
|
+
};
|
|
199
|
+
if (authenticationType !== "define later" ||
|
|
200
|
+
(this.config.prisma.provider !== "sqlite" &&
|
|
201
|
+
authenticationType !== "static")) {
|
|
202
|
+
const { multipleRoles } = await inquirer_1.default.prompt([
|
|
197
203
|
{
|
|
198
|
-
type: "
|
|
199
|
-
name: "
|
|
200
|
-
|
|
201
|
-
|
|
204
|
+
type: "confirm",
|
|
205
|
+
name: "multipleRoles",
|
|
206
|
+
default: true,
|
|
207
|
+
message: `Would you like to use authentication with ${chalk_1.default.blue("Multiple Roles")}?`,
|
|
202
208
|
},
|
|
203
209
|
]);
|
|
204
210
|
this.config.authentication = {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
multipleRoles: false,
|
|
211
|
+
...this.config.authentication,
|
|
212
|
+
multipleRoles,
|
|
208
213
|
};
|
|
209
|
-
if (authenticationType !== "define later" ||
|
|
210
|
-
(this.config.prisma.provider !== "sqlite" &&
|
|
211
|
-
authenticationType !== "static")) {
|
|
212
|
-
const { multipleRoles } = yield inquirer_1.default.prompt([
|
|
213
|
-
{
|
|
214
|
-
type: "confirm",
|
|
215
|
-
name: "multipleRoles",
|
|
216
|
-
default: true,
|
|
217
|
-
message: `Would you like to use authentication with ${chalk_1.default.blue("Multiple Roles")}?`,
|
|
218
|
-
},
|
|
219
|
-
]);
|
|
220
|
-
this.config.authentication = Object.assign(Object.assign({}, this.config.authentication), { multipleRoles });
|
|
221
|
-
}
|
|
222
|
-
else if (this.config.prisma.provider === "sqlite") {
|
|
223
|
-
console.info(`\nSkipping multiple roles option because it is not supported with sqlite prisma provider and static authentication...`);
|
|
224
|
-
}
|
|
225
214
|
}
|
|
226
|
-
|
|
215
|
+
else if (this.config.prisma.provider === "sqlite") {
|
|
216
|
+
console.info(`\nSkipping multiple roles option because it is not supported with sqlite prisma provider and static authentication mode.`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
227
219
|
}
|
|
228
220
|
}
|
|
229
221
|
const projectConfigInquirer = new ProjectConfigInquirer();
|