create-arkos 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const chalk_1 = __importDefault(require("chalk"));
|
|
19
19
|
const child_process_1 = require("child_process");
|
|
@@ -26,7 +26,7 @@ function main() {
|
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const config = yield project_config_inquirer_1.default.run();
|
|
28
28
|
const projectPath = config.projectPath;
|
|
29
|
-
|
|
29
|
+
fs_1.default.mkdirSync(projectPath, { recursive: true });
|
|
30
30
|
console.info(`\nCreating a new ${chalk_1.default.bold(chalk_1.default.cyan("Arkos.js"))} project in ${chalk_1.default.green(`./${config.projectName}`)}`);
|
|
31
31
|
const templatesDir = path_1.default.resolve(`./src/utils/templates/basic`);
|
|
32
32
|
yield template_compiler_1.default.compile(templatesDir, config);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,
|
|
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,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";\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.resolve(`./src/utils/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"]}
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
18
18
|
handlebars_1.default.registerHelper("eq", (a, b) => a === b);
|
|
@@ -38,7 +38,7 @@ handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
|
|
|
38
38
|
projectPath: outputDir,
|
|
39
39
|
};
|
|
40
40
|
function processTemplates(dir, relativeDir = "") {
|
|
41
|
-
|
|
41
|
+
fs_1.default.readdirSync(dir, { withFileTypes: true }).forEach((dirent) => __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
const fullPath = path_1.default.join(dir, dirent.name);
|
|
43
43
|
const relativePath = path_1.default.join(relativeDir, dirent.name);
|
|
44
44
|
if (dirent.isDirectory()) {
|
|
@@ -46,14 +46,14 @@ handlebars_1.default.registerHelper("neq", (a, b) => a !== b);
|
|
|
46
46
|
}
|
|
47
47
|
else if (dirent.name.endsWith(".hbs")) {
|
|
48
48
|
const templatePath = fullPath;
|
|
49
|
-
const template = handlebars_1.default.compile(
|
|
49
|
+
const template = handlebars_1.default.compile(fs_1.default.readFileSync(templatePath, "utf8"));
|
|
50
50
|
const content = template(config);
|
|
51
51
|
const ext = config.typescript ? ".ts" : ".js";
|
|
52
52
|
let outputPath = path_1.default.join(outputDir, relativePath.replace(".hbs", ""));
|
|
53
53
|
if (dirent.name.endsWith(".ts.hbs"))
|
|
54
54
|
outputPath = path_1.default.join(outputDir, relativePath.replace(".ts.hbs", ext));
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
fs_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true });
|
|
56
|
+
fs_1.default.writeFileSync(outputPath, content);
|
|
57
57
|
}
|
|
58
58
|
}));
|
|
59
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hbs-tester.helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers/hbs-tester.helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,
|
|
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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,CAAC,YAAY,CAAC,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,CAAA,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 },\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"]}
|
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
18
18
|
class TemplateCompiler {
|
|
19
19
|
canCompileAuthenticationTemplates(config) {
|
|
@@ -38,7 +38,7 @@ class TemplateCompiler {
|
|
|
38
38
|
const isTypescript = config.typescript;
|
|
39
39
|
const filesToBeSkipped = this.filesToBeSkipped(config);
|
|
40
40
|
function processTemplates(dir, relativeDir = "") {
|
|
41
|
-
|
|
41
|
+
fs_1.default.readdirSync(dir, { withFileTypes: true }).forEach((dirent) => __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
if (filesToBeSkipped.includes(dirent.name))
|
|
43
43
|
return;
|
|
44
44
|
const fullPath = path_1.default.join(dir, dirent.name);
|
|
@@ -48,15 +48,15 @@ class TemplateCompiler {
|
|
|
48
48
|
}
|
|
49
49
|
else if (dirent.name.endsWith(".hbs")) {
|
|
50
50
|
const templatePath = fullPath;
|
|
51
|
-
const template = handlebars_1.default.compile(
|
|
51
|
+
const template = handlebars_1.default.compile(fs_1.default.readFileSync(templatePath, "utf8"));
|
|
52
52
|
let arkosLatestVersion = "1.0.0";
|
|
53
53
|
const content = template(Object.assign(Object.assign({}, config), { arkosLatestVersion }));
|
|
54
54
|
const ext = isTypescript ? ".ts" : ".js";
|
|
55
55
|
let outputPath = path_1.default.join(outputDir, relativePath.replace(".hbs", ""));
|
|
56
56
|
if (dirent.name.endsWith(".ts.hbs"))
|
|
57
57
|
outputPath = path_1.default.join(outputDir, relativePath.replace(".ts.hbs", ext));
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
fs_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true });
|
|
59
|
+
fs_1.default.writeFileSync(outputPath, content);
|
|
60
60
|
}
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gDAAwB;AACxB,
|
|
1
|
+
{"version":3,"file":"template-compiler.js","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gDAAwB;AACxB,4CAAoB;AACpB,4DAAoC;AAGpC,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,CAAC,CAAC;SACnC;QAED,IAAI,CAAA,MAAA,MAAM,CA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AAkB,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// import { getLatestVersion } from \"./helpers\";\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-arkos",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
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"
|
|
@@ -23,10 +23,8 @@
|
|
|
23
23
|
"homepage": "https://www.arkosjs.com",
|
|
24
24
|
"files": ["dist", "cli.js", "README.md"],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/fs-extra": "^11.0.4",
|
|
27
26
|
"@types/inquirer": "^8.1.0",
|
|
28
27
|
"@types/node": "^16.18.126",
|
|
29
|
-
"fs-extra": "^10.1.0",
|
|
30
28
|
"inquirer": "^8.2.6",
|
|
31
29
|
"ts-node": "^10.9.2",
|
|
32
30
|
"typescript": "^4.9.5"
|