Socket
Socket
Sign inDemoInstall

nx

Package Overview
Dependencies
Maintainers
8
Versions
1371
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nx - npm Package Compare versions

Comparing version 0.0.0-pr-27652-a405076 to 0.0.0-pr-27691-4be37c2

src/command-line/login/command-object.d.ts

26

package.json
{
"name": "nx",
"version": "0.0.0-pr-27652-a405076",
"version": "0.0.0-pr-27691-4be37c2",
"private": false,

@@ -59,3 +59,3 @@ "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",

"jsonc-parser": "3.2.0",
"lines-and-columns": "~2.0.3",
"lines-and-columns": "2.0.3",
"minimatch": "9.0.3",

@@ -75,3 +75,3 @@ "npm-run-path": "^4.0.1",

"ora": "5.3.0",
"@nrwl/tao": "0.0.0-pr-27652-a405076"
"@nrwl/tao": "0.0.0-pr-27691-4be37c2"
},

@@ -91,12 +91,12 @@ "peerDependencies": {

"optionalDependencies": {
"@nx/nx-darwin-x64": "0.0.0-pr-27652-a405076",
"@nx/nx-darwin-arm64": "0.0.0-pr-27652-a405076",
"@nx/nx-linux-x64-gnu": "0.0.0-pr-27652-a405076",
"@nx/nx-linux-x64-musl": "0.0.0-pr-27652-a405076",
"@nx/nx-win32-x64-msvc": "0.0.0-pr-27652-a405076",
"@nx/nx-linux-arm64-gnu": "0.0.0-pr-27652-a405076",
"@nx/nx-linux-arm64-musl": "0.0.0-pr-27652-a405076",
"@nx/nx-linux-arm-gnueabihf": "0.0.0-pr-27652-a405076",
"@nx/nx-win32-arm64-msvc": "0.0.0-pr-27652-a405076",
"@nx/nx-freebsd-x64": "0.0.0-pr-27652-a405076"
"@nx/nx-darwin-x64": "0.0.0-pr-27691-4be37c2",
"@nx/nx-darwin-arm64": "0.0.0-pr-27691-4be37c2",
"@nx/nx-linux-x64-gnu": "0.0.0-pr-27691-4be37c2",
"@nx/nx-linux-x64-musl": "0.0.0-pr-27691-4be37c2",
"@nx/nx-win32-x64-msvc": "0.0.0-pr-27691-4be37c2",
"@nx/nx-linux-arm64-gnu": "0.0.0-pr-27691-4be37c2",
"@nx/nx-linux-arm64-musl": "0.0.0-pr-27691-4be37c2",
"@nx/nx-linux-arm-gnueabihf": "0.0.0-pr-27691-4be37c2",
"@nx/nx-win32-arm64-msvc": "0.0.0-pr-27691-4be37c2",
"@nx/nx-freebsd-x64": "0.0.0-pr-27691-4be37c2"
},

@@ -103,0 +103,0 @@ "nx-migrations": {

@@ -285,2 +285,9 @@ {

"description": "Whether to automatically apply sync generator changes when running tasks. If not set, the user will be prompted. If set to `true`, the user will not be prompted and the changes will be applied. If set to `false`, the user will not be prompted and the changes will not be applied."
},
"disabledTaskSyncGenerators": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of registered task sync generators to disable."
}

@@ -287,0 +294,0 @@ },

@@ -63,5 +63,7 @@ "use strict";

if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
const token = process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken;
const token = process.env.NX_CLOUD_ACCESS_TOKEN ||
nxJson.nxCloudAccessToken ||
nxJson.nxCloudId;
if (!token) {
throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
throw new Error(`Unable to authenticate. If you are connecting to Nx Cloud locally, set Nx Cloud ID in nx.json. If you are connecting in a CI context, either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
}

@@ -72,6 +74,5 @@ const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token);

bodyLines: [
'If you have not done so already, connect your workspace to your Nx Cloud account:',
`- Connect with Nx Cloud at:
${connectCloudUrl}`,
'If you have not done so already, connect your workspace to your Nx Cloud account with the following URL:',
'',
`${connectCloudUrl}`,
],

@@ -78,0 +79,0 @@ });

@@ -678,4 +678,6 @@ "use strict";

inputs.forEach((input) => {
if (input.startsWith('{workspaceRoot}')) {
workspaceRootInputs.push(input);
// grouped workspace inputs look like workspace:[pattern,otherPattern]
if (input.startsWith('workspace:[')) {
const inputs = input.substring(11, input.length - 1).split(',');
workspaceRootInputs.push(...inputs);
return;

@@ -700,18 +702,3 @@ }

});
const workspaceRootsExpanded = workspaceRootInputs.flatMap((input) => {
const matches = [];
const withoutWorkspaceRoot = input.substring(16);
const matchingFile = allWorkspaceFiles.find((t) => t.file === withoutWorkspaceRoot);
if (matchingFile) {
matches.push(matchingFile.file);
}
else {
allWorkspaceFiles
.filter((f) => (0, minimatch_1.minimatch)(f.file, withoutWorkspaceRoot))
.forEach((f) => {
matches.push(f.file);
});
}
return matches;
});
const workspaceRootsExpanded = getExpandedWorkspaceRoots(workspaceRootInputs, allWorkspaceFiles);
const otherInputsExpanded = otherInputs.map((input) => {

@@ -749,2 +736,32 @@ if (input === 'TsConfig') {

}
function getExpandedWorkspaceRoots(workspaceRootInputs, allWorkspaceFiles) {
const workspaceRootsExpanded = [];
const negativeWRPatterns = [];
const positiveWRPatterns = [];
for (const fileset of workspaceRootInputs) {
if (fileset.startsWith('!')) {
negativeWRPatterns.push(fileset.substring(17));
}
else {
positiveWRPatterns.push(fileset.substring(16));
}
}
for (const pattern of positiveWRPatterns) {
const matchingFile = allWorkspaceFiles.find((t) => t.file === pattern);
if (matchingFile &&
!negativeWRPatterns.some((p) => (0, minimatch_1.minimatch)(matchingFile.file, p))) {
workspaceRootsExpanded.push(matchingFile.file);
}
else {
allWorkspaceFiles
.filter((f) => (0, minimatch_1.minimatch)(f.file, pattern) &&
!negativeWRPatterns.some((p) => (0, minimatch_1.minimatch)(f.file, p)))
.forEach((f) => {
workspaceRootsExpanded.push(f.file);
});
}
}
workspaceRootsExpanded.sort();
return workspaceRootsExpanded;
}
async function createJsonOutput(prunedGraph, rawGraph, projects, targets) {

@@ -751,0 +768,0 @@ const response = {

@@ -27,6 +27,2 @@ "use strict";

})
.option('depth', {
type: 'number',
description: 'The depth to clone the source repository (limit this for faster git clone)',
})
.option('interactive', {

@@ -33,0 +29,0 @@ type: 'boolean',

@@ -18,6 +18,2 @@ export interface ImportOptions {

destination: string;
/**
* The depth to clone the source repository (limit this for faster clone times)
*/
depth: number;
verbose: boolean;

@@ -24,0 +20,0 @@ interactive: boolean;

@@ -67,3 +67,2 @@ "use strict";

originName: importRemoteName,
depth: options.depth,
});

@@ -109,3 +108,2 @@ }

required: true,
initial: source ? source : undefined,
},

@@ -112,0 +110,0 @@ ])).destination;

@@ -19,43 +19,83 @@ "use strict";

const relativeSourceDir = (0, path_1.relative)(gitClient.root, (0, path_1.join)(gitClient.root, source));
if (relativeSourceDir !== '') {
spinner.start(`Filtering git history to only include files in ${relativeSourceDir}`);
await gitClient.filterBranch(relativeSourceDir, tempImportBranch);
spinner.succeed(`Filtered git history to only include files in ${relativeSourceDir}`);
}
const destinationInSource = (0, path_1.join)(gitClient.root, relativeDestination);
spinner.start(`Moving files and git history to ${destinationInSource}`);
// The result of filter-branch will contain only the files in the subdirectory at its root.
const files = await gitClient.getGitFiles('.');
try {
await (0, promises_1.rm)(destinationInSource, {
recursive: true,
});
if (relativeSourceDir === '') {
const files = await gitClient.getGitFiles('.');
try {
await (0, promises_1.rm)(destinationInSource, {
recursive: true,
});
}
catch { }
await (0, promises_1.mkdir)(destinationInSource, { recursive: true });
const gitignores = new Set();
for (const file of files) {
if ((0, path_1.basename)(file) === '.gitignore') {
gitignores.add(file);
continue;
}
spinner.start(`Moving files and git history to ${destinationInSource}: ${file}`);
const newPath = (0, path_1.join)(destinationInSource, file);
await (0, promises_1.mkdir)((0, path_1.dirname)(newPath), { recursive: true });
try {
await gitClient.move(file, newPath);
}
catch {
await wait(100);
await gitClient.move(file, newPath);
}
}
await gitClient.commit(`chore(repo): move ${source} to ${relativeDestination} to prepare to be imported`);
for (const gitignore of gitignores) {
await gitClient.move(gitignore, (0, path_1.join)(destinationInSource, gitignore));
}
await gitClient.amendCommit();
for (const gitignore of gitignores) {
await (0, promises_1.copyFile)((0, path_1.join)(destinationInSource, gitignore), (0, path_1.join)(gitClient.root, gitignore));
}
}
catch { }
await (0, promises_1.mkdir)(destinationInSource, { recursive: true });
const gitignores = new Set();
for (const file of files) {
if ((0, path_1.basename)(file) === '.gitignore') {
gitignores.add(file);
continue;
else {
let needsSquash = false;
const needsMove = destinationInSource !== (0, path_1.join)(gitClient.root, source);
if (needsMove) {
try {
await (0, promises_1.rm)(destinationInSource, {
recursive: true,
});
await gitClient.commit(`chore(repo): move ${source} to ${relativeDestination} to prepare to be imported`);
needsSquash = true;
}
catch { }
await (0, promises_1.mkdir)(destinationInSource, { recursive: true });
}
spinner.start(`Moving files and git history to ${destinationInSource}: ${file}`);
const newPath = (0, path_1.join)(destinationInSource, file);
await (0, promises_1.mkdir)((0, path_1.dirname)(newPath), { recursive: true });
try {
await gitClient.move(file, newPath);
const files = await gitClient.getGitFiles('.');
for (const file of files) {
if (file === '.gitignore') {
continue;
}
spinner.start(`Moving files and git history to ${destinationInSource}: ${file}`);
if (!(0, path_1.relative)(source, file).startsWith('..')) {
if (needsMove) {
const newPath = (0, path_1.join)(destinationInSource, file);
await (0, promises_1.mkdir)((0, path_1.dirname)(newPath), { recursive: true });
try {
await gitClient.move(file, newPath);
}
catch {
await wait(100);
await gitClient.move(file, newPath);
}
}
}
else {
await (0, promises_1.rm)((0, path_1.join)(gitClient.root, file), {
recursive: true,
});
}
}
catch {
await wait(100);
await gitClient.move(file, newPath);
await gitClient.commit(`chore(repo): move ${source} to ${relativeDestination} to prepare to be imported`);
if (needsSquash) {
await gitClient.squashLastTwoCommits();
}
}
await gitClient.commit(`chore(repo): move ${source} to ${relativeDestination} to prepare to be imported`);
for (const gitignore of gitignores) {
await gitClient.move(gitignore, (0, path_1.join)(destinationInSource, gitignore));
}
await gitClient.amendCommit();
for (const gitignore of gitignores) {
await (0, promises_1.copyFile)((0, path_1.join)(destinationInSource, gitignore), (0, path_1.join)(gitClient.root, gitignore));
}
spinner.succeed(`${sourceRemoteUrl} has been prepared to be imported into this workspace on a temporary branch: ${tempImportBranch} in ${gitClient.root}`);

@@ -62,0 +102,0 @@ }

@@ -27,4 +27,6 @@ "use strict";

const command_object_21 = require("./add/command-object");
const command_object_22 = require("./login/command-object");
const command_object_23 = require("./logout/command-object");
const command_objects_1 = require("./deprecated/command-objects");
const command_object_22 = require("./sync/command-object");
const command_object_24 = require("./sync/command-object");
// Ensure that the output takes up the available width of the terminal.

@@ -74,7 +76,9 @@ yargs.wrap(yargs.terminalWidth());

.command(command_object_17.yargsShowCommand)
.command(command_object_22.yargsSyncCommand)
.command(command_object_22.yargsSyncCheckCommand)
.command(command_object_24.yargsSyncCommand)
.command(command_object_24.yargsSyncCheckCommand)
.command(command_object_2.yargsViewLogsCommand)
.command(command_object_18.yargsWatchCommand)
.command(command_object_15.yargsNxInfixCommand)
.command(command_object_22.yargsLoginCommand)
.command(command_object_23.yargsLogoutCommand)
.scriptName('nx')

@@ -81,0 +85,0 @@ .help()

@@ -13,17 +13,19 @@ import type { NxReleaseConfiguration } from '../../config/nx-json';

}
declare const defaultClient: ReleaseClient;
/**
* @public
*/
export declare const releaseChangelog: any;
export declare const releaseChangelog: typeof defaultClient.releaseChangelog;
/**
* @public
*/
export declare const releasePublish: any;
export declare const releasePublish: typeof defaultClient.releasePublish;
/**
* @public
*/
export declare const releaseVersion: any;
export declare const releaseVersion: typeof defaultClient.releaseVersion;
/**
* @public
*/
export declare const release: any;
export declare const release: typeof defaultClient.release;
export {};

@@ -5,2 +5,3 @@ "use strict";

const ora = require("ora");
const nx_json_1 = require("../../config/nx-json");
const project_graph_1 = require("../../project-graph/project-graph");

@@ -14,3 +15,13 @@ const output_1 = require("../../utils/output");

const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
const syncGenerators = await (0, sync_generators_1.collectAllRegisteredSyncGenerators)(projectGraph);
const nxJson = (0, nx_json_1.readNxJson)();
const syncGenerators = await (0, sync_generators_1.collectAllRegisteredSyncGenerators)(projectGraph, nxJson);
if (!syncGenerators.length) {
output_1.output.success({
title: options.check
? 'The workspace is up to date'
: 'The workspace is already up to date',
bodyLines: ['There are no sync generators to run.'],
});
return 0;
}
const results = await (0, sync_generators_1.getSyncGeneratorChanges)(syncGenerators);

@@ -17,0 +28,0 @@ if (!results.length) {

@@ -289,3 +289,3 @@ import type { ChangelogRenderOptions } from '../../release/changelog-renderer';

* Whether to automatically apply sync generator changes when running tasks.
* If not set, the user will be prompted.
* If not set, the user will be prompted in interactive mode.
* If set to `true`, the user will not be prompted and the changes will be applied.

@@ -295,2 +295,6 @@ * If set to `false`, the user will not be prompted and the changes will not be applied.

applyChanges?: boolean;
/**
* List of registered task sync generators to disable.
*/
disabledTaskSyncGenerators?: string[];
}

@@ -297,0 +301,0 @@ /**

@@ -24,2 +24,3 @@ "use strict";

let storedNxJsonHash;
let storedDisabledTaskSyncGeneratorsHash;
const log = (...messageParts) => {

@@ -111,2 +112,6 @@ logger_1.serverLogger.log('[SYNC]:', ...messageParts);

scheduledGenerators.clear();
if (!registeredSyncGenerators.size) {
// there are no generators to run
return;
}
for (const generator of registeredSyncGenerators) {

@@ -149,7 +154,11 @@ scheduledGenerators.add(generator);

function collectAllRegisteredSyncGenerators(projectGraph) {
const nxJson = (0, nx_json_1.readNxJson)();
const projectGraphHash = hashProjectGraph(projectGraph);
if (storedProjectGraphHash !== projectGraphHash) {
const disabledTaskSyncGeneratorsHash = (0, file_hasher_1.hashArray)(nxJson.sync?.disabledTaskSyncGenerators?.sort() ?? []);
if (projectGraphHash !== storedProjectGraphHash ||
disabledTaskSyncGeneratorsHash !== storedDisabledTaskSyncGeneratorsHash) {
storedProjectGraphHash = projectGraphHash;
storedDisabledTaskSyncGeneratorsHash = disabledTaskSyncGeneratorsHash;
registeredTaskSyncGenerators =
(0, sync_generators_1.collectRegisteredTaskSyncGenerators)(projectGraph);
(0, sync_generators_1.collectEnabledTaskSyncGeneratorsFromProjectGraph)(projectGraph, nxJson);
}

@@ -159,3 +168,2 @@ else {

}
const nxJson = (0, nx_json_1.readNxJson)();
const nxJsonHash = (0, file_hasher_1.hashArray)(nxJson.sync?.globalGenerators?.sort() ?? []);

@@ -162,0 +170,0 @@ if (storedNxJsonHash !== nxJsonHash) {

@@ -19,3 +19,3 @@ "use strict";

(0, task_env_1.unloadDotEnvFile)(path, env);
const result = (0, task_env_1.loadAndExpandDotEnvFile)(path, env);
const result = (0, task_env_1.loadAndExpandDotEnvFile)(path, env, true);
if (result.error) {

@@ -297,10 +297,15 @@ throw result.error;

const localEnv = (0, npm_run_path_1.env)({ cwd: cwd ?? process.cwd() });
const res = {
let res = {
...process.env,
...localEnv,
...env,
};
// env file from envFile option takes priority over process env
if (process.env.NX_LOAD_DOT_ENV_FILES !== 'false') {
loadEnvVars(envFile, res);
}
// env variables from env option takes priority over everything else
res = {
...res,
...env,
};
// need to override PATH to make sure we are using the local node_modules

@@ -307,0 +312,0 @@ if (localEnv.PATH)

@@ -41,3 +41,3 @@ import { NxJsonConfiguration } from '../config/nx-json';

private hashProjectInputs;
private hashRootFileset;
private hashRootFilesets;
private hashProjectConfig;

@@ -44,0 +44,0 @@ private hashTsConfig;

@@ -302,6 +302,6 @@ "use strict";

this.hashTsConfig(projectName),
...[
...workspaceFilesets,
...this.legacyFilesetInputs.map((r) => r.fileset),
].map((fileset) => this.hashRootFileset(fileset)),
...(workspaceFilesets.length
? [this.hashRootFilesets(workspaceFilesets)]
: []),
this.hashRootFilesets(this.legacyFilesetInputs.map((r) => r.fileset)),
...[...notFilesets, ...this.legacyRuntimeInputs].map((r) => r['runtime']

@@ -324,18 +324,36 @@ ? this.hashRuntime(env, r['runtime'])

}
async hashRootFileset(fileset) {
const mapKey = fileset;
const withoutWorkspaceRoot = fileset.substring(16);
async hashRootFilesets(filesets) {
const mapKey = `workspace:[${filesets.join(',')}]`;
if (!this.filesetHashes[mapKey]) {
this.filesetHashes[mapKey] = new Promise(async (res) => {
const parts = [];
const matchingFile = this.allWorkspaceFiles.find((t) => t.file === withoutWorkspaceRoot);
if (matchingFile) {
parts.push(matchingFile.hash);
const negativePatterns = [];
const positivePatterns = [];
for (const fileset of filesets) {
if (fileset.startsWith('!')) {
negativePatterns.push(fileset.substring(17));
}
else {
positivePatterns.push(fileset.substring(16));
}
}
else {
this.allWorkspaceFiles
.filter((f) => (0, minimatch_1.minimatch)(f.file, withoutWorkspaceRoot))
.forEach((f) => {
parts.push(f.hash);
});
for (const fileset of positivePatterns) {
const withoutWorkspaceRoot = fileset;
// Used to shortcut minimatch if not necessary
const matchingFile = this.allWorkspaceFiles.find((t) => t.file === withoutWorkspaceRoot);
// shortcut because there is a direct match
if (matchingFile) {
if (!negativePatterns.some((p) => (0, minimatch_1.minimatch)(matchingFile.file, p))) {
parts.push(matchingFile.hash);
}
// No direct match, check if pattern matched
}
else {
this.allWorkspaceFiles
.filter((f) => (0, minimatch_1.minimatch)(f.file, withoutWorkspaceRoot) &&
!negativePatterns.some((p) => (0, minimatch_1.minimatch)(f.file, p)))
.forEach((f) => {
parts.push(f.hash);
});
}
}

@@ -342,0 +360,0 @@ const value = (0, file_hasher_1.hashArray)(parts);

@@ -45,14 +45,2 @@ "use strict";

}
async function createNxCloudWorkspaceV1(workspaceName, installationSource, nxInitDate) {
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
const response = await require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
workspaceName,
installationSource,
nxInitDate,
});
if (response.data.message) {
throw new Error(response.data.message);
}
return response.data;
}
async function createNxCloudWorkspaceV2(workspaceName, installationSource, nxInitDate) {

@@ -85,15 +73,2 @@ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();

}
function addNxCloudOptionsToNxJson(tree, token, directory = '') {
const nxJsonPath = (0, path_1.join)(directory, 'nx.json');
if (tree.exists(nxJsonPath)) {
(0, json_1.updateJson)(tree, (0, path_1.join)(directory, 'nx.json'), (nxJson) => {
const overrideUrl = process.env.NX_CLOUD_API || process.env.NRWL_API;
if (overrideUrl) {
nxJson.nxCloudUrl = overrideUrl;
}
nxJson.nxCloudAccessToken = token;
return nxJson;
});
}
}
function addNxCloudIdToNxJson(tree, nxCloudId, directory = '') {

@@ -120,3 +95,2 @@ const nxJsonPath = (0, path_1.join)(directory, 'nx.json');

const usesGithub = schema.github ?? (await (0, url_shorten_1.repoUsesGithub)(schema.github));
let responseFromCreateNxCloudWorkspaceV1;
let responseFromCreateNxCloudWorkspaceV2;

@@ -126,18 +100,8 @@ // do NOT create Nx Cloud token (createNxCloudWorkspace)

if (!(usesGithub && schema.installationSource === 'nx-connect')) {
if (process.env.NX_ENABLE_LOGIN === 'true') {
responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(getRootPackageName(tree), schema.installationSource, getNxInitDate());
addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
silent: schema.hideFormatLogs,
});
return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
}
else {
responseFromCreateNxCloudWorkspaceV1 = await createNxCloudWorkspaceV1(getRootPackageName(tree), schema.installationSource, getNxInitDate());
addNxCloudOptionsToNxJson(tree, responseFromCreateNxCloudWorkspaceV1?.token, schema.directory);
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
silent: schema.hideFormatLogs,
});
return responseFromCreateNxCloudWorkspaceV1.token;
}
responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(getRootPackageName(tree), schema.installationSource, getNxInitDate());
addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
silent: schema.hideFormatLogs,
});
return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
}

@@ -144,0 +108,0 @@ }

@@ -14,3 +14,3 @@ import type { CloudTaskRunnerOptions } from './nx-cloud-tasks-runner-shell';

nxCloudTasksRunner: TasksRunner<CloudTaskRunnerOptions>;
remoteCache: RemoteCacheV2;
getRemoteCache: () => RemoteCacheV2;
}

@@ -17,0 +17,0 @@ export declare function verifyOrUpdateNxCloudClient(options: CloudTaskRunnerOptions): Promise<{

@@ -14,8 +14,3 @@ "use strict";

if (!accessToken && !nxCloudId) {
if (process.env.NX_ENABLE_LOGIN === 'true' && !nxCloudId) {
throw new Error(`Unable to authenticate. Please connect your workspace to Nx Cloud to define a valid Nx Cloud Id. If you are in a CI context, please set the NX_CLOUD_ACCESS_TOKEN environment variable or define an access token in your nx.json.`);
}
else {
throw new Error(`Unable to authenticate. Either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable. If you do not want to use Nx Cloud for this command, either set NX_NO_CLOUD=true, or pass the --no-cloud flag.`);
}
throw new Error(`Unable to authenticate. If you are connecting to Nx Cloud locally, set an Nx Cloud ID in your nx.json with "nx connect". If you are in a CI context, please set the NX_CLOUD_ACCESS_TOKEN environment variable or define an access token in your nx.json.`);
}

@@ -22,0 +17,0 @@ if (options.customProxyConfigPath) {

@@ -21,2 +21,9 @@ "use strict";

...node_module_1.builtinModules.map((x) => `node:${x}`),
// These are missing in the builtinModules list
// See: https://github.com/nodejs/node/issues/42785
// TODO(v20): We should be safe to use `isBuiltin` function instead of keep the set here (https://nodejs.org/api/module.html#moduleisbuiltinmodulename)
'test',
'node:test',
'node:sea',
'node:sqlite',
]);

@@ -269,3 +276,3 @@ function isBuiltinModuleImport(importExpr) {

let dir = (0, node_path_1.dirname)(pathOfFileInPackage);
while (dir !== (0, node_path_1.parse)(dir).root) {
while (dir !== (0, node_path_1.dirname)(dir)) {
const packageJsonPath = (0, node_path_1.join)(dir, 'package.json');

@@ -272,0 +279,0 @@ try {

@@ -84,4 +84,4 @@ "use strict";

const { nxCloudClient } = await (0, update_manager_1.verifyOrUpdateNxCloudClient)(options);
if (nxCloudClient.remoteCache) {
return nxCloudClient.remoteCache;
if (nxCloudClient.getRemoteCache) {
return nxCloudClient.getRemoteCache();
}

@@ -88,0 +88,0 @@ else {

@@ -59,5 +59,5 @@ "use strict";

async function runAllTasks(tasks, options, context) {
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, options, context.nxArgs?.nxBail, context.daemon);
const orchestrator = new task_orchestrator_1.TaskOrchestrator(context.hasher, context.initiatingProject, context.projectGraph, context.taskGraph, options, context.nxArgs?.nxBail, context.daemon, context.nxArgs?.outputStyle);
return orchestrator.run();
}
exports.default = exports.defaultTasksRunner;
import { NxArgs } from '../utils/command-line-utils';
import { Task, TaskGraph } from '../config/task-graph';
import { TaskResult } from './life-cycle';
export declare function initTasksRunner(nxArgs: NxArgs): Promise<{

@@ -10,3 +11,4 @@ invoke: (opts: {

taskGraph: TaskGraph;
taskResults: Record<string, TaskResult>;
}>;
}>;

@@ -55,2 +55,3 @@ "use strict";

taskGraph,
taskResults: lifeCycle.getTaskResults(),
};

@@ -57,0 +58,0 @@ },

import { TaskStatus } from '../tasks-runner';
import type { LifeCycle } from '../life-cycle';
import type { LifeCycle, TaskResult } from '../life-cycle';
import { Task } from '../../config/task-graph';

@@ -8,11 +8,9 @@ export declare class InvokeRunnerTerminalOutputLifeCycle implements LifeCycle {

cachedTasks: Task[];
private taskResults;
constructor(tasks: Task[]);
startCommand(): void;
endCommand(): void;
endTasks(taskResults: {
task: Task;
status: TaskStatus;
code: number;
}[]): void;
endTasks(taskResults: TaskResult[]): void;
printTaskTerminalOutput(task: Task, cacheStatus: TaskStatus, terminalOutput: string): void;
getTaskResults(): Record<string, TaskResult>;
}

@@ -11,2 +11,3 @@ "use strict";

this.cachedTasks = [];
this.taskResults = {};
}

@@ -49,2 +50,3 @@ startCommand() {

for (let t of taskResults) {
this.taskResults[t.task.id] = t;
if (t.status === 'failure') {

@@ -68,3 +70,6 @@ this.failedTasks.push(t.task);

}
getTaskResults() {
return this.taskResults;
}
}
exports.InvokeRunnerTerminalOutputLifeCycle = InvokeRunnerTerminalOutputLifeCycle;

@@ -124,12 +124,3 @@ "use strict";

// collect unique syncGenerators from the tasks
const uniqueSyncGenerators = new Set();
for (const { target } of Object.values(taskGraph.tasks)) {
const { syncGenerators } = projectGraph.nodes[target.project].data.targets[target.target];
if (!syncGenerators) {
continue;
}
for (const generator of syncGenerators) {
uniqueSyncGenerators.add(generator);
}
}
const uniqueSyncGenerators = (0, sync_generators_1.collectEnabledTaskSyncGeneratorsFromTaskGraph)(taskGraph, projectGraph, nxJson);
if (!uniqueSyncGenerators.size) {

@@ -445,3 +436,3 @@ // There are no sync generators registered in the tasks to run

process.env.NX_CLOUD_ACCESS_TOKEN ||
// Nx Cloud Id specified in nxJson
// Nx Cloud ID specified in nxJson
nxJson.nxCloudId;

@@ -448,0 +439,0 @@ return isCloudRunner ? 'nx-cloud' : require.resolve('./default-tasks-runner');

@@ -10,5 +10,5 @@ import { Task } from '../config/task-graph';

* This function loads a .env file and expands the variables in it.
* It is going to override existing environmentVariables.
* @param filename
* @param environmentVariables
* @param filename the .env file to load
* @param environmentVariables the object to load environment variables into
* @param override whether to override existing environment variables
*/

@@ -15,0 +15,0 @@ export declare function loadAndExpandDotEnvFile(filename: string, environmentVariables: NodeJS.ProcessEnv, override?: boolean): import("dotenv-expand").DotenvExpandOutput;

@@ -82,5 +82,5 @@ "use strict";

* This function loads a .env file and expands the variables in it.
* It is going to override existing environmentVariables.
* @param filename
* @param environmentVariables
* @param filename the .env file to load
* @param environmentVariables the object to load environment variables into
* @param override whether to override existing environment variables
*/

@@ -87,0 +87,0 @@ function loadAndExpandDotEnvFile(filename, environmentVariables, override = false) {

@@ -15,2 +15,3 @@ import { TaskHasher } from '../hasher/task-hasher';

private readonly daemon;
private readonly outputStyle;
private cache;

@@ -27,3 +28,3 @@ private forkedProcessTaskRunner;

private bailed;
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, options: DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient);
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, options: DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string);
run(): Promise<{

@@ -30,0 +31,0 @@ [id: string]: TaskStatus;

@@ -22,3 +22,3 @@ "use strict";

// endregion internal state
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon) {
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon, outputStyle) {
this.hasher = hasher;

@@ -31,2 +31,3 @@ this.initiatingProject = initiatingProject;

this.daemon = daemon;
this.outputStyle = outputStyle;
this.cache = process.env.NX_DB_CACHE === 'true'

@@ -214,3 +215,5 @@ ? new cache_1.DbCache({

const temporaryOutputPath = this.cache.temporaryOutputPath(task);
const streamOutput = (0, utils_1.shouldStreamOutput)(task, this.initiatingProject);
const streamOutput = this.outputStyle === 'static'
? false
: (0, utils_1.shouldStreamOutput)(task, this.initiatingProject);
let env = pipeOutput

@@ -217,0 +220,0 @@ ? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, process.env.FORCE_COLOR === undefined

@@ -35,3 +35,3 @@ import type { Arguments } from 'yargs';

export declare function createOverrides(__overrides_unparsed__?: string[]): Record<string, any>;
export declare function getBaseRef(nxJson: NxJsonConfiguration): string;
export declare function getBaseRef(nxJson: NxJsonConfiguration, head?: string): string;
export declare function splitArgsIntoNxArgsAndOverrides(args: {

@@ -38,0 +38,0 @@ [k: string]: any;

@@ -28,4 +28,12 @@ "use strict";

}
function getBaseRef(nxJson) {
return nxJson.defaultBase ?? nxJson.affected?.defaultBase ?? 'main';
function getBaseRef(nxJson, head) {
try {
const baseRes = (0, child_process_1.execSync)(`git rev-parse ${head ? `${head}~1` : 'HEAD~1'}`, {
encoding: 'utf-8',
});
return (nxJson.defaultBase ?? nxJson.affected?.defaultBase ?? baseRes ?? 'main');
}
catch {
return undefined;
}
}

@@ -96,3 +104,3 @@ function splitArgsIntoNxArgsAndOverrides(args, mode, options = { printWarnings: true }, nxJson) {

if (!nxArgs.base) {
nxArgs.base = getBaseRef(nxJson);
nxArgs.base = getBaseRef(nxJson, nxArgs.head);
// No user-provided arguments to set the affected criteria, so inform the user of the defaults being used

@@ -214,2 +222,11 @@ if (options.printWarnings &&

}
else if (head && !base) {
return {
files: Array.from(new Set([
...getAllFilesOfFirstCommit(head),
...getUncommittedFiles(),
...getUntrackedFiles(),
])),
};
}
}

@@ -250,2 +267,5 @@ function getUncommittedFiles() {

}
function getAllFilesOfFirstCommit(head) {
return parseGitOutput(`git --no-pager show --name-only "${head}"`);
}
function parseGitOutput(command) {

@@ -252,0 +272,0 @@ return (0, child_process_1.execSync)(command, { maxBuffer: file_utils_1.TEN_MEGABYTES, cwd: workspace_root_1.workspaceRoot })

@@ -1,4 +0,4 @@

export declare function cloneFromUpstream(url: string, destination: string, { originName, depth }?: {
import { ExecSyncOptions } from 'child_process';
export declare function cloneFromUpstream(url: string, destination: string, { originName }?: {
originName: string;
depth?: number;
}): Promise<GitRepository>;

@@ -16,2 +16,3 @@ export declare class GitRepository {

reset(ref: string): Promise<string>;
squashLastTwoCommits(): Promise<string>;
mergeUnrelatedHistories(ref: string, message: string): Promise<string>;

@@ -28,4 +29,4 @@ fetch(remote: string, ref?: string): Promise<string>;

deleteGitRemote(name: string): Promise<string>;
deleteBranch(branch: string): Promise<string>;
addGitRemote(name: string, url: string): Promise<string>;
filterBranch(subdirectory: string, branchName: string): Promise<string>;
}

@@ -36,2 +37,3 @@ /**

export declare function updateRebaseFile(contents: string): string;
export declare function fetchGitRemote(name: string, branch: string, execOptions: ExecSyncOptions): string | Buffer;
/**

@@ -38,0 +40,0 @@ * This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.

@@ -6,2 +6,3 @@ "use strict";

exports.updateRebaseFile = updateRebaseFile;
exports.fetchGitRemote = fetchGitRemote;
exports.getGithubSlugOrNull = getGithubSlugOrNull;

@@ -14,2 +15,3 @@ exports.extractUserAndRepoFromGitHubUrl = extractUserAndRepoFromGitHubUrl;

const path_1 = require("path");
const SQUASH_EDITOR = (0, path_1.join)(__dirname, 'squash.js');
function execAsync(command, execOptions) {

@@ -25,6 +27,4 @@ return new Promise((res, rej) => {

}
async function cloneFromUpstream(url, destination, { originName, depth } = {
originName: 'origin',
}) {
await execAsync(`git clone ${url} ${destination} ${depth ? `--depth ${depth}` : ''} --origin ${originName}`, {
async function cloneFromUpstream(url, destination, { originName } = { originName: 'origin' }) {
await execAsync(`git clone ${url} ${destination} --depth 1 --origin ${originName}`, {
cwd: (0, path_1.dirname)(destination),

@@ -46,4 +46,4 @@ });

}
async addFetchRemote(remoteName, branch) {
return await this.execAsync(`git config --add remote.${remoteName}.fetch "+refs/heads/${branch}:refs/remotes/${remoteName}/${branch}"`);
addFetchRemote(remoteName, branch) {
return this.execAsync(`git config --add remote.${remoteName}.fetch "+refs/heads/${branch}:refs/remotes/${remoteName}/${branch}"`);
}

@@ -75,35 +75,36 @@ execAsync(command) {

async reset(ref) {
return await this.execAsync(`git reset ${ref} --hard`);
return this.execAsync(`git reset ${ref} --hard`);
}
async squashLastTwoCommits() {
return this.execAsync(`git -c core.editor="node ${SQUASH_EDITOR}" rebase --interactive --no-autosquash HEAD~2`);
}
async mergeUnrelatedHistories(ref, message) {
return await this.execAsync(`git merge ${ref} -X ours --allow-unrelated-histories -m "${message}"`);
return this.execAsync(`git merge ${ref} -X ours --allow-unrelated-histories -m "${message}"`);
}
async fetch(remote, ref) {
return await this.execAsync(`git fetch ${remote}${ref ? ` ${ref}` : ''}`);
return this.execAsync(`git fetch ${remote}${ref ? ` ${ref}` : ''}`);
}
async checkout(branch, opts) {
return await this.execAsync(`git checkout ${opts.new ? '-b ' : ' '}${branch}${opts.base ? ' ' + opts.base : ''}`);
return this.execAsync(`git checkout ${opts.new ? '-b ' : ' '}${branch}${opts.base ? ' ' + opts.base : ''}`);
}
async move(path, destination) {
return await this.execAsync(`git mv "${path}" "${destination}"`);
return this.execAsync(`git mv "${path}" "${destination}"`);
}
async push(ref, remoteName) {
return await this.execAsync(`git push -u -f ${remoteName} ${ref}`);
return this.execAsync(`git push -u -f ${remoteName} ${ref}`);
}
async commit(message) {
return await this.execAsync(`git commit -am "${message}"`);
return this.execAsync(`git commit -am "${message}"`);
}
async amendCommit() {
return await this.execAsync(`git commit --amend -a --no-edit`);
return this.execAsync(`git commit --amend -a --no-edit`);
}
async deleteGitRemote(name) {
return await this.execAsync(`git remote rm ${name}`);
deleteGitRemote(name) {
return this.execAsync(`git remote rm ${name}`);
}
async addGitRemote(name, url) {
return await this.execAsync(`git remote add ${name} ${url}`);
deleteBranch(branch) {
return this.execAsync(`git branch -D ${branch}`);
}
async filterBranch(subdirectory, branchName) {
// We need non-ASCII file names to not be quoted, or else filter-branch will exclude them.
await this.execAsync(`git config core.quotepath false`);
return await this.execAsync(`git filter-branch --subdirectory-filter ${subdirectory} -- ${branchName}`);
addGitRemote(name, url) {
return this.execAsync(`git remote add ${name} ${url}`);
}

@@ -121,2 +122,5 @@ }

}
function fetchGitRemote(name, branch, execOptions) {
return (0, child_process_1.execSync)(`git fetch ${name} ${branch} --depth 1`, execOptions);
}
/**

@@ -123,0 +127,0 @@ * This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.

import type { GeneratorCallback } from '../config/misc-interfaces';
import { type NxJsonConfiguration } from '../config/nx-json';
import type { ProjectGraph } from '../config/project-graph';
import type { TaskGraph } from '../config/task-graph';
import type { ProjectConfiguration } from '../config/workspace-json-project-json';

@@ -18,6 +20,7 @@ import { FsTree, type FileChange, type Tree } from '../generators/tree';

export declare function flushSyncGeneratorChanges(results: SyncGeneratorChangesResult[]): Promise<void>;
export declare function collectAllRegisteredSyncGenerators(projectGraph: ProjectGraph): Promise<string[]>;
export declare function collectAllRegisteredSyncGenerators(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Promise<string[]>;
export declare function runSyncGenerator(tree: FsTree, generatorSpecifier: string, projects: Record<string, ProjectConfiguration>): Promise<SyncGeneratorChangesResult>;
export declare function collectRegisteredTaskSyncGenerators(projectGraph: ProjectGraph): Set<string>;
export declare function collectRegisteredGlobalSyncGenerators(nxJson?: import("../config/nx-json").NxJsonConfiguration<string[] | "*">): Set<string>;
export declare function collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Set<string>;
export declare function collectEnabledTaskSyncGeneratorsFromTaskGraph(taskGraph: TaskGraph, projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Set<string>;
export declare function collectRegisteredGlobalSyncGenerators(nxJson?: NxJsonConfiguration<string[] | "*">): Set<string>;
export declare function syncGeneratorResultsToMessageLines(results: SyncGeneratorChangesResult[]): string[];

@@ -7,3 +7,4 @@ "use strict";

exports.runSyncGenerator = runSyncGenerator;
exports.collectRegisteredTaskSyncGenerators = collectRegisteredTaskSyncGenerators;
exports.collectEnabledTaskSyncGeneratorsFromProjectGraph = collectEnabledTaskSyncGeneratorsFromProjectGraph;
exports.collectEnabledTaskSyncGeneratorsFromTaskGraph = collectEnabledTaskSyncGeneratorsFromTaskGraph;
exports.collectRegisteredGlobalSyncGenerators = collectRegisteredGlobalSyncGenerators;

@@ -43,6 +44,6 @@ exports.syncGeneratorResultsToMessageLines = syncGeneratorResultsToMessageLines;

}
async function collectAllRegisteredSyncGenerators(projectGraph) {
async function collectAllRegisteredSyncGenerators(projectGraph, nxJson) {
if (!client_1.daemonClient.enabled()) {
return [
...collectRegisteredTaskSyncGenerators(projectGraph),
...collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph, nxJson),
...collectRegisteredGlobalSyncGenerators(),

@@ -74,4 +75,5 @@ ];

}
function collectRegisteredTaskSyncGenerators(projectGraph) {
function collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph, nxJson) {
const taskSyncGenerators = new Set();
const disabledTaskSyncGenerators = new Set(nxJson.sync?.disabledTaskSyncGenerators ?? []);
for (const { data: { targets }, } of Object.values(projectGraph.nodes)) {

@@ -82,6 +84,26 @@ if (!targets) {

for (const target of Object.values(targets)) {
if (!target.syncGenerators) {
if (!target.syncGenerators?.length) {
continue;
}
for (const generator of target.syncGenerators) {
if (!disabledTaskSyncGenerators.has(generator) &&
!taskSyncGenerators.has(generator)) {
taskSyncGenerators.add(generator);
}
}
}
}
return taskSyncGenerators;
}
function collectEnabledTaskSyncGeneratorsFromTaskGraph(taskGraph, projectGraph, nxJson) {
const taskSyncGenerators = new Set();
const disabledTaskSyncGenerators = new Set(nxJson.sync?.disabledTaskSyncGenerators ?? []);
for (const { target } of Object.values(taskGraph.tasks)) {
const { syncGenerators } = projectGraph.nodes[target.project].data.targets[target.target];
if (!syncGenerators?.length) {
continue;
}
for (const generator of syncGenerators) {
if (!disabledTaskSyncGenerators.has(generator) &&
!taskSyncGenerators.has(generator)) {
taskSyncGenerators.add(generator);

@@ -88,0 +110,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc