@nx/js 23.3.0-beta.0 → 23.3.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.
|
@@ -39,6 +39,19 @@ function isAlreadyPublishedPublishError(stdoutData, stderr = '', stdout = '') {
|
|
|
39
39
|
(error?.code === 'E409' &&
|
|
40
40
|
errorMessage.includes('this package is already present')));
|
|
41
41
|
}
|
|
42
|
+
function isNpmViewNotFoundError(err) {
|
|
43
|
+
if (err.code === 'ENOBUFS' || err.signal) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const errorCode = JSON.parse(err.stdout?.toString() || '{}').error?.code;
|
|
48
|
+
if (errorCode) {
|
|
49
|
+
return errorCode === 'E404';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch { }
|
|
53
|
+
return /(?:^|\n)npm (?:ERR!|error) code E404(?:\n|$)/i.test(err.stderr?.toString() || '');
|
|
54
|
+
}
|
|
42
55
|
async function runExecutor(options, context) {
|
|
43
56
|
const pm = (0, devkit_1.detectPackageManager)();
|
|
44
57
|
// Check if npm is installed (needed for dist-tag management and as fallback for view command)
|
|
@@ -146,10 +159,11 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
|
|
|
146
159
|
}, warnFn);
|
|
147
160
|
// Use bun info when bun is the package manager, otherwise use npm view
|
|
148
161
|
// (npm view works across npm/pnpm/yarn environments and is the established default)
|
|
162
|
+
const npmViewDistTagField = `dist-tags[${tag}]`;
|
|
149
163
|
const npmViewCommandSegments = pm === 'bun'
|
|
150
164
|
? ['bun info', packageName, `--json --"${registryConfigKey}=${registry}"`]
|
|
151
165
|
: [
|
|
152
|
-
`npm view ${packageName}
|
|
166
|
+
`npm view ${packageName}@${packageJson.version} name version "${npmViewDistTagField}" --json --"${registryConfigKey}=${registry}"`,
|
|
153
167
|
];
|
|
154
168
|
const npmDistTagAddCommandSegments = [
|
|
155
169
|
`npm dist-tag add ${packageName}@${packageJson.version} ${tag} --"${registryConfigKey}=${registry}"`,
|
|
@@ -171,20 +185,47 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
|
|
|
171
185
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
172
186
|
windowsHide: true,
|
|
173
187
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
188
|
+
// `npm view`/`bun info` can exit 0 with empty stdout when the package exists in the registry but has
|
|
189
|
+
// no published versions or dist-tags yet (e.g. GitHub packages). Treat empty output the same as
|
|
190
|
+
// package not existing yet and continue to the publish step.
|
|
191
|
+
const output = result.toString().trim();
|
|
192
|
+
let distTagVersion;
|
|
193
|
+
let versionExists;
|
|
194
|
+
if (!output) {
|
|
195
|
+
versionExists = false;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const resultJson = JSON.parse(output);
|
|
199
|
+
if (pm === 'bun') {
|
|
200
|
+
distTagVersion = resultJson['dist-tags']?.[tag];
|
|
201
|
+
versionExists = (Array.isArray(resultJson.versions)
|
|
202
|
+
? resultJson.versions
|
|
203
|
+
: [resultJson.versions]).includes(currentVersion);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
const metadataEntries = Array.isArray(resultJson)
|
|
207
|
+
? resultJson
|
|
208
|
+
: [resultJson];
|
|
209
|
+
const currentVersionMetadata = metadataEntries.find((metadata) => metadata?.name === packageName &&
|
|
210
|
+
metadata?.version === currentVersion);
|
|
211
|
+
if (!currentVersionMetadata) {
|
|
212
|
+
console.error(`Something unexpected went wrong when checking for existing dist-tags. The registry returned metadata that did not match ${packageName}@${currentVersion}.`);
|
|
213
|
+
return {
|
|
214
|
+
success: false,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
distTagVersion = currentVersionMetadata[npmViewDistTagField];
|
|
218
|
+
versionExists = true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (distTagVersion === currentVersion) {
|
|
177
222
|
console.warn(`Skipped ${packageTxt} because v${currentVersion} already exists in ${registry} with tag "${tag}"`);
|
|
178
223
|
return {
|
|
179
224
|
success: true,
|
|
180
225
|
};
|
|
181
226
|
}
|
|
182
227
|
if (isNpmInstalled) {
|
|
183
|
-
|
|
184
|
-
const versions = Array.isArray(resultJson.versions)
|
|
185
|
-
? resultJson.versions
|
|
186
|
-
: [resultJson.versions];
|
|
187
|
-
if (versions.includes(currentVersion)) {
|
|
228
|
+
if (versionExists) {
|
|
188
229
|
try {
|
|
189
230
|
if (!isDryRun) {
|
|
190
231
|
(0, child_process_1.execSync)(npmDistTagAddCommandSegments.join(' '), {
|
|
@@ -245,35 +286,15 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
|
|
|
245
286
|
}
|
|
246
287
|
}
|
|
247
288
|
catch (err) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
err.stderr?.toString().toLowerCase().includes('not found'))) {
|
|
258
|
-
console.error(`Something unexpected went wrong when checking for existing dist-tags.\n`, err);
|
|
259
|
-
return {
|
|
260
|
-
success: false,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
catch {
|
|
265
|
-
// JSON parse failed entirely — check stderr/stdout for plain 404
|
|
266
|
-
const stderrStr = err.stderr?.toString() || '';
|
|
267
|
-
const stdoutStr = err.stdout?.toString() || '';
|
|
268
|
-
if (!((stderrStr.includes('404') &&
|
|
269
|
-
stderrStr.toLowerCase().includes('not found')) ||
|
|
270
|
-
(stdoutStr.includes('404') &&
|
|
271
|
-
stdoutStr.toLowerCase().includes('not found')))) {
|
|
272
|
-
console.error(`Something unexpected went wrong when checking for existing dist-tags.\n`, err);
|
|
273
|
-
return {
|
|
274
|
-
success: false,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
289
|
+
const isNotFound = pm === 'bun'
|
|
290
|
+
? [err.stderr?.toString(), err.stdout?.toString()].some((output) => output?.includes('404') &&
|
|
291
|
+
output.toLowerCase().includes('not found'))
|
|
292
|
+
: isNpmViewNotFoundError(err);
|
|
293
|
+
if (!isNotFound) {
|
|
294
|
+
console.error(`Something unexpected went wrong when checking for existing dist-tags.\n`, err);
|
|
295
|
+
return {
|
|
296
|
+
success: false,
|
|
297
|
+
};
|
|
277
298
|
}
|
|
278
299
|
}
|
|
279
300
|
}
|
|
@@ -125,6 +125,7 @@ exports.createNodesV2 = [
|
|
|
125
125
|
configOwners: new Map(),
|
|
126
126
|
projectContexts: new Map(),
|
|
127
127
|
configContexts: new Map(),
|
|
128
|
+
referenceExpansionCache: new Map(),
|
|
128
129
|
});
|
|
129
130
|
const cache = cacheStore.get(cacheKey);
|
|
130
131
|
initializeTsConfigCache(configFilePaths, context.workspaceRoot, cache);
|
|
@@ -701,62 +702,100 @@ function getExternalProjectReferenceTsconfigPatterns(tsConfig, internalProjectRe
|
|
|
701
702
|
continue;
|
|
702
703
|
}
|
|
703
704
|
visited.add(configPath);
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
705
|
+
const expansion = getReferenceExpansion(configPath, ownerProject, workspaceRoot, cache);
|
|
706
|
+
// Extended-config patterns follow the traversal's first-visit semantics.
|
|
707
|
+
for (const extended of expansion.extendedConfigs) {
|
|
708
|
+
if (visited.has(extended.configPath)) {
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
uniqueRelPaths.add(extended.pattern);
|
|
712
|
+
worklist.push({
|
|
713
|
+
configPath: extended.configPath,
|
|
714
|
+
ownerProject: extended.ownerProject,
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
// Reference patterns are collected even when traversal already visited them.
|
|
718
|
+
for (const ref of expansion.projectReferences) {
|
|
719
|
+
if (ref.pattern !== undefined) {
|
|
720
|
+
uniqueRelPaths.add(ref.pattern);
|
|
721
|
+
}
|
|
722
|
+
if (!visited.has(ref.configPath)) {
|
|
723
|
+
worklist.push({
|
|
724
|
+
configPath: ref.configPath,
|
|
725
|
+
ownerProject: ref.ownerProject,
|
|
726
|
+
});
|
|
727
|
+
}
|
|
708
728
|
}
|
|
729
|
+
}
|
|
730
|
+
return Array.from(uniqueRelPaths).map((relPath) => `^{projectRoot}/${relPath}`);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Returns a config's immediate `extends` and project-reference expansion for
|
|
734
|
+
* the current owner, caching it for reuse within this invocation. Transitive
|
|
735
|
+
* traversal, ordering, and visited checks remain with the caller.
|
|
736
|
+
*/
|
|
737
|
+
function getReferenceExpansion(configPath, ownerProject, workspaceRoot, cache) {
|
|
738
|
+
const configKey = posixRelative(workspaceRoot, configPath);
|
|
739
|
+
// Reference classification and relative patterns depend on the owner.
|
|
740
|
+
const ownerKey = ownerProject.normalized;
|
|
741
|
+
let ownerCache = cache.referenceExpansionCache.get(configKey);
|
|
742
|
+
const cached = ownerCache?.get(ownerKey);
|
|
743
|
+
if (cached) {
|
|
744
|
+
return cached;
|
|
745
|
+
}
|
|
746
|
+
const expansion = {
|
|
747
|
+
extendedConfigs: [],
|
|
748
|
+
projectReferences: [],
|
|
749
|
+
};
|
|
750
|
+
const tsConfigData = tsConfigCacheData[configKey]?.data;
|
|
751
|
+
if (tsConfigData) {
|
|
709
752
|
// Walk `extends` chains for the visited tsconfig. tsc reads extended
|
|
710
753
|
// configs while resolving project references, so the rel paths must be
|
|
711
754
|
// emitted as inputs. Workspace-root files (no owning project) are skipped
|
|
712
755
|
// — those are covered by the local project's own extends walk.
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
});
|
|
730
|
-
}
|
|
756
|
+
for (const extended of tsConfigData.extendedConfigFiles ?? []) {
|
|
757
|
+
if (!extended.filePath) {
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
const extendedWsRelPath = posixRelative(workspaceRoot, extended.filePath);
|
|
761
|
+
if (!tsConfigCacheData[extendedWsRelPath]) {
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
const extendedContext = getConfigContext(extended.filePath, workspaceRoot, cache);
|
|
765
|
+
if (extendedContext.project.root &&
|
|
766
|
+
extendedContext.project.root !== '.') {
|
|
767
|
+
expansion.extendedConfigs.push({
|
|
768
|
+
configPath: extended.filePath,
|
|
769
|
+
ownerProject: extendedContext.project,
|
|
770
|
+
pattern: posixRelative(extendedContext.project.absolute, extended.filePath),
|
|
771
|
+
});
|
|
731
772
|
}
|
|
732
773
|
}
|
|
733
|
-
|
|
734
|
-
continue;
|
|
735
|
-
}
|
|
736
|
-
for (const ref of tsConfigData.projectReferences) {
|
|
774
|
+
for (const ref of tsConfigData.projectReferences ?? []) {
|
|
737
775
|
let refPath = ref.path;
|
|
738
776
|
if (!refPath.endsWith('.json')) {
|
|
739
777
|
refPath = (0, node_path_1.join)(refPath, 'tsconfig.json');
|
|
740
778
|
}
|
|
741
|
-
//
|
|
779
|
+
// References absent from the invocation's tsconfig data remain ignored.
|
|
742
780
|
const refWsRelPath = posixRelative(workspaceRoot, refPath);
|
|
743
781
|
if (!tsConfigCacheData[refWsRelPath]) {
|
|
744
782
|
continue;
|
|
745
783
|
}
|
|
746
784
|
const refContext = getConfigContext(refPath, workspaceRoot, cache);
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
});
|
|
756
|
-
}
|
|
785
|
+
expansion.projectReferences.push({
|
|
786
|
+
configPath: refPath,
|
|
787
|
+
ownerProject: refContext.project,
|
|
788
|
+
// Only references owned by this project contribute input patterns.
|
|
789
|
+
pattern: isExternalProjectReference(refContext, ownerProject, workspaceRoot, cache)
|
|
790
|
+
? undefined
|
|
791
|
+
: posixRelative(ownerProject.absolute, refPath),
|
|
792
|
+
});
|
|
757
793
|
}
|
|
758
794
|
}
|
|
759
|
-
|
|
795
|
+
ownerCache ??= new Map();
|
|
796
|
+
ownerCache.set(ownerKey, expansion);
|
|
797
|
+
cache.referenceExpansionCache.set(configKey, ownerCache);
|
|
798
|
+
return expansion;
|
|
760
799
|
}
|
|
761
800
|
function isExternalProjectReference(refConfig, project, workspaceRoot, cache) {
|
|
762
801
|
const owner = cache.configOwners.get(refConfig.relativePath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "23.3.0-beta.
|
|
3
|
+
"version": "23.3.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -147,18 +147,18 @@
|
|
|
147
147
|
"source-map-support": "0.5.19",
|
|
148
148
|
"tinyglobby": "^0.2.12",
|
|
149
149
|
"tslib": "^2.3.0",
|
|
150
|
-
"@nx/
|
|
151
|
-
"@nx/
|
|
150
|
+
"@nx/workspace": "23.3.0-beta.2",
|
|
151
|
+
"@nx/devkit": "23.3.0-beta.2"
|
|
152
152
|
},
|
|
153
153
|
"devDependencies": {
|
|
154
|
-
"@nx/
|
|
155
|
-
"@nx/
|
|
156
|
-
"@nx/
|
|
157
|
-
"@nx/oxlint": "23.3.0-beta.
|
|
158
|
-
"@nx/
|
|
159
|
-
"nx": "23.3.0-beta.
|
|
160
|
-
"
|
|
161
|
-
"@nx/
|
|
154
|
+
"@nx/jest": "23.3.0-beta.2",
|
|
155
|
+
"@nx/esbuild": "23.3.0-beta.2",
|
|
156
|
+
"@nx/eslint": "23.3.0-beta.2",
|
|
157
|
+
"@nx/oxlint": "23.3.0-beta.2",
|
|
158
|
+
"@nx/vitest": "23.3.0-beta.2",
|
|
159
|
+
"@nx/rollup": "23.3.0-beta.2",
|
|
160
|
+
"nx": "23.3.0-beta.2",
|
|
161
|
+
"@nx/vite": "23.3.0-beta.2"
|
|
162
162
|
},
|
|
163
163
|
"peerDependencies": {
|
|
164
164
|
"@swc/cli": ">=0.6.0 <0.9.0",
|