@mxpicture/build-api 0.2.21 → 0.2.23
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 +3 -4
- package/dist/barrel/Barrel.js +27 -28
- package/dist/changes/Changes.d.ts +6 -0
- package/dist/changes/Changes.js +15 -0
- package/dist/changes/index.d.ts +1 -0
- package/dist/changes/index.js +2 -0
- package/dist/cleanup/Cleanup.d.ts +1 -4
- package/dist/cleanup/Cleanup.js +11 -15
- package/dist/common/common.json.d.ts +2 -0
- package/dist/common/common.json.js +3 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +1 -0
- package/dist/deps/FixWorkspaceDeps.d.ts +6 -5
- package/dist/deps/FixWorkspaceDeps.js +31 -26
- package/dist/git/GitChanges.d.ts +8 -5
- package/dist/git/GitChanges.js +22 -17
- package/dist/git/git.util.d.ts +4 -0
- package/dist/git/git.util.js +6 -0
- package/dist/npmPublish/NpmPublisher.d.ts +3 -3
- package/dist/npmPublish/NpmPublisher.js +12 -17
- package/dist/osInfo/osInfo.common.d.ts +2 -0
- package/dist/osInfo/osInfo.common.js +4 -0
- package/dist/pkg/Pkg.d.ts +24 -0
- package/dist/pkg/Pkg.js +74 -0
- package/dist/pkg/SyncPkgVersion.d.ts +7 -9
- package/dist/pkg/SyncPkgVersion.js +31 -25
- package/dist/pkg/UpdatePackages.d.ts +4 -6
- package/dist/pkg/UpdatePackages.js +12 -11
- package/dist/pkg/index.d.ts +2 -0
- package/dist/pkg/index.js +2 -0
- package/dist/pkg/pkg.fs.d.ts +5 -0
- package/dist/pkg/pkg.fs.js +11 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/types.barrel.d.ts +5 -6
- package/dist/types/types.cleanup.d.ts +2 -2
- package/dist/types/types.deps.d.ts +5 -4
- package/dist/types/types.git.d.ts +2 -2
- package/dist/types/types.npm.d.ts +2 -2
- package/dist/types/types.package.d.ts +8 -12
- package/dist/types/types.run.d.ts +1 -5
- package/dist/vscode/vscode.settings.d.ts +2 -0
- package/dist/vscode/vscode.settings.js +4 -0
- package/dist/vscode/vscode.storage.d.ts +2 -0
- package/dist/vscode/vscode.storage.js +4 -0
- package/dist/workspace/Workspace.d.ts +25 -0
- package/dist/workspace/Workspace.js +70 -0
- package/dist/workspace/WorkspacePaths.d.ts +1 -7
- package/dist/workspace/WorkspacePaths.js +30 -30
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/workspace.common.d.ts +2 -0
- package/dist/workspace/workspace.common.js +4 -0
- package/package.json +4 -4
- package/dist/types/types.changeset.d.ts +0 -2
- package/dist/types/types.changeset.js +0 -1
- package/dist/workspace/workspace.pkg.d.ts +0 -15
- package/dist/workspace/workspace.pkg.js +0 -123
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { stat } from "node:fs/promises";
|
|
2
|
-
import { join, relative, sep } from "node:path";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
1
|
+
// import { stat } from "node:fs/promises";
|
|
2
|
+
// import { join, relative, sep } from "node:path";
|
|
3
|
+
export {};
|
|
4
|
+
// const __instances: Record<string, WorkspacePaths> = {};
|
|
5
|
+
// export class WorkspacePaths {
|
|
6
|
+
// public static instance(
|
|
7
|
+
// repoRoot: string,
|
|
8
|
+
// workspacesName: string = "packages",
|
|
9
|
+
// ): WorkspacePaths {
|
|
10
|
+
// const workspacesDir = join(repoRoot, workspacesName);
|
|
11
|
+
// if (!__instances[workspacesDir])
|
|
12
|
+
// __instances[workspacesDir] = new WorkspacePaths(repoRoot, workspacesDir);
|
|
13
|
+
// return __instances[workspacesDir];
|
|
14
|
+
// }
|
|
15
|
+
// private constructor(
|
|
16
|
+
// public readonly repoRoot: string,
|
|
17
|
+
// public readonly workspacesDir: string,
|
|
18
|
+
// ) {}
|
|
19
|
+
// public async workspaceByPath(path: string): Promise<string | null> {
|
|
20
|
+
// try {
|
|
21
|
+
// const pkgPath = relative(this.workspacesDir, path);
|
|
22
|
+
// const pkg = pkgPath.split(sep).shift();
|
|
23
|
+
// if (!pkg) return null;
|
|
24
|
+
// const pkgJsonPath = join(this.workspacesDir, pkg, "package.json");
|
|
25
|
+
// return (await stat(pkgJsonPath)).isFile() ? pkg : null;
|
|
26
|
+
// } catch {
|
|
27
|
+
// return null;
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
// }
|
package/dist/workspace/index.js
CHANGED
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mxpicture/build-api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.23",
|
|
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 +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
|
-
};
|