@fairgarden/distribution 0.1.0-0.canary.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 +97 -0
- package/dist/add-module.d.ts +62 -0
- package/dist/add-module.d.ts.map +1 -0
- package/dist/add-module.js +279 -0
- package/dist/add-module.js.map +1 -0
- package/dist/calver.d.ts +65 -0
- package/dist/calver.d.ts.map +1 -0
- package/dist/calver.js +115 -0
- package/dist/calver.js.map +1 -0
- package/dist/canary.d.ts +58 -0
- package/dist/canary.d.ts.map +1 -0
- package/dist/canary.js +130 -0
- package/dist/canary.js.map +1 -0
- package/dist/changelog.d.ts +111 -0
- package/dist/changelog.d.ts.map +1 -0
- package/dist/changelog.js +285 -0
- package/dist/changelog.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1076 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-edit.d.ts +18 -0
- package/dist/config-edit.d.ts.map +1 -0
- package/dist/config-edit.js +166 -0
- package/dist/config-edit.js.map +1 -0
- package/dist/extends.d.ts +60 -0
- package/dist/extends.d.ts.map +1 -0
- package/dist/extends.js +173 -0
- package/dist/extends.js.map +1 -0
- package/dist/extract.d.ts +31 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/extract.js +177 -0
- package/dist/extract.js.map +1 -0
- package/dist/forks.d.ts +116 -0
- package/dist/forks.d.ts.map +1 -0
- package/dist/forks.js +357 -0
- package/dist/forks.js.map +1 -0
- package/dist/git-url.d.ts +19 -0
- package/dist/git-url.d.ts.map +1 -0
- package/dist/git-url.js +55 -0
- package/dist/git-url.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/inherit.d.ts +18 -0
- package/dist/inherit.d.ts.map +1 -0
- package/dist/inherit.js +84 -0
- package/dist/inherit.js.map +1 -0
- package/dist/manifest.d.ts +43 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +64 -0
- package/dist/manifest.js.map +1 -0
- package/dist/overrides.d.ts +32 -0
- package/dist/overrides.d.ts.map +1 -0
- package/dist/overrides.js +81 -0
- package/dist/overrides.js.map +1 -0
- package/dist/policy.d.ts +86 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +269 -0
- package/dist/policy.js.map +1 -0
- package/dist/readme.d.ts +60 -0
- package/dist/readme.d.ts.map +1 -0
- package/dist/readme.js +304 -0
- package/dist/readme.js.map +1 -0
- package/dist/release.d.ts +164 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +454 -0
- package/dist/release.js.map +1 -0
- package/dist/scaffold.d.ts +45 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +492 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/submodules.d.ts +144 -0
- package/dist/submodules.d.ts.map +1 -0
- package/dist/submodules.js +315 -0
- package/dist/submodules.js.map +1 -0
- package/dist/workflows.d.ts +102 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +710 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this repository ships modules, as opposed to being one.
|
|
3
|
+
*
|
|
4
|
+
* Read from `.gitmodules`, which is committed, rather than from
|
|
5
|
+
* {@link submodules}, which only reports checkouts that are actually there. A
|
|
6
|
+
* clone made without `--recurse-submodules` has the file and none of the
|
|
7
|
+
* checkouts, and treating that as a module would write a module's readme over
|
|
8
|
+
* the distribution's and let it be released as if it were one.
|
|
9
|
+
*/
|
|
10
|
+
export declare const isDistribution: (root: string) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Submodules that are missing their checkout.
|
|
13
|
+
*
|
|
14
|
+
* Anything that reads a module's own package.json needs to say so rather than
|
|
15
|
+
* quietly leave it out.
|
|
16
|
+
*/
|
|
17
|
+
export declare const uninitialised: (root: string) => string[];
|
|
18
|
+
/** The repository holding the submodules, which is not the monolith directory. */
|
|
19
|
+
export declare const repositoryRoot: (from: string) => string | undefined;
|
|
20
|
+
export interface Submodule {
|
|
21
|
+
/** Last path segment, which is what you name on the command line. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** The section name in .gitmodules, which is what config reads and writes. */
|
|
24
|
+
configName: string;
|
|
25
|
+
/** Path as recorded in .gitmodules, relative to the repository. */
|
|
26
|
+
relativePath: string;
|
|
27
|
+
path: string;
|
|
28
|
+
url: string;
|
|
29
|
+
/**
|
|
30
|
+
* Where a fork was forked from, recorded as `submodule.<name>.upstream` in
|
|
31
|
+
* .gitmodules. Git ignores the key; this is what reads it. Undefined for a
|
|
32
|
+
* module checked out from its own repository.
|
|
33
|
+
*/
|
|
34
|
+
upstream: string | undefined;
|
|
35
|
+
/** The commit the repository has pinned. */
|
|
36
|
+
pinned: string;
|
|
37
|
+
}
|
|
38
|
+
/** The remote a fork's checkout fetches its upstream from. */
|
|
39
|
+
export declare const UPSTREAM = "upstream";
|
|
40
|
+
/** Read one key of a submodule's section in .gitmodules. */
|
|
41
|
+
export declare const gitmodulesGet: (root: string, configName: string, key: string) => string | undefined;
|
|
42
|
+
/** Write, or with `undefined` remove, one key of a submodule's section in .gitmodules. */
|
|
43
|
+
export declare const gitmodulesSet: (root: string, configName: string, key: string, value: string | undefined) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Point a fork's checkout at its upstream, as a remote of its own.
|
|
46
|
+
*
|
|
47
|
+
* Every clone of the distribution has the fork's url as `origin`, from
|
|
48
|
+
* .gitmodules; the upstream is only recorded there, so each checkout adds the
|
|
49
|
+
* remote the first time it is needed.
|
|
50
|
+
*/
|
|
51
|
+
export declare const ensureUpstreamRemote: (cwd: string, url: string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Whether `base` already has everything `head` changes since they parted.
|
|
54
|
+
*
|
|
55
|
+
* Answered by merging one into the other without touching the checkout: when
|
|
56
|
+
* the result is `base` exactly, `head` has nothing `base` lacks. That holds
|
|
57
|
+
* however upstream took the changes — merged, rebased or squashed — which is
|
|
58
|
+
* what matters before dropping a fork. A conflict, or anything left over,
|
|
59
|
+
* counts as not.
|
|
60
|
+
*/
|
|
61
|
+
export declare const containsAll: (cwd: string, base: string, head: string) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Submodules as `.gitmodules` records them, with the commit each is pinned to.
|
|
64
|
+
*
|
|
65
|
+
* Uninitialised submodules are left out — there is nothing to inspect until
|
|
66
|
+
* they are checked out.
|
|
67
|
+
*/
|
|
68
|
+
export declare const submodules: (root: string) => Submodule[];
|
|
69
|
+
/** How a fork stands against the repository it was forked from. */
|
|
70
|
+
export interface ForkState {
|
|
71
|
+
upstream: string;
|
|
72
|
+
/** Commits the fork has that upstream does not, merges and equivalent patches aside. */
|
|
73
|
+
ahead: number;
|
|
74
|
+
/**
|
|
75
|
+
* The oldest upstream release, from the pinned one on, that has everything
|
|
76
|
+
* the fork adds — or the upstream branch, when only that has it yet.
|
|
77
|
+
* Undefined while upstream has not taken all of it.
|
|
78
|
+
*/
|
|
79
|
+
merged: string | undefined;
|
|
80
|
+
}
|
|
81
|
+
export type ReleaseKind = 'major' | 'minor' | 'patch';
|
|
82
|
+
export interface SubmoduleState {
|
|
83
|
+
submodule: Submodule;
|
|
84
|
+
/** The commit checked out right now, which a bump changes. */
|
|
85
|
+
head: string;
|
|
86
|
+
/** Version pinned right now, when a tag names it. */
|
|
87
|
+
current: string | undefined;
|
|
88
|
+
/** Whether that tag is the pinned commit rather than an ancestor of it. */
|
|
89
|
+
exact: boolean;
|
|
90
|
+
/** Newer version tags, newest first. */
|
|
91
|
+
available: string[];
|
|
92
|
+
/** The newest upgrade of each kind that is available. */
|
|
93
|
+
upgrades: Partial<Record<ReleaseKind, string>>;
|
|
94
|
+
/** Commits on the tracked branch that no version tag covers yet. */
|
|
95
|
+
untagged: number;
|
|
96
|
+
/** Uncommitted changes, which make moving the pin unsafe. */
|
|
97
|
+
dirty: boolean;
|
|
98
|
+
/** Whether the remote was reachable, when a fetch was attempted. */
|
|
99
|
+
fetched: boolean | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Whether the pinned commit is on the remote, so other clones can check it
|
|
102
|
+
* out. Only known after a fetch.
|
|
103
|
+
*/
|
|
104
|
+
pushed: boolean | undefined;
|
|
105
|
+
/** Set for a fork, which also takes releases from its upstream. */
|
|
106
|
+
fork: ForkState | undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Compare a submodule's pinned commit against the versions its repository has.
|
|
110
|
+
*
|
|
111
|
+
* Only tags that name a version are considered an upgrade. Commits past the
|
|
112
|
+
* newest tag are counted and reported, but never bumped to — a commit carries
|
|
113
|
+
* no statement about what changed, which is the whole point of the version.
|
|
114
|
+
*/
|
|
115
|
+
export declare const inspect: (submodule: Submodule, { fetch }?: {
|
|
116
|
+
fetch?: boolean;
|
|
117
|
+
}) => SubmoduleState;
|
|
118
|
+
/**
|
|
119
|
+
* The version a bump should move to, or undefined when there is nothing to do.
|
|
120
|
+
*
|
|
121
|
+
* Major upgrades are held back unless asked for: they are the ones that need a
|
|
122
|
+
* person to read a changelog first.
|
|
123
|
+
*/
|
|
124
|
+
export declare const target: (state: SubmoduleState, { major }?: {
|
|
125
|
+
major?: boolean;
|
|
126
|
+
}) => string | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Record a different URL for a submodule.
|
|
129
|
+
*
|
|
130
|
+
* `.gitmodules` is what gets committed, and `submodule sync` copies it into the
|
|
131
|
+
* local config so the existing checkout uses it too. The caller commits.
|
|
132
|
+
*/
|
|
133
|
+
export declare const setUrl: (root: string, submodule: Submodule, url: string) => void;
|
|
134
|
+
/**
|
|
135
|
+
* Whether a remote can be read with no credentials at all.
|
|
136
|
+
*
|
|
137
|
+
* This is the question a build host asks. Prompting is disabled so a private
|
|
138
|
+
* repository fails immediately instead of waiting for a password nobody is
|
|
139
|
+
* there to type.
|
|
140
|
+
*/
|
|
141
|
+
export declare const isPublic: (url: string, timeout?: number) => boolean;
|
|
142
|
+
/** Move a submodule's checkout to a tag. The caller commits the new pointer. */
|
|
143
|
+
export declare const moveTo: (submodule: Submodule, tag: string) => void;
|
|
144
|
+
//# sourceMappingURL=submodules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submodules.d.ts","sourceRoot":"","sources":["../src/submodules.ts"],"names":[],"mappings":"AAqBA;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,OAEyC,CAAA;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAAM,EAOlD,CAAA;AAED,kFAAkF;AAClF,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SACV,CAAA;AAE7C,MAAM,WAAW,SAAS;IACxB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAA;IACZ,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAA;IAClB,mEAAmE;IACnE,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAA;CACf;AAED,8DAA8D;AAC9D,eAAO,MAAM,QAAQ,aAAa,CAAA;AAElC,4DAA4D;AAC5D,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,YAAY,MAAM,EAAE,KAAK,MAAM,KAAG,MAAM,GAAG,SACiB,CAAA;AAExG,0FAA0F;AAC1F,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,YAAY,MAAM,EAClB,KAAK,MAAM,EACX,OAAO,MAAM,GAAG,SAAS,KACxB,IASF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAA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ED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GACjB,OAAO,cAAc,EACrB,YAAmB;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,KAC1C,MAAM,GAAG,SASX,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,EAAE,WAAW,SAAS,EAAE,KAAK,MAAM,KAAG,IAYxE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,gBAAgB,KAAG,OAoBxD,CAAA;AAED,gFAAgF;AAChF,eAAO,MAAM,MAAM,GAAI,WAAW,SAAS,EAAE,KAAK,MAAM,KAAG,IAa1D,CAAA"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
/** Run git, returning undefined rather than throwing when it fails. */
|
|
6
|
+
const git = (cwd, args) => {
|
|
7
|
+
try {
|
|
8
|
+
return execFileSync('git', args, {
|
|
9
|
+
cwd,
|
|
10
|
+
encoding: 'utf8',
|
|
11
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
12
|
+
}).trim();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const lines = (value) => value ? value.split('\n').filter(Boolean) : [];
|
|
19
|
+
/**
|
|
20
|
+
* Whether this repository ships modules, as opposed to being one.
|
|
21
|
+
*
|
|
22
|
+
* Read from `.gitmodules`, which is committed, rather than from
|
|
23
|
+
* {@link submodules}, which only reports checkouts that are actually there. A
|
|
24
|
+
* clone made without `--recurse-submodules` has the file and none of the
|
|
25
|
+
* checkouts, and treating that as a module would write a module's readme over
|
|
26
|
+
* the distribution's and let it be released as if it were one.
|
|
27
|
+
*/
|
|
28
|
+
export const isDistribution = (root) => existsSync(path.join(root, '.gitmodules')) &&
|
|
29
|
+
(git(root, ['config', '--file', '.gitmodules', '--get-regexp', 'path']) ?? '') !== '';
|
|
30
|
+
/**
|
|
31
|
+
* Submodules that are missing their checkout.
|
|
32
|
+
*
|
|
33
|
+
* Anything that reads a module's own package.json needs to say so rather than
|
|
34
|
+
* quietly leave it out.
|
|
35
|
+
*/
|
|
36
|
+
export const uninitialised = (root) => {
|
|
37
|
+
const config = git(root, ['config', '--file', '.gitmodules', '--get-regexp', 'path']);
|
|
38
|
+
return lines(config)
|
|
39
|
+
.map((line) => line.split(' ')[1])
|
|
40
|
+
.filter((relativePath) => Boolean(relativePath))
|
|
41
|
+
.filter((relativePath) => !existsSync(path.join(root, relativePath, '.git')));
|
|
42
|
+
};
|
|
43
|
+
/** The repository holding the submodules, which is not the monolith directory. */
|
|
44
|
+
export const repositoryRoot = (from) => git(from, ['rev-parse', '--show-toplevel']);
|
|
45
|
+
/** The remote a fork's checkout fetches its upstream from. */
|
|
46
|
+
export const UPSTREAM = 'upstream';
|
|
47
|
+
/** Read one key of a submodule's section in .gitmodules. */
|
|
48
|
+
export const gitmodulesGet = (root, configName, key) => git(root, ['config', '--file', '.gitmodules', '--get', `submodule.${configName}.${key}`]) || undefined;
|
|
49
|
+
/** Write, or with `undefined` remove, one key of a submodule's section in .gitmodules. */
|
|
50
|
+
export const gitmodulesSet = (root, configName, key, value) => {
|
|
51
|
+
const name = `submodule.${configName}.${key}`;
|
|
52
|
+
if (value === undefined) {
|
|
53
|
+
git(root, ['config', '--file', '.gitmodules', '--unset', name]);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (git(root, ['config', '--file', '.gitmodules', name, value]) === undefined) {
|
|
57
|
+
throw new Error(`Could not write ${name} to .gitmodules.`);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Point a fork's checkout at its upstream, as a remote of its own.
|
|
62
|
+
*
|
|
63
|
+
* Every clone of the distribution has the fork's url as `origin`, from
|
|
64
|
+
* .gitmodules; the upstream is only recorded there, so each checkout adds the
|
|
65
|
+
* remote the first time it is needed.
|
|
66
|
+
*/
|
|
67
|
+
export const ensureUpstreamRemote = (cwd, url) => {
|
|
68
|
+
const current = git(cwd, ['remote', 'get-url', UPSTREAM]);
|
|
69
|
+
if (current === url)
|
|
70
|
+
return;
|
|
71
|
+
git(cwd, current === undefined ? ['remote', 'add', UPSTREAM, url] : ['remote', 'set-url', UPSTREAM, url]);
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Whether `base` already has everything `head` changes since they parted.
|
|
75
|
+
*
|
|
76
|
+
* Answered by merging one into the other without touching the checkout: when
|
|
77
|
+
* the result is `base` exactly, `head` has nothing `base` lacks. That holds
|
|
78
|
+
* however upstream took the changes — merged, rebased or squashed — which is
|
|
79
|
+
* what matters before dropping a fork. A conflict, or anything left over,
|
|
80
|
+
* counts as not.
|
|
81
|
+
*/
|
|
82
|
+
export const containsAll = (cwd, base, head) => {
|
|
83
|
+
if (git(cwd, ['merge-base', '--is-ancestor', head, base]) !== undefined)
|
|
84
|
+
return true;
|
|
85
|
+
const merged = git(cwd, ['merge-tree', '--write-tree', base, head])?.split('\n')[0];
|
|
86
|
+
return merged !== undefined && merged === git(cwd, ['rev-parse', `${base}^{tree}`]);
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Submodules as `.gitmodules` records them, with the commit each is pinned to.
|
|
90
|
+
*
|
|
91
|
+
* Uninitialised submodules are left out — there is nothing to inspect until
|
|
92
|
+
* they are checked out.
|
|
93
|
+
*/
|
|
94
|
+
export const submodules = (root) => {
|
|
95
|
+
const config = git(root, ['config', '--file', '.gitmodules', '--get-regexp', 'path']);
|
|
96
|
+
const found = [];
|
|
97
|
+
for (const line of lines(config)) {
|
|
98
|
+
const [key, relativePath] = line.split(' ');
|
|
99
|
+
if (!relativePath)
|
|
100
|
+
continue;
|
|
101
|
+
const name = key.slice('submodule.'.length, -'.path'.length);
|
|
102
|
+
const url = git(root, ['config', '--file', '.gitmodules', '--get', `submodule.${name}.url`]) ?? '';
|
|
103
|
+
const full = path.join(root, relativePath);
|
|
104
|
+
// An uninitialised submodule is an empty directory, and git run inside one
|
|
105
|
+
// finds the distribution instead — reporting the distribution's own tags
|
|
106
|
+
// as the module's, and checking one out onto the distribution's HEAD.
|
|
107
|
+
if (!existsSync(path.join(full, '.git')))
|
|
108
|
+
continue;
|
|
109
|
+
const pinned = git(full, ['rev-parse', 'HEAD']);
|
|
110
|
+
if (!pinned)
|
|
111
|
+
continue;
|
|
112
|
+
found.push({
|
|
113
|
+
name: path.basename(relativePath),
|
|
114
|
+
configName: name,
|
|
115
|
+
relativePath,
|
|
116
|
+
path: full,
|
|
117
|
+
url,
|
|
118
|
+
upstream: gitmodulesGet(root, name, 'upstream'),
|
|
119
|
+
pinned,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return found;
|
|
123
|
+
};
|
|
124
|
+
/** Tags that name a version, newest first. */
|
|
125
|
+
const versionTags = (cwd) => lines(git(cwd, ['tag', '--list']))
|
|
126
|
+
.filter((tag) => semver.valid(tag) !== null)
|
|
127
|
+
.sort((a, b) => semver.rcompare(a, b));
|
|
128
|
+
/**
|
|
129
|
+
* The branch tip the submodule is tracking, for counting unreleased work: a
|
|
130
|
+
* fork's upstream, since that is where its releases come from, else its own.
|
|
131
|
+
*/
|
|
132
|
+
const trackedTip = (cwd, fork) => {
|
|
133
|
+
const remotes = fork ? [UPSTREAM, 'origin'] : ['origin'];
|
|
134
|
+
const refs = [...remotes.flatMap((remote) => ['HEAD', 'main', 'master'].map((branch) => `${remote}/${branch}`)), 'main', 'master'];
|
|
135
|
+
for (const ref of refs) {
|
|
136
|
+
if (git(cwd, ['rev-parse', '--verify', '--quiet', ref]))
|
|
137
|
+
return ref;
|
|
138
|
+
}
|
|
139
|
+
return undefined;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Whether a commit is on the checkout's `origin`, so that another clone of
|
|
143
|
+
* the distribution — a build host, say — can check it out. A commit made in
|
|
144
|
+
* the checkout and pinned before it was pushed is not.
|
|
145
|
+
*/
|
|
146
|
+
const onOrigin = (cwd, commit) => {
|
|
147
|
+
if (lines(git(cwd, ['branch', '--remotes', '--contains', commit, '--list', 'origin/*'])).length > 0) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
// Tags reach commits too, and a fork is often pinned at an upstream tag
|
|
151
|
+
// pushed to it rather than at a branch.
|
|
152
|
+
return lines(git(cwd, ['ls-remote', '--tags', 'origin'])).some((line) => {
|
|
153
|
+
const sha = line.split('\t')[0];
|
|
154
|
+
return sha === commit || git(cwd, ['merge-base', '--is-ancestor', commit, sha]) !== undefined;
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Compare a submodule's pinned commit against the versions its repository has.
|
|
159
|
+
*
|
|
160
|
+
* Only tags that name a version are considered an upgrade. Commits past the
|
|
161
|
+
* newest tag are counted and reported, but never bumped to — a commit carries
|
|
162
|
+
* no statement about what changed, which is the whole point of the version.
|
|
163
|
+
*/
|
|
164
|
+
export const inspect = (submodule, { fetch = true } = {}) => {
|
|
165
|
+
const cwd = submodule.path;
|
|
166
|
+
const fork = submodule.upstream;
|
|
167
|
+
if (fork)
|
|
168
|
+
ensureUpstreamRemote(cwd, fork);
|
|
169
|
+
let fetched;
|
|
170
|
+
if (fetch) {
|
|
171
|
+
fetched = git(cwd, ['fetch', '--tags', '--quiet']) !== undefined;
|
|
172
|
+
if (fork) {
|
|
173
|
+
// A fork takes its releases from upstream, so upstream's tags are the
|
|
174
|
+
// versions it can move to.
|
|
175
|
+
const upstreamFetched = git(cwd, ['fetch', '--tags', '--quiet', UPSTREAM]) !== undefined;
|
|
176
|
+
if (upstreamFetched)
|
|
177
|
+
git(cwd, ['remote', 'set-head', UPSTREAM, '--auto']);
|
|
178
|
+
fetched = fetched && upstreamFetched;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const dirty = (git(cwd, ['status', '--porcelain']) ?? '') !== '';
|
|
182
|
+
const tags = versionTags(cwd);
|
|
183
|
+
// Read HEAD rather than trusting the commit captured at discovery: a bump
|
|
184
|
+
// moves the checkout, and anything inspecting afterwards must see that.
|
|
185
|
+
const head = git(cwd, ['rev-parse', 'HEAD']) ?? submodule.pinned;
|
|
186
|
+
const exactTag = lines(git(cwd, ['tag', '--points-at', head])).find((tag) => semver.valid(tag) !== null);
|
|
187
|
+
// Otherwise the newest tag the pinned commit descends from.
|
|
188
|
+
const describedTag = git(cwd, ['describe', '--tags', '--abbrev=0', '--match', '*', head]);
|
|
189
|
+
const described = describedTag && semver.valid(describedTag) !== null ? describedTag : undefined;
|
|
190
|
+
const current = exactTag ?? described;
|
|
191
|
+
const available = current
|
|
192
|
+
? tags.filter((tag) => semver.gt(tag, current))
|
|
193
|
+
: tags;
|
|
194
|
+
const upgrades = {};
|
|
195
|
+
for (const tag of available) {
|
|
196
|
+
// semver.diff also returns premajor, preminor and prepatch. Bucketing
|
|
197
|
+
// those as patch would let a jump to 1.0.0-alpha.0 apply without --major,
|
|
198
|
+
// which matters most for the 0.x.y-alpha.n versions this is built for.
|
|
199
|
+
const difference = current ? semver.diff(current, tag) : 'major';
|
|
200
|
+
const bucket = difference === 'major' || difference === 'premajor'
|
|
201
|
+
? 'major'
|
|
202
|
+
: difference === 'minor' || difference === 'preminor'
|
|
203
|
+
? 'minor'
|
|
204
|
+
: 'patch';
|
|
205
|
+
// available is newest first, so the first of each kind is the newest.
|
|
206
|
+
upgrades[bucket] ??= tag;
|
|
207
|
+
}
|
|
208
|
+
const tip = trackedTip(cwd, fork !== undefined);
|
|
209
|
+
const from = available[0] ?? current ?? head;
|
|
210
|
+
const untagged = tip
|
|
211
|
+
? Number(git(cwd, ['rev-list', '--count', `${from}..${tip}`]) ?? '0')
|
|
212
|
+
: 0;
|
|
213
|
+
let forkState;
|
|
214
|
+
if (fork) {
|
|
215
|
+
const ahead = tip
|
|
216
|
+
? Number(git(cwd, ['rev-list', '--count', '--no-merges', '--cherry-pick', '--right-only', `${tip}...${head}`]) ??
|
|
217
|
+
'0')
|
|
218
|
+
: 0;
|
|
219
|
+
// Oldest first: returning to upstream should move no further than it has to.
|
|
220
|
+
const releases = [...(current ? [current] : []), ...[...available].reverse()];
|
|
221
|
+
const merged = releases.find((tag) => containsAll(cwd, `refs/tags/${tag}`, head)) ??
|
|
222
|
+
(tip && containsAll(cwd, tip, head) ? tip : undefined);
|
|
223
|
+
forkState = { upstream: fork, ahead, merged };
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
submodule,
|
|
227
|
+
head,
|
|
228
|
+
current,
|
|
229
|
+
exact: exactTag !== undefined,
|
|
230
|
+
available,
|
|
231
|
+
upgrades,
|
|
232
|
+
untagged,
|
|
233
|
+
dirty,
|
|
234
|
+
fetched,
|
|
235
|
+
pushed: fetched ? onOrigin(cwd, head) : undefined,
|
|
236
|
+
fork: forkState,
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* The version a bump should move to, or undefined when there is nothing to do.
|
|
241
|
+
*
|
|
242
|
+
* Major upgrades are held back unless asked for: they are the ones that need a
|
|
243
|
+
* person to read a changelog first.
|
|
244
|
+
*/
|
|
245
|
+
export const target = (state, { major = false } = {}) => {
|
|
246
|
+
const candidates = [
|
|
247
|
+
state.upgrades.patch,
|
|
248
|
+
state.upgrades.minor,
|
|
249
|
+
...(major ? [state.upgrades.major] : []),
|
|
250
|
+
].filter((tag) => tag !== undefined);
|
|
251
|
+
if (candidates.length === 0)
|
|
252
|
+
return undefined;
|
|
253
|
+
return candidates.sort((a, b) => semver.rcompare(a, b))[0];
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Record a different URL for a submodule.
|
|
257
|
+
*
|
|
258
|
+
* `.gitmodules` is what gets committed, and `submodule sync` copies it into the
|
|
259
|
+
* local config so the existing checkout uses it too. The caller commits.
|
|
260
|
+
*/
|
|
261
|
+
export const setUrl = (root, submodule, url) => {
|
|
262
|
+
const written = git(root, [
|
|
263
|
+
'config',
|
|
264
|
+
'--file',
|
|
265
|
+
'.gitmodules',
|
|
266
|
+
`submodule.${submodule.configName}.url`,
|
|
267
|
+
url,
|
|
268
|
+
]);
|
|
269
|
+
if (written === undefined) {
|
|
270
|
+
throw new Error(`Could not set the url for ${submodule.relativePath}.`);
|
|
271
|
+
}
|
|
272
|
+
git(root, ['submodule', 'sync', '--quiet', '--', submodule.relativePath]);
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Whether a remote can be read with no credentials at all.
|
|
276
|
+
*
|
|
277
|
+
* This is the question a build host asks. Prompting is disabled so a private
|
|
278
|
+
* repository fails immediately instead of waiting for a password nobody is
|
|
279
|
+
* there to type.
|
|
280
|
+
*/
|
|
281
|
+
export const isPublic = (url, timeout = 15_000) => {
|
|
282
|
+
try {
|
|
283
|
+
execFileSync('git', ['ls-remote', '--exit-code', url, 'HEAD'], {
|
|
284
|
+
encoding: 'utf8',
|
|
285
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
286
|
+
timeout,
|
|
287
|
+
env: {
|
|
288
|
+
...process.env,
|
|
289
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
290
|
+
GIT_ASKPASS: 'echo',
|
|
291
|
+
GIT_SSH_COMMAND: 'ssh -oBatchMode=yes',
|
|
292
|
+
GIT_CONFIG_COUNT: '1',
|
|
293
|
+
GIT_CONFIG_KEY_0: 'credential.helper',
|
|
294
|
+
GIT_CONFIG_VALUE_0: '',
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
/** Move a submodule's checkout to a tag. The caller commits the new pointer. */
|
|
304
|
+
export const moveTo = (submodule, tag) => {
|
|
305
|
+
// Belt and braces: never check out inside something that is not the
|
|
306
|
+
// submodule's own repository.
|
|
307
|
+
if (!existsSync(path.join(submodule.path, '.git'))) {
|
|
308
|
+
throw new Error(`${submodule.relativePath} is not checked out, so there is nothing to move.`);
|
|
309
|
+
}
|
|
310
|
+
const result = git(submodule.path, ['checkout', '--quiet', `refs/tags/${tag}`]);
|
|
311
|
+
if (result === undefined) {
|
|
312
|
+
throw new Error(`Could not check out ${tag} in ${submodule.relativePath}.`);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
//# sourceMappingURL=submodules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submodules.js","sourceRoot":"","sources":["../src/submodules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,uEAAuE;AACvE,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,IAAc,EAAsB,EAAE;IAC9D,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE;YAC/B,GAAG;YACH,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC,CAAC,IAAI,EAAE,CAAA;IACX,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,KAAyB,EAAY,EAAE,CACpD,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAEhD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAW,EAAE,CACtD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC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CAAA;IAC7E,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Files } from './scaffold.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The publishing workflow a module carries.
|
|
4
|
+
*
|
|
5
|
+
* A module releases on its own schedule, so the workflow lives in the module
|
|
6
|
+
* rather than the distribution. Authentication is npm trusted publishing over
|
|
7
|
+
* OIDC — there is no token to leak, and the package must already exist on npm
|
|
8
|
+
* with a trusted publisher pointing at this repository and this file.
|
|
9
|
+
*/
|
|
10
|
+
export declare const publishWorkflow: (packageName: string) => Files;
|
|
11
|
+
/**
|
|
12
|
+
* The publishing workflow a distribution carries, for others to extend it.
|
|
13
|
+
*
|
|
14
|
+
* The same shape as a module's — a canary on every push to main, a release by
|
|
15
|
+
* hand — but checked out with its submodules, since `fg-dist canary` and
|
|
16
|
+
* `release --check` record every module's version, path, repository and
|
|
17
|
+
* commit in the manifest they publish. That is what an extension checks
|
|
18
|
+
* itself against and takes its own modules from.
|
|
19
|
+
*/
|
|
20
|
+
export declare const distributionWorkflow: (packageName: string) => Files;
|
|
21
|
+
/**
|
|
22
|
+
* The pull request check that keeps a changelog current.
|
|
23
|
+
*
|
|
24
|
+
* Every pull request has to add a line linking itself under the version being
|
|
25
|
+
* worked on — or, in a distribution, every one that changes the
|
|
26
|
+
* organization's policy — so a release's notes are written, and committed,
|
|
27
|
+
* before it is released. A distribution is checked out with its submodules,
|
|
28
|
+
* without which its workspace does not install.
|
|
29
|
+
*/
|
|
30
|
+
export declare const changelogWorkflow: ({ submodules }: {
|
|
31
|
+
submodules: boolean;
|
|
32
|
+
}) => Files;
|
|
33
|
+
export interface WorkflowUpdate {
|
|
34
|
+
relativePath: string;
|
|
35
|
+
files: string[];
|
|
36
|
+
skipped: boolean;
|
|
37
|
+
/** Whether `private: true` was taken off, so the module can publish at all. */
|
|
38
|
+
unprivated: boolean;
|
|
39
|
+
/** True when nothing in the manifest says what the tarball should contain. */
|
|
40
|
+
missingFiles: boolean;
|
|
41
|
+
/** True when nothing says whether the package publishes publicly. */
|
|
42
|
+
missingAccess: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The scripts the workflow calls, and a module releases by hand with.
|
|
46
|
+
*
|
|
47
|
+
* They are named rather than spelled out in the workflow so that every
|
|
48
|
+
* module's workflow is the same file, and so `pnpm release` is the answer to
|
|
49
|
+
* "how do I release this" wherever you are standing.
|
|
50
|
+
*/
|
|
51
|
+
export declare const releaseScripts: (packageName: string) => Record<string, string>;
|
|
52
|
+
export interface ManifestChange {
|
|
53
|
+
changed: boolean;
|
|
54
|
+
unprivated: boolean;
|
|
55
|
+
missingFiles: boolean;
|
|
56
|
+
missingAccess: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Give a module what it needs to publish itself.
|
|
60
|
+
*
|
|
61
|
+
* One pass over the manifest rather than several: a structural rewrite undoes
|
|
62
|
+
* a careful textual splice, so doing both would mean the second silently
|
|
63
|
+
* discarding the first's formatting. Two-space JSON is what npm and pnpm write
|
|
64
|
+
* anyway.
|
|
65
|
+
*/
|
|
66
|
+
export declare const updateManifest: (moduleRoot: string, packageName: string, version: string | undefined, packageManager: string | undefined, { write }?: {
|
|
67
|
+
write?: boolean;
|
|
68
|
+
}) => Promise<ManifestChange>;
|
|
69
|
+
/**
|
|
70
|
+
* Give every module a publishing workflow.
|
|
71
|
+
*
|
|
72
|
+
* A module that already has one is left alone: it may have been changed on
|
|
73
|
+
* purpose, and overwriting it would be the kind of help nobody asked for.
|
|
74
|
+
*/
|
|
75
|
+
export declare const writeWorkflows: (root: string, { force, dryRun, names, }?: {
|
|
76
|
+
force?: boolean;
|
|
77
|
+
dryRun?: boolean;
|
|
78
|
+
/** Only these modules, by name or path; every one when empty. */
|
|
79
|
+
names?: string[];
|
|
80
|
+
}) => Promise<WorkflowUpdate[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Give the distribution itself a publishing workflow, so others can extend it.
|
|
83
|
+
*
|
|
84
|
+
* Asked for rather than done by `writeWorkflows`: it makes the distribution
|
|
85
|
+
* public on npm, which a distribution only its owner deploys has no need to be.
|
|
86
|
+
* The tarball is the manifest and the organization's policy, which is what an
|
|
87
|
+
* extension builds its own on.
|
|
88
|
+
*/
|
|
89
|
+
export declare const writeDistributionWorkflow: (root: string, { force, dryRun }?: {
|
|
90
|
+
force?: boolean;
|
|
91
|
+
dryRun?: boolean;
|
|
92
|
+
}) => Promise<WorkflowUpdate>;
|
|
93
|
+
/**
|
|
94
|
+
* Give the distribution itself the changelog check, for pull requests that
|
|
95
|
+
* change the organization's policy — what else changes in it, fg-dist notes
|
|
96
|
+
* itself. Unlike its publishing, this makes nothing public.
|
|
97
|
+
*/
|
|
98
|
+
export declare const writeDistributionChangelogCheck: (root: string, { force, dryRun }?: {
|
|
99
|
+
force?: boolean;
|
|
100
|
+
dryRun?: boolean;
|
|
101
|
+
}) => Promise<WorkflowUpdate>;
|
|
102
|
+
//# sourceMappingURL=workflows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../src/workflows.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM,KAAG,KAkMpD,CAAA;AAkCF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,aAAa,MAAM,KAAG,KAuGzD,CAAA;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,gBAAgB;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,KAAG,KAmD1E,CAAA;AAEF,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,+EAA+E;IAC/E,UAAU,EAAE,OAAO,CAA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