@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?: BumpParams | undefined;
7
- constructor(paths: WorkspacePaths, bump?: BumpParams | undefined);
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 readRoot(): Promise<PackageEntry>;
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, writePackageEntry, } from "../workspace/workspace.pkg.js";
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
- export const runSyncPkgVersion = async (params) => new SyncPkgVersion(WorkspacePaths.instance(params.repoRoot, params.workspacesName), params.bump).run();
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
- constructor(paths, bump) {
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 [entries, root] = await Promise.all([this.read(), this.readRoot()]);
15
- let maxVersion = splitVersion(root.content.version);
16
- for (const entry of entries) {
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
- maxVersion = bumpVersion(maxVersion, this.bump ?? { patch: true });
30
+ if (this.bump)
31
+ maxVersion = bumpVersion(maxVersion, this.bump);
23
32
  const newVersion = concatVersion(maxVersion);
24
33
  // set/update
25
- root.content.version = newVersion;
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 Promise.all([this.write(entries), this.writeRoot(root)]);
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
- return await readPackageEntries(this.paths.repoRoot);
35
- }
36
- async readRoot() {
37
- return readPackageEntryThrow(join(this.paths.repoRoot, "package.json"));
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 writeRoot(entry) {
43
- await writePackageEntry(entry);
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(/@mxpicture\+([^@]+)@(.+)/);
84
+ const match = dir.match(/\/(@?[a-z-+]+)@(.+)$/);
85
85
  if (!match)
86
86
  continue;
87
87
  const [, pkgName, version] = match;
88
- const key = `@mxpicture/${pkgName.replace(/\+/g, "/")}`;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxpicture/build-api",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "Build utilities API",
5
5
  "type": "module",
6
6
  "author": "MXPicture",