@mxpicture/build-api 0.2.22 → 0.2.24

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.
Files changed (58) hide show
  1. package/dist/barrel/Barrel.d.ts +3 -4
  2. package/dist/barrel/Barrel.js +27 -28
  3. package/dist/changes/Changes.d.ts +6 -0
  4. package/dist/changes/Changes.js +15 -0
  5. package/dist/changes/index.d.ts +1 -0
  6. package/dist/changes/index.js +2 -0
  7. package/dist/cleanup/Cleanup.d.ts +1 -4
  8. package/dist/cleanup/Cleanup.js +11 -15
  9. package/dist/common/common.json.d.ts +2 -0
  10. package/dist/common/common.json.js +3 -0
  11. package/dist/common/index.d.ts +1 -0
  12. package/dist/common/index.js +1 -0
  13. package/dist/deps/FixWorkspaceDeps.d.ts +6 -5
  14. package/dist/deps/FixWorkspaceDeps.js +31 -26
  15. package/dist/git/GitChanges.d.ts +8 -5
  16. package/dist/git/GitChanges.js +22 -17
  17. package/dist/git/git.util.d.ts +4 -0
  18. package/dist/git/git.util.js +6 -0
  19. package/dist/npmPublish/NpmPublisher.d.ts +3 -3
  20. package/dist/npmPublish/NpmPublisher.js +12 -17
  21. package/dist/osInfo/osInfo.common.d.ts +2 -0
  22. package/dist/osInfo/osInfo.common.js +4 -0
  23. package/dist/pkg/Pkg.d.ts +24 -0
  24. package/dist/pkg/Pkg.js +74 -0
  25. package/dist/pkg/SyncPkgVersion.d.ts +5 -6
  26. package/dist/pkg/SyncPkgVersion.js +14 -19
  27. package/dist/pkg/UpdatePackages.d.ts +4 -6
  28. package/dist/pkg/UpdatePackages.js +12 -11
  29. package/dist/pkg/index.d.ts +2 -0
  30. package/dist/pkg/index.js +2 -0
  31. package/dist/pkg/pkg.fs.d.ts +5 -0
  32. package/dist/pkg/pkg.fs.js +11 -0
  33. package/dist/types/index.d.ts +0 -1
  34. package/dist/types/index.js +0 -1
  35. package/dist/types/types.barrel.d.ts +5 -6
  36. package/dist/types/types.cleanup.d.ts +2 -2
  37. package/dist/types/types.deps.d.ts +5 -4
  38. package/dist/types/types.git.d.ts +2 -2
  39. package/dist/types/types.npm.d.ts +2 -2
  40. package/dist/types/types.package.d.ts +6 -12
  41. package/dist/types/types.run.d.ts +1 -5
  42. package/dist/vscode/vscode.settings.d.ts +2 -0
  43. package/dist/vscode/vscode.settings.js +4 -0
  44. package/dist/vscode/vscode.storage.d.ts +2 -0
  45. package/dist/vscode/vscode.storage.js +4 -0
  46. package/dist/workspace/Workspace.d.ts +25 -0
  47. package/dist/workspace/Workspace.js +70 -0
  48. package/dist/workspace/WorkspacePaths.d.ts +1 -7
  49. package/dist/workspace/WorkspacePaths.js +30 -30
  50. package/dist/workspace/index.d.ts +1 -1
  51. package/dist/workspace/index.js +1 -1
  52. package/dist/workspace/workspace.common.d.ts +2 -0
  53. package/dist/workspace/workspace.common.js +4 -0
  54. package/package.json +4 -4
  55. package/dist/types/types.changeset.d.ts +0 -2
  56. package/dist/types/types.changeset.js +0 -1
  57. package/dist/workspace/workspace.pkg.d.ts +0 -15
  58. package/dist/workspace/workspace.pkg.js +0 -123
@@ -1,4 +1,4 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
+ export * from "./Workspace.js";
2
3
  export * from "./WorkspacePaths.js";
3
4
  export * from "./workspace.common.js";
4
- export * from "./workspace.pkg.js";
@@ -3,3 +3,5 @@ export declare const DEFAULT_WORKSPACE_FILE_ENDING = ".code-workspace";
3
3
  export declare const getFileType: (filename: string) => WorkspaceFileType;
4
4
  export declare const findWorkspaceRoot: (startPath: string) => Promise<WorkspaceFile>;
5
5
  export declare const readWorkspaceYaml: (repoRoot: string) => Promise<PnpmWorkspace>;
6
+ /** @internal test-only */
7
+ export declare const __resetWorkspaceRoot: () => void;
@@ -78,3 +78,7 @@ export const readWorkspaceYaml = async (repoRoot) => {
78
78
  packages.push(...packageColletion);
79
79
  return { packages };
80
80
  };
81
+ /** @internal test-only */
82
+ export const __resetWorkspaceRoot = () => {
83
+ __workspaceRoot = null;
84
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/build-api",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "description": "Build utilities API",
5
5
  "type": "module",
6
6
  "author": "MXPicture",
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "exports": {
13
13
  "./barrel": "./dist/barrel/index.js",
14
+ "./changes": "./dist/changes/index.js",
14
15
  "./cleanup": "./dist/cleanup/index.js",
15
16
  "./common": "./dist/common/index.js",
16
17
  "./deps": "./dist/deps/index.js",
@@ -34,7 +35,8 @@
34
35
  },
35
36
  "scripts": {
36
37
  "lint": "eslint \"src/**/*.{ts,tsx}\" --ext .ts,.tsx",
37
- "build": "tsc -b ."
38
+ "build": "tsc -b .",
39
+ "test": "vitest run"
38
40
  },
39
41
  "publishConfig": {
40
42
  "access": "public"
@@ -43,9 +45,7 @@
43
45
  "typescript": "^5.9.3"
44
46
  },
45
47
  "dependencies": {
46
- "@commander-js/extra-typings": "^14.0.0",
47
48
  "@types/micromatch": "^4.0.10",
48
- "commander": "^14.0.3",
49
49
  "json5": "^2.2.3",
50
50
  "micromatch": "^4.0.8",
51
51
  "prettier": "^3.8.1",
@@ -1,2 +0,0 @@
1
- import { RunRepoRootWsParams } from "./types.run.js";
2
- export type ChangesetParams = RunRepoRootWsParams;
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import { PackageJson, PackageEntry, MapEntry } from "../types/types.package.js";
2
- export declare const readPackageJson: (dirOrFilepath: string) => Promise<PackageJson | null>;
3
- export declare const readPackageEntry: (dirOrFilepath: string) => Promise<PackageEntry | null>;
4
- export declare const readPackageJsonThrow: (dirOrFilepath: string) => Promise<PackageJson>;
5
- export declare const readPackageEntryThrow: (dirOrFilepath: string) => Promise<PackageEntry>;
6
- export declare const readPackageJsonSync: (dirOrFilepath: string) => PackageJson;
7
- export declare const readPackageEntrySync: (dirOrFilepath: string) => PackageEntry;
8
- export declare const readPackageJsons: (repoRoot: string) => Promise<PackageJson[]>;
9
- export declare const readPackageEntries: (repoRoot: string) => Promise<PackageEntry[]>;
10
- export declare const writePackageEntries: (entries: PackageEntry[]) => Promise<void[]>;
11
- export declare const writePackageJson: (jsonPath: string, content: PackageJson) => Promise<void>;
12
- export declare const writePackageEntry: (entry: PackageEntry) => Promise<void>;
13
- export declare const buildMapEntries: (pkgEntries: PackageEntry[]) => MapEntry[];
14
- export declare const readPackageVersions: (rootDir: string) => Promise<Record<string, string>>;
15
- export declare const readMinPackageVersion: (rootDir: string) => Promise<string | null>;
@@ -1,123 +0,0 @@
1
- import { readFile, writeFile } from "node:fs/promises";
2
- import { join, relative, sep } from "node:path";
3
- import { splitVersion, compareVersions, concatVersion, } from "../pkg/pkg.common.js";
4
- import json5 from "json5";
5
- import { logInfo, logSuccess } from "../logger/Logger.js";
6
- import { readFileSync } from "node:fs";
7
- import { readWorkspaceYaml } from "./workspace.common.js";
8
- import { formatJsonStringify } from "../format/format.code.js";
9
- const ensurePkgJsonPath = (dirOrFilepath) => dirOrFilepath.endsWith("/package.json")
10
- ? dirOrFilepath
11
- : join(dirOrFilepath, "package.json");
12
- export const readPackageJson = async (dirOrFilepath) => {
13
- try {
14
- return readPackageJsonThrow(dirOrFilepath);
15
- }
16
- catch {
17
- return null;
18
- }
19
- };
20
- export const readPackageEntry = async (dirOrFilepath) => {
21
- try {
22
- return readPackageEntryThrow(dirOrFilepath);
23
- }
24
- catch {
25
- return null;
26
- }
27
- };
28
- export const readPackageJsonThrow = async (dirOrFilepath) => json5.parse(await readFile(ensurePkgJsonPath(dirOrFilepath), "utf8"));
29
- export const readPackageEntryThrow = async (dirOrFilepath) => {
30
- const pkgPath = ensurePkgJsonPath(dirOrFilepath);
31
- const parts = pkgPath.split(sep);
32
- parts.pop();
33
- const wsName = parts.pop();
34
- if (!wsName)
35
- throw new Error(`Path ${pkgPath} does not conatin any workspace`);
36
- return {
37
- jsonPath: pkgPath,
38
- repoPath: null,
39
- content: await readPackageJsonThrow(pkgPath),
40
- modified: false,
41
- wsName,
42
- };
43
- };
44
- export const readPackageJsonSync = (dirOrFilepath) => json5.parse(readFileSync(ensurePkgJsonPath(dirOrFilepath), "utf8"));
45
- export const readPackageEntrySync = (dirOrFilepath) => {
46
- const pkgPath = ensurePkgJsonPath(dirOrFilepath);
47
- const parts = pkgPath.split(sep);
48
- parts.pop();
49
- const wsName = parts.pop();
50
- if (!wsName)
51
- throw new Error(`Path ${pkgPath} does not conatin any workspace`);
52
- return {
53
- jsonPath: pkgPath,
54
- repoPath: null,
55
- content: readPackageJsonSync(pkgPath),
56
- modified: false,
57
- wsName,
58
- };
59
- };
60
- export const readPackageJsons = async (repoRoot) => (await readPackageEntries(repoRoot)).map((entry) => entry.content);
61
- export const readPackageEntries = async (repoRoot) => {
62
- try {
63
- const pnpmWS = await readWorkspaceYaml(repoRoot);
64
- return Promise.all(pnpmWS.packages.map(async (repoPath) => {
65
- const jsonPath = join(repoRoot, repoPath, "package.json");
66
- const content = await readPackageJsonThrow(jsonPath);
67
- return {
68
- jsonPath,
69
- repoPath,
70
- content,
71
- modified: false,
72
- wsName: repoPath.startsWith("packages/")
73
- ? repoPath.substring(9)
74
- : repoPath,
75
- };
76
- }));
77
- }
78
- catch {
79
- return [];
80
- }
81
- };
82
- export const writePackageEntries = async (entries) => Promise.all(entries.map(writePackageEntry));
83
- export const writePackageJson = async (jsonPath, content) => writeFile(jsonPath, await formatJsonStringify(json5.stringify(content)));
84
- export const writePackageEntry = async (entry) => {
85
- if (entry.modified) {
86
- await writePackageJson(entry.jsonPath, entry.content);
87
- logSuccess(` ✅ package.json updated ${entry.content.name}\n`);
88
- }
89
- else {
90
- logInfo(` ⏭️ No changes in package.json. ${entry.content.name}\n`);
91
- }
92
- };
93
- // Build a map of package names to their versions
94
- export const buildMapEntries = (pkgEntries) => {
95
- const versionEntries = [];
96
- for (const fromPkg of pkgEntries)
97
- for (const toPkg of pkgEntries)
98
- if (fromPkg.content.name !== toPkg.content.name)
99
- versionEntries.push({
100
- fromPkg,
101
- toPkg,
102
- relPath: relative(fromPkg.jsonPath, toPkg.jsonPath),
103
- });
104
- return versionEntries;
105
- };
106
- export const readPackageVersions = async (rootDir) => {
107
- const versions = {};
108
- const packageEntries = await readPackageEntries(rootDir);
109
- for (const packageEntry of packageEntries) {
110
- if (!packageEntry.repoPath)
111
- continue;
112
- versions[packageEntry.repoPath] = packageEntry.content.version;
113
- }
114
- return versions;
115
- };
116
- export const readMinPackageVersion = async (rootDir) => {
117
- const versions = await readPackageVersions(rootDir);
118
- const splitVersions = Object.values(versions).map(splitVersion);
119
- if (splitVersions.length === 0)
120
- return null;
121
- splitVersions.sort(compareVersions);
122
- return concatVersion(splitVersions[0]);
123
- };