Comparing version 0.0.0-pr-29703-8312c59 to 0.0.0-pr-29705-bc2a0dd
{ | ||
"name": "nx", | ||
"version": "0.0.0-pr-29703-8312c59", | ||
"version": "0.0.0-pr-29705-bc2a0dd", | ||
"private": false, | ||
@@ -85,12 +85,12 @@ "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.", | ||
"optionalDependencies": { | ||
"@nx/nx-darwin-arm64": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-darwin-x64": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-freebsd-x64": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-linux-arm-gnueabihf": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-linux-arm64-gnu": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-linux-arm64-musl": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-linux-x64-gnu": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-linux-x64-musl": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-win32-arm64-msvc": "0.0.0-pr-29703-8312c59", | ||
"@nx/nx-win32-x64-msvc": "0.0.0-pr-29703-8312c59" | ||
"@nx/nx-darwin-arm64": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-darwin-x64": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-freebsd-x64": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-linux-arm-gnueabihf": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-linux-arm64-gnu": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-linux-arm64-musl": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-linux-x64-gnu": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-linux-x64-musl": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-win32-arm64-msvc": "0.0.0-pr-29705-bc2a0dd", | ||
"@nx/nx-win32-x64-msvc": "0.0.0-pr-29705-bc2a0dd" | ||
}, | ||
@@ -97,0 +97,0 @@ "nx-migrations": { |
@@ -83,5 +83,11 @@ "use strict"; | ||
...projectConfiguration, | ||
root: undefined, | ||
}; | ||
(0, json_1.writeJson)(tree, packageJsonFile, packageJson); | ||
// We don't want to ever this since it is inferred | ||
delete packageJson.nx.root; | ||
// Only set `nx` property in `package.json` if it is a root project (necessary to mark it as Nx project), | ||
// or if there are properties to be set. If it is empty, then avoid it so we don't add unnecessary boilerplate. | ||
if (projectConfiguration.root === '.' || | ||
Object.keys(packageJson.nx).length > 0) { | ||
(0, json_1.writeJson)(tree, packageJsonFile, packageJson); | ||
} | ||
} | ||
@@ -162,3 +168,7 @@ function updateProjectConfigurationInProjectJson(tree, projectName, projectConfiguration) { | ||
'project.json', | ||
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })), | ||
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true }), (p) => { | ||
const content = tree.read(p, 'utf-8'); | ||
const { load } = require('@zkochan/js-yaml'); | ||
return load(content, { filename: p }); | ||
}, (p) => tree.exists(p)), | ||
]; | ||
@@ -165,0 +175,0 @@ const globbedFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(tree.root, patterns); |
@@ -6,3 +6,3 @@ import { PackageJson } from '../../../../utils/package-json'; | ||
export declare function getHoistedPackageVersion(packageName: string): string; | ||
export type NormalizedPackageJson = Pick<PackageJson, 'name' | 'version' | 'license' | 'dependencies' | 'devDependencies' | 'peerDependencies' | 'peerDependenciesMeta' | 'optionalDependencies'>; | ||
export type NormalizedPackageJson = Pick<PackageJson, 'name' | 'version' | 'license' | 'dependencies' | 'devDependencies' | 'peerDependencies' | 'peerDependenciesMeta' | 'optionalDependencies' | 'packageManager'>; | ||
/** | ||
@@ -9,0 +9,0 @@ * Strip off non-pruning related fields from package.json |
@@ -22,3 +22,3 @@ "use strict"; | ||
function normalizePackageJson(packageJson) { | ||
const { name, version, license, dependencies, devDependencies, peerDependencies, peerDependenciesMeta, optionalDependencies, } = packageJson; | ||
const { name, version, license, dependencies, devDependencies, peerDependencies, peerDependenciesMeta, optionalDependencies, packageManager, } = packageJson; | ||
return { | ||
@@ -33,3 +33,4 @@ name, | ||
optionalDependencies, | ||
packageManager, | ||
}; | ||
} |
@@ -421,14 +421,25 @@ "use strict"; | ||
function generateRootWorkspacePackage(packageJson) { | ||
let isVersion4 = false; | ||
if (!!packageJson.packageManager) { | ||
const [_, version] = packageJson.packageManager.split('@'); | ||
isVersion4 = !!version && (0, semver_1.satisfies)(version, '>=4.0.0'); | ||
} | ||
const reducer = (acc, [name, version]) => { | ||
acc[name] = isVersion4 ? `npm:${version}` : version; | ||
return acc; | ||
}; | ||
return { | ||
version: '0.0.0-use.local', | ||
resolution: `${packageJson.name}@workspace:.`, | ||
...(packageJson.dependencies && { dependencies: packageJson.dependencies }), | ||
...(packageJson.dependencies && { | ||
dependencies: Object.entries(packageJson.dependencies).reduce(reducer, {}), | ||
}), | ||
...(packageJson.peerDependencies && { | ||
peerDependencies: packageJson.peerDependencies, | ||
peerDependencies: Object.entries(packageJson.peerDependencies).reduce(reducer, {}), | ||
}), | ||
...(packageJson.devDependencies && { | ||
devDependencies: packageJson.devDependencies, | ||
devDependencies: Object.entries(packageJson.devDependencies).reduce(reducer, {}), | ||
}), | ||
...(packageJson.optionalDependencies && { | ||
optionalDependencies: packageJson.optionalDependencies, | ||
optionalDependencies: Object.entries(packageJson.optionalDependencies).reduce(reducer, {}), | ||
}), | ||
@@ -435,0 +446,0 @@ languageName: 'unknown', |
@@ -19,2 +19,2 @@ import { NxJsonConfiguration } from '../../config/nx-json'; | ||
*/ | ||
export declare function getGlobPatternsFromPackageManagerWorkspaces(root: string, readJson?: <T extends Object>(path: string) => T): string[]; | ||
export declare function getGlobPatternsFromPackageManagerWorkspaces(root: string, readJson?: <T extends Object>(path: string) => T, readYaml?: <T extends Object>(path: string) => T, exists?: (path: string) => boolean): string[]; |
@@ -154,4 +154,5 @@ "use strict"; | ||
*/ | ||
function getGlobPatternsFromPackageManagerWorkspaces(root, readJson = (path) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, path)) // making this an arg allows us to reuse in devkit | ||
) { | ||
function getGlobPatternsFromPackageManagerWorkspaces(root, | ||
// allow overwriting these args so we can use them in devkit | ||
readJson = (path) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, path)), readYaml = (path) => (0, fileutils_1.readYamlFile)((0, node_path_1.join)(root, path)), exists = (p) => (0, node_fs_1.existsSync)((0, node_path_1.join)(root, p))) { | ||
try { | ||
@@ -163,5 +164,5 @@ const patterns = []; | ||
: packageJson.workspaces?.packages ?? [])); | ||
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(root, 'pnpm-workspace.yaml'))) { | ||
if (exists('pnpm-workspace.yaml')) { | ||
try { | ||
const { packages } = (0, fileutils_1.readYamlFile)((0, node_path_1.join)(root, 'pnpm-workspace.yaml')) ?? {}; | ||
const { packages } = readYaml('pnpm-workspace.yaml') ?? {}; | ||
patterns.push(...normalizePatterns(packages || [])); | ||
@@ -168,0 +169,0 @@ } |
@@ -21,3 +21,3 @@ "use strict"; | ||
return { | ||
outputsPath: (0, path_1.join)(cacheDirectory, hash, 'outputs'), | ||
outputsPath: cacheDirectory, | ||
terminalOutput: terminalOutput ?? oldTerminalOutput, | ||
@@ -31,22 +31,4 @@ code, | ||
}, | ||
store: async (hash, cacheDirectory, terminalOutput, code) => { | ||
// The new db cache places the outputs directly into the cacheDirectory + hash. | ||
// old instances of Nx Cloud expect these outputs to be in cacheDirectory + hash + outputs | ||
// this ensures that everything that was in the cache directory is moved to the outputs directory | ||
const cacheDir = (0, path_1.join)(cacheDirectory, hash); | ||
const outputDir = (0, path_1.join)(cacheDir, 'outputs'); | ||
await (0, promises_1.mkdir)(outputDir, { recursive: true }); | ||
const files = await (0, promises_1.readdir)(cacheDir); | ||
await Promise.all(files.map(async (file) => { | ||
const filePath = (0, path_1.join)(cacheDir, file); | ||
// we don't want to move these files to the outputs directory because they are not artifacts of the task | ||
if (filePath === outputDir || | ||
file === 'code' || | ||
file === 'terminalOutput') { | ||
return; | ||
} | ||
await (0, promises_1.rename)(filePath, (0, path_1.join)(outputDir, file)); | ||
})); | ||
store: async (hash, cacheDirectory, __, code) => { | ||
await (0, promises_1.writeFile)((0, path_1.join)(cacheDirectory, hash, 'code'), code.toString()); | ||
await (0, promises_1.writeFile)((0, path_1.join)(cacheDirectory, hash, 'terminalOutput'), terminalOutput); | ||
return cache.store(hash, cacheDirectory); | ||
@@ -53,0 +35,0 @@ }, |
Sorry, the diff of this file is not supported yet
54229
8291839