gh-secrets-sync 0.1.3 → 0.1.4

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/dist/cli.mjs +13 -5
  2. package/package.json +14 -15
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import process from 'node:process';
2
2
  import c from 'ansis';
3
3
  import { cac } from 'cac';
4
- import { readFile } from 'node:fs/promises';
4
+ import { writeFile, readFile } from 'node:fs/promises';
5
5
  import * as p from '@clack/prompts';
6
6
  import { join } from 'pathe';
7
7
  import { parse } from 'yaml';
@@ -10,7 +10,7 @@ import Spinner from 'yocto-spinner';
10
10
  import sodium from 'libsodium-wrappers';
11
11
 
12
12
  const name = "gh-secrets-sync";
13
- const version = "0.1.3";
13
+ const version = "0.1.4";
14
14
 
15
15
  const DEFAULT_SYNC_OPTIONS = {
16
16
  config: "./secrets.config.yaml",
@@ -19,6 +19,7 @@ const DEFAULT_SYNC_OPTIONS = {
19
19
  envPrefix: "",
20
20
  apiVersion: "2022-11-28",
21
21
  private: false,
22
+ perPage: 100,
22
23
  baseUrl: "github.com",
23
24
  repo: "",
24
25
  dry: false,
@@ -145,6 +146,7 @@ async function getRepos(config) {
145
146
  config,
146
147
  async () => {
147
148
  const { status, data } = await octokit.request(url, {
149
+ per_page: config.perPage,
148
150
  headers: {
149
151
  "X-GitHub-Api-Version": config.apiVersion
150
152
  }
@@ -152,6 +154,7 @@ async function getRepos(config) {
152
154
  if (status !== 200) {
153
155
  throw new Error(`HTTP ${status}: ${JSON.stringify(data)}`);
154
156
  }
157
+ await writeFile("repos.json", JSON.stringify(data, null, 2));
155
158
  return data;
156
159
  }
157
160
  );
@@ -242,12 +245,17 @@ async function resolveConfig(options) {
242
245
  }
243
246
  async function resolveRepoPatterns(options) {
244
247
  const filter = createRegexFilter(options.repos, "full_name");
245
- let repos = (await getRepos(options)).filter((i) => filter(i) && (options.private || !i.private)).filter((i) => options.fork || !i.fork).map((i) => i.full_name);
248
+ const repositories = await getRepos(options);
249
+ let repos = repositories.filter((i) => filter(i) && (options.private || !i.private)).filter((i) => options.fork || !i.fork).map((i) => i.full_name);
246
250
  if (repos.length) {
247
251
  repos = [.../* @__PURE__ */ new Set([...options.repos, ...repos])];
248
252
  }
249
253
  repos = repos.filter((i) => !i.includes("*"));
250
- if (options.yes || !repos.length) {
254
+ if (!repos.length) {
255
+ p.outro(c.red("No repos found"));
256
+ process.exit(1);
257
+ }
258
+ if (options.yes) {
251
259
  options.repos = repos;
252
260
  return;
253
261
  }
@@ -295,7 +303,7 @@ async function resolveSecretPatterns(options) {
295
303
 
296
304
  try {
297
305
  const cli = cac("gh-secrets-sync");
298
- cli.command("").option("--config <config>", "secrets config file", { default: "./secrets.config.yaml" }).option("--secrets <secrets...>", "secrets name to sync", { default: [] }).option("--token <token>", "GitHub token").option("--api-version <version>", "GitHub API version", { default: "2022-11-28" }).option("--private", "Detect private repositories", { default: false }).option("--fork", "Detect forked repositories", { default: false }).option("--env-prefix <prefix>", "environment variable prefix", { default: "" }).option("--repo <repo>", "central GitHub repository").option("--strict", "Throw error if secret is not found in the environment variables", { default: true }).option("--yes", "Prompt to confirm resolved matches when regex patterns are used in repos or secrets", { default: false }).option("--dry", "Dry run", { default: false }).allowUnknownOptions().action(async (options) => {
306
+ cli.command("").option("--config <config>", "secrets config file", { default: "./secrets.config.yaml" }).option("--secrets <secrets...>", "secrets name to sync", { default: [] }).option("--token <token>", "GitHub token").option("--api-version <version>", "GitHub API version", { default: "2022-11-28" }).option("--private", "Detect private repositories", { default: false }).option("--fork", "Detect forked repositories", { default: false }).option("--per-page <count>", "GitHub API per page count", { default: 100 }).option("--env-prefix <prefix>", "environment variable prefix", { default: "" }).option("--repo <repo>", "central GitHub repository").option("--strict", "Throw error if secret is not found in the environment variables", { default: true }).option("--yes", "Prompt to confirm resolved matches when regex patterns are used in repos or secrets", { default: false }).option("--dry", "Dry run", { default: false }).allowUnknownOptions().action(async (options) => {
299
307
  console.log(`${c.yellow(name)} ${c.dim(`v${version}`)}`);
300
308
  console.log();
301
309
  const config = await resolveConfig(options);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gh-secrets-sync",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.4",
5
5
  "description": "CLI tool to batch sync GitHub Actions secrets across multiple repositories.",
6
6
  "author": "jinghaihan",
7
7
  "license": "MIT",
@@ -36,8 +36,8 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@clack/prompts": "^0.11.0",
39
- "@octokit/core": "^7.0.3",
40
- "ansis": "^4.1.0",
39
+ "@octokit/core": "^7.0.6",
40
+ "ansis": "^4.2.0",
41
41
  "cac": "^6.7.14",
42
42
  "execa": "^9.6.0",
43
43
  "libsodium-wrappers": "^0.7.15",
@@ -46,19 +46,19 @@
46
46
  "yocto-spinner": "^1.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@antfu/eslint-config": "^5.2.1",
49
+ "@antfu/eslint-config": "^6.2.0",
50
50
  "@types/libsodium-wrappers": "^0.7.14",
51
- "@types/node": "^24.3.0",
52
- "bumpp": "^10.2.3",
53
- "eslint": "^9.33.0",
54
- "lint-staged": "^16.1.5",
55
- "pncat": "^0.4.2",
51
+ "@types/node": "^24.10.0",
52
+ "bumpp": "^10.3.1",
53
+ "eslint": "^9.39.1",
54
+ "lint-staged": "^16.2.6",
55
+ "pncat": "^0.7.4",
56
56
  "simple-git-hooks": "^2.13.1",
57
- "taze": "^19.3.0",
58
- "tsx": "^4.20.4",
59
- "typescript": "^5.9.2",
57
+ "taze": "^19.9.0",
58
+ "tsx": "^4.20.6",
59
+ "typescript": "^5.9.3",
60
60
  "unbuild": "^3.6.1",
61
- "vitest": "^3.2.4"
61
+ "vitest": "^4.0.8"
62
62
  },
63
63
  "simple-git-hooks": {
64
64
  "pre-commit": "pnpm lint-staged"
@@ -75,7 +75,6 @@
75
75
  "deps": "taze major -I",
76
76
  "release": "bumpp && pnpm publish --no-git-checks",
77
77
  "catalog": "pncat",
78
- "bootstrap": "pnpm install",
79
- "preinstall": "npx only-allow pnpm"
78
+ "bootstrap": "pnpm install"
80
79
  }
81
80
  }