@seasb/metafab 0.0.1 → 2.0.0-next.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 +46 -1
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +419 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/build.d.ts +31 -0
- package/dist/commands/build.js +156 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/check.d.ts +2 -0
- package/dist/commands/check.js +52 -0
- package/dist/commands/check.js.map +1 -0
- package/dist/commands/create.d.ts +2 -0
- package/dist/commands/create.js +75 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/detach.d.ts +2 -0
- package/dist/commands/detach.js +24 -0
- package/dist/commands/detach.js.map +1 -0
- package/dist/commands/diff.d.ts +2 -0
- package/dist/commands/diff.js +35 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/env.d.ts +4 -0
- package/dist/commands/env.js +362 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/import.d.ts +2 -0
- package/dist/commands/import.js +107 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +77 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/map.d.ts +2 -0
- package/dist/commands/map.js +42 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/pipeline-add.d.ts +2 -0
- package/dist/commands/pipeline-add.js +68 -0
- package/dist/commands/pipeline-add.js.map +1 -0
- package/dist/commands/pipeline-remove.d.ts +2 -0
- package/dist/commands/pipeline-remove.js +45 -0
- package/dist/commands/pipeline-remove.js.map +1 -0
- package/dist/commands/publish.d.ts +2 -0
- package/dist/commands/publish.js +153 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/types.d.ts +45 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.js +97 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/core/adopt.d.ts +53 -0
- package/dist/core/adopt.js +676 -0
- package/dist/core/adopt.js.map +1 -0
- package/dist/core/build/agents.d.ts +26 -0
- package/dist/core/build/agents.js +67 -0
- package/dist/core/build/agents.js.map +1 -0
- package/dist/core/build/index.d.ts +5 -0
- package/dist/core/build/index.js +6 -0
- package/dist/core/build/index.js.map +1 -0
- package/dist/core/build/markers.d.ts +34 -0
- package/dist/core/build/markers.js +97 -0
- package/dist/core/build/markers.js.map +1 -0
- package/dist/core/build/plan.d.ts +82 -0
- package/dist/core/build/plan.js +912 -0
- package/dist/core/build/plan.js.map +1 -0
- package/dist/core/build/preview.d.ts +39 -0
- package/dist/core/build/preview.js +344 -0
- package/dist/core/build/preview.js.map +1 -0
- package/dist/core/build/skill.d.ts +99 -0
- package/dist/core/build/skill.js +354 -0
- package/dist/core/build/skill.js.map +1 -0
- package/dist/core/check/drift.d.ts +13 -0
- package/dist/core/check/drift.js +205 -0
- package/dist/core/check/drift.js.map +1 -0
- package/dist/core/check/index.d.ts +16 -0
- package/dist/core/check/index.js +84 -0
- package/dist/core/check/index.js.map +1 -0
- package/dist/core/check/markers.d.ts +9 -0
- package/dist/core/check/markers.js +220 -0
- package/dist/core/check/markers.js.map +1 -0
- package/dist/core/config/destinations.d.ts +5 -0
- package/dist/core/config/destinations.js +20 -0
- package/dist/core/config/destinations.js.map +1 -0
- package/dist/core/config/load.d.ts +4 -0
- package/dist/core/config/load.js +41 -0
- package/dist/core/config/load.js.map +1 -0
- package/dist/core/config/parse.d.ts +8 -0
- package/dist/core/config/parse.js +201 -0
- package/dist/core/config/parse.js.map +1 -0
- package/dist/core/config/source.d.ts +25 -0
- package/dist/core/config/source.js +67 -0
- package/dist/core/config/source.js.map +1 -0
- package/dist/core/config/types.d.ts +48 -0
- package/dist/core/config/types.js +2 -0
- package/dist/core/config/types.js.map +1 -0
- package/dist/core/config/validate.d.ts +11 -0
- package/dist/core/config/validate.js +389 -0
- package/dist/core/config/validate.js.map +1 -0
- package/dist/core/config/writers.d.ts +14 -0
- package/dist/core/config/writers.js +269 -0
- package/dist/core/config/writers.js.map +1 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/config.js +8 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/discovery.d.ts +34 -0
- package/dist/core/discovery.js +272 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/edit/create.d.ts +18 -0
- package/dist/core/edit/create.js +190 -0
- package/dist/core/edit/create.js.map +1 -0
- package/dist/core/edit/document.d.ts +4 -0
- package/dist/core/edit/document.js +16 -0
- package/dist/core/edit/document.js.map +1 -0
- package/dist/core/edit/factory-yaml.d.ts +17 -0
- package/dist/core/edit/factory-yaml.js +213 -0
- package/dist/core/edit/factory-yaml.js.map +1 -0
- package/dist/core/edit/files.d.ts +6 -0
- package/dist/core/edit/files.js +47 -0
- package/dist/core/edit/files.js.map +1 -0
- package/dist/core/edit/index.d.ts +9 -0
- package/dist/core/edit/index.js +10 -0
- package/dist/core/edit/index.js.map +1 -0
- package/dist/core/edit/map.d.ts +24 -0
- package/dist/core/edit/map.js +82 -0
- package/dist/core/edit/map.js.map +1 -0
- package/dist/core/edit/names.d.ts +2 -0
- package/dist/core/edit/names.js +17 -0
- package/dist/core/edit/names.js.map +1 -0
- package/dist/core/edit/paths.d.ts +8 -0
- package/dist/core/edit/paths.js +81 -0
- package/dist/core/edit/paths.js.map +1 -0
- package/dist/core/edit/pipeline.d.ts +19 -0
- package/dist/core/edit/pipeline.js +152 -0
- package/dist/core/edit/pipeline.js.map +1 -0
- package/dist/core/edit/skill.d.ts +1 -0
- package/dist/core/edit/skill.js +10 -0
- package/dist/core/edit/skill.js.map +1 -0
- package/dist/core/env/condition.d.ts +40 -0
- package/dist/core/env/condition.js +283 -0
- package/dist/core/env/condition.js.map +1 -0
- package/dist/core/env/declarations.d.ts +16 -0
- package/dist/core/env/declarations.js +328 -0
- package/dist/core/env/declarations.js.map +1 -0
- package/dist/core/env/directives.d.ts +75 -0
- package/dist/core/env/directives.js +429 -0
- package/dist/core/env/directives.js.map +1 -0
- package/dist/core/env/git-config.d.ts +15 -0
- package/dist/core/env/git-config.js +110 -0
- package/dist/core/env/git-config.js.map +1 -0
- package/dist/core/env/imports.d.ts +60 -0
- package/dist/core/env/imports.js +217 -0
- package/dist/core/env/imports.js.map +1 -0
- package/dist/core/env/index.d.ts +6 -0
- package/dist/core/env/index.js +7 -0
- package/dist/core/env/index.js.map +1 -0
- package/dist/core/env/markdown.d.ts +22 -0
- package/dist/core/env/markdown.js +33 -0
- package/dist/core/env/markdown.js.map +1 -0
- package/dist/core/env/render.d.ts +13 -0
- package/dist/core/env/render.js +65 -0
- package/dist/core/env/render.js.map +1 -0
- package/dist/core/env/report.d.ts +29 -0
- package/dist/core/env/report.js +39 -0
- package/dist/core/env/report.js.map +1 -0
- package/dist/core/env/scenarios.d.ts +40 -0
- package/dist/core/env/scenarios.js +124 -0
- package/dist/core/env/scenarios.js.map +1 -0
- package/dist/core/env/select.d.ts +30 -0
- package/dist/core/env/select.js +191 -0
- package/dist/core/env/select.js.map +1 -0
- package/dist/core/env/types.d.ts +38 -0
- package/dist/core/env/types.js +2 -0
- package/dist/core/env/types.js.map +1 -0
- package/dist/core/env/validate.d.ts +25 -0
- package/dist/core/env/validate.js +212 -0
- package/dist/core/env/validate.js.map +1 -0
- package/dist/core/factory/discovery.d.ts +9 -0
- package/dist/core/factory/discovery.js +139 -0
- package/dist/core/factory/discovery.js.map +1 -0
- package/dist/core/factory/factory-yaml.d.ts +29 -0
- package/dist/core/factory/factory-yaml.js +538 -0
- package/dist/core/factory/factory-yaml.js.map +1 -0
- package/dist/core/factory/index.d.ts +5 -0
- package/dist/core/factory/index.js +6 -0
- package/dist/core/factory/index.js.map +1 -0
- package/dist/core/factory/lines.d.ts +8 -0
- package/dist/core/factory/lines.js +11 -0
- package/dist/core/factory/lines.js.map +1 -0
- package/dist/core/factory/load.d.ts +4 -0
- package/dist/core/factory/load.js +83 -0
- package/dist/core/factory/load.js.map +1 -0
- package/dist/core/factory/requires.d.ts +9 -0
- package/dist/core/factory/requires.js +123 -0
- package/dist/core/factory/requires.js.map +1 -0
- package/dist/core/factory/types.d.ts +58 -0
- package/dist/core/factory/types.js +2 -0
- package/dist/core/factory/types.js.map +1 -0
- package/dist/core/factory/validate.d.ts +44 -0
- package/dist/core/factory/validate.js +460 -0
- package/dist/core/factory/validate.js.map +1 -0
- package/dist/core/hooks/index.d.ts +8 -0
- package/dist/core/hooks/index.js +15 -0
- package/dist/core/hooks/index.js.map +1 -0
- package/dist/core/hooks/script.d.ts +21 -0
- package/dist/core/hooks/script.js +34 -0
- package/dist/core/hooks/script.js.map +1 -0
- package/dist/core/hooks/sync.d.ts +17 -0
- package/dist/core/hooks/sync.js +262 -0
- package/dist/core/hooks/sync.js.map +1 -0
- package/dist/core/import/conflicts.d.ts +82 -0
- package/dist/core/import/conflicts.js +256 -0
- package/dist/core/import/conflicts.js.map +1 -0
- package/dist/core/import/copy.d.ts +10 -0
- package/dist/core/import/copy.js +76 -0
- package/dist/core/import/copy.js.map +1 -0
- package/dist/core/import/file-tree.d.ts +43 -0
- package/dist/core/import/file-tree.js +107 -0
- package/dist/core/import/file-tree.js.map +1 -0
- package/dist/core/import/index.d.ts +5 -0
- package/dist/core/import/index.js +6 -0
- package/dist/core/import/index.js.map +1 -0
- package/dist/core/import/pipeline-changes.d.ts +8 -0
- package/dist/core/import/pipeline-changes.js +89 -0
- package/dist/core/import/pipeline-changes.js.map +1 -0
- package/dist/core/import/run.d.ts +76 -0
- package/dist/core/import/run.js +275 -0
- package/dist/core/import/run.js.map +1 -0
- package/dist/core/init/gitattributes.d.ts +20 -0
- package/dist/core/init/gitattributes.js +89 -0
- package/dist/core/init/gitattributes.js.map +1 -0
- package/dist/core/init/index.d.ts +4 -0
- package/dist/core/init/index.js +5 -0
- package/dist/core/init/index.js.map +1 -0
- package/dist/core/init/name.d.ts +1 -0
- package/dist/core/init/name.js +4 -0
- package/dist/core/init/name.js.map +1 -0
- package/dist/core/init/run.d.ts +51 -0
- package/dist/core/init/run.js +261 -0
- package/dist/core/init/run.js.map +1 -0
- package/dist/core/init/targets.d.ts +17 -0
- package/dist/core/init/targets.js +87 -0
- package/dist/core/init/targets.js.map +1 -0
- package/dist/core/merge.d.ts +88 -0
- package/dist/core/merge.js +239 -0
- package/dist/core/merge.js.map +1 -0
- package/dist/core/publish/exclude.d.ts +9 -0
- package/dist/core/publish/exclude.js +32 -0
- package/dist/core/publish/exclude.js.map +1 -0
- package/dist/core/publish/git-target.d.ts +32 -0
- package/dist/core/publish/git-target.js +460 -0
- package/dist/core/publish/git-target.js.map +1 -0
- package/dist/core/publish/index.d.ts +10 -0
- package/dist/core/publish/index.js +11 -0
- package/dist/core/publish/index.js.map +1 -0
- package/dist/core/publish/npm-target.d.ts +15 -0
- package/dist/core/publish/npm-target.js +177 -0
- package/dist/core/publish/npm-target.js.map +1 -0
- package/dist/core/publish/package-json.d.ts +31 -0
- package/dist/core/publish/package-json.js +74 -0
- package/dist/core/publish/package-json.js.map +1 -0
- package/dist/core/publish/prepare.d.ts +35 -0
- package/dist/core/publish/prepare.js +102 -0
- package/dist/core/publish/prepare.js.map +1 -0
- package/dist/core/publish/provenance.d.ts +1 -0
- package/dist/core/publish/provenance.js +20 -0
- package/dist/core/publish/provenance.js.map +1 -0
- package/dist/core/publish/publish.d.ts +13 -0
- package/dist/core/publish/publish.js +143 -0
- package/dist/core/publish/publish.js.map +1 -0
- package/dist/core/publish/readme.d.ts +22 -0
- package/dist/core/publish/readme.js +109 -0
- package/dist/core/publish/readme.js.map +1 -0
- package/dist/core/publish/stage.d.ts +19 -0
- package/dist/core/publish/stage.js +333 -0
- package/dist/core/publish/stage.js.map +1 -0
- package/dist/core/publish/types.d.ts +71 -0
- package/dist/core/publish/types.js +2 -0
- package/dist/core/publish/types.js.map +1 -0
- package/dist/core/requires/check.d.ts +15 -0
- package/dist/core/requires/check.js +83 -0
- package/dist/core/requires/check.js.map +1 -0
- package/dist/core/requires/index.d.ts +4 -0
- package/dist/core/requires/index.js +5 -0
- package/dist/core/requires/index.js.map +1 -0
- package/dist/core/requires/inspect.d.ts +44 -0
- package/dist/core/requires/inspect.js +114 -0
- package/dist/core/requires/inspect.js.map +1 -0
- package/dist/core/requires/paths.d.ts +29 -0
- package/dist/core/requires/paths.js +83 -0
- package/dist/core/requires/paths.js.map +1 -0
- package/dist/core/requires/setup.d.ts +37 -0
- package/dist/core/requires/setup.js +147 -0
- package/dist/core/requires/setup.js.map +1 -0
- package/dist/core/setup.d.ts +27 -0
- package/dist/core/setup.js +84 -0
- package/dist/core/setup.js.map +1 -0
- package/dist/core/sources/cache.d.ts +38 -0
- package/dist/core/sources/cache.js +264 -0
- package/dist/core/sources/cache.js.map +1 -0
- package/dist/core/sources/containment.d.ts +21 -0
- package/dist/core/sources/containment.js +50 -0
- package/dist/core/sources/containment.js.map +1 -0
- package/dist/core/sources/env.d.ts +12 -0
- package/dist/core/sources/env.js +28 -0
- package/dist/core/sources/env.js.map +1 -0
- package/dist/core/sources/extract.d.ts +25 -0
- package/dist/core/sources/extract.js +639 -0
- package/dist/core/sources/extract.js.map +1 -0
- package/dist/core/sources/git-process.d.ts +26 -0
- package/dist/core/sources/git-process.js +51 -0
- package/dist/core/sources/git-process.js.map +1 -0
- package/dist/core/sources/git.d.ts +41 -0
- package/dist/core/sources/git.js +525 -0
- package/dist/core/sources/git.js.map +1 -0
- package/dist/core/sources/https.d.ts +21 -0
- package/dist/core/sources/https.js +218 -0
- package/dist/core/sources/https.js.map +1 -0
- package/dist/core/sources/index.d.ts +13 -0
- package/dist/core/sources/index.js +14 -0
- package/dist/core/sources/index.js.map +1 -0
- package/dist/core/sources/npm-cli.d.ts +19 -0
- package/dist/core/sources/npm-cli.js +51 -0
- package/dist/core/sources/npm-cli.js.map +1 -0
- package/dist/core/sources/npm.d.ts +29 -0
- package/dist/core/sources/npm.js +411 -0
- package/dist/core/sources/npm.js.map +1 -0
- package/dist/core/sources/parse.d.ts +46 -0
- package/dist/core/sources/parse.js +446 -0
- package/dist/core/sources/parse.js.map +1 -0
- package/dist/core/sources/path.d.ts +10 -0
- package/dist/core/sources/path.js +331 -0
- package/dist/core/sources/path.js.map +1 -0
- package/dist/core/sources/problems.d.ts +29 -0
- package/dist/core/sources/problems.js +36 -0
- package/dist/core/sources/problems.js.map +1 -0
- package/dist/core/sources/redact.d.ts +2 -0
- package/dist/core/sources/redact.js +70 -0
- package/dist/core/sources/redact.js.map +1 -0
- package/dist/core/sources/resolve.d.ts +9 -0
- package/dist/core/sources/resolve.js +29 -0
- package/dist/core/sources/resolve.js.map +1 -0
- package/dist/core/sources/types.d.ts +86 -0
- package/dist/core/sources/types.js +2 -0
- package/dist/core/sources/types.js.map +1 -0
- package/dist/core/sources/validate.d.ts +9 -0
- package/dist/core/sources/validate.js +116 -0
- package/dist/core/sources/validate.js.map +1 -0
- package/dist/core/summary.d.ts +79 -0
- package/dist/core/summary.js +411 -0
- package/dist/core/summary.js.map +1 -0
- package/dist/core/update/clashes.d.ts +63 -0
- package/dist/core/update/clashes.js +192 -0
- package/dist/core/update/clashes.js.map +1 -0
- package/dist/core/update/detach.d.ts +21 -0
- package/dist/core/update/detach.js +38 -0
- package/dist/core/update/detach.js.map +1 -0
- package/dist/core/update/diff.d.ts +58 -0
- package/dist/core/update/diff.js +180 -0
- package/dist/core/update/diff.js.map +1 -0
- package/dist/core/update/fetch.d.ts +34 -0
- package/dist/core/update/fetch.js +73 -0
- package/dist/core/update/fetch.js.map +1 -0
- package/dist/core/update/index.d.ts +6 -0
- package/dist/core/update/index.js +7 -0
- package/dist/core/update/index.js.map +1 -0
- package/dist/core/update/restore.d.ts +20 -0
- package/dist/core/update/restore.js +195 -0
- package/dist/core/update/restore.js.map +1 -0
- package/dist/core/update/run.d.ts +113 -0
- package/dist/core/update/run.js +1135 -0
- package/dist/core/update/run.js.map +1 -0
- package/dist/core/update/select.d.ts +39 -0
- package/dist/core/update/select.js +157 -0
- package/dist/core/update/select.js.map +1 -0
- package/dist/core/update/spelling.d.ts +51 -0
- package/dist/core/update/spelling.js +185 -0
- package/dist/core/update/spelling.js.map +1 -0
- package/dist/core/update/trees.d.ts +24 -0
- package/dist/core/update/trees.js +72 -0
- package/dist/core/update/trees.js.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.js +24 -0
- package/dist/errors.js.map +1 -0
- package/dist/help.d.ts +51 -0
- package/dist/help.js +117 -0
- package/dist/help.js.map +1 -0
- package/dist/input.d.ts +25 -0
- package/dist/input.js +174 -0
- package/dist/input.js.map +1 -0
- package/dist/output.d.ts +21 -0
- package/dist/output.js +37 -0
- package/dist/output.js.map +1 -0
- package/dist/util/frontmatter.d.ts +12 -0
- package/dist/util/frontmatter.js +58 -0
- package/dist/util/frontmatter.js.map +1 -0
- package/dist/util/fs.d.ts +38 -0
- package/dist/util/fs.js +135 -0
- package/dist/util/fs.js.map +1 -0
- package/dist/util/git-names.d.ts +8 -0
- package/dist/util/git-names.js +25 -0
- package/dist/util/git-names.js.map +1 -0
- package/dist/util/git.d.ts +12 -0
- package/dist/util/git.js +33 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/suggest.d.ts +6 -0
- package/dist/util/suggest.js +48 -0
- package/dist/util/suggest.js.map +1 -0
- package/dist/util/text.d.ts +8 -0
- package/dist/util/text.js +19 -0
- package/dist/util/text.js.map +1 -0
- package/dist/util/version.d.ts +7 -0
- package/dist/util/version.js +13 -0
- package/dist/util/version.js.map +1 -0
- package/dist/util/yaml.d.ts +30 -0
- package/dist/util/yaml.js +201 -0
- package/dist/util/yaml.js.map +1 -0
- package/package.json +51 -3
- package/resources/metafab-skill/SKILL.md +173 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Problem } from "../../errors.js";
|
|
2
|
+
import type { LocalPaths } from "../import/conflicts.js";
|
|
3
|
+
/** Factory-relative paths an update will write, as files and as directories. */
|
|
4
|
+
export interface IncomingPaths {
|
|
5
|
+
/** Paths written as a file or a symbolic link. */
|
|
6
|
+
files: readonly string[];
|
|
7
|
+
/** Directories created before a file beneath them is written. */
|
|
8
|
+
directories: readonly string[];
|
|
9
|
+
/**
|
|
10
|
+
* Paths the update removes before it writes. Local content at these paths is
|
|
11
|
+
* gone by the time a write lands, so it never stands in the way: an upstream
|
|
12
|
+
* rename or a file turned into a directory removes a path and writes its
|
|
13
|
+
* replacement. Without this, a normal restructure would be refused.
|
|
14
|
+
*/
|
|
15
|
+
removed?: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* True when a source file replaces a local file that differs only in case,
|
|
18
|
+
* and the copy spells it the source's way. An unversioned update replaces the
|
|
19
|
+
* file by design, so a case-only difference is not a conflict there.
|
|
20
|
+
*/
|
|
21
|
+
replaceCaseOnlyFiles?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* True when the update realigns a local directory whose spelling differs only
|
|
24
|
+
* in case from an incoming directory. A versioned update writes the source's
|
|
25
|
+
* spelling for every path it writes, so a case-only directory rename is not a
|
|
26
|
+
* conflict there: the directory moves, and local-only files move with it.
|
|
27
|
+
*/
|
|
28
|
+
renameCaseOnlyDirectories?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Paths whose case variant the merge already reconciled: upstream renamed a
|
|
31
|
+
* file while changing only the case of its spelling, and the merge compared
|
|
32
|
+
* the three sides at the new spelling. The write realigns the local file
|
|
33
|
+
* rather than replacing different content, so the case-only difference is not
|
|
34
|
+
* a clash. Without this an edit inside a case-renamed path would refuse an
|
|
35
|
+
* update the merge can handle.
|
|
36
|
+
*/
|
|
37
|
+
mergedCaseOnlyFiles?: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Every incoming path that would replace local content instead of merging with
|
|
41
|
+
* it: a file or link landing on a local directory, a directory landing on a
|
|
42
|
+
* local file, a path beneath a local file, or any path that differs only in
|
|
43
|
+
* case from a local file.
|
|
44
|
+
*
|
|
45
|
+
* The update writes with a remove-then-write, so without this check an incoming
|
|
46
|
+
* file at the path of a local directory would delete that directory and
|
|
47
|
+
* everything under it, while the merge plan still reported those files as
|
|
48
|
+
* preserved. A case-only clash is refused, so the same fab update behaves the
|
|
49
|
+
* same everywhere, as `import` does. The exception is a directory a versioned
|
|
50
|
+
* update realigns to the source's spelling: that moves the directory rather
|
|
51
|
+
* than replacing it, so local-only files inside it survive.
|
|
52
|
+
*
|
|
53
|
+
* Several local spellings can fold to one incoming path on a case-sensitive
|
|
54
|
+
* filesystem. An exact match is used; when none matches exactly there is no
|
|
55
|
+
* safe pick, so the update is refused rather than renaming one entry over
|
|
56
|
+
* another and losing local content.
|
|
57
|
+
*
|
|
58
|
+
* Paths the merge plan removes are not obstacles: they are deleted before any
|
|
59
|
+
* write lands. A local directory counts as removed once the plan removes every
|
|
60
|
+
* file beneath it, which is what lets an upstream directory collapse into a
|
|
61
|
+
* file. Local content the plan keeps still blocks a write, as it must.
|
|
62
|
+
*/
|
|
63
|
+
export declare function findPathClashes(local: LocalPaths, incoming: IncomingPaths): Problem[];
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { ambiguousSpellingProblem, ancestors, differentSpelling, indexOf } from "../import/conflicts.js";
|
|
2
|
+
/** The candidates the plan has not removed, in their local spelling. */
|
|
3
|
+
function remaining(candidates, removed) {
|
|
4
|
+
return (candidates ?? []).filter((candidate) => !removed.has(candidate.key.toLowerCase()));
|
|
5
|
+
}
|
|
6
|
+
function exactOf(candidates, relativePath) {
|
|
7
|
+
return candidates.find((candidate) => candidate.key === relativePath);
|
|
8
|
+
}
|
|
9
|
+
function replacedKind(file) {
|
|
10
|
+
return {
|
|
11
|
+
level: "error",
|
|
12
|
+
file,
|
|
13
|
+
message: `The update would replace ${file} with a different kind of entry`,
|
|
14
|
+
fix: "Move the local entry away, then run metafab update again",
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function blockedByFile(file, incoming) {
|
|
18
|
+
return {
|
|
19
|
+
level: "error",
|
|
20
|
+
file,
|
|
21
|
+
message: `The update writes ${incoming}, but ${file} is a file`,
|
|
22
|
+
fix: `Move ${file} away, then run metafab update again`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Every incoming path that would replace local content instead of merging with
|
|
27
|
+
* it: a file or link landing on a local directory, a directory landing on a
|
|
28
|
+
* local file, a path beneath a local file, or any path that differs only in
|
|
29
|
+
* case from a local file.
|
|
30
|
+
*
|
|
31
|
+
* The update writes with a remove-then-write, so without this check an incoming
|
|
32
|
+
* file at the path of a local directory would delete that directory and
|
|
33
|
+
* everything under it, while the merge plan still reported those files as
|
|
34
|
+
* preserved. A case-only clash is refused, so the same fab update behaves the
|
|
35
|
+
* same everywhere, as `import` does. The exception is a directory a versioned
|
|
36
|
+
* update realigns to the source's spelling: that moves the directory rather
|
|
37
|
+
* than replacing it, so local-only files inside it survive.
|
|
38
|
+
*
|
|
39
|
+
* Several local spellings can fold to one incoming path on a case-sensitive
|
|
40
|
+
* filesystem. An exact match is used; when none matches exactly there is no
|
|
41
|
+
* safe pick, so the update is refused rather than renaming one entry over
|
|
42
|
+
* another and losing local content.
|
|
43
|
+
*
|
|
44
|
+
* Paths the merge plan removes are not obstacles: they are deleted before any
|
|
45
|
+
* write lands. A local directory counts as removed once the plan removes every
|
|
46
|
+
* file beneath it, which is what lets an upstream directory collapse into a
|
|
47
|
+
* file. Local content the plan keeps still blocks a write, as it must.
|
|
48
|
+
*/
|
|
49
|
+
export function findPathClashes(local, incoming) {
|
|
50
|
+
const files = indexOf(local.files.entries());
|
|
51
|
+
const directories = indexOf(local.directories.entries());
|
|
52
|
+
const removed = new Set((incoming.removed ?? []).map((relativePath) => relativePath.toLowerCase()));
|
|
53
|
+
const mergedCaseOnly = new Set((incoming.mergedCaseOnlyFiles ?? []).map((relativePath) => relativePath.toLowerCase()));
|
|
54
|
+
const foldedLocalFiles = [...local.files.keys()].map((key) => key.toLowerCase());
|
|
55
|
+
const problems = [];
|
|
56
|
+
const reported = new Set();
|
|
57
|
+
function report(problem) {
|
|
58
|
+
const id = `${problem.file}\u0000${problem.message}`;
|
|
59
|
+
if (reported.has(id))
|
|
60
|
+
return;
|
|
61
|
+
reported.add(id);
|
|
62
|
+
problems.push(problem);
|
|
63
|
+
}
|
|
64
|
+
/** True when the plan removes every local file beneath `prefix`. */
|
|
65
|
+
function emptied(prefix) {
|
|
66
|
+
const head = `${prefix}/`;
|
|
67
|
+
for (const key of foldedLocalFiles) {
|
|
68
|
+
if (key.startsWith(head) && !removed.has(key))
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reports the first ancestor that blocks a path, or whose spelling folds to
|
|
75
|
+
* more than one local entry. Returns true when it reported.
|
|
76
|
+
*
|
|
77
|
+
* The realignment walks every component of an incoming path, so an ambiguous
|
|
78
|
+
* ancestor refuses the update even when the path itself is accepted. Checking
|
|
79
|
+
* it here keeps the refusal ahead of any write or removal.
|
|
80
|
+
*/
|
|
81
|
+
function checkAncestors(relativePath) {
|
|
82
|
+
for (const prefix of ancestors(relativePath)) {
|
|
83
|
+
const foldedPrefix = prefix.toLowerCase();
|
|
84
|
+
const ancestorFiles = remaining(files.get(foldedPrefix), removed);
|
|
85
|
+
const exactAncestor = exactOf(ancestorFiles, prefix);
|
|
86
|
+
if (exactAncestor !== undefined) {
|
|
87
|
+
report(blockedByFile(exactAncestor.value.file, relativePath));
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (ancestorFiles.length > 1) {
|
|
91
|
+
report(ambiguousSpellingProblem(ancestorFiles.map((entry) => entry.value.file), relativePath, "update"));
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
if (ancestorFiles.length === 1) {
|
|
95
|
+
report(differentSpelling(ancestorFiles[0].value.file, relativePath, "update"));
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
const ancestorDirectories = directories.get(foldedPrefix) ?? [];
|
|
99
|
+
const exactDirectory = exactOf(ancestorDirectories, prefix);
|
|
100
|
+
if (exactDirectory !== undefined)
|
|
101
|
+
continue;
|
|
102
|
+
if (ancestorDirectories.length > 1) {
|
|
103
|
+
report(ambiguousSpellingProblem(ancestorDirectories.map((entry) => entry.value), relativePath, "update"));
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (ancestorDirectories.length === 1) {
|
|
107
|
+
const replaceable = incoming.replaceCaseOnlyFiles === true ||
|
|
108
|
+
incoming.renameCaseOnlyDirectories === true ||
|
|
109
|
+
emptied(foldedPrefix);
|
|
110
|
+
if (!replaceable) {
|
|
111
|
+
report(differentSpelling(ancestorDirectories[0].value, relativePath, "update"));
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
function check(relativePath, incomingDirectory) {
|
|
119
|
+
const folded = relativePath.toLowerCase();
|
|
120
|
+
const localFiles = remaining(files.get(folded), removed);
|
|
121
|
+
const localDirectories = directories.get(folded) ?? [];
|
|
122
|
+
const exactFile = exactOf(localFiles, relativePath);
|
|
123
|
+
const exactLocalDirectory = exactOf(localDirectories, relativePath);
|
|
124
|
+
// On a case-sensitive filesystem a file and a directory can fold to one
|
|
125
|
+
// name. With no exact match for either there is no safe choice, so the
|
|
126
|
+
// update is refused rather than picking one and losing the other.
|
|
127
|
+
if (exactFile === undefined &&
|
|
128
|
+
exactLocalDirectory === undefined &&
|
|
129
|
+
localFiles.length + localDirectories.length > 1) {
|
|
130
|
+
report(ambiguousSpellingProblem([
|
|
131
|
+
...localFiles.map((entry) => entry.value.file),
|
|
132
|
+
...localDirectories.map((entry) => entry.value),
|
|
133
|
+
], relativePath, "update"));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (exactFile !== undefined) {
|
|
137
|
+
if (incomingDirectory)
|
|
138
|
+
report(replacedKind(exactFile.value.file));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (localFiles.length > 1) {
|
|
142
|
+
report(ambiguousSpellingProblem(localFiles.map((entry) => entry.value.file), relativePath, "update"));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (localFiles.length === 1) {
|
|
146
|
+
// An unversioned copy may replace a file that differs only in case; the
|
|
147
|
+
// copy spells it the source's way. A directory landing on a local file
|
|
148
|
+
// is still a kind clash. So is a file the merge did not reconcile: only a
|
|
149
|
+
// case-only rename of a base path makes the two spellings one file.
|
|
150
|
+
const mergedCaseOnlyFile = incomingDirectory !== true && mergedCaseOnly.has(folded);
|
|
151
|
+
const replaceCaseOnlyFile = incomingDirectory !== true && incoming.replaceCaseOnlyFiles === true;
|
|
152
|
+
if (!mergedCaseOnlyFile && !replaceCaseOnlyFile) {
|
|
153
|
+
report(differentSpelling(localFiles[0].value.file, relativePath, "update"));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// The file's own spelling is accepted, but the realignment still walks
|
|
157
|
+
// every ancestor and refuses one whose spelling folds to more than one
|
|
158
|
+
// local entry. Check them, or a refused update would move or remove files
|
|
159
|
+
// before the realignment reports the ambiguity.
|
|
160
|
+
checkAncestors(relativePath);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// A path beneath a local file is blocked, and an ancestor whose spelling
|
|
164
|
+
// differs only in case is refused unless the update realigns it.
|
|
165
|
+
if (checkAncestors(relativePath))
|
|
166
|
+
return;
|
|
167
|
+
if (exactLocalDirectory !== undefined) {
|
|
168
|
+
if (!incomingDirectory && !emptied(folded)) {
|
|
169
|
+
report(replacedKind(exactLocalDirectory.value));
|
|
170
|
+
}
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (localDirectories.length === 1) {
|
|
174
|
+
// Two directories that differ only in case can be reconciled when the
|
|
175
|
+
// source is copied over them, when a versioned update realigns the
|
|
176
|
+
// directory to the source's spelling, or when the plan empties the local
|
|
177
|
+
// one. A file landing on the local directory is still a kind clash.
|
|
178
|
+
const replaceable = (incoming.replaceCaseOnlyFiles === true && incomingDirectory) ||
|
|
179
|
+
(incoming.renameCaseOnlyDirectories === true && incomingDirectory) ||
|
|
180
|
+
emptied(folded);
|
|
181
|
+
if (!replaceable) {
|
|
182
|
+
report(differentSpelling(localDirectories[0].value, relativePath, "update"));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const relativePath of [...incoming.files].sort())
|
|
187
|
+
check(relativePath, false);
|
|
188
|
+
for (const relativePath of [...incoming.directories].sort())
|
|
189
|
+
check(relativePath, true);
|
|
190
|
+
return problems;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=clashes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clashes.js","sourceRoot":"","sources":["../../../src/core/update/clashes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAwCzG,wEAAwE;AACxE,SAAS,SAAS,CAChB,UAA6C,EAC7C,OAA4B;IAE5B,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,OAAO,CAAI,UAAiC,EAAE,YAAoB;IACzE,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,KAAK,YAAY,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO;QACL,KAAK,EAAE,OAAO;QACd,IAAI;QACJ,OAAO,EAAE,4BAA4B,IAAI,iCAAiC;QAC1E,GAAG,EAAE,0DAA0D;KAChE,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,QAAgB;IACnD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YAChF,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,MAAM,YAAY,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAClF,KAAK,MAAM,YAAY,IAAI,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAEvF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { UpstreamEntry } from "../config/types.js";
|
|
2
|
+
export interface DetachOptions {
|
|
3
|
+
/** Repository root that contains `.factory/`. */
|
|
4
|
+
root: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DetachReport {
|
|
7
|
+
root: string;
|
|
8
|
+
/** False when the configuration had no upstream in the first place. */
|
|
9
|
+
detached: boolean;
|
|
10
|
+
/** The upstream that was removed. */
|
|
11
|
+
upstream?: UpstreamEntry;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Removes the `upstream` key from `.factory/metafab.yaml`.
|
|
15
|
+
*
|
|
16
|
+
* Only the configuration changes: every factory file stays exactly as it is,
|
|
17
|
+
* so a detached factory keeps the content it last received.
|
|
18
|
+
*/
|
|
19
|
+
export declare function runDetach(options: DetachOptions): Promise<DetachReport>;
|
|
20
|
+
/** Human-readable report for `detach`. */
|
|
21
|
+
export declare function describeDetach(report: DetachReport): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { ExitCode, MetafabError } from "../../errors.js";
|
|
3
|
+
import { loadConfig } from "../config/load.js";
|
|
4
|
+
import { CONFIG_FILE } from "../config/parse.js";
|
|
5
|
+
import { removeUpstream } from "../config/writers.js";
|
|
6
|
+
function configInvalid(problems) {
|
|
7
|
+
return new MetafabError("The factory configuration has problems.", {
|
|
8
|
+
exitCode: ExitCode.Failed,
|
|
9
|
+
code: "config-invalid",
|
|
10
|
+
problems,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Removes the `upstream` key from `.factory/metafab.yaml`.
|
|
15
|
+
*
|
|
16
|
+
* Only the configuration changes: every factory file stays exactly as it is,
|
|
17
|
+
* so a detached factory keeps the content it last received.
|
|
18
|
+
*/
|
|
19
|
+
export async function runDetach(options) {
|
|
20
|
+
const root = path.resolve(options.root);
|
|
21
|
+
const factoryDir = path.join(root, ".factory");
|
|
22
|
+
const config = await loadConfig(factoryDir);
|
|
23
|
+
const configErrors = config.problems.filter((problem) => problem.level === "error");
|
|
24
|
+
if (configErrors.length > 0)
|
|
25
|
+
throw configInvalid(configErrors);
|
|
26
|
+
const previous = config.upstream;
|
|
27
|
+
if (previous === undefined)
|
|
28
|
+
return { root, detached: false };
|
|
29
|
+
await removeUpstream(factoryDir);
|
|
30
|
+
return { root, detached: true, upstream: previous };
|
|
31
|
+
}
|
|
32
|
+
/** Human-readable report for `detach`. */
|
|
33
|
+
export function describeDetach(report) {
|
|
34
|
+
if (!report.detached)
|
|
35
|
+
return "No upstream to detach.";
|
|
36
|
+
return `Removed the upstream from ${CONFIG_FILE}.`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=detach.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detach.js","sourceRoot":"","sources":["../../../src/core/update/detach.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAetD,SAAS,aAAa,CAAC,QAAmB;IACxC,OAAO,IAAI,YAAY,CAAC,yCAAyC,EAAE;QACjE,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,IAAI,EAAE,gBAAgB;QACtB,QAAQ;KACT,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAsB;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAW,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;IAEpD,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;IACpF,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAE7D,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC;IACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AACtD,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,cAAc,CAAC,MAAoB;IACjD,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,OAAO,wBAAwB,CAAC;IACtD,OAAO,6BAA6B,WAAW,GAAG,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { UpstreamEntry } from "../config/types.js";
|
|
2
|
+
import type { SourceOptions } from "../sources/index.js";
|
|
3
|
+
/** How a factory path differs from the recorded upstream. */
|
|
4
|
+
export type DiffStatus = "added" | "modified" | "removed";
|
|
5
|
+
export interface DiffFile {
|
|
6
|
+
/** Factory-relative POSIX path. */
|
|
7
|
+
path: string;
|
|
8
|
+
status: DiffStatus;
|
|
9
|
+
/** A unified diff for text content; absent for binary content and mode-only changes. */
|
|
10
|
+
patch?: string;
|
|
11
|
+
/** True when either side is binary. Not part of the JSON result. */
|
|
12
|
+
binary?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DiffOptions {
|
|
15
|
+
/** Repository root that contains `.factory/`. */
|
|
16
|
+
root: string;
|
|
17
|
+
/** Limit the comparison to this file or directory, relative to the repository or `.factory/`. */
|
|
18
|
+
path?: string;
|
|
19
|
+
/** Let Git prompt for credentials; the command enables it for a TTY. */
|
|
20
|
+
interactive?: boolean;
|
|
21
|
+
/** Injected source settings, used by tests for a local registry or transport. */
|
|
22
|
+
sourceOptions?: SourceOptions;
|
|
23
|
+
}
|
|
24
|
+
export interface DiffReport {
|
|
25
|
+
root: string;
|
|
26
|
+
upstream: UpstreamEntry;
|
|
27
|
+
versioned: boolean;
|
|
28
|
+
/** The normalised factory-relative prefix, when the caller limited the comparison. */
|
|
29
|
+
prefix?: string;
|
|
30
|
+
files: DiffFile[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Turns the command's path argument into a factory-relative prefix.
|
|
34
|
+
*
|
|
35
|
+
* A caller may write `skills/guide`, `.factory/skills/guide`, or an absolute
|
|
36
|
+
* path inside `.factory/`; all three name the same files. An empty value, or
|
|
37
|
+
* the factory root itself, means no limit.
|
|
38
|
+
*/
|
|
39
|
+
export declare function normalizePrefix(root: string, given: string | undefined): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Compares the factory with the recorded upstream (or the current source for an
|
|
42
|
+
* unversioned upstream). Content is compared as a snapshot does: text with LF
|
|
43
|
+
* line endings, links by target, and the permission bits as part of the entry.
|
|
44
|
+
*/
|
|
45
|
+
export declare function runDiff(options: DiffOptions): Promise<DiffReport>;
|
|
46
|
+
/**
|
|
47
|
+
* Human-readable report for `diff`.
|
|
48
|
+
*
|
|
49
|
+
* With nothing to show, the line names the upstream the factory matched, so a
|
|
50
|
+
* reader learns the comparison ran. With a path limit it names the prefix.
|
|
51
|
+
*/
|
|
52
|
+
export declare function describeDiff(report: DiffReport): string;
|
|
53
|
+
/** The JSON shape of one compared file: `{ path, status, patch? }`. */
|
|
54
|
+
export declare function jsonFile(file: DiffFile): {
|
|
55
|
+
path: string;
|
|
56
|
+
status: DiffStatus;
|
|
57
|
+
patch?: string;
|
|
58
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createTwoFilesPatch } from "diff";
|
|
3
|
+
import { ExitCode, MetafabError } from "../../errors.js";
|
|
4
|
+
import { loadConfig } from "../config/load.js";
|
|
5
|
+
import { CONFIG_FILE } from "../config/parse.js";
|
|
6
|
+
import { fetchRecordedBase } from "./fetch.js";
|
|
7
|
+
import { recordedLabel } from "./select.js";
|
|
8
|
+
import { factoryTree, localFactoryTree, sameEntry } from "./trees.js";
|
|
9
|
+
function noUpstream() {
|
|
10
|
+
return new MetafabError("This factory has no upstream to compare", {
|
|
11
|
+
exitCode: ExitCode.Failed,
|
|
12
|
+
code: "no-upstream",
|
|
13
|
+
problems: [
|
|
14
|
+
{
|
|
15
|
+
level: "error",
|
|
16
|
+
file: CONFIG_FILE,
|
|
17
|
+
message: "This factory has no upstream to compare",
|
|
18
|
+
fix: "Run metafab import <source>",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function configInvalid(problems) {
|
|
24
|
+
return new MetafabError("The factory configuration has problems.", {
|
|
25
|
+
exitCode: ExitCode.Failed,
|
|
26
|
+
code: "config-invalid",
|
|
27
|
+
problems,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Turns the command's path argument into a factory-relative prefix.
|
|
32
|
+
*
|
|
33
|
+
* A caller may write `skills/guide`, `.factory/skills/guide`, or an absolute
|
|
34
|
+
* path inside `.factory/`; all three name the same files. An empty value, or
|
|
35
|
+
* the factory root itself, means no limit.
|
|
36
|
+
*/
|
|
37
|
+
export function normalizePrefix(root, given) {
|
|
38
|
+
if (given === undefined)
|
|
39
|
+
return undefined;
|
|
40
|
+
let value = given.trim().replace(/\\/g, "/");
|
|
41
|
+
if (value === "")
|
|
42
|
+
return undefined;
|
|
43
|
+
const factoryDir = path.join(path.resolve(root), ".factory");
|
|
44
|
+
if (path.isAbsolute(value)) {
|
|
45
|
+
value = path.relative(factoryDir, value).replace(/\\/g, "/");
|
|
46
|
+
}
|
|
47
|
+
value = value.replace(/^\.\//, "");
|
|
48
|
+
if (value === ".factory")
|
|
49
|
+
return undefined;
|
|
50
|
+
if (value.startsWith(".factory/"))
|
|
51
|
+
value = value.slice(".factory/".length);
|
|
52
|
+
value = value.replace(/\/+$/, "");
|
|
53
|
+
if (value === "" || value === ".")
|
|
54
|
+
return undefined;
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
function isUnder(relativePath, prefix) {
|
|
58
|
+
if (prefix === undefined)
|
|
59
|
+
return true;
|
|
60
|
+
return relativePath === prefix || relativePath.startsWith(`${prefix}/`);
|
|
61
|
+
}
|
|
62
|
+
/** The text a text file or a symbolic link contributes to a patch. */
|
|
63
|
+
function textOf(entry) {
|
|
64
|
+
if (entry.link !== undefined)
|
|
65
|
+
return entry.link;
|
|
66
|
+
return entry.text ?? "";
|
|
67
|
+
}
|
|
68
|
+
function isBinaryEntry(entry) {
|
|
69
|
+
return entry?.binary === true;
|
|
70
|
+
}
|
|
71
|
+
function statusOf(upstream, local) {
|
|
72
|
+
if (upstream === undefined)
|
|
73
|
+
return "added";
|
|
74
|
+
if (local === undefined)
|
|
75
|
+
return "removed";
|
|
76
|
+
return "modified";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Compares the factory with the recorded upstream (or the current source for an
|
|
80
|
+
* unversioned upstream). Content is compared as a snapshot does: text with LF
|
|
81
|
+
* line endings, links by target, and the permission bits as part of the entry.
|
|
82
|
+
*/
|
|
83
|
+
export async function runDiff(options) {
|
|
84
|
+
const root = path.resolve(options.root);
|
|
85
|
+
const factoryDir = path.join(root, ".factory");
|
|
86
|
+
const config = await loadConfig(factoryDir);
|
|
87
|
+
const configErrors = config.problems.filter((problem) => problem.level === "error");
|
|
88
|
+
if (configErrors.length > 0)
|
|
89
|
+
throw configInvalid(configErrors);
|
|
90
|
+
const upstream = config.upstream;
|
|
91
|
+
if (upstream === undefined)
|
|
92
|
+
throw noUpstream();
|
|
93
|
+
const prefix = normalizePrefix(root, options.path);
|
|
94
|
+
const sourceOptions = {
|
|
95
|
+
...options.sourceOptions,
|
|
96
|
+
...(options.interactive === true ? { interactive: true } : {}),
|
|
97
|
+
};
|
|
98
|
+
let base;
|
|
99
|
+
try {
|
|
100
|
+
// A recorded source is relative to the project root, so `diff` works from a
|
|
101
|
+
// subdirectory as `update` does. Every failure propagates unchanged,
|
|
102
|
+
// including a base that no longer exists: unlike `update`, a comparison
|
|
103
|
+
// has nothing to fall back on, so the fetch's own problem and exit code
|
|
104
|
+
// reach the user.
|
|
105
|
+
base = await fetchRecordedBase(upstream, { ...sourceOptions, cwd: root });
|
|
106
|
+
const upstreamTree = await factoryTree(base.factoryDir);
|
|
107
|
+
const localTree = await localFactoryTree(root);
|
|
108
|
+
const paths = [...new Set([...Object.keys(upstreamTree), ...Object.keys(localTree)])]
|
|
109
|
+
.filter((relativePath) => isUnder(relativePath, prefix))
|
|
110
|
+
.sort();
|
|
111
|
+
const files = [];
|
|
112
|
+
for (const relativePath of paths) {
|
|
113
|
+
const theirs = upstreamTree[relativePath];
|
|
114
|
+
const yours = localTree[relativePath];
|
|
115
|
+
if (sameEntry(theirs, yours))
|
|
116
|
+
continue;
|
|
117
|
+
const file = {
|
|
118
|
+
path: relativePath,
|
|
119
|
+
status: statusOf(theirs, yours),
|
|
120
|
+
};
|
|
121
|
+
if (isBinaryEntry(theirs) || isBinaryEntry(yours)) {
|
|
122
|
+
file.binary = true;
|
|
123
|
+
files.push(file);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const before = theirs === undefined ? "" : textOf(theirs);
|
|
127
|
+
const after = yours === undefined ? "" : textOf(yours);
|
|
128
|
+
if (before !== after) {
|
|
129
|
+
file.patch = createTwoFilesPatch(`a/upstream/${relativePath}`, `b/local/${relativePath}`, before, after);
|
|
130
|
+
}
|
|
131
|
+
files.push(file);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
root,
|
|
135
|
+
upstream,
|
|
136
|
+
versioned: upstream.kind !== "unversioned",
|
|
137
|
+
...(prefix === undefined ? {} : { prefix }),
|
|
138
|
+
files,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
await base?.cleanup?.();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function binaryLine(relativePath) {
|
|
146
|
+
return `Binary files a/upstream/${relativePath} and b/local/${relativePath} differ`;
|
|
147
|
+
}
|
|
148
|
+
function describeFile(file) {
|
|
149
|
+
if (file.patch !== undefined)
|
|
150
|
+
return file.patch.trimEnd();
|
|
151
|
+
if (file.binary === true)
|
|
152
|
+
return binaryLine(file.path);
|
|
153
|
+
return `File mode of ${file.path} changed.`;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Human-readable report for `diff`.
|
|
157
|
+
*
|
|
158
|
+
* With nothing to show, the line names the upstream the factory matched, so a
|
|
159
|
+
* reader learns the comparison ran. With a path limit it names the prefix.
|
|
160
|
+
*/
|
|
161
|
+
export function describeDiff(report) {
|
|
162
|
+
if (report.files.length !== 0)
|
|
163
|
+
return report.files.map(describeFile).join("\n");
|
|
164
|
+
const source = report.upstream.source;
|
|
165
|
+
const since = report.upstream.kind === "unversioned"
|
|
166
|
+
? `${source}.`
|
|
167
|
+
: `${source} ${recordedLabel(report.upstream)}.`;
|
|
168
|
+
if (report.prefix === undefined)
|
|
169
|
+
return `No local edits since ${since}`;
|
|
170
|
+
return `No local edits in ${report.prefix} since ${since}`;
|
|
171
|
+
}
|
|
172
|
+
/** The JSON shape of one compared file: `{ path, status, patch? }`. */
|
|
173
|
+
export function jsonFile(file) {
|
|
174
|
+
return {
|
|
175
|
+
path: file.path,
|
|
176
|
+
status: file.status,
|
|
177
|
+
...(file.patch === undefined ? {} : { patch: file.patch }),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/core/update/diff.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAmCtE,SAAS,UAAU;IACjB,OAAO,IAAI,YAAY,CAAC,yCAAyC,EAAE;QACjE,QAAQ,EAAE,QAAQ,CAAC,MAAM;QACzB,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE;YACR;gBACE,KAAK,EAAE,OAAO;gBACd,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,yCAAyC;gBAClD,GAAG,EAAE,6BAA6B;aACnC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAC,QAAmB;IACxC,OAAO,IAAI,YAAY,CAAC,yCAA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AI;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,gBAAgB,IAAI,CAAC,IAAI,WAAW,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhF,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACtC,MAAM,KAAK,GACT,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,aAAa;QACpC,CAAC,CAAC,GAAG,MAAM,GAAG;QACd,CAAC,CAAC,GAAG,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,wBAAwB,KAAK,EAAE,CAAC;IACxE,OAAO,qBAAqB,MAAM,CAAC,MAAM,UAAU,KAAK,EAAE,CAAC;AAC7D,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CAAC,IAAc;IACrC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SourceOptions } from "../sources/resolve.js";
|
|
2
|
+
import type { FetchedFab, Resolved } from "../sources/types.js";
|
|
3
|
+
import type { UpstreamEntry } from "../config/types.js";
|
|
4
|
+
export interface RecordedFetchOptions extends SourceOptions {
|
|
5
|
+
/** Directory a recorded relative path resolves against. */
|
|
6
|
+
cwd: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the version or revision a recorded upstream entry names.
|
|
10
|
+
*
|
|
11
|
+
* This is the base of an update and the other half of `metafab diff`: it always
|
|
12
|
+
* resolves the recorded version or commit, never a newer one.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveRecorded(upstream: UpstreamEntry, options: RecordedFetchOptions): Promise<Resolved>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches the recorded base, so a caller can compare it with the local factory
|
|
17
|
+
* or merge it. The caller must call `cleanup` on the result in a `finally`.
|
|
18
|
+
*
|
|
19
|
+
* A failure here is either a base that no longer exists at its source (see
|
|
20
|
+
* `recordedBaseGone`) or a fetch that failed for another reason. The caller
|
|
21
|
+
* decides which: `update` merges without a base only in the first case.
|
|
22
|
+
*/
|
|
23
|
+
export declare function fetchRecordedBase(upstream: UpstreamEntry, options: RecordedFetchOptions): Promise<FetchedFab>;
|
|
24
|
+
/**
|
|
25
|
+
* True only when the recorded base no longer exists at its source: a Git ref
|
|
26
|
+
* or commit that was removed by a force push, or an npm package or version
|
|
27
|
+
* that was unpublished or removed.
|
|
28
|
+
*
|
|
29
|
+
* Every other fetch failure — an unreachable remote, a rejected credential, a
|
|
30
|
+
* cache or filesystem problem, an attribute-write failure — is not a missing
|
|
31
|
+
* base. `update` must abort on it, with the original problem and exit code,
|
|
32
|
+
* before it writes anything; `diff` must report it as it is.
|
|
33
|
+
*/
|
|
34
|
+
export declare function recordedBaseGone(error: unknown): boolean;
|