@dbx-tools/projen 0.6.36 → 0.6.38

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 (2) hide show
  1. package/package.json +4 -4
  2. package/tasks/bump.ts +27 -3
package/package.json CHANGED
@@ -9,9 +9,9 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@clack/prompts": "^1.7.0",
12
- "@dbx-tools/core": "^0.3.40",
13
- "@dbx-tools/path": "^0.3.40",
14
- "@dbx-tools/shared-core": "^0.3.40",
12
+ "@dbx-tools/core": "^0.6.37",
13
+ "@dbx-tools/path": "^0.6.37",
14
+ "@dbx-tools/shared-core": "^0.6.37",
15
15
  "commander": "^15.0.0",
16
16
  "concurrently": "^10.0.3",
17
17
  "constructs": "^10.6.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "main": "index.ts",
34
34
  "license": "Apache-2.0",
35
- "version": "0.6.36",
35
+ "version": "0.6.38",
36
36
  "types": "index.ts",
37
37
  "type": "module",
38
38
  "exports": {
package/tasks/bump.ts CHANGED
@@ -47,6 +47,12 @@ import { resolve } from "node:path";
47
47
 
48
48
  const logger = log.logger("projen:bump");
49
49
  const LEVELS = ["patch", "minor", "major"] as const;
50
+ const DEPENDENCY_FIELDS = [
51
+ "dependencies",
52
+ "devDependencies",
53
+ "optionalDependencies",
54
+ "peerDependencies",
55
+ ] as const;
50
56
  type Level = (typeof LEVELS)[number];
51
57
 
52
58
  /** A standalone in-repo project released alongside the root, on its own tag prefix. */
@@ -124,18 +130,35 @@ function readPackageVersion(pkgPath: string): [number, number, number] {
124
130
  * the write is bracketed by a chmod; the mode is restored afterwards to leave the
125
131
  * tree exactly as synth left it.
126
132
  */
127
- function writeManifestVersion(pkgPath: string, version: string): void {
133
+ function writeManifestVersion(pkgPath: string, version: string, dependencyScope?: string): void {
128
134
  const { mode } = statSync(pkgPath);
129
135
  chmodSync(pkgPath, mode | 0o200);
130
136
  try {
131
137
  const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as Record<string, unknown>;
132
138
  pkg.version = version;
139
+ if (dependencyScope) {
140
+ for (const field of DEPENDENCY_FIELDS) {
141
+ const dependencies = pkg[field];
142
+ if (!dependencies || typeof dependencies !== "object") continue;
143
+ for (const name of Object.keys(dependencies)) {
144
+ if (name.startsWith(dependencyScope)) {
145
+ (dependencies as Record<string, string>)[name] = `^${version}`;
146
+ }
147
+ }
148
+ }
149
+ }
133
150
  writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
134
151
  } finally {
135
152
  chmodSync(pkgPath, mode);
136
153
  }
137
154
  }
138
155
 
156
+ /** Scoped package prefix (`@scope/`) shared by the root's release packages. */
157
+ function releaseDependencyScope(pkgPath: string): string | undefined {
158
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as { name?: string };
159
+ return /^@[^/]+\//.exec(pkg.name ?? "")?.[0];
160
+ }
161
+
139
162
  /**
140
163
  * Resolve the `--local-registry` value to a registry URL to publish to, or
141
164
  * `undefined` to skip. `false` skips; a URL is used as-is; `auto` uses the
@@ -194,6 +217,7 @@ program
194
217
  }) => {
195
218
  const pkgPath = resolve(process.cwd(), "package.json");
196
219
  if (!existsSync(pkgPath)) throw new Error(`no package.json in ${process.cwd()}`);
220
+ const dependencyScope = releaseDependencyScope(pkgPath);
197
221
 
198
222
  const siblings = opts.sibling.map((s) => ({ ...s, pkgPath: resolve(s.dir, "package.json") }));
199
223
  for (const s of siblings) {
@@ -241,7 +265,7 @@ program
241
265
 
242
266
  if (opts.version) {
243
267
  writeManifestVersion(pkgPath, version);
244
- for (const s of siblings) writeManifestVersion(s.pkgPath, version);
268
+ for (const s of siblings) writeManifestVersion(s.pkgPath, version, dependencyScope);
245
269
  const also = siblings.length ? ` (and ${siblings.map((s) => s.dir).join(", ")})` : "";
246
270
  logger.info(`wrote version ${version} to package.json${also}`);
247
271
  }
@@ -340,7 +364,7 @@ program
340
364
  // manifest finish the bump in lockstep.
341
365
  if (opts.version) {
342
366
  writeManifestVersion(pkgPath, version);
343
- for (const s of siblings) writeManifestVersion(s.pkgPath, version);
367
+ for (const s of siblings) writeManifestVersion(s.pkgPath, version, dependencyScope);
344
368
  logger.info(`synchronized release manifests at ${version}`);
345
369
  }
346
370
  },