Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to nx 16.10 #207

Merged
merged 4 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ This plugin supports Nx migrations and provides necessary version and code updat

| qwik-nx version | Nx version |
| ------------------ | ---------- |
| ^1.1.0 | ^16.8.0 |
| ^1.0.0 | ^16.0.0 |
| ^0.16.0 | ^16.0.0 |
| >= 0.12.0 < 0.16.0 | ^15.8.0 |
Expand Down
33 changes: 0 additions & 33 deletions e2e/qwik-nx-e2e/tests/__snapshots__/application.spec.ts.snap

This file was deleted.

33 changes: 0 additions & 33 deletions e2e/qwik-nx-e2e/tests/__snapshots__/preset.spec.ts.snap

This file was deleted.

30 changes: 22 additions & 8 deletions e2e/qwik-nx-e2e/tests/application-basic-behavior.suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import {
import { names } from '@nx/devkit';

export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
const isPreset = generator === 'preset';
const appPathPrefix = isPreset ? 'apps/' : '';
const libPathPrefix = isPreset ? 'libs/' : '';
const devServerPort = 4212;
const previewServerPort = 4232;
describe(`Basic behavior with ${generator} generator`, () => {
Expand All @@ -36,12 +39,11 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
beforeAll(async () => {
project = uniq('qwik-nx');
libProject = uniq('qwik-nx');
rootRoutePath = `apps/${project}/src/routes/index.tsx`;
libComponentPath = `libs/${libProject}/src/lib/${libProject}.tsx`;
rootRoutePath = `${appPathPrefix}${project}/src/routes/index.tsx`;
libComponentPath = `${libPathPrefix}${libProject}/src/lib/${libProject}.tsx`;
libComponentName = names(libProject).className;

const projectNameParam =
generator === 'preset' ? `--qwikAppName=${project}` : project;
const projectNameParam = isPreset ? `--qwikAppName=${project}` : project;

await runNxCommandAsync(
`generate qwik-nx:${generator} ${projectNameParam} --no-interactive`
Expand Down Expand Up @@ -91,10 +93,14 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
`Successfully ran target build for project ${project}`
);
expect(() =>
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
checkFilesExist(
`dist/${appPathPrefix}${project}/client/q-manifest.json`
)
).not.toThrow();
expect(() =>
checkFilesExist(`dist/apps/${project}/server/entry.preview.mjs`)
checkFilesExist(
`dist/${appPathPrefix}${project}/server/entry.preview.mjs`
)
).not.toThrow();
},
DEFAULT_E2E_TIMEOUT
Expand Down Expand Up @@ -141,8 +147,16 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') {
.replace(/-p .+/, '-p REPLACED_PATH/tsconfig.app.json');
}

expect(replaceDynamicContent(result.stderr)).toMatchSnapshot('stderr');
expect(replaceDynamicContent(result.stdout)).toMatchSnapshot('stdout');
const stdout = replaceDynamicContent(stripConsoleColors(result.stdout));
expect(stdout).toContain(
`PROJECT_NAME/src/routes/index.tsx:8:15 - error TS2322: Type 'string' is not assignable to type 'number'.`
);
expect(stdout).toContain(
`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'.`
);
expect(stdout).toContain(
`Running target build for project PROJECT_NAME failed`
);
},
DEFAULT_E2E_TIMEOUT
);
Expand Down
28 changes: 11 additions & 17 deletions e2e/qwik-nx-e2e/tests/micro-frontends.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,10 @@ describe('Micro-frontends e2e', () => {
it(
'should create host and remote applications',
async () => {
expect(() =>
checkFilesExist(`apps/${project}/vite.config.ts`)
).not.toThrow();
expect(() =>
checkFilesExist(`apps/${remote1}/vite.config.ts`)
).not.toThrow();
expect(() =>
checkFilesExist(`apps/${remote2}/vite.config.ts`)
).not.toThrow();
const configFilePath = `apps/${project}/src/config/remotes.json`;
expect(() => checkFilesExist(`${project}/vite.config.ts`)).not.toThrow();
expect(() => checkFilesExist(`${remote1}/vite.config.ts`)).not.toThrow();
expect(() => checkFilesExist(`${remote2}/vite.config.ts`)).not.toThrow();
const configFilePath = `${project}/src/config/remotes.json`;
expect(() => checkFilesExist(configFilePath)).not.toThrow();
const config = readJson(configFilePath);
expect(config[remote1]).toEqual('http://localhost:5174');
Expand All @@ -67,10 +61,10 @@ describe('Micro-frontends e2e', () => {
`Successfully ran target build for project ${name}`
);
expect(() =>
checkFilesExist(`dist/apps/${name}/client/q-manifest.json`)
checkFilesExist(`dist/${name}/client/q-manifest.json`)
).not.toThrow();
expect(() =>
checkFilesExist(`dist/apps/${name}/server/entry.preview.mjs`)
checkFilesExist(`dist/${name}/server/entry.preview.mjs`)
).not.toThrow();
};
await checkProject(project);
Expand Down Expand Up @@ -162,7 +156,7 @@ describe('Micro-frontends e2e', () => {
`Successfully ran target build for project ${remote3}`
);
expect(() =>
checkFilesExist(`dist/apps/${remote3}/server/entry.preview.mjs`)
checkFilesExist(`dist/${remote3}/server/entry.preview.mjs`)
).not.toThrow();

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

Expand All @@ -300,7 +294,7 @@ async function previewHostAndRemotes(

// build output
builtHost ||= stripConsoleColors(output).includes(
`../../dist/apps/${hostName}/server/entry.preview.mjs`
`../dist/${hostName}/server/entry.preview.mjs`
);
builtRemote1 ||= includesBuiltMessage(remote1);
builtRemote2 ||= includesBuiltMessage(remote2);
Expand Down Expand Up @@ -339,8 +333,8 @@ async function previewHostAndRemotes(

const hasBuildOutputs = (projectName: string): boolean => {
try {
checkFilesExist(`dist/apps/${projectName}/client/q-manifest.json`);
checkFilesExist(`dist/apps/${projectName}/server/entry.preview.mjs`);
checkFilesExist(`dist/${projectName}/client/q-manifest.json`);
checkFilesExist(`dist/${projectName}/server/entry.preview.mjs`);
return true;
} catch {
return false;
Expand Down
6 changes: 2 additions & 4 deletions e2e/qwik-nx-e2e/tests/qwik-nx-cloudflare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ describe('qwik nx cloudflare generator', () => {
`Successfully ran target build for project ${project}`
);
expect(() =>
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
checkFilesExist(`dist/${project}/client/q-manifest.json`)
).not.toThrow();
expect(() =>
checkFilesExist(
`dist/apps/${project}/server/entry.cloudflare-pages.js`
)
checkFilesExist(`dist/${project}/server/entry.cloudflare-pages.js`)
).not.toThrow();
},
DEFAULT_E2E_TIMEOUT
Expand Down
4 changes: 2 additions & 2 deletions e2e/qwik-nx-e2e/tests/qwik-nx-netlify.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ describe('qwik nx netlify generator', () => {
`Successfully ran target build for project ${project}`
);
expect(() =>
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
checkFilesExist(`dist/${project}/client/q-manifest.json`)
).not.toThrow();
expect(() =>
checkFilesExist(
`dist/apps/${project}/.netlify/edge-functions/entry.netlify-edge/entry.netlify-edge.js`
`dist/${project}/.netlify/edge-functions/entry.netlify-edge/entry.netlify-edge.js`
)
).not.toThrow();
},
Expand Down
21 changes: 9 additions & 12 deletions e2e/qwik-nx-e2e/tests/qwik-nx-vite.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('qwikNxVite plugin e2e', () => {
// move header component into the library

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

// move header component files
const headerFolderOldPath = `apps/${project}/src/components/header`;
const headerFolderNewPath = `libs/${headerLibName}/src/lib`;
const headerFolderOldPath = `${project}/src/components/header`;
const headerFolderNewPath = `${headerLibName}/src/lib`;
removeFile(`${headerFolderNewPath}/${headerLibName}.tsx`);
removeFile(`${headerFolderNewPath}/${headerLibName}.css`);
renameFile(
Expand All @@ -78,7 +78,7 @@ describe('qwikNxVite plugin e2e', () => {
`${headerFolderNewPath}/header.css`
);
updateFile(
`libs/${headerLibName}/src/index.ts`,
`${headerLibName}/src/index.ts`,
`export * from './lib/header';`
);

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

// move icon component file
const qwikIconFolderNewPath = `libs/${iconLibName}/src/lib`;
const qwikIconFolderNewPath = `${iconLibName}/src/lib`;
removeFile(`${qwikIconFolderNewPath}/${iconLibName}.tsx`);
removeFile(`${qwikIconFolderNewPath}/${iconLibName}.css`);
renameFile(
`apps/${project}/src/components/icons/qwik.tsx`,
`${project}/src/components/icons/qwik.tsx`,
`${qwikIconFolderNewPath}/qwik.tsx`
);
updateFile(
`libs/${iconLibName}/src/index.ts`,
`export * from './lib/qwik';`
);
updateFile(`${iconLibName}/src/index.ts`, `export * from './lib/qwik';`);
}, DEFAULT_E2E_TIMEOUT);

it(
Expand All @@ -116,10 +113,10 @@ describe('qwikNxVite plugin e2e', () => {
`Successfully ran target build for project ${project}`
);
expect(() =>
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
checkFilesExist(`dist/${project}/client/q-manifest.json`)
).not.toThrow();
expect(() =>
checkFilesExist(`dist/apps/${project}/server/entry.preview.mjs`)
checkFilesExist(`dist/${project}/server/entry.preview.mjs`)
).not.toThrow();
},
DEFAULT_E2E_TIMEOUT
Expand Down
13 changes: 5 additions & 8 deletions e2e/qwik-nx-e2e/tests/storybook.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('qwikNxVite plugin e2e', () => {
);
await addAdditionalStories(appProject);
}, DEFAULT_E2E_TIMEOUT);
checkStorybookIsBuiltAndServed(appProject, 'apps');
checkStorybookIsBuiltAndServed(appProject);
});
describe('Applying storybook for existing library', () => {
beforeAll(async () => {
Expand All @@ -55,7 +55,7 @@ describe('qwikNxVite plugin e2e', () => {
);
await addAdditionalStories(libProject);
}, DEFAULT_E2E_TIMEOUT);
checkStorybookIsBuiltAndServed(libProject, 'libs');
checkStorybookIsBuiltAndServed(libProject);
});

describe('Generating a new library with storybook configuration', () => {
Expand All @@ -65,7 +65,7 @@ describe('qwikNxVite plugin e2e', () => {
);
await addAdditionalStories(secondLibProject);
}, DEFAULT_E2E_TIMEOUT);
checkStorybookIsBuiltAndServed(secondLibProject, 'libs');
checkStorybookIsBuiltAndServed(secondLibProject);
});
});
});
Expand All @@ -79,10 +79,7 @@ async function addAdditionalStories(projectName: string): Promise<void> {
);
}

function checkStorybookIsBuiltAndServed(
projectName: string,
type: 'apps' | 'libs'
) {
function checkStorybookIsBuiltAndServed(projectName: string) {
it(
`should be able to build storybook for the "${projectName}"`,
async () => {
Expand Down Expand Up @@ -115,7 +112,7 @@ function checkStorybookIsBuiltAndServed(
}
);

const mdxPattern = normalize(`${type}/${projectName}/**/*.stories.mdx`);
const mdxPattern = normalize(`${projectName}/**/*.stories.mdx`);

// it is expected that projects won't have stories by default and storybook should recognize it.
expect(resultOutput).toContain(
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"@commitlint/config-angular": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@jscutlery/semver": "^3.1.0",
"@nx/cypress": "16.7.0",
"@nx/devkit": "16.7.0",
"@nx/eslint-plugin": "16.7.0",
"@nx/jest": "16.7.0",
"@nx/js": "16.7.0",
"@nx/linter": "16.7.0",
"@nx/plugin": "16.7.0",
"@nx/storybook": "16.7.0",
"@nx/vite": "16.7.0",
"@nx/workspace": "16.7.0",
"@nx/cypress": "16.10.0",
"@nx/devkit": "16.10.0",
"@nx/eslint-plugin": "16.10.0",
"@nx/jest": "16.10.0",
"@nx/js": "16.10.0",
"@nx/linter": "16.10.0",
"@nx/plugin": "16.10.0",
"@nx/storybook": "16.10.0",
"@nx/vite": "16.10.0",
"@nx/workspace": "16.10.0",
"@nxkit/playwright": "^3.0.2",
"@swc-node/register": "^1.4.2",
"@swc-node/register": "1.6.8",
"@swc/cli": "0.1.62",
"@swc/core": "^1.2.173",
"@types/fs-extra": "11.0.1",
Expand Down Expand Up @@ -63,8 +63,8 @@
"jsonc-eslint-parser": "^2.1.0",
"kill-port": "2.0.1",
"ngx-deploy-npm": "^6.0.0",
"nx": "16.7.0",
"nx-cloud": "16.3.0",
"nx": "16.10.0",
"nx-cloud": "16.5.2",
"prettier": "^2.8.0",
"pretty-quick": "^3.1.3",
"tcp-port-used": "1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-nx/src/generators/application/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function appGenerator(
tree: Tree,
options: QwikAppGeneratorSchema
) {
const normalizedOptions = normalizeOptions(tree, options);
const normalizedOptions = await normalizeOptions(tree, options);
const tasks: GeneratorCallback[] = [];

const targets: Record<string, TargetConfiguration> =
Expand Down
Loading
Loading