feat(core): use flag in nx.json for toggling crystal (#21980)
This commit is contained in:
parent
e9da3db560
commit
a89c73483e
@ -38,6 +38,7 @@ Nx.json configuration
|
||||
- [targetDefaults](../../devkit/documents/NxJsonConfiguration#targetdefaults): TargetDefaults
|
||||
- [tasksRunnerOptions](../../devkit/documents/NxJsonConfiguration#tasksrunneroptions): Object
|
||||
- [useDaemonProcess](../../devkit/documents/NxJsonConfiguration#usedaemonprocess): boolean
|
||||
- [useInferencePlugins](../../devkit/documents/NxJsonConfiguration#useinferenceplugins): boolean
|
||||
- [workspaceLayout](../../devkit/documents/NxJsonConfiguration#workspacelayout): Object
|
||||
|
||||
## Properties
|
||||
@ -248,6 +249,14 @@ Set this to false to disable the daemon.
|
||||
|
||||
---
|
||||
|
||||
### useInferencePlugins
|
||||
|
||||
• `Optional` **useInferencePlugins**: `boolean`
|
||||
|
||||
Set this to false to disable adding inference plugins when generating new projects
|
||||
|
||||
---
|
||||
|
||||
### workspaceLayout
|
||||
|
||||
• `Optional` **workspaceLayout**: `Object`
|
||||
|
||||
@ -37,6 +37,7 @@ use ProjectsConfigurations or NxJsonConfiguration
|
||||
- [targetDefaults](../../devkit/documents/Workspace#targetdefaults): TargetDefaults
|
||||
- [tasksRunnerOptions](../../devkit/documents/Workspace#tasksrunneroptions): Object
|
||||
- [useDaemonProcess](../../devkit/documents/Workspace#usedaemonprocess): boolean
|
||||
- [useInferencePlugins](../../devkit/documents/Workspace#useinferenceplugins): boolean
|
||||
- [version](../../devkit/documents/Workspace#version): number
|
||||
- [workspaceLayout](../../devkit/documents/Workspace#workspacelayout): Object
|
||||
|
||||
@ -340,6 +341,18 @@ Set this to false to disable the daemon.
|
||||
|
||||
---
|
||||
|
||||
### useInferencePlugins
|
||||
|
||||
• `Optional` **useInferencePlugins**: `boolean`
|
||||
|
||||
Set this to false to disable adding inference plugins when generating new projects
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[NxJsonConfiguration](../../devkit/documents/NxJsonConfiguration).[useInferencePlugins](../../devkit/documents/NxJsonConfiguration#useinferenceplugins)
|
||||
|
||||
---
|
||||
|
||||
### version
|
||||
|
||||
• **version**: `number`
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
joinPathFragments,
|
||||
readProjectConfiguration,
|
||||
updateProjectConfiguration,
|
||||
readNxJson,
|
||||
} from '@nx/devkit';
|
||||
import { nxVersion } from '../../../utils/versions';
|
||||
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
|
||||
@ -15,7 +16,10 @@ import type { NormalizedSchema } from './normalized-schema';
|
||||
|
||||
export async function addE2e(tree: Tree, options: NormalizedSchema) {
|
||||
// since e2e are separate projects, default to adding plugins
|
||||
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
if (options.e2eTestRunner === 'cypress') {
|
||||
// TODO: This can call `@nx/web:static-config` generator when ready
|
||||
|
||||
@ -11,6 +11,7 @@ import {
|
||||
joinPathFragments,
|
||||
offsetFromRoot,
|
||||
readJson,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
stripIndents,
|
||||
updateJson,
|
||||
@ -342,6 +343,10 @@ export class E2eMigrator extends ProjectMigrator<SupportedTargets> {
|
||||
tags: [],
|
||||
implicitDependencies: [this.appName],
|
||||
});
|
||||
const nxJson = readNxJson(this.tree) ?? {};
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
await configurationGenerator(this.tree, {
|
||||
project: this.project.name,
|
||||
linter: this.isProjectUsingEsLint ? Linter.EsLint : Linter.None,
|
||||
@ -349,7 +354,7 @@ export class E2eMigrator extends ProjectMigrator<SupportedTargets> {
|
||||
// any target would do, we replace it later with the target existing in the project being migrated
|
||||
devServerTarget: `${this.appName}:serve`,
|
||||
baseUrl: 'http://localhost:4200',
|
||||
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
||||
addPlugin,
|
||||
});
|
||||
|
||||
const cypressConfigFilePath = this.updateOrCreateCypressConfigFile(
|
||||
|
||||
@ -43,7 +43,7 @@ export async function componentConfigurationGeneratorInternal(
|
||||
options: CypressComponentConfigurationSchema
|
||||
) {
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
const opts = normalizeOptions(options);
|
||||
const opts = normalizeOptions(tree, options);
|
||||
|
||||
tasks.push(
|
||||
await init(tree, {
|
||||
@ -78,7 +78,10 @@ export async function componentConfigurationGeneratorInternal(
|
||||
return runTasksInSerial(...tasks);
|
||||
}
|
||||
|
||||
function normalizeOptions(options: CypressComponentConfigurationSchema) {
|
||||
function normalizeOptions(
|
||||
tree: Tree,
|
||||
options: CypressComponentConfigurationSchema
|
||||
) {
|
||||
const cyVersion = installedCypressVersion();
|
||||
if (cyVersion && cyVersion < 10) {
|
||||
throw new Error(
|
||||
@ -86,8 +89,13 @@ function normalizeOptions(options: CypressComponentConfigurationSchema) {
|
||||
);
|
||||
}
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
return {
|
||||
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
||||
addPlugin,
|
||||
...options,
|
||||
directory: options.directory ?? 'cypress',
|
||||
};
|
||||
|
||||
@ -150,6 +150,11 @@ In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:
|
||||
throw new Error('Either baseUrl or devServerTarget must be provided');
|
||||
}
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
options.addPlugin ??=
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
return {
|
||||
...options,
|
||||
bundler: options.bundler ?? 'webpack',
|
||||
|
||||
@ -105,7 +105,12 @@ export async function cypressInitGeneratorInternal(
|
||||
options: Schema
|
||||
) {
|
||||
updateProductionFileset(tree);
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
|
||||
options.addPlugin ??=
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
if (options.addPlugin) {
|
||||
addPlugin(tree);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { names, readProjectConfiguration, Tree } from '@nx/devkit';
|
||||
import { names, readNxJson, readProjectConfiguration, Tree } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Schema } from '../schema';
|
||||
|
||||
@ -23,8 +23,11 @@ export async function normalizeOptions(
|
||||
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
||||
callingGenerator: '@nx/detox:application',
|
||||
});
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
const { fileName: appFileName, className: appClassName } = names(
|
||||
options.appName || options.appProject
|
||||
|
||||
@ -20,7 +20,12 @@ export function detoxInitGenerator(host: Tree, schema: Schema) {
|
||||
export async function detoxInitGeneratorInternal(host: Tree, schema: Schema) {
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
|
||||
if (!schema.skipPackageJson) {
|
||||
tasks.push(moveDependency(host));
|
||||
|
||||
@ -74,7 +74,11 @@ export async function initEsLint(
|
||||
tree: Tree,
|
||||
options: LinterInitOptions
|
||||
): Promise<GeneratorCallback> {
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
const hasPlugin = hasEslintPlugin(tree);
|
||||
const rootEslintFile = findEslintFile(tree);
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import type {
|
||||
Tree,
|
||||
} from '@nx/devkit';
|
||||
import {
|
||||
readNxJson,
|
||||
formatFiles,
|
||||
offsetFromRoot,
|
||||
readJson,
|
||||
@ -67,7 +68,11 @@ export async function lintProjectGeneratorInternal(
|
||||
tree: Tree,
|
||||
options: LintProjectOptions
|
||||
) {
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
const initTask = await lintInitGenerator(tree, {
|
||||
skipPackageJson: options.skipPackageJson,
|
||||
|
||||
@ -5,6 +5,7 @@ import {
|
||||
generateFiles,
|
||||
joinPathFragments,
|
||||
logger,
|
||||
readNxJson,
|
||||
Tree,
|
||||
} from '@nx/devkit';
|
||||
import { camelize } from '@nx/devkit/src/utils/string-utils';
|
||||
@ -22,10 +23,16 @@ export async function lintWorkspaceRuleGenerator(
|
||||
tree: Tree,
|
||||
options: LintWorkspaceRuleGeneratorOptions
|
||||
) {
|
||||
const nxJson = readNxJson(tree);
|
||||
// Ensure that the workspace rules project has been created
|
||||
const projectGeneratorCallback = await lintWorkspaceRulesProjectGenerator(
|
||||
tree,
|
||||
{ skipFormat: true, addPlugin: process.env.NX_ADD_PLUGINS !== 'false' }
|
||||
{
|
||||
skipFormat: true,
|
||||
addPlugin:
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false,
|
||||
}
|
||||
);
|
||||
|
||||
const ruleDir = joinPathFragments(
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { names, Tree } from '@nx/devkit';
|
||||
import { names, readNxJson, Tree } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Schema } from '../schema';
|
||||
|
||||
@ -30,7 +30,11 @@ export async function normalizeOptions(
|
||||
callingGenerator: '@nx/expo:application',
|
||||
});
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const { className } = names(options.name);
|
||||
const parsedTags = options.tags
|
||||
|
||||
@ -28,7 +28,11 @@ export function expoInitGenerator(tree: Tree, schema: Schema) {
|
||||
}
|
||||
|
||||
export async function expoInitGeneratorInternal(host: Tree, schema: Schema) {
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
|
||||
addGitIgnoreEntry(host);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Tree } from '@nx/devkit';
|
||||
import { Tree, readNxJson } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Schema } from '../schema';
|
||||
|
||||
@ -28,7 +28,11 @@ export async function normalizeOptions(
|
||||
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
||||
callingGenerator: '@nx/expo:library',
|
||||
});
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const parsedTags = options.tags
|
||||
? options.tags.split(',').map((s) => s.trim())
|
||||
|
||||
@ -2,6 +2,7 @@ import type { GeneratorCallback, Tree } from '@nx/devkit';
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
formatFiles,
|
||||
readNxJson,
|
||||
runTasksInSerial,
|
||||
toJS,
|
||||
updateJson,
|
||||
@ -114,7 +115,11 @@ async function normalizeOptions(
|
||||
callingGenerator: '@nx/express:application',
|
||||
});
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
return {
|
||||
...options,
|
||||
|
||||
@ -36,7 +36,12 @@ function normalizeOptions(
|
||||
options.testEnvironment = 'jsdom';
|
||||
}
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
options.targetName ??= 'test';
|
||||
|
||||
|
||||
@ -110,7 +110,11 @@ export async function jestInitGeneratorInternal(
|
||||
tree: Tree,
|
||||
options: JestInitSchema
|
||||
): Promise<GeneratorCallback> {
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const presetExt = isPresetCjs(tree) ? 'cjs' : 'js';
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
names,
|
||||
offsetFromRoot,
|
||||
ProjectConfiguration,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
runTasksInSerial,
|
||||
toJS,
|
||||
@ -585,7 +586,11 @@ async function normalizeOptions(
|
||||
tree: Tree,
|
||||
options: LibraryGeneratorSchema
|
||||
): Promise<NormalizedSchema> {
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
/**
|
||||
* We are deprecating the compiler and the buildable options.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Tree } from '@nx/devkit';
|
||||
import { Tree, readNxJson } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Linter } from '@nx/eslint';
|
||||
import type { Schema as NodeApplicationGeneratorOptions } from '@nx/node/src/generators/application/schema';
|
||||
@ -23,8 +23,13 @@ export async function normalizeOptions(
|
||||
options.rootProject = appProjectRoot === '.';
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
return {
|
||||
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
||||
addPlugin,
|
||||
...options,
|
||||
strict: options.strict ?? false,
|
||||
appProjectName,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Tree } from '@nx/devkit';
|
||||
import { Tree, readNxJson } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { getNpmScope } from '@nx/js/src/utils/package-json/get-npm-scope';
|
||||
import type { LibraryGeneratorSchema as JsLibraryGeneratorSchema } from '@nx/js/src/utils/schema';
|
||||
@ -22,7 +22,12 @@ export async function normalizeOptions(
|
||||
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
||||
callingGenerator: '@nx/nest:library',
|
||||
});
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
const fileName = options.simpleName
|
||||
? projectNames.projectSimpleName
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { joinPathFragments, names, Tree } from '@nx/devkit';
|
||||
import { joinPathFragments, names, readNxJson, Tree } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Linter } from '@nx/eslint';
|
||||
import { assertValidStyle } from '@nx/react/src/utils/assertion';
|
||||
@ -34,7 +34,13 @@ export async function normalizeOptions(
|
||||
});
|
||||
options.rootProject = appProjectRoot === '.';
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
||||
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
||||
|
||||
@ -4,6 +4,7 @@ import {
|
||||
runTasksInSerial,
|
||||
type GeneratorCallback,
|
||||
type Tree,
|
||||
readNxJson,
|
||||
} from '@nx/devkit';
|
||||
import { updatePackageScripts } from '@nx/devkit/src/utils/update-package-scripts';
|
||||
import { reactDomVersion, reactVersion } from '@nx/react/src/utils/versions';
|
||||
@ -44,7 +45,12 @@ export async function nextInitGeneratorInternal(
|
||||
host: Tree,
|
||||
schema: InitSchema
|
||||
) {
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
if (schema.addPlugin) {
|
||||
addPlugin(host);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Tree } from '@nx/devkit';
|
||||
import { Tree, readNxJson } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Schema } from '../schema';
|
||||
|
||||
@ -21,7 +21,12 @@ export async function normalizeOptions(
|
||||
callingGenerator: '@nx/next:library',
|
||||
});
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
return {
|
||||
...options,
|
||||
|
||||
@ -10,6 +10,7 @@ import {
|
||||
names,
|
||||
offsetFromRoot,
|
||||
ProjectConfiguration,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
runTasksInSerial,
|
||||
TargetConfiguration,
|
||||
@ -543,8 +544,13 @@ async function normalizeOptions(
|
||||
? options.tags.split(',').map((s) => s.trim())
|
||||
: [];
|
||||
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
return {
|
||||
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
||||
addPlugin,
|
||||
...options,
|
||||
name: appProjectName,
|
||||
frontendProject: options.frontendProject
|
||||
|
||||
@ -7,6 +7,7 @@ import {
|
||||
joinPathFragments,
|
||||
names,
|
||||
offsetFromRoot,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
runTasksInSerial,
|
||||
Tree,
|
||||
@ -163,8 +164,13 @@ async function normalizeOptions(
|
||||
callingGenerator: null,
|
||||
});
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
return {
|
||||
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
||||
addPlugin,
|
||||
...options,
|
||||
e2eProjectRoot,
|
||||
e2eProjectName,
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
joinPathFragments,
|
||||
names,
|
||||
offsetFromRoot,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
runTasksInSerial,
|
||||
toJS,
|
||||
@ -101,7 +102,13 @@ async function normalizeOptions(
|
||||
callingGenerator: '@nx/node:library',
|
||||
});
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const fileName = getCaseAwareFileName({
|
||||
fileName: options.simpleModuleName
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
"18.0.0-disable-adding-plugins-for-existing-workspaces": {
|
||||
"cli": "nx",
|
||||
"version": "18.0.0-beta.2",
|
||||
"description": "Updates .env to disabled adding plugins when generating projects in an existing Nx workspace",
|
||||
"description": "Updates nx.json to disabled adding plugins when generating projects in an existing Nx workspace",
|
||||
"implementation": "./src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces",
|
||||
"x-repair-skip": true
|
||||
},
|
||||
|
||||
@ -101,6 +101,10 @@
|
||||
"type": "boolean",
|
||||
"description": "Specifies whether the daemon should be used for the default tasks runner."
|
||||
},
|
||||
"useInferencePlugins": {
|
||||
"type": "boolean",
|
||||
"description": "Specifies whether to add inference plugins when generating new projects."
|
||||
},
|
||||
"release": {
|
||||
"type": "object",
|
||||
"description": "Configuration for the nx release commands.",
|
||||
|
||||
@ -75,6 +75,7 @@ export const allowedWorkspaceExtensions = [
|
||||
'parallel',
|
||||
'cacheDirectory',
|
||||
'useDaemonProcess',
|
||||
'useInferencePlugins',
|
||||
] as const;
|
||||
|
||||
if (!patched) {
|
||||
|
||||
@ -112,6 +112,7 @@ async function initializePlugin(
|
||||
updatePackageScripts = options.updatePackageScripts;
|
||||
} else {
|
||||
updatePackageScripts =
|
||||
readNxJson().useInferencePlugins !== false &&
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
coreNxPlugins.includes(pkgName);
|
||||
}
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
import { Argv, CommandModule } from 'yargs';
|
||||
import { parseCSV } from '../yargs-utils/shared-options';
|
||||
import { readNxJson } from '../../config/nx-json';
|
||||
|
||||
const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false';
|
||||
const useV2 =
|
||||
process.env['NX_ADD_PLUGINS'] !== 'false' &&
|
||||
readNxJson().useInferencePlugins !== false;
|
||||
|
||||
export const yargsInitCommand: CommandModule = {
|
||||
command: 'init',
|
||||
|
||||
@ -392,6 +392,11 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
||||
* Set this to false to disable the daemon.
|
||||
*/
|
||||
useDaemonProcess?: boolean;
|
||||
|
||||
/**
|
||||
* Set this to false to disable adding inference plugins when generating new projects
|
||||
*/
|
||||
useInferencePlugins?: boolean;
|
||||
}
|
||||
|
||||
export type PluginConfiguration =
|
||||
|
||||
@ -1,29 +1,26 @@
|
||||
import { createTree } from '../../generators/testing-utils/create-tree';
|
||||
import { createTreeWithEmptyWorkspace } from '../../generators/testing-utils/create-tree-with-empty-workspace';
|
||||
import migrate from './disable-crystal-for-existing-workspaces';
|
||||
|
||||
describe('disable crystal for existing workspaces', () => {
|
||||
it("should create a .env if it doesn't exist", () => {
|
||||
const tree = createTree();
|
||||
it('should add flag to nx.json', () => {
|
||||
const tree = createTreeWithEmptyWorkspace();
|
||||
migrate(tree);
|
||||
expect(tree.read('.env', 'utf-8')).toMatchInlineSnapshot(`
|
||||
"# Nx 18 enables using plugins to infer targets by default
|
||||
# This is disabled for existing workspaces to maintain compatibility
|
||||
# For more info, see: https://nx.dev/concepts/inferred-tasks
|
||||
NX_ADD_PLUGINS=false"
|
||||
`);
|
||||
});
|
||||
|
||||
it('should update an existing .env', () => {
|
||||
const tree = createTree();
|
||||
tree.write('.env', 'FOO=bar');
|
||||
migrate(tree);
|
||||
expect(tree.read('.env', 'utf-8')).toMatchInlineSnapshot(`
|
||||
"FOO=bar
|
||||
|
||||
# Nx 18 enables using plugins to infer targets by default
|
||||
# This is disabled for existing workspaces to maintain compatibility
|
||||
# For more info, see: https://nx.dev/concepts/inferred-tasks
|
||||
NX_ADD_PLUGINS=false"
|
||||
expect(tree.read('nx.json', 'utf-8')).toMatchInlineSnapshot(`
|
||||
"{
|
||||
"affected": {
|
||||
"defaultBase": "main"
|
||||
},
|
||||
"targetDefaults": {
|
||||
"build": {
|
||||
"cache": true
|
||||
},
|
||||
"lint": {
|
||||
"cache": true
|
||||
}
|
||||
},
|
||||
"useInferencePlugins": false
|
||||
}
|
||||
"
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,33 +1,8 @@
|
||||
import { readNxJson, updateNxJson } from '../../generators/utils/nx-json';
|
||||
import { Tree } from '../../generators/tree';
|
||||
import { logger } from '../../utils/logger';
|
||||
import ignore from 'ignore';
|
||||
|
||||
export default function migrate(tree: Tree) {
|
||||
const ig = ignore();
|
||||
try {
|
||||
ig.add(tree.read('.gitignore', 'utf-8'));
|
||||
if (ig.ignores('.env')) {
|
||||
logger.warn(
|
||||
'NX The NX_ADD_PLUGINS=false environment variable was added to your .env file for backwards compatibility. However, your .env is ignored by git. Other contributors should add this key to their .env file or ensure that the environment variable is set to false when generating code with Nx.'
|
||||
);
|
||||
}
|
||||
} catch {}
|
||||
|
||||
if (!tree.exists('.env')) {
|
||||
tree.write('.env', '');
|
||||
}
|
||||
|
||||
const dotenv = tree.read('.env', 'utf-8');
|
||||
const newDotenvContents = [
|
||||
'# Nx 18 enables using plugins to infer targets by default',
|
||||
'# This is disabled for existing workspaces to maintain compatibility',
|
||||
'# For more info, see: https://nx.dev/concepts/inferred-tasks',
|
||||
'NX_ADD_PLUGINS=false',
|
||||
];
|
||||
|
||||
if (dotenv.length) {
|
||||
newDotenvContents.unshift(dotenv, '');
|
||||
}
|
||||
|
||||
tree.write('.env', newDotenvContents.join('\n'));
|
||||
const nxJson = readNxJson(tree);
|
||||
nxJson.useInferencePlugins = false;
|
||||
updateNxJson(tree, nxJson);
|
||||
}
|
||||
|
||||
@ -39,7 +39,10 @@ export async function configurationGeneratorInternal(
|
||||
tree: Tree,
|
||||
options: ConfigurationGeneratorSchema
|
||||
) {
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
options.addPlugin ??=
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
tasks.push(
|
||||
await initGenerator(tree, {
|
||||
|
||||
@ -22,7 +22,12 @@ export async function initGeneratorInternal(
|
||||
) {
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
if (!options.skipPackageJson) {
|
||||
tasks.push(
|
||||
|
||||
@ -11,6 +11,7 @@ import {
|
||||
names,
|
||||
offsetFromRoot,
|
||||
readJson,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
runTasksInSerial,
|
||||
updateProjectConfiguration,
|
||||
@ -37,7 +38,12 @@ async function normalizeOptions(
|
||||
): Promise<NormalizedSchema> {
|
||||
const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
let projectRoot: string;
|
||||
if (options.projectNameAndRootFormat === 'as-provided') {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { joinPathFragments, names, Tree } from '@nx/devkit';
|
||||
import { joinPathFragments, names, readNxJson, Tree } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Schema } from '../schema';
|
||||
|
||||
@ -34,7 +34,11 @@ export async function normalizeOptions(
|
||||
callingGenerator: '@nx/react-native:application',
|
||||
});
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const { className, fileName } = names(options.name);
|
||||
const iosProjectRoot = joinPathFragments(appProjectRoot, 'ios');
|
||||
|
||||
@ -32,7 +32,11 @@ export async function reactNativeInitGeneratorInternal(
|
||||
) {
|
||||
addGitIgnoreEntry(host);
|
||||
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
|
||||
if (schema.addPlugin) {
|
||||
addPlugin(host);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Tree } from '@nx/devkit';
|
||||
import { Tree, readNxJson } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { Schema } from '../schema';
|
||||
|
||||
@ -30,7 +30,11 @@ export async function normalizeOptions(
|
||||
callingGenerator: '@nx/react-native:library',
|
||||
});
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const parsedTags = options.tags
|
||||
? options.tags.split(',').map((s) => s.trim())
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Tree, logger } from '@nx/devkit';
|
||||
import { Tree, logger, readNxJson } from '@nx/devkit';
|
||||
import { storybookConfigurationGenerator as reactStorybookConfigurationGenerator } from '@nx/react';
|
||||
import { StorybookConfigureSchema } from './schema';
|
||||
|
||||
@ -23,7 +23,11 @@ export async function storybookConfigurationGeneratorInternal(
|
||||
logger.warn(
|
||||
`Please run 'nx run @nx/react:storybook-configuration ${schema.project}' instead.`
|
||||
);
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
|
||||
return reactStorybookConfigurationGenerator(host, schema);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Tree, extractLayoutDirectory, names } from '@nx/devkit';
|
||||
import { Tree, extractLayoutDirectory, names, readNxJson } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { assertValidStyle } from '../../../utils/assertion';
|
||||
import { NormalizedSchema, Schema } from '../schema';
|
||||
@ -33,7 +33,13 @@ export async function normalizeOptions<T extends Schema = Schema>(
|
||||
rootProject: options.rootProject,
|
||||
callingGenerator,
|
||||
});
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
options.rootProject = appProjectRoot === '.';
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import {
|
||||
ensurePackage,
|
||||
formatFiles,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
Tree,
|
||||
} from '@nx/devkit';
|
||||
@ -32,7 +33,12 @@ export async function cypressComponentConfigGeneratorInternal(
|
||||
typeof import('@nx/cypress')
|
||||
>('@nx/cypress', nxVersion);
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
const projectConfig = readProjectConfiguration(tree, options.project);
|
||||
const installTask = await baseCyCtConfig(tree, {
|
||||
|
||||
@ -3,6 +3,7 @@ import {
|
||||
joinPathFragments,
|
||||
logger,
|
||||
normalizePath,
|
||||
readNxJson,
|
||||
Tree,
|
||||
} from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
@ -26,7 +27,12 @@ export async function normalizeOptions(
|
||||
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
||||
callingGenerator: '@nx/react:library',
|
||||
});
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
options.addPlugin ??= addPlugin;
|
||||
|
||||
const fileName = options.simpleName
|
||||
? projectNames.projectSimpleName
|
||||
|
||||
@ -4,6 +4,7 @@ import {
|
||||
ensurePackage,
|
||||
formatFiles,
|
||||
joinPathFragments,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
Tree,
|
||||
} from '@nx/devkit';
|
||||
@ -47,7 +48,11 @@ export async function storybookConfigurationGeneratorInternal(
|
||||
host: Tree,
|
||||
schema: StorybookConfigureSchema
|
||||
) {
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
const { configurationGenerator } = ensurePackage<
|
||||
typeof import('@nx/storybook')
|
||||
>('@nx/storybook', nxVersion);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { type Tree } from '@nx/devkit';
|
||||
import { readNxJson, type Tree } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { type NxRemixGeneratorSchema } from '../schema';
|
||||
import { Linter } from '@nx/eslint';
|
||||
@ -26,7 +26,11 @@ export async function normalizeOptions(
|
||||
});
|
||||
options.rootProject = projectRoot === '.';
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const e2eProjectName = options.rootProject ? 'e2e' : `${projectName}-e2e`;
|
||||
const e2eProjectRoot = options.rootProject ? 'e2e' : `${projectRoot}-e2e`;
|
||||
|
||||
@ -2,6 +2,7 @@ import {
|
||||
formatFiles,
|
||||
generateFiles,
|
||||
readProjectConfiguration,
|
||||
readNxJson,
|
||||
type Tree,
|
||||
} from '@nx/devkit';
|
||||
import { join } from 'path';
|
||||
@ -22,7 +23,11 @@ export async function cypressComponentConfigurationGeneratorInternal(
|
||||
tree: Tree,
|
||||
options: CypressComponentConfigurationSchema
|
||||
) {
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
await cypressComponentConfigGenerator(tree, {
|
||||
project: options.project,
|
||||
generateTests: options.generateTests,
|
||||
|
||||
@ -62,7 +62,11 @@ export async function remixInitGeneratorInternal(tree: Tree, options: Schema) {
|
||||
tasks.push(installTask);
|
||||
}
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
if (options.addPlugin) {
|
||||
addPlugin(tree);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { Tree } from '@nx/devkit';
|
||||
import { type Tree, readNxJson } from '@nx/devkit';
|
||||
import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
||||
import { getImportPath } from '@nx/js/src/utils/get-import-path';
|
||||
import type { NxRemixGeneratorSchema } from '../schema';
|
||||
@ -21,7 +21,11 @@ export async function normalizeOptions(
|
||||
callingGenerator: '@nx/remix:library',
|
||||
});
|
||||
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const importPath = options.importPath ?? getImportPath(tree, projectRoot);
|
||||
|
||||
@ -31,5 +35,6 @@ export async function normalizeOptions(
|
||||
importPath,
|
||||
projectName,
|
||||
projectRoot,
|
||||
projectNameAndRootFormat,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { formatFiles, GeneratorCallback, Tree } from '@nx/devkit';
|
||||
import { formatFiles, GeneratorCallback, readNxJson, Tree } from '@nx/devkit';
|
||||
|
||||
import { runTasksInSerial } from '@nx/devkit';
|
||||
import applicationGenerator from '../application/application.impl';
|
||||
@ -13,6 +13,11 @@ export default async function (tree: Tree, _options: RemixGeneratorSchema) {
|
||||
const setupGenTask = await setupGenerator(tree);
|
||||
tasks.push(setupGenTask);
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
const appGenTask = await applicationGenerator(tree, {
|
||||
name: options.appName,
|
||||
tags: options.tags,
|
||||
@ -21,7 +26,7 @@ export default async function (tree: Tree, _options: RemixGeneratorSchema) {
|
||||
unitTestRunner: options.unitTestRunner ?? 'vitest',
|
||||
e2eTestRunner: options.e2eTestRunner ?? 'cypress',
|
||||
js: options.js ?? false,
|
||||
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
||||
addPlugin: addPluginDefault,
|
||||
});
|
||||
tasks.push(appGenTask);
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import {
|
||||
generateFiles,
|
||||
joinPathFragments,
|
||||
readProjectConfiguration,
|
||||
readNxJson,
|
||||
type Tree,
|
||||
} from '@nx/devkit';
|
||||
import { join } from 'path';
|
||||
@ -22,7 +23,11 @@ export default async function remixStorybookConfigurationInternal(
|
||||
tree: Tree,
|
||||
schema: StorybookConfigurationSchema
|
||||
) {
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
const { root } = readProjectConfiguration(tree, schema.project);
|
||||
|
||||
if (!tree.exists(joinPathFragments(root, 'vite.config.ts'))) {
|
||||
|
||||
@ -65,7 +65,7 @@ export async function configurationGeneratorInternal(
|
||||
throw new Error(pleaseUpgrade());
|
||||
}
|
||||
|
||||
const schema = normalizeSchema(rawSchema);
|
||||
const schema = normalizeSchema(tree, rawSchema);
|
||||
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
|
||||
@ -259,14 +259,20 @@ export async function configurationGeneratorInternal(
|
||||
}
|
||||
|
||||
function normalizeSchema(
|
||||
tree: Tree,
|
||||
schema: StorybookConfigureSchema
|
||||
): StorybookConfigureSchema {
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
const defaults = {
|
||||
interactionTests: true,
|
||||
linter: Linter.EsLint,
|
||||
js: false,
|
||||
tsConfiguration: true,
|
||||
addPlugin: process.env.NX_ADD_PLUGINS !== 'false',
|
||||
addPlugin,
|
||||
};
|
||||
return {
|
||||
...defaults,
|
||||
|
||||
@ -95,7 +95,11 @@ export function initGenerator(tree: Tree, schema: Schema) {
|
||||
}
|
||||
|
||||
export async function initGeneratorInternal(tree: Tree, schema: Schema) {
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
|
||||
if (schema.addPlugin) {
|
||||
addPlugin(tree);
|
||||
|
||||
@ -40,7 +40,11 @@ export async function viteConfigurationGeneratorInternal(
|
||||
) {
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
|
||||
const projectConfig = readProjectConfiguration(tree, schema.project);
|
||||
const { targets, root: projectRoot } = projectConfig;
|
||||
@ -73,7 +77,6 @@ export async function viteConfigurationGeneratorInternal(
|
||||
tasks.push(initTask);
|
||||
tasks.push(ensureDependencies(tree, schema));
|
||||
|
||||
const nxJson = readNxJson(tree);
|
||||
const hasPlugin = nxJson.plugins?.some((p) =>
|
||||
typeof p === 'string'
|
||||
? p === '@nx/vite/plugin'
|
||||
|
||||
@ -56,7 +56,11 @@ export async function initGeneratorInternal(
|
||||
tree: Tree,
|
||||
schema: InitGeneratorSchema
|
||||
) {
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
if (schema.addPlugin) {
|
||||
addPlugin(tree);
|
||||
}
|
||||
|
||||
@ -467,7 +467,11 @@ async function normalizeOptions(
|
||||
callingGenerator: '@nx/web:application',
|
||||
});
|
||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(host);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const e2eProjectName = `${appProjectName}-e2e`;
|
||||
const e2eProjectRoot = `${appProjectRoot}-e2e`;
|
||||
|
||||
@ -3,6 +3,7 @@ import {
|
||||
GeneratorCallback,
|
||||
joinPathFragments,
|
||||
offsetFromRoot,
|
||||
readNxJson,
|
||||
readProjectConfiguration,
|
||||
runTasksInSerial,
|
||||
Tree,
|
||||
@ -29,7 +30,11 @@ export async function configurationGeneratorInternal(
|
||||
options: ConfigurationGeneratorSchema
|
||||
) {
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
options.addPlugin ??= addPluginDefault;
|
||||
|
||||
const initTask = await webpackInitGenerator(tree, {
|
||||
...options,
|
||||
|
||||
@ -16,7 +16,11 @@ export function webpackInitGenerator(tree: Tree, schema: Schema) {
|
||||
}
|
||||
|
||||
export async function webpackInitGeneratorInternal(tree: Tree, schema: Schema) {
|
||||
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPluginDefault =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
schema.addPlugin ??= addPluginDefault;
|
||||
|
||||
if (schema.addPlugin) {
|
||||
addPlugin(tree);
|
||||
|
||||
@ -91,6 +91,7 @@ function createNxJson(
|
||||
};
|
||||
if (process.env.NX_ADD_PLUGINS === 'false') {
|
||||
nxJson.targetDefaults.build.inputs = ['production', '^production'];
|
||||
nxJson.useInferencePlugins = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -85,12 +85,16 @@ describe('preset', () => {
|
||||
});
|
||||
|
||||
it('should create files (preset = react-native)', async () => {
|
||||
console.log('Hello');
|
||||
await presetGenerator(tree, {
|
||||
name: 'proj',
|
||||
preset: Preset.ReactNative,
|
||||
linter: 'eslint',
|
||||
});
|
||||
|
||||
process.stderr.write('HELLO');
|
||||
process.stderr.write(tree.listChanges().toString());
|
||||
|
||||
expect(tree.exists('/apps/proj/src/app/App.tsx')).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { installPackagesTask, names, Tree } from '@nx/devkit';
|
||||
import { installPackagesTask, names, readNxJson, Tree } from '@nx/devkit';
|
||||
import { Schema } from './schema';
|
||||
import { Preset } from '../utils/presets';
|
||||
import { join } from 'path';
|
||||
@ -15,7 +15,15 @@ export async function presetGenerator(tree: Tree, options: Schema) {
|
||||
export default presetGenerator;
|
||||
|
||||
async function createPreset(tree: Tree, options: Schema) {
|
||||
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false';
|
||||
console.log('Crate preset');
|
||||
const nxJson = readNxJson(tree);
|
||||
const addPlugin =
|
||||
process.env.NX_ADD_PLUGINS !== 'false' &&
|
||||
nxJson.useInferencePlugins !== false;
|
||||
|
||||
console.log('Add plugin', addPlugin);
|
||||
console.log(options.preset, Preset.ReactNative);
|
||||
|
||||
if (options.preset === Preset.Apps) {
|
||||
return;
|
||||
} else if (options.preset === Preset.AngularMonorepo) {
|
||||
@ -210,8 +218,11 @@ async function createPreset(tree: Tree, options: Schema) {
|
||||
addPlugin,
|
||||
});
|
||||
} else if (options.preset === Preset.ReactNative) {
|
||||
console.log('Before require');
|
||||
const { reactNativeApplicationGenerator } = require('@nx' +
|
||||
'/react-native');
|
||||
console.log('Hello', reactNativeApplicationGenerator);
|
||||
console.log('Active require');
|
||||
return reactNativeApplicationGenerator(tree, {
|
||||
name: options.name,
|
||||
directory: join('apps', options.name),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user