github-settings-as-code 1.2.9 → 2.0.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/README.md +60 -9
- package/dist/cmd/{gh-apply-all.d.mts → repo-settings.d.mts} +1 -1
- package/dist/cmd/repo-settings.d.mts.map +1 -0
- package/dist/cmd/repo-settings.mjs +118 -0
- package/dist/cmd/repo-settings.mjs.map +1 -0
- package/dist/github/actions-settings/api/get-actions-settings.d.mts +8 -0
- package/dist/github/actions-settings/api/get-actions-settings.d.mts.map +1 -0
- package/dist/github/actions-settings/api/get-actions-settings.mjs +25 -0
- package/dist/github/actions-settings/api/get-actions-settings.mjs.map +1 -0
- package/dist/github/actions-settings/api/index.d.mts +3 -0
- package/dist/github/actions-settings/api/index.d.mts.map +1 -0
- package/dist/github/actions-settings/api/index.mjs +3 -0
- package/dist/github/actions-settings/api/index.mjs.map +1 -0
- package/dist/github/actions-settings/api/set-actions-settings.d.mts +4 -0
- package/dist/github/actions-settings/api/set-actions-settings.d.mts.map +1 -0
- package/dist/github/actions-settings/api/set-actions-settings.mjs +27 -0
- package/dist/github/actions-settings/api/set-actions-settings.mjs.map +1 -0
- package/dist/github/actions-settings/apply.d.mts +5 -0
- package/dist/github/actions-settings/apply.d.mts.map +1 -0
- package/dist/github/actions-settings/apply.mjs +39 -0
- package/dist/github/actions-settings/apply.mjs.map +1 -0
- package/dist/github/actions-settings/backup.d.mts +5 -0
- package/dist/github/actions-settings/backup.d.mts.map +1 -0
- package/dist/github/actions-settings/backup.mjs +22 -0
- package/dist/github/actions-settings/backup.mjs.map +1 -0
- package/dist/github/actions-settings/constants.d.mts +69 -0
- package/dist/github/actions-settings/constants.d.mts.map +1 -0
- package/dist/github/actions-settings/constants.mjs +42 -0
- package/dist/github/actions-settings/constants.mjs.map +1 -0
- package/dist/github/actions-settings/index.d.mts +5 -0
- package/dist/github/actions-settings/index.d.mts.map +1 -0
- package/dist/github/actions-settings/index.mjs +5 -0
- package/dist/github/actions-settings/index.mjs.map +1 -0
- package/dist/github/constants.d.mts +4 -2
- package/dist/github/constants.d.mts.map +1 -1
- package/dist/github/constants.mjs +7 -31
- package/dist/github/constants.mjs.map +1 -1
- package/dist/github/index.d.mts +4 -0
- package/dist/github/index.d.mts.map +1 -1
- package/dist/github/index.mjs +4 -0
- package/dist/github/index.mjs.map +1 -1
- package/dist/github/octokit.d.mts.map +1 -1
- package/dist/github/octokit.mjs +39 -3
- package/dist/github/octokit.mjs.map +1 -1
- package/dist/github/pages/api/get-pages-settings.d.mts +8 -0
- package/dist/github/pages/api/get-pages-settings.d.mts.map +1 -0
- package/dist/github/pages/api/get-pages-settings.mjs +26 -0
- package/dist/github/pages/api/get-pages-settings.mjs.map +1 -0
- package/dist/github/pages/api/index.d.mts +3 -0
- package/dist/github/pages/api/index.d.mts.map +1 -0
- package/dist/github/pages/api/index.mjs +3 -0
- package/dist/github/pages/api/index.mjs.map +1 -0
- package/dist/github/pages/api/set-pages-settings.d.mts +9 -0
- package/dist/github/pages/api/set-pages-settings.d.mts.map +1 -0
- package/dist/github/pages/api/set-pages-settings.mjs +33 -0
- package/dist/github/pages/api/set-pages-settings.mjs.map +1 -0
- package/dist/github/pages/apply.d.mts +10 -0
- package/dist/github/pages/apply.d.mts.map +1 -0
- package/dist/github/pages/apply.mjs +49 -0
- package/dist/github/pages/apply.mjs.map +1 -0
- package/dist/github/pages/backup.d.mts +5 -0
- package/dist/github/pages/backup.d.mts.map +1 -0
- package/dist/github/pages/backup.mjs +26 -0
- package/dist/github/pages/backup.mjs.map +1 -0
- package/dist/github/pages/constants.d.mts +42 -0
- package/dist/github/pages/constants.d.mts.map +1 -0
- package/dist/github/pages/constants.mjs +14 -0
- package/dist/github/pages/constants.mjs.map +1 -0
- package/dist/github/pages/index.d.mts +5 -0
- package/dist/github/pages/index.d.mts.map +1 -0
- package/dist/github/pages/index.mjs +5 -0
- package/dist/github/pages/index.mjs.map +1 -0
- package/dist/github/repository/api/update-repository.d.mts.map +1 -1
- package/dist/github/repository/apply.d.mts.map +1 -1
- package/dist/github/repository/apply.mjs +4 -4
- package/dist/github/repository/apply.mjs.map +1 -1
- package/dist/github/repository/backup.d.mts.map +1 -1
- package/dist/github/repository/backup.mjs +2 -2
- package/dist/github/repository/backup.mjs.map +1 -1
- package/dist/github/repository/constants.d.mts +3267 -2032
- package/dist/github/repository/constants.d.mts.map +1 -1
- package/dist/github/repository/constants.mjs +2 -1
- package/dist/github/repository/constants.mjs.map +1 -1
- package/dist/github/resolve-target-repo.d.mts +16 -0
- package/dist/github/resolve-target-repo.d.mts.map +1 -0
- package/dist/github/resolve-target-repo.mjs +113 -0
- package/dist/github/resolve-target-repo.mjs.map +1 -0
- package/dist/github/ruleset/api/create-ruleset.d.mts.map +1 -1
- package/dist/github/ruleset/api/get-all-rulesets.d.mts.map +1 -1
- package/dist/github/ruleset/api/get-all-rulesets.mjs.map +1 -1
- package/dist/github/ruleset/api/get-ruleset.d.mts.map +1 -1
- package/dist/github/ruleset/api/update-ruleset.d.mts.map +1 -1
- package/dist/github/ruleset/apply.mjs.map +1 -1
- package/dist/github/ruleset/backup.d.mts.map +1 -1
- package/dist/github/ruleset/backup.mjs.map +1 -1
- package/dist/github/ruleset/constants.d.mts +752 -269
- package/dist/github/ruleset/constants.d.mts.map +1 -1
- package/dist/github/ruleset/constants.mjs +2 -1
- package/dist/github/ruleset/constants.mjs.map +1 -1
- package/dist/github/ruleset/read-rule-set-contents.mjs.map +1 -1
- package/dist/github/upgrade-stale-codec.d.mts +19 -0
- package/dist/github/upgrade-stale-codec.d.mts.map +1 -0
- package/dist/github/upgrade-stale-codec.mjs +20 -0
- package/dist/github/upgrade-stale-codec.mjs.map +1 -0
- package/dist/github/variables/api/create-repo-variable.d.mts.map +1 -1
- package/dist/github/variables/api/update-repo-variable.d.mts.map +1 -1
- package/dist/github/variables/apply.d.mts.map +1 -1
- package/dist/github/variables/apply.mjs +9 -6
- package/dist/github/variables/apply.mjs.map +1 -1
- package/package.json +53 -58
- package/src/cmd/repo-settings.mts +153 -0
- package/src/github/actions-settings/api/get-actions-settings.mts +38 -0
- package/src/github/actions-settings/api/index.mts +2 -0
- package/src/github/actions-settings/api/set-actions-settings.mts +39 -0
- package/src/github/actions-settings/apply.mts +63 -0
- package/src/github/actions-settings/backup.mts +36 -0
- package/src/github/actions-settings/constants.mts +50 -0
- package/src/github/actions-settings/index.mts +4 -0
- package/src/github/constants.mts +9 -42
- package/src/github/index.mts +4 -0
- package/src/github/octokit.mts +47 -3
- package/src/github/pages/api/get-pages-settings.mts +35 -0
- package/src/github/pages/api/index.mts +2 -0
- package/src/github/pages/api/set-pages-settings.mts +47 -0
- package/src/github/pages/apply.mts +73 -0
- package/src/github/pages/backup.mts +44 -0
- package/src/github/pages/constants.mts +16 -0
- package/src/github/pages/index.mts +4 -0
- package/src/github/repository/apply.mts +4 -7
- package/src/github/repository/backup.mts +2 -5
- package/src/github/repository/constants.mts +5 -1
- package/src/github/resolve-target-repo.mts +144 -0
- package/src/github/ruleset/api/get-all-rulesets.mts +3 -6
- package/src/github/ruleset/constants.mts +5 -1
- package/src/github/upgrade-stale-codec.mts +29 -0
- package/src/github/variables/apply.mts +9 -6
- package/dist/cmd/gh-apply-all.d.mts.map +0 -1
- package/dist/cmd/gh-apply-all.mjs +0 -10
- package/dist/cmd/gh-apply-all.mjs.map +0 -1
- package/dist/cmd/gh-backup-all.d.mts +0 -3
- package/dist/cmd/gh-backup-all.d.mts.map +0 -1
- package/dist/cmd/gh-backup-all.mjs +0 -9
- package/dist/cmd/gh-backup-all.mjs.map +0 -1
- package/src/cmd/gh-apply-all.mts +0 -18
- package/src/cmd/gh-backup-all.mts +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/github/ruleset/constants.mts"],"names":[],"mappings":"AAMA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRo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;;;;;;;;;;;;;;;;;;;;;;;;;;EAGzB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RepositoryRuleset, } from 'octokit-safe-types';
|
|
2
2
|
import { expectType } from 'ts-data-forge';
|
|
3
3
|
import * as t from 'ts-fortress';
|
|
4
|
+
import { upgradeStaleCodec } from '../upgrade-stale-codec.mjs';
|
|
4
5
|
export const rulesetKeysToPick = [
|
|
5
6
|
'id',
|
|
6
7
|
'name',
|
|
@@ -12,5 +13,5 @@ export const rulesetKeysToPick = [
|
|
|
12
13
|
];
|
|
13
14
|
expectType('=');
|
|
14
15
|
expectType('=');
|
|
15
|
-
export const RulesetPicked = t.pick(RepositoryRuleset, rulesetKeysToPick);
|
|
16
|
+
export const RulesetPicked = t.pick(upgradeStaleCodec(RepositoryRuleset), rulesetKeysToPick);
|
|
16
17
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/github/ruleset/constants.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/github/ruleset/constants.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI;IACJ,MA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AAC;IAC3B,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,IAAI,kBAAkB,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACxC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-repo-variable.d.mts","sourceRoot":"","sources":["../../../../src/github/variables/api/create-repo-variable.mts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"create-repo-variable.d.mts","sourceRoot":"","sources":["../../../../src/github/variables/api/create-repo-variable.mts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,qBAG5B,QAAQ,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,KAAG,OAAO,CAAC,IAAI,CAahB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-repo-variable.d.mts","sourceRoot":"","sources":["../../../../src/github/variables/api/update-repo-variable.mts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"update-repo-variable.d.mts","sourceRoot":"","sources":["../../../../src/github/variables/api/update-repo-variable.mts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,qBAG5B,QAAQ,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,KAAG,OAAO,CAAC,IAAI,CAahB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.mts","sourceRoot":"","sources":["../../../src/github/variables/apply.mts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AAQvB,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"apply.d.mts","sourceRoot":"","sources":["../../../src/github/variables/apply.mts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AAQvB,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,IAAI,CA8BnD,CAAC"}
|
|
@@ -5,16 +5,19 @@ import { createRepoVariable, listRepoVariables, updateRepoVariable, } from './ap
|
|
|
5
5
|
export const applyVariables = async () => {
|
|
6
6
|
const variables = [
|
|
7
7
|
{
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// noshiro-semantic-release-bot (App ID: 1442563)
|
|
9
|
+
name: 'SEMANTIC_RELEASE_BOT_CLIENT_ID',
|
|
10
|
+
value: 'Iv23liAmv2bgTYTkv2pt',
|
|
10
11
|
},
|
|
11
12
|
{
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
// noshiro-changesets-release-bot (App ID: 1576218)
|
|
14
|
+
name: 'CHANGESETS_RELEASE_BOT_CLIENT_ID',
|
|
15
|
+
value: 'Iv23limuZKrTEcXmN0lp',
|
|
14
16
|
},
|
|
15
17
|
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
// noshiro-repo-settings-bot (App ID: 4476573)
|
|
19
|
+
name: 'REPO_SETTINGS_BOT_CLIENT_ID',
|
|
20
|
+
value: 'Iv23ctr4Lq9H3wOYRQrD',
|
|
18
21
|
},
|
|
19
22
|
];
|
|
20
23
|
const variableListSaved = await listRepoVariables();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.mjs","sourceRoot":"","sources":["../../../src/github/variables/apply.mts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,IAAmB,EAAE;IACtD,MAAM,SAAS,GAAG;QAChB;YACE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"apply.mjs","sourceRoot":"","sources":["../../../src/github/variables/apply.mts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,IAAmB,EAAE;IACtD,MAAM,SAAS,GAAG;QAChB;YACE,iDAAiD;YACjD,IAAI,EAAE,gCAAgC;YACtC,KAAK,EAAE,sBAAsB;SAC9B;QACD;YACE,mDAAmD;YACnD,IAAI,EAAE,kCAAkC;YACxC,KAAK,EAAE,sBAAsB;SAC9B;QACD;YACE,8CAA8C;YAC9C,IAAI,EAAE,6BAA6B;YACnC,KAAK,EAAE,sBAAsB;SAC9B;KACO,CAAC;IAEX,MAAM,iBAAiB,GAAG,MAAM,iBAAiB,EAAE,CAAC;IAEpD,MAAM,cAAc,GAAwB,IAAI,GAAG,CACjD,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CACrC,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEhD,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC,CAAC;AAEF,IAAI,kBAAkB,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACxC,MAAM,cAAc,EAAE,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-settings-as-code",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -15,13 +15,7 @@
|
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"type": "module",
|
|
17
17
|
"bin": {
|
|
18
|
-
"
|
|
19
|
-
"gh-apply-repository-settings": "./dist/github/repository/apply.mjs",
|
|
20
|
-
"gh-apply-rulesets": "./dist/github/ruleset/apply.mjs",
|
|
21
|
-
"gh-apply-variables": "./dist/github/variables/apply.mjs",
|
|
22
|
-
"gh-backup-all": "./dist/cmd/gh-backup-all.mjs",
|
|
23
|
-
"gh-backup-repository-settings": "./dist/github/repository/backup.mjs",
|
|
24
|
-
"gh-backup-rulesets": "./dist/github/ruleset/backup.mjs"
|
|
18
|
+
"repo-settings": "./dist/cmd/repo-settings.mjs"
|
|
25
19
|
},
|
|
26
20
|
"files": [
|
|
27
21
|
"src",
|
|
@@ -30,94 +24,95 @@
|
|
|
30
24
|
"LICENSE"
|
|
31
25
|
],
|
|
32
26
|
"scripts": {
|
|
27
|
+
"agents:gen": "tsx ./scripts/cmd/gen-agents-md.mts",
|
|
28
|
+
"agents:sync": "tsx ./scripts/cmd/sync-agent-config.mts",
|
|
33
29
|
"build": "tsx ./scripts/cmd/build.mts",
|
|
34
30
|
"build:min": "tsx ./scripts/cmd/build.mts --skip-check",
|
|
35
31
|
"check:ext": "tsx ./scripts/cmd/check-ext.mts",
|
|
36
32
|
"check-all": "tsx ./scripts/cmd/check-all.mts",
|
|
37
33
|
"codemod": "run-s codemod:uncommitted:as-const fmt codemod:uncommitted:readonly fmt",
|
|
34
|
+
"codemod:diff": "run-s codemod:diff:as-const fmt codemod:diff:readonly fmt",
|
|
35
|
+
"codemod:diff:as-const": "append-as-const --diff-from origin/main '{src,scripts,samples}/**/*.mts'",
|
|
36
|
+
"codemod:diff:readonly": "convert-to-readonly --diff-from origin/main '{src,scripts,samples}/**/*.mts'",
|
|
38
37
|
"codemod:full": "run-s codemod:full:as-const fmt codemod:full:readonly fmt",
|
|
39
|
-
"codemod:full:as-const": "append-as-const '{src,scripts,samples}/**/*.
|
|
40
|
-
"codemod:full:readonly": "convert-to-readonly '{src,scripts,samples}/**/*.
|
|
41
|
-
"codemod:uncommitted:as-const": "append-as-const --uncommitted '{src,scripts,samples}/**/*.
|
|
42
|
-
"codemod:uncommitted:readonly": "convert-to-readonly --uncommitted '{src,scripts,samples}/**/*.
|
|
43
|
-
"cspell": "cspell \"
|
|
38
|
+
"codemod:full:as-const": "append-as-const '{src,scripts,samples}/**/*.mts'",
|
|
39
|
+
"codemod:full:readonly": "convert-to-readonly '{src,scripts,samples}/**/*.mts'",
|
|
40
|
+
"codemod:uncommitted:as-const": "append-as-const --uncommitted '{src,scripts,samples}/**/*.mts'",
|
|
41
|
+
"codemod:uncommitted:readonly": "convert-to-readonly --uncommitted '{src,scripts,samples}/**/*.mts'",
|
|
42
|
+
"cspell": "cspell \"{**,.changeset/**/*,.github/**/*}\" --gitignore --gitignore-root ./ --no-progress",
|
|
44
43
|
"doc": "tsx ./scripts/cmd/gen-docs.mts",
|
|
45
44
|
"fmt": "format-uncommitted",
|
|
46
45
|
"fmt:diff": "format-diff-from origin/main",
|
|
47
46
|
"fmt:full": "prettier --write .",
|
|
48
|
-
"gh:apply-all": "tsx ./src/cmd/gh-apply-all.mts",
|
|
49
|
-
"gh:apply-repository-settings": "tsx ./src/github/repository/apply.mts",
|
|
50
|
-
"gh:apply-rulesets": "tsx ./src/github/ruleset/apply.mts",
|
|
51
|
-
"gh:apply-variables": "tsx ./src/github/variables/apply.mts",
|
|
52
|
-
"gh:backup-all": "tsx ./src/cmd/gh-backup-all.mts",
|
|
53
|
-
"gh:backup-repository-settings": "tsx ./src/github/repository/backup.mts",
|
|
54
|
-
"gh:backup-rulesets": "tsx ./src/github/ruleset/backup.mts",
|
|
55
47
|
"gi": "run-s gi:src fmt",
|
|
56
48
|
"gi:src": "gen-index-ts ./src/github --index-ext .mts --export-ext .mjs --target-ext .mts --exclude cmd --exclude octokit.mts",
|
|
57
49
|
"lint": "eslint .",
|
|
58
50
|
"lint:fix": "eslint . --fix",
|
|
59
51
|
"md": "markdownlint-cli2",
|
|
52
|
+
"repo-settings:apply": "tsx ./src/cmd/repo-settings.mts apply",
|
|
53
|
+
"repo-settings:backup": "tsx ./src/cmd/repo-settings.mts backup",
|
|
60
54
|
"test": "pnpm run z:vitest:node run",
|
|
61
55
|
"test:cov": "pnpm run z:vitest:node run --coverage",
|
|
62
56
|
"test:cov:ui": "vite preview --outDir ./coverage",
|
|
63
57
|
"test:ui": "pnpm run z:vitest:node --ui",
|
|
64
58
|
"testw": "pnpm run z:vitest:node watch",
|
|
65
|
-
"tsc": "tsc --noEmit",
|
|
66
|
-
"tscw": "tsc --noEmit --watch -p ./tsconfig.json",
|
|
67
|
-
"type-check": "tsc --noEmit",
|
|
68
|
-
"update-packages": "pnpm update --latest",
|
|
59
|
+
"tsc": "node ./node_modules/typescript-native/bin/tsc --noEmit",
|
|
60
|
+
"tscw": "node ./node_modules/typescript-native/bin/tsc --noEmit --watch -p ./tsconfig.json",
|
|
61
|
+
"type-check": "node ./node_modules/typescript-native/bin/tsc --noEmit",
|
|
69
62
|
"z:vitest": "vitest --config ./configs/vitest.config.mts",
|
|
70
63
|
"z:vitest:node": "pnpm run z:vitest --project='Node.js'"
|
|
71
64
|
},
|
|
72
65
|
"dependencies": {
|
|
73
66
|
"@octokit/core": "^7.0.6",
|
|
74
67
|
"dotenv": "^17.4.2",
|
|
75
|
-
"octokit-safe-types": "^1.2.
|
|
76
|
-
"ts-data-forge": "^
|
|
77
|
-
"ts-fortress": "^
|
|
78
|
-
"ts-type-forge": "^
|
|
68
|
+
"octokit-safe-types": "^1.2.19",
|
|
69
|
+
"ts-data-forge": "^12.2.2",
|
|
70
|
+
"ts-fortress": "^11.2.0",
|
|
71
|
+
"ts-type-forge": "^9.1.1"
|
|
79
72
|
},
|
|
80
73
|
"devDependencies": {
|
|
81
|
-
"@semantic-release/changelog": "
|
|
74
|
+
"@semantic-release/changelog": "7.0.0",
|
|
82
75
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
83
76
|
"@semantic-release/exec": "7.1.0",
|
|
84
|
-
"@semantic-release/git": "
|
|
85
|
-
"@semantic-release/github": "12.0.
|
|
77
|
+
"@semantic-release/git": "11.0.1",
|
|
78
|
+
"@semantic-release/github": "12.0.9",
|
|
86
79
|
"@semantic-release/npm": "13.1.5",
|
|
87
|
-
"@semantic-release/release-notes-generator": "14.1.
|
|
88
|
-
"@types/node": "
|
|
89
|
-
"@vitest/coverage-v8": "4.1.
|
|
90
|
-
"@vitest/ui": "4.1.
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"playwright": "1.59.1",
|
|
102
|
-
"prettier": "3.8.3",
|
|
80
|
+
"@semantic-release/release-notes-generator": "14.1.1",
|
|
81
|
+
"@types/node": "26.1.2",
|
|
82
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
83
|
+
"@vitest/ui": "4.1.10",
|
|
84
|
+
"conventional-changelog-conventionalcommits": "10.2.1",
|
|
85
|
+
"cspell": "10.0.1",
|
|
86
|
+
"eslint": "10.8.0",
|
|
87
|
+
"eslint-config-typed": "5.8.2",
|
|
88
|
+
"jiti": "2.7.0",
|
|
89
|
+
"markdownlint": "0.41.1",
|
|
90
|
+
"markdownlint-cli2": "0.23.2",
|
|
91
|
+
"npm-run-all2": "9.0.2",
|
|
92
|
+
"playwright": "1.62.0",
|
|
93
|
+
"prettier": "3.9.6",
|
|
103
94
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
104
95
|
"prettier-plugin-packagejson": "3.0.2",
|
|
105
|
-
"semantic-release": "25.0.
|
|
106
|
-
"ts-codemod-lib": "2.
|
|
107
|
-
"ts-repo-utils": "10.
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"typedoc": "0.28.19",
|
|
96
|
+
"semantic-release": "25.0.8",
|
|
97
|
+
"ts-codemod-lib": "2.2.3",
|
|
98
|
+
"ts-repo-utils": "10.1.6",
|
|
99
|
+
"tsx": "4.23.1",
|
|
100
|
+
"typedoc": "0.28.20",
|
|
111
101
|
"typedoc-github-theme": "0.4.0",
|
|
112
|
-
"typescript": "
|
|
113
|
-
"
|
|
102
|
+
"typescript": "6.0.3",
|
|
103
|
+
"typescript-native": "npm:typescript@7.0.2",
|
|
104
|
+
"vitest": "4.1.10"
|
|
114
105
|
},
|
|
115
|
-
"packageManager": "pnpm@
|
|
106
|
+
"packageManager": "pnpm@11.20.0",
|
|
116
107
|
"engines": {
|
|
117
|
-
"node": ">=22.
|
|
108
|
+
"node": ">=22.22.2",
|
|
118
109
|
"pnpm": ">=9.0.0"
|
|
119
110
|
},
|
|
120
111
|
"volta": {
|
|
121
|
-
"node": "
|
|
112
|
+
"node": "26.3.1"
|
|
113
|
+
},
|
|
114
|
+
"publishConfig": {
|
|
115
|
+
"access": "public",
|
|
116
|
+
"provenance": true
|
|
122
117
|
}
|
|
123
118
|
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import 'dotenv/config';
|
|
4
|
+
import * as util from 'node:util';
|
|
5
|
+
|
|
6
|
+
const HELP = `
|
|
7
|
+
Usage: repo-settings <command> [target] [options]
|
|
8
|
+
|
|
9
|
+
GitHub の repository 設定を JSON ファイルで管理する。
|
|
10
|
+
|
|
11
|
+
Commands:
|
|
12
|
+
apply [target] ローカルの設定ファイルを GitHub に反映する
|
|
13
|
+
backup [target] GitHub の現在値をローカルの bk/ に保存する
|
|
14
|
+
|
|
15
|
+
Targets:
|
|
16
|
+
all すべて(既定)
|
|
17
|
+
repository github/repository-settings/settings.json
|
|
18
|
+
rulesets github/rulesets/*.json
|
|
19
|
+
variables repository variables ( apply のみ )
|
|
20
|
+
actions github/actions-settings/settings.json
|
|
21
|
+
pages github/pages/settings.json
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
--owner <owner> 対象の owner
|
|
25
|
+
--repo <repo> 対象の repository 名
|
|
26
|
+
-h, --help このヘルプを表示する
|
|
27
|
+
|
|
28
|
+
owner / repo は「コマンドライン引数 → 環境変数 OWNER / REPO_NAME →
|
|
29
|
+
git remote origin → package.json の name 」の順で解決される。
|
|
30
|
+
通常は git remote から決まるため、どちらの指定も不要。
|
|
31
|
+
|
|
32
|
+
認証は「環境変数 GITHUB_APP_TOKEN / GH_TOKEN / PERSONAL_ACCESS_TOKEN →
|
|
33
|
+
gh CLI ( gh auth token )」の順で解決される。ローカルでは gh auth login
|
|
34
|
+
だけで動く。
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
repo-settings apply
|
|
38
|
+
repo-settings apply rulesets
|
|
39
|
+
repo-settings backup
|
|
40
|
+
repo-settings apply --owner noshiro-pf --repo ts-repo-utils
|
|
41
|
+
`.trim();
|
|
42
|
+
|
|
43
|
+
const COMMANDS = ['apply', 'backup'] as const;
|
|
44
|
+
|
|
45
|
+
type Command = (typeof COMMANDS)[number];
|
|
46
|
+
|
|
47
|
+
const TARGETS = [
|
|
48
|
+
'all',
|
|
49
|
+
'repository',
|
|
50
|
+
'rulesets',
|
|
51
|
+
'variables',
|
|
52
|
+
'actions',
|
|
53
|
+
'pages',
|
|
54
|
+
] as const;
|
|
55
|
+
|
|
56
|
+
type Target = (typeof TARGETS)[number];
|
|
57
|
+
|
|
58
|
+
const COMMAND_SET: ReadonlySet<string> = new Set(COMMANDS);
|
|
59
|
+
|
|
60
|
+
const isCommand = (value: string): value is Command => COMMAND_SET.has(value);
|
|
61
|
+
|
|
62
|
+
const TARGET_SET: ReadonlySet<string> = new Set(TARGETS);
|
|
63
|
+
|
|
64
|
+
const isTarget = (value: string): value is Target => TARGET_SET.has(value);
|
|
65
|
+
|
|
66
|
+
// NOTE: 明示的な型注釈を変数側に付けることで、呼び出し後に制御フローが到達
|
|
67
|
+
// しないことを TypeScript に認識させる( narrowing のために必要 )。
|
|
68
|
+
const fail: (message: string) => never = (message) => {
|
|
69
|
+
console.error(`❌ ${message}`);
|
|
70
|
+
|
|
71
|
+
console.error('');
|
|
72
|
+
|
|
73
|
+
console.error(HELP);
|
|
74
|
+
|
|
75
|
+
process.exit(1);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { values, positionals } = util.parseArgs({
|
|
79
|
+
args: process.argv.slice(2),
|
|
80
|
+
options: {
|
|
81
|
+
owner: { type: 'string' },
|
|
82
|
+
repo: { type: 'string' },
|
|
83
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
84
|
+
},
|
|
85
|
+
strict: false,
|
|
86
|
+
allowPositionals: true,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (values.help === true || positionals.length === 0) {
|
|
90
|
+
console.log(HELP);
|
|
91
|
+
|
|
92
|
+
process.exit(positionals.length === 0 ? 1 : 0);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const [commandArg, targetArg = 'all'] = positionals;
|
|
96
|
+
|
|
97
|
+
if (commandArg === undefined || !isCommand(commandArg)) {
|
|
98
|
+
fail(`Unknown command: "${commandArg ?? ''}"`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!isTarget(targetArg)) {
|
|
102
|
+
fail(`Unknown target: "${targetArg}"`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// NOTE: ここで初めて設定モジュールを読み込む。 owner / repo の解決は import 時に
|
|
106
|
+
// 走るため、 --help や引数エラーの時点では評価させたくない。
|
|
107
|
+
const github = await import('../github/index.mjs');
|
|
108
|
+
|
|
109
|
+
const runners: Readonly<
|
|
110
|
+
Record<Command, Partial<Record<Target, () => Promise<void>>>>
|
|
111
|
+
> = {
|
|
112
|
+
apply: {
|
|
113
|
+
all: async () => {
|
|
114
|
+
await github.applyVariables();
|
|
115
|
+
|
|
116
|
+
await github.applyRulesets();
|
|
117
|
+
|
|
118
|
+
await github.applyRepositorySettings();
|
|
119
|
+
|
|
120
|
+
await github.applyActionsSettings();
|
|
121
|
+
|
|
122
|
+
await github.applyPagesSettings();
|
|
123
|
+
},
|
|
124
|
+
repository: github.applyRepositorySettings,
|
|
125
|
+
rulesets: github.applyRulesets,
|
|
126
|
+
variables: github.applyVariables,
|
|
127
|
+
actions: github.applyActionsSettings,
|
|
128
|
+
pages: github.applyPagesSettings,
|
|
129
|
+
},
|
|
130
|
+
backup: {
|
|
131
|
+
all: async () => {
|
|
132
|
+
await github.backupRulesets();
|
|
133
|
+
|
|
134
|
+
await github.backupRepositorySettings();
|
|
135
|
+
|
|
136
|
+
await github.backupActionsSettings();
|
|
137
|
+
|
|
138
|
+
await github.backupPagesSettings();
|
|
139
|
+
},
|
|
140
|
+
repository: github.backupRepositorySettings,
|
|
141
|
+
rulesets: github.backupRulesets,
|
|
142
|
+
actions: github.backupActionsSettings,
|
|
143
|
+
pages: github.backupPagesSettings,
|
|
144
|
+
},
|
|
145
|
+
} as const;
|
|
146
|
+
|
|
147
|
+
const runner = runners[commandArg][targetArg];
|
|
148
|
+
|
|
149
|
+
if (runner === undefined) {
|
|
150
|
+
fail(`"${commandArg}" does not support the target "${targetArg}"`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
await runner();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type EndpointKeys } from 'octokit-safe-types';
|
|
2
|
+
import { octokitHeaders, OWNER, REPO } from '../../constants.mjs';
|
|
3
|
+
import { octokit } from '../../octokit.mjs';
|
|
4
|
+
import { ActionsSettings } from '../constants.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Settings > Actions > General の現在値を取得する。
|
|
8
|
+
*
|
|
9
|
+
* 2 つのエンドポイントの結果を 1 つのオブジェクトにまとめる。
|
|
10
|
+
*/
|
|
11
|
+
export const getActionsSettings = async (): Promise<ActionsSettings> => {
|
|
12
|
+
// https://docs.github.com/rest/actions/permissions#get-github-actions-permissions-for-a-repository
|
|
13
|
+
const permissions = await octokit.request(
|
|
14
|
+
'GET /repos/{owner}/{repo}/actions/permissions' satisfies EndpointKeys,
|
|
15
|
+
{ owner: OWNER, repo: REPO, headers: octokitHeaders },
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// https://docs.github.com/rest/actions/permissions#get-fork-pr-contributor-approval-permissions-for-a-repository
|
|
19
|
+
const forkPrApproval = await octokit.request(
|
|
20
|
+
'GET /repos/{owner}/{repo}/actions/permissions/fork-pr-contributor-approval' satisfies EndpointKeys,
|
|
21
|
+
{ owner: OWNER, repo: REPO, headers: octokitHeaders },
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// sha_pinning_required は @octokit/types v16 の型に無いため、レスポンスから
|
|
25
|
+
// 直接読まずに validate 側の既定値へフォールバックさせる。
|
|
26
|
+
const shaPinningRequired: unknown = (
|
|
27
|
+
permissions.data as Readonly<Record<string, unknown>>
|
|
28
|
+
)['sha_pinning_required'];
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line unicorn/no-array-fill-with-reference-type
|
|
31
|
+
return ActionsSettings.fill({
|
|
32
|
+
enabled: permissions.data.enabled,
|
|
33
|
+
allowed_actions: permissions.data.allowed_actions,
|
|
34
|
+
sha_pinning_required:
|
|
35
|
+
typeof shaPinningRequired === 'boolean' ? shaPinningRequired : undefined,
|
|
36
|
+
fork_pr_contributor_approval_policy: forkPrApproval.data.approval_policy,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type EndpointKeys } from 'octokit-safe-types';
|
|
2
|
+
import { octokitHeaders, OWNER, REPO } from '../../constants.mjs';
|
|
3
|
+
import { octokit } from '../../octokit.mjs';
|
|
4
|
+
import { type ActionsSettings } from '../constants.mjs';
|
|
5
|
+
|
|
6
|
+
/** Settings > Actions > General を JSON の内容に合わせる。 */
|
|
7
|
+
export const setActionsSettings = async (
|
|
8
|
+
settings: ActionsSettings,
|
|
9
|
+
): Promise<void> => {
|
|
10
|
+
// https://docs.github.com/rest/actions/permissions#set-github-actions-permissions-for-a-repository
|
|
11
|
+
//
|
|
12
|
+
// NOTE: sha_pinning_required は @octokit/types v16 の型定義にまだ無い。 API は
|
|
13
|
+
// 受け付けるので、いったん変数に束縛して渡している(オブジェクトリテラルを直接
|
|
14
|
+
// 渡すと excess property check に引っかかるため)。型が追随したら不要になる。
|
|
15
|
+
const permissionsParams = {
|
|
16
|
+
owner: OWNER,
|
|
17
|
+
repo: REPO,
|
|
18
|
+
headers: octokitHeaders,
|
|
19
|
+
enabled: settings.enabled,
|
|
20
|
+
allowed_actions: settings.allowed_actions,
|
|
21
|
+
sha_pinning_required: settings.sha_pinning_required,
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
await octokit.request(
|
|
25
|
+
'PUT /repos/{owner}/{repo}/actions/permissions' satisfies EndpointKeys,
|
|
26
|
+
permissionsParams,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// https://docs.github.com/rest/actions/permissions#set-fork-pr-contributor-approval-permissions-for-a-repository
|
|
30
|
+
await octokit.request(
|
|
31
|
+
'PUT /repos/{owner}/{repo}/actions/permissions/fork-pr-contributor-approval' satisfies EndpointKeys,
|
|
32
|
+
{
|
|
33
|
+
owner: OWNER,
|
|
34
|
+
repo: REPO,
|
|
35
|
+
headers: octokitHeaders,
|
|
36
|
+
approval_policy: settings.fork_pr_contributor_approval_policy,
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { validationErrorsToMessages } from 'ts-fortress';
|
|
6
|
+
import {
|
|
7
|
+
formatUncommittedFiles,
|
|
8
|
+
isDirectlyExecuted,
|
|
9
|
+
Result,
|
|
10
|
+
} from 'ts-repo-utils';
|
|
11
|
+
import { actionsSettingsDir, settingsJsonName } from '../constants.mjs';
|
|
12
|
+
import { getActionsSettings, setActionsSettings } from './api/index.mjs';
|
|
13
|
+
import { backupActionsSettings } from './backup.mjs';
|
|
14
|
+
import { ActionsSettings } from './constants.mjs';
|
|
15
|
+
|
|
16
|
+
/** `github/actions-settings/settings.json` を Settings > Actions > General に反映する。 */
|
|
17
|
+
export const applyActionsSettings = async (): Promise<void> => {
|
|
18
|
+
await backupActionsSettings(false);
|
|
19
|
+
|
|
20
|
+
const settings = await readSettings();
|
|
21
|
+
|
|
22
|
+
await setActionsSettings(settings);
|
|
23
|
+
|
|
24
|
+
// 反映後の実際の値でローカルのファイルを更新する
|
|
25
|
+
{
|
|
26
|
+
const applied = await getActionsSettings();
|
|
27
|
+
|
|
28
|
+
const str = JSON.stringify(applied, undefined, 2);
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
31
|
+
await fs.writeFile(path.resolve(actionsSettingsDir, settingsJsonName), str);
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
34
|
+
await fs.writeFile(
|
|
35
|
+
path.resolve(actionsSettingsDir, 'bk', settingsJsonName),
|
|
36
|
+
str,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
await formatUncommittedFiles();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const readSettings = async (): Promise<ActionsSettings> => {
|
|
44
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
45
|
+
const settingsText = await fs.readFile(
|
|
46
|
+
path.resolve(actionsSettingsDir, settingsJsonName),
|
|
47
|
+
{ encoding: 'utf8' },
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const validationResult = ActionsSettings.validate(JSON.parse(settingsText));
|
|
51
|
+
|
|
52
|
+
if (Result.isErr(validationResult)) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
validationErrorsToMessages(validationResult.value).join('\n'),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return validationResult.value;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
if (isDirectlyExecuted(import.meta.url)) {
|
|
62
|
+
await applyActionsSettings();
|
|
63
|
+
}
|