public-ai-sync 0.0.24 → 0.0.26
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 +40 -9
- package/lib/config.mjs +28 -16
- package/lib/prune.mjs +28 -7
- package/lib/vendors.mjs +79 -0
- package/lib/wire.mjs +22 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# public-ai-sync
|
|
2
2
|
|
|
3
|
-
NPM **dev dependency** that installs this pack's AI environment into a consuming repo: rules, skills, agent files,
|
|
3
|
+
NPM **dev dependency** that installs this pack's AI environment into a consuming repo: rules, skills, agent entry files, agent hooks, scripts (lint, guard, privacy, git hooks), and code-quality runners.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ npm install --save-dev public-ai-sync
|
|
|
12
12
|
|
|
13
13
|
Default target: `.public-ai/`
|
|
14
14
|
Default source: `https://github.com/CodyTVWeber/Public-AI`
|
|
15
|
-
Default paths: `rules`, `skills`, `AI-setup`, `AGENTS.md`, `
|
|
15
|
+
Default paths: `rules`, `skills`, `AI-setup`, `AGENTS.md`, `PRIVACY.md`, `.func-size`, `.mr-size`, `scripts`, the neutral dir, plus each vendor row's entry file and config dir ([Vendors](#vendors))
|
|
16
16
|
|
|
17
17
|
Install is not a full consumer setup. Linked files are gitignored. CI, Husky, linter ignore lists, and size floors still need the steps in **Wire a consumer**.
|
|
18
18
|
|
|
@@ -40,27 +40,58 @@ skills/repo/setup-repo/assets/scripts/pre-push-gate.sh || exit $?
|
|
|
40
40
|
| --- | --- | --- |
|
|
41
41
|
| `.mr-size` | `risk: low` → size hard caps become advisory | Omit from `publicAiSync.paths` (leave unlinked) |
|
|
42
42
|
| `.func-size` | `size: b` → function warn 20 / error 40 | Omit; keep profile `a` (40/80) or `c` (50/100) via env / own file |
|
|
43
|
-
| `AGENTS.md`,
|
|
43
|
+
| `AGENTS.md`, vendor entry files | Whole-file link when the name is free | Omit when the consumer already has a real file |
|
|
44
44
|
| `PRIVACY.md`, `scripts/check-privacy.sh` | Privacy grep for this public pack | Omit or leave unhooked on a private product repo |
|
|
45
45
|
| `scripts/install-hooks.sh` | Privacy + language (Bash/JS only) + skill-catalog + size | Skip: Husky / `core.hooksPath` already set, or `PUBLIC_AI_SYNC_SKIP_HOOKS=1`. Language check fails on Python and other languages |
|
|
46
46
|
|
|
47
|
-
`scripts
|
|
47
|
+
`scripts/`, the neutral dir, and each vendor config dir merge as real directories: each child is linked; a real child file stays. Other default paths link as a whole, or stay if a real file or directory already occupies the name.
|
|
48
48
|
|
|
49
49
|
### Already has files
|
|
50
50
|
|
|
51
|
-
- Real `AGENTS.md`,
|
|
52
|
-
- `.
|
|
51
|
+
- Real `AGENTS.md`, vendor entry files, `.claude/settings.json`, Husky: left in place
|
|
52
|
+
- `.ai/rules` is linked next to a real `.ai`
|
|
53
|
+
- `.claude` links to `.ai` only when the name is free. This pack ships `.claude/settings.json`, so `.claude` stays a real dir and gets no `rules` or `skills` link; the consumer's own `.claude/rules` link (from `setup-repo`) is untouched
|
|
53
54
|
- Tracked `scripts/install-hooks.sh` that is not a pack link runs as-is (a no-op stub keeps Husky even on an empty `.husky` miss)
|
|
54
|
-
- Product skills stay in `.
|
|
55
|
+
- Product skills stay in `.ai/skills/`; pack skills live at gitignored `skills/`
|
|
55
56
|
|
|
56
57
|
## What install does
|
|
57
58
|
|
|
58
59
|
1. Copy the default paths into the target folder (atomic replace: staging, then swap)
|
|
59
|
-
2. Create relative symlinks at the consumer root so
|
|
60
|
+
2. Create relative symlinks at the consumer root so agent hooks (project-dir-relative commands) resolve. The neutral dir, vendor config dirs, and `scripts/` stay real directories; each child is linked. `AGENTS.md`, vendor entry files, `PRIVACY.md`, `rules`, `skills`, `AI-setup`, `.func-size`, and `.mr-size` link as a whole when those names are free. An existing non-link file is left in place
|
|
60
61
|
3. Gitignore the target and every link this package created
|
|
61
62
|
4. Run `scripts/install-hooks.sh` when that script is present **and** the consumer has no `.husky/` directory and no `core.hooksPath`. A consumer that is not a git repo, or that already has a foreign hook plus a `.bak`, does not fail the install
|
|
62
63
|
5. Add `public-ai:*` npm scripts when those names are free: `public-ai:sync` (manual re-run), `public-ai:lint-docs`, `public-ai:lint-explainer`, `public-ai:lint`, `public-ai:check-languages`, `public-ai:check-copies`, `public-ai:check-duplicates`, `public-ai:check-skill-catalog`, `public-ai:check-1k-cross`, `public-ai:verdict-parse`, `public-ai:code-quality`, `public-ai:privacy`, and `public-ai:install-hooks`. Consumer `postinstall` and `prepare` scripts are not added
|
|
63
64
|
|
|
65
|
+
## Vendors
|
|
66
|
+
|
|
67
|
+
One table, `DEFAULT_VENDORS` in `lib/vendors.mjs`, names every agent-specific file. Code reads rows; adding an agent is a row, never code.
|
|
68
|
+
|
|
69
|
+
| Field | Meaning |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `name` | Key. A row with a default name overrides that default |
|
|
72
|
+
| `entry` | Root file that only redirects to `AGENTS.md`. Linked as a whole |
|
|
73
|
+
| `dir` | Optional agent config dir (hooks, settings). Merged as a real dir |
|
|
74
|
+
| `neutralLink` | `true`: when `dir` differs from the neutral dir, link `dir` to the neutral dir if the name is free |
|
|
75
|
+
| `what` | One-line note |
|
|
76
|
+
|
|
77
|
+
| Default row | `entry` | `dir` | `neutralLink` |
|
|
78
|
+
| --- | --- | --- | --- |
|
|
79
|
+
| `claude` | `CLAUDE.md` | `.claude` | `true` |
|
|
80
|
+
| `gemini` | `GEMINI.md` | none | none |
|
|
81
|
+
|
|
82
|
+
- Neutral dir (`neutralDir`, default `.ai`): vendor-free dir that holds rules and skills in the source. A vendor row with `neutralLink` links its `dir` to it when the name is free. Vendor settings and hooks (`.claude/settings.json`) live in the vendor dir, which then stays real
|
|
83
|
+
- Rows join the default paths only when `paths` is omitted; an explicit `paths` list is used as given. Merge dirs always include every row's `dir`
|
|
84
|
+
- Extend: `publicAiSync.vendors` array, or env `PUBLIC_AI_SYNC_VENDORS` (JSON array, wins)
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"publicAiSync": {
|
|
89
|
+
"neutralDir": ".ai",
|
|
90
|
+
"vendors": [{ "name": "acme", "entry": "ACME.md", "dir": ".acme", "what": "Acme redirect" }]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
64
95
|
## Config
|
|
65
96
|
|
|
66
97
|
Consumer `package.json`:
|
|
@@ -76,7 +107,7 @@ Consumer `package.json`:
|
|
|
76
107
|
}
|
|
77
108
|
```
|
|
78
109
|
|
|
79
|
-
Env (wins over `package.json`): `PUBLIC_AI_SYNC_SOURCE`, `PUBLIC_AI_SYNC_REF`, `PUBLIC_AI_SYNC_TARGET`, `PUBLIC_AI_SYNC_PATHS` (comma list), `PUBLIC_AI_SYNC_ROOT`, `PUBLIC_AI_SYNC_SKIP=1`, `PUBLIC_AI_SYNC_SKIP_HOOKS=1`.
|
|
110
|
+
Env (wins over `package.json`): `PUBLIC_AI_SYNC_SOURCE`, `PUBLIC_AI_SYNC_REF`, `PUBLIC_AI_SYNC_TARGET`, `PUBLIC_AI_SYNC_PATHS` (comma list), `PUBLIC_AI_SYNC_VENDORS` (JSON array), `PUBLIC_AI_SYNC_NEUTRAL_DIR`, `PUBLIC_AI_SYNC_ROOT`, `PUBLIC_AI_SYNC_SKIP=1`, `PUBLIC_AI_SYNC_SKIP_HOOKS=1`.
|
|
80
111
|
|
|
81
112
|
`source` is a git URL or a local directory. Omit `paths` to take the full default list. A supplied env or `publicAiSync.paths` list is used even when every entry canonicalizes away; an empty list then fails at materialize instead of installing the defaults.
|
|
82
113
|
|
package/lib/config.mjs
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { isAbsolute, join, posix } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_NEUTRAL_DIR,
|
|
5
|
+
DEFAULT_VENDORS,
|
|
6
|
+
defaultPathsFor,
|
|
7
|
+
mergeTopsFor,
|
|
8
|
+
neutralLinkDirs,
|
|
9
|
+
parseVendorRows,
|
|
10
|
+
resolveVendors,
|
|
11
|
+
} from "./vendors.mjs";
|
|
3
12
|
|
|
4
13
|
export const DEFAULT_SOURCE = "https://github.com/CodyTVWeber/Public-AI";
|
|
5
14
|
export const DEFAULT_TARGET = ".public-ai";
|
|
6
15
|
export const DEFAULT_REF = "main";
|
|
7
|
-
export const DEFAULT_PATHS =
|
|
8
|
-
"rules",
|
|
9
|
-
"skills",
|
|
10
|
-
"AI-setup",
|
|
11
|
-
"AGENTS.md",
|
|
12
|
-
"CLAUDE.md",
|
|
13
|
-
"GEMINI.md",
|
|
14
|
-
"PRIVACY.md",
|
|
15
|
-
".claude",
|
|
16
|
-
".func-size",
|
|
17
|
-
".mr-size",
|
|
18
|
-
"scripts",
|
|
19
|
-
];
|
|
16
|
+
export const DEFAULT_PATHS = defaultPathsFor(DEFAULT_VENDORS, DEFAULT_NEUTRAL_DIR);
|
|
20
17
|
export const FIELD = "publicAiSync";
|
|
21
18
|
export const PKG_NAME = "public-ai-sync";
|
|
22
19
|
|
|
@@ -27,13 +24,15 @@ export function loadConfig(env = process.env) {
|
|
|
27
24
|
const source = env.PUBLIC_AI_SYNC_SOURCE || field.source || DEFAULT_SOURCE;
|
|
28
25
|
const targetRel = canonicalRel(env.PUBLIC_AI_SYNC_TARGET || field.target || DEFAULT_TARGET)
|
|
29
26
|
|| DEFAULT_TARGET;
|
|
27
|
+
const agent = agentConfig(env, field);
|
|
30
28
|
return {
|
|
31
29
|
skip: envFlag(env.PUBLIC_AI_SYNC_SKIP) || skipSelf(root, pkg),
|
|
32
30
|
skipHooks: envFlag(env.PUBLIC_AI_SYNC_SKIP_HOOKS),
|
|
33
31
|
root,
|
|
34
32
|
source: resolveSource(root, source),
|
|
35
33
|
ref: env.PUBLIC_AI_SYNC_REF || field.ref || DEFAULT_REF,
|
|
36
|
-
paths: listedPaths(env, field),
|
|
34
|
+
paths: listedPaths(env, field, agent.defaultPaths),
|
|
35
|
+
...agent,
|
|
37
36
|
targetRel,
|
|
38
37
|
target: join(root, targetRel),
|
|
39
38
|
};
|
|
@@ -47,12 +46,25 @@ export function canonicalRel(rel) {
|
|
|
47
46
|
return collapseRel(rel);
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
function
|
|
49
|
+
function agentConfig(env, field) {
|
|
50
|
+
const neutralDir = canonicalRel(env.PUBLIC_AI_SYNC_NEUTRAL_DIR || field.neutralDir || "")
|
|
51
|
+
|| DEFAULT_NEUTRAL_DIR;
|
|
52
|
+
const vendors = resolveVendors(parseVendorRows(env.PUBLIC_AI_SYNC_VENDORS || field.vendors));
|
|
53
|
+
return {
|
|
54
|
+
vendors,
|
|
55
|
+
neutralDir,
|
|
56
|
+
defaultPaths: defaultPathsFor(vendors, neutralDir),
|
|
57
|
+
mergeTops: mergeTopsFor(vendors, neutralDir),
|
|
58
|
+
neutralLinks: neutralLinkDirs(vendors, neutralDir),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function listedPaths(env, field, defaults) {
|
|
51
63
|
const fromEnv = splitRaw(env.PUBLIC_AI_SYNC_PATHS);
|
|
52
64
|
if (fromEnv) return uniqueRels(fromEnv);
|
|
53
65
|
const fromField = arrayPaths(field.paths);
|
|
54
66
|
if (fromField) return uniqueRels(fromField);
|
|
55
|
-
return
|
|
67
|
+
return uniqueRels(defaults);
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
function splitRaw(raw) {
|
package/lib/prune.mjs
CHANGED
|
@@ -8,9 +8,8 @@ import {
|
|
|
8
8
|
writeFileSync,
|
|
9
9
|
} from "node:fs";
|
|
10
10
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
11
|
-
import {
|
|
11
|
+
import { canonicalRel } from "./config.mjs";
|
|
12
12
|
|
|
13
|
-
export const MERGE_TOPS = ["scripts", ".claude"];
|
|
14
13
|
const SKIP_NAMES = new Set(["node_modules", ".git", ".public-ai"]);
|
|
15
14
|
const WIRED_NAME = ".wired";
|
|
16
15
|
|
|
@@ -34,7 +33,7 @@ export function pruneStaleOwned(job) {
|
|
|
34
33
|
const keptSet = new Set(job.kept.map(normalizeRel));
|
|
35
34
|
for (const rel of staleCandidates(job)) {
|
|
36
35
|
if (keptSet.has(normalizeRel(rel))) continue;
|
|
37
|
-
|
|
36
|
+
dropStaleOwnedPath(job, rel);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -75,10 +74,10 @@ function staleCandidates(job) {
|
|
|
75
74
|
|
|
76
75
|
function candidateRels(job) {
|
|
77
76
|
return [
|
|
78
|
-
...
|
|
77
|
+
...job.cfg.defaultPaths,
|
|
79
78
|
...job.cfg.paths,
|
|
80
79
|
...rootLinkRels(job.cfg),
|
|
81
|
-
...mergeOwnedRels(job.cfg
|
|
80
|
+
...mergeOwnedRels(job.cfg),
|
|
82
81
|
...(job.previous || []),
|
|
83
82
|
];
|
|
84
83
|
}
|
|
@@ -108,8 +107,8 @@ function ownedRootRel(cfg, name) {
|
|
|
108
107
|
return [name];
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
function mergeOwnedRels(
|
|
112
|
-
return
|
|
110
|
+
function mergeOwnedRels(cfg) {
|
|
111
|
+
return cfg.mergeTops.flatMap((top) => ownedRelsUnder(cfg.root, top));
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
function ownedRelsUnder(root, top) {
|
|
@@ -183,3 +182,25 @@ function linkResolvesInto(dest, targetRoot) {
|
|
|
183
182
|
function missingPath(_err) {
|
|
184
183
|
return false;
|
|
185
184
|
}
|
|
185
|
+
|
|
186
|
+
function dropStaleOwnedPath(job, rel) {
|
|
187
|
+
const dest = join(job.cfg.root, rel);
|
|
188
|
+
const wasNeutral = (job.previous || []).includes(normalizeRel(rel)) && neutralDirRel(job.cfg, rel);
|
|
189
|
+
if (wasNeutral && isSymlink(dest)) {
|
|
190
|
+
unlinkSync(dest);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
dropStaleLink(dest, job.cfg.target);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function neutralDirRel(cfg, rel) {
|
|
197
|
+
return cfg.vendors.some((row) => row.dir === normalizeRel(rel));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function isSymlink(path) {
|
|
201
|
+
try {
|
|
202
|
+
return lstatSync(path).isSymbolicLink();
|
|
203
|
+
} catch (err) {
|
|
204
|
+
return missingPath(err);
|
|
205
|
+
}
|
|
206
|
+
}
|
package/lib/vendors.mjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_NEUTRAL_DIR = ".ai";
|
|
4
|
+
export const DEFAULT_VENDORS = [
|
|
5
|
+
{ name: "claude", entry: "CLAUDE.md", dir: ".claude", neutralLink: true, what: "Claude Code redirect and hooks" },
|
|
6
|
+
{ name: "gemini", entry: "GEMINI.md", what: "Gemini redirect" },
|
|
7
|
+
];
|
|
8
|
+
const HEAD_PATHS = ["rules", "skills", "AI-setup", "AGENTS.md"];
|
|
9
|
+
const TAIL_PATHS = [".func-size", ".mr-size", "scripts"];
|
|
10
|
+
|
|
11
|
+
export function resolveVendors(extra) {
|
|
12
|
+
const byName = new Map(DEFAULT_VENDORS.map((row) => [row.name, row]));
|
|
13
|
+
for (const row of extra.map(cleanRow).filter(Boolean)) {
|
|
14
|
+
byName.set(row.name, { ...byName.get(row.name), ...row });
|
|
15
|
+
}
|
|
16
|
+
return [...byName.values()];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function parseVendorRows(value) {
|
|
20
|
+
const parsed = isText(value) ? parseJson(value) : value;
|
|
21
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function defaultPathsFor(vendors, neutralDir) {
|
|
25
|
+
const entries = vendors.map((row) => row.entry);
|
|
26
|
+
const dirs = vendors.map((row) => row.dir);
|
|
27
|
+
const all = [...HEAD_PATHS, ...entries, "PRIVACY.md", neutralDir, ...dirs, ...TAIL_PATHS];
|
|
28
|
+
return [...new Set(all.filter(Boolean))];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function mergeTopsFor(vendors, neutralDir) {
|
|
32
|
+
const all = ["scripts", neutralDir, ...vendors.map((row) => row.dir)];
|
|
33
|
+
return [...new Set(all.filter(Boolean))];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function neutralLinkDirs(vendors, neutralDir) {
|
|
37
|
+
return vendors
|
|
38
|
+
.filter((row) => row.neutralLink && row.dir && row.dir !== neutralDir)
|
|
39
|
+
.map((row) => row.dir);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function cleanRow(row) {
|
|
43
|
+
if (!row || typeof row !== "object" || !isText(row.name) || !row.name.trim()) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const out = { name: row.name.trim() };
|
|
47
|
+
for (const key of ["entry", "dir"]) {
|
|
48
|
+
const rel = relOrEmpty(row[key]);
|
|
49
|
+
if (rel) out[key] = rel;
|
|
50
|
+
}
|
|
51
|
+
if (typeof row.neutralLink === "boolean") out.neutralLink = row.neutralLink;
|
|
52
|
+
if (isText(row.what)) out.what = row.what;
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function relOrEmpty(value) {
|
|
57
|
+
if (!isText(value)) return "";
|
|
58
|
+
const raw = value.trim().replaceAll("\\", "/");
|
|
59
|
+
if (!raw || posix.isAbsolute(raw)) return "";
|
|
60
|
+
const rel = posix.normalize(raw).replace(/\/$/, "");
|
|
61
|
+
if (!rel || rel === "." || rel === ".." || rel.startsWith("../")) return "";
|
|
62
|
+
return rel;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isText(value) {
|
|
66
|
+
return typeof value === "string";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parseJson(text) {
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(text);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
return invalid(err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function invalid(_err) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
package/lib/wire.mjs
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import { dirname, join, relative } from "node:path";
|
|
10
10
|
import { npmScripts } from "./tools.mjs";
|
|
11
11
|
import {
|
|
12
|
-
MERGE_TOPS,
|
|
13
12
|
dropOwnedTree,
|
|
14
13
|
hasLstat,
|
|
15
14
|
isOurLink,
|
|
@@ -22,25 +21,39 @@ import {
|
|
|
22
21
|
const JSON_INDENT = 2;
|
|
23
22
|
|
|
24
23
|
export function wireConsumer(cfg, previous = []) {
|
|
25
|
-
const
|
|
24
|
+
const wired = cfg.paths.flatMap((rel) => wirePath({ cfg, rel }));
|
|
25
|
+
const links = [...wired, ...linkNeutralDirs(cfg)];
|
|
26
26
|
pruneStaleOwned({ cfg, kept: links, previous });
|
|
27
27
|
writeWired(cfg.target, links);
|
|
28
28
|
injectNpmScripts(cfg.root);
|
|
29
29
|
return links;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function linkNeutralDirs(cfg) {
|
|
33
|
+
if (!cfg.paths.includes(cfg.neutralDir)) return [];
|
|
34
|
+
const src = join(cfg.root, cfg.neutralDir);
|
|
35
|
+
if (!isRealDir(src)) return [];
|
|
36
|
+
return cfg.neutralLinks.flatMap((rel) => neutralLink({ dest: join(cfg.root, rel), src, rel }));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function neutralLink(job) {
|
|
40
|
+
if (hasLstat(job.dest)) return [];
|
|
41
|
+
makeLink(job.dest, job.src);
|
|
42
|
+
return [job.rel];
|
|
43
|
+
}
|
|
44
|
+
|
|
32
45
|
function wirePath(job) {
|
|
33
46
|
const src = join(job.cfg.target, job.rel);
|
|
34
47
|
if (!hasLstat(src)) {
|
|
35
48
|
dropOwnedTree(join(job.cfg.root, job.rel), job.cfg.target);
|
|
36
49
|
return [];
|
|
37
50
|
}
|
|
38
|
-
if (isMergeRoot(job
|
|
51
|
+
if (isMergeRoot(job)) return mergeDir(job);
|
|
39
52
|
return placeLink(job, src);
|
|
40
53
|
}
|
|
41
54
|
|
|
42
|
-
function isMergeRoot(
|
|
43
|
-
return
|
|
55
|
+
function isMergeRoot(job) {
|
|
56
|
+
return job.cfg.mergeTops.includes(job.rel);
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
function mergeDir(job) {
|
|
@@ -79,11 +92,12 @@ function refreshOrSkip(state) {
|
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
function canMerge(state) {
|
|
82
|
-
return underMergeTop(state.job
|
|
95
|
+
return underMergeTop(state.job) && isRealDir(state.dest) && isRealDir(state.src);
|
|
83
96
|
}
|
|
84
97
|
|
|
85
|
-
function underMergeTop(
|
|
86
|
-
|
|
98
|
+
function underMergeTop(job) {
|
|
99
|
+
const rel = job.rel;
|
|
100
|
+
return job.cfg.mergeTops.some((top) => rel === top || rel.startsWith(`${top}/`));
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
function linkChildren(state) {
|