@ryusenkei/conventions 0.8.0 → 0.8.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.
package/README.md CHANGED
@@ -55,7 +55,7 @@ The PreToolUse hook blocks the call and tells Claude why, so Claude can fix it a
55
55
  | PR title = squash commit message | Checks `gh pr create` / `gh pr edit` titles with prose-lint's commit rules |
56
56
  | No AI signature | `attribution` is empty, and the hook blocks PR bodies with an AI signature |
57
57
  | Squash merge | Blocks `gh pr merge --rebase`, and `--merge` except for a `dev/*` → `main` PR with the epic flow, which must use `--merge` |
58
- | Merge only after CI passes | Blocks `gh pr merge` unless every check of the PR has passed (`gh pr checks`). Pending, failed, missing, or unreadable checks are blocked, also with `--auto`. A PR may have no checks only when the repository has no workflow that runs on `pull_request` (the pre-push `pnpm check` is the gate), or with the epic flow when it targets `dev/*`. Right after a push, the checks may not be registered yet, so the hook points to `gh pr checks --watch` |
58
+ | Merge only after CI passes | Blocks `gh pr merge` unless every check of the PR has passed (`gh pr checks`). Pending, failed, missing, or unreadable checks are blocked, also with `--auto`. A PR may have no checks only when the repository has no enabled workflow that runs on `pull_request` (workflows disabled on GitHub with `gh workflow disable` don't count; the pre-push `pnpm check` is the gate), or with the epic flow when it targets `dev/*`. Right after a push, the checks may not be registered yet, so the hook points to `gh pr checks --watch` |
59
59
  | Epic flow (opt-in) | See [Epic flow](#epic-flow) |
60
60
  | Do not edit `node_modules` | Blocks Edit and Write under `node_modules` |
61
61
  | Secrets | `permissions.deny` blocks reading `.env` and `.dev.vars` with Claude's file tools (not Bash) |
@@ -186,6 +186,7 @@ jobs:
186
186
  | `reusable-ci.yaml` | Checkout (full history), mise, pnpm, `pnpm install --frozen-lockfile`, `pnpm typecheck`, `pnpm test`, `pnpm lint:prose`, the `checks` input, the PR title with prose-lint's commit rules (not for Dependabot), and a gitleaks scan with `.gitleaks.toml` |
187
187
  | `reusable-pr-title.yaml` | Re-checks the PR title when it is edited, with the `@ryusenkei/prose-lint` version from `package.json` and no install |
188
188
 
189
+ - `terraform`: space-separated directories to check with `terraform fmt -check` and `validate` (no backend, so no credentials). Terraform comes from the caller's `mise.toml`.
189
190
  - Language jobs (Go, Rust) stay in the calling workflow as extra jobs.
190
191
  - PR title edits run in their own workflow. In the same workflow, the later `edited` run would overwrite the `ci` job's result with "skipped" and hide a failure.
191
192
  - `@main` follows toolkit's `main`, so fixes reach every repository at once. A breaking change gets a new file name instead of changing these.
package/dist/hook.js CHANGED
@@ -70,15 +70,28 @@ function prBase(pr, cwd) {
70
70
  const r = spawnSync('gh', ['pr', 'view', ...(pr ? [pr] : []), '--json', 'baseRefName', '--jq', '.baseRefName'], { cwd: cwd ?? root, encoding: 'utf8' });
71
71
  return (r.status === 0 && r.stdout.trim()) || undefined;
72
72
  }
73
+ // GitHub で無効にしたワークフローはチェックを出さない → 有効なものだけを数える
73
74
  // 読めなければ「ある」とみなす(チェックなしのマージを許可しない側に倒す)
74
75
  function hasPrWorkflow(cwd) {
75
76
  const dir = join(repoRoot(cwd) ?? root, '.github', 'workflows');
77
+ let files;
76
78
  try {
77
- return readdirSync(dir).some((f) => /\.ya?ml$/.test(f) && /^\s*pull_request(_target)?\s*:|^on:.*\bpull_request/m.test(readFileSync(join(dir, f), 'utf8')));
79
+ files = readdirSync(dir).filter((f) => /\.ya?ml$/.test(f) && /^\s*pull_request(_target)?\s*:|^on:.*\bpull_request/m.test(readFileSync(join(dir, f), 'utf8')));
78
80
  }
79
81
  catch (e) {
80
82
  return e.code !== 'ENOENT';
81
83
  }
84
+ if (files.length === 0)
85
+ return false;
86
+ const r = spawnSync('gh', ['workflow', 'list', '--all', '--json', 'path,state'], { cwd: cwd ?? root, encoding: 'utf8' });
87
+ try {
88
+ const states = new Map(JSON.parse(r.stdout).map((w) => [w.path, w.state]));
89
+ // GitHub にまだないファイル(未 push)は有効とみなす
90
+ return files.some((f) => (states.get(`.github/workflows/${f}`) ?? 'active') === 'active');
91
+ }
92
+ catch {
93
+ return true;
94
+ }
82
95
  }
83
96
  // `gh pr checks` は実行中・失敗で終了コードが0以外(8・1)→ 終了コードではなく出力で判定
84
97
  function prChecks(pr, cwd) {
package/dist/policy.d.ts CHANGED
@@ -24,7 +24,7 @@ export type Context = {
24
24
  prHead: (pr: string | undefined, cwd: string | undefined) => string | undefined;
25
25
  /** PR の base のブランチ(`pr` の省略時は現在のブランチの PR) */
26
26
  prBase: (pr: string | undefined, cwd: string | undefined) => string | undefined;
27
- /** PR で動くワークフロー(`pull_request`)がリポにあるか */
27
+ /** PR で動くワークフロー(`pull_request`)のうち、GitHub で有効なものがリポにあるか */
28
28
  hasPrWorkflow: (cwd: string | undefined) => boolean;
29
29
  /** PR のチェックの集計(`pr` の省略時は現在のブランチの PR) */
30
30
  prChecks: (pr: string | undefined, cwd: string | undefined) => Checks;
package/dist/policy.js CHANGED
@@ -251,7 +251,7 @@ function mergeReasons(args, st, ctx) {
251
251
  const checks = ctx.prChecks(pr, cwd);
252
252
  if (checks === 'pass')
253
253
  return [];
254
- // PR で動くワークフローがないリポ: CI の代わりに pre-push の `pnpm check` が関門
254
+ // PR で動く有効なワークフローがないリポ: CI の代わりに pre-push の `pnpm check` が関門
255
255
  if (checks === 'none' && !ctx.hasPrWorkflow(cwd))
256
256
  return [];
257
257
  if (checks === 'none' && epicFlow(st, ctx)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryusenkei/conventions",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "RYUSENKEI のモノリポの共通の規約(Claude Code の規約・hook、共通ファイルの同期)",
5
5
  "license": "MIT",
6
6
  "author": "RYUSENKEI",