Skip to content

Commit 6181c77

Browse files
chore: migrate to nx 16.10 (#207)
* chore: migrate to nx 16.10 * chore: bump lock file * test: do not use snapshots for error verification in e2e * chore: update readme
1 parent 58f5b47 commit 6181c77

29 files changed

+2596
-2512
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ This plugin supports Nx migrations and provides necessary version and code updat
8787

8888
| qwik-nx version | Nx version |
8989
| ------------------ | ---------- |
90+
| ^1.1.0 | ^16.8.0 |
9091
| ^1.0.0 | ^16.0.0 |
9192
| ^0.16.0 | ^16.0.0 |
9293
| >= 0.12.0 < 0.16.0 | ^15.8.0 |

e2e/qwik-nx-e2e/tests/__snapshots__/application.spec.ts.snap

Lines changed: 0 additions & 33 deletions
This file was deleted.

e2e/qwik-nx-e2e/tests/__snapshots__/preset.spec.ts.snap

Lines changed: 0 additions & 33 deletions
This file was deleted.

e2e/qwik-nx-e2e/tests/application-basic-behavior.suite.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import {
1919
import { names } from '@nx/devkit';
2020

2121
export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
22+
const isPreset = generator === 'preset';
23+
const appPathPrefix = isPreset ? 'apps/' : '';
24+
const libPathPrefix = isPreset ? 'libs/' : '';
2225
const devServerPort = 4212;
2326
const previewServerPort = 4232;
2427
describe(`Basic behavior with ${generator} generator`, () => {
@@ -36,12 +39,11 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
3639
beforeAll(async () => {
3740
project = uniq('qwik-nx');
3841
libProject = uniq('qwik-nx');
39-
rootRoutePath = `apps/${project}/src/routes/index.tsx`;
40-
libComponentPath = `libs/${libProject}/src/lib/${libProject}.tsx`;
42+
rootRoutePath = `${appPathPrefix}${project}/src/routes/index.tsx`;
43+
libComponentPath = `${libPathPrefix}${libProject}/src/lib/${libProject}.tsx`;
4144
libComponentName = names(libProject).className;
4245

43-
const projectNameParam =
44-
generator === 'preset' ? `--qwikAppName=${project}` : project;
46+
const projectNameParam = isPreset ? `--qwikAppName=${project}` : project;
4547

4648
await runNxCommandAsync(
4749
`generate qwik-nx:${generator} ${projectNameParam} --no-interactive`
@@ -91,10 +93,14 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
9193
`Successfully ran target build for project ${project}`
9294
);
9395
expect(() =>
94-
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
96+
checkFilesExist(
97+
`dist/${appPathPrefix}${project}/client/q-manifest.json`
98+
)
9599
).not.toThrow();
96100
expect(() =>
97-
checkFilesExist(`dist/apps/${project}/server/entry.preview.mjs`)
101+
checkFilesExist(
102+
`dist/${appPathPrefix}${project}/server/entry.preview.mjs`
103+
)
98104
).not.toThrow();
99105
},
100106
DEFAULT_E2E_TIMEOUT
@@ -141,8 +147,16 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
141147
.replace(/-p .+/, '-p REPLACED_PATH/tsconfig.app.json');
142148
}
143149

144-
expect(replaceDynamicContent(result.stderr)).toMatchSnapshot('stderr');
145-
expect(replaceDynamicContent(result.stdout)).toMatchSnapshot('stdout');
150+
const stdout = replaceDynamicContent(stripConsoleColors(result.stdout));
151+
expect(stdout).toContain(
152+
`PROJECT_NAME/src/routes/index.tsx:8:15 - error TS2322: Type 'string' is not assignable to type 'number'.`
153+
);
154+
expect(stdout).toContain(
155+
`LIB_PROJECT_NAME/src/lib/LIB_PROJECT_NAME.tsx:7:22 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.`
156+
);
157+
expect(stdout).toContain(
158+
`Running target build for project PROJECT_NAME failed`
159+
);
146160
},
147161
DEFAULT_E2E_TIMEOUT
148162
);

e2e/qwik-nx-e2e/tests/micro-frontends.spec.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,10 @@ describe('Micro-frontends e2e', () => {
4040
it(
4141
'should create host and remote applications',
4242
async () => {
43-
expect(() =>
44-
checkFilesExist(`apps/${project}/vite.config.ts`)
45-
).not.toThrow();
46-
expect(() =>
47-
checkFilesExist(`apps/${remote1}/vite.config.ts`)
48-
).not.toThrow();
49-
expect(() =>
50-
checkFilesExist(`apps/${remote2}/vite.config.ts`)
51-
).not.toThrow();
52-
const configFilePath = `apps/${project}/src/config/remotes.json`;
43+
expect(() => checkFilesExist(`${project}/vite.config.ts`)).not.toThrow();
44+
expect(() => checkFilesExist(`${remote1}/vite.config.ts`)).not.toThrow();
45+
expect(() => checkFilesExist(`${remote2}/vite.config.ts`)).not.toThrow();
46+
const configFilePath = `${project}/src/config/remotes.json`;
5347
expect(() => checkFilesExist(configFilePath)).not.toThrow();
5448
const config = readJson(configFilePath);
5549
expect(config[remote1]).toEqual('http://localhost:5174');
@@ -67,10 +61,10 @@ describe('Micro-frontends e2e', () => {
6761
`Successfully ran target build for project ${name}`
6862
);
6963
expect(() =>
70-
checkFilesExist(`dist/apps/${name}/client/q-manifest.json`)
64+
checkFilesExist(`dist/${name}/client/q-manifest.json`)
7165
).not.toThrow();
7266
expect(() =>
73-
checkFilesExist(`dist/apps/${name}/server/entry.preview.mjs`)
67+
checkFilesExist(`dist/${name}/server/entry.preview.mjs`)
7468
).not.toThrow();
7569
};
7670
await checkProject(project);
@@ -162,7 +156,7 @@ describe('Micro-frontends e2e', () => {
162156
`Successfully ran target build for project ${remote3}`
163157
);
164158
expect(() =>
165-
checkFilesExist(`dist/apps/${remote3}/server/entry.preview.mjs`)
159+
checkFilesExist(`dist/${remote3}/server/entry.preview.mjs`)
166160
).not.toThrow();
167161

168162
const runResult = await runHostAndRemotes(
@@ -281,7 +275,7 @@ async function previewHostAndRemotes(
281275
const includesBuiltMessage = (remote: string) => {
282276
// checking for the presence of ssr build output message to determine whether project has been built
283277
return stripConsoleColors(output).includes(
284-
`${remote.toUpperCase()} ../../dist/apps/${remote}/server/entry.preview.mjs`
278+
`${remote.toUpperCase()} ../dist/${remote}/server/entry.preview.mjs`
285279
);
286280
};
287281

@@ -300,7 +294,7 @@ async function previewHostAndRemotes(
300294

301295
// build output
302296
builtHost ||= stripConsoleColors(output).includes(
303-
`../../dist/apps/${hostName}/server/entry.preview.mjs`
297+
`../dist/${hostName}/server/entry.preview.mjs`
304298
);
305299
builtRemote1 ||= includesBuiltMessage(remote1);
306300
builtRemote2 ||= includesBuiltMessage(remote2);
@@ -339,8 +333,8 @@ async function previewHostAndRemotes(
339333

340334
const hasBuildOutputs = (projectName: string): boolean => {
341335
try {
342-
checkFilesExist(`dist/apps/${projectName}/client/q-manifest.json`);
343-
checkFilesExist(`dist/apps/${projectName}/server/entry.preview.mjs`);
336+
checkFilesExist(`dist/${projectName}/client/q-manifest.json`);
337+
checkFilesExist(`dist/${projectName}/server/entry.preview.mjs`);
344338
return true;
345339
} catch {
346340
return false;

e2e/qwik-nx-e2e/tests/qwik-nx-cloudflare.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ describe('qwik nx cloudflare generator', () => {
5353
`Successfully ran target build for project ${project}`
5454
);
5555
expect(() =>
56-
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
56+
checkFilesExist(`dist/${project}/client/q-manifest.json`)
5757
).not.toThrow();
5858
expect(() =>
59-
checkFilesExist(
60-
`dist/apps/${project}/server/entry.cloudflare-pages.js`
61-
)
59+
checkFilesExist(`dist/${project}/server/entry.cloudflare-pages.js`)
6260
).not.toThrow();
6361
},
6462
DEFAULT_E2E_TIMEOUT

e2e/qwik-nx-e2e/tests/qwik-nx-netlify.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ describe('qwik nx netlify generator', () => {
4545
`Successfully ran target build for project ${project}`
4646
);
4747
expect(() =>
48-
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
48+
checkFilesExist(`dist/${project}/client/q-manifest.json`)
4949
).not.toThrow();
5050
expect(() =>
5151
checkFilesExist(
52-
`dist/apps/${project}/.netlify/edge-functions/entry.netlify-edge/entry.netlify-edge.js`
52+
`dist/${project}/.netlify/edge-functions/entry.netlify-edge/entry.netlify-edge.js`
5353
)
5454
).not.toThrow();
5555
},

e2e/qwik-nx-e2e/tests/qwik-nx-vite.spec.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('qwikNxVite plugin e2e', () => {
5656
// move header component into the library
5757

5858
// update import in layout.tsx
59-
const layoutFilePath = `apps/${project}/src/routes/layout.tsx`;
59+
const layoutFilePath = `${project}/src/routes/layout.tsx`;
6060
let layoutFile = readFile(layoutFilePath);
6161
layoutFile = layoutFile.replace(
6262
`import Header from '../components/header/header';`,
@@ -65,8 +65,8 @@ describe('qwikNxVite plugin e2e', () => {
6565
updateFile(layoutFilePath, layoutFile);
6666

6767
// move header component files
68-
const headerFolderOldPath = `apps/${project}/src/components/header`;
69-
const headerFolderNewPath = `libs/${headerLibName}/src/lib`;
68+
const headerFolderOldPath = `${project}/src/components/header`;
69+
const headerFolderNewPath = `${headerLibName}/src/lib`;
7070
removeFile(`${headerFolderNewPath}/${headerLibName}.tsx`);
7171
removeFile(`${headerFolderNewPath}/${headerLibName}.css`);
7272
renameFile(
@@ -78,7 +78,7 @@ describe('qwikNxVite plugin e2e', () => {
7878
`${headerFolderNewPath}/header.css`
7979
);
8080
updateFile(
81-
`libs/${headerLibName}/src/index.ts`,
81+
`${headerLibName}/src/index.ts`,
8282
`export * from './lib/header';`
8383
);
8484

@@ -95,17 +95,14 @@ describe('qwikNxVite plugin e2e', () => {
9595
updateFile(`${headerFolderNewPath}/header.tsx`, headerTsx);
9696

9797
// move icon component file
98-
const qwikIconFolderNewPath = `libs/${iconLibName}/src/lib`;
98+
const qwikIconFolderNewPath = `${iconLibName}/src/lib`;
9999
removeFile(`${qwikIconFolderNewPath}/${iconLibName}.tsx`);
100100
removeFile(`${qwikIconFolderNewPath}/${iconLibName}.css`);
101101
renameFile(
102-
`apps/${project}/src/components/icons/qwik.tsx`,
102+
`${project}/src/components/icons/qwik.tsx`,
103103
`${qwikIconFolderNewPath}/qwik.tsx`
104104
);
105-
updateFile(
106-
`libs/${iconLibName}/src/index.ts`,
107-
`export * from './lib/qwik';`
108-
);
105+
updateFile(`${iconLibName}/src/index.ts`, `export * from './lib/qwik';`);
109106
}, DEFAULT_E2E_TIMEOUT);
110107

111108
it(
@@ -116,10 +113,10 @@ describe('qwikNxVite plugin e2e', () => {
116113
`Successfully ran target build for project ${project}`
117114
);
118115
expect(() =>
119-
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
116+
checkFilesExist(`dist/${project}/client/q-manifest.json`)
120117
).not.toThrow();
121118
expect(() =>
122-
checkFilesExist(`dist/apps/${project}/server/entry.preview.mjs`)
119+
checkFilesExist(`dist/${project}/server/entry.preview.mjs`)
123120
).not.toThrow();
124121
},
125122
DEFAULT_E2E_TIMEOUT

e2e/qwik-nx-e2e/tests/storybook.spec.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('qwikNxVite plugin e2e', () => {
4343
);
4444
await addAdditionalStories(appProject);
4545
}, DEFAULT_E2E_TIMEOUT);
46-
checkStorybookIsBuiltAndServed(appProject, 'apps');
46+
checkStorybookIsBuiltAndServed(appProject);
4747
});
4848
describe('Applying storybook for existing library', () => {
4949
beforeAll(async () => {
@@ -55,7 +55,7 @@ describe('qwikNxVite plugin e2e', () => {
5555
);
5656
await addAdditionalStories(libProject);
5757
}, DEFAULT_E2E_TIMEOUT);
58-
checkStorybookIsBuiltAndServed(libProject, 'libs');
58+
checkStorybookIsBuiltAndServed(libProject);
5959
});
6060

6161
describe('Generating a new library with storybook configuration', () => {
@@ -65,7 +65,7 @@ describe('qwikNxVite plugin e2e', () => {
6565
);
6666
await addAdditionalStories(secondLibProject);
6767
}, DEFAULT_E2E_TIMEOUT);
68-
checkStorybookIsBuiltAndServed(secondLibProject, 'libs');
68+
checkStorybookIsBuiltAndServed(secondLibProject);
6969
});
7070
});
7171
});
@@ -79,10 +79,7 @@ async function addAdditionalStories(projectName: string): Promise<void> {
7979
);
8080
}
8181

82-
function checkStorybookIsBuiltAndServed(
83-
projectName: string,
84-
type: 'apps' | 'libs'
85-
) {
82+
function checkStorybookIsBuiltAndServed(projectName: string) {
8683
it(
8784
`should be able to build storybook for the "${projectName}"`,
8885
async () => {
@@ -115,7 +112,7 @@ function checkStorybookIsBuiltAndServed(
115112
}
116113
);
117114

118-
const mdxPattern = normalize(`${type}/${projectName}/**/*.stories.mdx`);
115+
const mdxPattern = normalize(`${projectName}/**/*.stories.mdx`);
119116

120117
// it is expected that projects won't have stories by default and storybook should recognize it.
121118
expect(resultOutput).toContain(

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@
2323
"@commitlint/config-angular": "^17.3.0",
2424
"@commitlint/config-conventional": "^17.3.0",
2525
"@jscutlery/semver": "^3.1.0",
26-
"@nx/cypress": "16.7.0",
27-
"@nx/devkit": "16.7.0",
28-
"@nx/eslint-plugin": "16.7.0",
29-
"@nx/jest": "16.7.0",
30-
"@nx/js": "16.7.0",
31-
"@nx/linter": "16.7.0",
32-
"@nx/plugin": "16.7.0",
33-
"@nx/storybook": "16.7.0",
34-
"@nx/vite": "16.7.0",
35-
"@nx/workspace": "16.7.0",
26+
"@nx/cypress": "16.10.0",
27+
"@nx/devkit": "16.10.0",
28+
"@nx/eslint-plugin": "16.10.0",
29+
"@nx/jest": "16.10.0",
30+
"@nx/js": "16.10.0",
31+
"@nx/linter": "16.10.0",
32+
"@nx/plugin": "16.10.0",
33+
"@nx/storybook": "16.10.0",
34+
"@nx/vite": "16.10.0",
35+
"@nx/workspace": "16.10.0",
3636
"@nxkit/playwright": "^3.0.2",
37-
"@swc-node/register": "^1.4.2",
37+
"@swc-node/register": "1.6.8",
3838
"@swc/cli": "0.1.62",
3939
"@swc/core": "^1.2.173",
4040
"@types/fs-extra": "11.0.1",
@@ -63,8 +63,8 @@
6363
"jsonc-eslint-parser": "^2.1.0",
6464
"kill-port": "2.0.1",
6565
"ngx-deploy-npm": "^6.0.0",
66-
"nx": "16.7.0",
67-
"nx-cloud": "16.3.0",
66+
"nx": "16.10.0",
67+
"nx-cloud": "16.5.2",
6868
"prettier": "^2.8.0",
6969
"pretty-quick": "^3.1.3",
7070
"tcp-port-used": "1.0.2",

0 commit comments

Comments
 (0)