klei-cli 1.0.0 → 1.0.3
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 -26
- package/bin/cli.js +349 -67
- package/package.json +13 -7
- package/bin/cli.mjs +0 -62
package/README.md
CHANGED
|
@@ -7,9 +7,9 @@ KLEI CLI es una herramienta de línea de comandos profesional con múltiples car
|
|
|
7
7
|
Para instalar las dependencias del proyecto, ejecuta:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install -g
|
|
10
|
+
npm install -g klei-cli
|
|
11
11
|
# o
|
|
12
|
-
pnpm install -g
|
|
12
|
+
pnpm install -g klei-cli
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Uso
|
|
@@ -18,44 +18,24 @@ Para usar la CLI, puedes ejecutar los siguientes comandos:
|
|
|
18
18
|
|
|
19
19
|
### Mostrar Ayuda
|
|
20
20
|
|
|
21
|
-
```bash
|
|
22
|
-
klei ayuda
|
|
23
|
-
```
|
|
24
|
-
|
|
25
21
|
Este comando muestra la ayuda y los comandos disponibles.
|
|
26
22
|
|
|
27
|
-
### Saludar
|
|
28
|
-
|
|
29
23
|
```bash
|
|
30
|
-
klei
|
|
24
|
+
klei help
|
|
31
25
|
```
|
|
32
26
|
|
|
33
|
-
Este comando saluda al usuario especificado.
|
|
34
|
-
|
|
35
|
-
#### Opciones
|
|
36
|
-
|
|
37
|
-
- `-e, --exclamar`: Agrega una exclamación al saludo.
|
|
38
|
-
|
|
39
27
|
## Comandos Disponibles
|
|
40
28
|
|
|
41
|
-
- `
|
|
42
|
-
-
|
|
29
|
+
- `create [nombre]`: Crea un nuevo proyecto.
|
|
30
|
+
- `--t, --type <type>`: Especifica el tipo de proyecto.
|
|
43
31
|
- `help`: Muestra la ayuda y los comandos disponibles.
|
|
44
32
|
|
|
45
33
|
## Ejemplos
|
|
46
34
|
|
|
47
35
|
```bash
|
|
48
|
-
klei
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Este comando saluda a Juan con una exclamación.
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
klei ayuda
|
|
36
|
+
klei create mi-proyecto --type npmjs
|
|
55
37
|
```
|
|
56
38
|
|
|
57
|
-
Este comando muestra la ayuda.
|
|
58
|
-
|
|
59
39
|
## Contribuir
|
|
60
40
|
|
|
61
41
|
Si deseas contribuir a este proyecto, por favor sigue los siguientes pasos:
|
package/bin/cli.js
CHANGED
|
@@ -1,85 +1,367 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
"use strict";
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
-
mod
|
|
25
|
-
));
|
|
2
|
+
// $ klei
|
|
26
3
|
|
|
27
4
|
// src/index.ts
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
import chalk4 from "chalk";
|
|
6
|
+
import { program } from "commander";
|
|
30
7
|
|
|
31
|
-
// src/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.log(
|
|
36
|
-
|
|
37
|
-
|
|
8
|
+
// src/utils/banner.ts
|
|
9
|
+
import chalk from "chalk";
|
|
10
|
+
import figlet from "figlet";
|
|
11
|
+
var printBanner = () => {
|
|
12
|
+
console.log(
|
|
13
|
+
chalk.blue(
|
|
14
|
+
figlet.textSync("KLEI", { horizontalLayout: "full" })
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
};
|
|
38
18
|
|
|
39
|
-
|
|
19
|
+
// src/commands/create.ts
|
|
20
|
+
import inquirer from "inquirer";
|
|
21
|
+
import chalk3 from "chalk";
|
|
22
|
+
import ora from "ora";
|
|
40
23
|
|
|
41
|
-
|
|
24
|
+
// src/utils/project.ts
|
|
25
|
+
import chalk2 from "chalk";
|
|
26
|
+
import fs2 from "fs";
|
|
27
|
+
import path2 from "path";
|
|
42
28
|
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
// src/templates/npmjs.ts
|
|
30
|
+
var npmjs = [
|
|
31
|
+
{
|
|
32
|
+
content: "# Proyecto generado por Klei CLI.",
|
|
33
|
+
pathFileName: "README.md"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
content: JSON.stringify({
|
|
37
|
+
name: "my-project",
|
|
38
|
+
version: "1.0.0",
|
|
39
|
+
description: "",
|
|
40
|
+
type: "module",
|
|
41
|
+
main: "./dist/index.cjs",
|
|
42
|
+
module: "./dist/index.js",
|
|
43
|
+
types: "./dist/index.d.ts",
|
|
44
|
+
files: [
|
|
45
|
+
"dist/**"
|
|
46
|
+
],
|
|
47
|
+
scripts: {
|
|
48
|
+
start: "tsx src/index.ts",
|
|
49
|
+
xtart: "npx -y tsx src/index.ts",
|
|
50
|
+
watch: 'tsup --entry.index src/index.ts --watch --onSuccess "node dist/index.js"',
|
|
51
|
+
build: "tsup --entry.index src/index.ts --format esm,cjs --dts",
|
|
52
|
+
"test:esm": 'tsup --entry.test src/index.ts --format esm --watch --onSuccess "node dist/test.js"',
|
|
53
|
+
"test:spec": 'tsup test/test.spec.ts --format esm --onSuccess "cross-env NODE_ENV=test node --test dist/test.spec.js"'
|
|
54
|
+
},
|
|
55
|
+
keywords: [],
|
|
56
|
+
author: "",
|
|
57
|
+
license: "ISC",
|
|
58
|
+
dependencies: {},
|
|
59
|
+
devDependencies: {
|
|
60
|
+
"@eslint/js": "latest",
|
|
61
|
+
// "@types/assert": 'latest',
|
|
62
|
+
"@types/node": "latest",
|
|
63
|
+
// 'cross-env': 'latest',
|
|
64
|
+
eslint: "latest",
|
|
65
|
+
nodemon: "latest",
|
|
66
|
+
"ts-node": "latest",
|
|
67
|
+
tsup: "latest",
|
|
68
|
+
tsx: "latest",
|
|
69
|
+
typescript: "latest",
|
|
70
|
+
"typescript-eslint": "latest"
|
|
71
|
+
}
|
|
72
|
+
}, null, 2),
|
|
73
|
+
pathFileName: "package.json"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
content: `import { defineConfig } from 'tsup'
|
|
77
|
+
export default defineConfig(${JSON.stringify({
|
|
78
|
+
entry: {
|
|
79
|
+
index: "src/index.ts"
|
|
80
|
+
},
|
|
81
|
+
format: ["esm", "cjs"],
|
|
82
|
+
dts: true,
|
|
83
|
+
clean: true
|
|
84
|
+
}, null, 2)})`,
|
|
85
|
+
pathFileName: "tsup.config.ts"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
content: JSON.stringify({
|
|
89
|
+
$schema: "https://json.schemastore.org/tsconfig",
|
|
90
|
+
display: "Default",
|
|
91
|
+
compilerOptions: {
|
|
92
|
+
target: "ES2016",
|
|
93
|
+
module: "CommonJS",
|
|
94
|
+
outDir: "./dist",
|
|
95
|
+
rootDir: "./src",
|
|
96
|
+
strict: true,
|
|
97
|
+
esModuleInterop: true,
|
|
98
|
+
skipLibCheck: true,
|
|
99
|
+
forceConsistentCasingInFileNames: true,
|
|
100
|
+
declaration: true,
|
|
101
|
+
resolveJsonModule: true,
|
|
102
|
+
noUnusedLocals: false,
|
|
103
|
+
noImplicitThis: false,
|
|
104
|
+
noUnusedParameters: false,
|
|
105
|
+
baseUrl: ".",
|
|
106
|
+
paths: {
|
|
107
|
+
"@/*": [
|
|
108
|
+
"./src/*"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
include: ["src/**/*"],
|
|
113
|
+
exclude: ["node_modules", "**.spec.ts", "dist", "build", "docs"]
|
|
114
|
+
}, null, 2),
|
|
115
|
+
pathFileName: "tsconfig.json"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
content: `// Example TypeScript code with types and interfaces
|
|
45
119
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
120
|
+
// Define an interface for a User
|
|
121
|
+
interface User {
|
|
122
|
+
id: number;
|
|
123
|
+
name: string;
|
|
124
|
+
email: string;
|
|
125
|
+
isActive: boolean;
|
|
51
126
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (options.exclamar) mensaje += " \u{1F44B}";
|
|
60
|
-
console.log(mensaje);
|
|
61
|
-
});
|
|
127
|
+
|
|
128
|
+
// Define a type for a function that takes a User and returns a string
|
|
129
|
+
type GreetUser = (user: User) => string;
|
|
130
|
+
|
|
131
|
+
// Example implementation of the GreetUser function
|
|
132
|
+
const greetUser: GreetUser = (user) => {
|
|
133
|
+
return \`Hello, \${user.name}! Your email is \${user.email}.\`;
|
|
62
134
|
};
|
|
63
135
|
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
import_figlet.default.textSync("KLEI", { horizontalLayout: "full" })
|
|
71
|
-
)
|
|
72
|
-
);
|
|
136
|
+
// Example usage
|
|
137
|
+
const exampleUser: User = {
|
|
138
|
+
id: 1,
|
|
139
|
+
name: 'John Doe',
|
|
140
|
+
email: 'john.doe@example.com',
|
|
141
|
+
isActive: true
|
|
73
142
|
};
|
|
74
143
|
|
|
144
|
+
console.log(greetUser(exampleUser));
|
|
145
|
+
`,
|
|
146
|
+
pathFileName: "src/index.ts"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
content: `// @ts-check
|
|
150
|
+
|
|
151
|
+
import eslint from '@eslint/js'
|
|
152
|
+
import tseslint from 'typescript-eslint'
|
|
153
|
+
|
|
154
|
+
export default tseslint.config(
|
|
155
|
+
{ ignores: ['node_modules', 'dist/', 'bin/'] },
|
|
156
|
+
eslint.configs.recommended,
|
|
157
|
+
tseslint.configs.strict,
|
|
158
|
+
tseslint.configs.stylistic,
|
|
159
|
+
{
|
|
160
|
+
rules: {
|
|
161
|
+
quotes: [2, 'single', { avoidEscape: true }],
|
|
162
|
+
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
|
|
163
|
+
'space-before-function-paren': ['off'],
|
|
164
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
165
|
+
'no-useless-escape': 'off',
|
|
166
|
+
'eol-last': ['error', 'always'],
|
|
167
|
+
semi: ['error', 'never'],
|
|
168
|
+
'quote-props': ['error', 'as-needed'],
|
|
169
|
+
'spaced-comment': ['error', 'always', { markers: ['/'] }],
|
|
170
|
+
'comma-dangle': ['error', 'never'],
|
|
171
|
+
'no-multiple-empty-lines': ['error', { max: 1 }],
|
|
172
|
+
'no-async-promise-executor': 'off'
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
)`,
|
|
176
|
+
pathFileName: "eslint.config.mjs"
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
// src/lib/utils/npm-utils.js
|
|
181
|
+
import fs from "node:fs";
|
|
182
|
+
import spawn from "cross-spawn";
|
|
183
|
+
import path from "node:path";
|
|
184
|
+
import process2 from "node:process";
|
|
185
|
+
function findPackageJson(startDir) {
|
|
186
|
+
let dir = path.resolve(startDir || process2.cwd());
|
|
187
|
+
do {
|
|
188
|
+
const pkgFile = path.join(dir, "package.json");
|
|
189
|
+
if (!fs.existsSync(pkgFile) || !fs.statSync(pkgFile).isFile()) {
|
|
190
|
+
dir = path.join(dir, "..");
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
return pkgFile;
|
|
194
|
+
} while (dir !== path.resolve(dir, ".."));
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
function installSyncSaveDev(packages, packageManager = "npm", cwd, installFlags = ["-D"]) {
|
|
198
|
+
const packageList = Array.isArray(packages) ? packages : [packages];
|
|
199
|
+
const installCmd = packageManager === "yarn" ? "add" : "install";
|
|
200
|
+
const installProcess = spawn.sync(packageManager, [installCmd, ...installFlags].concat(packageList), { stdio: "inherit", cwd });
|
|
201
|
+
const error = installProcess.error;
|
|
202
|
+
if (error && error.code === "ENOENT") {
|
|
203
|
+
const pluralS = packageList.length > 1 ? "s" : "";
|
|
204
|
+
console.error(`Could not execute ${packageManager}. Please install the following package${pluralS} with a package manager of your choice: ${packageList.join(", ")}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function parsePackageName(packageName) {
|
|
208
|
+
const atIndex = packageName.lastIndexOf("@");
|
|
209
|
+
if (atIndex > 0) {
|
|
210
|
+
const name = packageName.slice(0, atIndex);
|
|
211
|
+
const version2 = packageName.slice(atIndex + 1) || "latest";
|
|
212
|
+
return { name, version: version2 };
|
|
213
|
+
}
|
|
214
|
+
return { name: packageName, version: "latest" };
|
|
215
|
+
}
|
|
216
|
+
function getPkgs(path3) {
|
|
217
|
+
return JSON.parse(fs.readFileSync(path3, "utf-8"));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/utils/project.ts
|
|
221
|
+
var createProjectStructure = async (answers, spinner) => {
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
const projects = {
|
|
224
|
+
npmjs,
|
|
225
|
+
monorepo: []
|
|
226
|
+
};
|
|
227
|
+
const projectStr = projects[answers.projectType];
|
|
228
|
+
if (!projectStr) {
|
|
229
|
+
return reject(new Error("Tipo de proyecto no v\xE1lido. --t ".concat(Object.keys(projects).join(", "))));
|
|
230
|
+
}
|
|
231
|
+
const projectDir = path2.join(process.cwd(), answers.projectName);
|
|
232
|
+
if (fs2.existsSync(projectDir) && answers.projectName !== ".") {
|
|
233
|
+
return reject(new Error(`El directorio ${projectDir} ya existe. Elige otro nombre.`));
|
|
234
|
+
}
|
|
235
|
+
for (const file of projectStr) {
|
|
236
|
+
const { content, pathFileName } = file;
|
|
237
|
+
const filePath = path2.join(projectDir, pathFileName);
|
|
238
|
+
if (answers.projectName === "." && fs2.existsSync(filePath)) {
|
|
239
|
+
spinner.warn(`El archivo ${chalk2.yellow(filePath)} ya existe. Se omitir\xE1 su creaci\xF3n.`);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
spinner.info(`Creando ${chalk2.yellow(filePath)}`);
|
|
243
|
+
const dirPath = path2.dirname(filePath);
|
|
244
|
+
fs2.mkdirSync(dirPath, { recursive: true });
|
|
245
|
+
fs2.writeFileSync(filePath, content);
|
|
246
|
+
}
|
|
247
|
+
if (answers.projectInstall) {
|
|
248
|
+
spinner.info(`Instalando dependencias con ${chalk2.yellow(answers.projectPackageManager)}`);
|
|
249
|
+
const packageJsonPath = findPackageJson(projectDir);
|
|
250
|
+
const packageJson = getPkgs(packageJsonPath);
|
|
251
|
+
const pkgs = Object.keys(packageJson.devDependencies).map((pkgName) => parsePackageName(pkgName)).map((pkg) => pkg.name);
|
|
252
|
+
spinner.info(`Instalando dependencias: ${chalk2.yellow(pkgs.join(" "))}`);
|
|
253
|
+
installSyncSaveDev(pkgs, answers.projectPackageManager, projectDir);
|
|
254
|
+
spinner.info(chalk2.green("Dependencias instaladas exitosamente"));
|
|
255
|
+
}
|
|
256
|
+
spinner.succeed(`${chalk2.green(` Proyecto ${chalk2.bold(projectDir)} creado exitosamente`)}`);
|
|
257
|
+
resolve(true);
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// src/commands/create.ts
|
|
262
|
+
var logo = `
|
|
263
|
+
${chalk3.dim("Creaci\xF3n r\xE1pida de proyectos")}
|
|
264
|
+
`;
|
|
265
|
+
var questionsMain = [
|
|
266
|
+
{
|
|
267
|
+
type: "list",
|
|
268
|
+
name: "projectType",
|
|
269
|
+
message: " \xBFQu\xE9 tipo de proyecto quieres crear?",
|
|
270
|
+
choices: [
|
|
271
|
+
{ name: "npmjs package (Node.js)", value: "npmjs" }
|
|
272
|
+
// { name: 'Aplicación Monorepo (Node.js)', value: 'monorepo' }
|
|
273
|
+
// { name: 'Aplicación CLI (Node.js)', value: 'cli' }
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
type: "input",
|
|
278
|
+
name: "projectName",
|
|
279
|
+
message: " \xBFCu\xE1l es el nombre del proyecto?",
|
|
280
|
+
validate: (input) => {
|
|
281
|
+
if (input.trim() === "") {
|
|
282
|
+
return "El nombre del proyecto no puede estar vac\xEDo.";
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
type: "list",
|
|
289
|
+
name: "projectInstall",
|
|
290
|
+
message: " \xBFQuieres instalar dependencias?",
|
|
291
|
+
choices: [
|
|
292
|
+
{ name: "S\xED", value: true },
|
|
293
|
+
{ name: "No", value: false }
|
|
294
|
+
]
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
type: "list",
|
|
298
|
+
name: "projectPackageManager",
|
|
299
|
+
message: " \xBFQu\xE9 gestor de paquetes quieres usar?",
|
|
300
|
+
choices: [
|
|
301
|
+
{ name: "npm", value: "npm" },
|
|
302
|
+
{ name: "yarn", value: "yarn" },
|
|
303
|
+
{ name: "pnpm", value: "pnpm" },
|
|
304
|
+
{ name: "bun", value: "bun" }
|
|
305
|
+
],
|
|
306
|
+
when: (answers) => answers.projectInstall
|
|
307
|
+
}
|
|
308
|
+
];
|
|
309
|
+
async function createCommand({ name, options }) {
|
|
310
|
+
console.log(logo);
|
|
311
|
+
console.log(chalk3.blue("------------------------------------------------\n"));
|
|
312
|
+
const questions = [];
|
|
313
|
+
if (typeof options?.type === "undefined") questions.push(questionsMain[0]);
|
|
314
|
+
if (typeof name === "undefined") questions.push(questionsMain[1]);
|
|
315
|
+
let answers;
|
|
316
|
+
if (questions.length === 0) {
|
|
317
|
+
answers = {
|
|
318
|
+
projectType: options?.type,
|
|
319
|
+
projectName: name,
|
|
320
|
+
projectInstall: false,
|
|
321
|
+
projectPackageManager: "npm" /* npm */
|
|
322
|
+
};
|
|
323
|
+
} else {
|
|
324
|
+
questions.push(questionsMain[2]);
|
|
325
|
+
questions.push(questionsMain[3]);
|
|
326
|
+
answers = await inquirer.prompt(questions);
|
|
327
|
+
if (typeof name !== "undefined") {
|
|
328
|
+
answers.projectName = name;
|
|
329
|
+
}
|
|
330
|
+
if (typeof options?.type !== "undefined") {
|
|
331
|
+
answers.projectType = options.type;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const spinner = ora("Creando proyecto...\n\n").start();
|
|
335
|
+
try {
|
|
336
|
+
await createProjectStructure(answers, spinner);
|
|
337
|
+
} catch (error) {
|
|
338
|
+
spinner.fail(chalk3.red("Error al crear el proyecto."));
|
|
339
|
+
showError(error);
|
|
340
|
+
} finally {
|
|
341
|
+
spinner.stop();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
var create_default = createCommand;
|
|
345
|
+
function showError(error) {
|
|
346
|
+
if (error instanceof Error) {
|
|
347
|
+
console.error(chalk3.red(error.message));
|
|
348
|
+
} else {
|
|
349
|
+
console.error(chalk3.red("Error desconocido".concat(JSON.stringify(error))));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
75
353
|
// src/index.ts
|
|
354
|
+
var { version } = JSON.parse(
|
|
355
|
+
await import("fs").then((fs3) => fs3.readFileSync(new URL("../package.json", import.meta.url), "utf-8"))
|
|
356
|
+
);
|
|
76
357
|
printBanner();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
358
|
+
program.name("klei").version(version, "-v, --version", "Muestra la versi\xF3n actual").description("CLI con m\xFAltiples caracter\xEDsticas");
|
|
359
|
+
program.command("create [name]").alias("c").option("--t, --type <type>", "Tipo de proyecto").description("Crea un nuevo proyecto").action((name, options) => {
|
|
360
|
+
create_default({ name, options });
|
|
361
|
+
});
|
|
362
|
+
program.configureOutput({
|
|
81
363
|
outputError: (err) => {
|
|
82
|
-
console.error(
|
|
364
|
+
console.error(chalk4.red(`Error: ${err}`));
|
|
83
365
|
}
|
|
84
366
|
});
|
|
85
|
-
|
|
367
|
+
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klei-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "cli for creating and managing packages",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"funding": {
|
|
6
7
|
"type": "buymeacoffee",
|
|
7
8
|
"url": "https://www.buymeacoffee.com/kreisler"
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
"n:latest": "npm install -g npm@latest",
|
|
14
15
|
"p:latest": "pnpm add -g pnpm",
|
|
15
16
|
"p:update": "corepack install -g pnpm@10.4.1",
|
|
16
|
-
"pp": "npm publish --access public",
|
|
17
|
+
"pp": "npm run b && npm publish --access public",
|
|
17
18
|
"n:cache": "npm config get cache"
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
@@ -47,14 +48,15 @@
|
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@eslint/js": "^9.21.0",
|
|
49
50
|
"@types/assert": "^1.5.11",
|
|
51
|
+
"@types/cross-spawn": "^6.0.6",
|
|
50
52
|
"@types/figlet": "^1.7.0",
|
|
51
53
|
"@types/node": "^22.13.5",
|
|
52
54
|
"eslint": "^9.21.0",
|
|
53
|
-
"tsup": "^8.
|
|
54
|
-
"typescript": "^5.
|
|
55
|
+
"tsup": "^8.4.0",
|
|
56
|
+
"typescript": "^5.8.3",
|
|
55
57
|
"typescript-eslint": "^8.25.0"
|
|
56
58
|
},
|
|
57
|
-
"packageManager": "pnpm@10.
|
|
59
|
+
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
|
|
58
60
|
"pnpm": {
|
|
59
61
|
"onlyBuiltDependencies": [
|
|
60
62
|
"esbuild"
|
|
@@ -63,6 +65,10 @@
|
|
|
63
65
|
"dependencies": {
|
|
64
66
|
"chalk": "^5.4.1",
|
|
65
67
|
"commander": "^13.1.0",
|
|
66
|
-
"
|
|
68
|
+
"cross-spawn": "^7.0.6",
|
|
69
|
+
"figlet": "^1.8.0",
|
|
70
|
+
"inquirer": "^12.4.2",
|
|
71
|
+
"ora": "^8.2.0",
|
|
72
|
+
"simple-git": "^3.27.0"
|
|
67
73
|
}
|
|
68
|
-
}
|
|
74
|
+
}
|
package/bin/cli.mjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// #!/usr/bin/env node
|
|
3
|
-
|
|
4
|
-
// src/index.ts
|
|
5
|
-
import chalk4 from "chalk";
|
|
6
|
-
import { program } from "commander";
|
|
7
|
-
|
|
8
|
-
// src/commands/help.ts
|
|
9
|
-
import chalk from "chalk";
|
|
10
|
-
function helpCommand() {
|
|
11
|
-
console.log(chalk.blue("-".repeat(48)));
|
|
12
|
-
console.log(chalk.bold.green("klei CLI - Ayuda"));
|
|
13
|
-
console.log(chalk.yellow(`
|
|
14
|
-
Comandos disponibles:
|
|
15
|
-
|
|
16
|
-
saludar <nombre> Saluda al usuario.
|
|
17
|
-
|
|
18
|
-
help Muestra la ayuda y los comandos disponibles.
|
|
19
|
-
|
|
20
|
-
Uso:
|
|
21
|
-
klei <comando>
|
|
22
|
-
|
|
23
|
-
Ejemplos:
|
|
24
|
-
klei saludar <nombre> - Saluda al usuario.
|
|
25
|
-
klei help - Muestra la ayuda.
|
|
26
|
-
`));
|
|
27
|
-
console.log(chalk.blue("-".repeat(48)));
|
|
28
|
-
}
|
|
29
|
-
var help_default = helpCommand;
|
|
30
|
-
|
|
31
|
-
// src/commands/saludar.ts
|
|
32
|
-
import chalk2 from "chalk";
|
|
33
|
-
var saludar_default = (program2) => {
|
|
34
|
-
program2.command("saludar <nombre>").description("Saluda al usuario").option("-e, --exclamar", "Agrega una exclamaci\xF3n").action((nombre, options) => {
|
|
35
|
-
let mensaje = `Hola ${chalk2.green(nombre)}!`;
|
|
36
|
-
if (options.exclamar) mensaje += " \u{1F44B}";
|
|
37
|
-
console.log(mensaje);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// src/utils/banner.ts
|
|
42
|
-
import chalk3 from "chalk";
|
|
43
|
-
import figlet from "figlet";
|
|
44
|
-
var printBanner = () => {
|
|
45
|
-
console.log(
|
|
46
|
-
chalk3.blue(
|
|
47
|
-
figlet.textSync("KLEI", { horizontalLayout: "full" })
|
|
48
|
-
)
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// src/index.ts
|
|
53
|
-
printBanner();
|
|
54
|
-
program.name("klei").version("1.0.0").description("CLI profesional con m\xFAltiples caracter\xEDsticas");
|
|
55
|
-
program.command("help").description("Muestra ayuda en espa\xF1ol").action(help_default);
|
|
56
|
-
saludar_default(program);
|
|
57
|
-
program.configureOutput({
|
|
58
|
-
outputError: (err) => {
|
|
59
|
-
console.error(chalk4.red(`Error: ${err}`));
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
program.parse(process.argv);
|