@nx/js 24.1.0-beta.0 → 24.1.0-beta.2
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/internal.d.ts +2 -1
- package/dist/internal.js +8 -5
- package/dist/src/executors/copy-workspace-modules/copy-workspace-modules.js +40 -32
- package/dist/src/executors/prune-lockfile/prune-lockfile.js +105 -8
- package/dist/src/executors/verdaccio/placeholder-auth-token.d.ts +8 -0
- package/dist/src/executors/verdaccio/placeholder-auth-token.js +36 -0
- package/dist/src/executors/verdaccio/verdaccio.impl.js +49 -15
- package/dist/src/generators/setup-verdaccio/files/config.yml +8 -0
- package/dist/src/generators/typescript-sync/typescript-sync.js +5 -7
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.d.ts +1 -6
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.js +4 -224
- package/dist/src/migrations/update-23-2-0/add-pnpm-prune-lockfile-cache-config.js +18 -297
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.d.ts +8 -0
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.js +21 -0
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.md +49 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.d.ts +2 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.js +28 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.md +44 -0
- package/dist/src/migrations/update-24-1-0/add-verdaccio-jwt-security.d.ts +10 -0
- package/dist/src/migrations/update-24-1-0/add-verdaccio-jwt-security.js +145 -0
- package/dist/src/migrations/update-24-1-0/add-verdaccio-jwt-security.md +49 -0
- package/dist/src/plugins/jest/start-local-registry.d.ts +4 -4
- package/dist/src/plugins/jest/start-local-registry.js +46 -32
- package/dist/src/release/version-actions.js +6 -0
- package/dist/src/utils/bun-install-settings-inputs.d.ts +20 -0
- package/dist/src/utils/bun-install-settings-inputs.js +31 -0
- package/dist/src/utils/deploy-output-cache-inputs.d.ts +35 -0
- package/dist/src/utils/deploy-output-cache-inputs.js +400 -0
- package/dist/src/utils/pnpm-install-settings-inputs.d.ts +0 -6
- package/dist/src/utils/pnpm-install-settings-inputs.js +0 -6
- package/dist/src/utils/prune-lockfile-cache-config.d.ts +18 -0
- package/dist/src/utils/prune-lockfile-cache-config.js +288 -0
- package/dist/src/utils/target-defaults-matching.d.ts +3 -0
- package/dist/src/utils/target-defaults-matching.js +7 -0
- package/dist/src/utils/workspace-module-sections.d.ts +10 -5
- package/dist/src/utils/workspace-module-sections.js +15 -6
- package/migrations.json +18 -0
- package/package.json +12 -12
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.d.ts +0 -29
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.js +0 -177
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const prune_lockfile_cache_config_1 = require("../../utils/prune-lockfile-cache-config");
|
|
6
|
+
// The `bun patch` files and the vendored local-path dependencies the executor
|
|
7
|
+
// emits next to the pruned lockfile; without them in `outputs`, a cache replay
|
|
8
|
+
// restores only the manifest and the lockfile.
|
|
9
|
+
const ARTIFACTS = ['patches', 'local_path_modules'];
|
|
10
|
+
// The root manifest declares the trusted install scripts and the patches the
|
|
11
|
+
// output carries. The trust list reaches no package's hash, so nothing else in
|
|
12
|
+
// the hash moves when a package is untrusted.
|
|
13
|
+
const ROOT_INPUTS = ['{workspaceRoot}/package.json'];
|
|
14
|
+
async function update(tree) {
|
|
15
|
+
(0, prune_lockfile_cache_config_1.addPruneLockfileCacheConfig)(tree, {
|
|
16
|
+
lockFile: 'bun.lock',
|
|
17
|
+
artifacts: ARTIFACTS,
|
|
18
|
+
rootInputs: ROOT_INPUTS,
|
|
19
|
+
});
|
|
20
|
+
// A target generated on the binary bun.lockb declares that file, and the
|
|
21
|
+
// executor writes the text bun.lock once the workspace switches to it.
|
|
22
|
+
(0, prune_lockfile_cache_config_1.addPruneLockfileCacheConfig)(tree, {
|
|
23
|
+
lockFile: 'bun.lockb',
|
|
24
|
+
artifacts: ['bun.lock', ...ARTIFACTS],
|
|
25
|
+
rootInputs: ROOT_INPUTS,
|
|
26
|
+
});
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#### Update the cache configuration of `@nx/js:prune-lockfile` targets for the Bun install artifacts
|
|
2
|
+
|
|
3
|
+
In a Bun workspace on the text `bun.lock`, the `@nx/js:prune-lockfile` executor now emits a pruned `bun.lock` next to the pruned `package.json`, the `.patch` files of a `bun patch` workspace under `patches/`, and the non-workspace `file:` and `link:` dependencies the output installs under `local_path_modules/`. The emitted `package.json` carries the root `trustedDependencies` list and the `patchedDependencies` of the patches it ships.
|
|
4
|
+
|
|
5
|
+
Targets generated before this change declare only the manifest and the lockfile in `outputs`, so a cache replay in a clean checkout restores just those two files, and `bun install --frozen-lockfile` in the output fails on the missing patch files or vendored packages. The same targets declare no `inputs`, so nothing in the task hash covers the root `trustedDependencies`. Removing a package from that list would replay the previous run's output from cache and ship a manifest that still trusts it. The patch contents and the vendored package contents already reach the task hash through the packages they belong to.
|
|
6
|
+
|
|
7
|
+
The `patches` and `local_path_modules` paths are appended to whichever `outputs` array declares the `bun.lock` entry, reusing that entry's own path prefix. A target generated on the binary `bun.lockb` declares that file instead. It gets the same paths and a `bun.lock` output next to it, because the executor writes the text lockfile once the workspace switches to it. The root `package.json` is added to the `inputs` the target actually uses: its own `inputs` when it declares them, otherwise the `targetDefaults` entry supplying the array it inherits, and otherwise the target itself with nx's own default spelled out first, so nothing that was hashed stops being hashed. Targets on another package manager's lockfile are left alone, as are paths and inputs already present. Placement follows the same rules as the pnpm migration in Nx 23.2 (`update-23-2-0-add-pnpm-prune-lockfile-cache-config`).
|
|
8
|
+
|
|
9
|
+
#### Sample code changes
|
|
10
|
+
|
|
11
|
+
##### Before
|
|
12
|
+
|
|
13
|
+
```json title="apps/app1/project.json"
|
|
14
|
+
{
|
|
15
|
+
"targets": {
|
|
16
|
+
"prune-lockfile": {
|
|
17
|
+
"executor": "@nx/js:prune-lockfile",
|
|
18
|
+
"outputs": [
|
|
19
|
+
"{workspaceRoot}/dist/apps/app1/package.json",
|
|
20
|
+
"{workspaceRoot}/dist/apps/app1/bun.lock"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
##### After
|
|
28
|
+
|
|
29
|
+
```json title="apps/app1/project.json"
|
|
30
|
+
{
|
|
31
|
+
"targets": {
|
|
32
|
+
"prune-lockfile": {
|
|
33
|
+
"executor": "@nx/js:prune-lockfile",
|
|
34
|
+
"inputs": ["default", "^default", "{workspaceRoot}/package.json"],
|
|
35
|
+
"outputs": [
|
|
36
|
+
"{workspaceRoot}/dist/apps/app1/package.json",
|
|
37
|
+
"{workspaceRoot}/dist/apps/app1/bun.lock",
|
|
38
|
+
"{workspaceRoot}/dist/apps/app1/patches",
|
|
39
|
+
"{workspaceRoot}/dist/apps/app1/local_path_modules"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export default function addVerdaccioJwtSecurity(tree: Tree): Promise<{
|
|
3
|
+
nextSteps: string[];
|
|
4
|
+
agentContext: string[];
|
|
5
|
+
skipAgentic?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
nextSteps?: undefined;
|
|
8
|
+
agentContext?: undefined;
|
|
9
|
+
skipAgentic: boolean;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = addVerdaccioJwtSecurity;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
|
+
const js_yaml_1 = require("@zkochan/js-yaml");
|
|
7
|
+
const target_defaults_matching_1 = require("../../utils/target-defaults-matching");
|
|
8
|
+
const VERDACCIO_EXECUTOR = '@nx/js:verdaccio';
|
|
9
|
+
// The groups Verdaccio gives a user that is not logged in
|
|
10
|
+
const ANONYMOUS_GROUPS = new Set(['$all', '$anonymous', '@all', '@anonymous']);
|
|
11
|
+
const JWT_SECURITY_BLOCK = `# jwt tokens make verdaccio 7+ treat the placeholder npm auth token set by nx
|
|
12
|
+
# as anonymous instead of rejecting it
|
|
13
|
+
security:
|
|
14
|
+
api:
|
|
15
|
+
jwt:
|
|
16
|
+
sign:
|
|
17
|
+
expiresIn: 7d
|
|
18
|
+
`;
|
|
19
|
+
const MANUAL_STEP = 'To let Verdaccio 7+ accept the placeholder npm auth token that Nx sets, set `security.api.jwt.sign.expiresIn` (for example to `7d`) in it.';
|
|
20
|
+
async function addVerdaccioJwtSecurity(tree) {
|
|
21
|
+
const nextSteps = [];
|
|
22
|
+
for (const path of findVerdaccioConfigPaths(tree)) {
|
|
23
|
+
if (!tree.exists(path))
|
|
24
|
+
continue;
|
|
25
|
+
const content = tree.read(path, 'utf-8');
|
|
26
|
+
const config = parseYamlMap(content);
|
|
27
|
+
if (!config) {
|
|
28
|
+
nextSteps.push(`Could not parse ${path}. ${MANUAL_STEP}`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (acceptsPlaceholderToken(config))
|
|
32
|
+
continue;
|
|
33
|
+
if (reliesOnLoggedInUsers(config)) {
|
|
34
|
+
nextSteps.push(`${path} relies on logged-in users, so it was not changed. On Verdaccio 7+, npm and bun need a token from \`npm login\` to publish to it. Setting \`security.api.jwt\` would let them publish packages open to anonymous users with the placeholder npm auth token that Nx sets. It would also make existing tokens from \`npm login\` stop working until users log in again.`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if ('security' in config) {
|
|
38
|
+
nextSteps.push(`${path} already has a \`security\` section, so it was not changed. ${MANUAL_STEP}`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const updated = `${content}${content.endsWith('\n') ? '' : '\n'}\n${JWT_SECURITY_BLOCK}`;
|
|
42
|
+
// Appending breaks configs written as a single flow mapping
|
|
43
|
+
if (!parseYamlMap(updated)?.security?.api?.jwt?.sign) {
|
|
44
|
+
nextSteps.push(`Could not update ${path}. ${MANUAL_STEP}`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
tree.write(path, updated);
|
|
48
|
+
}
|
|
49
|
+
return nextSteps.length
|
|
50
|
+
? { nextSteps, agentContext: nextSteps }
|
|
51
|
+
: { skipAgentic: true };
|
|
52
|
+
}
|
|
53
|
+
function findVerdaccioConfigPaths(tree) {
|
|
54
|
+
const targetDefaults = (0, devkit_1.readNxJson)(tree)?.targetDefaults;
|
|
55
|
+
const paths = new Set();
|
|
56
|
+
for (const [projectName, project] of (0, devkit_1.getProjects)(tree)) {
|
|
57
|
+
const projectNode = {
|
|
58
|
+
name: projectName,
|
|
59
|
+
type: project.projectType === 'application' ? 'app' : 'lib',
|
|
60
|
+
data: project,
|
|
61
|
+
};
|
|
62
|
+
for (const [targetName, projectTarget] of Object.entries(project.targets ?? {})) {
|
|
63
|
+
try {
|
|
64
|
+
const target = resolveTarget({ targetName, projectName, projectNode, target: projectTarget }, targetDefaults);
|
|
65
|
+
if (target.executor !== VERDACCIO_EXECUTOR)
|
|
66
|
+
continue;
|
|
67
|
+
for (const options of [
|
|
68
|
+
target.options,
|
|
69
|
+
...Object.values(target.configurations ?? {}),
|
|
70
|
+
]) {
|
|
71
|
+
if (typeof options?.config !== 'string')
|
|
72
|
+
continue;
|
|
73
|
+
const { config } = (0, internal_1.resolveNxTokensInOptions)({ config: options.config }, project, `${projectName}:${targetName}`);
|
|
74
|
+
paths.add((0, devkit_1.joinPathFragments)(config));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Project graph creation fails on targets that cannot be resolved, so no task reads them
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return paths;
|
|
83
|
+
}
|
|
84
|
+
// Like project graph creation: `command` means nx:run-commands, defaults entries incompatible
|
|
85
|
+
// with the target are dropped, and the rest merge in order, so an incompatible one replaces earlier ones
|
|
86
|
+
function resolveTarget(ref, targetDefaults) {
|
|
87
|
+
const root = ref.projectNode.data.root;
|
|
88
|
+
const target = (0, internal_1.resolveCommandSyntacticSugar)(ref.target, root);
|
|
89
|
+
const matchedRef = {
|
|
90
|
+
...ref,
|
|
91
|
+
target,
|
|
92
|
+
matcherExecutor: target.executor,
|
|
93
|
+
};
|
|
94
|
+
const key = targetDefaults
|
|
95
|
+
? (0, target_defaults_matching_1.selectDefaultsKey)(matchedRef, targetDefaults, target.executor)
|
|
96
|
+
: null;
|
|
97
|
+
let defaults;
|
|
98
|
+
for (const entry of (0, target_defaults_matching_1.compatibleDefaultsEntries)(matchedRef, key, targetDefaults)) {
|
|
99
|
+
// The reader merges a key's entries without resolving `command`, so read one at a time
|
|
100
|
+
const matched = (0, internal_1.readTargetDefaultsForTarget)(ref.targetName, { [key]: [entry] }, target.executor, { projectName: ref.projectName, projectNode: ref.projectNode });
|
|
101
|
+
if (matched) {
|
|
102
|
+
defaults = (0, internal_1.mergeTargetConfigurations)((0, internal_1.resolveCommandSyntacticSugar)(matched, root), defaults);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return defaults ? (0, internal_1.mergeTargetConfigurations)(target, defaults) : target;
|
|
106
|
+
}
|
|
107
|
+
// Verdaccio 7+ rejects undecodable tokens only while `security.api.legacy` is on and `jwt` is unset
|
|
108
|
+
function acceptsPlaceholderToken(config) {
|
|
109
|
+
return (config.security?.api?.jwt != null || config.security?.api?.legacy === false);
|
|
110
|
+
}
|
|
111
|
+
// jwt tokens make existing login tokens anonymous, which can lose access under these configs
|
|
112
|
+
function reliesOnLoggedInUsers(config) {
|
|
113
|
+
if (config.publish?.check_owners === true)
|
|
114
|
+
return true;
|
|
115
|
+
// Auth plugins other than htpasswd can grant access or parse tokens their own way
|
|
116
|
+
if (config.auth &&
|
|
117
|
+
typeof config.auth === 'object' &&
|
|
118
|
+
Object.keys(config.auth).some((plugin) => plugin !== 'htpasswd')) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return Object.values(config.packages ?? {}).some((rule) => rule &&
|
|
122
|
+
typeof rule === 'object' &&
|
|
123
|
+
['access', 'publish', 'unpublish', 'stage'].some((action) => {
|
|
124
|
+
// An empty list denies everyone, and empty `unpublish` or `stage` falls back to `publish`
|
|
125
|
+
const groups = normalizeGroups(rule[action]);
|
|
126
|
+
return (groups.length > 0 &&
|
|
127
|
+
!groups.some((group) => ANONYMOUS_GROUPS.has(group)));
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
function normalizeGroups(groups) {
|
|
131
|
+
if (typeof groups === 'string')
|
|
132
|
+
return groups.split(/\s+/).filter(Boolean);
|
|
133
|
+
return Array.isArray(groups) ? groups.map(String) : [];
|
|
134
|
+
}
|
|
135
|
+
function parseYamlMap(content) {
|
|
136
|
+
try {
|
|
137
|
+
const value = (0, js_yaml_1.load)(content);
|
|
138
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
139
|
+
? value
|
|
140
|
+
: undefined;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#### Enable JWT API tokens in Verdaccio configs
|
|
2
|
+
|
|
3
|
+
The `@nx/js:verdaccio` executor and `startLocalRegistry` set a placeholder npm auth token for the local registry, because npm and bun refuse to publish to a registry without one. Verdaccio 7 rejects a token it cannot decode with a 401 error, which breaks `npm publish` and `npm view` against the local registry. With JWT API tokens enabled, Verdaccio 6 and 7 treat the placeholder token as anonymous instead.
|
|
4
|
+
|
|
5
|
+
The migration adds a `security.api.jwt` section to each Verdaccio config file that an `@nx/js:verdaccio` target points at through its `config` option, including target configurations and `targetDefaults` in `nx.json`. Config files that already set `security.api.jwt`, or set `security.api.legacy` to `false`, already accept the placeholder token and stay unchanged.
|
|
6
|
+
|
|
7
|
+
JWT API tokens turn existing tokens from `npm login` into anonymous ones. The migration therefore lists, and leaves unchanged, config files that rely on logged-in users:
|
|
8
|
+
|
|
9
|
+
- a package rule grants `access`, `publish`, `unpublish` or `stage` only to logged-in users
|
|
10
|
+
- `publish.check_owners` is enabled
|
|
11
|
+
- an auth plugin other than `htpasswd` is configured
|
|
12
|
+
|
|
13
|
+
It also lists config files that already have a `security` section, and files it cannot parse or update.
|
|
14
|
+
|
|
15
|
+
In the config files it changes, users who logged in before the migration act as anonymous users until they log in again. Installs and publishes keep working, but `npm whoami` fails on Verdaccio 7. New tokens from `npm login` expire after 7 days.
|
|
16
|
+
|
|
17
|
+
#### Sample code changes
|
|
18
|
+
|
|
19
|
+
##### Before
|
|
20
|
+
|
|
21
|
+
```yaml title=".verdaccio/config.yml"
|
|
22
|
+
storage: ../tmp/local-registry/storage
|
|
23
|
+
|
|
24
|
+
packages:
|
|
25
|
+
'**':
|
|
26
|
+
access: $all
|
|
27
|
+
publish: $all
|
|
28
|
+
unpublish: $all
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
##### After
|
|
32
|
+
|
|
33
|
+
```yaml title=".verdaccio/config.yml"
|
|
34
|
+
storage: ../tmp/local-registry/storage
|
|
35
|
+
|
|
36
|
+
packages:
|
|
37
|
+
'**':
|
|
38
|
+
access: $all
|
|
39
|
+
publish: $all
|
|
40
|
+
unpublish: $all
|
|
41
|
+
|
|
42
|
+
# jwt tokens make verdaccio 7+ treat the placeholder npm auth token set by nx
|
|
43
|
+
# as anonymous instead of rejecting it
|
|
44
|
+
security:
|
|
45
|
+
api:
|
|
46
|
+
jwt:
|
|
47
|
+
sign:
|
|
48
|
+
expiresIn: 7d
|
|
49
|
+
```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This function is used to start a local registry for testing purposes.
|
|
3
3
|
* @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
|
|
4
|
-
* @param storage the storage location for the local registry
|
|
5
|
-
* @param verbose whether to
|
|
6
|
-
* @param clearStorage whether to clear the
|
|
7
|
-
* @param listenAddress the address
|
|
4
|
+
* @param storage the storage location for the local registry, passed to the target as `--storage`
|
|
5
|
+
* @param verbose whether to print the target's stdout until the registry address appears (stderr is always printed)
|
|
6
|
+
* @param clearStorage whether to ask the target to clear the registry storage before starting, passed to the target as `--clear` (default `true`)
|
|
7
|
+
* @param listenAddress the address the target listens on (default `localhost`). It is not passed to the target; the helper waits for `http://<listenAddress>:<port>` in the target's stdout and uses it as the registry URL.
|
|
8
8
|
*/
|
|
9
9
|
export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, listenAddress, }: {
|
|
10
10
|
localRegistryTarget: string;
|
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.startLocalRegistry = startLocalRegistry;
|
|
4
4
|
const internal_1 = require("@nx/devkit/internal");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
+
const placeholder_auth_token_1 = require("../../executors/verdaccio/placeholder-auth-token");
|
|
6
7
|
/**
|
|
7
8
|
* This function is used to start a local registry for testing purposes.
|
|
8
9
|
* @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
|
|
9
|
-
* @param storage the storage location for the local registry
|
|
10
|
-
* @param verbose whether to
|
|
11
|
-
* @param clearStorage whether to clear the
|
|
12
|
-
* @param listenAddress the address
|
|
10
|
+
* @param storage the storage location for the local registry, passed to the target as `--storage`
|
|
11
|
+
* @param verbose whether to print the target's stdout until the registry address appears (stderr is always printed)
|
|
12
|
+
* @param clearStorage whether to ask the target to clear the registry storage before starting, passed to the target as `--clear` (default `true`)
|
|
13
|
+
* @param listenAddress the address the target listens on (default `localhost`). It is not passed to the target; the helper waits for `http://<listenAddress>:<port>` in the target's stdout and uses it as the registry URL.
|
|
13
14
|
*/
|
|
14
15
|
function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorage, listenAddress, }) {
|
|
15
16
|
listenAddress ??= 'localhost';
|
|
@@ -26,37 +27,50 @@ function startLocalRegistry({ localRegistryTarget, storage, verbose, clearStorag
|
|
|
26
27
|
process.stdout.write(data);
|
|
27
28
|
console.log('Waiting for local registry to start...');
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const output = data.toString();
|
|
31
|
+
const addressPrefix = `http://${listenAddress}:`;
|
|
32
|
+
const addressIndex = output.indexOf(addressPrefix);
|
|
33
|
+
if (addressIndex !== -1) {
|
|
34
|
+
childProcess?.stdout?.off('data', listener);
|
|
35
|
+
const port = parseInt(output.slice(addressIndex + addressPrefix.length));
|
|
32
36
|
const registry = `http://${listenAddress}:${port}`;
|
|
33
|
-
const
|
|
37
|
+
const authTokenKey = `//${listenAddress}:${port}/:_authToken`;
|
|
34
38
|
console.log(`Local registry started on ${registry}`);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
(0, placeholder_auth_token_1.isPlaceholderAuthTokenRejected)(registry)
|
|
40
|
+
.then((authTokenRejected) => {
|
|
41
|
+
if (authTokenRejected) {
|
|
42
|
+
(0, placeholder_auth_token_1.warnPlaceholderAuthTokenRejected)(registry);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
(0, child_process_1.execSync)(`npm config set ${authTokenKey} "${placeholder_auth_token_1.PLACEHOLDER_AUTH_TOKEN}" --ws=false`, {
|
|
46
|
+
windowsHide: true,
|
|
47
|
+
});
|
|
48
|
+
process.env[`pnpm_config_${authTokenKey}`] =
|
|
49
|
+
placeholder_auth_token_1.PLACEHOLDER_AUTH_TOKEN;
|
|
50
|
+
process.env.BUN_CONFIG_TOKEN = placeholder_auth_token_1.PLACEHOLDER_AUTH_TOKEN;
|
|
51
|
+
}
|
|
52
|
+
process.env.npm_config_registry = registry;
|
|
53
|
+
// pnpm 11 reads pnpm_config_* env vars instead of npm_config_*, and
|
|
54
|
+
// they take precedence over any registry configured in ~/.npmrc
|
|
55
|
+
process.env.pnpm_config_registry = registry;
|
|
56
|
+
// bun
|
|
57
|
+
process.env.BUN_CONFIG_REGISTRY = registry;
|
|
58
|
+
// yarnv1
|
|
59
|
+
process.env.YARN_REGISTRY = registry;
|
|
60
|
+
// yarnv2
|
|
61
|
+
process.env.YARN_NPM_REGISTRY_SERVER = registry;
|
|
62
|
+
process.env.YARN_UNSAFE_HTTP_WHITELIST = listenAddress;
|
|
63
|
+
console.log('Set npm, pnpm, bun, and yarn config registry to ' + registry);
|
|
64
|
+
resolve(() => {
|
|
65
|
+
childProcess.kill();
|
|
66
|
+
if (!authTokenRejected) {
|
|
67
|
+
(0, child_process_1.execSync)(`npm config delete ${authTokenKey} --ws=false`, {
|
|
68
|
+
windowsHide: true,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
57
71
|
});
|
|
58
|
-
})
|
|
59
|
-
|
|
72
|
+
})
|
|
73
|
+
.catch(reject);
|
|
60
74
|
}
|
|
61
75
|
};
|
|
62
76
|
childProcess?.stdout?.on('data', listener);
|
|
@@ -205,6 +205,12 @@ class JsVersionActions extends release_1.VersionActions {
|
|
|
205
205
|
let version = dependenciesToUpdate[targetProject.projectName];
|
|
206
206
|
if (version !== undefined) {
|
|
207
207
|
if (catalogManager?.isCatalogReference(currentVersion)) {
|
|
208
|
+
const catalogVersion = catalogManager.resolveCatalogReference(tree, dependencyName, currentVersion);
|
|
209
|
+
if (manifestToUpdate.preserveLocalDependencyProtocols &&
|
|
210
|
+
typeof catalogVersion === 'string' &&
|
|
211
|
+
this.isLocalDependencyProtocol(catalogVersion)) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
208
214
|
// collect the catalog updates so we can update the catalog definitions later
|
|
209
215
|
const catalogRef = catalogManager.parseCatalogReference(currentVersion);
|
|
210
216
|
catalogUpdates.push({
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PackageManager } from '@nx/devkit';
|
|
2
|
+
import type { JsonInput } from '@nx/devkit/internal';
|
|
3
|
+
/**
|
|
4
|
+
* Task inputs covering the root package.json fields a pruned Bun deploy output
|
|
5
|
+
* is built from: `trustedDependencies` (the packages allowed to run install
|
|
6
|
+
* scripts) and `patchedDependencies` (the patches it declares and ships).
|
|
7
|
+
* Nothing else in a build target's default hash moves when a package is
|
|
8
|
+
* untrusted, so a target that emits the deploy output must hash these or a
|
|
9
|
+
* cached run replays an output that still trusts it. The patch contents reach
|
|
10
|
+
* the hash through the patched packages' external nodes. The manifest is
|
|
11
|
+
* narrowed to these fields so dependency bumps in the root package.json do
|
|
12
|
+
* not invalidate every build.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BUN_INSTALL_SETTINGS_INPUTS: JsonInput[];
|
|
15
|
+
/**
|
|
16
|
+
* Whether an inferred build target needs {@link BUN_INSTALL_SETTINGS_INPUTS}:
|
|
17
|
+
* the workspace uses Bun with the text bun.lock. On the binary bun.lockb the
|
|
18
|
+
* deploy output is the manifest alone, without the trust list or patches.
|
|
19
|
+
*/
|
|
20
|
+
export declare function shouldIncludeBunInstallSettingsInputs(packageManager: PackageManager, workspaceRoot: string): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BUN_INSTALL_SETTINGS_INPUTS = void 0;
|
|
4
|
+
exports.shouldIncludeBunInstallSettingsInputs = shouldIncludeBunInstallSettingsInputs;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
/**
|
|
8
|
+
* Task inputs covering the root package.json fields a pruned Bun deploy output
|
|
9
|
+
* is built from: `trustedDependencies` (the packages allowed to run install
|
|
10
|
+
* scripts) and `patchedDependencies` (the patches it declares and ships).
|
|
11
|
+
* Nothing else in a build target's default hash moves when a package is
|
|
12
|
+
* untrusted, so a target that emits the deploy output must hash these or a
|
|
13
|
+
* cached run replays an output that still trusts it. The patch contents reach
|
|
14
|
+
* the hash through the patched packages' external nodes. The manifest is
|
|
15
|
+
* narrowed to these fields so dependency bumps in the root package.json do
|
|
16
|
+
* not invalidate every build.
|
|
17
|
+
*/
|
|
18
|
+
exports.BUN_INSTALL_SETTINGS_INPUTS = [
|
|
19
|
+
{
|
|
20
|
+
json: '{workspaceRoot}/package.json',
|
|
21
|
+
fields: ['trustedDependencies', 'patchedDependencies'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Whether an inferred build target needs {@link BUN_INSTALL_SETTINGS_INPUTS}:
|
|
26
|
+
* the workspace uses Bun with the text bun.lock. On the binary bun.lockb the
|
|
27
|
+
* deploy output is the manifest alone, without the trust list or patches.
|
|
28
|
+
*/
|
|
29
|
+
function shouldIncludeBunInstallSettingsInputs(packageManager, workspaceRoot) {
|
|
30
|
+
return (packageManager === 'bun' && (0, fs_1.existsSync)((0, path_1.join)(workspaceRoot, 'bun.lock')));
|
|
31
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type TargetDefaults, type Tree } from '@nx/devkit';
|
|
2
|
+
import { type JsonInput } from '@nx/devkit/internal';
|
|
3
|
+
import { type MatchedTargetRef } from './target-defaults-matching';
|
|
4
|
+
/**
|
|
5
|
+
* A source of the install settings a pruned deploy output carries and its
|
|
6
|
+
* lockfile does not record: a workspace root file, fields of a root JSON file,
|
|
7
|
+
* or a runtime probe.
|
|
8
|
+
*/
|
|
9
|
+
export type DeployOutputSettingsInput = string | JsonInput | {
|
|
10
|
+
runtime: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Adds `settingsInputs` to the `inputs` of build targets that emit the pruned
|
|
14
|
+
* deploy output. The settings those outputs carry reach no lockfile, so
|
|
15
|
+
* without these a changed setting leaves the task hash unchanged and a cached
|
|
16
|
+
* run replays an output that still carries the old one. Inferred targets are
|
|
17
|
+
* covered by the `@nx/webpack` and `@nx/rspack` plugins themselves; this
|
|
18
|
+
* covers the explicitly configured executor targets, plus overlays of inferred
|
|
19
|
+
* targets (a project-level entry, under the exact name or a glob-pattern key
|
|
20
|
+
* matching it, or a matching `targetDefaults` entry) whose replacing `inputs`
|
|
21
|
+
* array discards the plugin-generated one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function addDeployOutputCacheInputsToBuildTargets(tree: Tree, settingsInputs: readonly DeployOutputSettingsInput[]): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Adds the missing `settingsInputs` to the layer whose `inputs` array the
|
|
26
|
+
* runtime actually uses for this target: the target's own `inputs` when it
|
|
27
|
+
* declares them (its array replaces the defaults' rather than merging with
|
|
28
|
+
* it), otherwise the matching `targetDefaults` entry supplying the array it
|
|
29
|
+
* inherits, and otherwise the target itself with nx's own default spelled out
|
|
30
|
+
* first, so nothing that was hashed stops being hashed. Sources the effective
|
|
31
|
+
* inputs already hash, including via a whole-file fileset of a JSON source or
|
|
32
|
+
* a `json` input covering its fields, are left alone; no `'...'` is ever
|
|
33
|
+
* authored. Returns which layer was mutated, or null when nothing was missing.
|
|
34
|
+
*/
|
|
35
|
+
export declare function addDeployOutputCacheInputs(ref: MatchedTargetRef, targetDefaults: TargetDefaults | undefined, executor: string, settingsInputs: readonly DeployOutputSettingsInput[]): 'target' | 'defaults' | null;
|