create-arkos 0.0.7 → 0.0.9

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/dist/index.js CHANGED
@@ -20,6 +20,7 @@ const child_process_1 = require("child_process");
20
20
  const project_config_inquirer_1 = __importDefault(require("./utils/project-config-inquirer"));
21
21
  const template_compiler_1 = __importDefault(require("./utils/template-compiler"));
22
22
  const handlebars_1 = __importDefault(require("handlebars"));
23
+ const shared_1 = require("@arkos/shared");
23
24
  handlebars_1.default.registerHelper("eq", (a, b) => a === b);
24
25
  handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
25
26
  function main() {
@@ -31,9 +32,10 @@ function main() {
31
32
  const templatesDir = path_1.default.join(__dirname, `../templates/basic`);
32
33
  yield template_compiler_1.default.compile(templatesDir, config);
33
34
  process.chdir(projectPath);
35
+ const packageManager = (0, shared_1.detectPackageManagerFromUserAgent)();
34
36
  console.info("\nInstalling dependencies...");
35
- console.info("\nUsing npm.\n");
36
- (0, child_process_1.execSync)("npm install", { stdio: "inherit" });
37
+ console.info(`\nUsing ${packageManager}.\n`);
38
+ (0, child_process_1.execSync)(`${packageManager} install`, { stdio: "inherit" });
37
39
  console.info(`
38
40
  ${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project created successfully!
39
41
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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;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,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEpD,SAAe,IAAI;;QACjB,MAAM,MAAM,GAAG,MAAM,iCAAqB,CAAC,GAAG,EAAE,CAAC;QAEjD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QAEvC,YAAE,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE/C,OAAO,CAAC,IAAI,CACV,oBAAoB,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,eAAe,eAAK,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CAC9G,CAAC;QAEF,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAChE,MAAM,2BAAgB,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAErD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE3B,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE/B,IAAA,wBAAQ,EAAC,aAAa,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAE9C,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;;;;KAIvC,CAAC,CAAC;IACP,CAAC;CAAA;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\";\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 in ${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 console.info(\"\\nInstalling dependencies...\");\n console.info(\"\\nUsing npm.\\n\");\n\n execSync(\"npm install\", { 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. npx prisma generate\n 5. npm run dev\n `);\n}\n\nmain().catch(console.error);\n"]}
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,0CAAkE;AAElE,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,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAEpD,SAAe,IAAI;;QACjB,MAAM,MAAM,GAAG,MAAM,iCAAqB,CAAC,GAAG,EAAE,CAAC;QAEjD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QAEvC,YAAE,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE/C,OAAO,CAAC,IAAI,CACV,oBAAoB,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,eAAe,eAAK,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CAC9G,CAAC;QAEF,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAChE,MAAM,2BAAgB,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAErD,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE3B,MAAM,cAAc,GAAG,IAAA,0CAAiC,GAAE,CAAC;QAE3D,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,WAAW,cAAc,KAAK,CAAC,CAAC;QAE7C,IAAA,wBAAQ,EAAC,GAAG,cAAc,UAAU,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAE5D,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;;;;KAIvC,CAAC,CAAC;IACP,CAAC;CAAA;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 { detectPackageManagerFromUserAgent } from \"@arkos/shared\";\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 in ${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\n console.info(\"\\nInstalling dependencies...\");\n console.info(`\\nUsing ${packageManager}.\\n`);\n\n execSync(`${packageManager} install`, { 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. npx prisma generate\n 5. npm run dev\n `);\n}\n\nmain().catch(console.error);\n"]}
@@ -79,9 +79,20 @@ class ProjectConfigInquirer {
79
79
  ],
80
80
  },
81
81
  ]);
82
+ let idDatabaseType;
83
+ switch (prismaProvider) {
84
+ case "mongodb":
85
+ idDatabaseType = '@id @default(auto()) @map("_id") @db.ObjectId';
86
+ break;
87
+ case "sqlite":
88
+ idDatabaseType = "@id @default(cuid())";
89
+ break;
90
+ default:
91
+ idDatabaseType = "@id @default(uuid())";
92
+ }
82
93
  this.config.prisma = {
83
94
  provider: prismaProvider,
84
- idDatabaseType: "@id @default(uuid())",
95
+ idDatabaseType: idDatabaseType,
85
96
  };
86
97
  });
87
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,wDAAgC;AAChC,kDAA0B;AA0B1B,MAAM,qBAAqB;IAGzB;QACE,IAAI,CAAC,MAAM,GAAG,EA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wBAC7D,aAAa;qBACd,CAAC;iBACH;aACF;QACH,CAAC;KAAA;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAE1D,kBAAe,qBAAqB,CAAC","sourcesContent":["import path from \"path\";\nimport inquirer from \"inquirer\";\nimport chalk from \"chalk\";\n\nexport interface ProjectConfig {\n projectName: string;\n typescript: boolean;\n validation: {\n type?: \"zod\" | \"class-validator\";\n };\n authentication: {\n type?: \"static\" | \"dynamic\" | \"define later\";\n usernameField?: \"username\" | \"email\" | \"custom\";\n multipleRoles: boolean;\n };\n prisma: {\n provider:\n | \"postgresql\"\n | \"mysql\"\n | \"sqlite\"\n | \"sqlserver\"\n | \"cockroachdb\"\n | \"mongodb\";\n idDatabaseType: string;\n };\n projectPath: string;\n}\n\nclass ProjectConfigInquirer {\n private config: ProjectConfig;\n\n constructor() {\n this.config = {} as ProjectConfig;\n }\n\n async run() {\n await this.promptProjectName();\n await this.promptTypescript();\n await this.promptPrismaProvider();\n await this.promptValidation();\n await this.promptAuthentication();\n\n const projectPath = path.resolve(process.cwd(), this.config.projectName);\n this.config.projectPath = projectPath;\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process.argv[2];\n\n if (!projectName) {\n const result = await inquirer.prompt([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is the name of your project?\",\n default: \"my-arkos-project\",\n validate: (input) =>\n input.length > 0 ? true : \"Project name cannot be empty\",\n },\n ]);\n projectName = result.projectName;\n }\n this.config.projectName = projectName;\n }\n\n private async promptTypescript() {\n const { typescript } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"typescript\",\n message: `Would you like to use ${chalk.cyan(\"TypeScript\")}?`,\n default: false,\n },\n ]);\n this.config.typescript = typescript;\n }\n\n private async promptPrismaProvider() {\n const { prismaProvider } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"prismaProvider\",\n message: `What db provider will be used for ${chalk.cyan(\"Prisma\")}?`,\n choices: [\n \"postgresql\",\n \"mongodb\",\n \"mysql\",\n \"sqlite\",\n \"sqlserver\",\n \"cockroachdb\",\n ],\n },\n ]);\n this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType: \"@id @default(uuid())\",\n };\n }\n\n private async promptValidation() {\n const { useValidation } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useValidation\",\n message: `Would you like to set up ${chalk.cyan(\"Validation\")}?`,\n default: true,\n },\n ]);\n\n if (useValidation) {\n const { validationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: \"Choose validation library:\",\n choices: [\"zod\", \"class-validator\"],\n },\n ]);\n this.config.validation = {\n type: validationType,\n };\n }\n }\n\n private async promptAuthentication() {\n const { useAuthentication } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useAuthentication\",\n message: `Would you like to set up ${chalk.cyan(\"Authentication\")}?`,\n default: true,\n },\n ]);\n\n if (useAuthentication) {\n const { authenticationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"authenticationType\",\n message: \"Choose authentication type:\",\n choices: [\"static\", \"dynamic\", \"define later\"],\n },\n ]);\n\n if (authenticationType !== \"define later\") {\n const { multipleRoles } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"multipleRoles\",\n default: true,\n message: `Would you like to use authentication with ${chalk.cyan(\"Multiple Roles\")}?`,\n },\n ]);\n\n const { usernameField } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"usernameField\",\n message: \"Choose default username field for login:\",\n choices: [\"email\", \"username\", \"define later\"],\n },\n ]);\n\n this.config.authentication = {\n type: authenticationType,\n usernameField:\n usernameField === \"define later\" ? \"custom\" : usernameField,\n multipleRoles,\n };\n }\n }\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
1
+ {"version":3,"file":"project-config-inquirer.js","sourceRoot":"","sources":["../../src/utils/project-config-inquirer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,wDAAg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,MAAM;4BACZ,IAAI,EAAE,eAAe;4BACrB,OAAO,EAAE,0CAA0C;4BACnD,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,cAAc,CAAC;yBAC/C;qBACF,CAAC,CAAC;oBAEH,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG;wBAC3B,IAAI,EAAE,kBAAkB;wBACxB,aAAa,EACX,aAAa,KAAK,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa;wBAC7D,aAAa;qBACd,CAAC;iBACH;aACF;QACH,CAAC;KAAA;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC;AAE1D,kBAAe,qBAAqB,CAAC","sourcesContent":["import path from \"path\";\nimport inquirer from \"inquirer\";\nimport chalk from \"chalk\";\n\nexport interface ProjectConfig {\n projectName: string;\n typescript: boolean;\n validation: {\n type?: \"zod\" | \"class-validator\";\n };\n authentication: {\n type?: \"static\" | \"dynamic\" | \"define later\";\n usernameField?: \"username\" | \"email\" | \"custom\";\n multipleRoles: boolean;\n };\n prisma: {\n provider:\n | \"postgresql\"\n | \"mysql\"\n | \"sqlite\"\n | \"sqlserver\"\n | \"cockroachdb\"\n | \"mongodb\";\n idDatabaseType: string;\n };\n projectPath: string;\n}\n\nclass ProjectConfigInquirer {\n private config: ProjectConfig;\n\n constructor() {\n this.config = {} as ProjectConfig;\n }\n\n async run() {\n await this.promptProjectName();\n await this.promptTypescript();\n await this.promptPrismaProvider();\n await this.promptValidation();\n await this.promptAuthentication();\n\n const projectPath = path.resolve(process.cwd(), this.config.projectName);\n this.config.projectPath = projectPath;\n\n return this.config;\n }\n\n private async promptProjectName() {\n let projectName = process.argv[2];\n\n if (!projectName) {\n const result = await inquirer.prompt([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is the name of your project?\",\n default: \"my-arkos-project\",\n validate: (input) =>\n input.length > 0 ? true : \"Project name cannot be empty\",\n },\n ]);\n projectName = result.projectName;\n }\n this.config.projectName = projectName;\n }\n\n private async promptTypescript() {\n const { typescript } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"typescript\",\n message: `Would you like to use ${chalk.cyan(\"TypeScript\")}?`,\n default: false,\n },\n ]);\n this.config.typescript = typescript;\n }\n\n private async promptPrismaProvider() {\n const { prismaProvider } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"prismaProvider\",\n message: `What db provider will be used for ${chalk.cyan(\"Prisma\")}?`,\n choices: [\n \"postgresql\",\n \"mongodb\",\n \"mysql\",\n \"sqlite\",\n \"sqlserver\",\n \"cockroachdb\",\n ],\n },\n ]);\n\n // Set the correct idDatabaseType based on provider\n let idDatabaseType: string;\n\n switch (prismaProvider) {\n case \"mongodb\":\n idDatabaseType = '@id @default(auto()) @map(\"_id\") @db.ObjectId';\n break;\n case \"sqlite\":\n idDatabaseType = \"@id @default(cuid())\";\n break;\n default:\n idDatabaseType = \"@id @default(uuid())\";\n }\n\n this.config.prisma = {\n provider: prismaProvider,\n idDatabaseType: idDatabaseType,\n };\n }\n\n private async promptValidation() {\n const { useValidation } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useValidation\",\n message: `Would you like to set up ${chalk.cyan(\"Validation\")}?`,\n default: true,\n },\n ]);\n\n if (useValidation) {\n const { validationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"validationType\",\n message: \"Choose validation library:\",\n choices: [\"zod\", \"class-validator\"],\n },\n ]);\n this.config.validation = {\n type: validationType,\n };\n }\n }\n\n private async promptAuthentication() {\n const { useAuthentication } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"useAuthentication\",\n message: `Would you like to set up ${chalk.cyan(\"Authentication\")}?`,\n default: true,\n },\n ]);\n\n if (useAuthentication) {\n const { authenticationType } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"authenticationType\",\n message: \"Choose authentication type:\",\n choices: [\"static\", \"dynamic\", \"define later\"],\n },\n ]);\n\n if (authenticationType !== \"define later\") {\n const { multipleRoles } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"multipleRoles\",\n default: true,\n message: `Would you like to use authentication with ${chalk.cyan(\"Multiple Roles\")}?`,\n },\n ]);\n\n const { usernameField } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"usernameField\",\n message: \"Choose default username field for login:\",\n choices: [\"email\", \"username\", \"define later\"],\n },\n ]);\n\n this.config.authentication = {\n type: authenticationType,\n usernameField:\n usernameField === \"define later\" ? \"custom\" : usernameField,\n multipleRoles,\n };\n }\n }\n }\n}\n\nconst projectConfigInquirer = new ProjectConfigInquirer();\n\nexport default projectConfigInquirer;\n"]}
@@ -24,12 +24,12 @@ class TemplateCompiler {
24
24
  filesToBeSkipped(config) {
25
25
  var _a;
26
26
  const files = [];
27
- if (config.authentication.type !== "define later") {
27
+ if (config.authentication.type !== "define later")
28
28
  files.concat(["user.prisma.hbs"]);
29
- }
30
- if (((_a = config.authentication) === null || _a === void 0 ? void 0 : _a.type) === "static") {
29
+ if (((_a = config.authentication) === null || _a === void 0 ? void 0 : _a.type) === "static")
31
30
  files.concat(["auth-role.prisma.hbs", "auth-permission.prisma.hbs"]);
32
- }
31
+ if (!config.typescript)
32
+ files.concat(["tsconfig.json.hbs"]);
33
33
  return files;
34
34
  }
35
35
  compile(templatesDir, config) {
@@ -1 +1 @@
1
- {"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gDAAwB;AACxB,4CAAoB;AACpB,4DAAoC;AAEpC,MAAM,gBAAgB;IACd,iCAAiC,CAAC,MAAqB;;YAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;QACjC,CAAC;KAAA;IAED,gBAAgB,CAAC,MAAqB;;QACpC,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,KAAK,cAAc,EAAE;YACjD,KAAK,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,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C,MAAM,OAAO,GAAG,QAAQ,iCAAM,MAAM,KAAE,kBAAkB,IAAG,CAAC;wBAC5D,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;wBAEzC,IAAI,UAAU,GAAG,cAAI,CAAC,IAAI,CACxB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACjC,CAAC;wBACF,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;4BACjC,UAAU,GAAG,cAAI,CAAC,IAAI,CACpB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;wBAEJ,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;wBAC5D,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;qBACvC;gBACH,CAAC,CAAA,CAAC,CAAC;YACL,CAAC;YAED,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACjC,CAAC;KAAA;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEhD,kBAAe,gBAAgB,CAAC","sourcesContent":["import { ProjectConfig } from \"./project-config-inquirer\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport handlebars from \"handlebars\";\n\nclass TemplateCompiler {\n async canCompileAuthenticationTemplates(config: ProjectConfig) {\n return !!config.authentication;\n }\n\n filesToBeSkipped(config: ProjectConfig) {\n const files: string[] = [];\n\n if (config.authentication.type !== \"define later\") {\n files.concat([\"user.prisma.hbs\"]);\n }\n\n if (config.authentication?.type === \"static\") {\n files.concat([\"auth-role.prisma.hbs\", \"auth-permission.prisma.hbs\"]);\n }\n return files;\n }\n /**\n * Compiles the Arkos.js project with handlebars templates\n *\n * @param templatesDir {string} templates location\n * @param config {ProjectConfig} the project configuration\n * @returns void\n * */\n async compile(templatesDir: string, config: ProjectConfig) {\n const outputDir = config.projectPath;\n const isTypescript = config.typescript;\n const filesToBeSkipped = this.filesToBeSkipped(config);\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n if (filesToBeSkipped.includes(dirent.name)) return;\n\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 let arkosLatestVersion = \"1.0.0\";\n\n const content = template({ ...config, arkosLatestVersion });\n const ext = isTypescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(\n outputDir,\n relativePath.replace(\".hbs\", \"\")\n );\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}\n\nconst templateCompiler = new TemplateCompiler();\n\nexport default templateCompiler;\n"]}
1
+ {"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gDAAwB;AACxB,4CAAoB;AACpB,4DAAoC;AAEpC,MAAM,gBAAgB;IACd,iCAAiC,CAAC,MAAqB;;YAC3D,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;QACjC,CAAC;KAAA;IAED,gBAAgB,CAAC,MAAqB;;QACpC,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,IAAI,MAAM,CAAC,cAAc,CAAC,IAAI,KAAK,cAAc;YAC/C,KAAK,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC,CA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Y,EAAE,MAAM,CAAC,CACtC,CAAC;wBAEF,IAAI,kBAAkB,GAAG,OAAO,CAAC;wBAEjC,MAAM,OAAO,GAAG,QAAQ,iCAAM,MAAM,KAAE,kBAAkB,IAAG,CAAC;wBAC5D,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;wBAEzC,IAAI,UAAU,GAAG,cAAI,CAAC,IAAI,CACxB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACjC,CAAC;wBACF,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;4BACjC,UAAU,GAAG,cAAI,CAAC,IAAI,CACpB,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CACrC,CAAC;wBAEJ,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;wBAC5D,YAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;qBACvC;gBACH,CAAC,CAAA,CAAC,CAAC;YACL,CAAC;YAED,gBAAgB,CAAC,YAAY,CAAC,CAAC;QACjC,CAAC;KAAA;CACF;AAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEhD,kBAAe,gBAAgB,CAAC","sourcesContent":["import { ProjectConfig } from \"./project-config-inquirer\";\nimport path from \"path\";\nimport fs from \"fs\";\nimport handlebars from \"handlebars\";\n\nclass TemplateCompiler {\n async canCompileAuthenticationTemplates(config: ProjectConfig) {\n return !!config.authentication;\n }\n\n filesToBeSkipped(config: ProjectConfig) {\n const files: string[] = [];\n\n if (config.authentication.type !== \"define later\")\n files.concat([\"user.prisma.hbs\"]);\n\n if (config.authentication?.type === \"static\")\n files.concat([\"auth-role.prisma.hbs\", \"auth-permission.prisma.hbs\"]);\n\n if (!config.typescript) files.concat([\"tsconfig.json.hbs\"]);\n\n return files;\n }\n /**\n * Compiles the Arkos.js project with handlebars templates\n *\n * @param templatesDir {string} templates location\n * @param config {ProjectConfig} the project configuration\n * @returns void\n * */\n async compile(templatesDir: string, config: ProjectConfig) {\n const outputDir = config.projectPath;\n const isTypescript = config.typescript;\n const filesToBeSkipped = this.filesToBeSkipped(config);\n\n function processTemplates(dir: string, relativeDir = \"\") {\n fs.readdirSync(dir, { withFileTypes: true }).forEach(async (dirent) => {\n if (filesToBeSkipped.includes(dirent.name)) return;\n\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 let arkosLatestVersion = \"1.0.0\";\n\n const content = template({ ...config, arkosLatestVersion });\n const ext = isTypescript ? \".ts\" : \".js\";\n\n let outputPath = path.join(\n outputDir,\n relativePath.replace(\".hbs\", \"\")\n );\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}\n\nconst templateCompiler = new TemplateCompiler();\n\nexport default templateCompiler;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-arkos",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "CLI for creating Arkos.js projects, see docs at www.arkosjs.com/docs",
5
5
  "bin": {
6
6
  "create-arkos": "./dist/index.js"
@@ -9,6 +9,7 @@
9
9
  "build": "tsc",
10
10
  "dev": "ts-node src/index.ts",
11
11
  "test:hbs": "ts-node src/utils/helpers/hbs-tester.helpers.ts",
12
+ "prebuild": "npm run build -w @arkos/shared && npm run build -w arkos",
12
13
  "prepublishOnly": "pnpm run build"
13
14
  },
14
15
  "author": "Uanela Como",
@@ -20,7 +21,7 @@
20
21
  "bugs": {
21
22
  "url": "https://github.com/uanela/arkos/issues"
22
23
  },
23
- "homepage": "https://www.arkosjs.com",
24
+ "homepage": "https://www.arkosjs.com/docs/api-reference/create-arkos-cli",
24
25
  "files": ["dist", "templates", "cli.js", "README.md"],
25
26
  "devDependencies": {
26
27
  "@types/inquirer": "^8.1.0",
@@ -32,6 +33,7 @@
32
33
  "@clack/prompts": "^0.11.0",
33
34
  "@inquirer/prompts": "^7.6.0",
34
35
  "inquirer": "^8.2.6",
36
+ "@arkos/shared": "workspace:*",
35
37
  "chalk": "^5.4.1",
36
38
  "handlebars": "^4.7.8"
37
39
  }
@@ -1 +1,2 @@
1
1
  DATABASE_URL=your-db-url-here
2
+ PORT=8000
@@ -1,4 +1,4 @@
1
- {{#if TYPECSRIPT_ENABLED}}
1
+ {{#if typescript}}
2
2
  import { ArkosConfig } from 'arkos'
3
3
 
4
4
  const config: ArkosConfig = {}
@@ -16,11 +16,11 @@ model AuthPermission {
16
16
  {{else}}
17
17
  action AuthPermissionAction @default(View)
18
18
  {{/if}}
19
- roleId String
19
+ roleId String {{#if (eq prisma.provider "mongodb")}}@db.ObjectId{{/if}}
20
20
  role AuthRole @relation(fields: [roleId], references: [id])
21
21
  description String?
22
22
  createdAt DateTime @default(now())
23
- updatedAt DateTime @default(now())
23
+ updatedAt DateTime {{#if (eq prisma.provider "mongodb")}}@updatedAt{{else}}@default(now()){{/if}}
24
24
 
25
25
  @@unique([resource, action, roleId])
26
26
  }
@@ -5,6 +5,6 @@ model AuthRole {
5
5
  permissions AuthPermission[]
6
6
  users UserRole[]
7
7
  createdAt DateTime @default(now())
8
- updatedAt DateTime @default(now())
8
+ updatedAt DateTime {{#if (eq prisma.provider "mongodb")}}@updatedAt{{else}}@default(now()){{/if}}
9
9
  }
10
10
 
@@ -1,5 +1,5 @@
1
1
  generator client {
2
- provider = "prisma-client-js"
2
+ provider = "prisma-client-js"
3
3
  }
4
4
 
5
5
  datasource db {
@@ -0,0 +1,19 @@
1
+ {{#if (eq authentication.type "dynamic")}}
2
+ model UserRole {
3
+ id String {{prisma.idDatabaseType}}
4
+ {{#if authentication.multipleRoles}}
5
+ userId String
6
+ {{else}}
7
+ userId String @unique
8
+ {{/if}}
9
+ user User @relation(fields: [userId], references: [id])
10
+ roleId String {{#if (eq prisma.provider "mongodb")}}@db.ObjectId{{/if}}
11
+ role AuthRole @relation(fields: [roleId], references: [id])
12
+ createdAt DateTime @default(now())
13
+ updatedAt DateTime {{#if (eq prisma.provider "mongodb")}}@updatedAt{{else}}@default(now()){{/if}}
14
+ {{#if authentication.multipleRoles}}
15
+
16
+ @@unique([userId, roleId])
17
+ {{/if}}
18
+ }
19
+ {{/if}}
@@ -26,29 +26,10 @@ model User {
26
26
  {{/if}}
27
27
  {{/if}}
28
28
  createdAt DateTime @default(now())
29
- updatedAt DateTime @default(now())
30
- // other fields for your application
31
- }
32
-
33
- {{#if (eq authentication.type "dynamic")}}
34
- model UserRole {
35
- id String {{prisma.idDatabaseType}}
36
- {{#if authentication.multipleRoles}}
37
- userId String
38
- {{else}}
39
- userId String @unique
40
- {{/if}}
41
- user User @relation(fields: [userId], references: [id])
42
- roleId String
43
- role AuthRole @relation(fields: [roleId], references: [id])
44
- createdAt DateTime @default(now())
45
- updatedAt DateTime @default(now())
46
- {{#if authentication.multipleRoles}}
29
+ updatedAt DateTime {{#if (eq prisma.provider "mongodb")}}@updatedAt{{else}}@default(now()){{/if}}
47
30
 
48
- @@unique([userId, roleId])
49
- {{/if}}
31
+ // other fields for your application
50
32
  }
51
- {{/if}}
52
33
 
53
34
  {{#if (eq authentication.type "static")}}
54
35
  {{#if (eq prisma.provider "sqlite")}}
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "Node16",
5
+ "moduleResolution": "node16",
6
+ "rootDir": "./src",
7
+ "strict": true,
8
+ "sourceMap": true,
9
+ "inlineSources": true,
10
+ "removeComments": true,
11
+ "esModuleInterop": true,
12
+ "experimentalDecorators": true,
13
+ "emitDecoratorMetadata": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ },
16
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
17
+ "exclude": ["node_modules", ".build", "src/**/__tests__/**", "src/**/*.test.ts"]
18
+ }