Skip to content

Commit 6c109d2

Browse files
authored
fix(core): add env var to disable fetching migration metadata from registry (#32850)
Add a new `NX_MIGRATE_SKIP_REGISTRY_FETCH` environment variable to opt out of fetching package versions and migrations metadata from the registry and instead, use package installation to get the information.
1 parent 5ea2e47 commit 6c109d2

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

astro-docs/src/content/docs/reference/environment-variables.mdoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The following environment variables are ones that you can set to change the beha
4141
| `NX_BATCH_MODE` | boolean | If set to `true`, Nx will run task(s) in batches for executors which support batches. |
4242
| `NX_SKIP_LOG_GROUPING` | boolean | If set to `true`, Nx will not group command's logs on CI. |
4343
| `NX_MIGRATE_CLI_VERSION` | string | The version of Nx to use for running the `nx migrate` command. If not set, it defaults to `latest`. |
44+
| NX_MIGRATE_SKIP_REGISTRY_FETCH | boolean | If set to `true`, will skip fetching metadata from the registry and instead use the installation method directly. |
4445
| `NX_LOAD_DOT_ENV_FILES` | boolean | If set to 'false', Nx will not load any environment files (e.g. `.local.env`, `.env.local`) |
4546
| `NX_MAX_CACHE_SIZE` | string | Alternative to configuring `maxCacheSize` in `nx.json`. Defines the maximum size of the local task cache. See [`maxCacheSize`](/docs/reference/nx-json#max-cache-size) for supported units and behavior details. |
4647
| `NX_NATIVE_FILE_CACHE_DIRECTORY` | string | The cache for native `.node` files is stored under a global temp directory by default. Set this variable to use a different directory. This is interpreted as an absolute path. |

docs/shared/reference/environment-variables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The following environment variables are ones that you can set to change the beha
3838
| NX_BATCH_MODE | boolean | If set to `true`, Nx will run task(s) in batches for executors which support batches. |
3939
| NX_SKIP_LOG_GROUPING | boolean | If set to `true`, Nx will not group command's logs on CI. |
4040
| NX_MIGRATE_CLI_VERSION | string | The version of Nx to use for running the `nx migrate` command. If not set, it defaults to `latest`. |
41+
| NX_MIGRATE_SKIP_REGISTRY_FETCH | boolean | If set to `true`, will skip fetching metadata from the registry and instead use the installation method directly. |
4142
| NX_LOAD_DOT_ENV_FILES | boolean | If set to 'false', Nx will not load any environment files (e.g. `.local.env`, `.env.local`) |
4243
| NX_MAX_CACHE_SIZE | string | Alternative to configuring `maxCacheSize` in `nx.json`. Defines the maximum size of the local task cache. See [`maxCacheSize`](/reference/nx-json#max-cache-size) for supported units and behavior details. |
4344
| NX_NATIVE_FILE_CACHE_DIRECTORY | string | The cache for native `.node` files is stored under a global temp directory by default. Set this variable to use a different directory. This is interpreted as an absolute path. |

packages/nx/src/command-line/migrate/migrate.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,12 @@ function createFetcher() {
926926
packageVersion,
927927
setCache: (packageName: string, packageVersion: string) => void
928928
): Promise<ResolvedMigrationConfiguration> {
929+
if (process.env.NX_MIGRATE_SKIP_REGISTRY_FETCH === 'true') {
930+
// Skip registry fetch and use installation method directly
931+
logger.info(`Fetching ${packageName}@${packageVersion}`);
932+
return getPackageMigrationsUsingInstall(packageName, packageVersion);
933+
}
934+
929935
const cacheKey = packageName + '-' + packageVersion;
930936
return Promise.resolve(resolvedVersionCache[cacheKey])
931937
.then((cachedResolvedVersion) => {

0 commit comments

Comments
 (0)