claude-plugin-dsh 0.1.0 → 0.2.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 +34 -0
- package/dist/bin/cli.js +31 -2
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/update.d.ts +30 -0
- package/dist/bin/update.d.ts.map +1 -0
- package/dist/bin/update.js +237 -0
- package/dist/bin/update.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,6 +116,40 @@ Or for every profile, add a row to `~/.dsh/cordis.patch.yml`. DSH picks it up wi
|
|
|
116
116
|
|
|
117
117
|
A row config can turn parts off: `config: { disable: [hooks] }`.
|
|
118
118
|
|
|
119
|
+
## Updating installed plugins
|
|
120
|
+
|
|
121
|
+
When adapters are loaded from git checkouts (one `file://.../dsh/index.js` row per checkout
|
|
122
|
+
in `~/.dsh/cordis.patch.yml`), `update` brings them to their upstream branch:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
bun x claude-plugin-dsh update # every checkout DSH loads an adapter from
|
|
126
|
+
bun x claude-plugin-dsh update --check # report what is behind, write nothing, exit 1 if any
|
|
127
|
+
bun x claude-plugin-dsh update ~/Development/design-studio
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Without directories it updates the checkout behind every `file://` row whose path is inside a
|
|
131
|
+
`dsh/` directory, wherever the checkout lives (`~/Development/<plugin>` works as well as
|
|
132
|
+
`$DSH_HOME/plugins-src/<plugin>`), plus every git checkout directly under
|
|
133
|
+
`$DSH_HOME/plugins-src`. Other `file://` rows, such as a plugin's own `dist/` build, are left
|
|
134
|
+
alone.
|
|
135
|
+
|
|
136
|
+
For each checkout it fetches, fast-forwards the current branch onto its tracking ref
|
|
137
|
+
(`origin/<branch>` when none is configured), runs `bun install --frozen-lockfile` in every
|
|
138
|
+
tracked `dsh/` directory (also when the checkout was already up to date, so a fresh clone gets
|
|
139
|
+
its dependencies), and rewrites the `# <dir> <branch> <hash>` comment above the
|
|
140
|
+
checkout's row in the patch file. That comment is a note for people; DSH loads the checkout
|
|
141
|
+
as it is on disk. A dirty working tree stops the update for that checkout.
|
|
142
|
+
|
|
143
|
+
Private HTTPS remotes fetch with your `gh auth login` session when `gh` is on `PATH`. It is
|
|
144
|
+
tried after any credential helper you configured. SSH remotes use your SSH keys as usual.
|
|
145
|
+
|
|
146
|
+
When the remote history was rewritten and the branch cannot be fast-forwarded, `update`
|
|
147
|
+
refuses and prints the undo command. `--reset` moves the branch onto the upstream with
|
|
148
|
+
`git reset --hard` instead; local commits that are not upstream are dropped from the branch
|
|
149
|
+
but stay in the reflog. `--patch <file>` rewrites pins in a different file.
|
|
150
|
+
|
|
151
|
+
Restart DSH afterwards so it loads the new version.
|
|
152
|
+
|
|
119
153
|
## Keeping vendored copies current
|
|
120
154
|
|
|
121
155
|
```sh
|
package/dist/bin/cli.js
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
import { inspect } from './inspect.js';
|
|
3
3
|
import { scaffold } from './scaffold.js';
|
|
4
4
|
import { sync } from './sync.js';
|
|
5
|
+
import { discoverCheckouts, update } from './update.js';
|
|
5
6
|
const usage = `Usage: claude-plugin-dsh <command> [options] <plugin-dir>...
|
|
6
7
|
|
|
7
8
|
Commands:
|
|
8
9
|
scaffold [--scope @you] <plugin-dir>... Generate manifest, locale and runtime
|
|
9
10
|
inspect <plugin-dir>... List plugin registrations (loads plugin code)
|
|
10
11
|
sync [--check] <plugin-dir>... Copy runtime, or check for drift
|
|
12
|
+
update [--check] [--reset] [--patch <file>] [<checkout-dir>...]
|
|
13
|
+
Pull adapter checkouts, install their dsh/ dependencies and
|
|
14
|
+
refresh the pin comments in cordis.patch.yml. Without directories,
|
|
15
|
+
every checkout behind a file:// adapter row in the patch file and
|
|
16
|
+
every checkout under $DSH_HOME/plugins-src is updated.
|
|
11
17
|
|
|
12
18
|
Options:
|
|
13
19
|
-h, --help Show help
|
|
@@ -20,7 +26,7 @@ async function main(args) {
|
|
|
20
26
|
console.log(usage);
|
|
21
27
|
return 0;
|
|
22
28
|
}
|
|
23
|
-
if (command !== 'scaffold' && command !== 'inspect' && command !== 'sync') {
|
|
29
|
+
if (command !== 'scaffold' && command !== 'inspect' && command !== 'sync' && command !== 'update') {
|
|
24
30
|
throw new UsageError(command ? `Unknown command: ${command}` : 'A command is required');
|
|
25
31
|
}
|
|
26
32
|
if (rest.length === 1 && (rest[0] === '-h' || rest[0] === '--help')) {
|
|
@@ -29,6 +35,8 @@ async function main(args) {
|
|
|
29
35
|
}
|
|
30
36
|
let scope;
|
|
31
37
|
let check = false;
|
|
38
|
+
let reset = false;
|
|
39
|
+
let patch;
|
|
32
40
|
let positional = false;
|
|
33
41
|
const directories = [];
|
|
34
42
|
for (let index = 0; index < rest.length; index++) {
|
|
@@ -46,11 +54,23 @@ async function main(args) {
|
|
|
46
54
|
throw new UsageError(`--scope must look like @name, got ${JSON.stringify(scope)}`);
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
|
-
else if (!positional && arg === '--check' && command === 'sync') {
|
|
57
|
+
else if (!positional && arg === '--check' && (command === 'sync' || command === 'update')) {
|
|
50
58
|
if (check)
|
|
51
59
|
throw new UsageError('--check may only be supplied once');
|
|
52
60
|
check = true;
|
|
53
61
|
}
|
|
62
|
+
else if (!positional && arg === '--reset' && command === 'update') {
|
|
63
|
+
if (reset)
|
|
64
|
+
throw new UsageError('--reset may only be supplied once');
|
|
65
|
+
reset = true;
|
|
66
|
+
}
|
|
67
|
+
else if (!positional && arg === '--patch' && command === 'update') {
|
|
68
|
+
if (patch !== undefined)
|
|
69
|
+
throw new UsageError('--patch may only be supplied once');
|
|
70
|
+
patch = rest[++index];
|
|
71
|
+
if (patch === undefined || patch.startsWith('-'))
|
|
72
|
+
throw new UsageError('--patch requires a file path');
|
|
73
|
+
}
|
|
54
74
|
else if (!positional && arg.startsWith('-')) {
|
|
55
75
|
throw new UsageError(`Unknown option for ${command}: ${arg}`);
|
|
56
76
|
}
|
|
@@ -58,6 +78,15 @@ async function main(args) {
|
|
|
58
78
|
directories.push(arg);
|
|
59
79
|
}
|
|
60
80
|
}
|
|
81
|
+
if (command === 'update') {
|
|
82
|
+
if (check && reset)
|
|
83
|
+
throw new UsageError('--check and --reset cannot be combined');
|
|
84
|
+
const targets = directories.length ? directories : discoverCheckouts(process.env, patch);
|
|
85
|
+
if (!targets.length) {
|
|
86
|
+
throw new UsageError('update found no checkouts in the patch file or under $DSH_HOME/plugins-src; pass directories explicitly');
|
|
87
|
+
}
|
|
88
|
+
return update(targets, { check, reset, patch });
|
|
89
|
+
}
|
|
61
90
|
if (!directories.length)
|
|
62
91
|
throw new UsageError(`${command} requires at least one plugin directory`);
|
|
63
92
|
if (command === 'scaffold') {
|
package/dist/bin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../bin/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEvD,MAAM,KAAK,GAAG;;;;;;;;;;;;;;CAcb,CAAA;AAED,MAAM,UAAW,SAAQ,KAAK;CAAG;AAEjC,KAAK,UAAU,IAAI,CAAC,IAAuB;IACzC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IAC/B,IAAI,CAAC,OAAO,KAAK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CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACrE,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACrD,OAAO,CAAC,QAAQ,GAAG,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface UpdateOptions {
|
|
2
|
+
/** Report what would change and exit 1 when behind, without writing. */
|
|
3
|
+
check: boolean;
|
|
4
|
+
/** When the branch cannot be fast-forwarded, `git reset --hard` it onto the upstream. */
|
|
5
|
+
reset: boolean;
|
|
6
|
+
/** Patch file whose pin comments are rewritten; undefined uses $DSH_HOME/cordis.patch.yml. */
|
|
7
|
+
patch: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface Checkout {
|
|
10
|
+
root: string;
|
|
11
|
+
/** Directory name: the pin comments in cordis.patch.yml are keyed by it. */
|
|
12
|
+
name: string;
|
|
13
|
+
upstream: string;
|
|
14
|
+
branch: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function defaultPatchFile(env?: NodeJS.ProcessEnv): string;
|
|
17
|
+
/**
|
|
18
|
+
* Every checkout DSH loads an adapter from: the patch file's `file://` adapter rows plus every git
|
|
19
|
+
* checkout directly under $DSH_HOME/plugins-src. A checkout reached both ways is listed once.
|
|
20
|
+
*/
|
|
21
|
+
export declare function discoverCheckouts(env?: NodeJS.ProcessEnv, patchFile?: string): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Rewrite the `# <dir> <branch> <hash>` pin comment above the checkout's insert row.
|
|
24
|
+
* The comment is documentation only; DSH loads whatever the checkout contains.
|
|
25
|
+
* Returns false when the patch file has no pin for this checkout.
|
|
26
|
+
*/
|
|
27
|
+
export declare function rewritePin(patchFile: string, checkout: Checkout, hash: string, write: boolean): boolean;
|
|
28
|
+
export declare function update(directories: readonly string[], options: UpdateOptions): number;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../bin/update.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAA;IACd,yFAAyF;IACzF,KAAK,EAAE,OAAO,CAAA;IACd,8FAA8F;IAC9F,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B;AAED,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAkCD,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAE7E;AAwBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,SAAS,SAAwB,GAAG,MAAM,EAAE,CAgBnH;AAoDD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAiBvG;AAED,wBAAgB,MAAM,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAYrF"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
5
|
+
function git(root, ...args) {
|
|
6
|
+
const result = spawnSync('git', ['-C', root, ...args], { encoding: 'utf8' });
|
|
7
|
+
if (result.error)
|
|
8
|
+
throw result.error;
|
|
9
|
+
return { ok: result.status === 0, out: result.stdout.trim(), err: result.stderr.trim() };
|
|
10
|
+
}
|
|
11
|
+
let ghCredentialArgs;
|
|
12
|
+
/**
|
|
13
|
+
* Lets fetch use the `gh auth login` session. Added after the user's own helpers, so it is only a fallback,
|
|
14
|
+
* and gh answers nothing for hosts it is not logged in to.
|
|
15
|
+
*/
|
|
16
|
+
function credentialArgs() {
|
|
17
|
+
if (ghCredentialArgs === undefined) {
|
|
18
|
+
const probe = spawnSync('gh', ['--version'], { stdio: 'ignore' });
|
|
19
|
+
ghCredentialArgs = probe.error || probe.status !== 0 ? [] : ['-c', 'credential.helper=!gh auth git-credential'];
|
|
20
|
+
}
|
|
21
|
+
return ghCredentialArgs;
|
|
22
|
+
}
|
|
23
|
+
function short(hash) {
|
|
24
|
+
return hash.slice(0, 7);
|
|
25
|
+
}
|
|
26
|
+
function escapeRegExp(value) {
|
|
27
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
28
|
+
}
|
|
29
|
+
function dshHome(env) {
|
|
30
|
+
return env.DSH_HOME || join(homedir(), '.dsh');
|
|
31
|
+
}
|
|
32
|
+
export function defaultPatchFile(env = process.env) {
|
|
33
|
+
return join(dshHome(env), 'cordis.patch.yml');
|
|
34
|
+
}
|
|
35
|
+
/** The nearest ancestor of `start` holding a .git entry, keeping the path as written. */
|
|
36
|
+
function checkoutRootOf(start) {
|
|
37
|
+
for (let dir = start;; dir = dirname(dir)) {
|
|
38
|
+
if (existsSync(join(dir, '.git')))
|
|
39
|
+
return dir;
|
|
40
|
+
if (dirname(dir) === dir)
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Checkouts behind the patch file's `file://.../dsh/<entry>` adapter rows, wherever they live. */
|
|
45
|
+
function checkoutsFromPatch(patchFile) {
|
|
46
|
+
if (!existsSync(patchFile))
|
|
47
|
+
return [];
|
|
48
|
+
const roots = [];
|
|
49
|
+
for (const match of readFileSync(patchFile, 'utf8').matchAll(/file:\/\/(\/[^"'\s]+)/g)) {
|
|
50
|
+
const entry = match[1];
|
|
51
|
+
// Only adapter bundles; other file:// rows (a plugin's own dist build) are not ours to pull.
|
|
52
|
+
if (entry === undefined || basename(dirname(entry)) !== 'dsh' || !existsSync(entry))
|
|
53
|
+
continue;
|
|
54
|
+
const root = checkoutRootOf(dirname(entry));
|
|
55
|
+
if (root)
|
|
56
|
+
roots.push(root);
|
|
57
|
+
}
|
|
58
|
+
return roots;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Every checkout DSH loads an adapter from: the patch file's `file://` adapter rows plus every git
|
|
62
|
+
* checkout directly under $DSH_HOME/plugins-src. A checkout reached both ways is listed once.
|
|
63
|
+
*/
|
|
64
|
+
export function discoverCheckouts(env = process.env, patchFile = defaultPatchFile(env)) {
|
|
65
|
+
const source = join(dshHome(env), 'plugins-src');
|
|
66
|
+
const fromSource = existsSync(source)
|
|
67
|
+
? readdirSync(source, { withFileTypes: true })
|
|
68
|
+
.filter((entry) => entry.isDirectory() && existsSync(join(source, entry.name, '.git')))
|
|
69
|
+
.map((entry) => join(source, entry.name))
|
|
70
|
+
: [];
|
|
71
|
+
const seen = new Set();
|
|
72
|
+
const roots = [];
|
|
73
|
+
for (const root of [...checkoutsFromPatch(patchFile), ...fromSource]) {
|
|
74
|
+
const key = realpathSync(root);
|
|
75
|
+
if (seen.has(key))
|
|
76
|
+
continue;
|
|
77
|
+
seen.add(key);
|
|
78
|
+
roots.push(root);
|
|
79
|
+
}
|
|
80
|
+
return roots.sort();
|
|
81
|
+
}
|
|
82
|
+
/** The plugin version from .claude-plugin/plugin.json at the checkout root, if any. */
|
|
83
|
+
function pluginVersion(root) {
|
|
84
|
+
const manifest = join(root, '.claude-plugin', 'plugin.json');
|
|
85
|
+
if (!existsSync(manifest))
|
|
86
|
+
return undefined;
|
|
87
|
+
try {
|
|
88
|
+
const value = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
89
|
+
if (typeof value === 'object' && value !== null && 'version' in value && typeof value.version === 'string')
|
|
90
|
+
return value.version;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// a broken manifest is the plugin's problem, not the updater's
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
/** Resolve the tracking ref: the configured upstream, else origin/<branch>, else origin/HEAD. */
|
|
98
|
+
function resolveUpstream(root) {
|
|
99
|
+
const tracked = git(root, 'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}');
|
|
100
|
+
if (tracked.ok && tracked.out)
|
|
101
|
+
return { upstream: tracked.out, branch: tracked.out.replace(/^[^/]+\//, '') };
|
|
102
|
+
const head = git(root, 'rev-parse', '--abbrev-ref', 'HEAD');
|
|
103
|
+
if (head.ok && head.out !== 'HEAD' && git(root, 'rev-parse', '--verify', '--quiet', `origin/${head.out}`).ok) {
|
|
104
|
+
return { upstream: `origin/${head.out}`, branch: head.out };
|
|
105
|
+
}
|
|
106
|
+
const remoteHead = git(root, 'symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD');
|
|
107
|
+
if (remoteHead.ok && remoteHead.out)
|
|
108
|
+
return { upstream: remoteHead.out, branch: remoteHead.out.replace(/^[^/]+\//, '') };
|
|
109
|
+
throw new Error(`${basename(root)}: cannot determine the upstream branch (detached HEAD?); run git checkout <branch> or git branch --set-upstream-to first`);
|
|
110
|
+
}
|
|
111
|
+
function openCheckout(directory) {
|
|
112
|
+
const root = resolve(directory);
|
|
113
|
+
const inside = git(root, 'rev-parse', '--is-inside-work-tree');
|
|
114
|
+
if (!inside.ok || inside.out !== 'true')
|
|
115
|
+
throw new Error(`${root}: not a git checkout`);
|
|
116
|
+
const top = git(root, 'rev-parse', '--show-toplevel').out;
|
|
117
|
+
if (realpathSync(top) !== realpathSync(root))
|
|
118
|
+
throw new Error(`${root}: pass the checkout root (${top})`);
|
|
119
|
+
const { upstream, branch } = resolveUpstream(root);
|
|
120
|
+
return { root, name: basename(root), upstream, branch };
|
|
121
|
+
}
|
|
122
|
+
/** Adapter directories: every tracked dsh/bun.lock, so nested adapters are found too. */
|
|
123
|
+
function adapterDirectories(root) {
|
|
124
|
+
const listed = git(root, 'ls-files', '--', 'dsh/bun.lock', '**/dsh/bun.lock');
|
|
125
|
+
return listed.out ? listed.out.split('\n').map((file) => join(root, dirname(file))) : [];
|
|
126
|
+
}
|
|
127
|
+
function installAdapterDependencies(root) {
|
|
128
|
+
for (const dsh of adapterDirectories(root)) {
|
|
129
|
+
const result = spawnSync('bun', ['install', '--frozen-lockfile'], { cwd: dsh, encoding: 'utf8' });
|
|
130
|
+
if (result.error)
|
|
131
|
+
throw new Error(`${dsh}: bun install failed to start: ${result.error.message}`);
|
|
132
|
+
if (result.status !== 0)
|
|
133
|
+
throw new Error(`${dsh}: bun install --frozen-lockfile failed\n${result.stderr.trim()}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Rewrite the `# <dir> <branch> <hash>` pin comment above the checkout's insert row.
|
|
138
|
+
* The comment is documentation only; DSH loads whatever the checkout contains.
|
|
139
|
+
* Returns false when the patch file has no pin for this checkout.
|
|
140
|
+
*/
|
|
141
|
+
export function rewritePin(patchFile, checkout, hash, write) {
|
|
142
|
+
if (!existsSync(patchFile))
|
|
143
|
+
return false;
|
|
144
|
+
const lines = readFileSync(patchFile, 'utf8').split('\n');
|
|
145
|
+
const pin = new RegExp(`^# ${escapeRegExp(checkout.name)} \\S+ [0-9a-f]{7,40}\\s*$`);
|
|
146
|
+
for (let index = 0; index < lines.length; index++) {
|
|
147
|
+
const line = lines[index];
|
|
148
|
+
if (line === undefined || !pin.test(line))
|
|
149
|
+
continue;
|
|
150
|
+
const below = lines.slice(index + 1, index + 5).join('\n');
|
|
151
|
+
if (!below.includes(`file://${checkout.root}/`))
|
|
152
|
+
continue;
|
|
153
|
+
const replacement = `# ${checkout.name} ${checkout.branch} ${hash}`;
|
|
154
|
+
if (line !== replacement && write) {
|
|
155
|
+
lines[index] = replacement;
|
|
156
|
+
writeFileSync(patchFile, lines.join('\n'));
|
|
157
|
+
}
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
export function update(directories, options) {
|
|
163
|
+
const patchFile = options.patch ?? defaultPatchFile();
|
|
164
|
+
let status = 0;
|
|
165
|
+
for (const directory of directories) {
|
|
166
|
+
try {
|
|
167
|
+
if (!updateOne(openCheckout(directory), options, patchFile))
|
|
168
|
+
status = 1;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
status = 1;
|
|
172
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return status;
|
|
176
|
+
}
|
|
177
|
+
/** Returns false when the checkout is behind in --check mode. Throws when it cannot be updated. */
|
|
178
|
+
function updateOne(checkout, options, patchFile) {
|
|
179
|
+
const { root, name, upstream } = checkout;
|
|
180
|
+
const label = `${name}:`;
|
|
181
|
+
const remote = upstream.split('/')[0] ?? 'origin';
|
|
182
|
+
const fetch = git(root, ...credentialArgs(), 'fetch', '--quiet', remote);
|
|
183
|
+
if (!fetch.ok) {
|
|
184
|
+
const hint = credentialArgs().length ? '' : '\n(gh not found: install it and run gh auth login, or configure a git credential helper)';
|
|
185
|
+
throw new Error(`${label} git fetch ${remote} failed\n${fetch.err}${hint}`);
|
|
186
|
+
}
|
|
187
|
+
const dirty = git(root, 'status', '--porcelain', '--untracked-files=no');
|
|
188
|
+
if (dirty.out)
|
|
189
|
+
throw new Error(`${label} working tree has uncommitted changes, commit or stash them first`);
|
|
190
|
+
const before = git(root, 'rev-parse', 'HEAD').out;
|
|
191
|
+
const target = git(root, 'rev-parse', '--verify', '--quiet', upstream);
|
|
192
|
+
if (!target.ok)
|
|
193
|
+
throw new Error(`${label} unknown upstream ${upstream}`);
|
|
194
|
+
const versionBefore = pluginVersion(root);
|
|
195
|
+
const noPin = `, no pin comment in ${patchFile}`;
|
|
196
|
+
if (before === target.out) {
|
|
197
|
+
// A fresh clone or a manual pull is up to date but may lack the adapter's dependencies.
|
|
198
|
+
if (!options.check)
|
|
199
|
+
installAdapterDependencies(root);
|
|
200
|
+
const pinned = rewritePin(patchFile, checkout, before, !options.check);
|
|
201
|
+
console.log(`${label} up to date at ${short(before)}${versionBefore ? ` (${versionBefore})` : ''}${pinned ? '' : noPin}`);
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
const base = git(root, 'merge-base', before, target.out);
|
|
205
|
+
const fastForward = base.ok && base.out === before;
|
|
206
|
+
const localOnly = base.ok ? git(root, 'rev-list', '--count', `${target.out}..${before}`).out : '';
|
|
207
|
+
if (options.check) {
|
|
208
|
+
const behind = git(root, 'rev-list', '--count', `${before}..${target.out}`).out;
|
|
209
|
+
const how = fastForward ? 'fast-forward' : base.ok ? `diverged, ${localOnly} local commit(s)` : 'unrelated history, needs --reset';
|
|
210
|
+
console.log(`${label} behind ${upstream} by ${behind} commit(s), ${short(before)} -> ${short(target.out)} (${how})`);
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if (fastForward) {
|
|
214
|
+
const merge = git(root, 'merge', '--ff-only', '--quiet', target.out);
|
|
215
|
+
if (!merge.ok)
|
|
216
|
+
throw new Error(`${label} git merge --ff-only failed\n${merge.err}`);
|
|
217
|
+
}
|
|
218
|
+
else if (options.reset) {
|
|
219
|
+
const reset = git(root, 'reset', '--hard', '--quiet', target.out);
|
|
220
|
+
if (!reset.ok)
|
|
221
|
+
throw new Error(`${label} git reset --hard failed\n${reset.err}`);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const why = base.ok
|
|
225
|
+
? `the local branch has ${localOnly} commit(s) not on ${upstream}`
|
|
226
|
+
: `local and ${upstream} share no history (the remote was rewritten)`;
|
|
227
|
+
throw new Error(`${label} cannot fast-forward: ${why}. Re-run with --reset to move the branch onto ${upstream} (undo: git -C ${root} reset --hard ${short(before)}).`);
|
|
228
|
+
}
|
|
229
|
+
installAdapterDependencies(root);
|
|
230
|
+
const after = git(root, 'rev-parse', 'HEAD').out;
|
|
231
|
+
const pinned = rewritePin(patchFile, checkout, after, true);
|
|
232
|
+
const versionAfter = pluginVersion(root);
|
|
233
|
+
const versions = versionBefore || versionAfter ? ` (${versionBefore ?? '?'} -> ${versionAfter ?? '?'})` : '';
|
|
234
|
+
console.log(`${label} ${short(before)} -> ${short(after)}${versions}${pinned ? '' : noPin}`);
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../bin/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAmB5D,SAAS,GAAG,CAAC,IAAY,EAAE,GAAG,IAAc;IAC1C,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;IAC5E,IAAI,MAAM,CAAC,KAAK;QAAE,MAAM,MAAM,CAAC,KAAK,CAAA;IACpC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,C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