complete-cli 1.0.32 → 1.1.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.
@@ -35,6 +35,9 @@ export class InitCommand extends Command {
35
35
  pnpm = Option.Boolean("--pnpm", false, {
36
36
  description: "Use pnpm as the package manager.",
37
37
  });
38
+ bun = Option.Boolean("--bun", false, {
39
+ description: "Use bun as the package manager.",
40
+ });
38
41
  skipGit = Option.Boolean("--skip-git", false, {
39
42
  description: "Do not initialize Git.",
40
43
  });
@@ -1,35 +1,23 @@
1
1
  import chalk from "chalk";
2
+ import { getEnumValues } from "complete-common";
2
3
  import { commandExists, PackageManager } from "complete-node";
3
4
  import { DEFAULT_PACKAGE_MANAGER } from "../../constants.js";
4
5
  import { promptError } from "../../prompt.js";
6
+ const PACKAGE_MANAGERS = getEnumValues(PackageManager);
5
7
  export async function getPackageManagerUsedForNewProject(options) {
6
8
  const packageManagerFromOptions = await getPackageManagerFromOptions(options);
7
- if (packageManagerFromOptions !== undefined) {
8
- return packageManagerFromOptions;
9
- }
10
- return DEFAULT_PACKAGE_MANAGER;
9
+ return packageManagerFromOptions ?? DEFAULT_PACKAGE_MANAGER;
11
10
  }
12
11
  async function getPackageManagerFromOptions(options) {
13
- if (options.npm) {
14
- const npmExists = await commandExists("npm");
15
- if (!npmExists) {
16
- promptError(`You specified the "--npm" option, but "${chalk.green("npm")}" does not seem to be a valid command.`);
17
- }
18
- return PackageManager.npm;
19
- }
20
- if (options.yarn) {
21
- const yarnExists = await commandExists("yarn");
22
- if (!yarnExists) {
23
- promptError(`You specified the "--yarn" option, but "${chalk.green("yarn")}" does not seem to be a valid command.`);
24
- }
25
- return PackageManager.yarn;
26
- }
27
- if (options.pnpm) {
28
- const pnpmExists = await commandExists("pnpm");
29
- if (!pnpmExists) {
30
- promptError(`You specified the "--pnpm" option, but "${chalk.green("pnpm")}" does not seem to be a valid command.`);
12
+ for (const packageManager of PACKAGE_MANAGERS) {
13
+ if (options[packageManager]) {
14
+ // eslint-disable-next-line no-await-in-loop
15
+ const exists = await commandExists(packageManager);
16
+ if (!exists) {
17
+ promptError(`You specified the "--${packageManager}" option, but "${chalk.green(packageManager)}" does not seem to be a valid command.`);
18
+ }
19
+ return packageManager;
31
20
  }
32
- return PackageManager.pnpm;
33
21
  }
34
22
  return undefined;
35
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "complete-cli",
3
- "version": "1.0.32",
3
+ "version": "1.1.0",
4
4
  "description": "A command line tool for bootstrapping TypeScript projects.",
5
5
  "keywords": [
6
6
  "typescript"
@@ -39,18 +39,18 @@
39
39
  "clipanion": "4.0.0-rc.4",
40
40
  "complete-common": "2.1.0",
41
41
  "complete-node": "5.1.2",
42
- "klaw-sync": "6.0.0",
43
- "yaml": "2.7.0"
42
+ "klaw-sync": "7.0.0",
43
+ "yaml": "2.7.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/klaw-sync": "6.0.5",
47
- "@types/node": "22.13.10",
47
+ "@types/node": "22.14.1",
48
48
  "glob": "11.0.1",
49
49
  "ts-loader": "9.5.2",
50
50
  "tsconfig-paths-webpack-plugin": "4.2.0",
51
- "typescript": "5.8.2",
52
- "typescript-eslint": "8.26.1",
53
- "webpack": "5.98.0",
51
+ "typescript": "5.8.3",
52
+ "typescript-eslint": "8.30.1",
53
+ "webpack": "5.99.6",
54
54
  "webpack-cli": "6.0.1",
55
55
  "webpack-shebang-plugin": "1.1.8"
56
56
  },
@@ -47,6 +47,10 @@ export class InitCommand extends Command {
47
47
  description: "Use pnpm as the package manager.",
48
48
  });
49
49
 
50
+ bun = Option.Boolean("--bun", false, {
51
+ description: "Use bun as the package manager.",
52
+ });
53
+
50
54
  skipGit = Option.Boolean("--skip-git", false, {
51
55
  description: "Do not initialize Git.",
52
56
  });
@@ -1,63 +1,36 @@
1
1
  import chalk from "chalk";
2
+ import type { ReadonlyRecord } from "complete-common";
3
+ import { getEnumValues } from "complete-common";
2
4
  import { commandExists, PackageManager } from "complete-node";
3
5
  import { DEFAULT_PACKAGE_MANAGER } from "../../constants.js";
4
6
  import { promptError } from "../../prompt.js";
5
7
 
6
- interface PackageManagerOptions {
7
- npm: boolean;
8
- yarn: boolean;
9
- pnpm: boolean;
10
- }
8
+ const PACKAGE_MANAGERS = getEnumValues(PackageManager);
11
9
 
12
10
  export async function getPackageManagerUsedForNewProject(
13
- options: PackageManagerOptions,
11
+ options: ReadonlyRecord<PackageManager, boolean>,
14
12
  ): Promise<PackageManager> {
15
13
  const packageManagerFromOptions = await getPackageManagerFromOptions(options);
16
- if (packageManagerFromOptions !== undefined) {
17
- return packageManagerFromOptions;
18
- }
19
-
20
- return DEFAULT_PACKAGE_MANAGER;
14
+ return packageManagerFromOptions ?? DEFAULT_PACKAGE_MANAGER;
21
15
  }
22
16
 
23
- async function getPackageManagerFromOptions(options: PackageManagerOptions) {
24
- if (options.npm) {
25
- const npmExists = await commandExists("npm");
26
- if (!npmExists) {
27
- promptError(
28
- `You specified the "--npm" option, but "${chalk.green(
29
- "npm",
30
- )}" does not seem to be a valid command.`,
31
- );
32
- }
33
-
34
- return PackageManager.npm;
35
- }
36
-
37
- if (options.yarn) {
38
- const yarnExists = await commandExists("yarn");
39
- if (!yarnExists) {
40
- promptError(
41
- `You specified the "--yarn" option, but "${chalk.green(
42
- "yarn",
43
- )}" does not seem to be a valid command.`,
44
- );
45
- }
46
-
47
- return PackageManager.yarn;
48
- }
49
-
50
- if (options.pnpm) {
51
- const pnpmExists = await commandExists("pnpm");
52
- if (!pnpmExists) {
53
- promptError(
54
- `You specified the "--pnpm" option, but "${chalk.green(
55
- "pnpm",
56
- )}" does not seem to be a valid command.`,
57
- );
17
+ async function getPackageManagerFromOptions(
18
+ options: ReadonlyRecord<PackageManager, boolean>,
19
+ ) {
20
+ for (const packageManager of PACKAGE_MANAGERS) {
21
+ if (options[packageManager]) {
22
+ // eslint-disable-next-line no-await-in-loop
23
+ const exists = await commandExists(packageManager);
24
+ if (!exists) {
25
+ promptError(
26
+ `You specified the "--${packageManager}" option, but "${chalk.green(
27
+ packageManager,
28
+ )}" does not seem to be a valid command.`,
29
+ );
30
+ }
31
+
32
+ return packageManager;
58
33
  }
59
-
60
- return PackageManager.pnpm;
61
34
  }
62
35
 
63
36
  return undefined;