fix(misc): ensure all project generators add project to workspaces config (#29582)
- Update project generators to add the project to the workspaces setup in the new TS solution setup - Update some library generators that were not running package installation <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
d30a84f49c
commit
0d5bfe3700
@ -28,21 +28,6 @@ describe('Node Applications', () => {
|
||||
packages: ['@nx/node', '@nx/express', '@nx/nest', '@nx/webpack'],
|
||||
preset: 'ts',
|
||||
});
|
||||
if (pm === 'pnpm') {
|
||||
updateFile(
|
||||
'pnpm-workspace.yaml',
|
||||
`
|
||||
packages:
|
||||
- 'apps/*'
|
||||
- 'packages/*'
|
||||
`
|
||||
);
|
||||
} else {
|
||||
updateJson('package.json', (json) => {
|
||||
json.workspaces = ['apps/*', 'packages/*'];
|
||||
return json;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
@ -18,21 +18,6 @@ describe('Vue Plugin', () => {
|
||||
packages: ['@nx/vue'],
|
||||
preset: 'ts',
|
||||
});
|
||||
if (pm === 'pnpm') {
|
||||
updateFile(
|
||||
'pnpm-workspace.yaml',
|
||||
`
|
||||
packages:
|
||||
- 'apps/*'
|
||||
- 'packages/*'
|
||||
`
|
||||
);
|
||||
} else {
|
||||
updateJson('package.json', (json) => {
|
||||
json.workspaces = ['apps/*', 'packages/*'];
|
||||
return json;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(() => cleanupProject());
|
||||
|
||||
@ -1633,6 +1633,50 @@ describe('lib', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each`
|
||||
directory | expected
|
||||
${'my-ts-lib'} | ${'my-ts-lib'}
|
||||
${'libs/my-ts-lib'} | ${'libs/*'}
|
||||
${'libs/shared/my-ts-lib'} | ${'libs/shared/*'}
|
||||
`(
|
||||
'should add "$expected" to the workspace when creating a library in "$directory" using pnpm',
|
||||
async ({ directory, expected }) => {
|
||||
tree.write('pnpm-workspace.yaml', '');
|
||||
|
||||
await libraryGenerator(tree, {
|
||||
...defaultOptions,
|
||||
directory,
|
||||
});
|
||||
|
||||
expect(tree.read('pnpm-workspace.yaml', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"packages:
|
||||
- '${expected}'
|
||||
"
|
||||
`);
|
||||
}
|
||||
);
|
||||
|
||||
it.each`
|
||||
directory | expected
|
||||
${'my-ts-lib'} | ${'my-ts-lib'}
|
||||
${'libs/my-ts-lib'} | ${'libs/*'}
|
||||
${'libs/shared/my-ts-lib'} | ${'libs/shared/*'}
|
||||
`(
|
||||
'should add "$expected" to the workspace when creating a library in "$directory" using npm or yarn',
|
||||
async ({ directory, expected }) => {
|
||||
// ensure there's no pnpm-workspace.yaml, so it uses the package.json workspaces
|
||||
tree.delete('pnpm-workspace.yaml');
|
||||
|
||||
await libraryGenerator(tree, {
|
||||
...defaultOptions,
|
||||
directory,
|
||||
});
|
||||
|
||||
expect(readJson(tree, 'package.json').workspaces).toContain(expected);
|
||||
}
|
||||
);
|
||||
|
||||
it('should map non-buildable libraries to source', async () => {
|
||||
await libraryGenerator(tree, {
|
||||
...defaultOptions,
|
||||
|
||||
@ -36,10 +36,6 @@ import { join } from 'path';
|
||||
import type { CompilerOptions } from 'typescript';
|
||||
import { normalizeLinterOption } from '../../utils/generator-prompts';
|
||||
import { getUpdatedPackageJsonContent } from '../../utils/package-json/update-package-json';
|
||||
import {
|
||||
getProjectPackageManagerWorkspaceState,
|
||||
getProjectPackageManagerWorkspaceStateWarningTask,
|
||||
} from '../../utils/package-manager-workspaces';
|
||||
import { addSwcConfig } from '../../utils/swc/add-swc-config';
|
||||
import { getSwcDependencies } from '../../utils/swc/add-swc-dependencies';
|
||||
import { getNeededCompilerOptionOverrides } from '../../utils/typescript/configuration';
|
||||
@ -53,6 +49,7 @@ import {
|
||||
readTsConfigFromTree,
|
||||
} from '../../utils/typescript/ts-config';
|
||||
import {
|
||||
addProjectToTsSolutionWorkspace,
|
||||
isUsingTsSolutionSetup,
|
||||
isUsingTypeScriptPlugin,
|
||||
} from '../../utils/typescript/ts-solution-setup';
|
||||
@ -218,21 +215,14 @@ export async function libraryGeneratorInternal(
|
||||
);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
addProjectToTsSolutionWorkspace(tree, options.projectRoot);
|
||||
}
|
||||
|
||||
if (
|
||||
!options.skipWorkspacesWarning &&
|
||||
options.isUsingTsSolutionConfig &&
|
||||
options.projectPackageManagerWorkspaceState !== 'included'
|
||||
) {
|
||||
tasks.push(
|
||||
getProjectPackageManagerWorkspaceStateWarningTask(
|
||||
options.projectPackageManagerWorkspaceState,
|
||||
tree.root
|
||||
)
|
||||
);
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
if (options.publishable) {
|
||||
@ -872,9 +862,6 @@ async function normalizeOptions(
|
||||
|
||||
options.minimal ??= false;
|
||||
|
||||
const projectPackageManagerWorkspaceState =
|
||||
getProjectPackageManagerWorkspaceState(tree, projectRoot);
|
||||
|
||||
// We default to generate a project.json file if the new setup is not being used
|
||||
options.useProjectJson ??= !isUsingTsSolutionConfig;
|
||||
|
||||
@ -888,7 +875,6 @@ async function normalizeOptions(
|
||||
importPath,
|
||||
hasPlugin,
|
||||
isUsingTsSolutionConfig,
|
||||
projectPackageManagerWorkspaceState,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ export interface LibraryGeneratorSchema {
|
||||
simpleName?: boolean;
|
||||
addPlugin?: boolean;
|
||||
useProjectJson?: boolean;
|
||||
skipWorkspacesWarning?: boolean;
|
||||
useTscExecutor?: boolean;
|
||||
}
|
||||
|
||||
@ -47,5 +46,4 @@ export interface NormalizedLibraryGeneratorOptions
|
||||
importPath?: string;
|
||||
hasPlugin: boolean;
|
||||
isUsingTsSolutionConfig: boolean;
|
||||
projectPackageManagerWorkspaceState: ProjectPackageManagerWorkspaceState;
|
||||
}
|
||||
|
||||
@ -206,11 +206,8 @@ export function addProjectToTsSolutionWorkspace(
|
||||
if (tree.exists('pnpm-workspace.yaml')) {
|
||||
const { load, dump } = require('@zkochan/js-yaml');
|
||||
const workspaceFile = tree.read('pnpm-workspace.yaml', 'utf-8');
|
||||
const yamlData = load(workspaceFile);
|
||||
|
||||
if (!yamlData?.packages) {
|
||||
yamlData.packages = [];
|
||||
}
|
||||
const yamlData = load(workspaceFile) ?? {};
|
||||
yamlData.packages ??= [];
|
||||
|
||||
if (!yamlData.packages.includes(pattern)) {
|
||||
yamlData.packages.push(pattern);
|
||||
|
||||
@ -30,7 +30,10 @@ export async function libraryGeneratorInternal(
|
||||
rawOptions: LibraryGeneratorOptions
|
||||
): Promise<GeneratorCallback> {
|
||||
const options = await normalizeOptions(tree, rawOptions);
|
||||
await jsLibraryGenerator(tree, toJsLibraryGeneratorOptions(options));
|
||||
const jsLibraryTask = await jsLibraryGenerator(
|
||||
tree,
|
||||
toJsLibraryGeneratorOptions(options)
|
||||
);
|
||||
const initTask = await initGenerator(tree, rawOptions);
|
||||
const depsTask = ensureDependencies(tree);
|
||||
deleteFiles(tree, options);
|
||||
@ -45,6 +48,7 @@ export async function libraryGeneratorInternal(
|
||||
|
||||
return runTasksInSerial(
|
||||
...[
|
||||
jsLibraryTask,
|
||||
initTask,
|
||||
depsTask,
|
||||
() => {
|
||||
|
||||
@ -56,6 +56,7 @@ import { hasWebpackPlugin } from '../../utils/has-webpack-plugin';
|
||||
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
|
||||
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';
|
||||
import {
|
||||
addProjectToTsSolutionWorkspace,
|
||||
isUsingTsSolutionSetup,
|
||||
updateTsconfigFiles,
|
||||
} from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
@ -572,10 +573,6 @@ export async function applicationGeneratorInternal(tree: Tree, schema: Schema) {
|
||||
tasks.push(dockerTask);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
updateTsconfigFiles(
|
||||
tree,
|
||||
@ -591,6 +588,16 @@ export async function applicationGeneratorInternal(tree: Tree, schema: Schema) {
|
||||
);
|
||||
}
|
||||
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
addProjectToTsSolutionWorkspace(tree, options.appProjectRoot);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
tasks.push(() => {
|
||||
logShowProjectCommand(options.name);
|
||||
});
|
||||
|
||||
@ -30,7 +30,10 @@ import {
|
||||
} from '@nx/eslint/src/generators/utils/eslint-file';
|
||||
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';
|
||||
import { findRootJestPreset } from '@nx/jest/src/utils/config/config-file';
|
||||
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import {
|
||||
addProjectToTsSolutionWorkspace,
|
||||
isUsingTsSolutionSetup,
|
||||
} from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import { getImportPath } from '@nx/js/src/utils/get-import-path';
|
||||
import { relative } from 'node:path/posix';
|
||||
|
||||
@ -230,10 +233,6 @@ export async function e2eProjectGeneratorInternal(
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(host);
|
||||
}
|
||||
|
||||
if (isUsingTsSolutionConfig) {
|
||||
updateJson(host, 'tsconfig.json', (json) => {
|
||||
json.references ??= [];
|
||||
@ -245,6 +244,16 @@ export async function e2eProjectGeneratorInternal(
|
||||
});
|
||||
}
|
||||
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (isUsingTsSolutionConfig) {
|
||||
addProjectToTsSolutionWorkspace(host, options.e2eProjectRoot);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(host);
|
||||
}
|
||||
|
||||
tasks.push(() => {
|
||||
logShowProjectCommand(options.e2eProjectName);
|
||||
});
|
||||
|
||||
@ -29,7 +29,10 @@ import { tslibVersion, typesNodeVersion } from '../../utils/versions';
|
||||
import { initGenerator } from '../init/init';
|
||||
import { Schema } from './schema';
|
||||
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
|
||||
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import {
|
||||
addProjectToTsSolutionWorkspace,
|
||||
isUsingTsSolutionSetup,
|
||||
} from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import { getImportPath } from '@nx/js/src/utils/get-import-path';
|
||||
|
||||
export interface NormalizedSchema extends Schema {
|
||||
@ -108,6 +111,12 @@ export async function libraryGeneratorInternal(tree: Tree, schema: Schema) {
|
||||
tasks.push(() => installPackagesTask(tree, true));
|
||||
}
|
||||
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
addProjectToTsSolutionWorkspace(tree, options.projectRoot);
|
||||
}
|
||||
|
||||
if (!schema.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
@ -33,7 +33,10 @@ import {
|
||||
createNxCloudOnboardingURLForWelcomeApp,
|
||||
} from 'nx/src/nx-cloud/utilities/onboarding';
|
||||
import { getImportPath } from '@nx/js/src/utils/get-import-path';
|
||||
import { updateTsconfigFiles } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import {
|
||||
addProjectToTsSolutionWorkspace,
|
||||
updateTsconfigFiles,
|
||||
} from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
|
||||
export async function applicationGenerator(tree: Tree, schema: Schema) {
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
@ -170,22 +173,6 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {
|
||||
|
||||
if (options.js) toJS(tree);
|
||||
|
||||
if (!options.skipFormat) await formatFiles(tree);
|
||||
|
||||
tasks.push(() => {
|
||||
try {
|
||||
execSync(`npx -y nuxi prepare`, {
|
||||
cwd: options.appProjectRoot,
|
||||
|
||||
windowsHide: false,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Failed to run \`nuxi prepare\` in "${options.appProjectRoot}". Please run the command manually.`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
updateTsconfigFiles(
|
||||
tree,
|
||||
@ -204,6 +191,28 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {
|
||||
);
|
||||
}
|
||||
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
addProjectToTsSolutionWorkspace(tree, options.appProjectRoot);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) await formatFiles(tree);
|
||||
|
||||
tasks.push(() => {
|
||||
try {
|
||||
execSync(`npx -y nuxi prepare`, {
|
||||
cwd: options.appProjectRoot,
|
||||
|
||||
windowsHide: false,
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`Failed to run \`nuxi prepare\` in "${options.appProjectRoot}". Please run the command manually.`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
tasks.push(() => {
|
||||
logShowProjectCommand(options.projectName);
|
||||
});
|
||||
|
||||
@ -13,10 +13,6 @@ import {
|
||||
updateProjectConfiguration,
|
||||
} from '@nx/devkit';
|
||||
import { libraryGenerator as jsLibraryGenerator } from '@nx/js';
|
||||
import {
|
||||
getProjectPackageManagerWorkspaceState,
|
||||
getProjectPackageManagerWorkspaceStateWarningTask,
|
||||
} from '@nx/js/src/utils/package-manager-workspaces';
|
||||
import { addTsLibDependencies } from '@nx/js/src/utils/typescript/add-tslib-dependencies';
|
||||
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import { tsLibVersion } from '@nx/js/src/utils/versions';
|
||||
@ -61,7 +57,13 @@ export async function createPackageGeneratorInternal(
|
||||
);
|
||||
tasks.push(installTask);
|
||||
|
||||
await createCliPackage(host, options, pluginPackageName);
|
||||
const cliPackageTask = await createCliPackage(
|
||||
host,
|
||||
options,
|
||||
pluginPackageName
|
||||
);
|
||||
tasks.push(cliPackageTask);
|
||||
|
||||
if (options.e2eProject) {
|
||||
addE2eProject(host, options);
|
||||
}
|
||||
@ -70,20 +72,6 @@ export async function createPackageGeneratorInternal(
|
||||
await formatFiles(host);
|
||||
}
|
||||
|
||||
if (options.isTsSolutionSetup) {
|
||||
const projectPackageManagerWorkspaceState =
|
||||
getProjectPackageManagerWorkspaceState(host, options.projectRoot);
|
||||
|
||||
if (projectPackageManagerWorkspaceState !== 'included') {
|
||||
tasks.push(
|
||||
getProjectPackageManagerWorkspaceStateWarningTask(
|
||||
projectPackageManagerWorkspaceState,
|
||||
host.root
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return runTasksInSerial(...tasks);
|
||||
}
|
||||
|
||||
@ -116,7 +104,7 @@ async function createCliPackage(
|
||||
options: NormalizedSchema,
|
||||
pluginPackageName: string
|
||||
) {
|
||||
await jsLibraryGenerator(host, {
|
||||
const jsLibraryTask = await jsLibraryGenerator(host, {
|
||||
...options,
|
||||
directory: options.directory,
|
||||
rootProject: false,
|
||||
@ -127,7 +115,6 @@ async function createCliPackage(
|
||||
skipFormat: true,
|
||||
skipTsConfig: true,
|
||||
useTscExecutor: true,
|
||||
skipWorkspacesWarning: true,
|
||||
});
|
||||
|
||||
host.delete(joinPathFragments(options.projectRoot, 'src'));
|
||||
@ -203,6 +190,8 @@ async function createCliPackage(
|
||||
tmpl: '',
|
||||
}
|
||||
);
|
||||
|
||||
return jsLibraryTask;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -28,10 +28,9 @@ import { setupVerdaccio } from '@nx/js/src/generators/setup-verdaccio/generator'
|
||||
import { addLocalRegistryScripts } from '@nx/js/src/utils/add-local-registry-scripts';
|
||||
import { normalizeLinterOption } from '@nx/js/src/utils/generator-prompts';
|
||||
import {
|
||||
getProjectPackageManagerWorkspaceState,
|
||||
getProjectPackageManagerWorkspaceStateWarningTask,
|
||||
} from '@nx/js/src/utils/package-manager-workspaces';
|
||||
import { isUsingTsSolutionSetup } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
addProjectToTsSolutionWorkspace,
|
||||
isUsingTsSolutionSetup,
|
||||
} from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import type { PackageJson } from 'nx/src/utils/package-json';
|
||||
import { join } from 'path';
|
||||
import type { Schema } from './schema';
|
||||
@ -256,24 +255,16 @@ export async function e2eProjectGeneratorInternal(host: Tree, schema: Schema) {
|
||||
});
|
||||
}
|
||||
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (options.isTsSolutionSetup) {
|
||||
addProjectToTsSolutionWorkspace(host, options.projectRoot);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(host);
|
||||
}
|
||||
|
||||
if (options.isTsSolutionSetup && !options.skipWorkspacesWarning) {
|
||||
const projectPackageManagerWorkspaceState =
|
||||
getProjectPackageManagerWorkspaceState(host, options.projectRoot);
|
||||
|
||||
if (projectPackageManagerWorkspaceState !== 'included') {
|
||||
tasks.push(
|
||||
getProjectPackageManagerWorkspaceStateWarningTask(
|
||||
projectPackageManagerWorkspaceState,
|
||||
host.root
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return runTasksInSerial(...tasks);
|
||||
}
|
||||
|
||||
|
||||
@ -11,5 +11,4 @@ export interface Schema {
|
||||
rootProject?: boolean;
|
||||
useProjectJson?: boolean;
|
||||
addPlugin?: boolean;
|
||||
skipWorkspacesWarning?: boolean;
|
||||
}
|
||||
|
||||
@ -12,10 +12,6 @@ import {
|
||||
} from '@nx/devkit';
|
||||
import { Linter } from '@nx/eslint';
|
||||
import { libraryGenerator as jsLibraryGenerator } from '@nx/js';
|
||||
import {
|
||||
getProjectPackageManagerWorkspaceState,
|
||||
getProjectPackageManagerWorkspaceStateWarningTask,
|
||||
} from '@nx/js/src/utils/package-manager-workspaces';
|
||||
import {
|
||||
addSwcDependencies,
|
||||
addSwcRegisterDependencies,
|
||||
@ -102,7 +98,6 @@ export async function pluginGeneratorInternal(host: Tree, schema: Schema) {
|
||||
useProjectJson: options.useProjectJson,
|
||||
addPlugin: options.addPlugin,
|
||||
skipFormat: true,
|
||||
skipWorkspacesWarning: true,
|
||||
useTscExecutor: true,
|
||||
})
|
||||
);
|
||||
@ -149,7 +144,6 @@ export async function pluginGeneratorInternal(host: Tree, schema: Schema) {
|
||||
linter: options.linter,
|
||||
useProjectJson: options.useProjectJson,
|
||||
addPlugin: options.addPlugin,
|
||||
skipWorkspacesWarning: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -162,20 +156,6 @@ export async function pluginGeneratorInternal(host: Tree, schema: Schema) {
|
||||
await formatFiles(host);
|
||||
}
|
||||
|
||||
if (options.isTsSolutionSetup) {
|
||||
const projectPackageManagerWorkspaceState =
|
||||
getProjectPackageManagerWorkspaceState(host, options.projectRoot);
|
||||
|
||||
if (projectPackageManagerWorkspaceState !== 'included') {
|
||||
tasks.push(
|
||||
getProjectPackageManagerWorkspaceStateWarningTask(
|
||||
projectPackageManagerWorkspaceState,
|
||||
host.root
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return runTasksInSerial(...tasks);
|
||||
}
|
||||
|
||||
|
||||
@ -310,9 +310,6 @@ export default {...nxPreset};
|
||||
tasks.push(await addE2E(tree, options));
|
||||
|
||||
addViteTempFilesToGitIgnore(tree);
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
updateTsconfigFiles(
|
||||
tree,
|
||||
@ -335,6 +332,10 @@ export default {...nxPreset};
|
||||
addProjectToTsSolutionWorkspace(tree, options.projectRoot);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
tasks.push(() => {
|
||||
logShowProjectCommand(options.projectName);
|
||||
});
|
||||
|
||||
@ -23,7 +23,10 @@ import { extractTsConfigBase } from '../../utils/create-ts-config';
|
||||
import { ensureDependencies } from '../../utils/ensure-dependencies';
|
||||
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';
|
||||
import { getImportPath } from '@nx/js/src/utils/get-import-path';
|
||||
import { updateTsconfigFiles } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import {
|
||||
addProjectToTsSolutionWorkspace,
|
||||
updateTsconfigFiles,
|
||||
} from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
|
||||
export function applicationGenerator(tree: Tree, options: Schema) {
|
||||
return applicationGeneratorInternal(tree, { addPlugin: false, ...options });
|
||||
@ -123,8 +126,6 @@ export async function applicationGeneratorInternal(
|
||||
|
||||
if (options.js) toJS(tree);
|
||||
|
||||
if (!options.skipFormat) await formatFiles(tree);
|
||||
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
updateTsconfigFiles(
|
||||
tree,
|
||||
@ -143,6 +144,14 @@ export async function applicationGeneratorInternal(
|
||||
);
|
||||
}
|
||||
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
addProjectToTsSolutionWorkspace(tree, options.appProjectRoot);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) await formatFiles(tree);
|
||||
|
||||
tasks.push(() => {
|
||||
logShowProjectCommand(options.projectName);
|
||||
});
|
||||
|
||||
@ -26,7 +26,10 @@ import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-com
|
||||
import { getRelativeCwd } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
||||
import { relative } from 'path';
|
||||
import { getImportPath } from '@nx/js/src/utils/get-import-path';
|
||||
import { updateTsconfigFiles } from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
import {
|
||||
addProjectToTsSolutionWorkspace,
|
||||
updateTsconfigFiles,
|
||||
} from '@nx/js/src/utils/typescript/ts-solution-setup';
|
||||
|
||||
export function libraryGenerator(tree: Tree, schema: Schema) {
|
||||
return libraryGeneratorInternal(tree, { addPlugin: false, ...schema });
|
||||
@ -141,8 +144,6 @@ export async function libraryGeneratorInternal(tree: Tree, schema: Schema) {
|
||||
|
||||
if (options.js) toJS(tree);
|
||||
|
||||
if (!options.skipFormat) await formatFiles(tree);
|
||||
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
updateTsconfigFiles(
|
||||
tree,
|
||||
@ -161,6 +162,14 @@ export async function libraryGeneratorInternal(tree: Tree, schema: Schema) {
|
||||
);
|
||||
}
|
||||
|
||||
// If we are using the new TS solution
|
||||
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
addProjectToTsSolutionWorkspace(tree, options.projectRoot);
|
||||
}
|
||||
|
||||
if (!options.skipFormat) await formatFiles(tree);
|
||||
|
||||
// Always run install to link packages.
|
||||
if (options.isUsingTsSolutionConfig) {
|
||||
tasks.push(() => installPackagesTask(tree, true));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user