harness-config-manager 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1547 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +584 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.js +49 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +24 -0
- package/dist/commands/context.js +329 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/export.d.ts +19 -0
- package/dist/commands/export.js +116 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +33 -0
- package/dist/commands/import.js +81 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/info.d.ts +19 -0
- package/dist/commands/info.js +235 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.js +116 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +119 -0
- package/dist/commands/install.js +533 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/list.d.ts +9 -0
- package/dist/commands/list.js +102 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/params.d.ts +58 -0
- package/dist/commands/params.js +366 -0
- package/dist/commands/params.js.map +1 -0
- package/dist/commands/refs.d.ts +60 -0
- package/dist/commands/refs.js +329 -0
- package/dist/commands/refs.js.map +1 -0
- package/dist/commands/registry.d.ts +18 -0
- package/dist/commands/registry.js +173 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/status.d.ts +10 -0
- package/dist/commands/status.js +83 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/targets.d.ts +8 -0
- package/dist/commands/targets.js +61 -0
- package/dist/commands/targets.js.map +1 -0
- package/dist/commands/uninstall.d.ts +71 -0
- package/dist/commands/uninstall.js +322 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +66 -0
- package/dist/commands/update.js +384 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.js +38 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/core/bundle.d.ts +49 -0
- package/dist/core/bundle.js +326 -0
- package/dist/core/bundle.js.map +1 -0
- package/dist/core/config.d.ts +65 -0
- package/dist/core/config.js +112 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/conflicts.d.ts +67 -0
- package/dist/core/conflicts.js +300 -0
- package/dist/core/conflicts.js.map +1 -0
- package/dist/core/context.d.ts +139 -0
- package/dist/core/context.js +432 -0
- package/dist/core/context.js.map +1 -0
- package/dist/core/deps.d.ts +62 -0
- package/dist/core/deps.js +339 -0
- package/dist/core/deps.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +26 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/executor.d.ts +9 -0
- package/dist/core/executor.js +139 -0
- package/dist/core/executor.js.map +1 -0
- package/dist/core/flavors.d.ts +128 -0
- package/dist/core/flavors.js +386 -0
- package/dist/core/flavors.js.map +1 -0
- package/dist/core/frontmatter.d.ts +6 -0
- package/dist/core/frontmatter.js +20 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/fsx.d.ts +40 -0
- package/dist/core/fsx.js +180 -0
- package/dist/core/fsx.js.map +1 -0
- package/dist/core/github.d.ts +37 -0
- package/dist/core/github.js +157 -0
- package/dist/core/github.js.map +1 -0
- package/dist/core/harnesses.d.ts +142 -0
- package/dist/core/harnesses.js +215 -0
- package/dist/core/harnesses.js.map +1 -0
- package/dist/core/hash.d.ts +12 -0
- package/dist/core/hash.js +34 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/logger.d.ts +16 -0
- package/dist/core/logger.js +36 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/overlap.d.ts +79 -0
- package/dist/core/overlap.js +155 -0
- package/dist/core/overlap.js.map +1 -0
- package/dist/core/parameters.d.ts +249 -0
- package/dist/core/parameters.js +944 -0
- package/dist/core/parameters.js.map +1 -0
- package/dist/core/paths.d.ts +20 -0
- package/dist/core/paths.js +35 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/planner.d.ts +36 -0
- package/dist/core/planner.js +364 -0
- package/dist/core/planner.js.map +1 -0
- package/dist/core/prompt.d.ts +52 -0
- package/dist/core/prompt.js +197 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/refmap.d.ts +91 -0
- package/dist/core/refmap.js +331 -0
- package/dist/core/refmap.js.map +1 -0
- package/dist/core/refs.d.ts +297 -0
- package/dist/core/refs.js +801 -0
- package/dist/core/refs.js.map +1 -0
- package/dist/core/registry.d.ts +119 -0
- package/dist/core/registry.js +363 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/rename.d.ts +36 -0
- package/dist/core/rename.js +74 -0
- package/dist/core/rename.js.map +1 -0
- package/dist/core/rollback.d.ts +38 -0
- package/dist/core/rollback.js +226 -0
- package/dist/core/rollback.js.map +1 -0
- package/dist/core/semver.d.ts +56 -0
- package/dist/core/semver.js +214 -0
- package/dist/core/semver.js.map +1 -0
- package/dist/core/state.d.ts +99 -0
- package/dist/core/state.js +196 -0
- package/dist/core/state.js.map +1 -0
- package/dist/core/store.d.ts +30 -0
- package/dist/core/store.js +54 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/types.d.ts +515 -0
- package/dist/core/types.js +49 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/merge/blocks.d.ts +48 -0
- package/dist/merge/blocks.js +0 -0
- package/dist/merge/blocks.js.map +1 -0
- package/dist/merge/json-merge.d.ts +66 -0
- package/dist/merge/json-merge.js +176 -0
- package/dist/merge/json-merge.js.map +1 -0
- package/dist/merge/toml.d.ts +48 -0
- package/dist/merge/toml.js +118 -0
- package/dist/merge/toml.js.map +1 -0
- package/dist/targets/claude-code.d.ts +11 -0
- package/dist/targets/claude-code.js +94 -0
- package/dist/targets/claude-code.js.map +1 -0
- package/dist/targets/copilot.d.ts +13 -0
- package/dist/targets/copilot.js +126 -0
- package/dist/targets/copilot.js.map +1 -0
- package/dist/targets/index.d.ts +20 -0
- package/dist/targets/index.js +60 -0
- package/dist/targets/index.js.map +1 -0
- package/dist/targets/opencode.d.ts +32 -0
- package/dist/targets/opencode.js +172 -0
- package/dist/targets/opencode.js.map +1 -0
- package/dist/targets/pi.d.ts +42 -0
- package/dist/targets/pi.js +134 -0
- package/dist/targets/pi.js.map +1 -0
- package/dist/targets/reasonix.d.ts +27 -0
- package/dist/targets/reasonix.js +192 -0
- package/dist/targets/reasonix.js.map +1 -0
- package/dist/targets/shared.d.ts +33 -0
- package/dist/targets/shared.js +109 -0
- package/dist/targets/shared.js.map +1 -0
- package/dist/targets/types.d.ts +40 -0
- package/dist/targets/types.js +17 -0
- package/dist/targets/types.js.map +1 -0
- package/docs/authoring-bundles.md +828 -0
- package/package.json +74 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flavors: installing part of a bundle.
|
|
3
|
+
*
|
|
4
|
+
* A coding kit that covers Python and C# is one bundle -- the review command,
|
|
5
|
+
* the house conventions, the PR skill are the same either way -- but half of
|
|
6
|
+
* what it ships is only useful in one language. A *flavor* names that half:
|
|
7
|
+
*
|
|
8
|
+
* hcm install coding-kit --flavor python
|
|
9
|
+
*
|
|
10
|
+
* installs everything common to the kit plus everything marked `python`, and
|
|
11
|
+
* leaves the rest on the shelf.
|
|
12
|
+
*
|
|
13
|
+
* Two rules, and the rest follows from them:
|
|
14
|
+
*
|
|
15
|
+
* 1. A resource belonging to no flavor is *common*: it installs whatever was
|
|
16
|
+
* asked for. This is what keeps every bundle written before flavors
|
|
17
|
+
* existed installing in full, and it is why a dependency that has never
|
|
18
|
+
* heard of `python` still arrives whole when its dependent is narrowed.
|
|
19
|
+
* 2. A resource belonging to at least one flavor installs only when one of
|
|
20
|
+
* its flavors was asked for. Asking for no flavor at all asks for all of
|
|
21
|
+
* them, so a plain `hcm install` is unchanged.
|
|
22
|
+
*
|
|
23
|
+
* A resource says which flavors it belongs to in its own frontmatter:
|
|
24
|
+
*
|
|
25
|
+
* ---
|
|
26
|
+
* description: Runs pytest and reads the failures
|
|
27
|
+
* flavors: [python]
|
|
28
|
+
* ---
|
|
29
|
+
*
|
|
30
|
+
* or the manifest says it for them with a path pattern, which is the only
|
|
31
|
+
* option for `mcp/`, `settings/` and `assets/` -- they have no frontmatter to
|
|
32
|
+
* write in:
|
|
33
|
+
*
|
|
34
|
+
* flavors:
|
|
35
|
+
* python:
|
|
36
|
+
* description: Python tooling
|
|
37
|
+
* includes:
|
|
38
|
+
* - skills/pytest-*
|
|
39
|
+
* - mcp/pyright.json
|
|
40
|
+
* - assets/python
|
|
41
|
+
*
|
|
42
|
+
* Nothing here removes anything. A flavor decides what a *plan* contains, so an
|
|
43
|
+
* install narrowed to Python writes only Python items and its receipts claim
|
|
44
|
+
* only those -- and uninstall, status and rollback need to know nothing about
|
|
45
|
+
* any of this.
|
|
46
|
+
*/
|
|
47
|
+
import type { BundleManifest, BundleResource, FlavorDefinition, FlavorSummary, LoadedBundle } from './types.js';
|
|
48
|
+
/**
|
|
49
|
+
* `--flavor all` is how you ask for the whole bundle, which matters for `hcm
|
|
50
|
+
* update`: with no flag at all it reinstalls whatever subset was recorded, so
|
|
51
|
+
* widening back needs something to say. Reserved, so it always means that.
|
|
52
|
+
*/
|
|
53
|
+
export declare const ALL_FLAVORS = "all";
|
|
54
|
+
/**
|
|
55
|
+
* Accept every way of writing `flavors:` and return the one shape the rest of
|
|
56
|
+
* hcm works with:
|
|
57
|
+
*
|
|
58
|
+
* flavors: [python, csharp] # names alone
|
|
59
|
+
*
|
|
60
|
+
* flavors:
|
|
61
|
+
* python: Python tooling # names with a description
|
|
62
|
+
*
|
|
63
|
+
* flavors:
|
|
64
|
+
* python: # names with patterns
|
|
65
|
+
* description: Python tooling
|
|
66
|
+
* includes: [skills/pytest-*, mcp/pyright.json]
|
|
67
|
+
*/
|
|
68
|
+
export declare function normalizeFlavors(manifest: BundleManifest, where?: string): FlavorDefinition[];
|
|
69
|
+
/**
|
|
70
|
+
* Does a bundle-relative path fall under a flavor's pattern?
|
|
71
|
+
*
|
|
72
|
+
* `*` matches within one path segment, `**` across segments, `?` one character.
|
|
73
|
+
* A pattern naming a directory takes everything under it, so `assets/python`
|
|
74
|
+
* covers `assets/python/lint.sh` without a trailing `/**` -- which is what
|
|
75
|
+
* anyone writing the pattern by hand means by it.
|
|
76
|
+
*/
|
|
77
|
+
export declare function matchesPattern(bundlePath: string, pattern: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Work out which flavors each resource belongs to, and which flavors the bundle
|
|
80
|
+
* has at all. Sets `resource.flavors` in place; returns the bundle's flavors.
|
|
81
|
+
*
|
|
82
|
+
* Declaring nothing in the manifest is allowed -- the flavors are then whatever
|
|
83
|
+
* the resources named for themselves, which is the shortest way to write a kit
|
|
84
|
+
* that is all markdown. Declaring some makes that list the authority, and
|
|
85
|
+
* `hcm validate` reports a resource naming one outside it.
|
|
86
|
+
*/
|
|
87
|
+
export declare function attachFlavors(resources: BundleResource[], declared: FlavorDefinition[]): FlavorDefinition[];
|
|
88
|
+
/**
|
|
89
|
+
* Is this resource part of an install that asked for `requested`?
|
|
90
|
+
*
|
|
91
|
+
* An empty request is a whole install -- which is what every command that never
|
|
92
|
+
* mentions flavors passes, and what a bundle with no flavors always gets.
|
|
93
|
+
*/
|
|
94
|
+
export declare function inFlavors(resource: BundleResource, requested: string[]): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Tidy what the command line gave: trimmed, in the order typed, one entry per
|
|
97
|
+
* flavor however many times it was said.
|
|
98
|
+
*
|
|
99
|
+
* Undefined for "no narrowing" -- which `--flavor all` says explicitly, and an
|
|
100
|
+
* omitted flag says by default. The difference matters only to `hcm update`,
|
|
101
|
+
* where an omitted flag means "whatever was recorded" and `all` means "widen
|
|
102
|
+
* back to the whole bundle".
|
|
103
|
+
*/
|
|
104
|
+
export declare function expandFlavors(values: string[] | undefined): string[] | undefined;
|
|
105
|
+
/** True when a bundle offers a flavor by that name, however it is capitalised. */
|
|
106
|
+
export declare function hasFlavor(bundle: LoadedBundle, name: string): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Refuse a `--flavor` the bundles being installed do not have.
|
|
109
|
+
*
|
|
110
|
+
* A misspelled flavor would otherwise install the common part and quietly drop
|
|
111
|
+
* everything the user actually asked for, which looks exactly like a bundle
|
|
112
|
+
* that shipped less than it says.
|
|
113
|
+
*
|
|
114
|
+
* Naming several bundles at once is only allowed when they all define the
|
|
115
|
+
* flavor: one `--flavor python` cannot mean the Python part of one kit and the
|
|
116
|
+
* whole of another, and picking either reading for the user would be a guess.
|
|
117
|
+
*/
|
|
118
|
+
export declare function assertFlavorsAvailable(bundles: LoadedBundle[], requested: string[]): void;
|
|
119
|
+
/** What to store in the registry: the names and what they are for, not the patterns. */
|
|
120
|
+
export declare function summarizeFlavors(flavors: FlavorDefinition[]): FlavorSummary[];
|
|
121
|
+
/** `python, csharp` -- for the listings. */
|
|
122
|
+
export declare function flavorNames(flavors: FlavorSummary[] | undefined): string;
|
|
123
|
+
/** How an install describes the subset it is writing, in prose. */
|
|
124
|
+
export declare function describeFlavorSelection(flavors: string[] | undefined): string;
|
|
125
|
+
/** True when two installs asked for the same subset, however it was typed. */
|
|
126
|
+
export declare function sameFlavors(left: string[] | undefined, right: string[] | undefined): boolean;
|
|
127
|
+
/** Flavor mistakes worth reporting, surfaced by `hcm validate` and `hcm info`. */
|
|
128
|
+
export declare function flavorProblems(bundle: LoadedBundle): string[];
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flavors: installing part of a bundle.
|
|
3
|
+
*
|
|
4
|
+
* A coding kit that covers Python and C# is one bundle -- the review command,
|
|
5
|
+
* the house conventions, the PR skill are the same either way -- but half of
|
|
6
|
+
* what it ships is only useful in one language. A *flavor* names that half:
|
|
7
|
+
*
|
|
8
|
+
* hcm install coding-kit --flavor python
|
|
9
|
+
*
|
|
10
|
+
* installs everything common to the kit plus everything marked `python`, and
|
|
11
|
+
* leaves the rest on the shelf.
|
|
12
|
+
*
|
|
13
|
+
* Two rules, and the rest follows from them:
|
|
14
|
+
*
|
|
15
|
+
* 1. A resource belonging to no flavor is *common*: it installs whatever was
|
|
16
|
+
* asked for. This is what keeps every bundle written before flavors
|
|
17
|
+
* existed installing in full, and it is why a dependency that has never
|
|
18
|
+
* heard of `python` still arrives whole when its dependent is narrowed.
|
|
19
|
+
* 2. A resource belonging to at least one flavor installs only when one of
|
|
20
|
+
* its flavors was asked for. Asking for no flavor at all asks for all of
|
|
21
|
+
* them, so a plain `hcm install` is unchanged.
|
|
22
|
+
*
|
|
23
|
+
* A resource says which flavors it belongs to in its own frontmatter:
|
|
24
|
+
*
|
|
25
|
+
* ---
|
|
26
|
+
* description: Runs pytest and reads the failures
|
|
27
|
+
* flavors: [python]
|
|
28
|
+
* ---
|
|
29
|
+
*
|
|
30
|
+
* or the manifest says it for them with a path pattern, which is the only
|
|
31
|
+
* option for `mcp/`, `settings/` and `assets/` -- they have no frontmatter to
|
|
32
|
+
* write in:
|
|
33
|
+
*
|
|
34
|
+
* flavors:
|
|
35
|
+
* python:
|
|
36
|
+
* description: Python tooling
|
|
37
|
+
* includes:
|
|
38
|
+
* - skills/pytest-*
|
|
39
|
+
* - mcp/pyright.json
|
|
40
|
+
* - assets/python
|
|
41
|
+
*
|
|
42
|
+
* Nothing here removes anything. A flavor decides what a *plan* contains, so an
|
|
43
|
+
* install narrowed to Python writes only Python items and its receipts claim
|
|
44
|
+
* only those -- and uninstall, status and rollback need to know nothing about
|
|
45
|
+
* any of this.
|
|
46
|
+
*/
|
|
47
|
+
import { HcmError } from './errors.js';
|
|
48
|
+
const FLAVOR_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
49
|
+
/**
|
|
50
|
+
* `--flavor all` is how you ask for the whole bundle, which matters for `hcm
|
|
51
|
+
* update`: with no flag at all it reinstalls whatever subset was recorded, so
|
|
52
|
+
* widening back needs something to say. Reserved, so it always means that.
|
|
53
|
+
*/
|
|
54
|
+
export const ALL_FLAVORS = 'all';
|
|
55
|
+
const DECLARATION_HINT = 'Write "flavors: [python, csharp]", or a mapping of name to description, or a ' +
|
|
56
|
+
'mapping of name to {description, includes}.';
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// Reading the manifest
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
/**
|
|
61
|
+
* Accept every way of writing `flavors:` and return the one shape the rest of
|
|
62
|
+
* hcm works with:
|
|
63
|
+
*
|
|
64
|
+
* flavors: [python, csharp] # names alone
|
|
65
|
+
*
|
|
66
|
+
* flavors:
|
|
67
|
+
* python: Python tooling # names with a description
|
|
68
|
+
*
|
|
69
|
+
* flavors:
|
|
70
|
+
* python: # names with patterns
|
|
71
|
+
* description: Python tooling
|
|
72
|
+
* includes: [skills/pytest-*, mcp/pyright.json]
|
|
73
|
+
*/
|
|
74
|
+
export function normalizeFlavors(manifest, where = manifest.name) {
|
|
75
|
+
const declared = manifest.flavors;
|
|
76
|
+
if (declared === undefined)
|
|
77
|
+
return [];
|
|
78
|
+
let entries;
|
|
79
|
+
if (Array.isArray(declared)) {
|
|
80
|
+
for (const name of declared) {
|
|
81
|
+
if (typeof name !== 'string') {
|
|
82
|
+
throw new HcmError(`Malformed flavor in ${where}: ${JSON.stringify(name)}`, DECLARATION_HINT);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
entries = declared.map((name) => [name, undefined]);
|
|
86
|
+
}
|
|
87
|
+
else if (declared && typeof declared === 'object') {
|
|
88
|
+
entries = Object.entries(declared);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new HcmError(`"flavors" in ${where} must be a list of names or a mapping`, DECLARATION_HINT);
|
|
92
|
+
}
|
|
93
|
+
const seen = new Set();
|
|
94
|
+
const flavors = [];
|
|
95
|
+
for (const [rawName, value] of entries) {
|
|
96
|
+
const name = rawName.trim();
|
|
97
|
+
if (!FLAVOR_NAME_PATTERN.test(name)) {
|
|
98
|
+
throw new HcmError(`"${name}" is not a usable flavor name (in ${where})`, 'Use letters, digits, dots, dashes and underscores.');
|
|
99
|
+
}
|
|
100
|
+
const key = name.toLowerCase();
|
|
101
|
+
if (key === ALL_FLAVORS) {
|
|
102
|
+
throw new HcmError(`"${ALL_FLAVORS}" cannot be used as a flavor name (in ${where})`, `"--flavor ${ALL_FLAVORS}" is how a user asks for the whole bundle.`);
|
|
103
|
+
}
|
|
104
|
+
if (seen.has(key)) {
|
|
105
|
+
throw new HcmError(`"${name}" is listed twice in ${where}'s flavors`);
|
|
106
|
+
}
|
|
107
|
+
seen.add(key);
|
|
108
|
+
flavors.push({ name, ...readFlavorBody(name, value, where) });
|
|
109
|
+
}
|
|
110
|
+
return flavors;
|
|
111
|
+
}
|
|
112
|
+
/** The right-hand side of one flavor entry: nothing, a description, or both. */
|
|
113
|
+
function readFlavorBody(name, value, where) {
|
|
114
|
+
if (value === undefined || value === null)
|
|
115
|
+
return { includes: [] };
|
|
116
|
+
if (typeof value === 'string') {
|
|
117
|
+
const description = value.trim();
|
|
118
|
+
return { ...(description ? { description } : {}), includes: [] };
|
|
119
|
+
}
|
|
120
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
121
|
+
throw new HcmError(`Malformed flavor "${name}" in ${where}`, DECLARATION_HINT);
|
|
122
|
+
}
|
|
123
|
+
const shape = value;
|
|
124
|
+
if (shape.description !== undefined && typeof shape.description !== 'string') {
|
|
125
|
+
throw new HcmError(`"description" for flavor "${name}" in ${where} must be text`);
|
|
126
|
+
}
|
|
127
|
+
const description = typeof shape.description === 'string' ? shape.description.trim() : undefined;
|
|
128
|
+
return {
|
|
129
|
+
...(description ? { description } : {}),
|
|
130
|
+
includes: readPatterns(shape.includes, name, where),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function readPatterns(value, name, where) {
|
|
134
|
+
if (value === undefined || value === null)
|
|
135
|
+
return [];
|
|
136
|
+
const list = Array.isArray(value) ? value : [value];
|
|
137
|
+
const patterns = [];
|
|
138
|
+
for (const entry of list) {
|
|
139
|
+
if (typeof entry !== 'string' || !entry.trim()) {
|
|
140
|
+
throw new HcmError(`"includes" for flavor "${name}" in ${where} must be a path pattern or a list of them`, 'Patterns are bundle-relative, e.g. "skills/pytest-*" or "rules/python.md".');
|
|
141
|
+
}
|
|
142
|
+
// A trailing slash and a leading `./` both mean the same directory; strip
|
|
143
|
+
// them so `assets/python/` and `assets/python` are one pattern.
|
|
144
|
+
patterns.push(entry.trim().replace(/^\.\//, '').replace(/\/+$/, ''));
|
|
145
|
+
}
|
|
146
|
+
return patterns;
|
|
147
|
+
}
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
// Matching resources
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
const PATTERNS = new Map();
|
|
152
|
+
/**
|
|
153
|
+
* Does a bundle-relative path fall under a flavor's pattern?
|
|
154
|
+
*
|
|
155
|
+
* `*` matches within one path segment, `**` across segments, `?` one character.
|
|
156
|
+
* A pattern naming a directory takes everything under it, so `assets/python`
|
|
157
|
+
* covers `assets/python/lint.sh` without a trailing `/**` -- which is what
|
|
158
|
+
* anyone writing the pattern by hand means by it.
|
|
159
|
+
*/
|
|
160
|
+
export function matchesPattern(bundlePath, pattern) {
|
|
161
|
+
return compilePattern(pattern).test(bundlePath);
|
|
162
|
+
}
|
|
163
|
+
function compilePattern(pattern) {
|
|
164
|
+
const cached = PATTERNS.get(pattern);
|
|
165
|
+
if (cached)
|
|
166
|
+
return cached;
|
|
167
|
+
let source = '';
|
|
168
|
+
let at = 0;
|
|
169
|
+
while (at < pattern.length) {
|
|
170
|
+
const rest = pattern.slice(at);
|
|
171
|
+
// `**/` also matches zero directories, so `**/x.md` finds a top-level x.md.
|
|
172
|
+
if (rest.startsWith('**/')) {
|
|
173
|
+
source += '(?:.*/)?';
|
|
174
|
+
at += 3;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (rest.startsWith('**')) {
|
|
178
|
+
source += '.*';
|
|
179
|
+
at += 2;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const char = pattern[at];
|
|
183
|
+
if (char === '*')
|
|
184
|
+
source += '[^/]*';
|
|
185
|
+
else if (char === '?')
|
|
186
|
+
source += '[^/]';
|
|
187
|
+
else
|
|
188
|
+
source += char.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
189
|
+
at += 1;
|
|
190
|
+
}
|
|
191
|
+
const expression = new RegExp(`^${source}(?:/.*)?$`, 'i');
|
|
192
|
+
PATTERNS.set(pattern, expression);
|
|
193
|
+
return expression;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Work out which flavors each resource belongs to, and which flavors the bundle
|
|
197
|
+
* has at all. Sets `resource.flavors` in place; returns the bundle's flavors.
|
|
198
|
+
*
|
|
199
|
+
* Declaring nothing in the manifest is allowed -- the flavors are then whatever
|
|
200
|
+
* the resources named for themselves, which is the shortest way to write a kit
|
|
201
|
+
* that is all markdown. Declaring some makes that list the authority, and
|
|
202
|
+
* `hcm validate` reports a resource naming one outside it.
|
|
203
|
+
*/
|
|
204
|
+
export function attachFlavors(resources, declared) {
|
|
205
|
+
const spellings = new Map(declared.map((flavor) => [flavor.name.toLowerCase(), flavor.name]));
|
|
206
|
+
for (const resource of resources) {
|
|
207
|
+
const own = takeFrontmatterFlavors(resource.frontmatter, resource.bundlePath);
|
|
208
|
+
const matched = declared
|
|
209
|
+
.filter((flavor) => flavor.includes.some((pattern) => matchesPattern(resource.bundlePath, pattern)))
|
|
210
|
+
.map((flavor) => flavor.name);
|
|
211
|
+
// The manifest's spelling wins, so one flavor is one entry however the
|
|
212
|
+
// resources happened to capitalise it.
|
|
213
|
+
const names = new Map();
|
|
214
|
+
for (const name of [...own, ...matched]) {
|
|
215
|
+
const key = name.toLowerCase();
|
|
216
|
+
names.set(key, spellings.get(key) ?? name);
|
|
217
|
+
}
|
|
218
|
+
resource.flavors = [...names.values()].sort((a, b) => a.localeCompare(b));
|
|
219
|
+
}
|
|
220
|
+
if (declared.length > 0)
|
|
221
|
+
return declared;
|
|
222
|
+
const used = new Map();
|
|
223
|
+
for (const resource of resources) {
|
|
224
|
+
for (const name of resource.flavors)
|
|
225
|
+
used.set(name.toLowerCase(), name);
|
|
226
|
+
}
|
|
227
|
+
return [...used.values()]
|
|
228
|
+
.sort((a, b) => a.localeCompare(b))
|
|
229
|
+
.map((name) => ({ name, includes: [] }));
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Read a resource's own `flavors:` and take it back out of the frontmatter.
|
|
233
|
+
*
|
|
234
|
+
* Out, because every target copies frontmatter keys it does not recognise into
|
|
235
|
+
* the file it writes -- this one is hcm's bookkeeping and has no business in an
|
|
236
|
+
* installed SKILL.md.
|
|
237
|
+
*/
|
|
238
|
+
function takeFrontmatterFlavors(frontmatter, where) {
|
|
239
|
+
const names = [];
|
|
240
|
+
for (const key of ['flavors', 'flavor']) {
|
|
241
|
+
const value = frontmatter[key];
|
|
242
|
+
if (value === undefined)
|
|
243
|
+
continue;
|
|
244
|
+
delete frontmatter[key];
|
|
245
|
+
for (const entry of Array.isArray(value) ? value : [value]) {
|
|
246
|
+
if (typeof entry !== 'string' || !entry.trim()) {
|
|
247
|
+
throw new HcmError(`"${key}" in ${where} must be a flavor name or a list of them`, `Got ${JSON.stringify(entry)}.`);
|
|
248
|
+
}
|
|
249
|
+
names.push(entry.trim());
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return names;
|
|
253
|
+
}
|
|
254
|
+
// ---------------------------------------------------------------------------
|
|
255
|
+
// Selecting
|
|
256
|
+
// ---------------------------------------------------------------------------
|
|
257
|
+
/**
|
|
258
|
+
* Is this resource part of an install that asked for `requested`?
|
|
259
|
+
*
|
|
260
|
+
* An empty request is a whole install -- which is what every command that never
|
|
261
|
+
* mentions flavors passes, and what a bundle with no flavors always gets.
|
|
262
|
+
*/
|
|
263
|
+
export function inFlavors(resource, requested) {
|
|
264
|
+
const own = resource.flavors ?? [];
|
|
265
|
+
if (requested.length === 0 || own.length === 0)
|
|
266
|
+
return true;
|
|
267
|
+
const wanted = new Set(requested.map((name) => name.toLowerCase()));
|
|
268
|
+
return own.some((name) => wanted.has(name.toLowerCase()));
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Tidy what the command line gave: trimmed, in the order typed, one entry per
|
|
272
|
+
* flavor however many times it was said.
|
|
273
|
+
*
|
|
274
|
+
* Undefined for "no narrowing" -- which `--flavor all` says explicitly, and an
|
|
275
|
+
* omitted flag says by default. The difference matters only to `hcm update`,
|
|
276
|
+
* where an omitted flag means "whatever was recorded" and `all` means "widen
|
|
277
|
+
* back to the whole bundle".
|
|
278
|
+
*/
|
|
279
|
+
export function expandFlavors(values) {
|
|
280
|
+
if (!values?.length)
|
|
281
|
+
return undefined;
|
|
282
|
+
if (values.some((value) => value.trim().toLowerCase() === ALL_FLAVORS))
|
|
283
|
+
return undefined;
|
|
284
|
+
const seen = new Map();
|
|
285
|
+
for (const value of values) {
|
|
286
|
+
const name = value.trim();
|
|
287
|
+
if (!name)
|
|
288
|
+
continue;
|
|
289
|
+
const key = name.toLowerCase();
|
|
290
|
+
if (!seen.has(key))
|
|
291
|
+
seen.set(key, name);
|
|
292
|
+
}
|
|
293
|
+
const names = [...seen.values()];
|
|
294
|
+
return names.length > 0 ? names : undefined;
|
|
295
|
+
}
|
|
296
|
+
/** True when a bundle offers a flavor by that name, however it is capitalised. */
|
|
297
|
+
export function hasFlavor(bundle, name) {
|
|
298
|
+
return bundle.flavors.some((flavor) => flavor.name.toLowerCase() === name.toLowerCase());
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Refuse a `--flavor` the bundles being installed do not have.
|
|
302
|
+
*
|
|
303
|
+
* A misspelled flavor would otherwise install the common part and quietly drop
|
|
304
|
+
* everything the user actually asked for, which looks exactly like a bundle
|
|
305
|
+
* that shipped less than it says.
|
|
306
|
+
*
|
|
307
|
+
* Naming several bundles at once is only allowed when they all define the
|
|
308
|
+
* flavor: one `--flavor python` cannot mean the Python part of one kit and the
|
|
309
|
+
* whole of another, and picking either reading for the user would be a guess.
|
|
310
|
+
*/
|
|
311
|
+
export function assertFlavorsAvailable(bundles, requested) {
|
|
312
|
+
if (requested.length === 0 || bundles.length === 0)
|
|
313
|
+
return;
|
|
314
|
+
for (const name of requested) {
|
|
315
|
+
const missing = bundles.filter((bundle) => !hasFlavor(bundle, name));
|
|
316
|
+
if (missing.length === 0)
|
|
317
|
+
continue;
|
|
318
|
+
const first = bundles[0];
|
|
319
|
+
if (bundles.length === 1) {
|
|
320
|
+
throw new HcmError(`"${first.manifest.name}" has no flavor "${name}"`, first.flavors.length > 0
|
|
321
|
+
? `It offers: ${first.flavors.map((flavor) => flavor.name).join(', ')}`
|
|
322
|
+
: 'It defines no flavors, so it installs in full -- drop --flavor.');
|
|
323
|
+
}
|
|
324
|
+
throw new HcmError(`--flavor ${name} does not apply to ` +
|
|
325
|
+
missing.map((bundle) => `"${bundle.manifest.name}"`).join(', '), 'Installing several bundles at once with --flavor needs every one of them to define ' +
|
|
326
|
+
'the flavor. Install them one at a time to give each its own.');
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// ---------------------------------------------------------------------------
|
|
330
|
+
// Saying it out loud
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
/** What to store in the registry: the names and what they are for, not the patterns. */
|
|
333
|
+
export function summarizeFlavors(flavors) {
|
|
334
|
+
return flavors.map((flavor) => ({
|
|
335
|
+
name: flavor.name,
|
|
336
|
+
...(flavor.description ? { description: flavor.description } : {}),
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
/** `python, csharp` -- for the listings. */
|
|
340
|
+
export function flavorNames(flavors) {
|
|
341
|
+
return (flavors ?? []).map((flavor) => flavor.name).join(', ');
|
|
342
|
+
}
|
|
343
|
+
/** How an install describes the subset it is writing, in prose. */
|
|
344
|
+
export function describeFlavorSelection(flavors) {
|
|
345
|
+
return flavors?.length ? `flavor(s) ${flavors.join(', ')}` : 'every flavor';
|
|
346
|
+
}
|
|
347
|
+
/** True when two installs asked for the same subset, however it was typed. */
|
|
348
|
+
export function sameFlavors(left, right) {
|
|
349
|
+
const key = (names) => [...new Set((names ?? []).map((name) => name.toLowerCase()))].sort().join(',');
|
|
350
|
+
return key(left) === key(right);
|
|
351
|
+
}
|
|
352
|
+
// ---------------------------------------------------------------------------
|
|
353
|
+
// Validation
|
|
354
|
+
// ---------------------------------------------------------------------------
|
|
355
|
+
/** Flavor mistakes worth reporting, surfaced by `hcm validate` and `hcm info`. */
|
|
356
|
+
export function flavorProblems(bundle) {
|
|
357
|
+
const problems = [];
|
|
358
|
+
const declared = normalizeFlavors(bundle.manifest);
|
|
359
|
+
// Only when the manifest declares a list is there a list to be outside of.
|
|
360
|
+
if (declared.length > 0) {
|
|
361
|
+
const known = new Set(declared.map((flavor) => flavor.name.toLowerCase()));
|
|
362
|
+
for (const resource of bundle.resources) {
|
|
363
|
+
for (const name of resource.flavors) {
|
|
364
|
+
if (known.has(name.toLowerCase()))
|
|
365
|
+
continue;
|
|
366
|
+
problems.push(`${resource.bundlePath}: flavor "${name}" is not declared in the manifest ` +
|
|
367
|
+
`(it declares: ${declared.map((flavor) => flavor.name).join(', ')})`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
for (const flavor of bundle.flavors) {
|
|
372
|
+
for (const pattern of flavor.includes) {
|
|
373
|
+
if (bundle.resources.some((resource) => matchesPattern(resource.bundlePath, pattern))) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
problems.push(`Flavor "${flavor.name}": "${pattern}" matches nothing in the bundle`);
|
|
377
|
+
}
|
|
378
|
+
const members = bundle.resources.filter((resource) => resource.flavors.some((name) => name.toLowerCase() === flavor.name.toLowerCase()));
|
|
379
|
+
if (members.length === 0) {
|
|
380
|
+
problems.push(`Flavor "${flavor.name}" has no resources; ` +
|
|
381
|
+
`"--flavor ${flavor.name}" would install the common part and nothing else`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return problems;
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=flavors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flavors.js","sourceRoot":"","sources":["../../src/core/flavors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AASvC,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AAEjC,MAAM,gBAAgB,GACpB,+EAA+E;IAC/E,6CAA6C,CAAC;AAEhD,8EAA8E;AAC9E,uBAAuB;AACvB,8EAA8E;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAAwB,EACxB,KAAK,GAAG,QAAQ,CAAC,IAAI;IAErB,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC;IAClC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAEtC,IAAI,OAA4B,CAAC;IAEjC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,QAAQ,CAAC,uBAAuB,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;YAChG,CAAC;QACH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CAAC;gBACtF,SAAS;YACX,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,IAAI,OAAO,OAAO,iCAAiC,CAAC,CAAC;QACvF,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CACnD,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAClF,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,QAAQ,CAAC,IAAI,CACX,WAAW,MAAM,CAAC,IAAI,sBAAsB;gBAC1C,aAAa,MAAM,CAAC,IAAI,kDAAkD,CAC7E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import YAML from 'yaml';
|
|
2
|
+
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
3
|
+
export function parseMarkdown(text) {
|
|
4
|
+
const match = FRONTMATTER_RE.exec(text);
|
|
5
|
+
if (!match)
|
|
6
|
+
return { frontmatter: {}, body: text.trim() };
|
|
7
|
+
const parsed = YAML.parse(match[1]);
|
|
8
|
+
const frontmatter = parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
9
|
+
? parsed
|
|
10
|
+
: {};
|
|
11
|
+
return { frontmatter, body: text.slice(match[0].length).trim() };
|
|
12
|
+
}
|
|
13
|
+
export function renderMarkdown(frontmatter, body) {
|
|
14
|
+
const entries = Object.entries(frontmatter).filter(([, value]) => value !== undefined);
|
|
15
|
+
if (entries.length === 0)
|
|
16
|
+
return `${body.trim()}\n`;
|
|
17
|
+
const yaml = YAML.stringify(Object.fromEntries(entries)).trimEnd();
|
|
18
|
+
return `---\n${yaml}\n---\n\n${body.trim()}\n`;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/core/frontmatter.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAOxB,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAE3D,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;IAE1D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAW,CAAY,CAAC;IACzD,MAAM,WAAW,GACf,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAC5D,CAAC,CAAE,MAAkC;QACrC,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,WAAoC,EAAE,IAAY;IAC/E,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACvF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACnE,OAAO,QAAQ,IAAI,YAAY,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
/** Convert any path to POSIX separators, which is what receipts and manifests store. */
|
|
3
|
+
export declare function toPosix(p: string): string;
|
|
4
|
+
/** Resolve a scope-relative POSIX path against an absolute root. */
|
|
5
|
+
export declare function fromPosix(root: string, relative: string): string;
|
|
6
|
+
export declare function pathExists(target: string): Promise<boolean>;
|
|
7
|
+
export declare function isDirectory(target: string): Promise<boolean>;
|
|
8
|
+
export declare function readTextIfExists(target: string): Promise<string | undefined>;
|
|
9
|
+
/** Raw bytes, for content that would not survive a round trip through UTF-8. */
|
|
10
|
+
export declare function readBytesIfExists(target: string): Promise<Buffer | undefined>;
|
|
11
|
+
export declare function readJsonIfExists<T>(target: string): Promise<T | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Create a directory tree, returning the directories that did not previously
|
|
14
|
+
* exist (deepest last). Uninstall uses this to prune only what it created.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ensureDir(target: string): Promise<string[]>;
|
|
17
|
+
export declare function writeText(target: string, contents: string): Promise<string[]>;
|
|
18
|
+
export declare function writeBytes(target: string, contents: Buffer): Promise<string[]>;
|
|
19
|
+
export declare function writeJson(target: string, value: unknown): Promise<string[]>;
|
|
20
|
+
export declare function removeFile(target: string): Promise<void>;
|
|
21
|
+
/** Remove a directory only when it is empty. Returns true when removed. */
|
|
22
|
+
export declare function removeDirIfEmpty(target: string): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Walk upward from `target`, removing empty directories, stopping at `stopAt`
|
|
25
|
+
* (exclusive) or at the first non-empty directory.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pruneEmptyDirs(target: string, stopAt: string): Promise<void>;
|
|
28
|
+
/** Recursively list files under a directory, returning absolute paths. */
|
|
29
|
+
export declare function listFiles(root: string): Promise<string[]>;
|
|
30
|
+
/** Copy a file, creating parent directories as needed. */
|
|
31
|
+
export declare function copyFile(from: string, to: string): Promise<string[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Recursively copy a directory. `skip` names directories to leave behind --
|
|
34
|
+
* a bundle's own `.git` or `node_modules` are not part of the bundle.
|
|
35
|
+
* Symlinks are copied as links rather than followed, so a cycle cannot hang us.
|
|
36
|
+
*/
|
|
37
|
+
export declare function copyDir(from: string, to: string, skip?: string[]): Promise<void>;
|
|
38
|
+
/** Remove a directory and everything under it. Missing is not an error. */
|
|
39
|
+
export declare function removeDir(target: string): Promise<void>;
|
|
40
|
+
export { fs };
|