github-settings-as-code 2.0.1 → 2.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.
- package/dist/cmd/repo-settings.mjs +5 -4
- package/dist/cmd/repo-settings.mjs.map +1 -1
- package/dist/github/actions-settings/api/get-actions-settings.d.mts.map +1 -1
- package/dist/github/actions-settings/api/get-actions-settings.mjs +1 -4
- package/dist/github/actions-settings/api/get-actions-settings.mjs.map +1 -1
- package/dist/github/index.d.mts +0 -1
- package/dist/github/index.d.mts.map +1 -1
- package/dist/github/index.mjs +0 -1
- package/dist/github/index.mjs.map +1 -1
- package/dist/github/pages/api/get-pages-settings.d.mts.map +1 -1
- package/dist/github/pages/api/get-pages-settings.mjs +2 -4
- package/dist/github/pages/api/get-pages-settings.mjs.map +1 -1
- package/dist/github/repository/apply.d.mts.map +1 -1
- package/dist/github/repository/apply.mjs.map +1 -1
- package/dist/github/repository/constants.d.mts +80 -80
- package/dist/github/repository/constants.d.mts.map +1 -1
- package/dist/github/repository/constants.mjs +1 -2
- package/dist/github/repository/constants.mjs.map +1 -1
- package/dist/github/resolve-target-repo.mjs +3 -3
- package/dist/github/resolve-target-repo.mjs.map +1 -1
- package/dist/github/ruleset/constants.d.mts +88 -32
- package/dist/github/ruleset/constants.d.mts.map +1 -1
- package/dist/github/ruleset/constants.mjs +1 -2
- package/dist/github/ruleset/constants.mjs.map +1 -1
- package/dist/github/variables/apply.d.mts.map +1 -1
- package/dist/github/variables/apply.mjs +3 -12
- package/dist/github/variables/apply.mjs.map +1 -1
- package/package.json +16 -13
- package/src/cmd/repo-settings.mts +9 -6
- package/src/github/actions-settings/api/get-actions-settings.mts +1 -8
- package/src/github/index.mts +0 -1
- package/src/github/pages/api/get-pages-settings.mts +2 -6
- package/src/github/repository/apply.mts +2 -1
- package/src/github/repository/constants.mts +1 -5
- package/src/github/resolve-target-repo.mts +3 -3
- package/src/github/ruleset/constants.mts +1 -5
- package/src/github/variables/apply.mts +3 -12
- package/dist/github/upgrade-stale-codec.d.mts +0 -19
- package/dist/github/upgrade-stale-codec.d.mts.map +0 -1
- package/dist/github/upgrade-stale-codec.mjs +0 -20
- package/dist/github/upgrade-stale-codec.mjs.map +0 -1
- package/src/github/upgrade-stale-codec.mts +0 -29
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EndpointKeys } from 'octokit-safe-types';
|
|
2
|
+
import { hasKey, isRecord } from 'ts-data-forge';
|
|
2
3
|
import { octokitHeaders, OWNER, REPO } from '../../constants.mjs';
|
|
3
4
|
import { octokit } from '../../octokit.mjs';
|
|
4
5
|
import { PagesSettings } from '../constants.mjs';
|
|
@@ -21,12 +22,7 @@ export const getPagesSettings = async (): Promise<
|
|
|
21
22
|
// eslint-disable-next-line unicorn/no-array-fill-with-reference-type
|
|
22
23
|
return PagesSettings.fill({ build_type: response.data.build_type });
|
|
23
24
|
} catch (error) {
|
|
24
|
-
if (
|
|
25
|
-
typeof error === 'object' &&
|
|
26
|
-
error !== null &&
|
|
27
|
-
Object.hasOwn(error, 'status') &&
|
|
28
|
-
(error as Readonly<{ status?: unknown }>).status === 404
|
|
29
|
-
) {
|
|
25
|
+
if (isRecord(error) && hasKey(error, 'status') && error.status === 404) {
|
|
30
26
|
return undefined;
|
|
31
27
|
}
|
|
32
28
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
isDirectlyExecuted,
|
|
11
11
|
Result,
|
|
12
12
|
} from 'ts-repo-utils';
|
|
13
|
+
import { type StrictPick } from 'ts-type-forge';
|
|
13
14
|
import { repositorySettingsDir, settingsJsonName } from '../constants.mjs';
|
|
14
15
|
import { getRepositorySettings, updateRepository } from './api/index.mjs';
|
|
15
16
|
import { backupRepositorySettings } from './backup.mjs';
|
|
@@ -52,7 +53,7 @@ export const applyRepositorySettings = async (): Promise<void> => {
|
|
|
52
53
|
// NOTE: "RequestError [HttpError]: Allow forks can only be changed on org-owned repositories"
|
|
53
54
|
// allow_forking: settings.allow_forking,
|
|
54
55
|
web_commit_signoff_required: settings.web_commit_signoff_required,
|
|
55
|
-
} satisfies
|
|
56
|
+
} satisfies StrictPick<UpdateRepositoryRequest, RepositoryKeysToPick>,
|
|
56
57
|
});
|
|
57
58
|
|
|
58
59
|
// update local setting file
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
import { expectType } from 'ts-data-forge';
|
|
6
6
|
import * as t from 'ts-fortress';
|
|
7
7
|
import { type StrictExclude } from 'ts-type-forge';
|
|
8
|
-
import { upgradeStaleCodec } from '../upgrade-stale-codec.mjs';
|
|
9
8
|
|
|
10
9
|
const keysToPickBase = [
|
|
11
10
|
'allow_auto_merge',
|
|
@@ -64,9 +63,6 @@ export type RepositoryKeysToPick = StrictExclude<
|
|
|
64
63
|
|
|
65
64
|
expectType<keyof UpdateRepositoryRequest, RepositoryKeysToPick>('>=');
|
|
66
65
|
|
|
67
|
-
export const RepositoryPicked = t.pick(
|
|
68
|
-
upgradeStaleCodec(FullRepository),
|
|
69
|
-
repositoryKeysToPick,
|
|
70
|
-
);
|
|
66
|
+
export const RepositoryPicked = t.pick(FullRepository, repositoryKeysToPick);
|
|
71
67
|
|
|
72
68
|
export type RepositoryPicked = t.TypeOf<typeof RepositoryPicked>;
|
|
@@ -2,7 +2,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import * as fs from 'node:fs/promises';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import * as util from 'node:util';
|
|
5
|
-
import { hasKey, isRecord, isString, Json } from 'ts-data-forge';
|
|
5
|
+
import { Arr, hasKey, isRecord, isString, Json } from 'ts-data-forge';
|
|
6
6
|
import { Result } from 'ts-repo-utils';
|
|
7
7
|
|
|
8
8
|
export type TargetRepo = Readonly<{
|
|
@@ -12,7 +12,7 @@ export type TargetRepo = Readonly<{
|
|
|
12
12
|
|
|
13
13
|
/** `strict: false` の解析結果は string | boolean | 配列 になりうるため絞り込む。 */
|
|
14
14
|
const pickString = (value: unknown): string | undefined =>
|
|
15
|
-
|
|
15
|
+
value !== '' && isString(value) ? value : undefined;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* コマンドライン引数から `--owner` / `--repo` を読む。
|
|
@@ -21,7 +21,7 @@ const pickString = (value: unknown): string | undefined =>
|
|
|
21
21
|
*/
|
|
22
22
|
const fromCliArgs = (): Partial<TargetRepo> => {
|
|
23
23
|
const { values } = util.parseArgs({
|
|
24
|
-
args: process.argv
|
|
24
|
+
args: Arr.skip(process.argv, 2),
|
|
25
25
|
options: {
|
|
26
26
|
owner: { type: 'string' },
|
|
27
27
|
repo: { type: 'string' },
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
} from 'octokit-safe-types';
|
|
6
6
|
import { expectType } from 'ts-data-forge';
|
|
7
7
|
import * as t from 'ts-fortress';
|
|
8
|
-
import { upgradeStaleCodec } from '../upgrade-stale-codec.mjs';
|
|
9
8
|
|
|
10
9
|
export const rulesetKeysToPick = [
|
|
11
10
|
'id',
|
|
@@ -23,9 +22,6 @@ expectType<keyof UpdateRulesetRequest | 'id', KeysToPick>('=');
|
|
|
23
22
|
|
|
24
23
|
expectType<keyof CreateRulesetRequest, keyof UpdateRulesetRequest>('=');
|
|
25
24
|
|
|
26
|
-
export const RulesetPicked = t.pick(
|
|
27
|
-
upgradeStaleCodec(RepositoryRuleset),
|
|
28
|
-
rulesetKeysToPick,
|
|
29
|
-
);
|
|
25
|
+
export const RulesetPicked = t.pick(RepositoryRuleset, rulesetKeysToPick);
|
|
30
26
|
|
|
31
27
|
export type RulesetPicked = t.TypeOf<typeof RulesetPicked>;
|
|
@@ -9,16 +9,6 @@ import {
|
|
|
9
9
|
|
|
10
10
|
export const applyVariables = async (): Promise<void> => {
|
|
11
11
|
const variables = [
|
|
12
|
-
{
|
|
13
|
-
// noshiro-semantic-release-bot (App ID: 1442563)
|
|
14
|
-
name: 'SEMANTIC_RELEASE_BOT_CLIENT_ID',
|
|
15
|
-
value: 'Iv23liAmv2bgTYTkv2pt',
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
// noshiro-changesets-release-bot (App ID: 1576218)
|
|
19
|
-
name: 'CHANGESETS_RELEASE_BOT_CLIENT_ID',
|
|
20
|
-
value: 'Iv23limuZKrTEcXmN0lp',
|
|
21
|
-
},
|
|
22
12
|
{
|
|
23
13
|
// noshiro-repo-settings-bot (App ID: 4476573)
|
|
24
14
|
// Administration を含む強い権限を持つ。設定の backup / apply 専用。
|
|
@@ -27,8 +17,9 @@ export const applyVariables = async (): Promise<void> => {
|
|
|
27
17
|
},
|
|
28
18
|
{
|
|
29
19
|
// noshiro-repo-automation-bot (App ID: 4478721)
|
|
30
|
-
// Contents / Pull requests
|
|
31
|
-
// sync-agent-config
|
|
20
|
+
// Contents / Pull requests / Issues 権限。PR を作る自動化( pnpm-update /
|
|
21
|
+
// sync-agent-config )と release で共用する。実際に使う権限は各
|
|
22
|
+
// ワークフローの permission-* 入力で絞る。
|
|
32
23
|
name: 'REPO_AUTOMATION_BOT_CLIENT_ID',
|
|
33
24
|
value: 'Iv23lilpiDh0twq2PErv',
|
|
34
25
|
},
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type Type } from 'ts-fortress';
|
|
2
|
-
import { type StrictOmit } from 'ts-type-forge';
|
|
3
|
-
/**
|
|
4
|
-
* Restores the full ts-fortress `Type` interface for codecs imported from
|
|
5
|
-
* octokit-safe-types@1.2.19, whose declaration files were generated against
|
|
6
|
-
* ts-fortress 7 (whose `Type` lacked the `prune` member). The pnpm override in
|
|
7
|
-
* `pnpm-workspace.yaml` resolves ts-fortress >= 11 at runtime, so the codec
|
|
8
|
-
* object itself does have `prune`; only its declared type is stale. This
|
|
9
|
-
* verifies `prune` exists at runtime and rebuilds the codec with the correct
|
|
10
|
-
* type, without unsafe type assertions.
|
|
11
|
-
*
|
|
12
|
-
* TODO: Remove this helper once octokit-safe-types is rebuilt against
|
|
13
|
-
* ts-fortress >= 11.
|
|
14
|
-
*/
|
|
15
|
-
export declare const upgradeStaleCodec: <A>(codec: Readonly<{
|
|
16
|
-
defaultValue: A;
|
|
17
|
-
prune?: Type<A>['prune'];
|
|
18
|
-
}> & StrictOmit<Type<A>, 'defaultValue' | 'prune'>) => Type<A>;
|
|
19
|
-
//# sourceMappingURL=upgrade-stale-codec.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-stale-codec.d.mts","sourceRoot":"","sources":["../../src/github/upgrade-stale-codec.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAC1B,QAAQ,CAAC;IAAE,YAAY,EAAE,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC,GAC5D,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,KAC9C,IAAI,CAAC,CAAC,CAUR,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Restores the full ts-fortress `Type` interface for codecs imported from
|
|
3
|
-
* octokit-safe-types@1.2.19, whose declaration files were generated against
|
|
4
|
-
* ts-fortress 7 (whose `Type` lacked the `prune` member). The pnpm override in
|
|
5
|
-
* `pnpm-workspace.yaml` resolves ts-fortress >= 11 at runtime, so the codec
|
|
6
|
-
* object itself does have `prune`; only its declared type is stale. This
|
|
7
|
-
* verifies `prune` exists at runtime and rebuilds the codec with the correct
|
|
8
|
-
* type, without unsafe type assertions.
|
|
9
|
-
*
|
|
10
|
-
* TODO: Remove this helper once octokit-safe-types is rebuilt against
|
|
11
|
-
* ts-fortress >= 11.
|
|
12
|
-
*/
|
|
13
|
-
export const upgradeStaleCodec = (codec) => {
|
|
14
|
-
const { prune } = codec;
|
|
15
|
-
if (prune === undefined) {
|
|
16
|
-
throw new Error(`The codec "${codec.typeName}" has no prune function at runtime. octokit-safe-types is probably resolving an old ts-fortress version; check the pnpm overrides.`);
|
|
17
|
-
}
|
|
18
|
-
return { ...codec, prune };
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=upgrade-stale-codec.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-stale-codec.mjs","sourceRoot":"","sources":["../../src/github/upgrade-stale-codec.mts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAC+C,EACtC,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAExB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,cAAc,KAAK,CAAC,QAAQ,oIAAoI,CACjK,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type Type } from 'ts-fortress';
|
|
2
|
-
import { type StrictOmit } from 'ts-type-forge';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Restores the full ts-fortress `Type` interface for codecs imported from
|
|
6
|
-
* octokit-safe-types@1.2.19, whose declaration files were generated against
|
|
7
|
-
* ts-fortress 7 (whose `Type` lacked the `prune` member). The pnpm override in
|
|
8
|
-
* `pnpm-workspace.yaml` resolves ts-fortress >= 11 at runtime, so the codec
|
|
9
|
-
* object itself does have `prune`; only its declared type is stale. This
|
|
10
|
-
* verifies `prune` exists at runtime and rebuilds the codec with the correct
|
|
11
|
-
* type, without unsafe type assertions.
|
|
12
|
-
*
|
|
13
|
-
* TODO: Remove this helper once octokit-safe-types is rebuilt against
|
|
14
|
-
* ts-fortress >= 11.
|
|
15
|
-
*/
|
|
16
|
-
export const upgradeStaleCodec = <A,>(
|
|
17
|
-
codec: Readonly<{ defaultValue: A; prune?: Type<A>['prune'] }> &
|
|
18
|
-
StrictOmit<Type<A>, 'defaultValue' | 'prune'>,
|
|
19
|
-
): Type<A> => {
|
|
20
|
-
const { prune } = codec;
|
|
21
|
-
|
|
22
|
-
if (prune === undefined) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
`The codec "${codec.typeName}" has no prune function at runtime. octokit-safe-types is probably resolving an old ts-fortress version; check the pnpm overrides.`,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return { ...codec, prune };
|
|
29
|
-
};
|