nx
Advanced tools
Comparing version 19.3.1 to 19.3.2
{ | ||
"name": "nx", | ||
"version": "19.3.1", | ||
"version": "19.3.2", | ||
"private": false, | ||
@@ -48,4 +48,4 @@ "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.", | ||
"cliui": "^8.0.1", | ||
"dotenv": "~16.3.1", | ||
"dotenv-expand": "~10.0.0", | ||
"dotenv": "~16.4.5", | ||
"dotenv-expand": "~11.0.6", | ||
"enquirer": "~2.3.6", | ||
@@ -74,3 +74,3 @@ "figures": "3.2.0", | ||
"ora": "5.3.0", | ||
"@nrwl/tao": "19.3.1" | ||
"@nrwl/tao": "19.3.2" | ||
}, | ||
@@ -90,12 +90,12 @@ "peerDependencies": { | ||
"optionalDependencies": { | ||
"@nx/nx-darwin-x64": "19.3.1", | ||
"@nx/nx-darwin-arm64": "19.3.1", | ||
"@nx/nx-linux-x64-gnu": "19.3.1", | ||
"@nx/nx-linux-x64-musl": "19.3.1", | ||
"@nx/nx-win32-x64-msvc": "19.3.1", | ||
"@nx/nx-linux-arm64-gnu": "19.3.1", | ||
"@nx/nx-linux-arm64-musl": "19.3.1", | ||
"@nx/nx-linux-arm-gnueabihf": "19.3.1", | ||
"@nx/nx-win32-arm64-msvc": "19.3.1", | ||
"@nx/nx-freebsd-x64": "19.3.1" | ||
"@nx/nx-darwin-x64": "19.3.2", | ||
"@nx/nx-darwin-arm64": "19.3.2", | ||
"@nx/nx-linux-x64-gnu": "19.3.2", | ||
"@nx/nx-linux-x64-musl": "19.3.2", | ||
"@nx/nx-win32-x64-msvc": "19.3.2", | ||
"@nx/nx-linux-arm64-gnu": "19.3.2", | ||
"@nx/nx-linux-arm64-musl": "19.3.2", | ||
"@nx/nx-linux-arm-gnueabihf": "19.3.2", | ||
"@nx/nx-win32-arm64-msvc": "19.3.2", | ||
"@nx/nx-freebsd-x64": "19.3.2" | ||
}, | ||
@@ -102,0 +102,0 @@ "nx-migrations": { |
@@ -57,2 +57,8 @@ import { ChangelogChange } from '../../src/command-line/release/changelog'; | ||
/** | ||
* If authors is enabled, controls whether or not to try to map the authors to their GitHub usernames | ||
* using https://ungh.cc (from https://github.com/unjs/ungh) and the email addresses found in the commits. | ||
* Defaults to true. | ||
*/ | ||
mapAuthorsToGitHubUsernames?: boolean; | ||
/** | ||
* Whether or not the commit references (such as commit and/or PR links) should be included in the changelog. | ||
@@ -59,0 +65,0 @@ * Defaults to true. |
@@ -148,3 +148,3 @@ "use strict"; | ||
// Try to map authors to github usernames | ||
if (repoSlug) { | ||
if (repoSlug && changelogRenderOptions.mapAuthorsToGitHubUsernames) { | ||
await Promise.all([..._authors.keys()].map(async (authorName) => { | ||
@@ -151,0 +151,0 @@ const meta = _authors.get(authorName); |
@@ -6,4 +6,4 @@ import { NxJsonConfiguration } from '../../config/nx-json'; | ||
export declare function connectToNxCloudIfExplicitlyAsked(opts: NxArgs): Promise<void>; | ||
export declare function connectToNxCloudCommand(): Promise<boolean>; | ||
export declare function connectToNxCloudCommand(command?: string): Promise<boolean>; | ||
export declare function connectToNxCloudWithPrompt(command: string): Promise<void>; | ||
export declare function connectExistingRepoToNxCloudPrompt(key?: MessageKey): Promise<boolean>; |
@@ -44,34 +44,25 @@ "use strict"; | ||
exports.connectToNxCloudIfExplicitlyAsked = connectToNxCloudIfExplicitlyAsked; | ||
async function connectToNxCloudCommand() { | ||
async function connectToNxCloudCommand(command) { | ||
const nxJson = (0, configuration_1.readNxJson)(); | ||
if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) { | ||
if (process.env.NX_NEW_CLOUD_ONBOARDING !== 'true') { | ||
output_1.output.log({ | ||
title: '✔ This workspace already has Nx Cloud set up', | ||
bodyLines: [ | ||
'If you have not done so already, connect your workspace to your Nx Cloud account:', | ||
`- Login at ${(0, nx_cloud_utils_1.getNxCloudUrl)(nxJson)} to connect your repository`, | ||
], | ||
}); | ||
const token = process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken; | ||
if (!token) { | ||
throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`); | ||
} | ||
else { | ||
const token = process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken; | ||
if (!token) { | ||
throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`); | ||
} | ||
const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)('nx-connect', token); | ||
output_1.output.log({ | ||
title: '✔ This workspace already has Nx Cloud set up', | ||
bodyLines: [ | ||
'If you have not done so already, connect your workspace to your Nx Cloud account:', | ||
`- Connect with Nx Cloud at: | ||
const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)('nx-connect', token); | ||
output_1.output.log({ | ||
title: '✔ This workspace already has Nx Cloud set up', | ||
bodyLines: [ | ||
'If you have not done so already, connect your workspace to your Nx Cloud account:', | ||
`- Connect with Nx Cloud at: | ||
${connectCloudUrl}`, | ||
], | ||
}); | ||
} | ||
], | ||
}); | ||
return false; | ||
} | ||
const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, false, 'connect-to-nx-cloud'); | ||
const callback = await (0, connect_to_nx_cloud_1.connectToNxCloud)(tree, {}); | ||
const callback = await (0, connect_to_nx_cloud_1.connectToNxCloud)(tree, { | ||
installationSource: command ?? 'nx-connect', | ||
}); | ||
tree.lock(); | ||
@@ -85,3 +76,3 @@ (0, tree_1.flushChanges)(workspace_root_1.workspaceRoot, tree.listChanges()); | ||
const setNxCloud = await nxCloudPrompt('setupNxCloud'); | ||
const useCloud = setNxCloud === 'yes' ? await connectToNxCloudCommand() : false; | ||
const useCloud = setNxCloud === 'yes' ? await connectToNxCloudCommand(command) : false; | ||
await (0, ab_testing_1.recordStat)({ | ||
@@ -88,0 +79,0 @@ command, |
@@ -225,3 +225,8 @@ "use strict"; | ||
for (const project of releaseGroup.projects) { | ||
const dependentProjects = (projectsVersionData[project]?.dependentProjects || []) | ||
// If the project does not have any changes, do not process its dependents | ||
if (!projectsVersionData[project] || | ||
projectsVersionData[project].newVersion === null) { | ||
continue; | ||
} | ||
const dependentProjects = (projectsVersionData[project].dependentProjects || []) | ||
.map((dep) => { | ||
@@ -228,0 +233,0 @@ return { |
@@ -113,2 +113,3 @@ "use strict"; | ||
authors: true, | ||
mapAuthorsToGitHubUsernames: true, | ||
commitReferences: true, | ||
@@ -127,2 +128,3 @@ versionTitleDate: true, | ||
authors: true, | ||
mapAuthorsToGitHubUsernames: true, | ||
commitReferences: true, | ||
@@ -158,2 +160,3 @@ versionTitleDate: true, | ||
authors: true, | ||
mapAuthorsToGitHubUsernames: true, | ||
commitReferences: true, | ||
@@ -160,0 +163,0 @@ versionTitleDate: true, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cleanupPlugins = exports.getPlugins = void 0; | ||
const file_hasher_1 = require("../../hasher/file-hasher"); | ||
const nx_json_1 = require("../../config/nx-json"); | ||
const internal_api_1 = require("../../project-graph/plugins/internal-api"); | ||
const workspace_root_1 = require("../../utils/workspace-root"); | ||
let currentPluginsConfigurationHash; | ||
let loadedPlugins; | ||
let cleanup; | ||
async function getPlugins() { | ||
if (loadedPlugins) { | ||
const pluginsConfiguration = (0, nx_json_1.readNxJson)().plugins ?? []; | ||
const pluginsConfigurationHash = (0, file_hasher_1.hashObject)(pluginsConfiguration); | ||
// If the plugins configuration has not changed, reuse the current plugins | ||
if (loadedPlugins && | ||
pluginsConfigurationHash === currentPluginsConfigurationHash) { | ||
return loadedPlugins; | ||
} | ||
const pluginsConfiguration = (0, nx_json_1.readNxJson)().plugins ?? []; | ||
// Cleanup current plugins before loading new ones | ||
if (cleanup) { | ||
cleanup(); | ||
} | ||
currentPluginsConfigurationHash = pluginsConfigurationHash; | ||
const [result, cleanupFn] = await (0, internal_api_1.loadNxPlugins)(pluginsConfiguration, workspace_root_1.workspaceRoot); | ||
@@ -15,0 +25,0 @@ cleanup = cleanupFn; |
@@ -11,15 +11,20 @@ "use strict"; | ||
const exit_codes_1 = require("../../utils/exit-codes"); | ||
const task_env_1 = require("../../tasks-runner/task-env"); | ||
exports.LARGE_BUFFER = 1024 * 1000000; | ||
let pseudoTerminal; | ||
const childProcesses = new Set(); | ||
async function loadEnvVars(path) { | ||
function loadEnvVarsFile(path, env = {}) { | ||
(0, task_env_1.unloadDotEnvFile)(path, env); | ||
const result = (0, task_env_1.loadAndExpandDotEnvFile)(path, env); | ||
if (result.error) { | ||
throw result.error; | ||
} | ||
} | ||
function loadEnvVars(path, env = {}) { | ||
if (path) { | ||
const result = (await Promise.resolve().then(() => require('dotenv'))).config({ path }); | ||
if (result.error) { | ||
throw result.error; | ||
} | ||
loadEnvVarsFile(path, env); | ||
} | ||
else { | ||
try { | ||
(await Promise.resolve().then(() => require('dotenv'))).config(); | ||
loadEnvVarsFile('.env', env); | ||
} | ||
@@ -50,5 +55,2 @@ catch { } | ||
registerProcessListener(); | ||
if (process.env.NX_LOAD_DOT_ENV_FILES !== 'false') { | ||
await loadEnvVars(options.envFile); | ||
} | ||
const normalized = normalizeOptions(options); | ||
@@ -77,3 +79,3 @@ if (normalized.readyWhenStatus.length && !normalized.parallel) { | ||
async function runInParallel(options, context) { | ||
const procs = options.commands.map((c) => createProcess(null, c, options.readyWhenStatus, options.color, calculateCwd(options.cwd, context), options.env ?? {}, true, options.usePty, options.streamOutput, options.tty).then((result) => ({ | ||
const procs = options.commands.map((c) => createProcess(null, c, options.readyWhenStatus, options.color, calculateCwd(options.cwd, context), options.env ?? {}, true, options.usePty, options.streamOutput, options.tty, options.envFile).then((result) => ({ | ||
result, | ||
@@ -168,3 +170,3 @@ command: c.command, | ||
for (const c of options.commands) { | ||
const result = await createProcess(pseudoTerminal, c, [], options.color, calculateCwd(options.cwd, context), options.env ?? {}, false, options.usePty, options.streamOutput, options.tty); | ||
const result = await createProcess(pseudoTerminal, c, [], options.color, calculateCwd(options.cwd, context), options.processEnv ?? options.env ?? {}, false, options.usePty, options.streamOutput, options.tty, options.envFile); | ||
terminalOutput += result.terminalOutput; | ||
@@ -182,4 +184,4 @@ if (!result.success) { | ||
} | ||
async function createProcess(pseudoTerminal, commandConfig, readyWhenStatus = [], color, cwd, env, isParallel, usePty = true, streamOutput = true, tty) { | ||
env = processEnv(color, cwd, env); | ||
async function createProcess(pseudoTerminal, commandConfig, readyWhenStatus = [], color, cwd, env, isParallel, usePty = true, streamOutput = true, tty, envFile) { | ||
env = processEnv(color, cwd, env, envFile); | ||
// The rust runCommand is always a tty, so it will not look nice in parallel and if we need prefixes | ||
@@ -290,3 +292,3 @@ // currently does not work properly in windows | ||
} | ||
function processEnv(color, cwd, env) { | ||
function processEnv(color, cwd, env, envFile) { | ||
const localEnv = (0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd() }); | ||
@@ -298,2 +300,5 @@ const res = { | ||
}; | ||
if (process.env.NX_LOAD_DOT_ENV_FILES !== 'false') { | ||
loadEnvVars(envFile, res); | ||
} | ||
// need to override PATH to make sure we are using the local node_modules | ||
@@ -300,0 +305,0 @@ if (localEnv.PATH) |
@@ -7,4 +7,5 @@ import { Tree } from '../../../generators/tree'; | ||
github?: boolean; | ||
directory?: string; | ||
} | ||
export declare function connectToNxCloud(tree: Tree, schema: ConnectToNxCloudOptions): Promise<() => void>; | ||
export default connectToNxCloud; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const child_process_1 = require("child_process"); | ||
const node_url_1 = require("node:url"); | ||
const output_1 = require("../../../utils/output"); | ||
@@ -12,2 +11,5 @@ const json_1 = require("../../../generators/utils/json"); | ||
const url_shorten_1 = require("../../utilities/url-shorten"); | ||
const git_utils_1 = require("../../../utils/git-utils"); | ||
const ora = require("ora"); | ||
const open = require("open"); | ||
function printCloudConnectionDisabledMessage() { | ||
@@ -62,31 +64,55 @@ output_1.output.error({ | ||
} | ||
async function printSuccessMessage(url, token, installationSource, github) { | ||
if (process.env.NX_NEW_CLOUD_ONBOARDING !== 'true') { | ||
let origin = 'https://nx.app'; | ||
async function printSuccessMessage(url, token, installationSource, usesGithub, directory) { | ||
const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)(installationSource, token, usesGithub); | ||
if (installationSource === 'nx-connect' && usesGithub) { | ||
try { | ||
origin = new node_url_1.URL(url).origin; | ||
const cloudConnectSpinner = ora(`Opening Nx Cloud ${connectCloudUrl} in your browser to connect your workspace.`).start(); | ||
await sleep(2000); | ||
open(connectCloudUrl); | ||
cloudConnectSpinner.succeed(); | ||
} | ||
catch (e) { } | ||
output_1.output.note({ | ||
title: `Your Nx Cloud workspace is public`, | ||
bodyLines: [ | ||
`To restrict access, connect it to your Nx Cloud account:`, | ||
`- Push your changes`, | ||
`- Login at ${origin} to connect your repository`, | ||
], | ||
}); | ||
catch (e) { | ||
output_1.output.note({ | ||
title: `Your Nx Cloud workspace is ready.`, | ||
bodyLines: [ | ||
`To claim it, connect it to your Nx Cloud account:`, | ||
`- Go to the following URL to connect your workspace to Nx Cloud:`, | ||
'', | ||
`${connectCloudUrl}`, | ||
], | ||
}); | ||
} | ||
} | ||
else { | ||
const connectCloudUrl = await (0, url_shorten_1.shortenedCloudUrl)(installationSource, token, github); | ||
output_1.output.note({ | ||
title: `Your Nx Cloud workspace is ready.`, | ||
bodyLines: [ | ||
`To claim it, connect it to your Nx Cloud account:`, | ||
`- Commit and push your changes.`, | ||
`- Create a pull request for the changes.`, | ||
`- Go to the following URL to connect your workspace to Nx Cloud: | ||
${connectCloudUrl}`, | ||
], | ||
}); | ||
if (installationSource === 'create-nx-workspace') { | ||
output_1.output.note({ | ||
title: `Your Nx Cloud workspace is ready.`, | ||
bodyLines: [ | ||
`To claim it, connect it to your Nx Cloud account:`, | ||
`- Push your repository to your git hosting provider.`, | ||
`- Go to the following URL to connect your workspace to Nx Cloud:`, | ||
'', | ||
`${connectCloudUrl}`, | ||
], | ||
}); | ||
(0, git_utils_1.commitChanges)(`feat(nx): Added Nx Cloud token to your nx.json | ||
To connect your workspace to Nx Cloud, push your repository | ||
to your git hosting provider and go to the following URL: | ||
${connectCloudUrl}`, directory); | ||
} | ||
else { | ||
output_1.output.note({ | ||
title: `Your Nx Cloud workspace is ready.`, | ||
bodyLines: [ | ||
`To claim it, connect it to your Nx Cloud account:`, | ||
`- Commit and push your changes.`, | ||
`- Create a pull request for the changes.`, | ||
`- Go to the following URL to connect your workspace to Nx Cloud:`, | ||
'', | ||
`${connectCloudUrl}`, | ||
], | ||
}); | ||
} | ||
} | ||
@@ -114,12 +140,21 @@ } | ||
else { | ||
// TODO: Change to using loading light client when that is enabled by default | ||
const r = await createNxCloudWorkspace(getRootPackageName(tree), schema.installationSource, getNxInitDate()); | ||
addNxCloudOptionsToNxJson(tree, nxJson, r.token); | ||
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, { | ||
silent: schema.hideFormatLogs, | ||
}); | ||
return async () => await printSuccessMessage(r.url, r.token, schema.installationSource, schema.github); | ||
const usesGithub = await (0, url_shorten_1.repoUsesGithub)(schema.github); | ||
let responseFromCreateNxCloudWorkspace; | ||
// do NOT create Nx Cloud token (createNxCloudWorkspace) | ||
// if user is using github and is running nx-connect | ||
if (!(usesGithub && schema.installationSource === 'nx-connect')) { | ||
responseFromCreateNxCloudWorkspace = await createNxCloudWorkspace(getRootPackageName(tree), schema.installationSource, getNxInitDate()); | ||
addNxCloudOptionsToNxJson(tree, nxJson, responseFromCreateNxCloudWorkspace?.token); | ||
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, { | ||
silent: schema.hideFormatLogs, | ||
}); | ||
} | ||
const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`); | ||
return async () => await printSuccessMessage(responseFromCreateNxCloudWorkspace?.url ?? apiUrl, responseFromCreateNxCloudWorkspace?.token, schema.installationSource, usesGithub, schema.directory); | ||
} | ||
} | ||
exports.connectToNxCloud = connectToNxCloud; | ||
function sleep(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
exports.default = connectToNxCloud; |
@@ -28,2 +28,7 @@ { | ||
"default": false | ||
}, | ||
"directory": { | ||
"type": "string", | ||
"description": "The directory where the workspace is located", | ||
"x-priority": "internal" | ||
} | ||
@@ -30,0 +35,0 @@ }, |
@@ -1,1 +0,2 @@ | ||
export declare function shortenedCloudUrl(installationSource: string, accessToken: string, github?: boolean): Promise<string>; | ||
export declare function shortenedCloudUrl(installationSource: string, accessToken?: string, usesGithub?: boolean): Promise<string>; | ||
export declare function repoUsesGithub(github?: boolean): Promise<boolean>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.shortenedCloudUrl = void 0; | ||
exports.repoUsesGithub = exports.shortenedCloudUrl = void 0; | ||
const devkit_exports_1 = require("../../devkit-exports"); | ||
const git_utils_1 = require("../../utils/git-utils"); | ||
async function shortenedCloudUrl(installationSource, accessToken, github) { | ||
const semver_1 = require("semver"); | ||
async function shortenedCloudUrl(installationSource, accessToken, usesGithub) { | ||
const githubSlug = (0, git_utils_1.getGithubSlugOrNull)(); | ||
const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`); | ||
const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl); | ||
const usesGithub = (githubSlug || github) && | ||
(apiUrl.includes('cloud.nx.app') || | ||
apiUrl.includes('eu.nx.app') || | ||
installationSupportsGitHub); | ||
const version = await getNxCloudVersion(apiUrl); | ||
if (version && (0, semver_1.lt)(truncateToSemver(version), '2406.11.5')) { | ||
return apiUrl; | ||
} | ||
const source = getSource(installationSource); | ||
@@ -30,6 +30,16 @@ try { | ||
${e}`); | ||
return getURLifShortenFailed(usesGithub, githubSlug, apiUrl, accessToken, source); | ||
return getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessToken); | ||
} | ||
} | ||
exports.shortenedCloudUrl = shortenedCloudUrl; | ||
async function repoUsesGithub(github) { | ||
const githubSlug = (0, git_utils_1.getGithubSlugOrNull)(); | ||
const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`); | ||
const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl); | ||
return ((githubSlug || github) && | ||
(apiUrl.includes('cloud.nx.app') || | ||
apiUrl.includes('eu.nx.app') || | ||
installationSupportsGitHub)); | ||
} | ||
exports.repoUsesGithub = repoUsesGithub; | ||
function removeTrailingSlash(apiUrl) { | ||
@@ -52,9 +62,9 @@ return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl; | ||
} | ||
function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, accessToken, source) { | ||
function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessToken) { | ||
if (usesGithub) { | ||
if (githubSlug) { | ||
return `${apiUrl}/setup/connect-workspace/vcs?provider=GITHUB&selectedRepositoryName=${encodeURIComponent(githubSlug)}&source=${source}`; | ||
return `${apiUrl}/setup/connect-workspace/github/connect?name=${encodeURIComponent(githubSlug)}&source=${source}`; | ||
} | ||
else { | ||
return `${apiUrl}/setup/connect-workspace/vcs?provider=GITHUB&source=${source}`; | ||
return `${apiUrl}/setup/connect-workspace/github/select&source=${source}`; | ||
} | ||
@@ -80,1 +90,27 @@ } | ||
} | ||
async function getNxCloudVersion(apiUrl) { | ||
try { | ||
const response = await require('axios').get(`${apiUrl}/version`, { | ||
responseType: 'document', | ||
}); | ||
const version = extractVersion(response.data); | ||
if (!version) { | ||
throw new Error('Failed to extract version from response.'); | ||
} | ||
return version; | ||
} | ||
catch (e) { | ||
devkit_exports_1.logger.verbose(`Failed to get version of Nx Cloud. | ||
${e}`); | ||
} | ||
} | ||
function extractVersion(htmlString) { | ||
// The pattern assumes 'Version' is inside an h1 tag and the version number is the next span's content | ||
const regex = /<h1[^>]*>Version<\/h1>\s*<div[^>]*><div[^>]*><div[^>]*><span[^>]*>([^<]+)<\/span>/; | ||
const match = htmlString.match(regex); | ||
return match ? match[1].trim() : null; | ||
} | ||
function truncateToSemver(versionString) { | ||
// version may be something like 2406.13.5.hotfix2 | ||
return versionString.split(/[\.-]/).slice(0, 3).join('.'); | ||
} |
import { PluginConfiguration } from '../../../config/nx-json'; | ||
import { LoadedNxPlugin } from '../internal-api'; | ||
export declare function loadNxPluginInIsolation(plugin: PluginConfiguration, root?: string): [Promise<LoadedNxPlugin>, () => void]; | ||
export declare function loadNxPluginInIsolation(plugin: PluginConfiguration, root?: string): readonly [Promise<LoadedNxPlugin>, () => void]; |
@@ -13,9 +13,16 @@ "use strict"; | ||
if (remotePluginCache.has(cacheKey)) { | ||
return [remotePluginCache.get(cacheKey), () => { }]; | ||
return remotePluginCache.get(cacheKey); | ||
} | ||
const loadingPlugin = (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root); | ||
remotePluginCache.set(cacheKey, loadingPlugin); | ||
const [loadingPlugin, cleanup] = (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root); | ||
// We clean up plugin workers when Nx process completes. | ||
return [loadingPlugin, () => { }]; | ||
const val = [ | ||
loadingPlugin, | ||
() => { | ||
cleanup(); | ||
remotePluginCache.delete(cacheKey); | ||
}, | ||
]; | ||
remotePluginCache.set(cacheKey, val); | ||
return val; | ||
} | ||
exports.loadNxPluginInIsolation = loadNxPluginInIsolation; |
import { PluginConfiguration } from '../../../config/nx-json'; | ||
import { LoadedNxPlugin } from '../internal-api'; | ||
export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): Promise<LoadedNxPlugin>; | ||
export declare function loadRemoteNxPlugin(plugin: PluginConfiguration, root: string): [Promise<LoadedNxPlugin>, () => void]; |
@@ -45,6 +45,12 @@ "use strict"; | ||
cleanupFunctions.add(cleanupFunction); | ||
return new Promise((res, rej) => { | ||
worker.on('message', createWorkerHandler(worker, pendingPromises, res, rej)); | ||
worker.on('exit', exitHandler); | ||
}); | ||
return [ | ||
new Promise((res, rej) => { | ||
worker.on('message', createWorkerHandler(worker, pendingPromises, res, rej)); | ||
worker.on('exit', exitHandler); | ||
}), | ||
() => { | ||
cleanupFunction(); | ||
cleanupFunctions.delete(cleanupFunction); | ||
}, | ||
]; | ||
} | ||
@@ -51,0 +57,0 @@ exports.loadRemoteNxPlugin = loadRemoteNxPlugin; |
@@ -113,3 +113,9 @@ "use strict"; | ||
finally { | ||
cleanup(); | ||
// When plugins are isolated we don't clean them up during | ||
// a single run of the CLI. They are cleaned up when the CLI | ||
// process exits. Cleaning them here could cause issues if pending | ||
// promises are not resolved. | ||
if (process.env.NX_ISOLATE_PLUGINS !== 'true') { | ||
cleanup(); | ||
} | ||
} | ||
@@ -116,0 +122,0 @@ const { projectGraph, projectFileMapCache } = projectGraphResult; |
@@ -296,3 +296,3 @@ "use strict"; | ||
for (const result of results.flat()) { | ||
const [file, pluginName, nodes] = result; | ||
const [pluginName, file, nodes] = result; | ||
const { projects: projectNodes, externalNodes: pluginExternalNodes } = nodes; | ||
@@ -299,0 +299,0 @@ const sourceInfo = [file, pluginName]; |
@@ -9,1 +9,14 @@ /// <reference types="node" /> | ||
}; | ||
/** | ||
* This function loads a .env file and expands the variables in it. | ||
* It is going to override existing environmentVariables. | ||
* @param filename | ||
* @param environmentVariables | ||
*/ | ||
export declare function loadAndExpandDotEnvFile(filename: string, environmentVariables: NodeJS.ProcessEnv, override?: boolean): import("dotenv-expand").DotenvExpandOutput; | ||
/** | ||
* This function unloads a .env file and removes the variables in it from the environmentVariables. | ||
* @param filename | ||
* @param environmentVariables | ||
*/ | ||
export declare function unloadDotEnvFile(filename: string, environmentVariables: NodeJS.ProcessEnv, override?: boolean): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEnvVariablesForTask = exports.getTaskSpecificEnv = exports.getEnvVariablesForBatchProcess = void 0; | ||
exports.unloadDotEnvFile = exports.loadAndExpandDotEnvFile = exports.getEnvVariablesForTask = exports.getTaskSpecificEnv = exports.getEnvVariablesForBatchProcess = void 0; | ||
const dotenv_1 = require("dotenv"); | ||
@@ -78,5 +78,38 @@ const dotenv_expand_1 = require("dotenv-expand"); | ||
} | ||
function loadDotEnvFilesForTask(task, environmentVariables) { | ||
/** | ||
* This function loads a .env file and expands the variables in it. | ||
* It is going to override existing environmentVariables. | ||
* @param filename | ||
* @param environmentVariables | ||
*/ | ||
function loadAndExpandDotEnvFile(filename, environmentVariables, override = false) { | ||
const myEnv = (0, dotenv_1.config)({ | ||
path: filename, | ||
processEnv: environmentVariables, | ||
override, | ||
}); | ||
return (0, dotenv_expand_1.expand)({ | ||
...myEnv, | ||
processEnv: environmentVariables, | ||
}); | ||
} | ||
exports.loadAndExpandDotEnvFile = loadAndExpandDotEnvFile; | ||
/** | ||
* This function unloads a .env file and removes the variables in it from the environmentVariables. | ||
* @param filename | ||
* @param environmentVariables | ||
*/ | ||
function unloadDotEnvFile(filename, environmentVariables, override = false) { | ||
const parsedDotEnvFile = {}; | ||
loadAndExpandDotEnvFile(filename, parsedDotEnvFile, override); | ||
Object.keys(parsedDotEnvFile).forEach((envVarKey) => { | ||
if (environmentVariables[envVarKey] === parsedDotEnvFile[envVarKey]) { | ||
delete environmentVariables[envVarKey]; | ||
} | ||
}); | ||
} | ||
exports.unloadDotEnvFile = unloadDotEnvFile; | ||
function getEnvFilesForTask(task) { | ||
// Collect dot env files that may pertain to a task | ||
const dotEnvFiles = [ | ||
return [ | ||
// Load DotEnv Files for a configuration in the project root | ||
@@ -126,16 +159,7 @@ ...(task.target.configuration | ||
]; | ||
} | ||
function loadDotEnvFilesForTask(task, environmentVariables) { | ||
const dotEnvFiles = getEnvFilesForTask(task); | ||
for (const file of dotEnvFiles) { | ||
const myEnv = (0, dotenv_1.config)({ | ||
path: file, | ||
processEnv: environmentVariables, | ||
// Do not override existing env variables as we load | ||
override: false, | ||
}); | ||
environmentVariables = { | ||
...(0, dotenv_expand_1.expand)({ | ||
...myEnv, | ||
ignoreProcessEnv: true, // Do not override existing env variables as we load | ||
}).parsed, | ||
...environmentVariables, | ||
}; | ||
loadAndExpandDotEnvFile(file, environmentVariables); | ||
} | ||
@@ -145,15 +169,6 @@ return environmentVariables; | ||
function unloadDotEnvFiles(environmentVariables) { | ||
const unloadDotEnvFile = (filename) => { | ||
let parsedDotEnvFile = {}; | ||
(0, dotenv_1.config)({ path: filename, processEnv: parsedDotEnvFile }); | ||
Object.keys(parsedDotEnvFile).forEach((envVarKey) => { | ||
if (environmentVariables[envVarKey] === parsedDotEnvFile[envVarKey]) { | ||
delete environmentVariables[envVarKey]; | ||
} | ||
}); | ||
}; | ||
for (const file of ['.env', '.local.env', '.env.local']) { | ||
unloadDotEnvFile(file); | ||
unloadDotEnvFile(file, environmentVariables); | ||
} | ||
return environmentVariables; | ||
} |
export declare function getGithubSlugOrNull(): string | null; | ||
export declare function extractUserAndRepoFromGitHubUrl(gitRemotes: string): string | null; | ||
export declare function commitChanges(commitMessage: string): string | null; | ||
export declare function commitChanges(commitMessage: string, directory?: string): string | null; | ||
export declare function getLatestCommitSha(): string | null; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const child_process_1 = require("child_process"); | ||
const devkit_exports_1 = require("../devkit-exports"); | ||
function getGithubSlugOrNull() { | ||
@@ -42,3 +43,3 @@ try { | ||
} | ||
function commitChanges(commitMessage) { | ||
function commitChanges(commitMessage, directory) { | ||
try { | ||
@@ -50,6 +51,16 @@ (0, child_process_1.execSync)('git add -A', { encoding: 'utf8', stdio: 'pipe' }); | ||
input: commitMessage, | ||
cwd: directory, | ||
}); | ||
} | ||
catch (err) { | ||
throw new Error(`Error committing changes:\n${err.stderr}`); | ||
if (directory) { | ||
// We don't want to throw during create-nx-workspace | ||
// because maybe there was an error when setting up git | ||
// initially. | ||
devkit_exports_1.logger.verbose(`Git may not be set up correctly for this new workspace. | ||
${err}`); | ||
} | ||
else { | ||
throw new Error(`Error committing changes:\n${err.stderr}`); | ||
} | ||
} | ||
@@ -56,0 +67,0 @@ return getLatestCommitSha(); |
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
4217078
48248
375
391
+ Added@nrwl/tao@19.3.2(transitive)
+ Added@nx/nx-darwin-arm64@19.3.2(transitive)
+ Added@nx/nx-darwin-x64@19.3.2(transitive)
+ Added@nx/nx-freebsd-x64@19.3.2(transitive)
+ Added@nx/nx-linux-arm-gnueabihf@19.3.2(transitive)
+ Added@nx/nx-linux-arm64-gnu@19.3.2(transitive)
+ Added@nx/nx-linux-arm64-musl@19.3.2(transitive)
+ Added@nx/nx-linux-x64-gnu@19.3.2(transitive)
+ Added@nx/nx-linux-x64-musl@19.3.2(transitive)
+ Added@nx/nx-win32-arm64-msvc@19.3.2(transitive)
+ Added@nx/nx-win32-x64-msvc@19.3.2(transitive)
+ Added@swc/core@1.6.6(transitive)
+ Added@swc/core-darwin-arm64@1.6.6(transitive)
+ Added@swc/core-darwin-x64@1.6.6(transitive)
+ Added@swc/core-linux-arm-gnueabihf@1.6.6(transitive)
+ Added@swc/core-linux-arm64-gnu@1.6.6(transitive)
+ Added@swc/core-linux-arm64-musl@1.6.6(transitive)
+ Added@swc/core-linux-x64-gnu@1.6.6(transitive)
+ Added@swc/core-linux-x64-musl@1.6.6(transitive)
+ Added@swc/core-win32-arm64-msvc@1.6.6(transitive)
+ Added@swc/core-win32-ia32-msvc@1.6.6(transitive)
+ Added@swc/core-win32-x64-msvc@1.6.6(transitive)
+ Addeddotenv@16.4.5(transitive)
+ Addeddotenv-expand@11.0.6(transitive)
- Removed@nrwl/tao@19.3.1(transitive)
- Removed@nx/nx-darwin-arm64@19.3.1(transitive)
- Removed@nx/nx-darwin-x64@19.3.1(transitive)
- Removed@nx/nx-freebsd-x64@19.3.1(transitive)
- Removed@nx/nx-linux-arm-gnueabihf@19.3.1(transitive)
- Removed@nx/nx-linux-arm64-gnu@19.3.1(transitive)
- Removed@nx/nx-linux-arm64-musl@19.3.1(transitive)
- Removed@nx/nx-linux-x64-gnu@19.3.1(transitive)
- Removed@nx/nx-linux-x64-musl@19.3.1(transitive)
- Removed@nx/nx-win32-arm64-msvc@19.3.1(transitive)
- Removed@nx/nx-win32-x64-msvc@19.3.1(transitive)
- Removed@swc/core@1.6.5(transitive)
- Removed@swc/core-darwin-arm64@1.6.5(transitive)
- Removed@swc/core-darwin-x64@1.6.5(transitive)
- Removed@swc/core-linux-arm-gnueabihf@1.6.5(transitive)
- Removed@swc/core-linux-arm64-gnu@1.6.5(transitive)
- Removed@swc/core-linux-arm64-musl@1.6.5(transitive)
- Removed@swc/core-linux-x64-gnu@1.6.5(transitive)
- Removed@swc/core-linux-x64-musl@1.6.5(transitive)
- Removed@swc/core-win32-arm64-msvc@1.6.5(transitive)
- Removed@swc/core-win32-ia32-msvc@1.6.5(transitive)
- Removed@swc/core-win32-x64-msvc@1.6.5(transitive)
- Removeddotenv@16.3.2(transitive)
- Removeddotenv-expand@10.0.0(transitive)
Updated@nrwl/tao@19.3.2
Updateddotenv@~16.4.5
Updateddotenv-expand@~11.0.6