@codefast/cli 0.3.12 → 0.3.13-canary.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/README.md +206 -51
- package/dist/analyze-DvtJ3j9m.mjs +92 -0
- package/dist/arrange-Bbh62DrU.mjs +107 -0
- package/dist/arrange-BqP2DI3w.mjs +8 -0
- package/dist/ast-helpers-MDRYuIAk.mjs +115 -0
- package/dist/{bin.js → bin.mjs} +4 -1
- package/dist/caught-unknown-message-CRhkDWO7.mjs +20 -0
- package/dist/collectors-cn-BS8TTQ8O.mjs +61 -0
- package/dist/collectors-jsx-D9tL2ZPM.mjs +20 -0
- package/dist/collectors-tv-D2PXZaRt.mjs +170 -0
- package/dist/colors-BjdkCfGK.mjs +12 -0
- package/dist/commands/arrange.mjs +2 -0
- package/dist/commands/mirror.mjs +2 -0
- package/dist/commands/mirror.test.mjs +48 -0
- package/dist/commands/tag.mjs +2 -0
- package/dist/config-DVia_f9a.mjs +3 -0
- package/dist/config-reporter-SCcWDZc1.mjs +10 -0
- package/dist/constants-AtPhF-Ct.mjs +169 -0
- package/dist/constants-Bq5wdyLC.mjs +8 -0
- package/dist/dirent-list-BSDeRG5i.mjs +14 -0
- package/dist/engine-CcWEHSCq.mjs +287 -0
- package/dist/engine-DRTdkc5u.mjs +236 -0
- package/dist/errors-CFH4w6ic.mjs +15 -0
- package/dist/errors-CpU1ogfA.mjs +19 -0
- package/dist/formatters-DGE8jJ53.mjs +52 -0
- package/dist/group-file-ClW7XdD6.mjs +113 -0
- package/dist/grouping-c1grpCQT.mjs +235 -0
- package/dist/imports-DSVq1xhB.mjs +54 -0
- package/dist/lib/arrange/application/analyze.mjs +2 -0
- package/dist/lib/arrange/application/analyze.test.mjs +171 -0
- package/dist/lib/arrange/application/group-file.mjs +2 -0
- package/dist/lib/arrange/application/group-file.test.mjs +273 -0
- package/dist/lib/arrange/application/run-target.mjs +2 -0
- package/dist/lib/arrange/application/run-target.test.mjs +97 -0
- package/dist/lib/arrange/domain/ast/ast-helpers.mjs +2 -0
- package/dist/lib/arrange/domain/ast/ast-helpers.test.mjs +148 -0
- package/dist/lib/arrange/domain/ast/collectors-cn.mjs +2 -0
- package/dist/lib/arrange/domain/ast/collectors-cn.test.mjs +58 -0
- package/dist/lib/arrange/domain/ast/collectors-jsx.mjs +2 -0
- package/dist/lib/arrange/domain/ast/collectors-jsx.test.mjs +20 -0
- package/dist/lib/arrange/domain/ast/collectors-tv.mjs +2 -0
- package/dist/lib/arrange/domain/ast/collectors-tv.test.mjs +145 -0
- package/dist/lib/arrange/domain/ast/targets.mjs +2 -0
- package/dist/lib/arrange/domain/ast/targets.test.mjs +50 -0
- package/dist/lib/arrange/domain/constants.mjs +2 -0
- package/dist/lib/arrange/domain/errors.mjs +2 -0
- package/dist/lib/arrange/domain/grouping.mjs +2 -0
- package/dist/lib/arrange/domain/grouping.test.mjs +186 -0
- package/dist/lib/arrange/domain/imports.mjs +2 -0
- package/dist/lib/arrange/domain/imports.test.mjs +48 -0
- package/dist/lib/arrange/domain/tokenizer.mjs +2 -0
- package/dist/lib/arrange/domain/tokenizer.test.mjs +165 -0
- package/dist/lib/arrange/index.mjs +16 -0
- package/dist/lib/arrange/infra/walk.mjs +2 -0
- package/dist/lib/arrange/infra/walk.test.mjs +50 -0
- package/dist/lib/arrange/presentation/formatters.mjs +2 -0
- package/dist/lib/arrange/presentation/formatters.test.mjs +73 -0
- package/dist/lib/arrange/presentation/report.mjs +2 -0
- package/dist/lib/config/domain/schema.mjs +2 -0
- package/dist/lib/config/index.mjs +4 -0
- package/dist/lib/config/infra/loader.mjs +2 -0
- package/dist/lib/config/infra/loader.test.mjs +116 -0
- package/dist/lib/infra/caught-unknown-message.mjs +2 -0
- package/dist/lib/infra/config-reporter.mjs +2 -0
- package/dist/lib/infra/node-io.mjs +2 -0
- package/dist/lib/infra/workspace/repo-root.mjs +2 -0
- package/dist/lib/infra/workspace/repo-root.test.mjs +45 -0
- package/dist/lib/mirror/application/engine.mjs +2 -0
- package/dist/lib/mirror/application/sync.mjs +2 -0
- package/dist/lib/mirror/application/sync.test.mjs +482 -0
- package/dist/lib/mirror/domain/constants.mjs +2 -0
- package/dist/lib/mirror/domain/errors.mjs +2 -0
- package/dist/lib/mirror/domain/types.mjs +1 -0
- package/dist/lib/mirror/index.mjs +3 -0
- package/dist/lib/mirror/infra/dirent-list.mjs +2 -0
- package/dist/lib/mirror/infra/dirent-list.test.mjs +18 -0
- package/dist/lib/mirror/infra/package-filter.mjs +2 -0
- package/dist/lib/mirror/infra/package-filter.test.mjs +32 -0
- package/dist/lib/mirror/infra/path-normalizer.mjs +2 -0
- package/dist/lib/mirror/infra/update-pkg.mjs +2 -0
- package/dist/lib/mirror/infra/workspace-packages.mjs +2 -0
- package/dist/lib/mirror/infra/workspace-packages.test.mjs +167 -0
- package/dist/lib/mirror/presentation/reporter.mjs +2 -0
- package/dist/lib/tag/application/engine.mjs +2 -0
- package/dist/lib/tag/application/engine.test.mjs +159 -0
- package/dist/lib/tag/domain/types.mjs +1 -0
- package/dist/lib/tag/index.mjs +5 -0
- package/dist/lib/tag/infra/target-resolver.mjs +2 -0
- package/dist/lib/tag/presentation/colors.mjs +2 -0
- package/dist/lib/tag/presentation/tag-presenter.mjs +2 -0
- package/dist/lib/tag/presentation/tag-presenter.test.mjs +29 -0
- package/dist/loader-DpN-zl5g.mjs +78 -0
- package/dist/mirror-CbGiLXKT.mjs +2 -0
- package/dist/mirror-DqJE3ejL.mjs +66 -0
- package/dist/node-io-DFRbHO6m.mjs +30 -0
- package/dist/package-filter-C_8ryqvz.mjs +26 -0
- package/dist/path-normalizer-D4ceBO3l.mjs +7 -0
- package/dist/program-DR-H4tH3.mjs +34 -0
- package/dist/program.mjs +2 -0
- package/dist/repo-root-HmtIEm6J.mjs +22 -0
- package/dist/report-DYxvw34T.mjs +24 -0
- package/dist/reporter-CwIe_tAM.mjs +108 -0
- package/dist/run-target-CJWrqNT4.mjs +65 -0
- package/dist/schema-Or8RAARd.mjs +25 -0
- package/dist/sync-e1Sp-shi.mjs +157 -0
- package/dist/tag-Cd9JujU5.mjs +2 -0
- package/dist/tag-hEKVZ_-7.mjs +58 -0
- package/dist/tag-presenter-Cs66UBsH.mjs +63 -0
- package/dist/target-resolver-CR3FXMTy.mjs +170 -0
- package/dist/targets-pCTslnFh.mjs +106 -0
- package/dist/tokenizer-CeZx73Zu.mjs +216 -0
- package/dist/update-pkg-CnGfjWBy.mjs +37 -0
- package/dist/walk-DjgQn66n.mjs +33 -0
- package/dist/workspace-packages-K2NYTHJq.mjs +159 -0
- package/package.json +11 -11
- package/dist/bin.d.ts +0 -3
- package/dist/bin.d.ts.map +0 -1
- package/dist/commands/arrange.d.ts +0 -3
- package/dist/commands/arrange.d.ts.map +0 -1
- package/dist/commands/arrange.js +0 -114
- package/dist/commands/mirror.d.ts +0 -4
- package/dist/commands/mirror.d.ts.map +0 -1
- package/dist/commands/mirror.js +0 -63
- package/dist/lib/arrange/analyze.d.ts +0 -4
- package/dist/lib/arrange/analyze.d.ts.map +0 -1
- package/dist/lib/arrange/analyze.js +0 -105
- package/dist/lib/arrange/ast/collectors-cn.d.ts +0 -10
- package/dist/lib/arrange/ast/collectors-cn.d.ts.map +0 -1
- package/dist/lib/arrange/ast/collectors-cn.js +0 -84
- package/dist/lib/arrange/ast/collectors-jsx.d.ts +0 -4
- package/dist/lib/arrange/ast/collectors-jsx.d.ts.map +0 -1
- package/dist/lib/arrange/ast/collectors-jsx.js +0 -18
- package/dist/lib/arrange/ast/collectors-tv.d.ts +0 -13
- package/dist/lib/arrange/ast/collectors-tv.d.ts.map +0 -1
- package/dist/lib/arrange/ast/collectors-tv.js +0 -273
- package/dist/lib/arrange/ast/targets.d.ts +0 -8
- package/dist/lib/arrange/ast/targets.d.ts.map +0 -1
- package/dist/lib/arrange/ast/targets.js +0 -143
- package/dist/lib/arrange/ast/utils.d.ts +0 -36
- package/dist/lib/arrange/ast/utils.d.ts.map +0 -1
- package/dist/lib/arrange/ast/utils.js +0 -138
- package/dist/lib/arrange/constants.d.ts +0 -68
- package/dist/lib/arrange/constants.d.ts.map +0 -1
- package/dist/lib/arrange/constants.js +0 -179
- package/dist/lib/arrange/errors.d.ts +0 -14
- package/dist/lib/arrange/errors.d.ts.map +0 -1
- package/dist/lib/arrange/errors.js +0 -16
- package/dist/lib/arrange/formatters.d.ts +0 -16
- package/dist/lib/arrange/formatters.d.ts.map +0 -1
- package/dist/lib/arrange/formatters.js +0 -57
- package/dist/lib/arrange/group-file.d.ts +0 -4
- package/dist/lib/arrange/group-file.d.ts.map +0 -1
- package/dist/lib/arrange/group-file.js +0 -115
- package/dist/lib/arrange/grouping.d.ts +0 -41
- package/dist/lib/arrange/grouping.d.ts.map +0 -1
- package/dist/lib/arrange/grouping.js +0 -280
- package/dist/lib/arrange/imports.d.ts +0 -6
- package/dist/lib/arrange/imports.d.ts.map +0 -1
- package/dist/lib/arrange/imports.js +0 -74
- package/dist/lib/arrange/report.d.ts +0 -4
- package/dist/lib/arrange/report.d.ts.map +0 -1
- package/dist/lib/arrange/report.js +0 -37
- package/dist/lib/arrange/run-target.d.ts +0 -4
- package/dist/lib/arrange/run-target.d.ts.map +0 -1
- package/dist/lib/arrange/run-target.js +0 -28
- package/dist/lib/arrange/tokenizer.d.ts +0 -37
- package/dist/lib/arrange/tokenizer.d.ts.map +0 -1
- package/dist/lib/arrange/tokenizer.js +0 -390
- package/dist/lib/arrange/types.d.ts +0 -104
- package/dist/lib/arrange/types.d.ts.map +0 -1
- package/dist/lib/arrange/types.js +0 -7
- package/dist/lib/arrange/walk.d.ts +0 -4
- package/dist/lib/arrange/walk.d.ts.map +0 -1
- package/dist/lib/arrange/walk.js +0 -34
- package/dist/lib/arrange.d.ts +0 -41
- package/dist/lib/arrange.d.ts.map +0 -1
- package/dist/lib/arrange.js +0 -38
- package/dist/lib/infra/fs-contract.d.ts +0 -28
- package/dist/lib/infra/fs-contract.d.ts.map +0 -1
- package/dist/lib/infra/node-io.d.ts +0 -4
- package/dist/lib/infra/node-io.d.ts.map +0 -1
- package/dist/lib/infra/node-io.js +0 -27
- package/dist/lib/mirror/config.d.ts +0 -7
- package/dist/lib/mirror/config.d.ts.map +0 -1
- package/dist/lib/mirror/config.js +0 -146
- package/dist/lib/mirror/constants.d.ts +0 -10
- package/dist/lib/mirror/constants.d.ts.map +0 -1
- package/dist/lib/mirror/constants.js +0 -13
- package/dist/lib/mirror/engine.d.ts +0 -12
- package/dist/lib/mirror/engine.d.ts.map +0 -1
- package/dist/lib/mirror/engine.js +0 -248
- package/dist/lib/mirror/errors.d.ts +0 -10
- package/dist/lib/mirror/errors.d.ts.map +0 -1
- package/dist/lib/mirror/errors.js +0 -12
- package/dist/lib/mirror/package-filter.d.ts +0 -8
- package/dist/lib/mirror/package-filter.d.ts.map +0 -1
- package/dist/lib/mirror/package-filter.js +0 -33
- package/dist/lib/mirror/reporter.d.ts +0 -24
- package/dist/lib/mirror/reporter.d.ts.map +0 -1
- package/dist/lib/mirror/reporter.js +0 -126
- package/dist/lib/mirror/sync.d.ts +0 -4
- package/dist/lib/mirror/sync.d.ts.map +0 -1
- package/dist/lib/mirror/sync.js +0 -135
- package/dist/lib/mirror/types.d.ts +0 -81
- package/dist/lib/mirror/types.d.ts.map +0 -1
- package/dist/lib/mirror/update-pkg.d.ts +0 -13
- package/dist/lib/mirror/update-pkg.d.ts.map +0 -1
- package/dist/lib/mirror/update-pkg.js +0 -39
- package/dist/lib/mirror/workspace-packages.d.ts +0 -26
- package/dist/lib/mirror/workspace-packages.d.ts.map +0 -1
- package/dist/lib/mirror/workspace-packages.js +0 -160
- package/dist/lib/mirror.d.ts +0 -7
- package/dist/lib/mirror.d.ts.map +0 -1
- package/dist/lib/mirror.js +0 -5
- package/dist/lib/repo-root.d.ts +0 -7
- package/dist/lib/repo-root.d.ts.map +0 -1
- package/dist/lib/repo-root.js +0 -23
- package/dist/lib/shared/utils.d.ts +0 -9
- package/dist/lib/shared/utils.d.ts.map +0 -1
- package/dist/lib/shared/utils.js +0 -12
- package/dist/program.d.ts +0 -4
- package/dist/program.d.ts.map +0 -1
- package/dist/program.js +0 -38
- /package/dist/lib/{infra/fs-contract.js → arrange/domain/types.mjs} +0 -0
- /package/dist/lib/{mirror/types.js → infra/fs-contract.mjs} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs-contract.d.ts","sourceRoot":"","sources":["../../../src/lib/infra/fs-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,WAAW,EAAE,MAAM,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,OAAO,CAAA;KAAE,CAAC;IAClF,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,MAAM,CAAC;IACjE,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9E,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACxC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACtE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnF,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,KACvD,OAAO,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAClC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-io.d.ts","sourceRoot":"","sources":["../../../src/lib/infra/node-io.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wBAAgB,eAAe,IAAI,KAAK,CAgBvC;AAED,wBAAgB,mBAAmB,IAAI,SAAS,CAS/C"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import fsSync from "node:fs";
|
|
2
|
-
import fsPromises from "node:fs/promises";
|
|
3
|
-
import process from "node:process";
|
|
4
|
-
export function createNodeCliFs() {
|
|
5
|
-
return {
|
|
6
|
-
existsSync: fsSync.existsSync,
|
|
7
|
-
statSync: fsSync.statSync,
|
|
8
|
-
readFileSync: fsSync.readFileSync,
|
|
9
|
-
writeFileSync: fsSync.writeFileSync,
|
|
10
|
-
readdirSync: fsSync.readdirSync,
|
|
11
|
-
readFile: (p, enc) => fsPromises.readFile(p, enc),
|
|
12
|
-
writeFile: (p, data, enc) => fsPromises.writeFile(p, data, enc),
|
|
13
|
-
readdir: (p, opts) => fsPromises.readdir(p, opts),
|
|
14
|
-
rename: (oldPath, newPath) => fsPromises.rename(oldPath, newPath),
|
|
15
|
-
unlink: (p) => fsPromises.unlink(p),
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function createNodeCliLogger() {
|
|
19
|
-
return {
|
|
20
|
-
out: (line) => {
|
|
21
|
-
process.stdout.write(`${line}\n`);
|
|
22
|
-
},
|
|
23
|
-
err: (line) => {
|
|
24
|
-
process.stderr.write(`${line}\n`);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CliFs } from "#lib/infra/fs-contract";
|
|
2
|
-
import type { MirrorConfig } from "#lib/mirror/types";
|
|
3
|
-
export declare function loadMirrorConfig(rootDir: string, fs: CliFs): Promise<{
|
|
4
|
-
config: MirrorConfig;
|
|
5
|
-
warnings: string[];
|
|
6
|
-
}>;
|
|
7
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/mirror/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAOpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA2GtD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,KAAK,GACR,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA6CvD"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { CODEFAST_CONFIG_JS, CODEFAST_CONFIG_JSON, LEGACY_CONFIG_JS, LEGACY_CONFIG_JSON, } from "#lib/mirror/constants";
|
|
4
|
-
function configImportUrl(filePath) {
|
|
5
|
-
return pathToFileURL(filePath).href;
|
|
6
|
-
}
|
|
7
|
-
function isPlainObject(value) {
|
|
8
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
-
}
|
|
10
|
-
function isStringArray(value) {
|
|
11
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
12
|
-
}
|
|
13
|
-
function isPathTransformations(value) {
|
|
14
|
-
if (!isPlainObject(value))
|
|
15
|
-
return false;
|
|
16
|
-
for (const inner of Object.values(value)) {
|
|
17
|
-
if (!isPlainObject(inner))
|
|
18
|
-
return false;
|
|
19
|
-
if ("removePrefix" in inner &&
|
|
20
|
-
inner.removePrefix !== undefined &&
|
|
21
|
-
typeof inner.removePrefix !== "string") {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
function isCustomExports(value) {
|
|
28
|
-
if (!isPlainObject(value))
|
|
29
|
-
return false;
|
|
30
|
-
for (const inner of Object.values(value)) {
|
|
31
|
-
if (!isPlainObject(inner))
|
|
32
|
-
return false;
|
|
33
|
-
for (const leaf of Object.values(inner)) {
|
|
34
|
-
if (typeof leaf !== "string")
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
function isCssExports(value) {
|
|
41
|
-
if (!isPlainObject(value))
|
|
42
|
-
return false;
|
|
43
|
-
for (const entry of Object.values(value)) {
|
|
44
|
-
if (typeof entry === "boolean")
|
|
45
|
-
continue;
|
|
46
|
-
if (!isPlainObject(entry))
|
|
47
|
-
return false;
|
|
48
|
-
if ("enabled" in entry && entry.enabled !== undefined && typeof entry.enabled !== "boolean") {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if ("forceExportFiles" in entry &&
|
|
52
|
-
entry.forceExportFiles !== undefined &&
|
|
53
|
-
typeof entry.forceExportFiles !== "boolean") {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
const nested = entry.customExports;
|
|
57
|
-
if (nested !== undefined) {
|
|
58
|
-
if (!isPlainObject(nested))
|
|
59
|
-
return false;
|
|
60
|
-
for (const leaf of Object.values(nested)) {
|
|
61
|
-
if (typeof leaf !== "string")
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
/** Copies only {@link MirrorConfig} keys with runtime shape checks; strips unknown keys. */
|
|
69
|
-
function extractMirrorConfig(parsedObj) {
|
|
70
|
-
const config = {};
|
|
71
|
-
const skipPackages = parsedObj.skipPackages;
|
|
72
|
-
if (skipPackages !== undefined && isStringArray(skipPackages)) {
|
|
73
|
-
config.skipPackages = skipPackages;
|
|
74
|
-
}
|
|
75
|
-
const pathTransformations = parsedObj.pathTransformations;
|
|
76
|
-
if (pathTransformations !== undefined && isPathTransformations(pathTransformations)) {
|
|
77
|
-
config.pathTransformations = pathTransformations;
|
|
78
|
-
}
|
|
79
|
-
const customExports = parsedObj.customExports;
|
|
80
|
-
if (customExports !== undefined && isCustomExports(customExports)) {
|
|
81
|
-
config.customExports = customExports;
|
|
82
|
-
}
|
|
83
|
-
const cssExports = parsedObj.cssExports;
|
|
84
|
-
if (cssExports !== undefined && isCssExports(cssExports)) {
|
|
85
|
-
config.cssExports = cssExports;
|
|
86
|
-
}
|
|
87
|
-
return config;
|
|
88
|
-
}
|
|
89
|
-
function normalizeLoadedConfig(raw) {
|
|
90
|
-
if (!isPlainObject(raw))
|
|
91
|
-
return {};
|
|
92
|
-
const parsedObj = raw;
|
|
93
|
-
if ("mirror" in parsedObj) {
|
|
94
|
-
const wrapped = parsedObj.mirror;
|
|
95
|
-
if (isPlainObject(wrapped)) {
|
|
96
|
-
return extractMirrorConfig(wrapped);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return extractMirrorConfig(parsedObj);
|
|
100
|
-
}
|
|
101
|
-
export async function loadMirrorConfig(rootDir, fs) {
|
|
102
|
-
const warnings = [];
|
|
103
|
-
for (const name of CODEFAST_CONFIG_JS) {
|
|
104
|
-
const filePath = path.join(rootDir, name);
|
|
105
|
-
if (!fs.existsSync(filePath))
|
|
106
|
-
continue;
|
|
107
|
-
try {
|
|
108
|
-
const mod = await import(configImportUrl(filePath));
|
|
109
|
-
return { config: normalizeLoadedConfig(mod.default ?? mod), warnings };
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
warnings.push(`Could not load ${name}. Trying other config files…`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const codefastJson = path.join(rootDir, CODEFAST_CONFIG_JSON);
|
|
116
|
-
if (fs.existsSync(codefastJson)) {
|
|
117
|
-
try {
|
|
118
|
-
const content = await fs.readFile(codefastJson, "utf8");
|
|
119
|
-
return { config: normalizeLoadedConfig(JSON.parse(content)), warnings };
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
warnings.push(`Could not parse ${CODEFAST_CONFIG_JSON}: ${String(error)}`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const legacyJs = path.join(rootDir, LEGACY_CONFIG_JS);
|
|
126
|
-
if (fs.existsSync(legacyJs)) {
|
|
127
|
-
try {
|
|
128
|
-
const mod = await import(configImportUrl(legacyJs));
|
|
129
|
-
return { config: normalizeLoadedConfig(mod.default ?? mod), warnings };
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
warnings.push(`Could not load ${LEGACY_CONFIG_JS}. Falling back to .json`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const legacyJson = path.join(rootDir, LEGACY_CONFIG_JSON);
|
|
136
|
-
if (fs.existsSync(legacyJson)) {
|
|
137
|
-
try {
|
|
138
|
-
const content = await fs.readFile(legacyJson, "utf8");
|
|
139
|
-
return { config: normalizeLoadedConfig(JSON.parse(content)), warnings };
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
warnings.push(`Could not parse ${LEGACY_CONFIG_JSON}: ${String(error)}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return { config: {}, warnings };
|
|
146
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const DIST_DIR = "dist";
|
|
2
|
-
export declare const PACKAGE_JSON = "package.json";
|
|
3
|
-
export declare const CODEFAST_CONFIG_JS: readonly ["codefast.config.js", "codefast.config.mjs", "codefast.config.cjs"];
|
|
4
|
-
export declare const CODEFAST_CONFIG_JSON = "codefast.config.json";
|
|
5
|
-
export declare const LEGACY_CONFIG_JS = "generate-exports.config.js";
|
|
6
|
-
export declare const LEGACY_CONFIG_JSON = "generate-exports.config.json";
|
|
7
|
-
export declare const VALID_JS_EXTENSIONS: Set<string>;
|
|
8
|
-
export declare const DTS_EXTENSION = ".d.ts";
|
|
9
|
-
export declare const PACKAGE_JSON_EXPORT = "./package.json";
|
|
10
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/mirror/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,kBAAkB,YAC7B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,CACb,CAAC;AAEX,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAC7D,eAAO,MAAM,kBAAkB,iCAAiC,CAAC;AAEjE,eAAO,MAAM,mBAAmB,aAA2B,CAAC;AAC5D,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,eAAO,MAAM,mBAAmB,mBAAmB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const DIST_DIR = "dist";
|
|
2
|
-
export const PACKAGE_JSON = "package.json";
|
|
3
|
-
export const CODEFAST_CONFIG_JS = [
|
|
4
|
-
"codefast.config.js",
|
|
5
|
-
"codefast.config.mjs",
|
|
6
|
-
"codefast.config.cjs",
|
|
7
|
-
];
|
|
8
|
-
export const CODEFAST_CONFIG_JSON = "codefast.config.json";
|
|
9
|
-
export const LEGACY_CONFIG_JS = "generate-exports.config.js";
|
|
10
|
-
export const LEGACY_CONFIG_JSON = "generate-exports.config.json";
|
|
11
|
-
export const VALID_JS_EXTENSIONS = new Set([".js", ".cjs"]);
|
|
12
|
-
export const DTS_EXTENSION = ".d.ts";
|
|
13
|
-
export const PACKAGE_JSON_EXPORT = "./package.json";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CliFs } from "#lib/infra/fs-contract";
|
|
2
|
-
import type { GenerateExportsResult, MirrorConfig, Module } from "#lib/mirror/types";
|
|
3
|
-
export declare function normalizePath(relPath: string): string;
|
|
4
|
-
export declare function groupFilesByModule(files: string[]): Map<string, Module>;
|
|
5
|
-
export declare function toExportPath(distPath: string): string;
|
|
6
|
-
export declare function getExportGroup(exportPath: string, pathTransform: ((pathString: string) => string) | null): [string, string, number, number];
|
|
7
|
-
export declare function createPathTransform(config: MirrorConfig | undefined, packagePath: string): ((pathString: string) => string) | null;
|
|
8
|
-
/**
|
|
9
|
-
* Compute `package.json#exports` from a built `dist/` tree. No logging; no writes.
|
|
10
|
-
*/
|
|
11
|
-
export declare function generateExports(fs: CliFs, distDir: string, pathTransform: ((pathString: string) => string) | null, cssConfig: Record<string, unknown> | boolean | undefined, customExports: Record<string, string>): Promise<GenerateExportsResult>;
|
|
12
|
-
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/lib/mirror/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,KAAK,EAAe,qBAAqB,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAElG,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAoCD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BvE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIrD;AAcD,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GACrD,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAqBlC;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,GAAG,SAAS,EAChC,WAAW,EAAE,MAAM,GAClB,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,CAazC;AA0ED;;GAEG;AACH,wBAAsB,eAAe,CACnC,EAAE,EAAE,KAAK,EACT,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACtD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS,EACxD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,OAAO,CAAC,qBAAqB,CAAC,CAiEhC"}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { isDirentList } from "#lib/shared/utils";
|
|
3
|
-
import { DTS_EXTENSION, PACKAGE_JSON_EXPORT, VALID_JS_EXTENSIONS } from "#lib/mirror/constants";
|
|
4
|
-
export function normalizePath(relPath) {
|
|
5
|
-
return relPath.split(path.sep).join("/").replace(/\\/g, "/");
|
|
6
|
-
}
|
|
7
|
-
async function scanDirectoryFiles(fs, dir, baseDir = dir) {
|
|
8
|
-
try {
|
|
9
|
-
const raw = await fs.readdir(dir, { recursive: true, withFileTypes: true });
|
|
10
|
-
if (!isDirentList(raw))
|
|
11
|
-
return [];
|
|
12
|
-
return raw
|
|
13
|
-
.filter((f) => f.isFile())
|
|
14
|
-
.map((f) => {
|
|
15
|
-
const fullPath = path.join(f.parentPath, f.name);
|
|
16
|
-
const relPath = path.relative(baseDir, fullPath);
|
|
17
|
-
return normalizePath(relPath);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
if (err && typeof err === "object" && "code" in err) {
|
|
22
|
-
if (err.code === "ENOENT" || err.code === "EACCES")
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
throw err;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async function isDirectoryCssOnly(fs, distDir, dirPath) {
|
|
29
|
-
try {
|
|
30
|
-
const raw = await fs.readdir(path.join(distDir, dirPath), { withFileTypes: true });
|
|
31
|
-
if (!isDirentList(raw))
|
|
32
|
-
return false;
|
|
33
|
-
if (raw.length === 0)
|
|
34
|
-
return true;
|
|
35
|
-
return raw.every((f) => f.isFile() && f.name.endsWith(".css"));
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export function groupFilesByModule(files) {
|
|
42
|
-
const modules = new Map();
|
|
43
|
-
for (const file of files) {
|
|
44
|
-
let ext;
|
|
45
|
-
let modulePath;
|
|
46
|
-
if (file.endsWith(DTS_EXTENSION)) {
|
|
47
|
-
ext = DTS_EXTENSION;
|
|
48
|
-
modulePath = file.slice(0, -DTS_EXTENSION.length);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
ext = path.extname(file);
|
|
52
|
-
if (!VALID_JS_EXTENSIONS.has(ext))
|
|
53
|
-
continue;
|
|
54
|
-
modulePath = file.slice(0, -ext.length);
|
|
55
|
-
}
|
|
56
|
-
if (!path.basename(modulePath))
|
|
57
|
-
continue;
|
|
58
|
-
let mod = modules.get(modulePath);
|
|
59
|
-
if (!mod) {
|
|
60
|
-
mod = { path: modulePath, files: { js: null, cjs: null, dts: null } };
|
|
61
|
-
modules.set(modulePath, mod);
|
|
62
|
-
}
|
|
63
|
-
if (ext === ".js")
|
|
64
|
-
mod.files.js = file;
|
|
65
|
-
else if (ext === ".cjs")
|
|
66
|
-
mod.files.cjs = file;
|
|
67
|
-
else if (ext === DTS_EXTENSION)
|
|
68
|
-
mod.files.dts = file;
|
|
69
|
-
}
|
|
70
|
-
return modules;
|
|
71
|
-
}
|
|
72
|
-
export function toExportPath(distPath) {
|
|
73
|
-
if (distPath === "index")
|
|
74
|
-
return ".";
|
|
75
|
-
if (distPath.endsWith("/index"))
|
|
76
|
-
return `./${distPath.slice(0, -6)}`;
|
|
77
|
-
return `./${distPath}`;
|
|
78
|
-
}
|
|
79
|
-
const GROUP_ORDER = {
|
|
80
|
-
components: 100,
|
|
81
|
-
hooks: 200,
|
|
82
|
-
primitives: 300,
|
|
83
|
-
core: 400,
|
|
84
|
-
loaders: 500,
|
|
85
|
-
utils: 600,
|
|
86
|
-
adapters: 700,
|
|
87
|
-
script: 750,
|
|
88
|
-
css: 900,
|
|
89
|
-
};
|
|
90
|
-
export function getExportGroup(exportPath, pathTransform) {
|
|
91
|
-
if (exportPath === ".")
|
|
92
|
-
return [".", "", 0, 0];
|
|
93
|
-
const cleanPath = exportPath.startsWith("./") ? exportPath.slice(2) : exportPath;
|
|
94
|
-
if (cleanPath.endsWith("/*")) {
|
|
95
|
-
const dirName = cleanPath.slice(0, -2);
|
|
96
|
-
return [dirName, "", dirName === "css" ? 900 : 100, 0];
|
|
97
|
-
}
|
|
98
|
-
const parts = cleanPath.split("/");
|
|
99
|
-
if (parts.length === 1) {
|
|
100
|
-
const name = parts[0];
|
|
101
|
-
if (name in GROUP_ORDER)
|
|
102
|
-
return [name, "", GROUP_ORDER[name] ?? 0, 0];
|
|
103
|
-
if (pathTransform)
|
|
104
|
-
return ["components", name, 100, 1];
|
|
105
|
-
return ["", name, 800, 1];
|
|
106
|
-
}
|
|
107
|
-
const group = parts[0] ?? "";
|
|
108
|
-
const subpath = parts.slice(1).join("/");
|
|
109
|
-
return [group, subpath, GROUP_ORDER[group] ?? 700, 1];
|
|
110
|
-
}
|
|
111
|
-
export function createPathTransform(config, packagePath) {
|
|
112
|
-
if (!config?.pathTransformations?.[packagePath])
|
|
113
|
-
return null;
|
|
114
|
-
const { removePrefix } = config.pathTransformations[packagePath];
|
|
115
|
-
if (!removePrefix)
|
|
116
|
-
return null;
|
|
117
|
-
return (exportPath) => {
|
|
118
|
-
if (!exportPath.startsWith(removePrefix))
|
|
119
|
-
return exportPath;
|
|
120
|
-
const result = exportPath.slice(removePrefix.length);
|
|
121
|
-
if (result && result !== "." && !result.startsWith("./")) {
|
|
122
|
-
return `./${result}`;
|
|
123
|
-
}
|
|
124
|
-
return result;
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function getSortTuple(exportPath, pathTransform) {
|
|
128
|
-
const [group, subpath, order, isIndex] = getExportGroup(exportPath, pathTransform);
|
|
129
|
-
return [order, group, isIndex, subpath];
|
|
130
|
-
}
|
|
131
|
-
function compareTuples(left, right) {
|
|
132
|
-
if (left[0] !== right[0])
|
|
133
|
-
return left[0] - right[0];
|
|
134
|
-
if (left[1] !== right[1])
|
|
135
|
-
return left[1] < right[1] ? -1 : 1;
|
|
136
|
-
if (left[2] !== right[2])
|
|
137
|
-
return left[2] - right[2];
|
|
138
|
-
if (left[3] !== right[3])
|
|
139
|
-
return left[3] < right[3] ? -1 : 1;
|
|
140
|
-
return 0;
|
|
141
|
-
}
|
|
142
|
-
async function generateCssExports(fs, distDir, cssConfig) {
|
|
143
|
-
if (cssConfig === false)
|
|
144
|
-
return {};
|
|
145
|
-
if (cssConfig === true)
|
|
146
|
-
cssConfig = { enabled: true };
|
|
147
|
-
if (!cssConfig || cssConfig.enabled === false)
|
|
148
|
-
return {};
|
|
149
|
-
const files = await scanDirectoryFiles(fs, distDir);
|
|
150
|
-
const cssFiles = files.filter((f) => f.endsWith(".css"));
|
|
151
|
-
if (!cssFiles.length)
|
|
152
|
-
return {};
|
|
153
|
-
const cssExports = {
|
|
154
|
-
...cssConfig.customExports,
|
|
155
|
-
};
|
|
156
|
-
const cssByDir = new Map();
|
|
157
|
-
const rootCss = [];
|
|
158
|
-
for (const file of cssFiles) {
|
|
159
|
-
const dirName = normalizePath(path.dirname(file));
|
|
160
|
-
if (dirName === ".")
|
|
161
|
-
rootCss.push(file);
|
|
162
|
-
else {
|
|
163
|
-
const arr = cssByDir.get(dirName) || [];
|
|
164
|
-
arr.push(file);
|
|
165
|
-
cssByDir.set(dirName, arr);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
for (const file of rootCss) {
|
|
169
|
-
const exportPath = `./${file}`;
|
|
170
|
-
if (!(exportPath in cssExports))
|
|
171
|
-
cssExports[exportPath] = `./dist/${file}`;
|
|
172
|
-
}
|
|
173
|
-
for (const [dirName, dirFiles] of cssByDir.entries()) {
|
|
174
|
-
if ((await isDirectoryCssOnly(fs, distDir, dirName)) &&
|
|
175
|
-
!cssConfig.forceExportFiles) {
|
|
176
|
-
const wildcardExport = `./${dirName}/*`;
|
|
177
|
-
if (!(wildcardExport in cssExports)) {
|
|
178
|
-
cssExports[wildcardExport] = `./dist/${dirName}/*`;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
for (const file of dirFiles) {
|
|
183
|
-
const exportPath = `./${file}`;
|
|
184
|
-
if (!(exportPath in cssExports))
|
|
185
|
-
cssExports[exportPath] = `./dist/${file}`;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return cssExports;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Compute `package.json#exports` from a built `dist/` tree. No logging; no writes.
|
|
193
|
-
*/
|
|
194
|
-
export async function generateExports(fs, distDir, pathTransform, cssConfig, customExports) {
|
|
195
|
-
const files = await scanDirectoryFiles(fs, distDir);
|
|
196
|
-
if (!files.length)
|
|
197
|
-
return {
|
|
198
|
-
// Keep "./package.json" self-mapped as the standard Node.js exports fallback for package metadata.
|
|
199
|
-
exports: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
200
|
-
jsCount: 0,
|
|
201
|
-
cssCount: 0,
|
|
202
|
-
};
|
|
203
|
-
const modules = groupFilesByModule(files);
|
|
204
|
-
const validModules = Array.from(modules.values()).filter((mod) => mod.files.js && mod.files.dts);
|
|
205
|
-
if (!validModules.length)
|
|
206
|
-
return {
|
|
207
|
-
// Keep "./package.json" self-mapped as the standard Node.js exports fallback for package metadata.
|
|
208
|
-
exports: { [PACKAGE_JSON_EXPORT]: PACKAGE_JSON_EXPORT },
|
|
209
|
-
jsCount: 0,
|
|
210
|
-
cssCount: 0,
|
|
211
|
-
};
|
|
212
|
-
const exportsObj = {};
|
|
213
|
-
for (const mod of validModules) {
|
|
214
|
-
let exportPath = toExportPath(mod.path);
|
|
215
|
-
if (pathTransform)
|
|
216
|
-
exportPath = pathTransform(exportPath);
|
|
217
|
-
const distPath = `./dist/${mod.path}`;
|
|
218
|
-
const entry = { types: `${distPath}.d.ts` };
|
|
219
|
-
if (mod.files.js)
|
|
220
|
-
entry.import = `${distPath}.js`;
|
|
221
|
-
if (mod.files.cjs)
|
|
222
|
-
entry.require = `${distPath}.cjs`;
|
|
223
|
-
exportsObj[exportPath] = entry;
|
|
224
|
-
}
|
|
225
|
-
let sortedKeys = Object.keys(exportsObj).sort((pathA, pathB) => compareTuples(getSortTuple(pathA, pathTransform), getSortTuple(pathB, pathTransform)));
|
|
226
|
-
const sortedExports = {};
|
|
227
|
-
for (const exportKey of sortedKeys)
|
|
228
|
-
sortedExports[exportKey] = exportsObj[exportKey];
|
|
229
|
-
const cssExports = await generateCssExports(fs, distDir, cssConfig ?? { enabled: true });
|
|
230
|
-
Object.assign(sortedExports, cssExports);
|
|
231
|
-
for (const [specifier, mappedPath] of Object.entries(customExports || {})) {
|
|
232
|
-
if (specifier !== PACKAGE_JSON_EXPORT)
|
|
233
|
-
sortedExports[specifier] = mappedPath;
|
|
234
|
-
}
|
|
235
|
-
sortedKeys = Object.keys(sortedExports)
|
|
236
|
-
.filter((exportKey) => exportKey !== PACKAGE_JSON_EXPORT)
|
|
237
|
-
.sort((pathA, pathB) => compareTuples(getSortTuple(pathA, pathTransform), getSortTuple(pathB, pathTransform)));
|
|
238
|
-
const finalExports = {};
|
|
239
|
-
for (const exportKey of sortedKeys) {
|
|
240
|
-
finalExports[exportKey] = sortedExports[exportKey];
|
|
241
|
-
}
|
|
242
|
-
finalExports[PACKAGE_JSON_EXPORT] = PACKAGE_JSON_EXPORT;
|
|
243
|
-
return {
|
|
244
|
-
exports: finalExports,
|
|
245
|
-
jsCount: Object.keys(exportsObj).length,
|
|
246
|
-
cssCount: Object.keys(cssExports).length,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const MirrorErrorCode: {
|
|
2
|
-
readonly FATAL: "FATAL";
|
|
3
|
-
readonly PACKAGE_WRITE: "PACKAGE_WRITE";
|
|
4
|
-
};
|
|
5
|
-
export type MirrorErrorCode = (typeof MirrorErrorCode)[keyof typeof MirrorErrorCode];
|
|
6
|
-
export declare class MirrorError extends Error {
|
|
7
|
-
readonly code: MirrorErrorCode;
|
|
8
|
-
constructor(code: MirrorErrorCode, message: string, options?: ErrorOptions);
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/mirror/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;aAC1B,KAAK,EAAE,OAAO;aACd,aAAa,EAAE,eAAe;CACtB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAErF,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,YAAY,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAIzE;CACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const MirrorErrorCode = {
|
|
2
|
-
FATAL: "FATAL",
|
|
3
|
-
PACKAGE_WRITE: "PACKAGE_WRITE",
|
|
4
|
-
};
|
|
5
|
-
export class MirrorError extends Error {
|
|
6
|
-
code;
|
|
7
|
-
constructor(code, message, options) {
|
|
8
|
-
super(message, options);
|
|
9
|
-
this.name = "MirrorError";
|
|
10
|
-
this.code = code;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve `packageFilter` to a POSIX-ish path relative to `rootDir`, without using
|
|
3
|
-
* `process.cwd()`. Use for programmatic `runMirrorSync` calls.
|
|
4
|
-
*
|
|
5
|
-
* @throws If the resolved path is not a strict subdirectory of `rootDir`.
|
|
6
|
-
*/
|
|
7
|
-
export declare function resolvePackageFilterUnderRoot(rootDir: string, packageFilter: string): string;
|
|
8
|
-
//# sourceMappingURL=package-filter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-filter.d.ts","sourceRoot":"","sources":["../../../src/lib/mirror/package-filter.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAiB5F"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { realpathSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { normalizePath } from "#lib/mirror/engine";
|
|
4
|
-
function tryRealpath(entryPath) {
|
|
5
|
-
try {
|
|
6
|
-
return realpathSync.native(entryPath);
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
return path.resolve(entryPath);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Resolve `packageFilter` to a POSIX-ish path relative to `rootDir`, without using
|
|
14
|
-
* `process.cwd()`. Use for programmatic `runMirrorSync` calls.
|
|
15
|
-
*
|
|
16
|
-
* @throws If the resolved path is not a strict subdirectory of `rootDir`.
|
|
17
|
-
*/
|
|
18
|
-
export function resolvePackageFilterUnderRoot(rootDir, packageFilter) {
|
|
19
|
-
const rootResolved = path.resolve(rootDir);
|
|
20
|
-
const rootReal = tryRealpath(rootResolved);
|
|
21
|
-
const resolved = path.isAbsolute(packageFilter)
|
|
22
|
-
? tryRealpath(path.resolve(packageFilter))
|
|
23
|
-
: tryRealpath(path.join(rootReal, packageFilter));
|
|
24
|
-
const rel = path.relative(rootReal, resolved);
|
|
25
|
-
const normalized = normalizePath(rel);
|
|
26
|
-
if (normalized.startsWith("..") ||
|
|
27
|
-
path.isAbsolute(normalized) ||
|
|
28
|
-
normalized === "" ||
|
|
29
|
-
normalized === ".") {
|
|
30
|
-
throw new Error(`Package path must be a subdirectory under monorepo root: ${rootDir}`);
|
|
31
|
-
}
|
|
32
|
-
return normalized;
|
|
33
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { CliLogger } from "#lib/infra/fs-contract";
|
|
2
|
-
import type { GlobalStats, PackageStats, WorkspaceMultiDiscoverySource } from "#lib/mirror/types";
|
|
3
|
-
export declare function configureMirrorColors(noColor: boolean): void;
|
|
4
|
-
export declare function printMirrorConfigWarnings(logger: CliLogger, warnings: string[]): void;
|
|
5
|
-
export declare function mirrorGlobWarning(logger: CliLogger, message: string): void;
|
|
6
|
-
export declare function logSkippedWorkspacePackage(logger: CliLogger, index: number, total: number, displayName: string, reason: string): void;
|
|
7
|
-
export declare function mirrorBanner(logger: CliLogger): void;
|
|
8
|
-
export type MirrorProcessingMode = {
|
|
9
|
-
kind: "single";
|
|
10
|
-
} | {
|
|
11
|
-
kind: "multi";
|
|
12
|
-
source: WorkspaceMultiDiscoverySource;
|
|
13
|
-
};
|
|
14
|
-
export declare function mirrorProcessingMode(logger: CliLogger, mode: MirrorProcessingMode): void;
|
|
15
|
-
export declare function mirrorNoPackages(logger: CliLogger): void;
|
|
16
|
-
export declare function logPackageSuccess(logger: CliLogger, index: number, total: number, pkgStats: PackageStats, res: {
|
|
17
|
-
jsCount: number;
|
|
18
|
-
cssCount: number;
|
|
19
|
-
}, verbose: boolean): void;
|
|
20
|
-
export declare function logPackageError(logger: CliLogger, index: number, total: number, displayName: string, errValue: unknown, verbose: boolean): void;
|
|
21
|
-
export declare function mirrorSummarySeparator(logger: CliLogger): void;
|
|
22
|
-
export declare function mirrorSummary(logger: CliLogger, stats: GlobalStats, elapsedSeconds: number): void;
|
|
23
|
-
export declare function mirrorFatalError(logger: CliLogger, e: unknown): void;
|
|
24
|
-
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../src/lib/mirror/reporter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAuBlG,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAI5D;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAKrF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAG1E;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,IAAI,CAMN;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAIpD;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,6BAA6B,CAAA;CAAE,CAAC;AAE7D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAqBxF;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAExD;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC1C,OAAO,EAAE,OAAO,GACf,IAAI,CAmCN;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,OAAO,GACf,IAAI,CAUN;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAE9D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAgCjG;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI,CAIpE"}
|