klei-cli 1.0.5 → 1.0.7

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 +44 -5
  2. package/package.json +74 -74
package/bin/cli.js CHANGED
@@ -171,7 +171,9 @@ 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
  )`,
@@ -200,7 +202,7 @@ describe('greetUser', () => {
200
202
  }
201
203
  ];
202
204
 
203
- // src/lib/utils/npm-utils.js
205
+ // src/lib/utils/npm-utils.ts
204
206
  import fs from "node:fs";
205
207
  import spawn from "cross-spawn";
206
208
  import path from "node:path";
@@ -221,7 +223,11 @@ function findPackageJson(startDir) {
221
223
  function installSyncSaveDev(packages, packageManager = "npm", cwd, installFlags = ["-D"]) {
222
224
  const packageList = Array.isArray(packages) ? packages : [packages];
223
225
  const installCmd = packageManager === "yarn" ? "add" : "install";
224
- const installProcess = spawn.sync(packageManager, [installCmd, ...installFlags].concat(packageList), { stdio: "inherit", cwd });
226
+ const installProcess = spawn.sync(
227
+ packageManager,
228
+ [installCmd, ...installFlags].concat(packageList),
229
+ { stdio: "inherit", cwd }
230
+ );
225
231
  const error = installProcess.error;
226
232
  if (error && error.code === "ENOENT") {
227
233
  const pluralS = packageList.length > 1 ? "s" : "";
@@ -237,8 +243,8 @@ function parsePackageName(packageName) {
237
243
  }
238
244
  return { name: packageName, version: "latest" };
239
245
  }
240
- function getPkgs(path3) {
241
- return JSON.parse(fs.readFileSync(path3, "utf-8"));
246
+ function getPkgs(filePath) {
247
+ return JSON.parse(fs.readFileSync(filePath, "utf-8"));
242
248
  }
243
249
 
244
250
  // src/utils/project.ts
@@ -259,6 +265,39 @@ var createProjectStructure = async (answers, spinner) => {
259
265
  for (const file of projectStr) {
260
266
  const { content, pathFileName } = file;
261
267
  const filePath = path2.join(projectDir, pathFileName);
268
+ if (answers.projectName === "." && pathFileName === "package.json") {
269
+ spinner.info(`Actualizando ${chalk2.yellow("package.json")} existente`);
270
+ try {
271
+ const currentPackageJsonPath = path2.join(process.cwd(), "package.json");
272
+ let currentPackageJson = {};
273
+ if (fs2.existsSync(currentPackageJsonPath)) {
274
+ const currentContent = fs2.readFileSync(currentPackageJsonPath, "utf-8");
275
+ currentPackageJson = JSON.parse(currentContent);
276
+ }
277
+ const templatePackageJson = JSON.parse(content);
278
+ const mergedPackageJson = {
279
+ ...currentPackageJson,
280
+ ...templatePackageJson,
281
+ dependencies: {
282
+ ...currentPackageJson.dependencies,
283
+ ...templatePackageJson.dependencies
284
+ },
285
+ devDependencies: {
286
+ ...currentPackageJson.devDependencies,
287
+ ...templatePackageJson.devDependencies
288
+ },
289
+ scripts: {
290
+ ...currentPackageJson.scripts,
291
+ ...templatePackageJson.scripts
292
+ }
293
+ };
294
+ fs2.writeFileSync(currentPackageJsonPath, JSON.stringify(mergedPackageJson, null, 2));
295
+ spinner.succeed(`${chalk2.green("package.json actualizado exitosamente")}`);
296
+ } catch (error) {
297
+ spinner.warn(`Error al actualizar package.json: ${error}`);
298
+ }
299
+ continue;
300
+ }
262
301
  if (answers.projectName === "." && fs2.existsSync(filePath)) {
263
302
  spinner.warn(`El archivo ${chalk2.yellow(filePath)} ya existe. Se omitir\xE1 su creaci\xF3n.`);
264
303
  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.7",
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
+ }