@mxpicture/build-api 0.2.20 → 0.2.22
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.
|
@@ -3,11 +3,10 @@ import { WorkspacePaths } from "../workspace/WorkspacePaths.js";
|
|
|
3
3
|
export declare const runSyncPkgVersion: (params: SyncPkgVersionParams) => Promise<void>;
|
|
4
4
|
export declare class SyncPkgVersion {
|
|
5
5
|
protected readonly paths: WorkspacePaths;
|
|
6
|
-
protected readonly bump
|
|
7
|
-
|
|
6
|
+
protected readonly bump: BumpParams | null;
|
|
7
|
+
protected readonly noTag: boolean;
|
|
8
|
+
constructor(paths: WorkspacePaths, bump: BumpParams | null, noTag: boolean);
|
|
8
9
|
run(): Promise<void>;
|
|
9
10
|
protected read(): Promise<PackageEntry[]>;
|
|
10
|
-
protected
|
|
11
|
-
protected write(entries: PackageEntry[]): Promise<void>;
|
|
12
|
-
protected writeRoot(entry: PackageEntry): Promise<void>;
|
|
11
|
+
protected write(packages: PackageEntry[]): Promise<void>;
|
|
13
12
|
}
|
|
@@ -1,45 +1,56 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { readPackageEntries, readPackageEntryThrow, writePackageEntries,
|
|
2
|
+
import { readPackageEntries, readPackageEntryThrow, writePackageEntries, } from "../workspace/workspace.pkg.js";
|
|
3
3
|
import { WorkspacePaths } from "../workspace/WorkspacePaths.js";
|
|
4
4
|
import { bumpVersion, compareVersionsGT, concatVersion, splitVersion, } from "./pkg.common.js";
|
|
5
|
-
|
|
5
|
+
import { verifiedGit } from "../git/git.util.js";
|
|
6
|
+
export const runSyncPkgVersion = async (params) => new SyncPkgVersion(WorkspacePaths.instance(params.repoRoot, params.workspacesName), params.noBump ? null : (params.bump ?? { patch: true }), !!params.noTag).run();
|
|
6
7
|
export class SyncPkgVersion {
|
|
7
8
|
paths;
|
|
8
9
|
bump;
|
|
9
|
-
|
|
10
|
+
noTag;
|
|
11
|
+
constructor(paths, bump, noTag) {
|
|
10
12
|
this.paths = paths;
|
|
11
13
|
this.bump = bump;
|
|
14
|
+
this.noTag = noTag;
|
|
12
15
|
}
|
|
13
16
|
async run() {
|
|
14
|
-
const
|
|
15
|
-
let maxVersion =
|
|
16
|
-
|
|
17
|
+
const packages = await this.read();
|
|
18
|
+
let maxVersion = {
|
|
19
|
+
major: 0,
|
|
20
|
+
minor: 0,
|
|
21
|
+
patch: 0,
|
|
22
|
+
prefix: null,
|
|
23
|
+
};
|
|
24
|
+
for (const entry of packages) {
|
|
17
25
|
const version = splitVersion(entry.content.version);
|
|
18
26
|
if (compareVersionsGT(version, maxVersion))
|
|
19
27
|
maxVersion = version;
|
|
20
28
|
}
|
|
21
29
|
// bump
|
|
22
|
-
|
|
30
|
+
if (this.bump)
|
|
31
|
+
maxVersion = bumpVersion(maxVersion, this.bump);
|
|
23
32
|
const newVersion = concatVersion(maxVersion);
|
|
24
33
|
// set/update
|
|
25
|
-
|
|
26
|
-
root.modified = true;
|
|
27
|
-
for (const entry of entries) {
|
|
34
|
+
for (const entry of packages) {
|
|
28
35
|
entry.content.version = newVersion;
|
|
29
36
|
entry.modified = true;
|
|
30
37
|
}
|
|
31
|
-
await
|
|
38
|
+
await this.write(packages);
|
|
39
|
+
// create tag
|
|
40
|
+
if (!this.noTag) {
|
|
41
|
+
const git = await verifiedGit(this.paths.repoRoot);
|
|
42
|
+
await git.addAnnotatedTag(`v${newVersion}`, `Release v${newVersion}`);
|
|
43
|
+
await git.pushTags();
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
46
|
async read() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
async write(entries) {
|
|
40
|
-
await writePackageEntries(entries);
|
|
47
|
+
const [packages, root] = await Promise.all([
|
|
48
|
+
readPackageEntries(this.paths.repoRoot),
|
|
49
|
+
readPackageEntryThrow(join(this.paths.repoRoot, "package.json")),
|
|
50
|
+
]);
|
|
51
|
+
return [...packages, root];
|
|
41
52
|
}
|
|
42
|
-
async
|
|
43
|
-
await
|
|
53
|
+
async write(packages) {
|
|
54
|
+
await writePackageEntries(packages);
|
|
44
55
|
}
|
|
45
56
|
}
|
|
@@ -81,11 +81,13 @@ export class UpdatePackages {
|
|
|
81
81
|
// Group by package name to identify duplicates
|
|
82
82
|
const packageVersions = new Map();
|
|
83
83
|
for (const dir of versionDirs) {
|
|
84
|
-
const match = dir.match(
|
|
84
|
+
const match = dir.match(/\/(@?[a-z-+]+)@(.+)$/);
|
|
85
85
|
if (!match)
|
|
86
86
|
continue;
|
|
87
87
|
const [, pkgName, version] = match;
|
|
88
|
-
|
|
88
|
+
if (!micromatch.isMatch(pkgName, this.patternWoSlash))
|
|
89
|
+
continue;
|
|
90
|
+
const key = pkgName.replace(/\+/g, "/");
|
|
89
91
|
if (!packageVersions.has(key))
|
|
90
92
|
packageVersions.set(key, []);
|
|
91
93
|
packageVersions.get(key).push(version.split("_")[0]); // Remove peer dep suffixes
|
|
@@ -34,6 +34,8 @@ export interface BumpParams {
|
|
|
34
34
|
}
|
|
35
35
|
export interface SyncPkgVersionParams extends RunRepoRootWsParams {
|
|
36
36
|
bump?: BumpParams;
|
|
37
|
+
noBump?: boolean;
|
|
38
|
+
noTag?: boolean;
|
|
37
39
|
}
|
|
38
40
|
export interface UpdatePackagesParams extends RunRepoRootWsParams {
|
|
39
41
|
pattern: string;
|