@smoothbricks/nx-plugin 0.3.7 → 0.3.8
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/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/version-actions.cjs +75 -2
- package/dist/version-actions.d.cts +10 -3
- package/dist/version-actions.d.cts.map +1 -1
- package/package.json +1 -1
- package/src/index.test.ts +2 -0
- package/src/index.ts +5 -0
- package/src/version-actions.cts +105 -7
- package/src/version-actions.test.ts +80 -0
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAgHlC,eAAO,MAAM,aAAa,EAAE,aA4B3B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,11 @@ const CARGO_INPUTS = [
|
|
|
25
25
|
'{projectRoot}/**/Cargo.toml',
|
|
26
26
|
'{projectRoot}/**/Cargo.lock',
|
|
27
27
|
'{projectRoot}/**/.cargo/config.toml',
|
|
28
|
+
// Shell scripts a `.cargo/config.toml` points at — linker, runner, and rustc wrappers — decide
|
|
29
|
+
// what the compiler produces as surely as the config naming them does. Tracking the config
|
|
30
|
+
// without its shims caches an artifact against a toolchain that has since changed. Only `*.sh`
|
|
31
|
+
// is swept: `scripts/` also holds project tooling that has nothing to do with a cargo build.
|
|
32
|
+
'{projectRoot}/scripts/*.sh',
|
|
28
33
|
'!{projectRoot}/**/target/**',
|
|
29
34
|
];
|
|
30
35
|
const CARGO_OUTPUT_INPUTS = [...CARGO_INPUTS, '{projectRoot}/package.json', '{workspaceRoot}/bun.lock'];
|
package/dist/version-actions.cjs
CHANGED
|
@@ -3,6 +3,10 @@ const node_fs_1 = require("node:fs");
|
|
|
3
3
|
const node_path_1 = require("node:path");
|
|
4
4
|
const nxJsVersionActions = require('@nx/js/src/release/version-actions');
|
|
5
5
|
const baseVersionActions = nxJsVersionActions.default ?? nxJsVersionActions;
|
|
6
|
+
// The manifest sections that survive `npm publish` as a consumer's problem. A devDependency is
|
|
7
|
+
// build-time only: it never reaches an installer, so a new version of it changes nothing about
|
|
8
|
+
// the published artifact and is no reason to cut a release.
|
|
9
|
+
const PUBLISHED_DEPENDENCY_FIELDS = ['dependencies', 'peerDependencies', 'optionalDependencies'];
|
|
6
10
|
const afterAllProjectsVersioned = async (cwd, options) => {
|
|
7
11
|
const result = await nxJsVersionActions.afterAllProjectsVersioned(cwd, options);
|
|
8
12
|
// Temporary Bun workaround. Delete this hook together with the CLI lockfile
|
|
@@ -28,7 +32,76 @@ const afterAllProjectsVersioned = async (cwd, options) => {
|
|
|
28
32
|
deletedFiles: result.deletedFiles,
|
|
29
33
|
};
|
|
30
34
|
};
|
|
31
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Version only the dependents a release can actually reach.
|
|
37
|
+
*
|
|
38
|
+
* Nx expands a bump to every reverse edge of the project graph, and that graph cannot answer the
|
|
39
|
+
* question that matters: `@nx/js` merges `dependencies`, `devDependencies`, `peerDependencies`,
|
|
40
|
+
* and `optionalDependencies` into one edge set before the graph is built, so a package that only
|
|
41
|
+
* uses another for its own tests is indistinguishable from one that ships it. Left alone, a fix
|
|
42
|
+
* to a test-only library republishes every package that tests with it — and on macOS that means
|
|
43
|
+
* rebuilding and re-testing native binaries nothing in the release actually changed.
|
|
44
|
+
*
|
|
45
|
+
* `readDependencies` is Nx's sanctioned override for exactly this: `ReleaseGraph`'s reverse-edge
|
|
46
|
+
* map is built from its return value alone, so dropping the dev-only edges here removes those
|
|
47
|
+
* packages from the release, from the platform builds, and from the version data the CLI reads
|
|
48
|
+
* back. Specifier rewriting is unaffected: `updateProjectDependencies` reads the project graph
|
|
49
|
+
* directly, so a package that is versioned on its own merit still gets accurate devDependency
|
|
50
|
+
* pins.
|
|
51
|
+
*/
|
|
52
|
+
class SmoothbricksVersionActions extends baseVersionActions {
|
|
53
|
+
// Nx reads this off the exported module, not off an instance (`loaded.afterAllProjectsVersioned`).
|
|
54
|
+
static afterAllProjectsVersioned = afterAllProjectsVersioned;
|
|
55
|
+
/**
|
|
56
|
+
* The policy itself: keep an edge only when the source manifest declares the target in a
|
|
57
|
+
* section that survives publication.
|
|
58
|
+
*
|
|
59
|
+
* `packageNameOf` returns `null` for anything that is not a workspace project with a readable
|
|
60
|
+
* name — an external `npm:` node, most commonly. Those are kept exactly as the project graph
|
|
61
|
+
* reported them: they are not release projects, so they expand nothing, and keeping them makes
|
|
62
|
+
* this override strictly subtractive on the set that matters.
|
|
63
|
+
*/
|
|
64
|
+
static publishedDependencies(dependencies, manifest, packageNameOf) {
|
|
65
|
+
return dependencies.filter((dependency) => {
|
|
66
|
+
const packageName = packageNameOf(dependency.target);
|
|
67
|
+
if (packageName === null) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return PUBLISHED_DEPENDENCY_FIELDS.some((field) => {
|
|
71
|
+
const section = manifest[field];
|
|
72
|
+
return isRecord(section) && packageName in section;
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async readDependencies(tree, projectGraph) {
|
|
77
|
+
const dependencies = await super.readDependencies(tree, projectGraph);
|
|
78
|
+
const manifest = readManifest(tree, this.projectGraphNode);
|
|
79
|
+
if (!manifest) {
|
|
80
|
+
return dependencies;
|
|
81
|
+
}
|
|
82
|
+
return SmoothbricksVersionActions.publishedDependencies(dependencies, manifest, (projectName) => {
|
|
83
|
+
const node = projectGraph.nodes[projectName];
|
|
84
|
+
const packageName = node ? readManifest(tree, node)?.name : undefined;
|
|
85
|
+
return typeof packageName === 'string' ? packageName : null;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Exported as a typed value, not as the class declaration. `export =` of a class publishes every
|
|
90
|
+
// static as an ESM named import TypeScript can see but Node's CJS lexer cannot, which crashes an
|
|
91
|
+
// `import { publishedDependencies }` at runtime; a const has no members to publish.
|
|
92
|
+
const versionActions = SmoothbricksVersionActions;
|
|
93
|
+
/**
|
|
94
|
+
* Read a project's `package.json` from the version tree, which carries writes earlier projects in
|
|
95
|
+
* this run have already staged.
|
|
96
|
+
*/
|
|
97
|
+
function readManifest(tree, node) {
|
|
98
|
+
const contents = tree.read((0, node_path_1.join)(node.data.root, 'package.json'), 'utf-8');
|
|
99
|
+
if (contents === null) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const parsed = JSON.parse(contents);
|
|
103
|
+
return isRecord(parsed) ? parsed : null;
|
|
104
|
+
}
|
|
32
105
|
function syncBunLockfileVersionsToPackageJson(root) {
|
|
33
106
|
const lockfilePath = (0, node_path_1.join)(root, 'bun.lock');
|
|
34
107
|
if (!(0, node_fs_1.existsSync)(lockfilePath)) {
|
|
@@ -90,4 +163,4 @@ function isRecord(value) {
|
|
|
90
163
|
function escapeRegex(value) {
|
|
91
164
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
92
165
|
}
|
|
93
|
-
module.exports =
|
|
166
|
+
module.exports = versionActions;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import type JsVersionActions from '@nx/js/src/release/version-actions';
|
|
2
|
+
import type { AfterAllProjectsVersioned } from 'nx/release';
|
|
3
|
+
import type { ProjectGraphDependency } from 'nx/src/config/project-graph';
|
|
4
|
+
type JsVersionActionsClass = typeof JsVersionActions & {
|
|
3
5
|
afterAllProjectsVersioned: AfterAllProjectsVersioned;
|
|
4
6
|
};
|
|
5
|
-
|
|
7
|
+
/** The exported shape: the base class plus the statics this module adds. */
|
|
8
|
+
type SmoothbricksVersionActionsClass = JsVersionActionsClass & {
|
|
9
|
+
publishedDependencies(dependencies: readonly ProjectGraphDependency[], manifest: Record<string, unknown>, packageNameOf: (projectName: string) => string | null): ProjectGraphDependency[];
|
|
10
|
+
};
|
|
11
|
+
declare const versionActions: SmoothbricksVersionActionsClass;
|
|
12
|
+
export = versionActions;
|
|
6
13
|
//# sourceMappingURL=version-actions.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-actions.d.cts","sourceRoot":"","sources":["../src/version-actions.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"version-actions.d.cts","sourceRoot":"","sources":["../src/version-actions.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,gBAAgB,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAgB,sBAAsB,EAA2B,MAAM,6BAA6B,CAAC;AAMjH,KAAK,qBAAqB,GAAG,OAAO,gBAAgB,GAAG;IACrD,yBAAyB,EAAE,yBAAyB,CAAC;CACtD,CAAC;AAEF,4EAA4E;AAC5E,KAAK,+BAA+B,GAAG,qBAAqB,GAAG;IAC7D,qBAAqB,CACnB,YAAY,EAAE,SAAS,sBAAsB,EAAE,EAC/C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,aAAa,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GACpD,sBAAsB,EAAE,CAAC;CAC7B,CAAC;AAwGF,QAAA,MAAM,cAAc,EAAE,+BAA4D,CAAC;SAE1E,cAAc"}
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -261,6 +261,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
261
261
|
'{projectRoot}/**/Cargo.toml',
|
|
262
262
|
'{projectRoot}/**/Cargo.lock',
|
|
263
263
|
'{projectRoot}/**/.cargo/config.toml',
|
|
264
|
+
'{projectRoot}/scripts/*.sh',
|
|
264
265
|
'!{projectRoot}/**/target/**',
|
|
265
266
|
]);
|
|
266
267
|
expect(targets['cargo-lint']?.options).toMatchObject({
|
|
@@ -313,6 +314,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
313
314
|
'{projectRoot}/**/Cargo.toml',
|
|
314
315
|
'{projectRoot}/**/Cargo.lock',
|
|
315
316
|
'{projectRoot}/**/.cargo/config.toml',
|
|
317
|
+
'{projectRoot}/scripts/*.sh',
|
|
316
318
|
'!{projectRoot}/**/target/**',
|
|
317
319
|
'{projectRoot}/package.json',
|
|
318
320
|
'{workspaceRoot}/bun.lock',
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,11 @@ const CARGO_INPUTS = [
|
|
|
34
34
|
'{projectRoot}/**/Cargo.toml',
|
|
35
35
|
'{projectRoot}/**/Cargo.lock',
|
|
36
36
|
'{projectRoot}/**/.cargo/config.toml',
|
|
37
|
+
// Shell scripts a `.cargo/config.toml` points at — linker, runner, and rustc wrappers — decide
|
|
38
|
+
// what the compiler produces as surely as the config naming them does. Tracking the config
|
|
39
|
+
// without its shims caches an artifact against a toolchain that has since changed. Only `*.sh`
|
|
40
|
+
// is swept: `scripts/` also holds project tooling that has nothing to do with a cargo build.
|
|
41
|
+
'{projectRoot}/scripts/*.sh',
|
|
37
42
|
'!{projectRoot}/**/target/**',
|
|
38
43
|
];
|
|
39
44
|
const CARGO_OUTPUT_INPUTS = [...CARGO_INPUTS, '{projectRoot}/package.json', '{workspaceRoot}/bun.lock'];
|
package/src/version-actions.cts
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import type
|
|
3
|
+
import type JsVersionActions from '@nx/js/src/release/version-actions';
|
|
4
|
+
import type { AfterAllProjectsVersioned } from 'nx/release';
|
|
5
|
+
import type { ProjectGraph, ProjectGraphDependency, ProjectGraphProjectNode } from 'nx/src/config/project-graph';
|
|
6
|
+
import type { Tree } from 'nx/src/generators/tree';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
// The runtime `require` is what Nx's own loader does with this path, and the concrete
|
|
9
|
+
// `JsVersionActions` type is what makes subclassing it typecheck: `nx/release` only exports the
|
|
10
|
+
// abstract `VersionActions`, whose members this class does not reimplement.
|
|
11
|
+
type JsVersionActionsClass = typeof JsVersionActions & {
|
|
7
12
|
afterAllProjectsVersioned: AfterAllProjectsVersioned;
|
|
8
13
|
};
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
/** The exported shape: the base class plus the statics this module adds. */
|
|
16
|
+
type SmoothbricksVersionActionsClass = JsVersionActionsClass & {
|
|
17
|
+
publishedDependencies(
|
|
18
|
+
dependencies: readonly ProjectGraphDependency[],
|
|
19
|
+
manifest: Record<string, unknown>,
|
|
20
|
+
packageNameOf: (projectName: string) => string | null,
|
|
21
|
+
): ProjectGraphDependency[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const nxJsVersionActions = require('@nx/js/src/release/version-actions') as JsVersionActionsClass & {
|
|
25
|
+
default?: JsVersionActionsClass;
|
|
26
|
+
};
|
|
27
|
+
const baseVersionActions: JsVersionActionsClass = nxJsVersionActions.default ?? nxJsVersionActions;
|
|
28
|
+
|
|
29
|
+
// The manifest sections that survive `npm publish` as a consumer's problem. A devDependency is
|
|
30
|
+
// build-time only: it never reaches an installer, so a new version of it changes nothing about
|
|
31
|
+
// the published artifact and is no reason to cut a release.
|
|
32
|
+
const PUBLISHED_DEPENDENCY_FIELDS = ['dependencies', 'peerDependencies', 'optionalDependencies'] as const;
|
|
12
33
|
|
|
13
34
|
const afterAllProjectsVersioned: AfterAllProjectsVersioned = async (cwd, options) => {
|
|
14
35
|
const result = await nxJsVersionActions.afterAllProjectsVersioned(cwd, options);
|
|
@@ -38,9 +59,86 @@ const afterAllProjectsVersioned: AfterAllProjectsVersioned = async (cwd, options
|
|
|
38
59
|
};
|
|
39
60
|
};
|
|
40
61
|
|
|
41
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Version only the dependents a release can actually reach.
|
|
64
|
+
*
|
|
65
|
+
* Nx expands a bump to every reverse edge of the project graph, and that graph cannot answer the
|
|
66
|
+
* question that matters: `@nx/js` merges `dependencies`, `devDependencies`, `peerDependencies`,
|
|
67
|
+
* and `optionalDependencies` into one edge set before the graph is built, so a package that only
|
|
68
|
+
* uses another for its own tests is indistinguishable from one that ships it. Left alone, a fix
|
|
69
|
+
* to a test-only library republishes every package that tests with it — and on macOS that means
|
|
70
|
+
* rebuilding and re-testing native binaries nothing in the release actually changed.
|
|
71
|
+
*
|
|
72
|
+
* `readDependencies` is Nx's sanctioned override for exactly this: `ReleaseGraph`'s reverse-edge
|
|
73
|
+
* map is built from its return value alone, so dropping the dev-only edges here removes those
|
|
74
|
+
* packages from the release, from the platform builds, and from the version data the CLI reads
|
|
75
|
+
* back. Specifier rewriting is unaffected: `updateProjectDependencies` reads the project graph
|
|
76
|
+
* directly, so a package that is versioned on its own merit still gets accurate devDependency
|
|
77
|
+
* pins.
|
|
78
|
+
*/
|
|
79
|
+
class SmoothbricksVersionActions extends baseVersionActions {
|
|
80
|
+
// Nx reads this off the exported module, not off an instance (`loaded.afterAllProjectsVersioned`).
|
|
81
|
+
static override afterAllProjectsVersioned: AfterAllProjectsVersioned = afterAllProjectsVersioned;
|
|
42
82
|
|
|
43
|
-
|
|
83
|
+
/**
|
|
84
|
+
* The policy itself: keep an edge only when the source manifest declares the target in a
|
|
85
|
+
* section that survives publication.
|
|
86
|
+
*
|
|
87
|
+
* `packageNameOf` returns `null` for anything that is not a workspace project with a readable
|
|
88
|
+
* name — an external `npm:` node, most commonly. Those are kept exactly as the project graph
|
|
89
|
+
* reported them: they are not release projects, so they expand nothing, and keeping them makes
|
|
90
|
+
* this override strictly subtractive on the set that matters.
|
|
91
|
+
*/
|
|
92
|
+
static publishedDependencies(
|
|
93
|
+
dependencies: readonly ProjectGraphDependency[],
|
|
94
|
+
manifest: Record<string, unknown>,
|
|
95
|
+
packageNameOf: (projectName: string) => string | null,
|
|
96
|
+
): ProjectGraphDependency[] {
|
|
97
|
+
return dependencies.filter((dependency) => {
|
|
98
|
+
const packageName = packageNameOf(dependency.target);
|
|
99
|
+
if (packageName === null) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return PUBLISHED_DEPENDENCY_FIELDS.some((field) => {
|
|
103
|
+
const section = manifest[field];
|
|
104
|
+
return isRecord(section) && packageName in section;
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
override async readDependencies(tree: Tree, projectGraph: ProjectGraph): Promise<ProjectGraphDependency[]> {
|
|
110
|
+
const dependencies = await super.readDependencies(tree, projectGraph);
|
|
111
|
+
const manifest = readManifest(tree, this.projectGraphNode);
|
|
112
|
+
if (!manifest) {
|
|
113
|
+
return dependencies;
|
|
114
|
+
}
|
|
115
|
+
return SmoothbricksVersionActions.publishedDependencies(dependencies, manifest, (projectName) => {
|
|
116
|
+
const node = projectGraph.nodes[projectName];
|
|
117
|
+
const packageName = node ? readManifest(tree, node)?.name : undefined;
|
|
118
|
+
return typeof packageName === 'string' ? packageName : null;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Exported as a typed value, not as the class declaration. `export =` of a class publishes every
|
|
124
|
+
// static as an ESM named import TypeScript can see but Node's CJS lexer cannot, which crashes an
|
|
125
|
+
// `import { publishedDependencies }` at runtime; a const has no members to publish.
|
|
126
|
+
const versionActions: SmoothbricksVersionActionsClass = SmoothbricksVersionActions;
|
|
127
|
+
|
|
128
|
+
export = versionActions;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Read a project's `package.json` from the version tree, which carries writes earlier projects in
|
|
132
|
+
* this run have already staged.
|
|
133
|
+
*/
|
|
134
|
+
function readManifest(tree: Tree, node: ProjectGraphProjectNode): Record<string, unknown> | null {
|
|
135
|
+
const contents = tree.read(join(node.data.root, 'package.json'), 'utf-8');
|
|
136
|
+
if (contents === null) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const parsed: unknown = JSON.parse(contents);
|
|
140
|
+
return isRecord(parsed) ? parsed : null;
|
|
141
|
+
}
|
|
44
142
|
|
|
45
143
|
function syncBunLockfileVersionsToPackageJson(root: string): number {
|
|
46
144
|
const lockfilePath = join(root, 'bun.lock');
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
// The published entry point is what `nx.json` names in `release.version.versionActions`, so it is
|
|
3
|
+
// the artifact whose behaviour the release depends on.
|
|
4
|
+
import SmoothbricksVersionActions from '@smoothbricks/nx-plugin/version-actions';
|
|
5
|
+
import type { ProjectGraphDependency } from 'nx/src/config/project-graph';
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Helpers
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
function edge(target: string): ProjectGraphDependency {
|
|
12
|
+
return { source: 'consumer', target, type: 'static' };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Every fixture project's Nx name is its unscoped package name. */
|
|
16
|
+
function packageNameOf(projectName: string): string | null {
|
|
17
|
+
return projectName.startsWith('npm:') ? null : `@smoothbricks/${projectName}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// publishedDependencies
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
describe('publishedDependencies', () => {
|
|
25
|
+
it('keeps every section an installer resolves', () => {
|
|
26
|
+
const manifest = {
|
|
27
|
+
dependencies: { '@smoothbricks/runtime': 'workspace:*' },
|
|
28
|
+
peerDependencies: { '@smoothbricks/host': '^1.0.0' },
|
|
29
|
+
optionalDependencies: { '@smoothbricks/native': 'workspace:*' },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const kept = SmoothbricksVersionActions.publishedDependencies(
|
|
33
|
+
[edge('runtime'), edge('host'), edge('native')],
|
|
34
|
+
manifest,
|
|
35
|
+
packageNameOf,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(kept.map((dependency) => dependency.target)).toEqual(['runtime', 'host', 'native']);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('drops a dev-only edge, because a devDependency bump changes nothing an installer sees', () => {
|
|
42
|
+
const manifest = {
|
|
43
|
+
dependencies: { typia: '13.2.0' },
|
|
44
|
+
devDependencies: { '@smoothbricks/lmao': 'workspace:*' },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
expect(SmoothbricksVersionActions.publishedDependencies([edge('lmao')], manifest, packageNameOf)).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('keeps a package declared in both, because the published section is what ships', () => {
|
|
51
|
+
const manifest = {
|
|
52
|
+
dependencies: { '@smoothbricks/lmao': 'workspace:*' },
|
|
53
|
+
devDependencies: { '@smoothbricks/lmao': 'workspace:*' },
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
expect(
|
|
57
|
+
SmoothbricksVersionActions.publishedDependencies([edge('lmao')], manifest, packageNameOf).map(
|
|
58
|
+
(dependency) => dependency.target,
|
|
59
|
+
),
|
|
60
|
+
).toEqual(['lmao']);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('keeps an edge whose target has no resolvable package name', () => {
|
|
64
|
+
expect(
|
|
65
|
+
SmoothbricksVersionActions.publishedDependencies([edge('npm:typia')], {}, packageNameOf).map(
|
|
66
|
+
(dependency) => dependency.target,
|
|
67
|
+
),
|
|
68
|
+
).toEqual(['npm:typia']);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('drops every workspace edge of a manifest with no published sections', () => {
|
|
72
|
+
expect(
|
|
73
|
+
SmoothbricksVersionActions.publishedDependencies(
|
|
74
|
+
[edge('lmao'), edge('validation')],
|
|
75
|
+
{ devDependencies: { '@smoothbricks/lmao': 'workspace:*', '@smoothbricks/validation': 'workspace:*' } },
|
|
76
|
+
packageNameOf,
|
|
77
|
+
),
|
|
78
|
+
).toEqual([]);
|
|
79
|
+
});
|
|
80
|
+
});
|