@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":"UpdatePackages.d.ts","sourceRoot":"","sources":["../../src/pkg/UpdatePackages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,oBA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AAC,IAAI,CAAC;CAgDhD"}
|
|
@@ -2,17 +2,53 @@ import { logInfo, logSuccess } from "../logger/Logger.js";
|
|
|
2
2
|
import { execAsync } from "../common/common.fs.js";
|
|
3
3
|
import micromatch from "micromatch";
|
|
4
4
|
import { initWorkspace, workspace } from "../workspace/Workspace.js";
|
|
5
|
+
/**
|
|
6
|
+
* Initializes the workspace and runs the package-update workflow.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This is a convenience entry point that constructs an {@link UpdatePackages} instance
|
|
10
|
+
* and immediately invokes its {@link UpdatePackages.run} method.
|
|
11
|
+
*
|
|
12
|
+
* @param params - Configuration for the update, including the repo root and a glob pattern to select packages.
|
|
13
|
+
* @returns A promise that resolves when all matching packages have been updated and verified.
|
|
14
|
+
*/
|
|
5
15
|
export const runUpdatePackages = async (params) => {
|
|
6
16
|
initWorkspace(params.repoRoot);
|
|
7
17
|
return new UpdatePackages(params.pattern).run();
|
|
8
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Bulk-updates dependencies matching a glob pattern across all workspace packages.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The update pipeline performs five sequential steps:
|
|
24
|
+
* 1. Discover matching dependencies across every workspace package.
|
|
25
|
+
* 2. Run `pnpm update -r --latest` for the matched packages.
|
|
26
|
+
* 3. Deduplicate the dependency tree with `pnpm dedupe`.
|
|
27
|
+
* 4. Remove stale duplicate versions from `node_modules/.pnpm`.
|
|
28
|
+
* 5. Verify that all workspaces converge on the same version for each package.
|
|
29
|
+
*/
|
|
9
30
|
export class UpdatePackages {
|
|
10
31
|
pattern;
|
|
11
32
|
patternWoSlash;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new UpdatePackages instance.
|
|
35
|
+
*
|
|
36
|
+
* @param pattern - A glob pattern used to match dependency names (e.g. `"@angular/*"`).
|
|
37
|
+
*/
|
|
12
38
|
constructor(pattern) {
|
|
13
39
|
this.pattern = pattern;
|
|
14
40
|
this.patternWoSlash = pattern.replaceAll("/", "+");
|
|
15
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Executes the full package-update pipeline.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Discovers matching packages, updates them, deduplicates, cleans old versions,
|
|
47
|
+
* and verifies consistency. Exits the process with code 1 if version
|
|
48
|
+
* inconsistencies are detected after the update.
|
|
49
|
+
*
|
|
50
|
+
* @returns A promise that resolves when the pipeline completes successfully.
|
|
51
|
+
*/
|
|
16
52
|
async run() {
|
|
17
53
|
logInfo(`🚀 Starting ${this.pattern} packages update process...\n`);
|
|
18
54
|
// Step 1: Find all packages
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdatePackages.js","sourceRoot":"","sources":["../../src/pkg/UpdatePackages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAA4B,EAAE,EAAE;IACtE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,OAAO,cAAc;IAGa;IAF5B,cAAc,CAAS;IAEjC,YAAsC,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QACnD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,GAAG;QACd,OAAO,CAAC,eAAe,IAAI,CAAC,OAAO,+BAA+B,CAAC,CAAC;QAEpE,4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GAAG,CAAE,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAG,IAAY,CAAC,OAAO,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC;YACzC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAClD,IAAI,cAAc,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;gBAC7B,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAClD,SAAS;YACX,CAAC;YAED,OAAO,CAAC,+BAA+B,GAAG,GAAG,CAAC,CAAC;YAC/C,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,QAAQ;gBACzC,OAAO,CAAC,QAAQ,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;YAE3C,aAAa,GAAG,KAAK,CAAC;QACxB,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CACX,uEAAuE,CACxE,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,iCAAiC,CAAC,CAAC;QACnE,OAAO,CACL,+EAA+E,CAChF,CAAC;QACF,OAAO,CAAC,oDAAoD,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import { PackageJson, UpdatePackagesParams } from \"../types/types.package.js\";\nimport { logInfo, logSuccess } from \"../logger/Logger.js\";\nimport { execAsync } from \"../common/common.fs.js\";\nimport micromatch from \"micromatch\";\nimport { initWorkspace, workspace } from \"../workspace/Workspace.js\";\n\nexport const runUpdatePackages = async (params: UpdatePackagesParams) => {\n initWorkspace(params.repoRoot);\n return new UpdatePackages(params.pattern).run();\n};\n\nexport class UpdatePackages {\n protected patternWoSlash: string;\n\n public constructor(protected readonly pattern: string) {\n this.patternWoSlash = pattern.replaceAll(\"/\", \"+\");\n }\n\n public async run(): Promise<void> {\n logInfo(`🚀 Starting ${this.pattern} packages update process...\\n`);\n\n // Step 1: Find all packages\n const packages = await this.getPackages();\n logInfo(`📦 Found ${this.pattern} packages:`);\n for (const pkg of packages) logInfo(` - ${pkg}`);\n\n if (packages.size === 0)\n return logSuccess(`✅ No ${this.pattern} packages found.`);\n\n // Step 2: Update packages in all workspaces recursively\n await this.updatePackages(packages);\n\n // Step 3: Deduplicate dependencies\n await this.deduplicate();\n\n // Step 4: Remove old versions from node_modules\n await this.rmOldVersions();\n\n // Step 5: Verify all packages are at the same version\n await this.verifyPackages();\n }\n\n protected async exec(command: string): Promise<string> {\n console.log(`\\n▶ ${command}`);\n try {\n return (\n await execAsync(command, {\n cwd: workspace().repoRoot,\n encoding: \"utf-8\",\n })\n ).stdout;\n } catch (error) {\n console.error(`Error executing: ${command}`);\n throw error;\n }\n }\n\n protected async getPackages(): Promise<Set<string>> {\n const ws = workspace();\n await ws.read();\n const pkgs = [...ws.packages, ws.rootPackage];\n const packageNames: string[] = (\n await Promise.all(this.filterPackages(pkgs.map((p) => p.content)))\n ).flat();\n\n return new Set<string>(packageNames);\n }\n\n protected filterPackages(wsPackages: PackageJson[]): Promise<string[]>[] {\n return wsPackages.flatMap((wsPackage) => this.filterPackage(wsPackage));\n }\n\n protected filterPackage(wsPackage: PackageJson): Promise<string[]>[] {\n return [\n this.filterPackageDep(wsPackage.dependencies),\n this.filterPackageDep(wsPackage.devDependencies),\n ];\n }\n\n protected async filterPackageDep(\n deps: Record<string, string> | undefined,\n ): Promise<string[]> {\n return Promise.resolve(\n Object.keys(deps ?? []).filter((depName) =>\n micromatch.isMatch(depName, this.pattern),\n ),\n );\n }\n\n protected async updatePackages(packages: Set<string>): Promise<void> {\n logInfo(\"\\n📥 Updating packages across all workspaces...\");\n const packageList = Array.from(packages).join(\" \");\n await this.exec(`pnpm update -r --latest ${packageList}`);\n }\n\n protected async deduplicate(): Promise<void> {\n logInfo(\"\\n🔧 Deduplicating dependencies...\");\n await this.exec(\"pnpm dedupe\");\n }\n\n protected async rmOldVersions(): Promise<void> {\n logInfo(\"\\n🧹 Checking for old versions...\");\n const oldVersions = await this.exec(\n `find node_modules/.pnpm -type d -name \"${this.patternWoSlash}\" -depth 1 2>/dev/null || true`,\n );\n const versionDirs = oldVersions.trim().split(\"\\n\").filter(Boolean);\n\n // Group by package name to identify duplicates\n const packageVersions = new Map<string, string[]>();\n for (const dir of versionDirs) {\n const match = dir.match(/\\/(@?[a-z-+]+)@(.+)$/);\n if (!match) continue;\n const [, pkgName, version] = match;\n if (!micromatch.isMatch(pkgName, this.patternWoSlash)) continue;\n const key = pkgName.replace(/\\+/g, \"/\");\n if (!packageVersions.has(key)) packageVersions.set(key, []);\n packageVersions.get(key)!.push(version.split(\"_\")[0]); // Remove peer dep suffixes\n }\n\n // Check for duplicates\n let hasDuplicates = false;\n for (const [pkg, versions] of packageVersions) {\n const uniqueVersions = [...new Set(versions)];\n if (uniqueVersions.length <= 1) continue;\n logInfo(\n `⚠️ Multiple versions found for ${pkg}:`,\n uniqueVersions.join(\", \"),\n );\n hasDuplicates = true;\n }\n\n if (hasDuplicates) {\n logInfo(\"\\n🔨 Reinstalling to remove duplicate versions...\");\n logInfo(\" This ensures TypeScript loads the correct types.\");\n await this.exec(\"mv node_modules node_modules_tmp\");\n await Promise.all([\n this.exec(\"rm -rf node_modules_tmp\"),\n this.exec(\"pnpm install\"),\n ]);\n }\n }\n\n protected async verifyPackages(): Promise<void> {\n logSuccess(\"\\n✅ Verifying package versions...\");\n const listOutput = await this.exec(\n `pnpm list ${this.pattern} --depth=0 -r --json`,\n );\n const workspaces = JSON.parse(listOutput);\n\n const versionMap = new Map<string, Map<string, string>>();\n\n for (const workspace of workspaces) {\n const deps = workspace.dependencies ?? {};\n for (const [pkg, info] of Object.entries(deps)) {\n if (micromatch.isMatch(pkg, this.pattern)) {\n if (!versionMap.has(pkg)) versionMap.set(pkg, new Map());\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n versionMap.get(pkg)!.set(workspace.name, (info as any).version);\n }\n }\n }\n\n let allConsistent = true;\n for (const [pkg, versions] of versionMap) {\n const uniqueVersions = new Set(versions.values());\n if (uniqueVersions.size <= 1) {\n logSuccess(`✅ ${pkg}: ${[...uniqueVersions][0]}`);\n continue;\n }\n\n logInfo(`❌ Inconsistent versions for ${pkg}:`);\n for (const [workspace, version] of versions)\n logInfo(` - ${workspace}: ${version}`);\n\n allConsistent = false;\n }\n\n if (!allConsistent) {\n console.error(\n \"\\n❌ Version inconsistencies detected! Please review and fix manually.\",\n );\n process.exit(1);\n }\n\n logInfo(`\\n🎉 All ${this.pattern} packages updated successfully!`);\n logInfo(\n \"\\n💡 Tip: Restart your TypeScript server in VS Code to pick up the new types.\",\n );\n logInfo(' - Cmd+Shift+P → \"TypeScript: Restart TS Server\"');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UpdatePackages.js","sourceRoot":"","sources":["../../src/pkg/UpdatePackages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAErE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAA4B,EAAE,EAAE;IACtE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;AAClD,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,OAA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EAA+E,CAChF,CAAC;QACF,OAAO,CAAC,oDAAoD,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import { PackageJson, UpdatePackagesParams } from \"../types/types.package.js\";\nimport { logInfo, logSuccess } from \"../logger/Logger.js\";\nimport { execAsync } from \"../common/common.fs.js\";\nimport micromatch from \"micromatch\";\nimport { initWorkspace, workspace } from \"../workspace/Workspace.js\";\n\n/**\n * Initializes the workspace and runs the package-update workflow.\n *\n * @remarks\n * This is a convenience entry point that constructs an {@link UpdatePackages} instance\n * and immediately invokes its {@link UpdatePackages.run} method.\n *\n * @param params - Configuration for the update, including the repo root and a glob pattern to select packages.\n * @returns A promise that resolves when all matching packages have been updated and verified.\n */\nexport const runUpdatePackages = async (params: UpdatePackagesParams) => {\n initWorkspace(params.repoRoot);\n return new UpdatePackages(params.pattern).run();\n};\n\n/**\n * Bulk-updates dependencies matching a glob pattern across all workspace packages.\n *\n * @remarks\n * The update pipeline performs five sequential steps:\n * 1. Discover matching dependencies across every workspace package.\n * 2. Run `pnpm update -r --latest` for the matched packages.\n * 3. Deduplicate the dependency tree with `pnpm dedupe`.\n * 4. Remove stale duplicate versions from `node_modules/.pnpm`.\n * 5. Verify that all workspaces converge on the same version for each package.\n */\nexport class UpdatePackages {\n protected patternWoSlash: string;\n\n /**\n * Creates a new UpdatePackages instance.\n *\n * @param pattern - A glob pattern used to match dependency names (e.g. `\"@angular/*\"`).\n */\n public constructor(protected readonly pattern: string) {\n this.patternWoSlash = pattern.replaceAll(\"/\", \"+\");\n }\n\n /**\n * Executes the full package-update pipeline.\n *\n * @remarks\n * Discovers matching packages, updates them, deduplicates, cleans old versions,\n * and verifies consistency. Exits the process with code 1 if version\n * inconsistencies are detected after the update.\n *\n * @returns A promise that resolves when the pipeline completes successfully.\n */\n public async run(): Promise<void> {\n logInfo(`🚀 Starting ${this.pattern} packages update process...\\n`);\n\n // Step 1: Find all packages\n const packages = await this.getPackages();\n logInfo(`📦 Found ${this.pattern} packages:`);\n for (const pkg of packages) logInfo(` - ${pkg}`);\n\n if (packages.size === 0)\n return logSuccess(`✅ No ${this.pattern} packages found.`);\n\n // Step 2: Update packages in all workspaces recursively\n await this.updatePackages(packages);\n\n // Step 3: Deduplicate dependencies\n await this.deduplicate();\n\n // Step 4: Remove old versions from node_modules\n await this.rmOldVersions();\n\n // Step 5: Verify all packages are at the same version\n await this.verifyPackages();\n }\n\n protected async exec(command: string): Promise<string> {\n console.log(`\\n▶ ${command}`);\n try {\n return (\n await execAsync(command, {\n cwd: workspace().repoRoot,\n encoding: \"utf-8\",\n })\n ).stdout;\n } catch (error) {\n console.error(`Error executing: ${command}`);\n throw error;\n }\n }\n\n protected async getPackages(): Promise<Set<string>> {\n const ws = workspace();\n await ws.read();\n const pkgs = [...ws.packages, ws.rootPackage];\n const packageNames: string[] = (\n await Promise.all(this.filterPackages(pkgs.map((p) => p.content)))\n ).flat();\n\n return new Set<string>(packageNames);\n }\n\n protected filterPackages(wsPackages: PackageJson[]): Promise<string[]>[] {\n return wsPackages.flatMap((wsPackage) => this.filterPackage(wsPackage));\n }\n\n protected filterPackage(wsPackage: PackageJson): Promise<string[]>[] {\n return [\n this.filterPackageDep(wsPackage.dependencies),\n this.filterPackageDep(wsPackage.devDependencies),\n ];\n }\n\n protected async filterPackageDep(\n deps: Record<string, string> | undefined,\n ): Promise<string[]> {\n return Promise.resolve(\n Object.keys(deps ?? []).filter((depName) =>\n micromatch.isMatch(depName, this.pattern),\n ),\n );\n }\n\n protected async updatePackages(packages: Set<string>): Promise<void> {\n logInfo(\"\\n📥 Updating packages across all workspaces...\");\n const packageList = Array.from(packages).join(\" \");\n await this.exec(`pnpm update -r --latest ${packageList}`);\n }\n\n protected async deduplicate(): Promise<void> {\n logInfo(\"\\n🔧 Deduplicating dependencies...\");\n await this.exec(\"pnpm dedupe\");\n }\n\n protected async rmOldVersions(): Promise<void> {\n logInfo(\"\\n🧹 Checking for old versions...\");\n const oldVersions = await this.exec(\n `find node_modules/.pnpm -type d -name \"${this.patternWoSlash}\" -depth 1 2>/dev/null || true`,\n );\n const versionDirs = oldVersions.trim().split(\"\\n\").filter(Boolean);\n\n // Group by package name to identify duplicates\n const packageVersions = new Map<string, string[]>();\n for (const dir of versionDirs) {\n const match = dir.match(/\\/(@?[a-z-+]+)@(.+)$/);\n if (!match) continue;\n const [, pkgName, version] = match;\n if (!micromatch.isMatch(pkgName, this.patternWoSlash)) continue;\n const key = pkgName.replace(/\\+/g, \"/\");\n if (!packageVersions.has(key)) packageVersions.set(key, []);\n packageVersions.get(key)!.push(version.split(\"_\")[0]); // Remove peer dep suffixes\n }\n\n // Check for duplicates\n let hasDuplicates = false;\n for (const [pkg, versions] of packageVersions) {\n const uniqueVersions = [...new Set(versions)];\n if (uniqueVersions.length <= 1) continue;\n logInfo(\n `⚠️ Multiple versions found for ${pkg}:`,\n uniqueVersions.join(\", \"),\n );\n hasDuplicates = true;\n }\n\n if (hasDuplicates) {\n logInfo(\"\\n🔨 Reinstalling to remove duplicate versions...\");\n logInfo(\" This ensures TypeScript loads the correct types.\");\n await this.exec(\"mv node_modules node_modules_tmp\");\n await Promise.all([\n this.exec(\"rm -rf node_modules_tmp\"),\n this.exec(\"pnpm install\"),\n ]);\n }\n }\n\n protected async verifyPackages(): Promise<void> {\n logSuccess(\"\\n✅ Verifying package versions...\");\n const listOutput = await this.exec(\n `pnpm list ${this.pattern} --depth=0 -r --json`,\n );\n const workspaces = JSON.parse(listOutput);\n\n const versionMap = new Map<string, Map<string, string>>();\n\n for (const workspace of workspaces) {\n const deps = workspace.dependencies ?? {};\n for (const [pkg, info] of Object.entries(deps)) {\n if (micromatch.isMatch(pkg, this.pattern)) {\n if (!versionMap.has(pkg)) versionMap.set(pkg, new Map());\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n versionMap.get(pkg)!.set(workspace.name, (info as any).version);\n }\n }\n }\n\n let allConsistent = true;\n for (const [pkg, versions] of versionMap) {\n const uniqueVersions = new Set(versions.values());\n if (uniqueVersions.size <= 1) {\n logSuccess(`✅ ${pkg}: ${[...uniqueVersions][0]}`);\n continue;\n }\n\n logInfo(`❌ Inconsistent versions for ${pkg}:`);\n for (const [workspace, version] of versions)\n logInfo(` - ${workspace}: ${version}`);\n\n allConsistent = false;\n }\n\n if (!allConsistent) {\n console.error(\n \"\\n❌ Version inconsistencies detected! Please review and fix manually.\",\n );\n process.exit(1);\n }\n\n logInfo(`\\n🎉 All ${this.pattern} packages updated successfully!`);\n logInfo(\n \"\\n💡 Tip: Restart your TypeScript server in VS Code to pick up the new types.\",\n );\n logInfo(' - Cmd+Shift+P → \"TypeScript: Restart TS Server\"');\n }\n}\n"]}
|
package/dist/pkg/index.d.ts
CHANGED
package/dist/pkg/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pkg/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pkg/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
package/dist/pkg/index.js
CHANGED
package/dist/pkg/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pkg/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC","sourcesContent":["// This file is auto-generated for build-cli. Do not edit manually.\nexport * from \"./Pkg.js\";\nexport * from \"./SyncPkgVersion.js\";\nexport * from \"./UpdatePackages.js\";\nexport * from \"./pkg.common.js\";\nexport * from \"./pkg.fs.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pkg/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC","sourcesContent":["// This file is auto-generated for build-cli. Do not edit manually.\nexport * from \"./ExportExtractor.js\";\nexport * from \"./Pkg.js\";\nexport * from \"./SyncPkgVersion.js\";\nexport * from \"./UpdatePackages.js\";\nexport * from \"./pkg.common.js\";\nexport * from \"./pkg.fs.js\";\n"]}
|
package/dist/pkg/pkg.common.d.ts
CHANGED
|
@@ -1,7 +1,80 @@
|
|
|
1
1
|
import { BumpParams, PackageVersion } from "../types/types.package.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a semver version string into its constituent parts.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Accepts versions with or without a `v` prefix (e.g. `"v1.2.3"` or `"1.2.3"`).
|
|
7
|
+
* Throws if any of the major, minor, or patch segments are not valid numbers.
|
|
8
|
+
*
|
|
9
|
+
* @param version - A semver version string such as `"1.2.3"` or `"v1.2.3"`.
|
|
10
|
+
* @returns A {@link PackageVersion} object with numeric `major`, `minor`, `patch` and an optional `prefix`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* splitVersion("v1.2.3"); // { major: 1, minor: 2, patch: 3, prefix: "v" }
|
|
15
|
+
* splitVersion("0.5.10"); // { major: 0, minor: 5, patch: 10, prefix: null }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
2
18
|
export declare const splitVersion: (version: string) => PackageVersion;
|
|
19
|
+
/**
|
|
20
|
+
* Concatenates a {@link PackageVersion} object back into a version string.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Includes the prefix (e.g. `"v"`) when present. Minor and patch segments are
|
|
24
|
+
* only appended when they are truthy (non-zero).
|
|
25
|
+
*
|
|
26
|
+
* @param version - The parsed version object to concatenate.
|
|
27
|
+
* @returns The formatted version string, e.g. `"v1.2.3"` or `"1.0"`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* concatVersion({ major: 1, minor: 2, patch: 3, prefix: "v" }); // "v1.2.3"
|
|
32
|
+
* concatVersion({ major: 2, minor: 0, patch: 0, prefix: null }); // "2"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
3
35
|
export declare const concatVersion: (version: PackageVersion) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Compares two semantic versions numerically.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* Accepts either a version string or a {@link PackageVersion} object for each operand.
|
|
41
|
+
* Comparison proceeds from major → minor → patch, returning `0` when components
|
|
42
|
+
* that exist are equal, and short-circuiting when a component is `null`.
|
|
43
|
+
*
|
|
44
|
+
* @param a - The first version to compare.
|
|
45
|
+
* @param b - The second version to compare.
|
|
46
|
+
* @returns A negative number if `a` is less than `b`, a positive number if greater, or `0` if equal.
|
|
47
|
+
*/
|
|
4
48
|
export declare const compareVersions: (a: PackageVersion | string, b: PackageVersion | string) => number;
|
|
49
|
+
/**
|
|
50
|
+
* Checks whether version `a` is strictly greater than version `b`.
|
|
51
|
+
*
|
|
52
|
+
* @param a - The first version to compare.
|
|
53
|
+
* @param b - The second version to compare.
|
|
54
|
+
* @returns `true` if `a` is greater than `b`, otherwise `false`.
|
|
55
|
+
*/
|
|
5
56
|
export declare const compareVersionsGT: (a: PackageVersion | string, b: PackageVersion | string) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Increments a semantic version according to the specified bump parameters.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Only one of `major`, `minor`, or `patch` should be set in the bump params.
|
|
62
|
+
* When bumping `major`, `minor` and `patch` are reset to `0`.
|
|
63
|
+
* When bumping `minor`, `patch` is reset to `0`.
|
|
64
|
+
* The original version object is not mutated.
|
|
65
|
+
*
|
|
66
|
+
* @param version - The current version to bump.
|
|
67
|
+
* @param bump - An object indicating which semver component to increment.
|
|
68
|
+
* @returns A new {@link PackageVersion} with the bumped values.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* bumpVersion({ major: 1, minor: 2, patch: 3, prefix: null }, { patch: true });
|
|
73
|
+
* // { major: 1, minor: 2, patch: 4, prefix: null }
|
|
74
|
+
*
|
|
75
|
+
* bumpVersion({ major: 1, minor: 2, patch: 3, prefix: null }, { major: true });
|
|
76
|
+
* // { major: 2, minor: 0, patch: 0, prefix: null }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
6
79
|
export declare const bumpVersion: (version: PackageVersion, bump: BumpParams) => PackageVersion;
|
|
7
80
|
//# sourceMappingURL=pkg.common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.common.d.ts","sourceRoot":"","sources":["../../src/pkg/pkg.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEvE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,cA+B9C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,KAAG,MAMvD,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,GAAG,cAAc,GAAG,MAAM,EAC1B,GAAG,cAAc,GAAG,MAAM,KACzB,MASF,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,GAAG,cAAc,GAAG,MAAM,EAC1B,GAAG,cAAc,GAAG,MAAM,KACzB,OAAoC,CAAC;AAExC,eAAO,MAAM,WAAW,GACtB,SAAS,cAAc,EACvB,MAAM,UAAU,KACf,cAaF,CAAC"}
|
|
1
|
+
{"version":3,"file":"pkg.common.d.ts","sourceRoot":"","sources":["../../src/pkg/pkg.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,cA+B9C,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GAAI,SAAS,cAAc,KAAG,MAMvD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC1B,GAAG,cAAc,GAAG,MAAM,EAC1B,GAAG,cAAc,GAAG,MAAM,KACzB,MASF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,GAAG,cAAc,GAAG,MAAM,EAC1B,GAAG,cAAc,GAAG,MAAM,KACzB,OAAoC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GACtB,SAAS,cAAc,EACvB,MAAM,UAAU,KACf,cAaF,CAAC"}
|
package/dist/pkg/pkg.common.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a semver version string into its constituent parts.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Accepts versions with or without a `v` prefix (e.g. `"v1.2.3"` or `"1.2.3"`).
|
|
6
|
+
* Throws if any of the major, minor, or patch segments are not valid numbers.
|
|
7
|
+
*
|
|
8
|
+
* @param version - A semver version string such as `"1.2.3"` or `"v1.2.3"`.
|
|
9
|
+
* @returns A {@link PackageVersion} object with numeric `major`, `minor`, `patch` and an optional `prefix`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* splitVersion("v1.2.3"); // { major: 1, minor: 2, patch: 3, prefix: "v" }
|
|
14
|
+
* splitVersion("0.5.10"); // { major: 0, minor: 5, patch: 10, prefix: null }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
1
17
|
export const splitVersion = (version) => {
|
|
2
18
|
const parts = version.split(".");
|
|
3
19
|
const majorStr = parts.shift();
|
|
@@ -18,6 +34,22 @@ export const splitVersion = (version) => {
|
|
|
18
34
|
prefix,
|
|
19
35
|
};
|
|
20
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Concatenates a {@link PackageVersion} object back into a version string.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* Includes the prefix (e.g. `"v"`) when present. Minor and patch segments are
|
|
42
|
+
* only appended when they are truthy (non-zero).
|
|
43
|
+
*
|
|
44
|
+
* @param version - The parsed version object to concatenate.
|
|
45
|
+
* @returns The formatted version string, e.g. `"v1.2.3"` or `"1.0"`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* concatVersion({ major: 1, minor: 2, patch: 3, prefix: "v" }); // "v1.2.3"
|
|
50
|
+
* concatVersion({ major: 2, minor: 0, patch: 0, prefix: null }); // "2"
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
21
53
|
export const concatVersion = (version) => {
|
|
22
54
|
let result = version.major.toString();
|
|
23
55
|
if (version.prefix)
|
|
@@ -28,6 +60,18 @@ export const concatVersion = (version) => {
|
|
|
28
60
|
result += "." + version.patch.toString();
|
|
29
61
|
return result;
|
|
30
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Compares two semantic versions numerically.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Accepts either a version string or a {@link PackageVersion} object for each operand.
|
|
68
|
+
* Comparison proceeds from major → minor → patch, returning `0` when components
|
|
69
|
+
* that exist are equal, and short-circuiting when a component is `null`.
|
|
70
|
+
*
|
|
71
|
+
* @param a - The first version to compare.
|
|
72
|
+
* @param b - The second version to compare.
|
|
73
|
+
* @returns A negative number if `a` is less than `b`, a positive number if greater, or `0` if equal.
|
|
74
|
+
*/
|
|
31
75
|
export const compareVersions = (a, b) => {
|
|
32
76
|
a = typeof a === "string" ? splitVersion(a) : a;
|
|
33
77
|
b = typeof b === "string" ? splitVersion(b) : b;
|
|
@@ -43,7 +87,36 @@ export const compareVersions = (a, b) => {
|
|
|
43
87
|
return a.patch - b.patch;
|
|
44
88
|
return 0;
|
|
45
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Checks whether version `a` is strictly greater than version `b`.
|
|
92
|
+
*
|
|
93
|
+
* @param a - The first version to compare.
|
|
94
|
+
* @param b - The second version to compare.
|
|
95
|
+
* @returns `true` if `a` is greater than `b`, otherwise `false`.
|
|
96
|
+
*/
|
|
46
97
|
export const compareVersionsGT = (a, b) => compareVersions(a, b) > 0;
|
|
98
|
+
/**
|
|
99
|
+
* Increments a semantic version according to the specified bump parameters.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
* Only one of `major`, `minor`, or `patch` should be set in the bump params.
|
|
103
|
+
* When bumping `major`, `minor` and `patch` are reset to `0`.
|
|
104
|
+
* When bumping `minor`, `patch` is reset to `0`.
|
|
105
|
+
* The original version object is not mutated.
|
|
106
|
+
*
|
|
107
|
+
* @param version - The current version to bump.
|
|
108
|
+
* @param bump - An object indicating which semver component to increment.
|
|
109
|
+
* @returns A new {@link PackageVersion} with the bumped values.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* bumpVersion({ major: 1, minor: 2, patch: 3, prefix: null }, { patch: true });
|
|
114
|
+
* // { major: 1, minor: 2, patch: 4, prefix: null }
|
|
115
|
+
*
|
|
116
|
+
* bumpVersion({ major: 1, minor: 2, patch: 3, prefix: null }, { major: true });
|
|
117
|
+
* // { major: 2, minor: 0, patch: 0, prefix: null }
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
47
120
|
export const bumpVersion = (version, bump) => {
|
|
48
121
|
const result = { ...version };
|
|
49
122
|
if (bump.major) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.common.js","sourceRoot":"","sources":["../../src/pkg/pkg.common.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAkB,EAAE;IAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,EAAG,CAAC;IAChC,MAAM,MAAM,GAAkB,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAEpE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAEpC,IAAI,KAAK,CAAC,KAAK,CAAC;QACd,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,8DAA8D,CAClF,CAAC;IAEJ,IAAI,KAAK,CAAC,KAAK,CAAC;QACd,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,8DAA8D,CAClF,CAAC;IAEJ,IAAI,KAAK,CAAC,KAAK,CAAC;QACd,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,8DAA8D,CAClF,CAAC;IAEJ,OAAO;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAuB,EAAU,EAAE;IAC/D,IAAI,MAAM,GAAW,OAAO,CAAC,KAAK,C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,CAAC;AACX,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,CAA0B,EAC1B,CAA0B,EACjB,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAuB,EACvB,IAAgB,EACA,EAAE;IAClB,MAAM,MAAM,GAAmB,EAAE,GAAG,OAAO,EAAE,CAAC;IAC9C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACjB,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;SAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;SAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { BumpParams, PackageVersion } from \"../types/types.package.js\";\n\nexport const splitVersion = (version: string): PackageVersion => {\n const parts = version.split(\".\");\n\n const majorStr = parts.shift()!;\n const prefix: string | null = majorStr.startsWith(\"v\") ? \"v\" : null;\n\n const major = Number(prefix ? majorStr.substring(prefix.length) : majorStr);\n const minor = Number(parts.shift());\n const patch = Number(parts.shift());\n\n if (isNaN(major))\n throw new Error(\n `Version \"${version}\" does not match pattern \"/^v?major\\.minor\\.patch$/\" (major)`,\n );\n\n if (isNaN(minor))\n throw new Error(\n `Version \"${version}\" does not match pattern \"/^v?major\\.minor\\.patch$/\" (minor)`,\n );\n\n if (isNaN(patch))\n throw new Error(\n `Version \"${version}\" does not match pattern \"/^v?major\\.minor\\.patch$/\" (patch)`,\n );\n\n return {\n major,\n minor,\n patch,\n prefix,\n };\n};\n\nexport const concatVersion = (version: PackageVersion): string => {\n let result: string = version.major.toString();\n if (version.prefix) result = version.prefix + result;\n if (version.minor) result += \".\" + version.minor.toString();\n if (version.patch) result += \".\" + version.patch.toString();\n return result;\n};\n\nexport const compareVersions = (\n a: PackageVersion | string,\n b: PackageVersion | string,\n): number => {\n a = typeof a === \"string\" ? splitVersion(a) : a;\n b = typeof b === \"string\" ? splitVersion(b) : b;\n if (a.major !== b.major) return a.major - b.major;\n if (a.minor === null || b.minor === null) return 0;\n if (a.minor !== b.minor) return a.minor - b.minor;\n if (a.patch === null || b.patch === null) return 0;\n if (a.patch !== b.patch) return a.patch - b.patch;\n return 0;\n};\n\nexport const compareVersionsGT = (\n a: PackageVersion | string,\n b: PackageVersion | string,\n): boolean => compareVersions(a, b) > 0;\n\nexport const bumpVersion = (\n version: PackageVersion,\n bump: BumpParams,\n): PackageVersion => {\n const result: PackageVersion = { ...version };\n if (bump.major) {\n result.major = result.major ? result.major + 1 : 1;\n result.minor = 0;\n result.patch = 0;\n } else if (bump.minor) {\n result.minor = result.minor ? result.minor + 1 : 1;\n result.patch = 0;\n } else if (bump.patch) {\n result.patch = result.patch ? result.patch + 1 : 1;\n }\n return result;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"pkg.common.js","sourceRoot":"","sources":["../../src/pkg/pkg.common.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAkB,EAAE;IAC9D,MAAM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AAC;AAExC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAuB,EACvB,IAAgB,EACA,EAAE;IAClB,MAAM,MAAM,GAAmB,EAAE,GAAG,OAAO,EAAE,CAAC;IAC9C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACjB,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;SAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;SAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { BumpParams, PackageVersion } from \"../types/types.package.js\";\n\n/**\n * Parses a semver version string into its constituent parts.\n *\n * @remarks\n * Accepts versions with or without a `v` prefix (e.g. `\"v1.2.3\"` or `\"1.2.3\"`).\n * Throws if any of the major, minor, or patch segments are not valid numbers.\n *\n * @param version - A semver version string such as `\"1.2.3\"` or `\"v1.2.3\"`.\n * @returns A {@link PackageVersion} object with numeric `major`, `minor`, `patch` and an optional `prefix`.\n *\n * @example\n * ```ts\n * splitVersion(\"v1.2.3\"); // { major: 1, minor: 2, patch: 3, prefix: \"v\" }\n * splitVersion(\"0.5.10\"); // { major: 0, minor: 5, patch: 10, prefix: null }\n * ```\n */\nexport const splitVersion = (version: string): PackageVersion => {\n const parts = version.split(\".\");\n\n const majorStr = parts.shift()!;\n const prefix: string | null = majorStr.startsWith(\"v\") ? \"v\" : null;\n\n const major = Number(prefix ? majorStr.substring(prefix.length) : majorStr);\n const minor = Number(parts.shift());\n const patch = Number(parts.shift());\n\n if (isNaN(major))\n throw new Error(\n `Version \"${version}\" does not match pattern \"/^v?major\\.minor\\.patch$/\" (major)`,\n );\n\n if (isNaN(minor))\n throw new Error(\n `Version \"${version}\" does not match pattern \"/^v?major\\.minor\\.patch$/\" (minor)`,\n );\n\n if (isNaN(patch))\n throw new Error(\n `Version \"${version}\" does not match pattern \"/^v?major\\.minor\\.patch$/\" (patch)`,\n );\n\n return {\n major,\n minor,\n patch,\n prefix,\n };\n};\n\n/**\n * Concatenates a {@link PackageVersion} object back into a version string.\n *\n * @remarks\n * Includes the prefix (e.g. `\"v\"`) when present. Minor and patch segments are\n * only appended when they are truthy (non-zero).\n *\n * @param version - The parsed version object to concatenate.\n * @returns The formatted version string, e.g. `\"v1.2.3\"` or `\"1.0\"`.\n *\n * @example\n * ```ts\n * concatVersion({ major: 1, minor: 2, patch: 3, prefix: \"v\" }); // \"v1.2.3\"\n * concatVersion({ major: 2, minor: 0, patch: 0, prefix: null }); // \"2\"\n * ```\n */\nexport const concatVersion = (version: PackageVersion): string => {\n let result: string = version.major.toString();\n if (version.prefix) result = version.prefix + result;\n if (version.minor) result += \".\" + version.minor.toString();\n if (version.patch) result += \".\" + version.patch.toString();\n return result;\n};\n\n/**\n * Compares two semantic versions numerically.\n *\n * @remarks\n * Accepts either a version string or a {@link PackageVersion} object for each operand.\n * Comparison proceeds from major → minor → patch, returning `0` when components\n * that exist are equal, and short-circuiting when a component is `null`.\n *\n * @param a - The first version to compare.\n * @param b - The second version to compare.\n * @returns A negative number if `a` is less than `b`, a positive number if greater, or `0` if equal.\n */\nexport const compareVersions = (\n a: PackageVersion | string,\n b: PackageVersion | string,\n): number => {\n a = typeof a === \"string\" ? splitVersion(a) : a;\n b = typeof b === \"string\" ? splitVersion(b) : b;\n if (a.major !== b.major) return a.major - b.major;\n if (a.minor === null || b.minor === null) return 0;\n if (a.minor !== b.minor) return a.minor - b.minor;\n if (a.patch === null || b.patch === null) return 0;\n if (a.patch !== b.patch) return a.patch - b.patch;\n return 0;\n};\n\n/**\n * Checks whether version `a` is strictly greater than version `b`.\n *\n * @param a - The first version to compare.\n * @param b - The second version to compare.\n * @returns `true` if `a` is greater than `b`, otherwise `false`.\n */\nexport const compareVersionsGT = (\n a: PackageVersion | string,\n b: PackageVersion | string,\n): boolean => compareVersions(a, b) > 0;\n\n/**\n * Increments a semantic version according to the specified bump parameters.\n *\n * @remarks\n * Only one of `major`, `minor`, or `patch` should be set in the bump params.\n * When bumping `major`, `minor` and `patch` are reset to `0`.\n * When bumping `minor`, `patch` is reset to `0`.\n * The original version object is not mutated.\n *\n * @param version - The current version to bump.\n * @param bump - An object indicating which semver component to increment.\n * @returns A new {@link PackageVersion} with the bumped values.\n *\n * @example\n * ```ts\n * bumpVersion({ major: 1, minor: 2, patch: 3, prefix: null }, { patch: true });\n * // { major: 1, minor: 2, patch: 4, prefix: null }\n *\n * bumpVersion({ major: 1, minor: 2, patch: 3, prefix: null }, { major: true });\n * // { major: 2, minor: 0, patch: 0, prefix: null }\n * ```\n */\nexport const bumpVersion = (\n version: PackageVersion,\n bump: BumpParams,\n): PackageVersion => {\n const result: PackageVersion = { ...version };\n if (bump.major) {\n result.major = result.major ? result.major + 1 : 1;\n result.minor = 0;\n result.patch = 0;\n } else if (bump.minor) {\n result.minor = result.minor ? result.minor + 1 : 1;\n result.patch = 0;\n } else if (bump.patch) {\n result.patch = result.patch ? result.patch + 1 : 1;\n }\n return result;\n};\n"]}
|
package/dist/pkg/pkg.fs.d.ts
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
import { PackageJson } from "../types/types.package.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reads and parses a `package.json` file asynchronously.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Uses JSON5 for parsing, so comments and trailing commas are permitted.
|
|
7
|
+
* If the path is a directory, `/package.json` is automatically appended.
|
|
8
|
+
*
|
|
9
|
+
* @param dirOrFilepath - An absolute path to either a directory containing `package.json` or the file itself.
|
|
10
|
+
* @returns A promise resolving to the parsed {@link PackageJson} contents.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const pkg = await readPackageJson("/path/to/my-package");
|
|
15
|
+
* console.log(pkg.name);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
2
18
|
export declare const readPackageJson: (dirOrFilepath: string) => Promise<PackageJson>;
|
|
19
|
+
/**
|
|
20
|
+
* Reads and parses a `package.json` file synchronously.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Uses JSON5 for parsing, so comments and trailing commas are permitted.
|
|
24
|
+
* If the path is a directory, `/package.json` is automatically appended.
|
|
25
|
+
*
|
|
26
|
+
* @param dirOrFilepath - An absolute path to either a directory containing `package.json` or the file itself.
|
|
27
|
+
* @returns The parsed {@link PackageJson} contents.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const pkg = readPackageJsonSync("/path/to/my-package");
|
|
32
|
+
* console.log(pkg.version);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
3
35
|
export declare const readPackageJsonSync: (dirOrFilepath: string) => PackageJson;
|
|
36
|
+
/**
|
|
37
|
+
* Writes a {@link PackageJson} object to disk as formatted JSON.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* The output is stringified via JSON5 and then formatted with the project's
|
|
41
|
+
* standard JSON formatter before being written.
|
|
42
|
+
*
|
|
43
|
+
* @param jsonPath - The absolute file path to write the `package.json` to.
|
|
44
|
+
* @param content - The package JSON content to serialize and write.
|
|
45
|
+
* @returns A promise that resolves when the file has been written.
|
|
46
|
+
*/
|
|
4
47
|
export declare const writePackageJson: (jsonPath: string, content: PackageJson) => Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Ensures a path ends with `/package.json`.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* If the path already ends with `/package.json` it is returned as-is;
|
|
53
|
+
* otherwise `package.json` is appended via `path.join`.
|
|
54
|
+
*
|
|
55
|
+
* @param dirOrFilepath - A directory path or a path already pointing to `package.json`.
|
|
56
|
+
* @returns The path guaranteed to end with `/package.json`.
|
|
57
|
+
*/
|
|
5
58
|
export declare const ensurePkgJsonPath: (dirOrFilepath: string) => string;
|
|
6
59
|
//# sourceMappingURL=pkg.fs.d.ts.map
|
package/dist/pkg/pkg.fs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.fs.d.ts","sourceRoot":"","sources":["../../src/pkg/pkg.fs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pkg.fs.d.ts","sourceRoot":"","sources":["../../src/pkg/pkg.fs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AASxD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAC1B,eAAe,MAAM,KACpB,OAAO,CAAC,WAAW,CAC+C,CAAC;AAEtE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,GAAI,eAAe,MAAM,KAAG,WACO,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,SAAS,WAAW,KACnB,OAAO,CAAC,IAAI,CAIZ,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,eAAe,MAAM,KAAG,MAGjB,CAAC"}
|
package/dist/pkg/pkg.fs.js
CHANGED
|
@@ -1,11 +1,63 @@
|
|
|
1
|
-
import json5 from "json5";
|
|
2
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
3
2
|
import { join } from "node:path";
|
|
4
|
-
import { formatJsonStringify } from "../code/code.format.js";
|
|
5
3
|
import { readFileSync } from "node:fs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { jsonParse, jsonStringify, JsonStringifyFormat, } from "../common/common.json.js";
|
|
5
|
+
/**
|
|
6
|
+
* Reads and parses a `package.json` file asynchronously.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Uses JSON5 for parsing, so comments and trailing commas are permitted.
|
|
10
|
+
* If the path is a directory, `/package.json` is automatically appended.
|
|
11
|
+
*
|
|
12
|
+
* @param dirOrFilepath - An absolute path to either a directory containing `package.json` or the file itself.
|
|
13
|
+
* @returns A promise resolving to the parsed {@link PackageJson} contents.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const pkg = await readPackageJson("/path/to/my-package");
|
|
18
|
+
* console.log(pkg.name);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const readPackageJson = async (dirOrFilepath) => jsonParse(await readFile(ensurePkgJsonPath(dirOrFilepath), "utf8"));
|
|
22
|
+
/**
|
|
23
|
+
* Reads and parses a `package.json` file synchronously.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* Uses JSON5 for parsing, so comments and trailing commas are permitted.
|
|
27
|
+
* If the path is a directory, `/package.json` is automatically appended.
|
|
28
|
+
*
|
|
29
|
+
* @param dirOrFilepath - An absolute path to either a directory containing `package.json` or the file itself.
|
|
30
|
+
* @returns The parsed {@link PackageJson} contents.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const pkg = readPackageJsonSync("/path/to/my-package");
|
|
35
|
+
* console.log(pkg.version);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const readPackageJsonSync = (dirOrFilepath) => jsonParse(readFileSync(ensurePkgJsonPath(dirOrFilepath), "utf8"));
|
|
39
|
+
/**
|
|
40
|
+
* Writes a {@link PackageJson} object to disk as formatted JSON.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* The output is stringified via JSON5 and then formatted with the project's
|
|
44
|
+
* standard JSON formatter before being written.
|
|
45
|
+
*
|
|
46
|
+
* @param jsonPath - The absolute file path to write the `package.json` to.
|
|
47
|
+
* @param content - The package JSON content to serialize and write.
|
|
48
|
+
* @returns A promise that resolves when the file has been written.
|
|
49
|
+
*/
|
|
50
|
+
export const writePackageJson = async (jsonPath, content) => writeFile(jsonPath, await jsonStringify(content, JsonStringifyFormat.jsonStringify));
|
|
51
|
+
/**
|
|
52
|
+
* Ensures a path ends with `/package.json`.
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* If the path already ends with `/package.json` it is returned as-is;
|
|
56
|
+
* otherwise `package.json` is appended via `path.join`.
|
|
57
|
+
*
|
|
58
|
+
* @param dirOrFilepath - A directory path or a path already pointing to `package.json`.
|
|
59
|
+
* @returns The path guaranteed to end with `/package.json`.
|
|
60
|
+
*/
|
|
9
61
|
export const ensurePkgJsonPath = (dirOrFilepath) => dirOrFilepath.endsWith("/package.json")
|
|
10
62
|
? dirOrFilepath
|
|
11
63
|
: join(dirOrFilepath, "package.json");
|
package/dist/pkg/pkg.fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.fs.js","sourceRoot":"","sources":["../../src/pkg/pkg.fs.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pkg.fs.js","sourceRoot":"","sources":["../../src/pkg/pkg.fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,SAAS,EACT,aAAa,EACb,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,aAAqB,EACC,EAAE,CACxB,SAAS,CAAC,MAAM,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,aAAqB,EAAe,EAAE,CACxE,SAAS,CAAC,YAAY,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,QAAgB,EAChB,OAAoB,EACL,EAAE,CACjB,SAAS,CACP,QAAQ,EACR,MAAM,aAAa,CAAC,OAAO,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAChE,CAAC;AAEJ;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,aAAqB,EAAU,EAAE,CACjE,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC;IACrC,CAAC,CAAC,aAAa;IACf,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { readFile, writeFile } from \"node:fs/promises\";\nimport { PackageJson } from \"../types/types.package.js\";\nimport { join } from \"node:path\";\nimport { readFileSync } from \"node:fs\";\nimport {\n jsonParse,\n jsonStringify,\n JsonStringifyFormat,\n} from \"../common/common.json.js\";\n\n/**\n * Reads and parses a `package.json` file asynchronously.\n *\n * @remarks\n * Uses JSON5 for parsing, so comments and trailing commas are permitted.\n * If the path is a directory, `/package.json` is automatically appended.\n *\n * @param dirOrFilepath - An absolute path to either a directory containing `package.json` or the file itself.\n * @returns A promise resolving to the parsed {@link PackageJson} contents.\n *\n * @example\n * ```ts\n * const pkg = await readPackageJson(\"/path/to/my-package\");\n * console.log(pkg.name);\n * ```\n */\nexport const readPackageJson = async (\n dirOrFilepath: string,\n): Promise<PackageJson> =>\n jsonParse(await readFile(ensurePkgJsonPath(dirOrFilepath), \"utf8\"));\n\n/**\n * Reads and parses a `package.json` file synchronously.\n *\n * @remarks\n * Uses JSON5 for parsing, so comments and trailing commas are permitted.\n * If the path is a directory, `/package.json` is automatically appended.\n *\n * @param dirOrFilepath - An absolute path to either a directory containing `package.json` or the file itself.\n * @returns The parsed {@link PackageJson} contents.\n *\n * @example\n * ```ts\n * const pkg = readPackageJsonSync(\"/path/to/my-package\");\n * console.log(pkg.version);\n * ```\n */\nexport const readPackageJsonSync = (dirOrFilepath: string): PackageJson =>\n jsonParse(readFileSync(ensurePkgJsonPath(dirOrFilepath), \"utf8\"));\n\n/**\n * Writes a {@link PackageJson} object to disk as formatted JSON.\n *\n * @remarks\n * The output is stringified via JSON5 and then formatted with the project's\n * standard JSON formatter before being written.\n *\n * @param jsonPath - The absolute file path to write the `package.json` to.\n * @param content - The package JSON content to serialize and write.\n * @returns A promise that resolves when the file has been written.\n */\nexport const writePackageJson = async (\n jsonPath: string,\n content: PackageJson,\n): Promise<void> =>\n writeFile(\n jsonPath,\n await jsonStringify(content, JsonStringifyFormat.jsonStringify),\n );\n\n/**\n * Ensures a path ends with `/package.json`.\n *\n * @remarks\n * If the path already ends with `/package.json` it is returned as-is;\n * otherwise `package.json` is appended via `path.join`.\n *\n * @param dirOrFilepath - A directory path or a path already pointing to `package.json`.\n * @returns The path guaranteed to end with `/package.json`.\n */\nexport const ensurePkgJsonPath = (dirOrFilepath: string): string =>\n dirOrFilepath.endsWith(\"/package.json\")\n ? dirOrFilepath\n : join(dirOrFilepath, \"package.json\");\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./types.cleanup.js";
|
|
|
4
4
|
export * from "./types.code.js";
|
|
5
5
|
export * from "./types.deps.js";
|
|
6
6
|
export * from "./types.documents.js";
|
|
7
|
+
export * from "./types.exports.js";
|
|
7
8
|
export * from "./types.git.js";
|
|
8
9
|
export * from "./types.npm.js";
|
|
9
10
|
export * from "./types.os.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./types.cleanup.js";
|
|
|
5
5
|
export * from "./types.code.js";
|
|
6
6
|
export * from "./types.deps.js";
|
|
7
7
|
export * from "./types.documents.js";
|
|
8
|
+
export * from "./types.exports.js";
|
|
8
9
|
export * from "./types.git.js";
|
|
9
10
|
export * from "./types.npm.js";
|
|
10
11
|
export * from "./types.os.js";
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC","sourcesContent":["// This file is auto-generated for build-cli. Do not edit manually.\nexport * from \"./types.barrel.js\";\nexport * from \"./types.changelog.js\";\nexport * from \"./types.cleanup.js\";\nexport * from \"./types.code.js\";\nexport * from \"./types.deps.js\";\nexport * from \"./types.documents.js\";\nexport * from \"./types.git.js\";\nexport * from \"./types.npm.js\";\nexport * from \"./types.os.js\";\nexport * from \"./types.package.js\";\nexport * from \"./types.run.js\";\nexport * from \"./types.vscode.js\";\nexport * from \"./types.workspace.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC","sourcesContent":["// This file is auto-generated for build-cli. Do not edit manually.\nexport * from \"./types.barrel.js\";\nexport * from \"./types.changelog.js\";\nexport * from \"./types.cleanup.js\";\nexport * from \"./types.code.js\";\nexport * from \"./types.deps.js\";\nexport * from \"./types.documents.js\";\nexport * from \"./types.exports.js\";\nexport * from \"./types.git.js\";\nexport * from \"./types.npm.js\";\nexport * from \"./types.os.js\";\nexport * from \"./types.package.js\";\nexport * from \"./types.run.js\";\nexport * from \"./types.vscode.js\";\nexport * from \"./types.workspace.js\";\n"]}
|
|
@@ -1,24 +1,52 @@
|
|
|
1
1
|
import type { Pkg } from "../pkg/Pkg.js";
|
|
2
2
|
import { SourceFile } from "./types.code.js";
|
|
3
3
|
import { RunRepoRootParams } from "./types.run.js";
|
|
4
|
+
/**
|
|
5
|
+
* A group of files within a directory that share a common barrel file.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Represents one directory's barrel-file context, including the files
|
|
9
|
+
* that should be re-exported and whether the barrel already exists on disk.
|
|
10
|
+
*/
|
|
4
11
|
export interface BarrelGroup {
|
|
12
|
+
/** Absolute path to the directory containing the barrel file. */
|
|
5
13
|
dirPath: string;
|
|
14
|
+
/** Absolute path to the barrel (index) file itself. */
|
|
6
15
|
barrelFilePath: string;
|
|
16
|
+
/** Whether the barrel file already exists on disk. */
|
|
7
17
|
barrelExists: boolean;
|
|
18
|
+
/** List of file paths to be re-exported through the barrel. */
|
|
8
19
|
files: string[];
|
|
20
|
+
/** The package that owns this barrel group. */
|
|
9
21
|
pkg: Pkg;
|
|
10
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The result of a barrel-file generation operation for a single package.
|
|
25
|
+
*/
|
|
11
26
|
export interface BarrelResult {
|
|
27
|
+
/** Directories in which barrel files were generated or updated. */
|
|
12
28
|
barrelDirs: string[];
|
|
29
|
+
/** The package for which barrels were generated. */
|
|
13
30
|
pkg: Pkg;
|
|
14
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Parameters for running barrel-file generation across a repository.
|
|
34
|
+
*/
|
|
15
35
|
export interface BarrelParams extends RunRepoRootParams {
|
|
36
|
+
/** Regular expressions used to exclude files or directories from barrel generation. */
|
|
16
37
|
excludes?: RegExp[];
|
|
38
|
+
/** A header comment to prepend to each generated barrel file. */
|
|
17
39
|
fileHeader?: string;
|
|
40
|
+
/** When `true`, use the TypeScript Compiler API to resolve exports. */
|
|
18
41
|
useCompilerApi?: boolean;
|
|
19
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Parameters for persisting a barrel file to disk.
|
|
45
|
+
*/
|
|
20
46
|
export interface BarrelPersistParams {
|
|
47
|
+
/** The barrel group to persist. */
|
|
21
48
|
group: BarrelGroup;
|
|
49
|
+
/** Optional pre-built source-file map to avoid redundant parsing. */
|
|
22
50
|
sourceFileMap?: Map<string, SourceFile>;
|
|
23
51
|
}
|
|
24
52
|
//# sourceMappingURL=types.barrel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.barrel.d.ts","sourceRoot":"","sources":["../../src/types/types.barrel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,EAAE,GAAG,CAAC;CACV;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,GAAG,CAAC;CACV;AA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E,WAAW,CAAC;IACnB,qEAAqE;IACrE,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.barrel.js","sourceRoot":"","sources":["../../src/types/types.barrel.ts"],"names":[],"mappings":"","sourcesContent":["import type { Pkg } from \"../pkg/Pkg.js\";\nimport { SourceFile } from \"./types.code.js\";\nimport { RunRepoRootParams } from \"./types.run.js\";\n\nexport interface BarrelGroup {\n dirPath: string;\n barrelFilePath: string;\n barrelExists: boolean;\n files: string[];\n pkg: Pkg;\n}\n\nexport interface BarrelResult {\n barrelDirs: string[];\n pkg: Pkg;\n}\n\nexport interface BarrelParams extends RunRepoRootParams {\n excludes?: RegExp[];\n fileHeader?: string;\n useCompilerApi?: boolean;\n}\n\nexport interface BarrelPersistParams {\n group: BarrelGroup;\n sourceFileMap?: Map<string, SourceFile>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.barrel.js","sourceRoot":"","sources":["../../src/types/types.barrel.ts"],"names":[],"mappings":"","sourcesContent":["import type { Pkg } from \"../pkg/Pkg.js\";\nimport { SourceFile } from \"./types.code.js\";\nimport { RunRepoRootParams } from \"./types.run.js\";\n\n/**\n * A group of files within a directory that share a common barrel file.\n *\n * @remarks\n * Represents one directory's barrel-file context, including the files\n * that should be re-exported and whether the barrel already exists on disk.\n */\nexport interface BarrelGroup {\n /** Absolute path to the directory containing the barrel file. */\n dirPath: string;\n /** Absolute path to the barrel (index) file itself. */\n barrelFilePath: string;\n /** Whether the barrel file already exists on disk. */\n barrelExists: boolean;\n /** List of file paths to be re-exported through the barrel. */\n files: string[];\n /** The package that owns this barrel group. */\n pkg: Pkg;\n}\n\n/**\n * The result of a barrel-file generation operation for a single package.\n */\nexport interface BarrelResult {\n /** Directories in which barrel files were generated or updated. */\n barrelDirs: string[];\n /** The package for which barrels were generated. */\n pkg: Pkg;\n}\n\n/**\n * Parameters for running barrel-file generation across a repository.\n */\nexport interface BarrelParams extends RunRepoRootParams {\n /** Regular expressions used to exclude files or directories from barrel generation. */\n excludes?: RegExp[];\n /** A header comment to prepend to each generated barrel file. */\n fileHeader?: string;\n /** When `true`, use the TypeScript Compiler API to resolve exports. */\n useCompilerApi?: boolean;\n}\n\n/**\n * Parameters for persisting a barrel file to disk.\n */\nexport interface BarrelPersistParams {\n /** The barrel group to persist. */\n group: BarrelGroup;\n /** Optional pre-built source-file map to avoid redundant parsing. */\n sourceFileMap?: Map<string, SourceFile>;\n}\n"]}
|