@mxpicture/build-api 0.2.56 → 0.2.58
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/dist/barrel/Barrel.d.ts +66 -0
- package/dist/barrel/Barrel.d.ts.map +1 -1
- package/dist/barrel/Barrel.js +66 -2
- package/dist/barrel/Barrel.js.map +1 -1
- package/dist/cleanup/Cleanup.d.ts +70 -0
- package/dist/cleanup/Cleanup.d.ts.map +1 -1
- package/dist/cleanup/Cleanup.js +70 -0
- package/dist/cleanup/Cleanup.js.map +1 -1
- package/dist/code/code.common.d.ts +37 -4
- package/dist/code/code.common.d.ts.map +1 -1
- package/dist/code/code.common.js +37 -4
- package/dist/code/code.common.js.map +1 -1
- package/dist/code/code.exports.d.ts +25 -0
- package/dist/code/code.exports.d.ts.map +1 -1
- package/dist/code/code.exports.js +25 -1
- package/dist/code/code.exports.js.map +1 -1
- package/dist/code/code.format.d.ts +23 -0
- package/dist/code/code.format.d.ts.map +1 -1
- package/dist/code/code.format.js +23 -0
- package/dist/code/code.format.js.map +1 -1
- package/dist/common/common.fs.d.ts +22 -0
- package/dist/common/common.fs.d.ts.map +1 -1
- package/dist/common/common.fs.js +22 -0
- package/dist/common/common.fs.js.map +1 -1
- package/dist/common/common.json.d.ts +33 -0
- package/dist/common/common.json.d.ts.map +1 -1
- package/dist/common/common.json.js +45 -0
- package/dist/common/common.json.js.map +1 -1
- package/dist/deps/FixWorkspaceDeps.d.ts +132 -0
- package/dist/deps/FixWorkspaceDeps.d.ts.map +1 -1
- package/dist/deps/FixWorkspaceDeps.js +120 -2
- package/dist/deps/FixWorkspaceDeps.js.map +1 -1
- package/dist/git/GitChanges.d.ts +60 -13
- package/dist/git/GitChanges.d.ts.map +1 -1
- package/dist/git/GitChanges.js +60 -13
- package/dist/git/GitChanges.js.map +1 -1
- package/dist/git/git.util.d.ts +58 -3
- package/dist/git/git.util.d.ts.map +1 -1
- package/dist/git/git.util.js +58 -3
- package/dist/git/git.util.js.map +1 -1
- package/dist/logger/Logger.d.ts +74 -0
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/Logger.js +49 -0
- package/dist/logger/Logger.js.map +1 -1
- package/dist/npmPublish/NpmPublisher.d.ts +36 -0
- package/dist/npmPublish/NpmPublisher.d.ts.map +1 -1
- package/dist/npmPublish/NpmPublisher.js +36 -0
- package/dist/npmPublish/NpmPublisher.js.map +1 -1
- package/dist/osInfo/osInfo.common.d.ts +45 -1
- package/dist/osInfo/osInfo.common.d.ts.map +1 -1
- package/dist/osInfo/osInfo.common.js +45 -1
- package/dist/osInfo/osInfo.common.js.map +1 -1
- package/dist/pkg/ExportExtractor.d.ts +44 -0
- package/dist/pkg/ExportExtractor.d.ts.map +1 -0
- package/dist/pkg/ExportExtractor.js +180 -0
- package/dist/pkg/ExportExtractor.js.map +1 -0
- package/dist/pkg/Pkg.d.ts +69 -0
- package/dist/pkg/Pkg.d.ts.map +1 -1
- package/dist/pkg/Pkg.js +69 -0
- package/dist/pkg/Pkg.js.map +1 -1
- package/dist/pkg/SyncPkgVersion.d.ts +35 -0
- package/dist/pkg/SyncPkgVersion.d.ts.map +1 -1
- package/dist/pkg/SyncPkgVersion.js +35 -0
- package/dist/pkg/SyncPkgVersion.js.map +1 -1
- package/dist/pkg/UpdatePackages.d.ts +36 -0
- package/dist/pkg/UpdatePackages.d.ts.map +1 -1
- package/dist/pkg/UpdatePackages.js +36 -0
- package/dist/pkg/UpdatePackages.js.map +1 -1
- package/dist/pkg/index.d.ts +1 -0
- package/dist/pkg/index.d.ts.map +1 -1
- package/dist/pkg/index.js +1 -0
- package/dist/pkg/index.js.map +1 -1
- package/dist/pkg/pkg.common.d.ts +73 -0
- package/dist/pkg/pkg.common.d.ts.map +1 -1
- package/dist/pkg/pkg.common.js +73 -0
- package/dist/pkg/pkg.common.js.map +1 -1
- package/dist/pkg/pkg.fs.d.ts +53 -0
- package/dist/pkg/pkg.fs.d.ts.map +1 -1
- package/dist/pkg/pkg.fs.js +57 -5
- package/dist/pkg/pkg.fs.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/types.barrel.d.ts +28 -0
- package/dist/types/types.barrel.d.ts.map +1 -1
- package/dist/types/types.barrel.js.map +1 -1
- package/dist/types/types.changelog.d.ts +28 -0
- package/dist/types/types.changelog.d.ts.map +1 -1
- package/dist/types/types.changelog.js +9 -0
- package/dist/types/types.changelog.js.map +1 -1
- package/dist/types/types.cleanup.d.ts +19 -0
- package/dist/types/types.cleanup.d.ts.map +1 -1
- package/dist/types/types.cleanup.js.map +1 -1
- package/dist/types/types.code.d.ts +36 -0
- package/dist/types/types.code.d.ts.map +1 -1
- package/dist/types/types.code.js.map +1 -1
- package/dist/types/types.deps.d.ts +27 -0
- package/dist/types/types.deps.d.ts.map +1 -1
- package/dist/types/types.deps.js +10 -0
- package/dist/types/types.deps.js.map +1 -1
- package/dist/types/types.documents.d.ts +9 -0
- package/dist/types/types.documents.d.ts.map +1 -1
- package/dist/types/types.documents.js.map +1 -1
- package/dist/types/types.exports.d.ts +42 -0
- package/dist/types/types.exports.d.ts.map +1 -0
- package/dist/types/types.exports.js +2 -0
- package/dist/types/types.exports.js.map +1 -0
- package/dist/types/types.git.d.ts +25 -0
- package/dist/types/types.git.d.ts.map +1 -1
- package/dist/types/types.git.js.map +1 -1
- package/dist/types/types.npm.d.ts +7 -0
- package/dist/types/types.npm.d.ts.map +1 -1
- package/dist/types/types.npm.js.map +1 -1
- package/dist/types/types.os.d.ts +8 -0
- package/dist/types/types.os.d.ts.map +1 -1
- package/dist/types/types.os.js.map +1 -1
- package/dist/types/types.package.d.ts +48 -0
- package/dist/types/types.package.d.ts.map +1 -1
- package/dist/types/types.package.js.map +1 -1
- package/dist/types/types.run.d.ts +4 -0
- package/dist/types/types.run.d.ts.map +1 -1
- package/dist/types/types.run.js.map +1 -1
- package/dist/types/types.vscode.d.ts +46 -0
- package/dist/types/types.vscode.d.ts.map +1 -1
- package/dist/types/types.vscode.js.map +1 -1
- package/dist/types/types.workspace.d.ts +18 -0
- package/dist/types/types.workspace.d.ts.map +1 -1
- package/dist/types/types.workspace.js +6 -0
- package/dist/types/types.workspace.js.map +1 -1
- package/dist/vscode/vscode.config.d.ts +18 -0
- package/dist/vscode/vscode.config.d.ts.map +1 -1
- package/dist/vscode/vscode.config.js +18 -0
- package/dist/vscode/vscode.config.js.map +1 -1
- package/dist/vscode/vscode.profiles.d.ts +37 -0
- package/dist/vscode/vscode.profiles.d.ts.map +1 -1
- package/dist/vscode/vscode.profiles.js +37 -0
- package/dist/vscode/vscode.profiles.js.map +1 -1
- package/dist/vscode/vscode.settings.d.ts +26 -1
- package/dist/vscode/vscode.settings.d.ts.map +1 -1
- package/dist/vscode/vscode.settings.js +28 -3
- package/dist/vscode/vscode.settings.js.map +1 -1
- package/dist/vscode/vscode.storage.d.ts +21 -1
- package/dist/vscode/vscode.storage.d.ts.map +1 -1
- package/dist/vscode/vscode.storage.js +23 -3
- package/dist/vscode/vscode.storage.js.map +1 -1
- package/dist/vscode/vscode.workspace.d.ts +17 -0
- package/dist/vscode/vscode.workspace.d.ts.map +1 -1
- package/dist/vscode/vscode.workspace.js +19 -2
- package/dist/vscode/vscode.workspace.js.map +1 -1
- package/dist/workspace/Workspace.d.ts +85 -0
- package/dist/workspace/Workspace.d.ts.map +1 -1
- package/dist/workspace/Workspace.js +85 -0
- package/dist/workspace/Workspace.js.map +1 -1
- package/dist/workspace/workspace.common.d.ts +42 -1
- package/dist/workspace/workspace.common.d.ts.map +1 -1
- package/dist/workspace/workspace.common.js +42 -1
- package/dist/workspace/workspace.common.js.map +1 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.common.js","sourceRoot":"","sources":["../../src/code/code.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,MAAM,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AC,WAAW,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC;IACnD,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC7C,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;IAC3C,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW;QAAE,OAAO,WAAW,CAAC;IACvD,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS;QAAE,OAAO,MAAM,CAAC;IAChD,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS;QAAE,OAAO,WAAW,CAAC;IACrD,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,QAAQ;QAAE,OAAO,UAAU,CAAC;IACnD,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK;QAAE,OAAO,OAAO,CAAC;IAC7C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import ts from \"typescript\";\nimport { SourceFile } from \"../types/types.code.js\";\n\n/**\n * Creates a TypeScript program and returns an array of {@link SourceFile} entries.\n *\n * @remarks\n * A new `ts.Program` is created for every call. When you need to process many\n * files, prefer {@link createSourceFileMap} which is more efficient because the\n * compiler is only instantiated once and results are keyed by path.\n *\n * @param filePaths - Absolute paths to the TypeScript source files to load.\n * @returns An array of successfully parsed {@link SourceFile} entries.\n */\nexport const createSourceFiles = (filePaths: string[]): SourceFile[] => {\n const program = ts.createProgram(filePaths, {\n target: ts.ScriptTarget.ES2023,\n module: ts.ModuleKind.Node20,\n strict: true,\n });\n const checker = program.getTypeChecker();\n const results: SourceFile[] = [];\n\n for (const filePath of filePaths) {\n const sourceFile = program.getSourceFile(filePath);\n if (!sourceFile) continue;\n results.push({ sourceFile, filePath, checker });\n }\n\n return results;\n};\n\n/**\n * Creates a single TypeScript program and returns a map from file path to {@link SourceFile}.\n *\n * @remarks\n * This is more efficient than {@link createSourceFiles} when processing many\n * files, because the TypeScript compiler is only instantiated once and the\n * results are keyed by path for O(1) lookup.\n *\n * @param filePaths - Absolute paths to the TypeScript source files to load.\n * @returns A map keyed by file path whose values are the parsed {@link SourceFile} entries.\n */\nexport const createSourceFileMap = (\n filePaths: string[],\n): Map<string, SourceFile> => {\n const program = ts.createProgram(filePaths, {\n target: ts.ScriptTarget.ES2023,\n module: ts.ModuleKind.Node20,\n strict: true,\n });\n const checker = program.getTypeChecker();\n const map = new Map<string, SourceFile>();\n for (const filePath of filePaths) {\n const sourceFile = program.getSourceFile(filePath);\n if (!sourceFile) continue;\n map.set(filePath, { sourceFile, filePath, checker });\n }\n return map;\n};\n\n/**\n * Returns the human-readable syntax-kind name for a TypeScript declaration node.\n *\n * @param d - The TypeScript declaration node to inspect.\n * @returns The name of the declaration's {@link ts.SyntaxKind}, or `\"Unknown\"` if unmapped.\n */\nexport const declarationKindName = (d: ts.Declaration) =>\n ts.SyntaxKind[d.kind] ?? \"Unknown\";\n\n/**\n * Infers a human-readable kind label from a symbol's flags.\n *\n * @remarks\n * The mapping is approximate — it checks flags in priority order and returns\n * the first match. This is sufficient for reporting purposes but may not\n * capture every nuance of the TypeScript symbol model.\n *\n * @param sym - The TypeScript symbol whose kind should be inferred.\n * @returns A lowercase label such as `\"function\"`, `\"class\"`, or `\"unknown\"`.\n */\nexport const guessKindFromFlags = (sym: ts.Symbol): string => {\n // Not perfect, but good enough for reporting.\n const f = sym.getFlags();\n if (f & ts.SymbolFlags.Function) return \"function\";\n if (f & ts.SymbolFlags.Class) return \"class\";\n if (f & ts.SymbolFlags.Enum) return \"enum\";\n if (f & ts.SymbolFlags.ValueModule) return \"namespace\";\n if (f & ts.SymbolFlags.TypeAlias) return \"type\";\n if (f & ts.SymbolFlags.Interface) return \"interface\";\n if (f & ts.SymbolFlags.Variable) return \"variable\";\n if (f & ts.SymbolFlags.Alias) return \"alias\";\n return \"unknown\";\n};\n"]}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
import { FileExportsParams, SourceExport } from "../types/types.code.js";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts exported symbols from a TypeScript file using the compiler API.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Walks the module's export surface (including re-exports) and classifies each
|
|
7
|
+
* symbol by kind, type-only status, and re-export origin. Results are sorted
|
|
8
|
+
* alphabetically by name for stable output. The caller can control which
|
|
9
|
+
* categories of exports are included via {@link FileExportsParams.opts}.
|
|
10
|
+
*
|
|
11
|
+
* @param p - Parameters specifying the file path, optional filter flags, and an
|
|
12
|
+
* optional pre-built source to avoid redundant parsing.
|
|
13
|
+
* @returns A {@link SourceExport} containing the discovered export items and
|
|
14
|
+
* whether the file uses selective (named) exports.
|
|
15
|
+
*/
|
|
2
16
|
export declare const fileExportsCompilerApi: (p: FileExportsParams) => SourceExport;
|
|
17
|
+
/**
|
|
18
|
+
* Non-compiler fallback that always returns an empty export list.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* This function exists as a no-op counterpart to {@link fileExportsCompilerApi}
|
|
22
|
+
* and is selected at call-sites that do not require TypeScript Compiler API
|
|
23
|
+
* analysis. It unconditionally reports no named exports.
|
|
24
|
+
*
|
|
25
|
+
* @param p - Parameters specifying the file whose exports would be extracted.
|
|
26
|
+
* @returns A {@link SourceExport} with an empty items array and `selectiveExport` set to `false`.
|
|
27
|
+
*/
|
|
3
28
|
export declare const fileExportsByFile: (p: FileExportsParams) => SourceExport;
|
|
4
29
|
//# sourceMappingURL=code.exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.exports.d.ts","sourceRoot":"","sources":["../../src/code/code.exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQzE,eAAO,MAAM,sBAAsB,GAAI,GAAG,iBAAiB,KAAG,YA2E7D,CAAC;
|
|
1
|
+
{"version":3,"file":"code.exports.d.ts","sourceRoot":"","sources":["../../src/code/code.exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAQzE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GAAI,GAAG,iBAAiB,KAAG,YA2E7D,CAAC;AAEF;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,iBAAiB,GAAI,GAAG,iBAAiB,KAAG,YAGvD,CAAC"}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { createSourceFiles, declarationKindName, guessKindFromFlags, } from "./code.common.js";
|
|
4
|
+
/**
|
|
5
|
+
* Extracts exported symbols from a TypeScript file using the compiler API.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Walks the module's export surface (including re-exports) and classifies each
|
|
9
|
+
* symbol by kind, type-only status, and re-export origin. Results are sorted
|
|
10
|
+
* alphabetically by name for stable output. The caller can control which
|
|
11
|
+
* categories of exports are included via {@link FileExportsParams.opts}.
|
|
12
|
+
*
|
|
13
|
+
* @param p - Parameters specifying the file path, optional filter flags, and an
|
|
14
|
+
* optional pre-built source to avoid redundant parsing.
|
|
15
|
+
* @returns A {@link SourceExport} containing the discovered export items and
|
|
16
|
+
* whether the file uses selective (named) exports.
|
|
17
|
+
*/
|
|
4
18
|
export const fileExportsCompilerApi = (p) => {
|
|
5
19
|
const includeTypeOnly = p.opts?.includeTypeOnly ?? true;
|
|
6
20
|
const includeReExports = p.opts?.includeReExports ?? true;
|
|
@@ -69,7 +83,17 @@ export const fileExportsCompilerApi = (p) => {
|
|
|
69
83
|
result.items.sort((a, b) => a.name.localeCompare(b.name));
|
|
70
84
|
return result;
|
|
71
85
|
};
|
|
72
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Non-compiler fallback that always returns an empty export list.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* This function exists as a no-op counterpart to {@link fileExportsCompilerApi}
|
|
91
|
+
* and is selected at call-sites that do not require TypeScript Compiler API
|
|
92
|
+
* analysis. It unconditionally reports no named exports.
|
|
93
|
+
*
|
|
94
|
+
* @param p - Parameters specifying the file whose exports would be extracted.
|
|
95
|
+
* @returns A {@link SourceExport} with an empty items array and `selectiveExport` set to `false`.
|
|
96
|
+
*/
|
|
73
97
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
98
|
export const fileExportsByFile = (p) => ({
|
|
75
99
|
items: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.exports.js","sourceRoot":"","sources":["../../src/code/code.exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAoB,EAAgB,EAAE;IAC3E,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,EAAE,eAAe,IAAI,IAAI,CAAC;IACxD,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,EAAE,gBAAgB,IAAI,IAAI,CAAC;IAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,KAAK,GAAG,CAAC,CAAC,cAAc;QAC5B,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;QACpB,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;IAE9E,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GA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C,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAoB,EAAgB,EAAE,CAAC,CAAC;IACxE,KAAK,EAAE,EAAE;IACT,eAAe,EAAE,KAAK;CACvB,CAAC,CAAC","sourcesContent":["import ts from \"typescript\";\nimport { FileExportsParams, SourceExport } from \"../types/types.code.js\";\nimport { resolve } from \"node:path\";\nimport {\n createSourceFiles,\n declarationKindName,\n guessKindFromFlags,\n} from \"./code.common.js\";\n\n/**\n * Extracts exported symbols from a TypeScript file using the compiler API.\n *\n * @remarks\n * Walks the module's export surface (including re-exports) and classifies each\n * symbol by kind, type-only status, and re-export origin. Results are sorted\n * alphabetically by name for stable output. The caller can control which\n * categories of exports are included via {@link FileExportsParams.opts}.\n *\n * @param p - Parameters specifying the file path, optional filter flags, and an\n * optional pre-built source to avoid redundant parsing.\n * @returns A {@link SourceExport} containing the discovered export items and\n * whether the file uses selective (named) exports.\n */\nexport const fileExportsCompilerApi = (p: FileExportsParams): SourceExport => {\n const includeTypeOnly = p.opts?.includeTypeOnly ?? true;\n const includeReExports = p.opts?.includeReExports ?? true;\n const abs = resolve(p.filePath);\n\n const files = p.preBuiltSource\n ? [p.preBuiltSource]\n : createSourceFiles([p.filePath]);\n if (files.length === 0) throw new Error(`Could not load source file: ${abs}`);\n\n const { checker, sourceFile } = files[0];\n\n const result: SourceExport = {\n items: [],\n selectiveExport: true,\n };\n\n const moduleSymbol = checker.getSymbolAtLocation(sourceFile);\n if (!moduleSymbol) return result;\n\n // This gives the \"export surface\" of the module (including re-exports).\n const exports = checker.getExportsOfModule(moduleSymbol);\n\n for (const sym of exports) {\n const name = sym.getName();\n if (name === \"default\") {\n result.selectiveExport = false;\n if (!p.opts?.includeDefault) continue;\n } else if (name.startsWith(\"_\")) {\n if (!p.opts?.includePrivate) continue;\n }\n\n // Determine if it's type-only (TypeScript 5.x provides isTypeOnlySymbol).\n // Fallback: approximate using flags.\n const isTypeOnly =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (checker as any).isTypeOnlySymbol === \"function\"\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ((checker as any).isTypeOnlySymbol(sym) as boolean)\n : !!(\n sym.getFlags() &\n (ts.SymbolFlags.Type |\n ts.SymbolFlags.Interface |\n ts.SymbolFlags.TypeAlias)\n );\n\n if (!includeTypeOnly && isTypeOnly) continue;\n\n // Re-export detection: if symbol is an alias and resolves elsewhere\n let isReExport = false;\n let resolved = sym;\n if (sym.getFlags() & ts.SymbolFlags.Alias) {\n const aliased = checker.getAliasedSymbol(sym);\n if (aliased && aliased !== sym) {\n isReExport = true;\n resolved = aliased;\n }\n }\n\n if (!includeReExports && isReExport) continue;\n\n const decls = (resolved.getDeclarations() ?? []).map(declarationKindName);\n\n result.items.push({\n name,\n kind: guessKindFromFlags(resolved),\n isTypeOnly,\n isReExport,\n declarations: decls,\n });\n }\n\n // stable-ish output\n result.items.sort((a, b) => a.name.localeCompare(b.name));\n return result;\n};\n\n/**\n * Non-compiler fallback that always returns an empty export list.\n *\n * @remarks\n * This function exists as a no-op counterpart to {@link fileExportsCompilerApi}\n * and is selected at call-sites that do not require TypeScript Compiler API\n * analysis. It unconditionally reports no named exports.\n *\n * @param p - Parameters specifying the file whose exports would be extracted.\n * @returns A {@link SourceExport} with an empty items array and `selectiveExport` set to `false`.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const fileExportsByFile = (p: FileExportsParams): SourceExport => ({\n items: [],\n selectiveExport: false,\n});\n"]}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats TypeScript code using Prettier.
|
|
3
|
+
*
|
|
4
|
+
* @param lines - One or more code strings that are joined with newlines before formatting.
|
|
5
|
+
* @returns The formatted TypeScript source code.
|
|
6
|
+
*/
|
|
1
7
|
export declare const formatCode: (...lines: string[]) => Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Formats a JSON document using Prettier.
|
|
10
|
+
*
|
|
11
|
+
* @param lines - One or more JSON strings that are joined with newlines before formatting.
|
|
12
|
+
* @returns The formatted JSON string.
|
|
13
|
+
*/
|
|
2
14
|
export declare const formatJson: (...lines: string[]) => Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Formats a JSON value using Prettier's `json-stringify` parser.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Unlike {@link formatJson}, this uses the `json-stringify` parser which
|
|
20
|
+
* produces output closer to `JSON.stringify` — for example it does not add a
|
|
21
|
+
* trailing newline after the top-level value.
|
|
22
|
+
*
|
|
23
|
+
* @param lines - One or more JSON strings that are joined with newlines before formatting.
|
|
24
|
+
* @returns The formatted JSON string.
|
|
25
|
+
*/
|
|
3
26
|
export declare const formatJsonStringify: (...lines: string[]) => Promise<string>;
|
|
4
27
|
//# sourceMappingURL=code.format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.format.d.ts","sourceRoot":"","sources":["../../src/code/code.format.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,GAAU,GAAG,OAAO,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,CAChB,CAAC;AAErD,eAAO,MAAM,UAAU,GAAU,GAAG,OAAO,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,CACtB,CAAC;AAE/C,eAAO,MAAM,mBAAmB,GAC9B,GAAG,OAAO,MAAM,EAAE,KACjB,OAAO,CAAC,MAAM,CAA2D,CAAC"}
|
|
1
|
+
{"version":3,"file":"code.format.d.ts","sourceRoot":"","sources":["../../src/code/code.format.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAU,GAAG,OAAO,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,CAChB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAU,GAAG,OAAO,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,CACtB,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAC9B,GAAG,OAAO,MAAM,EAAE,KACjB,OAAO,CAAC,MAAM,CAA2D,CAAC"}
|
package/dist/code/code.format.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import { format } from "prettier";
|
|
2
|
+
/**
|
|
3
|
+
* Formats TypeScript code using Prettier.
|
|
4
|
+
*
|
|
5
|
+
* @param lines - One or more code strings that are joined with newlines before formatting.
|
|
6
|
+
* @returns The formatted TypeScript source code.
|
|
7
|
+
*/
|
|
2
8
|
export const formatCode = async (...lines) => format(lines.join("\n"), { parser: "typescript" });
|
|
9
|
+
/**
|
|
10
|
+
* Formats a JSON document using Prettier.
|
|
11
|
+
*
|
|
12
|
+
* @param lines - One or more JSON strings that are joined with newlines before formatting.
|
|
13
|
+
* @returns The formatted JSON string.
|
|
14
|
+
*/
|
|
3
15
|
export const formatJson = async (...lines) => format(lines.join("\n"), { parser: "json" });
|
|
16
|
+
/**
|
|
17
|
+
* Formats a JSON value using Prettier's `json-stringify` parser.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* Unlike {@link formatJson}, this uses the `json-stringify` parser which
|
|
21
|
+
* produces output closer to `JSON.stringify` — for example it does not add a
|
|
22
|
+
* trailing newline after the top-level value.
|
|
23
|
+
*
|
|
24
|
+
* @param lines - One or more JSON strings that are joined with newlines before formatting.
|
|
25
|
+
* @returns The formatted JSON string.
|
|
26
|
+
*/
|
|
4
27
|
export const formatJsonStringify = async (...lines) => format(lines.join("\n"), { parser: "json-stringify" });
|
|
5
28
|
//# sourceMappingURL=code.format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.format.js","sourceRoot":"","sources":["../../src/code/code.format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,GAAG,KAAe,EAAmB,EAAE,CACtE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,GAAG,KAAe,EAAmB,EAAE,CACtE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,GAAG,KAAe,EACD,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC","sourcesContent":["import { format } from \"prettier\";\n\nexport const formatCode = async (...lines: string[]): Promise<string> =>\n format(lines.join(\"\\n\"), { parser: \"typescript\" });\n\nexport const formatJson = async (...lines: string[]): Promise<string> =>\n format(lines.join(\"\\n\"), { parser: \"json\" });\n\nexport const formatJsonStringify = async (\n ...lines: string[]\n): Promise<string> => format(lines.join(\"\\n\"), { parser: \"json-stringify\" });\n"]}
|
|
1
|
+
{"version":3,"file":"code.format.js","sourceRoot":"","sources":["../../src/code/code.format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,GAAG,KAAe,EAAmB,EAAE,CACtE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,GAAG,KAAe,EAAmB,EAAE,CACtE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EACtC,GAAG,KAAe,EACD,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC","sourcesContent":["import { format } from \"prettier\";\n\n/**\n * Formats TypeScript code using Prettier.\n *\n * @param lines - One or more code strings that are joined with newlines before formatting.\n * @returns The formatted TypeScript source code.\n */\nexport const formatCode = async (...lines: string[]): Promise<string> =>\n format(lines.join(\"\\n\"), { parser: \"typescript\" });\n\n/**\n * Formats a JSON document using Prettier.\n *\n * @param lines - One or more JSON strings that are joined with newlines before formatting.\n * @returns The formatted JSON string.\n */\nexport const formatJson = async (...lines: string[]): Promise<string> =>\n format(lines.join(\"\\n\"), { parser: \"json\" });\n\n/**\n * Formats a JSON value using Prettier's `json-stringify` parser.\n *\n * @remarks\n * Unlike {@link formatJson}, this uses the `json-stringify` parser which\n * produces output closer to `JSON.stringify` — for example it does not add a\n * trailing newline after the top-level value.\n *\n * @param lines - One or more JSON strings that are joined with newlines before formatting.\n * @returns The formatted JSON string.\n */\nexport const formatJsonStringify = async (\n ...lines: string[]\n): Promise<string> => format(lines.join(\"\\n\"), { parser: \"json-stringify\" });\n"]}
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { exec as execCb } from "node:child_process";
|
|
2
2
|
import { PathLike } from "node:fs";
|
|
3
|
+
/**
|
|
4
|
+
* Promise-based wrapper around {@link exec} from `node:child_process`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const { stdout } = await execAsync("echo hello");
|
|
9
|
+
* console.log(stdout); // "hello\n"
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export declare const execAsync: typeof execCb.__promisify__;
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether a file or directory exists at the given path.
|
|
15
|
+
*
|
|
16
|
+
* @param path - The file-system path to check.
|
|
17
|
+
* @returns `true` if the path points to an existing file or directory, `false` otherwise.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* if (await existsAsync("package.json")) {
|
|
22
|
+
* console.log("found");
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
4
26
|
export declare const existsAsync: (path: PathLike) => Promise<boolean>;
|
|
5
27
|
//# sourceMappingURL=common.fs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.fs.d.ts","sourceRoot":"","sources":["../../src/common/common.fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,eAAO,MAAM,SAAS,6BAAoB,CAAC;AAE3C,eAAO,MAAM,WAAW,GAAU,MAAM,QAAQ,KAAG,OAAO,CAAC,OAAO,CAOjE,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.fs.d.ts","sourceRoot":"","sources":["../../src/common/common.fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,6BAAoB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAU,MAAM,QAAQ,KAAG,OAAO,CAAC,OAAO,CAOjE,CAAC"}
|
package/dist/common/common.fs.js
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
import { exec as execCb } from "node:child_process";
|
|
2
2
|
import { stat } from "node:fs/promises";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
|
+
/**
|
|
5
|
+
* Promise-based wrapper around {@link exec} from `node:child_process`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const { stdout } = await execAsync("echo hello");
|
|
10
|
+
* console.log(stdout); // "hello\n"
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
4
13
|
export const execAsync = promisify(execCb);
|
|
14
|
+
/**
|
|
15
|
+
* Checks whether a file or directory exists at the given path.
|
|
16
|
+
*
|
|
17
|
+
* @param path - The file-system path to check.
|
|
18
|
+
* @returns `true` if the path points to an existing file or directory, `false` otherwise.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* if (await existsAsync("package.json")) {
|
|
23
|
+
* console.log("found");
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
5
27
|
export const existsAsync = async (path) => {
|
|
6
28
|
try {
|
|
7
29
|
const s = await stat(path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.fs.js","sourceRoot":"","sources":["../../src/common/common.fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,IAAc,EAAoB,EAAE;IACpE,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { exec as execCb } from \"node:child_process\";\nimport { PathLike } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\nimport { promisify } from \"node:util\";\n\nexport const execAsync = promisify(execCb);\n\nexport const existsAsync = async (path: PathLike): Promise<boolean> => {\n try {\n const s = await stat(path);\n return s.isFile() || s.isDirectory();\n } catch {\n return false;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"common.fs.js","sourceRoot":"","sources":["../../src/common/common.fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,IAAc,EAAoB,EAAE;IACpE,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { exec as execCb } from \"node:child_process\";\nimport { PathLike } from \"node:fs\";\nimport { stat } from \"node:fs/promises\";\nimport { promisify } from \"node:util\";\n\n/**\n * Promise-based wrapper around {@link exec} from `node:child_process`.\n *\n * @example\n * ```ts\n * const { stdout } = await execAsync(\"echo hello\");\n * console.log(stdout); // \"hello\\n\"\n * ```\n */\nexport const execAsync = promisify(execCb);\n\n/**\n * Checks whether a file or directory exists at the given path.\n *\n * @param path - The file-system path to check.\n * @returns `true` if the path points to an existing file or directory, `false` otherwise.\n *\n * @example\n * ```ts\n * if (await existsAsync(\"package.json\")) {\n * console.log(\"found\");\n * }\n * ```\n */\nexport const existsAsync = async (path: PathLike): Promise<boolean> => {\n try {\n const s = await stat(path);\n return s.isFile() || s.isDirectory();\n } catch {\n return false;\n }\n};\n"]}
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performs a deep-equality comparison of two values.
|
|
3
|
+
*
|
|
4
|
+
* @param a - The first value to compare.
|
|
5
|
+
* @param b - The second value to compare.
|
|
6
|
+
* @returns `true` if `a` and `b` are deeply equal, `false` otherwise.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* jsonEqual({ x: 1 }, { x: 1 }); // true
|
|
11
|
+
* jsonEqual([1, 2], [1, 3]); // false
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
1
14
|
export declare const jsonEqual: <T>(a: T, b: T) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a deep clone of the given value using the structured clone algorithm.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The value to clone.
|
|
19
|
+
* @returns A deep copy of `value`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const original = { nested: { key: "value" } };
|
|
24
|
+
* const copy = jsonClone(original);
|
|
25
|
+
* copy.nested.key = "changed";
|
|
26
|
+
* console.log(original.nested.key); // "value"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
2
29
|
export declare const jsonClone: <T>(value: T) => T;
|
|
30
|
+
export declare enum JsonStringifyFormat {
|
|
31
|
+
json = "json",
|
|
32
|
+
jsonStringify = "jsonStringify"
|
|
33
|
+
}
|
|
34
|
+
export declare const jsonStringify: (content: unknown, format?: JsonStringifyFormat) => Promise<string>;
|
|
35
|
+
export declare const jsonParse: <T>(content: string) => T;
|
|
3
36
|
//# sourceMappingURL=common.json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.json.d.ts","sourceRoot":"","sources":["../../src/common/common.json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.json.d.ts","sourceRoot":"","sources":["../../src/common/common.json.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,KAAG,OAAkC,CAAC;AAE7E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CAA2B,CAAC;AAEpE,oBAAY,mBAAmB;IAC7B,IAAI,SAAS;IACb,aAAa,kBAAkB;CAChC;AAED,eAAO,MAAM,aAAa,GACxB,SAAS,OAAO,EAChB,SAAS,mBAAmB,KAC3B,OAAO,CAAC,MAAM,CAQhB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,SAAS,MAAM,KAAG,CAAyB,CAAC"}
|
|
@@ -1,4 +1,49 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
import json5 from "json5";
|
|
3
|
+
import { formatJson, formatJsonStringify } from "../code/code.format.js";
|
|
4
|
+
/**
|
|
5
|
+
* Performs a deep-equality comparison of two values.
|
|
6
|
+
*
|
|
7
|
+
* @param a - The first value to compare.
|
|
8
|
+
* @param b - The second value to compare.
|
|
9
|
+
* @returns `true` if `a` and `b` are deeply equal, `false` otherwise.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* jsonEqual({ x: 1 }, { x: 1 }); // true
|
|
14
|
+
* jsonEqual([1, 2], [1, 3]); // false
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
2
17
|
export const jsonEqual = (a, b) => isDeepStrictEqual(a, b);
|
|
18
|
+
/**
|
|
19
|
+
* Creates a deep clone of the given value using the structured clone algorithm.
|
|
20
|
+
*
|
|
21
|
+
* @param value - The value to clone.
|
|
22
|
+
* @returns A deep copy of `value`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const original = { nested: { key: "value" } };
|
|
27
|
+
* const copy = jsonClone(original);
|
|
28
|
+
* copy.nested.key = "changed";
|
|
29
|
+
* console.log(original.nested.key); // "value"
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
3
32
|
export const jsonClone = (value) => structuredClone(value);
|
|
33
|
+
export var JsonStringifyFormat;
|
|
34
|
+
(function (JsonStringifyFormat) {
|
|
35
|
+
JsonStringifyFormat["json"] = "json";
|
|
36
|
+
JsonStringifyFormat["jsonStringify"] = "jsonStringify";
|
|
37
|
+
})(JsonStringifyFormat || (JsonStringifyFormat = {}));
|
|
38
|
+
export const jsonStringify = async (content, format) => {
|
|
39
|
+
let result = json5.stringify(content);
|
|
40
|
+
if (format === JsonStringifyFormat.json) {
|
|
41
|
+
result = await formatJson(result);
|
|
42
|
+
}
|
|
43
|
+
else if (format === JsonStringifyFormat.jsonStringify) {
|
|
44
|
+
result = await formatJsonStringify(result);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
export const jsonParse = (content) => json5.parse(content);
|
|
4
49
|
//# sourceMappingURL=common.json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.json.js","sourceRoot":"","sources":["../../src/common/common.json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"common.json.js","sourceRoot":"","sources":["../../src/common/common.json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEzE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,CAAI,EAAE,CAAI,EAAW,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,KAAQ,EAAK,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;AAEpE,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,oCAAa,CAAA;IACb,sDAA+B,CAAA;AACjC,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,OAAgB,EAChB,MAA4B,EACX,EAAE;IACnB,IAAI,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,MAAM,KAAK,mBAAmB,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;SAAM,IAAI,MAAM,KAAK,mBAAmB,CAAC,aAAa,EAAE,CAAC;QACxD,MAAM,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAI,OAAe,EAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import { isDeepStrictEqual } from \"node:util\";\nimport json5 from \"json5\";\nimport { formatJson, formatJsonStringify } from \"../code/code.format.js\";\n\n/**\n * Performs a deep-equality comparison of two values.\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n * @returns `true` if `a` and `b` are deeply equal, `false` otherwise.\n *\n * @example\n * ```ts\n * jsonEqual({ x: 1 }, { x: 1 }); // true\n * jsonEqual([1, 2], [1, 3]); // false\n * ```\n */\nexport const jsonEqual = <T>(a: T, b: T): boolean => isDeepStrictEqual(a, b);\n\n/**\n * Creates a deep clone of the given value using the structured clone algorithm.\n *\n * @param value - The value to clone.\n * @returns A deep copy of `value`.\n *\n * @example\n * ```ts\n * const original = { nested: { key: \"value\" } };\n * const copy = jsonClone(original);\n * copy.nested.key = \"changed\";\n * console.log(original.nested.key); // \"value\"\n * ```\n */\nexport const jsonClone = <T>(value: T): T => structuredClone(value);\n\nexport enum JsonStringifyFormat {\n json = \"json\",\n jsonStringify = \"jsonStringify\",\n}\n\nexport const jsonStringify = async (\n content: unknown,\n format?: JsonStringifyFormat,\n): Promise<string> => {\n let result = json5.stringify(content);\n if (format === JsonStringifyFormat.json) {\n result = await formatJson(result);\n } else if (format === JsonStringifyFormat.jsonStringify) {\n result = await formatJsonStringify(result);\n }\n return result;\n};\n\nexport const jsonParse = <T>(content: string): T => json5.parse(content);\n"]}
|
|
@@ -1,27 +1,159 @@
|
|
|
1
1
|
import { Pkg } from "../pkg/Pkg.js";
|
|
2
2
|
import { DepsProcessMode, DepsReplacementMode, FixWorkspaceDepsData, FixWorkspaceDepsMain, FixWorkspaceDepsParams } from "../types/types.deps.js";
|
|
3
3
|
import { MapEntry } from "../types/types.package.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fix or restore workspace dependency references across all packages.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Initializes the workspace from the given repository root, selects the
|
|
9
|
+
* appropriate replacement strategy ({@link FixWorkspaceDepsVersion} or
|
|
10
|
+
* {@link FixWorkspaceDepsFile}), and executes the full fix/restore run.
|
|
11
|
+
*
|
|
12
|
+
* @param p - Parameters specifying the repo root, processing mode, and replacement strategy.
|
|
13
|
+
* @returns A promise that resolves when all workspace dependencies have been processed and written.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* await runFixDeps({
|
|
18
|
+
* repoRoot: "/path/to/repo",
|
|
19
|
+
* mode: DepsProcessMode.fix,
|
|
20
|
+
* replacement: DepsReplacementMode.version,
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
4
24
|
export declare const runFixDeps: (p: FixWorkspaceDepsParams) => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Create the appropriate {@link IFixWorkspaceDeps} instance for the given replacement mode.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Acts as a factory function that returns a {@link FixWorkspaceDepsVersion}
|
|
30
|
+
* when the replacement mode is `version`, or a {@link FixWorkspaceDepsFile}
|
|
31
|
+
* when it is `file`.
|
|
32
|
+
*
|
|
33
|
+
* @param p - Object containing the processing mode and replacement strategy.
|
|
34
|
+
* @returns A concrete {@link IFixWorkspaceDeps} subclass ready to execute.
|
|
35
|
+
*/
|
|
5
36
|
export declare const instanceFixDeps: (p: {
|
|
6
37
|
mode: DepsProcessMode;
|
|
7
38
|
replacement: DepsReplacementMode;
|
|
8
39
|
}) => FixWorkspaceDepsVersion | FixWorkspaceDepsFile;
|
|
40
|
+
/**
|
|
41
|
+
* Abstract base class for fixing or restoring workspace dependency references.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Implements the template-method pattern: subclasses provide concrete
|
|
45
|
+
* {@link IFixWorkspaceDeps.fixVersion | fixVersion} and
|
|
46
|
+
* {@link IFixWorkspaceDeps.restoreVersion | restoreVersion} implementations
|
|
47
|
+
* while the base class orchestrates reading, processing, and writing all
|
|
48
|
+
* workspace packages.
|
|
49
|
+
*/
|
|
9
50
|
export declare abstract class IFixWorkspaceDeps {
|
|
10
51
|
readonly mode: DepsProcessMode;
|
|
52
|
+
/**
|
|
53
|
+
* Create a new workspace dependency fixer.
|
|
54
|
+
*
|
|
55
|
+
* @param mode - Whether to `fix` (replace `workspace:*`) or `restore` (revert to `workspace:*`).
|
|
56
|
+
*/
|
|
11
57
|
constructor(mode: DepsProcessMode);
|
|
58
|
+
/**
|
|
59
|
+
* Compute the replacement version string when fixing a dependency.
|
|
60
|
+
*
|
|
61
|
+
* @param p - Data about the dependency being processed.
|
|
62
|
+
* @returns The replacement version string, or `null` if no replacement is needed.
|
|
63
|
+
*/
|
|
12
64
|
protected abstract fixVersion(p: FixWorkspaceDepsData): string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Compute the original version string when restoring a dependency.
|
|
67
|
+
*
|
|
68
|
+
* @param p - Data about the dependency being processed.
|
|
69
|
+
* @returns The restored version string, or `null` if no restoration is needed.
|
|
70
|
+
*/
|
|
13
71
|
protected abstract restoreVersion(p: FixWorkspaceDepsData): string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Execute the full fix or restore operation across every workspace package.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* Reads the workspace, builds a version map and map entries, iterates over
|
|
77
|
+
* each package to apply the appropriate transformation, and writes all
|
|
78
|
+
* modified `package.json` files back to disk.
|
|
79
|
+
*
|
|
80
|
+
* @returns A promise that resolves when all packages have been written.
|
|
81
|
+
*/
|
|
14
82
|
run(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Process a single dependency map, replacing matching versions in place.
|
|
85
|
+
*
|
|
86
|
+
* @param deps - The dependency record (e.g. `dependencies`, `devDependencies`) to mutate.
|
|
87
|
+
* @param p - Contextual data for the consuming package and workspace.
|
|
88
|
+
*/
|
|
15
89
|
protected handleDependencies(deps: Record<string, string> | undefined, p: FixWorkspaceDepsMain): void;
|
|
90
|
+
/**
|
|
91
|
+
* Process all dependency groups for a single consuming package.
|
|
92
|
+
*
|
|
93
|
+
* @param p - Contextual data including the consuming package, map entries, and version map.
|
|
94
|
+
*/
|
|
16
95
|
protected runSingle(p: FixWorkspaceDepsMain): void;
|
|
96
|
+
/**
|
|
97
|
+
* Build pairwise mapping entries between all workspace packages.
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* Produces a cartesian product (excluding self-pairs) of packages, computing
|
|
101
|
+
* the relative filesystem path from each source package to every other
|
|
102
|
+
* target package.
|
|
103
|
+
*
|
|
104
|
+
* @param pkgs - The list of workspace packages.
|
|
105
|
+
* @returns An array of {@link MapEntry} objects describing each package-to-package relationship.
|
|
106
|
+
*/
|
|
17
107
|
protected buildMapEntries(pkgs: Pkg[]): MapEntry[];
|
|
18
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Workspace dependency fixer that replaces `workspace:*` with caret version ranges.
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* During a `fix` pass, `workspace:*` is replaced with `^{resolved-version}`.
|
|
114
|
+
* During a `restore` pass, caret-prefixed versions that match the workspace
|
|
115
|
+
* version map are reverted back to `workspace:*`.
|
|
116
|
+
*/
|
|
19
117
|
export declare class FixWorkspaceDepsVersion extends IFixWorkspaceDeps {
|
|
118
|
+
/**
|
|
119
|
+
* Replace a `workspace:*` reference with a caret version range.
|
|
120
|
+
*
|
|
121
|
+
* @param p - Data about the dependency being processed.
|
|
122
|
+
* @returns A string like `^1.2.3`, or `null` if the dependency is not `workspace:*`.
|
|
123
|
+
* @throws Error if the package cannot be found in the workspace version map.
|
|
124
|
+
*/
|
|
20
125
|
protected fixVersion(p: FixWorkspaceDepsData): string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Restore a caret version range back to `workspace:*`.
|
|
128
|
+
*
|
|
129
|
+
* @param p - Data about the dependency being processed.
|
|
130
|
+
* @returns The string `workspace:*` if the version matches the expected caret range, or `null` otherwise.
|
|
131
|
+
*/
|
|
21
132
|
protected restoreVersion(p: FixWorkspaceDepsData): string | null;
|
|
22
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Workspace dependency fixer that replaces `workspace:*` with `file:` protocol paths.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* During a `fix` pass, `workspace:*` is replaced with a relative `file:` path
|
|
139
|
+
* pointing to the dependency's package directory.
|
|
140
|
+
* During a `restore` pass, any `file:`-prefixed version is reverted to `workspace:*`.
|
|
141
|
+
*/
|
|
23
142
|
export declare class FixWorkspaceDepsFile extends IFixWorkspaceDeps {
|
|
143
|
+
/**
|
|
144
|
+
* Replace a `workspace:*` reference with a relative `file:` path.
|
|
145
|
+
*
|
|
146
|
+
* @param p - Data about the dependency being processed.
|
|
147
|
+
* @returns A string like `file:../sibling-pkg`, or `null` if the dependency is not `workspace:*`.
|
|
148
|
+
* @throws Error if no map entry can be found for the dependency.
|
|
149
|
+
*/
|
|
24
150
|
protected fixVersion(p: FixWorkspaceDepsData): string | null;
|
|
151
|
+
/**
|
|
152
|
+
* Restore a `file:` path reference back to `workspace:*`.
|
|
153
|
+
*
|
|
154
|
+
* @param p - Data about the dependency being processed.
|
|
155
|
+
* @returns The string `workspace:*` if the version uses the `file:` protocol, or `null` otherwise.
|
|
156
|
+
*/
|
|
25
157
|
protected restoreVersion(p: FixWorkspaceDepsData): string | null;
|
|
26
158
|
}
|
|
27
159
|
//# sourceMappingURL=FixWorkspaceDeps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FixWorkspaceDeps.d.ts","sourceRoot":"","sources":["../../src/deps/FixWorkspaceDeps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD,eAAO,MAAM,UAAU,GAAU,GAAG,sBAAsB,kBAGzD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,GAAG;IACjC,IAAI,EAAE,eAAe,CAAC;IACtB,WAAW,EAAE,mBAAmB,CAAC;CAClC,mDAGqC,CAAC;AAEvC,8BAAsB,iBAAiB;
|
|
1
|
+
{"version":3,"file":"FixWorkspaceDeps.d.ts","sourceRoot":"","sources":["../../src/deps/FixWorkspaceDeps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC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