harness-config-manager 0.1.4 → 0.1.6
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 +73 -3
- package/builtin/hcm/README.md +1 -1
- package/builtin/hcm/context/10-hcm.md +2 -1
- package/builtin/hcm/hcm.yaml +1 -1
- package/builtin/hcm/skills/hcm-bundle-authoring/SKILL.md +25 -0
- package/builtin/hcm/skills/hcm-bundle-authoring/collections.md +18 -0
- package/builtin/hcm/skills/hcm-integration/remote.md +13 -1
- package/builtin/hcm/skills/hcm-usage/SKILL.md +32 -3
- package/builtin/hcm/skills/hcm-usage/commands.md +4 -1
- package/builtin/hcm/skills/hcm-usage/requirements.md +182 -0
- package/dist/cli.js +42 -9
- package/dist/cli.js.map +1 -1
- package/dist/commands/list.d.ts +43 -1
- package/dist/commands/list.js +258 -36
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/requirements.d.ts +12 -0
- package/dist/commands/requirements.js +110 -0
- package/dist/commands/requirements.js.map +1 -0
- package/dist/core/analysis.d.ts +51 -0
- package/dist/core/analysis.js +90 -0
- package/dist/core/analysis.js.map +1 -0
- package/dist/core/executor.js +9 -1
- package/dist/core/executor.js.map +1 -1
- package/dist/core/git-cli.d.ts +64 -0
- package/dist/core/git-cli.js +147 -0
- package/dist/core/git-cli.js.map +1 -0
- package/dist/core/git.d.ts +19 -0
- package/dist/core/git.js +36 -4
- package/dist/core/git.js.map +1 -1
- package/dist/core/refs.js +1 -1
- package/dist/core/refs.js.map +1 -1
- package/dist/core/registry.js +6 -3
- package/dist/core/registry.js.map +1 -1
- package/dist/core/requirements.d.ts +92 -0
- package/dist/core/requirements.js +326 -0
- package/dist/core/requirements.js.map +1 -0
- package/dist/core/types.d.ts +22 -4
- package/dist/core/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hcm install -r [file]`: install the bundles that a project's requirements
|
|
3
|
+
* file lists. See `core/requirements.ts` for the file.
|
|
4
|
+
*
|
|
5
|
+
* The run has two phases. First, every line is read and every source is
|
|
6
|
+
* downloaded, and each named bundle is found. Then the bundles are installed.
|
|
7
|
+
* Thus a typing error on the last line stops the run before the first bundle
|
|
8
|
+
* is written.
|
|
9
|
+
*/
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { HcmError } from '../core/errors.js';
|
|
12
|
+
import { readTextIfExists } from '../core/fsx.js';
|
|
13
|
+
import { sourceReference } from '../core/github.js';
|
|
14
|
+
import { color, log } from '../core/logger.js';
|
|
15
|
+
import { availableEntries, matchEntry } from '../core/registry.js';
|
|
16
|
+
import { DEFAULT_REQUIREMENTS_FILE, locateRequirement, parseRequirements, } from '../core/requirements.js';
|
|
17
|
+
import { installCommand } from './install.js';
|
|
18
|
+
export async function installRequirementsCommand(file, options) {
|
|
19
|
+
const target = path.resolve(options.cwd, file ?? DEFAULT_REQUIREMENTS_FILE);
|
|
20
|
+
const contents = await readTextIfExists(target);
|
|
21
|
+
if (contents === undefined) {
|
|
22
|
+
throw new HcmError(`No such file: ${target}`, `Create ${DEFAULT_REQUIREMENTS_FILE} with one line per bundle: "<bundle> @ <url>[@ref]", or "<bundle>".`);
|
|
23
|
+
}
|
|
24
|
+
const requirements = parseRequirements(contents, path.dirname(target));
|
|
25
|
+
if (requirements.length === 0) {
|
|
26
|
+
log.warn(`${target} lists no bundles.`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
log.info(`Reading ${requirements.length} bundle(s) from ${target}`);
|
|
30
|
+
const resolved = await resolveRequirements(requirements, options);
|
|
31
|
+
// One memory of conflict answers and parameter answers for the whole file,
|
|
32
|
+
// as `hcm import` does: five bundles that want AGENT_NAME ask for it once.
|
|
33
|
+
const decisions = options.decisions ?? new Map();
|
|
34
|
+
const answers = options.answers ?? new Map();
|
|
35
|
+
for (const { requirement, reference } of resolved) {
|
|
36
|
+
await installCommand(reference, {
|
|
37
|
+
...options,
|
|
38
|
+
decisions,
|
|
39
|
+
answers,
|
|
40
|
+
...(requirement.targets ? { targets: requirement.targets } : {}),
|
|
41
|
+
...(requirement.flavors ? { flavors: requirement.flavors } : {}),
|
|
42
|
+
params: [...(options.params ?? []), ...scopedParams(requirement)],
|
|
43
|
+
// A line with a source pins the installation to that source, so that
|
|
44
|
+
// "hcm update" reads the same branch or tag, not the registry.
|
|
45
|
+
...(requirement.source ? { track: 'source' } : {}),
|
|
46
|
+
// Every source was downloaded in the first phase; read that copy.
|
|
47
|
+
refresh: false,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
log.info('');
|
|
51
|
+
log.success(`${resolved.length} bundle(s) from ${path.basename(target)} ` +
|
|
52
|
+
`${options.dryRun ? 'checked (dry run)' : 'installed'}.`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Find the bundle of every line. All lines are tried, and all errors are
|
|
56
|
+
* reported together.
|
|
57
|
+
*
|
|
58
|
+
* Each source is downloaded again, so a branch gives its latest commit. A
|
|
59
|
+
* repository that several lines use is downloaded once.
|
|
60
|
+
*/
|
|
61
|
+
async function resolveRequirements(requirements, options) {
|
|
62
|
+
const fetched = new Set();
|
|
63
|
+
const entries = await availableEntries();
|
|
64
|
+
const resolved = [];
|
|
65
|
+
const problems = [];
|
|
66
|
+
let unregistered = false;
|
|
67
|
+
for (const requirement of requirements) {
|
|
68
|
+
try {
|
|
69
|
+
if (requirement.source) {
|
|
70
|
+
const source = await locateRequirement({ ...requirement, source: requirement.source }, { refresh: options.refresh ?? true, fetched });
|
|
71
|
+
resolved.push({ requirement, reference: sourceReference(source), source });
|
|
72
|
+
log.info(` ${color.bold(requirement.name)} ${color.dim(sourceReference(source))}`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const entry = matchEntry(entries, requirement.name);
|
|
76
|
+
if (!entry) {
|
|
77
|
+
unregistered = true;
|
|
78
|
+
throw new HcmError(`"${requirement.name}" gives no source, and no bundle of that name is registered`);
|
|
79
|
+
}
|
|
80
|
+
resolved.push({ requirement, reference: entry.name });
|
|
81
|
+
log.info(` ${color.bold(requirement.name)} ${color.dim('(registry)')}`);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (!(error instanceof HcmError))
|
|
85
|
+
throw error;
|
|
86
|
+
problems.push(`line ${requirement.line} (${requirement.name}): ${error.message}`);
|
|
87
|
+
if (error.hint)
|
|
88
|
+
problems.push(` ${error.hint}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (problems.length > 0) {
|
|
92
|
+
throw new HcmError(`Cannot install the requirements file, so nothing was installed:\n ${problems.join('\n ')}`, unregistered
|
|
93
|
+
? 'For a line with no source, register the bundle with "hcm registry add <path|url>", ' +
|
|
94
|
+
'or give its source as "<bundle> @ <url>".'
|
|
95
|
+
: undefined);
|
|
96
|
+
}
|
|
97
|
+
return resolved;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The `--param` values of one line, limited to the bundle of that line. An
|
|
101
|
+
* unscoped `NAME=value` on the line becomes `<bundle>:NAME=value`, so that it
|
|
102
|
+
* does not apply to the dependencies of the bundle.
|
|
103
|
+
*/
|
|
104
|
+
function scopedParams(requirement) {
|
|
105
|
+
return (requirement.params ?? []).map((assignment) => {
|
|
106
|
+
const key = assignment.slice(0, assignment.indexOf('='));
|
|
107
|
+
return key.includes(':') ? assignment : `${requirement.name}:${assignment}`;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=requirements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirements.js","sourceRoot":"","sources":["../../src/commands/requirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,eAAe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CAAC;gBAAE,MAAM,KAAK,CAAC;YAC9C,QAAQ,CAAC,IAAI,CAAC,QAAQ,WAAW,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAClF,IAAI,KAAK,CAAC,IAAI;gBAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,QAAQ,CAChB,sEAAsE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAC7F,YAAY;YACV,CAAC,CAAC,qFAAqF;gBACnF,2CAA2C;YAC/C,CAAC,CAAC,SAAS,CACd,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,WAAwB;IAC5C,OAAO,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QACnD,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACzD,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,IAAI,UAAU,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each installed bundle brings to a project: its items, and every file or
|
|
3
|
+
* file entry that each item wrote. `hcm list --analysis` prints it.
|
|
4
|
+
*
|
|
5
|
+
* Installed files keep the names that the harness expects, so the file system
|
|
6
|
+
* cannot tell which bundle owns them. The receipts can: each one records its
|
|
7
|
+
* path, and, since this module exists, the bundle item it came from.
|
|
8
|
+
*/
|
|
9
|
+
import { type Claim } from './state.js';
|
|
10
|
+
import { type InstallationRecord, type Receipt, type ResourceKind, type Scope, type TargetId } from './types.js';
|
|
11
|
+
/** One file, or one entry in a file, that an installation wrote. */
|
|
12
|
+
export interface AnalyzedEntry {
|
|
13
|
+
op: Receipt['op'];
|
|
14
|
+
/**
|
|
15
|
+
* Where it is: relative to the project for project scope, from `~/` or as an
|
|
16
|
+
* absolute path for user scope.
|
|
17
|
+
*/
|
|
18
|
+
path: string;
|
|
19
|
+
/** The path, plus the key or block inside the file for a partial entry. */
|
|
20
|
+
location: string;
|
|
21
|
+
/** It was there before hcm, so hcm does not remove it. */
|
|
22
|
+
adopted: boolean;
|
|
23
|
+
/** The other bundles that claim the same file or entry. */
|
|
24
|
+
sharedWith: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One item of a bundle as installed. `kind` is `unknown` for receipts written
|
|
28
|
+
* before hcm recorded the item. Those receipts are grouped under one item.
|
|
29
|
+
*/
|
|
30
|
+
export interface AnalyzedItem {
|
|
31
|
+
kind: ResourceKind | 'unknown';
|
|
32
|
+
name: string;
|
|
33
|
+
entries: AnalyzedEntry[];
|
|
34
|
+
}
|
|
35
|
+
export interface AnalyzedInstallation {
|
|
36
|
+
bundle: string;
|
|
37
|
+
version: string;
|
|
38
|
+
scope: Scope;
|
|
39
|
+
target: TargetId;
|
|
40
|
+
items: AnalyzedItem[];
|
|
41
|
+
}
|
|
42
|
+
/** A path as a person finds it: in the project, under `~/`, or absolute. */
|
|
43
|
+
export declare function displayPath(scopeRoot: string, relative: string, cwd: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Break installations down into items and entries.
|
|
46
|
+
*
|
|
47
|
+
* `claims` is what `collectClaims` returns: every claim on every file and
|
|
48
|
+
* entry. An entry that another bundle also claims is marked with that bundle,
|
|
49
|
+
* because uninstalling one of them leaves the entry in place.
|
|
50
|
+
*/
|
|
51
|
+
export declare function analyzeInstallations(records: InstallationRecord[], claims: Map<string, Claim[]>, cwd: string): AnalyzedInstallation[];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each installed bundle brings to a project: its items, and every file or
|
|
3
|
+
* file entry that each item wrote. `hcm list --analysis` prints it.
|
|
4
|
+
*
|
|
5
|
+
* Installed files keep the names that the harness expects, so the file system
|
|
6
|
+
* cannot tell which bundle owns them. The receipts can: each one records its
|
|
7
|
+
* path, and, since this module exists, the bundle item it came from.
|
|
8
|
+
*/
|
|
9
|
+
import os from 'node:os';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { toPosix } from './fsx.js';
|
|
12
|
+
import { claimKeys } from './state.js';
|
|
13
|
+
import { describeReceipt, isPreexisting, KIND_DIRECTORIES, } from './types.js';
|
|
14
|
+
import { getTarget } from '../targets/index.js';
|
|
15
|
+
/** The order in which items are shown: the order of the bundle schema. */
|
|
16
|
+
const KIND_ORDER = [...Object.values(KIND_DIRECTORIES), 'unknown'];
|
|
17
|
+
/**
|
|
18
|
+
* The item of a receipt. A context block without an item still names it: its
|
|
19
|
+
* block id is `<bundle>/<resource>`.
|
|
20
|
+
*/
|
|
21
|
+
function itemKey(receipt) {
|
|
22
|
+
if (receipt.item)
|
|
23
|
+
return receipt.item;
|
|
24
|
+
if (receipt.op === 'block') {
|
|
25
|
+
return { kind: 'context', name: receipt.blockId.slice(receipt.blockId.indexOf('/') + 1) };
|
|
26
|
+
}
|
|
27
|
+
return { kind: 'unknown', name: '' };
|
|
28
|
+
}
|
|
29
|
+
/** A path as a person finds it: in the project, under `~/`, or absolute. */
|
|
30
|
+
export function displayPath(scopeRoot, relative, cwd) {
|
|
31
|
+
const absolute = path.resolve(scopeRoot, ...relative.split('/'));
|
|
32
|
+
for (const [base, prefix] of [
|
|
33
|
+
[path.resolve(cwd), ''],
|
|
34
|
+
[os.homedir(), '~/'],
|
|
35
|
+
]) {
|
|
36
|
+
const inside = path.relative(base, absolute);
|
|
37
|
+
if (inside && !inside.startsWith('..') && !path.isAbsolute(inside)) {
|
|
38
|
+
return `${prefix}${toPosix(inside)}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return toPosix(absolute);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Break installations down into items and entries.
|
|
45
|
+
*
|
|
46
|
+
* `claims` is what `collectClaims` returns: every claim on every file and
|
|
47
|
+
* entry. An entry that another bundle also claims is marked with that bundle,
|
|
48
|
+
* because uninstalling one of them leaves the entry in place.
|
|
49
|
+
*/
|
|
50
|
+
export function analyzeInstallations(records, claims, cwd) {
|
|
51
|
+
return records.map((record) => {
|
|
52
|
+
const scopeRoot = getTarget(record.target).scopeRoot(record.scope, cwd);
|
|
53
|
+
const items = new Map();
|
|
54
|
+
for (const receipt of record.receipts) {
|
|
55
|
+
const { kind, name } = itemKey(receipt);
|
|
56
|
+
const key = `${kind}:${name}`;
|
|
57
|
+
let item = items.get(key);
|
|
58
|
+
if (!item) {
|
|
59
|
+
item = { kind, name, entries: [] };
|
|
60
|
+
items.set(key, item);
|
|
61
|
+
}
|
|
62
|
+
const others = new Set();
|
|
63
|
+
for (const { key: claimKey } of claimKeys(receipt, scopeRoot)) {
|
|
64
|
+
for (const claim of claims.get(claimKey) ?? []) {
|
|
65
|
+
if (claim.bundle !== record.bundle)
|
|
66
|
+
others.add(claim.bundle);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const shown = displayPath(scopeRoot, receipt.path, cwd);
|
|
70
|
+
item.entries.push({
|
|
71
|
+
op: receipt.op,
|
|
72
|
+
path: shown,
|
|
73
|
+
location: shown + describeReceipt(receipt).slice(receipt.path.length),
|
|
74
|
+
adopted: isPreexisting(receipt),
|
|
75
|
+
sharedWith: [...others].sort(),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const sorted = [...items.values()].sort((a, b) => KIND_ORDER.indexOf(a.kind) - KIND_ORDER.indexOf(b.kind) || a.name.localeCompare(b.name));
|
|
79
|
+
for (const item of sorted)
|
|
80
|
+
item.entries.sort((a, b) => a.location.localeCompare(b.location));
|
|
81
|
+
return {
|
|
82
|
+
bundle: record.bundle,
|
|
83
|
+
version: record.version,
|
|
84
|
+
scope: record.scope,
|
|
85
|
+
target: record.target,
|
|
86
|
+
items: sorted,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=analysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysis.js","sourceRoot":"","sources":["../../src/core/analysis.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,SAAS,EAAc,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,eAAe,EACf,aAAa,EACb,gBAAgB,GAMjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAoChD,0EAA0E;AAC1E,MAAM,UAAU,GAAiC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC,CAAC;AAEjG;;;GAGG;AACH,SAAS,OAAO,CAAC,OAAgB;IAC/B,IAAI,OAAO,CAAC,IAAI;QAAE,OAAO,OAAO,CAAC,IAAI,CAAC;IACtC,IAAI,OAAO,CAAC,EAAE,KAAK,OAAO,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAC5F,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACvC,CAAC;A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U,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAClG,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,MAAM;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE7F,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM;SACd,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/core/executor.js
CHANGED
|
@@ -9,6 +9,10 @@ import { fromPosix, pathExists, readJsonIfExists, readTextIfExists, writeBytes,
|
|
|
9
9
|
import { hashValue, sha256, valuesEqual } from './hash.js';
|
|
10
10
|
import { upsertBlock } from '../merge/blocks.js';
|
|
11
11
|
import { appendArrayItems, setAtPointer } from '../merge/json-merge.js';
|
|
12
|
+
/** The bundle item that an action writes, for its receipt. See `ReceiptItem`. */
|
|
13
|
+
function itemOf(action) {
|
|
14
|
+
return action.resource ? { item: { kind: action.resource.kind, name: action.resource.name } } : {};
|
|
15
|
+
}
|
|
12
16
|
export async function applyPlan(plan) {
|
|
13
17
|
const receipts = [];
|
|
14
18
|
const byFile = groupByPath(plan.actions);
|
|
@@ -35,6 +39,7 @@ export async function applyPlan(plan) {
|
|
|
35
39
|
path: relativePath,
|
|
36
40
|
hash: sha256(contents),
|
|
37
41
|
...(action.adopt ? { preexisting: true } : {}),
|
|
42
|
+
...itemOf(action),
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
continue;
|
|
@@ -66,7 +71,7 @@ async function applyBlocks(absolutePath, relativePath, actions) {
|
|
|
66
71
|
continue;
|
|
67
72
|
const { blockId, syntax, body } = action.payload;
|
|
68
73
|
content = upsertBlock(content, syntax, blockId, body);
|
|
69
|
-
receipts.push({ op: 'block', path: relativePath, blockId, syntax });
|
|
74
|
+
receipts.push({ op: 'block', path: relativePath, blockId, syntax, ...itemOf(action) });
|
|
70
75
|
}
|
|
71
76
|
await writeText(absolutePath, content);
|
|
72
77
|
return receipts;
|
|
@@ -91,6 +96,7 @@ async function applyJson(absolutePath, relativePath, actions) {
|
|
|
91
96
|
hash: hashValue(value),
|
|
92
97
|
hadPrevious: false,
|
|
93
98
|
...(action.adopt ? { preexisting: true } : {}),
|
|
99
|
+
...itemOf(action),
|
|
94
100
|
});
|
|
95
101
|
continue;
|
|
96
102
|
}
|
|
@@ -106,6 +112,7 @@ async function applyJson(absolutePath, relativePath, actions) {
|
|
|
106
112
|
hash: hashValue(value),
|
|
107
113
|
hadPrevious: overwrote,
|
|
108
114
|
...(overwrote ? { previous: result.previous } : {}),
|
|
115
|
+
...itemOf(action),
|
|
109
116
|
});
|
|
110
117
|
continue;
|
|
111
118
|
}
|
|
@@ -127,6 +134,7 @@ async function applyJson(absolutePath, relativePath, actions) {
|
|
|
127
134
|
path: relativePath,
|
|
128
135
|
pointer,
|
|
129
136
|
hashes: [...hashes],
|
|
137
|
+
...itemOf(action),
|
|
130
138
|
});
|
|
131
139
|
}
|
|
132
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/core/executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,SAAS,GACV,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAA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AAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnD,GAAG,MAAM,CAAC,MAAM,CAAC;aAClB,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;YAC1C,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YACrD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;gBAAE,OAAO,GAAG,IAAI,CAAC;YAE/C,0EAA0E;YAC1E,uEAAuE;YACvE,uEAAuE;YACvE,sEAAsE;YACtE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;gBACrB,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACjD,GAAG,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;aAC7B,CAAC,CAAC;YAEH,QAAQ,CAAC,IAAI,CAAC;gBACZ,EAAE,EAAE,iBAAiB;gBACrB,IAAI,EAAE,YAAY;gBAClB,OAAO;gBACP,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC;gBACnB,GAAG,MAAM,CAAC,MAAM,CAAC;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,2EAA2E;IAC3E,sDAAsD;IACtD,IAAI,OAAO;QAAE,MAAM,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloading a repository with the `git` program, for SSH and git:// URLs.
|
|
3
|
+
*
|
|
4
|
+
* The HTTPS client in `git-http.ts` needs no `git` on the machine. SSH is a
|
|
5
|
+
* different case: the keys, the agent and `~/.ssh/config` belong to the
|
|
6
|
+
* user's own SSH setup, and only the `git` program uses them. So hcm runs
|
|
7
|
+
* `git` for these URLs, and reads the same result as the HTTPS client gives:
|
|
8
|
+
* the files of one commit, without the history.
|
|
9
|
+
*
|
|
10
|
+
* The work is done in a temporary bare repository:
|
|
11
|
+
*
|
|
12
|
+
* git init --bare an empty repository, with no work tree
|
|
13
|
+
* git fetch --depth 1 <url> <ref> one commit, written to FETCH_HEAD
|
|
14
|
+
* git ls-tree -r -z FETCH_HEAD the files of that commit
|
|
15
|
+
* git cat-file --batch their contents
|
|
16
|
+
*
|
|
17
|
+
* A bare repository has no checkout, so `core.autocrlf` and the other
|
|
18
|
+
* work-tree settings do not change the bytes. The files are the blobs as they
|
|
19
|
+
* are in the repository, as the HTTPS client gives them.
|
|
20
|
+
*/
|
|
21
|
+
import type { GitDownload } from './git-http.js';
|
|
22
|
+
/** The output of one `git` process. */
|
|
23
|
+
export interface GitRunResult {
|
|
24
|
+
code: number;
|
|
25
|
+
stdout: Buffer;
|
|
26
|
+
stderr: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Runs one `git` command. A test can give its own runner, so that the tests
|
|
30
|
+
* do not need SSH.
|
|
31
|
+
*/
|
|
32
|
+
export type GitRunner = (args: string[], options?: {
|
|
33
|
+
input?: Buffer;
|
|
34
|
+
}) => Promise<GitRunResult>;
|
|
35
|
+
/** The default runner: the `git` program on the PATH. */
|
|
36
|
+
export declare const runGit: GitRunner;
|
|
37
|
+
/**
|
|
38
|
+
* Download the files of one ref of a repository with the `git` program.
|
|
39
|
+
*
|
|
40
|
+
* `url` is any URL that `git fetch` accepts. `ref` is a branch, a tag, a full
|
|
41
|
+
* commit id, or `HEAD` for the default branch.
|
|
42
|
+
*/
|
|
43
|
+
export declare function downloadWithGit(options: {
|
|
44
|
+
url: string;
|
|
45
|
+
ref: string;
|
|
46
|
+
}, run?: GitRunner): Promise<GitDownload>;
|
|
47
|
+
interface TreeEntry {
|
|
48
|
+
mode: string;
|
|
49
|
+
id: string;
|
|
50
|
+
path: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Read `git ls-tree -r -z`. Each entry is `<mode> <type> <id>\t<path>\0`.
|
|
54
|
+
*
|
|
55
|
+
* Symbolic links and submodules are left out, for the same reasons as in
|
|
56
|
+
* `git-http.ts`. A path that could leave the target directory is refused.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseLsTree(output: Buffer): TreeEntry[];
|
|
59
|
+
/**
|
|
60
|
+
* Read `git cat-file --batch`. Each object is `<id> <type> <size>\n`, then the
|
|
61
|
+
* bytes, then a newline. A missing object is `<id> missing\n`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseCatFileBatch(output: Buffer): Map<string, Buffer>;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloading a repository with the `git` program, for SSH and git:// URLs.
|
|
3
|
+
*
|
|
4
|
+
* The HTTPS client in `git-http.ts` needs no `git` on the machine. SSH is a
|
|
5
|
+
* different case: the keys, the agent and `~/.ssh/config` belong to the
|
|
6
|
+
* user's own SSH setup, and only the `git` program uses them. So hcm runs
|
|
7
|
+
* `git` for these URLs, and reads the same result as the HTTPS client gives:
|
|
8
|
+
* the files of one commit, without the history.
|
|
9
|
+
*
|
|
10
|
+
* The work is done in a temporary bare repository:
|
|
11
|
+
*
|
|
12
|
+
* git init --bare an empty repository, with no work tree
|
|
13
|
+
* git fetch --depth 1 <url> <ref> one commit, written to FETCH_HEAD
|
|
14
|
+
* git ls-tree -r -z FETCH_HEAD the files of that commit
|
|
15
|
+
* git cat-file --batch their contents
|
|
16
|
+
*
|
|
17
|
+
* A bare repository has no checkout, so `core.autocrlf` and the other
|
|
18
|
+
* work-tree settings do not change the bytes. The files are the blobs as they
|
|
19
|
+
* are in the repository, as the HTTPS client gives them.
|
|
20
|
+
*/
|
|
21
|
+
import { spawn } from 'node:child_process';
|
|
22
|
+
import os from 'node:os';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { HcmError } from './errors.js';
|
|
25
|
+
import { fs } from './fsx.js';
|
|
26
|
+
const MODE_SYMLINK = '120000';
|
|
27
|
+
const MODE_SUBMODULE = '160000';
|
|
28
|
+
const NO_GIT_HINT = 'Install git, and make sure that the "git" command is on the PATH. ' +
|
|
29
|
+
'Or use the HTTPS clone URL of the repository, with a token in HCM_GIT_TOKEN.';
|
|
30
|
+
/** The default runner: the `git` program on the PATH. */
|
|
31
|
+
export const runGit = (args, options = {}) => new Promise((resolve, reject) => {
|
|
32
|
+
const child = spawn('git', args, {
|
|
33
|
+
// The terminal stays with the user, so SSH can ask for a key passphrase.
|
|
34
|
+
// Git itself must not ask for a user name: there is nobody to answer.
|
|
35
|
+
stdio: [options.input ? 'pipe' : 'inherit', 'pipe', 'pipe'],
|
|
36
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
37
|
+
windowsHide: true,
|
|
38
|
+
});
|
|
39
|
+
const stdout = [];
|
|
40
|
+
const stderr = [];
|
|
41
|
+
child.stdout?.on('data', (chunk) => stdout.push(chunk));
|
|
42
|
+
child.stderr?.on('data', (chunk) => stderr.push(chunk));
|
|
43
|
+
child.on('error', (error) => {
|
|
44
|
+
if (error.code === 'ENOENT') {
|
|
45
|
+
reject(new HcmError('An SSH or git:// URL needs the git program, which is not installed', NO_GIT_HINT));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
reject(error);
|
|
49
|
+
});
|
|
50
|
+
child.on('close', (code) => {
|
|
51
|
+
resolve({
|
|
52
|
+
code: code ?? 1,
|
|
53
|
+
stdout: Buffer.concat(stdout),
|
|
54
|
+
stderr: Buffer.concat(stderr).toString('utf8').trim(),
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
if (options.input)
|
|
58
|
+
child.stdin?.end(options.input);
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Download the files of one ref of a repository with the `git` program.
|
|
62
|
+
*
|
|
63
|
+
* `url` is any URL that `git fetch` accepts. `ref` is a branch, a tag, a full
|
|
64
|
+
* commit id, or `HEAD` for the default branch.
|
|
65
|
+
*/
|
|
66
|
+
export async function downloadWithGit(options, run = runGit) {
|
|
67
|
+
const temporary = await fs.mkdtemp(path.join(os.tmpdir(), 'hcm-git-'));
|
|
68
|
+
try {
|
|
69
|
+
const git = async (args, input) => {
|
|
70
|
+
const result = await run(['-C', temporary, ...args], input ? { input } : {});
|
|
71
|
+
if (result.code !== 0)
|
|
72
|
+
throw fetchFailure(options, result.stderr);
|
|
73
|
+
return result.stdout;
|
|
74
|
+
};
|
|
75
|
+
await git(['init', '--bare', '--quiet']);
|
|
76
|
+
await git(['fetch', '--depth', '1', '--no-tags', '--quiet', options.url, options.ref]);
|
|
77
|
+
const commit = (await git(['rev-parse', 'FETCH_HEAD'])).toString('utf8').trim();
|
|
78
|
+
const entries = parseLsTree(await git(['ls-tree', '-r', '-z', '--full-tree', commit]));
|
|
79
|
+
if (entries.length === 0)
|
|
80
|
+
return { commit, files: [] };
|
|
81
|
+
const contents = parseCatFileBatch(await git(['cat-file', '--batch'], Buffer.from(entries.map((entry) => `${entry.id}\n`).join(''))));
|
|
82
|
+
const files = entries.map((entry) => {
|
|
83
|
+
const data = contents.get(entry.id);
|
|
84
|
+
if (!data)
|
|
85
|
+
throw new HcmError(`git did not return the contents of "${entry.path}"`);
|
|
86
|
+
return { path: entry.path, data, executable: entry.mode === '100755' };
|
|
87
|
+
});
|
|
88
|
+
return { commit, files };
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
await fs.rm(temporary, { recursive: true, force: true });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function fetchFailure(options, stderr) {
|
|
95
|
+
const detail = stderr.replace(/^fatal:\s*/gim, '').split(/\r?\n/).filter(Boolean).join(' ');
|
|
96
|
+
return new HcmError(`git could not read ${options.url} at ${options.ref}${detail ? `: ${detail}` : ''}`, 'Check the URL and the ref. For SSH, make sure that "git ls-remote <url>" works in this terminal.');
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Read `git ls-tree -r -z`. Each entry is `<mode> <type> <id>\t<path>\0`.
|
|
100
|
+
*
|
|
101
|
+
* Symbolic links and submodules are left out, for the same reasons as in
|
|
102
|
+
* `git-http.ts`. A path that could leave the target directory is refused.
|
|
103
|
+
*/
|
|
104
|
+
export function parseLsTree(output) {
|
|
105
|
+
const entries = [];
|
|
106
|
+
for (const record of output.toString('utf8').split('\0')) {
|
|
107
|
+
if (!record)
|
|
108
|
+
continue;
|
|
109
|
+
const match = /^(\d+) (\w+) ([0-9a-f]+)\t(.+)$/s.exec(record);
|
|
110
|
+
if (!match)
|
|
111
|
+
throw new HcmError(`git returned a tree entry that hcm cannot read: "${record}"`);
|
|
112
|
+
const [, mode, type, id, entryPath] = match;
|
|
113
|
+
if (type !== 'blob' || mode === MODE_SYMLINK || mode === MODE_SUBMODULE)
|
|
114
|
+
continue;
|
|
115
|
+
const parts = entryPath.split('/');
|
|
116
|
+
if (parts.some((part) => part === '' || part === '.' || part === '..' || /[\\\0]/.test(part))) {
|
|
117
|
+
throw new HcmError(`The repository has a file name that hcm does not write: "${entryPath}"`);
|
|
118
|
+
}
|
|
119
|
+
if (parts.some((part) => part.toLowerCase() === '.git'))
|
|
120
|
+
continue;
|
|
121
|
+
entries.push({ mode, id, path: entryPath });
|
|
122
|
+
}
|
|
123
|
+
return entries;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Read `git cat-file --batch`. Each object is `<id> <type> <size>\n`, then the
|
|
127
|
+
* bytes, then a newline. A missing object is `<id> missing\n`.
|
|
128
|
+
*/
|
|
129
|
+
export function parseCatFileBatch(output) {
|
|
130
|
+
const objects = new Map();
|
|
131
|
+
let position = 0;
|
|
132
|
+
while (position < output.length) {
|
|
133
|
+
const newline = output.indexOf(0x0a, position);
|
|
134
|
+
if (newline < 0)
|
|
135
|
+
break;
|
|
136
|
+
const header = output.toString('utf8', position, newline);
|
|
137
|
+
position = newline + 1;
|
|
138
|
+
const match = /^([0-9a-f]+) (\w+) (\d+)$/.exec(header);
|
|
139
|
+
if (!match)
|
|
140
|
+
continue;
|
|
141
|
+
const size = Number(match[3]);
|
|
142
|
+
objects.set(match[1], output.subarray(position, position + size));
|
|
143
|
+
position += size + 1;
|
|
144
|
+
}
|
|
145
|
+
return objects;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=git-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cli.js","sourceRoot":"","sources":["../../src/core/git-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAgB9B,MAAM,YAAY,GAAG,QAAQ,CAAC;AAC9B,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEhC,MAAM,WAAW,GACf,oEAAoE;IACpE,8EAA8E,CAAC;AAEjF,yDAAyD;AACzD,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,IAAI,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,CACtD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE;QAC/B,yEAAyE;QACzE,sEAAsE;QACtE,KAAK,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;QAC3D,GAAG,EAAE,EAAE,GAAG,OAAO,CAA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MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,OAAO,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC/C,IAAI,OAAO,GAAG,CAAC;YAAE,MAAM;QACvB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC1D,QAAQ,GAAG,OAAO,GAAG,CAAC,CAAC;QAEvB,MAAM,KAAK,GAAG,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,CAAC,KAAK;YAAE,SAAS;QAErB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;QAC5E,QAAQ,IAAI,IAAI,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/core/git.d.ts
CHANGED
|
@@ -42,8 +42,27 @@ export interface FetchOptions {
|
|
|
42
42
|
*
|
|
43
43
|
* An Azure DevOps browser URL has the same data in its query string
|
|
44
44
|
* (`?path=/bundles/my-kit&version=GBmain`), and that is read too.
|
|
45
|
+
*
|
|
46
|
+
* SSH and git:// URLs are read too, and the `git` program downloads them --
|
|
47
|
+
* see `git-cli.ts`. The scp-like form is stored in the `ssh://` form:
|
|
48
|
+
*
|
|
49
|
+
* git@ssh.dev.azure.com:v3/org/project/repo Azure DevOps over SSH
|
|
50
|
+
* ssh://git@gitlab.com/group/repo.git the protocol form
|
|
51
|
+
* git+ssh://git@github.com:owner/repo.git pip style, with an scp-like path
|
|
45
52
|
*/
|
|
46
53
|
export declare function parseGitSource(input: string): GitSource | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Write an scp-like SSH address in the `ssh://` form, which `URL` can read:
|
|
56
|
+
*
|
|
57
|
+
* git@host:path -> ssh://git@host/path
|
|
58
|
+
* ssh://git@host:path -> ssh://git@host/path (a path, not a port)
|
|
59
|
+
*
|
|
60
|
+
* A port is digits only, so `ssh://git@host:2222/path` stays as it is. The
|
|
61
|
+
* scp-like form needs the user name: without it, `C:path` would read as a host.
|
|
62
|
+
*/
|
|
63
|
+
export declare function toSshUrl(input: string): string;
|
|
64
|
+
/** True for a URL that the `git` program downloads, not the HTTPS client. */
|
|
65
|
+
export declare function needsGitProgram(url: string): boolean;
|
|
47
66
|
/**
|
|
48
67
|
* The text that `parseGitSource` reads back into this source.
|
|
49
68
|
*
|