etranzact-fe-cli 0.0.0
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 +12 -0
- package/dist/index.js +108 -0
- package/dist/index.mjs +113 -0
- package/package.json +42 -0
package/README.md
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
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") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
var import_commander2 = require("commander");
|
|
28
|
+
|
|
29
|
+
// src/commands/scaffold.ts
|
|
30
|
+
var import_commander = require("commander");
|
|
31
|
+
var import_chalk = __toESM(require("chalk"));
|
|
32
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
var import_simple_git = require("simple-git");
|
|
35
|
+
var import_ora = __toESM(require("ora"));
|
|
36
|
+
var import_inquirer = __toESM(require("inquirer"));
|
|
37
|
+
var import_execa = require("execa");
|
|
38
|
+
|
|
39
|
+
// src/utils/constants.ts
|
|
40
|
+
var NEXT_TEMPLATE = "https://github.com/olayinkaa/nextjs-starter-template-etz.git";
|
|
41
|
+
var EXPRESS_TEMPLATE = "https://github.com/MUKE-coder/nodejs-typescript-starter-template.git";
|
|
42
|
+
|
|
43
|
+
// src/utils/resolve-templates.ts
|
|
44
|
+
function resolveTemplate(template) {
|
|
45
|
+
switch (template) {
|
|
46
|
+
case "next":
|
|
47
|
+
return { repoUrl: NEXT_TEMPLATE, label: "Next.js" };
|
|
48
|
+
case "express":
|
|
49
|
+
return { repoUrl: EXPRESS_TEMPLATE, label: "Express" };
|
|
50
|
+
default:
|
|
51
|
+
throw new Error("Invalid template selected.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/commands/scaffold.ts
|
|
56
|
+
var scaffoldCommand = new import_commander.Command("new");
|
|
57
|
+
scaffoldCommand.argument("<project-name>", "name of the project").action(async (projectName) => {
|
|
58
|
+
const projectPath = import_path.default.join(process.cwd(), projectName);
|
|
59
|
+
if (import_fs_extra.default.existsSync(projectPath)) {
|
|
60
|
+
console.error(
|
|
61
|
+
import_chalk.default.red(`Error: Directory ${projectName} already exists.`)
|
|
62
|
+
);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
const answers = await import_inquirer.default.prompt([
|
|
66
|
+
{
|
|
67
|
+
type: "list",
|
|
68
|
+
name: "template",
|
|
69
|
+
message: "Which template would you like to use?",
|
|
70
|
+
choices: [
|
|
71
|
+
{ name: "Nextjs", value: "next" },
|
|
72
|
+
{ name: "Express", value: "express" }
|
|
73
|
+
],
|
|
74
|
+
default: "ts"
|
|
75
|
+
}
|
|
76
|
+
]);
|
|
77
|
+
const { repoUrl } = resolveTemplate(answers.template);
|
|
78
|
+
import_fs_extra.default.mkdirSync(projectPath);
|
|
79
|
+
const spinner = (0, import_ora.default)().start();
|
|
80
|
+
const git = (0, import_simple_git.simpleGit)();
|
|
81
|
+
try {
|
|
82
|
+
spinner.text = `Downloading ${answers.template === "js" ? "JavaScript" : "TypeScript"} template...`;
|
|
83
|
+
await git.clone(repoUrl, projectPath);
|
|
84
|
+
spinner.succeed("Template downloaded successfully!");
|
|
85
|
+
process.chdir(projectPath);
|
|
86
|
+
spinner.start("Installing dependencies...");
|
|
87
|
+
await (0, import_execa.execa)("pnpm", ["install"], {
|
|
88
|
+
stdio: "inherit"
|
|
89
|
+
// shows install logs
|
|
90
|
+
});
|
|
91
|
+
spinner.succeed("Dependencies installed successfully!");
|
|
92
|
+
console.log();
|
|
93
|
+
console.log(import_chalk.default.green(`Project ${projectName} is ready! \u{1F680}`));
|
|
94
|
+
console.log(import_chalk.default.cyan(`cd ${projectName}`));
|
|
95
|
+
console.log(import_chalk.default.cyan(`pnpm dev`));
|
|
96
|
+
} catch (error) {
|
|
97
|
+
spinner.fail("Failed to set up the project.");
|
|
98
|
+
console.error(import_chalk.default.red(error.message));
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
var scaffold_default = scaffoldCommand;
|
|
103
|
+
|
|
104
|
+
// src/index.ts
|
|
105
|
+
var program = new import_commander2.Command();
|
|
106
|
+
program.name("etranzact").description("A powerful cli to scaffold new etranzact project").version("1.0.0");
|
|
107
|
+
program.addCommand(scaffold_default);
|
|
108
|
+
program.parse(process.argv);
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
7
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/utils/constants.ts
|
|
11
|
+
var NEXT_TEMPLATE, EXPRESS_TEMPLATE;
|
|
12
|
+
var init_constants = __esm({
|
|
13
|
+
"src/utils/constants.ts"() {
|
|
14
|
+
"use strict";
|
|
15
|
+
NEXT_TEMPLATE = "https://github.com/olayinkaa/nextjs-starter-template-etz.git";
|
|
16
|
+
EXPRESS_TEMPLATE = "https://github.com/MUKE-coder/nodejs-typescript-starter-template.git";
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// src/utils/resolve-templates.ts
|
|
21
|
+
function resolveTemplate(template) {
|
|
22
|
+
switch (template) {
|
|
23
|
+
case "next":
|
|
24
|
+
return { repoUrl: NEXT_TEMPLATE, label: "Next.js" };
|
|
25
|
+
case "express":
|
|
26
|
+
return { repoUrl: EXPRESS_TEMPLATE, label: "Express" };
|
|
27
|
+
default:
|
|
28
|
+
throw new Error("Invalid template selected.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var init_resolve_templates = __esm({
|
|
32
|
+
"src/utils/resolve-templates.ts"() {
|
|
33
|
+
"use strict";
|
|
34
|
+
init_constants();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// src/commands/scaffold.ts
|
|
39
|
+
import { Command } from "commander";
|
|
40
|
+
import chalk from "chalk";
|
|
41
|
+
import fs from "fs-extra";
|
|
42
|
+
import path from "path";
|
|
43
|
+
import { simpleGit } from "simple-git";
|
|
44
|
+
import ora from "ora";
|
|
45
|
+
import inquirer from "inquirer";
|
|
46
|
+
import { execa } from "execa";
|
|
47
|
+
var scaffoldCommand, scaffold_default;
|
|
48
|
+
var init_scaffold = __esm({
|
|
49
|
+
"src/commands/scaffold.ts"() {
|
|
50
|
+
"use strict";
|
|
51
|
+
init_resolve_templates();
|
|
52
|
+
scaffoldCommand = new Command("new");
|
|
53
|
+
scaffoldCommand.argument("<project-name>", "name of the project").action(async (projectName) => {
|
|
54
|
+
const projectPath = path.join(process.cwd(), projectName);
|
|
55
|
+
if (fs.existsSync(projectPath)) {
|
|
56
|
+
console.error(
|
|
57
|
+
chalk.red(`Error: Directory ${projectName} already exists.`)
|
|
58
|
+
);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
const answers = await inquirer.prompt([
|
|
62
|
+
{
|
|
63
|
+
type: "list",
|
|
64
|
+
name: "template",
|
|
65
|
+
message: "Which template would you like to use?",
|
|
66
|
+
choices: [
|
|
67
|
+
{ name: "Nextjs", value: "next" },
|
|
68
|
+
{ name: "Express", value: "express" }
|
|
69
|
+
],
|
|
70
|
+
default: "ts"
|
|
71
|
+
}
|
|
72
|
+
]);
|
|
73
|
+
const { repoUrl } = resolveTemplate(answers.template);
|
|
74
|
+
fs.mkdirSync(projectPath);
|
|
75
|
+
const spinner = ora().start();
|
|
76
|
+
const git = simpleGit();
|
|
77
|
+
try {
|
|
78
|
+
spinner.text = `Downloading ${answers.template === "js" ? "JavaScript" : "TypeScript"} template...`;
|
|
79
|
+
await git.clone(repoUrl, projectPath);
|
|
80
|
+
spinner.succeed("Template downloaded successfully!");
|
|
81
|
+
process.chdir(projectPath);
|
|
82
|
+
spinner.start("Installing dependencies...");
|
|
83
|
+
await execa("pnpm", ["install"], {
|
|
84
|
+
stdio: "inherit"
|
|
85
|
+
// shows install logs
|
|
86
|
+
});
|
|
87
|
+
spinner.succeed("Dependencies installed successfully!");
|
|
88
|
+
console.log();
|
|
89
|
+
console.log(chalk.green(`Project ${projectName} is ready! \u{1F680}`));
|
|
90
|
+
console.log(chalk.cyan(`cd ${projectName}`));
|
|
91
|
+
console.log(chalk.cyan(`pnpm dev`));
|
|
92
|
+
} catch (error) {
|
|
93
|
+
spinner.fail("Failed to set up the project.");
|
|
94
|
+
console.error(chalk.red(error.message));
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
scaffold_default = scaffoldCommand;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// src/index.ts
|
|
103
|
+
import { Command as Command2 } from "commander";
|
|
104
|
+
var require_index = __commonJS({
|
|
105
|
+
"src/index.ts"() {
|
|
106
|
+
init_scaffold();
|
|
107
|
+
var program = new Command2();
|
|
108
|
+
program.name("etranzact").description("A powerful cli to scaffold new etranzact project").version("1.0.0");
|
|
109
|
+
program.addCommand(scaffold_default);
|
|
110
|
+
program.parse(process.argv);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
export default require_index();
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "etranzact-fe-cli",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Etranzact Cli for scaffolding new frontend project",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"bin": {
|
|
10
|
+
"etz-cli": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "tsc -w",
|
|
17
|
+
"build:tsc": "tsc",
|
|
18
|
+
"build:esb": "node esbuild.config.mjs",
|
|
19
|
+
"build:tsup": "tsup",
|
|
20
|
+
"build": "tsup"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "Olayinka Ibrahim",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"packageManager": "pnpm@10.28.1",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/fs-extra": "^11.0.4",
|
|
28
|
+
"@types/node": "^25.3.0",
|
|
29
|
+
"esbuild": "^0.27.3",
|
|
30
|
+
"tsup": "^8.5.1",
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"chalk": "^5.6.2",
|
|
35
|
+
"commander": "^14.0.3",
|
|
36
|
+
"execa": "^9.6.1",
|
|
37
|
+
"fs-extra": "^11.3.3",
|
|
38
|
+
"inquirer": "^13.3.0",
|
|
39
|
+
"ora": "^9.3.0",
|
|
40
|
+
"simple-git": "^3.32.2"
|
|
41
|
+
}
|
|
42
|
+
}
|