backend-templates 1.0.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/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/templates.json +4 -0
- package/dist/utils/component.d.ts +2 -0
- package/dist/utils/component.d.ts.map +1 -0
- package/dist/utils/component.js +2 -0
- package/dist/utils/component.js.map +1 -0
- package/dist/utils/template.d.ts +2 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/dist/utils/template.js +47 -0
- package/dist/utils/template.js.map +1 -0
- package/package.json +44 -0
- package/readme.md +1 -0
- package/src/templates/templates.json +4 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { importTemplate } from "./utils/template.js";
|
|
4
|
+
const program = new Command();
|
|
5
|
+
program.version("0.0.1").description("CLI for downloading templates")
|
|
6
|
+
.argument("<template>", "Select a backend template")
|
|
7
|
+
.action(importTemplate);
|
|
8
|
+
program.parse(process.argv);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,+BAA+B,CAAC;KAChE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAC;KACnD,MAAM,CAAC,cAAc,CAAC,CACtB;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/utils/component.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/utils/component.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,GAAU,UAAU,MAAM,kBAgDpD,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { execSync } from "child_process";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import templates from "../templates/templates.json" with { type: "json" };
|
|
8
|
+
import { simpleGit } from "simple-git";
|
|
9
|
+
import { chdir } from "process";
|
|
10
|
+
export const importTemplate = async (template) => {
|
|
11
|
+
const Projectpath = path.join(process.cwd(), template);
|
|
12
|
+
if (fs.existsSync(Projectpath)) {
|
|
13
|
+
console.log(chalk.red(`Project with name ${template} already exists`));
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
const answers = await inquirer.prompt([
|
|
17
|
+
{
|
|
18
|
+
type: "list",
|
|
19
|
+
name: "template",
|
|
20
|
+
message: "Select the template you want to start with...",
|
|
21
|
+
choices: [
|
|
22
|
+
{ name: "Backend-Setup", value: "backend" },
|
|
23
|
+
{ name: "Authentication-Setup", value: "auth" }
|
|
24
|
+
],
|
|
25
|
+
default: "backend"
|
|
26
|
+
},
|
|
27
|
+
]);
|
|
28
|
+
const url = answers.template === "backend" ? templates.backend : templates.auth;
|
|
29
|
+
fs.mkdirSync(Projectpath);
|
|
30
|
+
const spinner = ora(`Downloading ${answers.template} template`).start();
|
|
31
|
+
const git = simpleGit();
|
|
32
|
+
try {
|
|
33
|
+
await git.clone(url, Projectpath);
|
|
34
|
+
spinner.succeed(`Downloaded ${answers.template} template`);
|
|
35
|
+
chdir(Projectpath);
|
|
36
|
+
spinner.start('Installing dependencies...');
|
|
37
|
+
execSync("npm install", { stdio: "inherit" });
|
|
38
|
+
spinner.succeed('Installed dependencies');
|
|
39
|
+
console.log(chalk.green(`Project ${template} created successfully`));
|
|
40
|
+
console.log(chalk.green(`Navigate to ${Projectpath} to start working on your project`));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.log(chalk.red(`Error creating project ${template}`));
|
|
44
|
+
console.log(error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,6BAA6B,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,QAAgB,EAAE,EAAE;IACrD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAA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,CAAC,CAAC;QAE1C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,QAAQ,uBAAuB,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,WAAW,mCAAmC,CAAC,CAAC,CAAC;IAG5F,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AAIL,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "backend-templates",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "CLI for downloading backend templates",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"src/templates"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"dev": "tsc --watch",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"server": "npm run build && npm run start"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"create-backend-template": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@types/commander": "^2.12.0",
|
|
26
|
+
"@types/nodemon": "^1.19.6",
|
|
27
|
+
"chalk": "^5.6.2",
|
|
28
|
+
"commander": "^14.0.3",
|
|
29
|
+
"express": "^5.2.1",
|
|
30
|
+
"fs-extra": "^11.3.3",
|
|
31
|
+
"inquirer": "^13.3.0",
|
|
32
|
+
"nodemon": "^3.1.14",
|
|
33
|
+
"ora": "^9.3.0",
|
|
34
|
+
"simple-git": "^3.32.3"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/express": "^5.0.6",
|
|
38
|
+
"@types/fs-extra": "^11.0.4",
|
|
39
|
+
"@types/inquirer": "^9.0.9",
|
|
40
|
+
"@types/node": "^25.3.3",
|
|
41
|
+
"ts-node": "^10.9.2",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Template-Component-project
|