@mxpicture/build-api 0.3.10 ā 0.3.16
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/exp/ExportsExtractor.d.ts.map +1 -1
- package/dist/exp/ExportsExtractor.js +7 -1
- package/dist/exp/ExportsExtractor.js.map +1 -1
- package/dist/npmPublish/NpmPublisher.d.ts +2 -1
- package/dist/npmPublish/NpmPublisher.d.ts.map +1 -1
- package/dist/npmPublish/NpmPublisher.js +7 -4
- package/dist/npmPublish/NpmPublisher.js.map +1 -1
- package/dist/types/types.npm.d.ts +3 -1
- package/dist/types/types.npm.d.ts.map +1 -1
- package/dist/types/types.npm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportsExtractor.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAUpD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAU,QAAQ,sBAAsB,
|
|
1
|
+
{"version":3,"file":"ExportsExtractor.d.ts","sourceRoot":"","sources":["../../src/exp/ExportsExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,cAAc,EACd,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAUpD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,GAAU,QAAQ,sBAAsB,kBA+BvE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,qBAAqB,KAC5B,OAAO,CAAC,WAAW,CASrB,CAAC;AAKF;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAQzB,SAAS,CAAC,QAAQ,EAAE,cAAc,EAAE;IACpC,SAAS,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE;IACrC,SAAS,CAAC,cAAc,CAAC,EAAE,qBAAqB;IATlD;;;;;OAKG;gBAES,QAAQ,EAAE,cAAc,EAAE,EAC1B,QAAQ,CAAC,EAAE,cAAc,EAAE,YAAA,EAC3B,cAAc,CAAC,EAAE,qBAAqB,YAAA;IAGlD;;OAEG;IACU,GAAG,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;CAsB1C"}
|
|
@@ -17,7 +17,13 @@ import { resolvePackageRoot } from "./exports.package.js";
|
|
|
17
17
|
* path, and optional additional file paths.
|
|
18
18
|
*/
|
|
19
19
|
export const runExportsExtractor = async (params) => {
|
|
20
|
-
const
|
|
20
|
+
const filePaths = params.filePaths ?? [];
|
|
21
|
+
const filePath = filePaths.length > 0 ? filePaths[0] : undefined;
|
|
22
|
+
const firstFile = await getPackagesFile({
|
|
23
|
+
repoRoot: params.repoRoot,
|
|
24
|
+
filePath,
|
|
25
|
+
filterPackages: params.filterPackages,
|
|
26
|
+
});
|
|
21
27
|
const otherFiles = [];
|
|
22
28
|
const commonExcludes = {
|
|
23
29
|
excludePackageJson: !!params.excludePackageJson,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportsExtractor.js","sourceRoot":"","sources":["../../src/exp/ExportsExtractor.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GA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EACb,IAAI,CAAC,cAAc,CACpB,CAAC,GAAG,EAAE,CACR,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type {\n ExportsCommonExcludes,\n ExportsExtractorParams,\n ExportsPackagesParams,\n ExportsPattern,\n PackageAPI,\n} from \"../types/types.exports.js\";\nimport type { ExportsContent } from \"./ExportsContent.js\";\nimport type { ExportsFile } from \"./ExportsFile.js\";\nimport { exportsFileByPkgs } from \"./ExportsFile.js\";\nimport { initWsAndRead } from \"../workspace/Workspace.js\";\nimport { join } from \"node:path\";\nimport { cwd } from \"node:process\";\nimport { createSourceFileMap } from \"../code/code.common.js\";\nimport { ExportsExtractorItem } from \"./ExportsExtractorItem.js\";\nimport { readDTsFilePaths } from \"./exports.file.js\";\nimport { resolvePackageRoot } from \"./exports.package.js\";\n\n/**\n * Run the full exports extraction pipeline.\n *\n * @remarks\n * Loads workspace packages, extracts `.d.ts` exports for every package,\n * then writes the results to one or more output files.\n *\n * @param params - Extraction parameters including repo root, output file\n * path, and optional additional file paths.\n */\nexport const runExportsExtractor = async (params: ExportsExtractorParams) => {\n const filePaths = params.filePaths ?? [];\n const filePath = filePaths.length > 0 ? filePaths[0] : undefined;\n\n const firstFile = await getPackagesFile({\n repoRoot: params.repoRoot,\n filePath,\n filterPackages: params.filterPackages,\n });\n\n const otherFiles: ExportsFile[] = [];\n\n const commonExcludes: Required<ExportsCommonExcludes> = {\n excludePackageJson: !!params.excludePackageJson,\n excludeKnownDuplicates: !!params.excludeKnownDuplicates,\n };\n\n const extr = new ExportsExtractor(\n firstFile.contents,\n undefined,\n commonExcludes,\n );\n await extr.run();\n\n for (const _filePath of params.filePaths ?? []) {\n const filePath = ensureFilePath(_filePath);\n if (filePath === firstFile.filePath) continue;\n otherFiles.push(firstFile.link(filePath));\n }\n\n await Promise.all([firstFile.write(), ...otherFiles.map((f) => f.write())]);\n};\n\n/**\n * Build an {@link ExportsFile} from workspace packages.\n *\n * @param params - Parameters including repo root, output file path, and\n * an optional `filterPackages` array to limit which packages are included.\n * @returns A promise resolving to the populated {@link ExportsFile}.\n */\nexport const getPackagesFile = async (\n params: ExportsPackagesParams,\n): Promise<ExportsFile> => {\n let pkgs = (await initWsAndRead(params.repoRoot)).packages;\n\n const filterPackages = params.filterPackages;\n if (filterPackages && filterPackages.length > 0)\n pkgs = pkgs.filter((pkg) => filterPackages.includes(pkg.content.name));\n\n const filePath = ensureFilePath(params.filePath);\n return exportsFileByPkgs(filePath, pkgs);\n};\n\nconst ensureFilePath = (filePath?: string | null) =>\n filePath ?? join(cwd(), \"exports.gen.json\");\n\n/**\n * Orchestrates export extraction across multiple packages.\n *\n * @remarks\n * Resolves `.d.ts` declaration files for each package root, builds a\n * shared TypeScript source-file map, then delegates per-package\n * extraction to {@link ExportsExtractorItem}.\n */\nexport class ExportsExtractor {\n /**\n * Analyze an installed package and produce\n * a structured API representation.\n *\n * @param pkg package name\n */\n public constructor(\n protected contents: ExportsContent[],\n protected excludes?: ExportsPattern[],\n protected commonExcludes?: ExportsCommonExcludes,\n ) {}\n\n /**\n * Analyze an installed package and build its API model.\n */\n public async run(): Promise<PackageAPI[]> {\n if (this.contents.length === 0) return [];\n\n const roots = this.contents.map((content) =>\n resolvePackageRoot(content.pkg.packageName),\n );\n const first: string = roots.shift()!;\n const filePaths = await readDTsFilePaths(first, ...roots);\n\n const srcMap = createSourceFileMap(filePaths);\n\n return Promise.all(\n this.contents.map((content) =>\n new ExportsExtractorItem(\n content,\n srcMap,\n this.excludes,\n this.commonExcludes,\n ).run(),\n ),\n );\n }\n}\n"]}
|
|
@@ -27,8 +27,9 @@ export declare const runNpmPublisher: (params: NpmPublisherParams) => Promise<vo
|
|
|
27
27
|
* exact version is already on the registry are silently skipped.
|
|
28
28
|
*/
|
|
29
29
|
export declare class NpmPublisher {
|
|
30
|
+
readonly npmCli: string;
|
|
30
31
|
/** Creates a new {@link NpmPublisher} instance. */
|
|
31
|
-
constructor();
|
|
32
|
+
constructor(npmCli?: string);
|
|
32
33
|
/**
|
|
33
34
|
* Publishes all non-private workspace packages.
|
|
34
35
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NpmPublisher.d.ts","sourceRoot":"","sources":["../../src/npmPublish/NpmPublisher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAAU,QAAQ,kBAAkB,kBAG/D,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"NpmPublisher.d.ts","sourceRoot":"","sources":["../../src/npmPublish/NpmPublisher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAAU,QAAQ,kBAAkB,kBAG/D,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,YAAY;aAEY,MAAM,EAAE,MAAM;IADjD,mDAAmD;gBAChB,MAAM,GAAE,MAAc;IAEzD;;;;;;;;;OASG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;cAiBjB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAoCpD"}
|
|
@@ -19,7 +19,7 @@ import { initWorkspace, workspace } from "../workspace/Workspace.js";
|
|
|
19
19
|
*/
|
|
20
20
|
export const runNpmPublisher = async (params) => {
|
|
21
21
|
initWorkspace(params.repoRoot);
|
|
22
|
-
return new NpmPublisher().run();
|
|
22
|
+
return new NpmPublisher(params.useCorepack ? "corepack npm" : "npm").run();
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* Publishes workspace packages to the npm registry.
|
|
@@ -31,8 +31,11 @@ export const runNpmPublisher = async (params) => {
|
|
|
31
31
|
* exact version is already on the registry are silently skipped.
|
|
32
32
|
*/
|
|
33
33
|
export class NpmPublisher {
|
|
34
|
+
npmCli;
|
|
34
35
|
/** Creates a new {@link NpmPublisher} instance. */
|
|
35
|
-
constructor() {
|
|
36
|
+
constructor(npmCli = "npm") {
|
|
37
|
+
this.npmCli = npmCli;
|
|
38
|
+
}
|
|
36
39
|
/**
|
|
37
40
|
* Publishes all non-private workspace packages.
|
|
38
41
|
*
|
|
@@ -62,7 +65,7 @@ export class NpmPublisher {
|
|
|
62
65
|
logInfo(`š¦ Publishing ${name}@${version} ... (${new Date().toISOString()})`);
|
|
63
66
|
// Check if this exact version is already published
|
|
64
67
|
try {
|
|
65
|
-
const { stdout } = await execAsync(
|
|
68
|
+
const { stdout } = await execAsync(`${this.npmCli} view ${name}@${version} version`);
|
|
66
69
|
const published = stdout.trim();
|
|
67
70
|
if (published === version) {
|
|
68
71
|
logInfo(`āļø ${name}@${version} already published, skipping.`);
|
|
@@ -73,7 +76,7 @@ export class NpmPublisher {
|
|
|
73
76
|
// npm view exits non-zero if the package/version doesn't exist ā means we should publish
|
|
74
77
|
}
|
|
75
78
|
try {
|
|
76
|
-
await execAsync(
|
|
79
|
+
await execAsync(`${this.npmCli} publish --access public`, {
|
|
77
80
|
cwd: pkg.dirPath,
|
|
78
81
|
});
|
|
79
82
|
logSuccess(`ā
${name}@${version} published successfully (${new Date().toISOString()}).`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NpmPublisher.js","sourceRoot":"","sources":["../../src/npmPublish/NpmPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;A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AI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,CAC7E,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,qBAAqB,IAAI,IAAI,OAAO,KAAK,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC;YAC1F,QAAQ,CAAC,KAAK,YAAY,EAAE,CAAC,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { logError, logInfo, logSuccess } from \"../logger/Logger.js\";\nimport { execAsync } from \"../common/common.fs.js\";\nimport type { NpmPublisherParams } from \"../types/types.npm.js\";\nimport type { Pkg } from \"../pkg/Pkg.js\";\nimport { initWorkspace, workspace } from \"../workspace/Workspace.js\";\n\n/**\n * Publishes all non-private workspace packages to the npm registry.\n *\n * @remarks\n * Initialises the workspace from the given repository root, then delegates\n * to {@link NpmPublisher.run} which publishes every public package in\n * parallel. Already-published versions are automatically skipped.\n *\n * @param params - Publisher parameters containing the repository root path.\n * @returns A promise that resolves when all packages have been processed.\n *\n * @example\n * ```ts\n * await runNpmPublisher({ repoRoot: \"/path/to/repo\" });\n * ```\n */\nexport const runNpmPublisher = async (params: NpmPublisherParams) => {\n initWorkspace(params.repoRoot);\n return new NpmPublisher(params.useCorepack ? \"corepack npm\" : \"npm\").run();\n};\n\n/**\n * Publishes workspace packages to the npm registry.\n *\n * @remarks\n * Reads every package from the current workspace, attempts to publish each\n * non-private package in parallel via `npm publish --access public`, and\n * exits the process with code 1 if any publication fails. Packages whose\n * exact version is already on the registry are silently skipped.\n */\nexport class NpmPublisher {\n /** Creates a new {@link NpmPublisher} instance. */\n public constructor(public readonly npmCli: string = \"npm\") {}\n\n /**\n * Publishes all non-private workspace packages.\n *\n * @remarks\n * Each package is published concurrently using `Promise.allSettled`.\n * If one or more packages fail, the errors are logged and the process\n * exits with code 1.\n *\n * @returns A promise that resolves when all publish attempts have settled.\n */\n public async run(): Promise<void> {\n const pkgs = (await workspace().read()).packages;\n\n const results = await Promise.allSettled(\n pkgs.map((d) => this.runPackage(d)),\n );\n\n const failures = results.filter((r) => r.status === \"rejected\");\n if (failures.length > 0) {\n logError(`\\nā ${failures.length} package(s) failed to publish:`);\n failures.forEach((failure) => {\n logError(failure.reason);\n });\n process.exit(1);\n }\n }\n\n protected async runPackage(pkg: Pkg): Promise<void> {\n if (pkg.content.private) return;\n const { name, version } = pkg.content;\n\n logInfo(\n `š¦ Publishing ${name}@${version} ... (${new Date().toISOString()})`,\n );\n\n // Check if this exact version is already published\n try {\n const { stdout } = await execAsync(\n `${this.npmCli} view ${name}@${version} version`,\n );\n const published = stdout.trim();\n\n if (published === version) {\n logInfo(`āļø ${name}@${version} already published, skipping.`);\n return;\n }\n } catch {\n // npm view exits non-zero if the package/version doesn't exist ā means we should publish\n }\n\n try {\n await execAsync(`${this.npmCli} publish --access public`, {\n cwd: pkg.dirPath,\n });\n logSuccess(\n `ā
${name}@${version} published successfully (${new Date().toISOString()}).`,\n );\n } catch (err) {\n const errorMessage = `Failed to publish ${name}@${version} (${new Date().toISOString()})`;\n logError(`ā ${errorMessage}`);\n throw new Error(errorMessage, { cause: err });\n }\n }\n}\n"]}
|
|
@@ -6,5 +6,7 @@ import type { RunRepoRootParams } from "./types.run.js";
|
|
|
6
6
|
* Currently an alias for {@link RunRepoRootParams}; extend this type
|
|
7
7
|
* to add publisher-specific options in the future.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export interface NpmPublisherParams extends RunRepoRootParams {
|
|
10
|
+
useCorepack?: boolean;
|
|
11
|
+
}
|
|
10
12
|
//# sourceMappingURL=types.npm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.npm.d.ts","sourceRoot":"","sources":["../../src/types/types.npm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"types.npm.d.ts","sourceRoot":"","sources":["../../src/types/types.npm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.npm.js","sourceRoot":"","sources":["../../src/types/types.npm.ts"],"names":[],"mappings":"","sourcesContent":["import type { RunRepoRootParams } from \"./types.run.js\";\n\n/**\n * Parameters for the npm package publisher.\n *\n * @remarks\n * Currently an alias for {@link RunRepoRootParams}; extend this type\n * to add publisher-specific options in the future.\n */\nexport
|
|
1
|
+
{"version":3,"file":"types.npm.js","sourceRoot":"","sources":["../../src/types/types.npm.ts"],"names":[],"mappings":"","sourcesContent":["import type { RunRepoRootParams } from \"./types.run.js\";\n\n/**\n * Parameters for the npm package publisher.\n *\n * @remarks\n * Currently an alias for {@link RunRepoRootParams}; extend this type\n * to add publisher-specific options in the future.\n */\nexport interface NpmPublisherParams extends RunRepoRootParams {\n useCorepack?: boolean;\n}\n"]}
|