Skip to content

Commit

Permalink
feat(core): enable project crystal by default
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Jan 31, 2024
1 parent 1327904 commit 07da547
Show file tree
Hide file tree
Showing 131 changed files with 3,266 additions and 4,078 deletions.
2 changes: 1 addition & 1 deletion docs/generated/cli/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The package name and optional version (e.g. `@nx/react` or `@nx/react@latest`) t

Type: `boolean`

Update `package.json` scripts with inferred targets. Defaults to `true` when `NX_PCV3=true` and the package is a core Nx plugin
Update `package.json` scripts with inferred targets. Defaults to `true` when the package is a core Nx plugin

### verbose

Expand Down
34 changes: 1 addition & 33 deletions docs/generated/cli/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,12 @@ Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`

## Options

### addE2e

Type: `boolean`

Default: `false`

Set up Cypress E2E tests in integrated workspaces. Only for CRA projects.

### force

Type: `boolean`

Default: `false`

Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.

### help

Type: `boolean`

Show help

### integrated

Type: `boolean`

Default: `false`

Migrate to an Nx integrated layout workspace. Only for Angular CLI workspaces and CRA projects.

### interactive

Type: `boolean`
Expand All @@ -59,7 +35,7 @@ When false disables interactive input prompts for options.

Type: `boolean`

Set up remote caching with Nx Cloud.
Set up distributed caching with Nx Cloud.

### useDotNxInstallation

Expand All @@ -74,11 +50,3 @@ Initialize an Nx workspace setup in the .nx directory of the current repository.
Type: `boolean`

Show version number

### vite

Type: `boolean`

Default: `true`

Use Vite as the bundler. Only for CRA projects.
2 changes: 1 addition & 1 deletion docs/generated/packages/nx/documents/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The package name and optional version (e.g. `@nx/react` or `@nx/react@latest`) t

Type: `boolean`

Update `package.json` scripts with inferred targets. Defaults to `true` when `NX_PCV3=true` and the package is a core Nx plugin
Update `package.json` scripts with inferred targets. Defaults to `true` when the package is a core Nx plugin

### verbose

Expand Down
34 changes: 1 addition & 33 deletions docs/generated/packages/nx/documents/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,12 @@ Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`

## Options

### addE2e

Type: `boolean`

Default: `false`

Set up Cypress E2E tests in integrated workspaces. Only for CRA projects.

### force

Type: `boolean`

Default: `false`

Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.

### help

Type: `boolean`

Show help

### integrated

Type: `boolean`

Default: `false`

Migrate to an Nx integrated layout workspace. Only for Angular CLI workspaces and CRA projects.

### interactive

Type: `boolean`
Expand All @@ -59,7 +35,7 @@ When false disables interactive input prompts for options.

Type: `boolean`

Set up remote caching with Nx Cloud.
Set up distributed caching with Nx Cloud.

### useDotNxInstallation

Expand All @@ -74,11 +50,3 @@ Initialize an Nx workspace setup in the .nx directory of the current repository.
Type: `boolean`

Show version number

### vite

Type: `boolean`

Default: `true`

Use Vite as the bundler. Only for CRA projects.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
updateJson,
} from 'e2e/utils';

describe('@nx/detox/plugin', () => {
describe('@nx/detox (legacy)', () => {
let project: string;
let appName: string;

Expand All @@ -16,7 +16,7 @@ describe('@nx/detox/plugin', () => {
appName = uniq('app');
runCLI(
`generate @nx/react-native:app ${appName} --e2eTestRunner=detox --install=false --project-name-and-root-format=as-provided --interactive=false`,
{ env: { NX_PCV3: 'true' } }
{ env: { NX_ADD_PLUGINS: 'false' } }
);
updateJson(`${appName}-e2e/.detoxrc.json`, (json) => {
json.apps['e2e.debug'] = {
Expand Down
4 changes: 2 additions & 2 deletions e2e/eslint/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,10 +790,10 @@ describe('Linter', () => {
});
});

it('should lint example app', () => {
it('should lint example app (legacy)', () => {
runCLI(
`generate @nx/react:app ${myapp} --directory apps/${myapp} --unitTestRunner=none --bundler=vite --e2eTestRunner=cypress --style=css --no-interactive --projectNameAndRootFormat=as-provided`,
{ env: { NX_PCV3: 'true' } }
{ env: { NX_ADD_PLUGINS: 'false' } }
);

let lintResults = runCLI(`lint ${myapp}`);
Expand Down
4 changes: 2 additions & 2 deletions e2e/expo/src/expo-pcv3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'e2e/utils';
import { join } from 'path';

describe('@nx/expo/plugin', () => {
describe('@nx/expo (legacy)', () => {
let project: string;
let appName: string;

Expand All @@ -22,7 +22,7 @@ describe('@nx/expo/plugin', () => {
appName = uniq('app');
runCLI(
`generate @nx/expo:app ${appName} --project-name-and-root-format=as-provided --no-interactive`,
{ env: { NX_PCV3: 'true' } }
{ env: { NX_ADD_PLUGINS: 'false' } }
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
createFile,
} from 'e2e/utils';

describe('@nx/next/plugin', () => {
describe('@nx/next (legacy)', () => {
let project: string;
let appName: string;

Expand All @@ -23,7 +23,7 @@ describe('@nx/next/plugin', () => {
appName = uniq('app');
runCLI(
`generate @nx/next:app ${appName} --project-name-and-root-format=as-provided --no-interactive`,
{ env: { NX_PCV3: 'true' } }
{ env: { NX_ADD_PLUGINS: 'false' } }
);

// update package.json to add next as a script
Expand All @@ -50,7 +50,7 @@ describe('@nx/next/plugin', () => {

it('should build the app', async () => {
const result = runCLI(`build ${appName}`);
// check build output for PCV3 artifacts (e.g. .next directory) are inside the project directory
// check build output for cached artifacts (e.g. .next directory) are inside the project directory
directoryExists(`${appName}/.next`);

expect(result).toContain(
Expand Down
10 changes: 5 additions & 5 deletions e2e/playwright/src/playwright.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ describe('Playwright E2E Test runner', () => {
);
});

describe('Playwright E2E Test Runner - PCV3', () => {
describe('Playwright E2E Test Runner - legacy', () => {
let env: string | undefined;

beforeAll(() => {
env = process.env.NX_PCV3;
env = process.env.NX_ADD_PLUGINS;
newProject({
name: uniq('playwright'),
unsetProjectNameAndRootFormat: false,
});
process.env.NX_PCV3 = 'true';
process.env.NX_ADD_PLUGINS = 'false';
});

afterAll(() => {
if (env) {
process.env.NX_PCV3 = env;
process.env.NX_ADD_PLUGINS = env;
} else {
delete process.env.NX_PCV3;
delete process.env.NX_ADD_PLUGINS;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,20 @@ import {
fileExists,
} from 'e2e/utils';

describe('@nx/react-native/plugin', () => {
describe('@nx/react-native (legacy)', () => {
let appName: string;

beforeAll(() => {
newProject();
appName = uniq('app');
runCLI(
`generate @nx/react-native:app ${appName} --project-name-and-root-format=as-provided --install=false --no-interactive`,
{ env: { NX_PCV3: 'true' } }
{ env: { NX_ADD_PLUGINS: 'false' } }
);
});

afterAll(() => cleanupProject());

it('nx.json should contain plugin configuration', () => {
const nxJson = readJson('nx.json');
const reactNativePlugin = nxJson.plugins.find(
(plugin) => plugin.plugin === '@nx/react-native/plugin'
);
expect(reactNativePlugin).toBeDefined();
expect(reactNativePlugin.options).toBeDefined();
expect(reactNativePlugin.options.bundleTargetName).toEqual('bundle');
expect(reactNativePlugin.options.startTargetName).toEqual('start');
});

it('should bundle the app', async () => {
const result = runCLI(
`bundle ${appName} --platform=ios --bundle-output=dist.js --entry-file=src/main.tsx`
Expand Down
2 changes: 1 addition & 1 deletion e2e/utils/get-env-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function getStrippedEnvironmentVariables() {
return true;
}

const allowedKeys = ['NX_PCV3'];
const allowedKeys = ['NX_ADD_PLUGINS'];

if (key.startsWith('NX_') && !allowedKeys.includes(key)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('@nx/vite/plugin', () => {

describe('with react', () => {
beforeAll(() => {
originalEnv = process.env.NX_PCV3;
process.env.NX_PCV3 = 'true';
originalEnv = process.env.NX_ADD_PLUGINS;
process.env.NX_ADD_PLUGINS = 'false';
proj = newProject({
packages: ['@nx/react', '@nx/vue'],
});
Expand Down Expand Up @@ -83,8 +83,8 @@ describe('@nx/vite/plugin', () => {
const reactVitest = uniq('reactVitest');

beforeAll(() => {
originalEnv = process.env.NX_PCV3;
process.env.NX_PCV3 = 'true';
originalEnv = process.env.NX_ADD_PLUGINS;
process.env.NX_ADD_PLUGINS = 'false';
proj = newProject({
packages: ['@nx/vite', '@nx/react'],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
} from '@nx/e2e/utils';
import { ChildProcess } from 'child_process';

describe('Webpack Plugin (PCv3)', () => {
let originalPcv3: string | undefined;
describe('Webpack Plugin (legacy)', () => {
let originalAddPluginsEnv: string | undefined;
const appName = uniq('app');
const libName = uniq('lib');

beforeAll(() => {
originalPcv3 = process.env.NX_PCV3;
process.env.NX_PCV3 = 'true';
originalAddPluginsEnv = process.env.NX_ADD_PLUGINS;
process.env.NX_ADD_PLUGINS = 'false';
newProject({
packages: ['@nx/react'],
unsetProjectNameAndRootFormat: false,
Expand All @@ -29,7 +29,7 @@ describe('Webpack Plugin (PCv3)', () => {
});

afterAll(() => {
process.env.NX_PCV3 = originalPcv3;
process.env.NX_ADD_PLUGINS = originalAddPluginsEnv;
cleanupProject();
});

Expand Down
18 changes: 12 additions & 6 deletions packages/angular/src/generators/add-linting/add-linting.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ProjectConfiguration, Tree } from '@nx/devkit';
import { ProjectConfiguration, readNxJson, Tree } from '@nx/devkit';
import {
addProjectConfiguration,
readJson,
Expand Down Expand Up @@ -65,17 +65,23 @@ describe('addLinting generator', () => {
expect(eslintConfig).toMatchSnapshot();
});

it('should update the project with the right lint target configuration', async () => {
it('should add @nx/eslint/plugin', async () => {
await addLintingGenerator(tree, {
prefix: 'myOrg',
projectName: appProjectName,
projectRoot: appProjectRoot,
skipFormat: true,
});

const project = readProjectConfiguration(tree, appProjectName);
expect(project.targets.lint).toEqual({
executor: '@nx/eslint:lint',
});
const nxJson = readNxJson(tree);
expect(
nxJson.plugins.find((p) => {
if (typeof p === 'string') {
return p === '@nx/eslint/plugin';
} else {
return p.plugin === '@nx/eslint/plugin';
}
})
).toBeTruthy();
});
});
Loading

0 comments on commit 07da547

Please sign in to comment.