klei-cli 1.0.5 → 1.0.8

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.
Files changed (2) hide show
  1. package/bin/cli.js +145 -5
  2. package/package.json +74 -74
package/bin/cli.js CHANGED
@@ -171,12 +171,115 @@ export default tseslint.config(
171
171
  'spaced-comment': ['error', 'always', { markers: ['/'] }],
172
172
  'comma-dangle': ['error', 'never'],
173
173
  'no-multiple-empty-lines': ['error', { max: 1 }],
174
- 'no-async-promise-executor': 'off'
174
+ 'no-async-promise-executor': 'off',
175
+ 'no-unused-vars': 'warn',
176
+ '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }]
175
177
  }
176
178
  }
177
179
  )`,
178
180
  pathFileName: "eslint.config.mjs"
179
181
  },
182
+ {
183
+ content: `# Dependencias
184
+ node_modules/
185
+ npm-debug.log*
186
+ yarn-debug.log*
187
+ yarn-error.log*
188
+ pnpm-debug.log*
189
+
190
+ # Archivos de construcci\xF3n
191
+ dist/
192
+ build/
193
+ *.tsbuildinfo
194
+
195
+ # Archivos de entorno
196
+ .env
197
+ .env.local
198
+ .env.development.local
199
+ .env.test.local
200
+ .env.production.local
201
+
202
+ # Archivos del sistema operativo
203
+ .DS_Store
204
+ .DS_Store?
205
+ ._*
206
+ .Spotlight-V100
207
+ .Trashes
208
+ ehthumbs.db
209
+ Thumbs.db
210
+
211
+ # Archivos del editor
212
+ .vscode/
213
+ .idea/
214
+ *.swp
215
+ *.swo
216
+ *~
217
+
218
+ # Logs
219
+ logs
220
+ *.log
221
+
222
+ # Archivos temporales
223
+ *.tmp
224
+ *.temp
225
+
226
+ # Coverage directory used by tools like istanbul
227
+ coverage/
228
+ *.lcov
229
+
230
+ # NYC test coverage
231
+ .nyc_output
232
+
233
+ # Dependency directories
234
+ jspm_packages/
235
+
236
+ # Optional npm cache directory
237
+ .npm
238
+
239
+ # Optional eslint cache
240
+ .eslintcache
241
+
242
+ # Microbundle cache
243
+ .rpt2_cache/
244
+ .rts2_cache_cjs/
245
+ .rts2_cache_es/
246
+ .rts2_cache_umd/
247
+
248
+ # Optional REPL history
249
+ .node_repl_history
250
+
251
+ # Output of 'npm pack'
252
+ *.tgz
253
+
254
+ # Yarn Integrity file
255
+ .yarn-integrity
256
+
257
+ # parcel-bundler cache (https://parceljs.org/)
258
+ .cache
259
+ .parcel-cache
260
+
261
+ # next.js build output
262
+ .next
263
+
264
+ # nuxt.js build output
265
+ .nuxt
266
+
267
+ # vuepress build output
268
+ .vuepress/dist
269
+
270
+ # Serverless directories
271
+ .serverless
272
+
273
+ # FuseBox cache
274
+ .fusebox/
275
+
276
+ # DynamoDB Local files
277
+ .dynamodb/
278
+
279
+ # TernJS port file
280
+ .tern-port`,
281
+ pathFileName: ".gitignore"
282
+ },
180
283
  {
181
284
  content: `// \u2501\u2501 IMPORT MODULES \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
182
285
  // \xBB IMPORT NATIVE NODE MODULES
@@ -200,7 +303,7 @@ describe('greetUser', () => {
200
303
  }
201
304
  ];
202
305
 
203
- // src/lib/utils/npm-utils.js
306
+ // src/lib/utils/npm-utils.ts
204
307
  import fs from "node:fs";
205
308
  import spawn from "cross-spawn";
206
309
  import path from "node:path";
@@ -221,7 +324,11 @@ function findPackageJson(startDir) {
221
324
  function installSyncSaveDev(packages, packageManager = "npm", cwd, installFlags = ["-D"]) {
222
325
  const packageList = Array.isArray(packages) ? packages : [packages];
223
326
  const installCmd = packageManager === "yarn" ? "add" : "install";
224
- const installProcess = spawn.sync(packageManager, [installCmd, ...installFlags].concat(packageList), { stdio: "inherit", cwd });
327
+ const installProcess = spawn.sync(
328
+ packageManager,
329
+ [installCmd, ...installFlags].concat(packageList),
330
+ { stdio: "inherit", cwd }
331
+ );
225
332
  const error = installProcess.error;
226
333
  if (error && error.code === "ENOENT") {
227
334
  const pluralS = packageList.length > 1 ? "s" : "";
@@ -237,8 +344,8 @@ function parsePackageName(packageName) {
237
344
  }
238
345
  return { name: packageName, version: "latest" };
239
346
  }
240
- function getPkgs(path3) {
241
- return JSON.parse(fs.readFileSync(path3, "utf-8"));
347
+ function getPkgs(filePath) {
348
+ return JSON.parse(fs.readFileSync(filePath, "utf-8"));
242
349
  }
243
350
 
244
351
  // src/utils/project.ts
@@ -259,6 +366,39 @@ var createProjectStructure = async (answers, spinner) => {
259
366
  for (const file of projectStr) {
260
367
  const { content, pathFileName } = file;
261
368
  const filePath = path2.join(projectDir, pathFileName);
369
+ if (answers.projectName === "." && pathFileName === "package.json") {
370
+ spinner.info(`Actualizando ${chalk2.yellow("package.json")} existente`);
371
+ try {
372
+ const currentPackageJsonPath = path2.join(process.cwd(), "package.json");
373
+ let currentPackageJson = {};
374
+ if (fs2.existsSync(currentPackageJsonPath)) {
375
+ const currentContent = fs2.readFileSync(currentPackageJsonPath, "utf-8");
376
+ currentPackageJson = JSON.parse(currentContent);
377
+ }
378
+ const templatePackageJson = JSON.parse(content);
379
+ const mergedPackageJson = {
380
+ ...currentPackageJson,
381
+ ...templatePackageJson,
382
+ dependencies: {
383
+ ...currentPackageJson.dependencies,
384
+ ...templatePackageJson.dependencies
385
+ },
386
+ devDependencies: {
387
+ ...currentPackageJson.devDependencies,
388
+ ...templatePackageJson.devDependencies
389
+ },
390
+ scripts: {
391
+ ...currentPackageJson.scripts,
392
+ ...templatePackageJson.scripts
393
+ }
394
+ };
395
+ fs2.writeFileSync(currentPackageJsonPath, JSON.stringify(mergedPackageJson, null, 2));
396
+ spinner.succeed(`${chalk2.green("package.json actualizado exitosamente")}`);
397
+ } catch (error) {
398
+ spinner.warn(`Error al actualizar package.json: ${error}`);
399
+ }
400
+ continue;
401
+ }
262
402
  if (answers.projectName === "." && fs2.existsSync(filePath)) {
263
403
  spinner.warn(`El archivo ${chalk2.yellow(filePath)} ya existe. Se omitir\xE1 su creaci\xF3n.`);
264
404
  continue;
package/package.json CHANGED
@@ -1,74 +1,74 @@
1
- {
2
- "name": "klei-cli",
3
- "version": "1.0.5",
4
- "description": "cli for creating and managing packages",
5
- "type": "module",
6
- "funding": {
7
- "type": "buymeacoffee",
8
- "url": "https://www.buymeacoffee.com/kreisler"
9
- },
10
- "scripts": {
11
- "start": "node ./bin/cli.js",
12
- "w": "tsup --entry.cli src/index.ts --watch --onSuccess \"node bin/cli.js\"",
13
- "b": "rm -rf bin/** && tsup",
14
- "n:latest": "npm install -g npm@latest",
15
- "p:latest": "pnpm add -g pnpm",
16
- "p:update": "corepack install -g pnpm@10.4.1",
17
- "pp": "npm run b && npm publish --access public",
18
- "n:cache": "npm config get cache"
19
- },
20
- "files": [
21
- "bin/**"
22
- ],
23
- "main": "bin/cli.js",
24
- "bin": {
25
- "klei": "./bin/cli.js"
26
- },
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/itskreisler/klei.git"
30
- },
31
- "homepage": "https://github.com/itskreisler/klei#readme",
32
- "bugs": {
33
- "url": "https://github.com/itskreisler/klei/issues"
34
- },
35
- "keywords": [
36
- "cli",
37
- "packages"
38
- ],
39
- "author": "kreisler <tempkreisler@outlook.com> (https://linktr.ee/itskreisler)",
40
- "contributors": [
41
- {
42
- "name": "Kreisler Ramirez Sierra",
43
- "email": "tempkreisler@outlook.com",
44
- "url": "https://linktr.ee/itskreisler"
45
- }
46
- ],
47
- "license": "MIT",
48
- "devDependencies": {
49
- "@eslint/js": "^9.21.0",
50
- "@types/assert": "^1.5.11",
51
- "@types/cross-spawn": "^6.0.6",
52
- "@types/figlet": "^1.7.0",
53
- "@types/node": "^22.13.5",
54
- "eslint": "^9.21.0",
55
- "tsup": "^8.4.0",
56
- "typescript": "^5.8.3",
57
- "typescript-eslint": "^8.25.0"
58
- },
59
- "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
60
- "pnpm": {
61
- "onlyBuiltDependencies": [
62
- "esbuild"
63
- ]
64
- },
65
- "dependencies": {
66
- "chalk": "^5.4.1",
67
- "commander": "^13.1.0",
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"
73
- }
74
- }
1
+ {
2
+ "name": "klei-cli",
3
+ "version": "1.0.8",
4
+ "description": "cli for creating and managing packages",
5
+ "type": "module",
6
+ "funding": {
7
+ "type": "buymeacoffee",
8
+ "url": "https://www.buymeacoffee.com/kreisler"
9
+ },
10
+ "scripts": {
11
+ "start": "node ./bin/cli.js",
12
+ "w": "tsup --entry.cli src/index.ts --watch --onSuccess \"node bin/cli.js\"",
13
+ "b": "rm -rf bin/** && tsup",
14
+ "n:latest": "npm install -g npm@latest",
15
+ "p:latest": "pnpm add -g pnpm",
16
+ "p:update": "corepack install -g pnpm@10.4.1",
17
+ "pp": "npm run b && npm publish --access public",
18
+ "n:cache": "npm config get cache"
19
+ },
20
+ "files": [
21
+ "bin/**"
22
+ ],
23
+ "main": "bin/cli.js",
24
+ "bin": {
25
+ "klei": "./bin/cli.js"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/itskreisler/klei.git"
30
+ },
31
+ "homepage": "https://github.com/itskreisler/klei#readme",
32
+ "bugs": {
33
+ "url": "https://github.com/itskreisler/klei/issues"
34
+ },
35
+ "keywords": [
36
+ "cli",
37
+ "packages"
38
+ ],
39
+ "author": "kreisler <tempkreisler@outlook.com> (https://linktr.ee/itskreisler)",
40
+ "contributors": [
41
+ {
42
+ "name": "Kreisler Ramirez Sierra",
43
+ "email": "tempkreisler@outlook.com",
44
+ "url": "https://linktr.ee/itskreisler"
45
+ }
46
+ ],
47
+ "license": "MIT",
48
+ "devDependencies": {
49
+ "@eslint/js": "^9.21.0",
50
+ "@types/assert": "^1.5.11",
51
+ "@types/cross-spawn": "^6.0.6",
52
+ "@types/figlet": "^1.7.0",
53
+ "@types/node": "^22.13.5",
54
+ "eslint": "^9.21.0",
55
+ "tsup": "^8.4.0",
56
+ "typescript": "^5.8.3",
57
+ "typescript-eslint": "^8.25.0"
58
+ },
59
+ "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
60
+ "pnpm": {
61
+ "onlyBuiltDependencies": [
62
+ "esbuild"
63
+ ]
64
+ },
65
+ "dependencies": {
66
+ "chalk": "^5.4.1",
67
+ "commander": "^13.1.0",
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"
73
+ }
74
+ }