Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More ā†’
Socket
Sign inDemoInstall
Socket

nx-ignore

Package Overview
Dependencies
Maintainers
3
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nx-ignore - npm Package Compare versions

Comparing version 18.3.0 to 18.3.1

2

package.json
{
"name": "nx-ignore",
"version": "18.3.0",
"version": "18.3.1",
"type": "commonjs",

@@ -5,0 +5,0 @@ "repository": {

@@ -17,3 +17,4 @@ # nx-ignore

- `--base` - Set a custom base SHA to compare changes (defaults to `CACHED_COMMIT_REF` on Netlify or `VERCEL_GIT_PREVIOUS_SHA` on Vercel)
- `--additional-packages` - List of additional npm packages to install when using `--slim-install`. Use this for packages required in configuration files that infer Nx targets (e.g. `@playwright/test`). Defaults to a list of known packages required by Nx and Nx plugins.
- `--base` - Set a custom base SHA to compare changes (defaults to `CACHED_COMMIT_REF` on Netlify or `VERCEL_GIT_PREVIOUS_SHA` on Vercel).
- `--plugins` - List of Nx plugins required (i.e. plugins that extend the Nx graph). Default plugins are read from nx.json.

@@ -41,1 +42,15 @@ - `--root` - Set a custom workspace root (defaults to current working directory).

The `nx-ignore` command uses Nx to determine whether the current commit affects the specified app. It exits with an error code (1) when the app is affected, which tells the platform to continue the build, otherwise it exits successfully, which tells the platform to cancel the build.
## Troubleshooting
### Error `Failed to process project graph` occurs on Netlify
When `plugins` are used in `nx.json`, Nx infers projects and targets through those plugins via their corresponding configuration files. For example, `@nx/next/plugin` infers projects and targets from `next.config.js` files. This means that modules imported in `next.config.js` must be present in order for Nx to work correctly.
If you run into the `Failed to process project graph` error, it means that some of the packages are missing. To debug what packages are missing, run `npx nx-ignore@latest <app> --verbose --slim-install` locally, and you should see and error with the missing package. You can also run `npx nx show projects` to debug any missing packages, after running the `npx nx-ignore` command.
Use the `--additional-packages` option to install the missing packages as detected above. For example,
```
npx nx-ignore@latest <app> --verbose --slim-install --additional-packages=@playwright/test,jest-environment-jsdom
```

@@ -13,3 +13,6 @@ #!/usr/bin/env node

declare const userDefinedPlugins: string[] | null;
declare const userDefinedPackagesArg: string;
declare const userDefinedPackages: string[] | null;
declare const isVerbose: boolean;
declare const isNetlify: boolean;
declare const isSlimInstall: boolean;

@@ -25,2 +28,3 @@ declare const headSha = "HEAD";

declare function slimNxInstallation(root: string, plugins: string[]): string | null;
declare function detectRequiredPackages(root: string): Record<string, string>;
declare function isPackageManagerInstalled(pm: 'yarn' | 'pnpm'): boolean;

@@ -27,0 +31,0 @@ declare function commitHasSkipMessage(message: string): boolean;

@@ -19,3 +19,8 @@ #!/usr/bin/env node

const userDefinedPlugins = userDefinedPluginsArg ? userDefinedPluginsArg.slice(10).split(',') : null;
const userDefinedPackagesArg = args.find((s)=>s.startsWith('--additional-packages=') || s.startsWith('--additional-packages '));
const userDefinedPackages = userDefinedPackagesArg ? userDefinedPackagesArg.slice(10).split(',') : null;
const isVerbose = args.some((s)=>s === '--verbose');
// This is always "true" when running on Netlify
// See: https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
const isNetlify = !!process.env.NETLIFY;
const isSlimInstall = args.some((s)=>s === '--slim-install' || s === '--slimInstall');

@@ -69,3 +74,3 @@ const headSha = 'HEAD';

if (e.stderr) console.error(e.stderr.toString());
exitWithoutBuild(`šŸ›‘ - Build cancelled due to the error above (Hint: commit with "[nx deploy]" to force deployment)`);
exitWithoutBuild(`šŸ›‘ - Build cancelled due to the error above, you may need to use --additional-packages option if using Nx plugins to infer targets e.g. Project Crystal (Hint: commit with "[nx deploy]" to force deployment if necessary)`);
}

@@ -102,7 +107,10 @@ const projects = JSON.parse(readFileSync(graphJsonPath).toString()).affectedProjects;

// This will make the install slower, so users can pass --slim-install to force a slim installation if it works for their repo.
if (plugins.length > 0 && !isSlimInstall) {
if (isNetlify) {
logDebug('Performing a slim installation of Nx because Netlify times out during full installation.');
return slimNxInstallation(root, plugins);
} else if (plugins.length > 0 && !isSlimInstall) {
logDebug('Performing a full installation because Nx plugins are used. Override this behavior with `--slim-install`.');
return fullNxInstallation(root);
} else {
logDebug(`Performing a slim installation of Nx and necessary plugins.`);
logDebug(`Performing a slim installation of Nx.`);
return slimNxInstallation(root, plugins);

@@ -152,13 +160,6 @@ }

const json = {
name: originalPackageJson.name
name: originalPackageJson.name,
dependencies: detectRequiredPackages(root)
};
json.dependencies = {
nx: deps['nx'],
typescript: deps['typescript']
};
// SWC is required when transpiling local plugins
if (deps['@swc/core'] && deps['@swc-node/register']) {
json.dependencies['@swc/core'] = deps['@swc/core'];
json.dependencies['@swc-node/register'] = deps['@swc-node/register'];
}
logDebug(`ā‰« Adding packages: ${Object.keys(json.dependencies).join(',')}`);
plugins.forEach((plugin)=>{

@@ -203,2 +204,3 @@ // Normalize deep imports into the package to install (e.g. `@nx/next/plugin` into `@nx/next`)

} catch (e) {
logDebug(`Error: ${e}`);
// nothing

@@ -208,2 +210,42 @@ }

}
function detectRequiredPackages(root) {
const knownPackagesUsedByConfigFilesForTargetInference = [
/^nx$/,
/@nx\/eslint-plugin/,
/^typescript$/,
/@typescript-eslint\//,
/^@swc\/core$/,
/^@swc-node\/register$/,
/^cypress$/,
/@cypress\//,
/^cypress-/,
/^eslint-/,
/^jest$/,
/^jest-/,
/^next$/,
/^nuxt$/,
/@playwright\//,
/@rollup\//,
/^rollup-plugin-/,
/^vite$/,
/^vite-plugin-/,
/@vitejs\//
];
const packages = {};
const packageJson = require(join(root, 'package.json'));
// Find common packages required by Nx plugins and their corresponding config files.
// e.g. `@nx/playwright/plugin` reads `playwright.config.ts` which requires `@playwright/test`
const deps = _extends._({}, packageJson.dependencies, packageJson.devDependencies);
for (const pkg of userDefinedPackages != null ? userDefinedPackages : []){
if (deps[pkg]) {
packages[pkg] = deps[pkg];
}
}
for (const pkg of Object.keys(deps)){
if (knownPackagesUsedByConfigFilesForTargetInference.some((r)=>r.test(pkg))) {
packages[pkg] = deps[pkg];
}
}
return packages;
}
function isPackageManagerInstalled(pm) {

@@ -210,0 +252,0 @@ try {

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