comfy-pr 1.1.0 → 1.2.1

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/package.json +2 -1
  2. package/src/cli.ts +60 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfy-pr",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Make PRs that publishes ComfyUI Custom Nodes to [ComfyUI Registry]( https://registry.comfy.org/ ).",
5
5
  "keywords": [],
6
6
  "license": "ISC",
@@ -10,6 +10,7 @@
10
10
  "url": "https://github.com/Comfy-Org/Comfy-PR"
11
11
  },
12
12
  "bin": {
13
+ "cmpr": "./src/cli.ts",
13
14
  "comfy-pr": "./src/cli.ts",
14
15
  "pr-bot": "./bot/cli.ts",
15
16
  "prbot": "./bot/cli.ts"
package/src/cli.ts CHANGED
@@ -1,40 +1,77 @@
1
1
  #!/usr/bin/env bun
2
- import DIE from "@snomiao/die";
3
2
  import { readFile } from "fs/promises";
4
- import { argv, $ as zx } from "zx";
3
+ import { hideBin } from "yargs/helpers";
4
+ import yargs from "yargs/yargs";
5
5
  import { checkComfyActivated } from "./checkComfyActivated";
6
6
  import { createComfyRegistryPullRequests } from "./createComfyRegistryPullRequests";
7
- zx.verbose = true;
8
-
9
- if (argv.help) {
10
- console.log(
11
- `
12
- bunx comfy-pr --repolist repos.txt one repo per-line
13
- bunx comfy-pr [...GITHUB_REPO_URLS] github repos
14
- bunx cross-env REPO=https://github.com/OWNER/REPO bunx comfy-pr
15
- `.trim(),
16
- );
17
- }
18
-
19
- {
20
- await checkComfyActivated();
21
7
 
8
+ async function resolveRepos(args: {
9
+ repolist?: string;
10
+ _: (string | number)[];
11
+ }): Promise<string[]> {
22
12
  const envRepos =
23
13
  process.env.REPO?.split("\n")
24
14
  .map((e) => e.trim())
25
15
  .filter(Boolean) || [];
26
- const argvRepos = argv._.filter((a) => !a.endsWith(import.meta.filename));
16
+
17
+ const argvRepos = args._.map(String).filter(Boolean);
18
+
27
19
  const listRepos =
28
- (argv.repolist &&
29
- (await readFile(argv.repolist, "utf8").catch(() => ""))
20
+ (args.repolist &&
21
+ (await readFile(args.repolist, "utf8").catch(() => ""))
30
22
  .split("\n")
31
23
  .map((e) => e.trim())
32
24
  .filter(Boolean)) ||
33
25
  [];
34
- const repos = (listRepos.length && listRepos) ||
26
+
27
+ const repos =
28
+ (listRepos.length && listRepos) ||
35
29
  (argvRepos.length && argvRepos) ||
36
- (envRepos.length && envRepos) || [DIE("Missing PR target, please set env.REPO")];
37
- for await (const upstreamUrl of repos) {
38
- await createComfyRegistryPullRequests(upstreamUrl);
30
+ (envRepos.length && envRepos) ||
31
+ [];
32
+
33
+ if (repos.length === 0) {
34
+ console.error("Error: No repos specified. Provide URLs as args, --repolist, or REPO env var.");
35
+ process.exit(1);
39
36
  }
37
+ return repos;
40
38
  }
39
+
40
+ const cli = yargs(hideBin(process.argv))
41
+ .scriptName("cmpr")
42
+ .usage("$0 <command> [options]")
43
+ .command(
44
+ "create [repos..]",
45
+ "Create registry publish PRs for ComfyUI custom nodes",
46
+ (yargs) =>
47
+ yargs
48
+ .positional("repos", {
49
+ describe: "GitHub repository URLs",
50
+ type: "string",
51
+ array: true,
52
+ })
53
+ .option("repolist", {
54
+ alias: "l",
55
+ type: "string",
56
+ describe: "File with one repo URL per line",
57
+ }),
58
+ async (args) => {
59
+ await checkComfyActivated();
60
+ const repos = await resolveRepos({ repolist: args.repolist, _: args.repos || [] });
61
+ for (const url of repos) {
62
+ await createComfyRegistryPullRequests(url);
63
+ }
64
+ },
65
+ )
66
+ .example("$0 create https://github.com/owner/repo", "Create PR for a single repo")
67
+ .example("$0 create --repolist repos.txt", "Create PRs from a file (one URL per line)")
68
+ .example("$0 create url1 url2 url3", "Create PRs for multiple repos")
69
+ .example("REPO=https://github.com/owner/repo $0 create", "Create PR via env variable")
70
+ .demandCommand(1, "Please specify a command. Run with --help to see available commands.")
71
+ .strict()
72
+ .help()
73
+ .alias("h", "help")
74
+ .version()
75
+ .alias("v", "version");
76
+
77
+ await cli.parse();