complete-cli 1.2.3 → 1.3.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.
@@ -0,0 +1,30 @@
1
+ import { Command, Option } from "clipanion";
2
+ import { getPackageRoot, writeFileAsync } from "complete-node";
3
+ import path from "node:path";
4
+ export class MetadataCommand extends Command {
5
+ static paths = [["metadata"], ["m"]];
6
+ // The first positional argument.
7
+ dependencyName = Option.String({
8
+ required: true,
9
+ });
10
+ reason = Option.String({
11
+ required: false,
12
+ });
13
+ static usage = Command.Usage({
14
+ description: 'Creates a "package-metadata.json" file to document locked dependencies. (The "update" command will respect the contents of this file.)',
15
+ });
16
+ async execute() {
17
+ const packageMetadata = {
18
+ dependencies: {},
19
+ };
20
+ packageMetadata.dependencies[this.dependencyName] = {
21
+ "lock-version": true,
22
+ "lock-reason": this.reason ?? "",
23
+ };
24
+ const packageRoot = await getPackageRoot();
25
+ const packageMetadataPath = path.join(packageRoot, "package-metadata.json");
26
+ const packageMetadataJSON = JSON.stringify(packageMetadata, undefined, 2);
27
+ await writeFileAsync(packageMetadataPath, packageMetadataJSON);
28
+ console.log(`Successfully created: ${packageMetadataPath}`);
29
+ }
30
+ }
package/dist/main.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { Builtins, Cli } from "clipanion";
3
3
  import { CheckCommand } from "./commands/CheckCommand.js";
4
4
  import { InitCommand } from "./commands/InitCommand.js";
5
+ import { MetadataCommand } from "./commands/MetadataCommand.js";
5
6
  import { NukeCommand } from "./commands/NukeCommand.js";
6
7
  import { PublishCommand } from "./commands/PublishCommand.js";
7
8
  import { UpdateCommand } from "./commands/UpdateCommand.js";
@@ -16,6 +17,7 @@ async function main() {
16
17
  });
17
18
  cli.register(CheckCommand);
18
19
  cli.register(InitCommand);
20
+ cli.register(MetadataCommand);
19
21
  cli.register(NukeCommand);
20
22
  cli.register(PublishCommand);
21
23
  cli.register(UpdateCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "complete-cli",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "A command line tool for bootstrapping TypeScript projects.",
5
5
  "keywords": [
6
6
  "typescript"
@@ -35,16 +35,16 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@zamiell/clack-prompts": "0.10.2",
38
- "chalk": "5.4.1",
38
+ "chalk": "5.5.0",
39
39
  "clipanion": "4.0.0-rc.4",
40
40
  "complete-common": "2.5.0",
41
- "complete-node": "7.4.4-dev.0",
41
+ "complete-node": "7.4.4",
42
42
  "klaw-sync": "7.0.0",
43
43
  "yaml": "2.8.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/klaw-sync": "6.0.5",
47
- "@types/node": "24.1.0",
47
+ "@types/node": "24.2.0",
48
48
  "ts-loader": "9.5.2",
49
49
  "tsconfig-paths-webpack-plugin": "4.2.0",
50
50
  "typescript": "5.8.3",
@@ -0,0 +1,39 @@
1
+ import { Command, Option } from "clipanion";
2
+ import { getPackageRoot, writeFileAsync } from "complete-node";
3
+ import path from "node:path";
4
+
5
+ export class MetadataCommand extends Command {
6
+ static override paths = [["metadata"], ["m"]];
7
+
8
+ // The first positional argument.
9
+ dependencyName = Option.String({
10
+ required: true,
11
+ });
12
+
13
+ reason = Option.String({
14
+ required: false,
15
+ });
16
+
17
+ static override usage = Command.Usage({
18
+ description:
19
+ 'Creates a "package-metadata.json" file to document locked dependencies. (The "update" command will respect the contents of this file.)',
20
+ });
21
+
22
+ async execute(): Promise<void> {
23
+ const packageMetadata = {
24
+ dependencies: {} as Record<string, unknown>,
25
+ };
26
+
27
+ packageMetadata.dependencies[this.dependencyName] = {
28
+ "lock-version": true,
29
+ "lock-reason": this.reason ?? "",
30
+ };
31
+
32
+ const packageRoot = await getPackageRoot();
33
+ const packageMetadataPath = path.join(packageRoot, "package-metadata.json");
34
+ const packageMetadataJSON = JSON.stringify(packageMetadata, undefined, 2);
35
+ await writeFileAsync(packageMetadataPath, packageMetadataJSON);
36
+
37
+ console.log(`Successfully created: ${packageMetadataPath}`);
38
+ }
39
+ }
package/src/main.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  import { Builtins, Cli } from "clipanion";
4
4
  import { CheckCommand } from "./commands/CheckCommand.js";
5
5
  import { InitCommand } from "./commands/InitCommand.js";
6
+ import { MetadataCommand } from "./commands/MetadataCommand.js";
6
7
  import { NukeCommand } from "./commands/NukeCommand.js";
7
8
  import { PublishCommand } from "./commands/PublishCommand.js";
8
9
  import { UpdateCommand } from "./commands/UpdateCommand.js";
@@ -21,6 +22,7 @@ async function main() {
21
22
 
22
23
  cli.register(CheckCommand);
23
24
  cli.register(InitCommand);
25
+ cli.register(MetadataCommand);
24
26
  cli.register(NukeCommand);
25
27
  cli.register(PublishCommand);
26
28
  cli.register(UpdateCommand);