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

feat(js): update vue/node app and lib generators to support TS solutions #29299

Merged
merged 9 commits into from
Dec 12, 2024
9 changes: 6 additions & 3 deletions docs/generated/packages/express/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint"],
"default": "eslint"
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests.",
"default": "jest"
"default": "none",
"x-prompt": "Which unit test runner would you like to use?"
},
"tags": {
"type": "string",
Expand Down
7 changes: 5 additions & 2 deletions docs/generated/packages/nest/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"description": "Test runner to use for unit tests.",
"type": "string",
"enum": ["jest", "none"],
"default": "jest"
"default": "none",
"x-prompt": "Which unit test runner would you like to use?"
},
"e2eTestRunner": {
"type": "string",
Expand Down
8 changes: 6 additions & 2 deletions docs/generated/packages/nest/generators/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"description": "Test runner to use for unit tests.",
"type": "string",
"enum": ["jest", "none"],
"default": "jest"
"default": "none",
"x-prompt": "Which unit test runner would you like to use?",
"x-priority": "important"
},
"tags": {
"description": "Add tags to the library (used for linting).",
Expand Down
24 changes: 15 additions & 9 deletions docs/generated/packages/node/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,26 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint"],
"default": "eslint"
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests.",
"default": "jest"
"default": "none",
"x-priority": "important",
"x-prompt": "Which unit test runner would you like to use?"
},
"e2eTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for end-to-end tests",
"default": "none",
"x-priority": "important",
"x-prompt": "Which end-to-end test runner would you like to use?"
},
"tags": {
"type": "string",
Expand Down Expand Up @@ -109,12 +121,6 @@
"hidden": true,
"x-priority": "internal"
},
"e2eTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for end to end (e2e) tests",
"default": "jest"
},
"docker": {
"type": "boolean",
"description": "Add a docker build target"
Expand Down
12 changes: 8 additions & 4 deletions docs/generated/packages/node/generators/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint"],
"default": "eslint"
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests.",
"default": "jest"
"default": "none",
"x-prompt": "Which unit test runner would you like to use?",
"x-priority": "important"
},
"tags": {
"type": "string",
Expand All @@ -69,7 +73,7 @@
},
"buildable": {
"type": "boolean",
"default": false,
"default": true,
"description": "Generate a buildable library.",
"x-priority": "important"
},
Expand Down
17 changes: 10 additions & 7 deletions docs/generated/packages/nuxt/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@
"pattern": "^[a-zA-Z][^:]*$",
"x-priority": "important"
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint"],
"default": "eslint"
},
"skipFormat": {
"description": "Skip formatting files.",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["vitest", "none"],
"description": "Test runner to use for unit tests.",
"x-prompt": "Which unit test runner would you like to use?",
"default": "none"
"default": "none",
"x-priority": "important"
},
"e2eTestRunner": {
"type": "string",
Expand Down
17 changes: 10 additions & 7 deletions docs/generated/packages/vue/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@
]
}
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
},
"routing": {
"type": "boolean",
"description": "Generate application with routes.",
Expand All @@ -72,12 +66,21 @@
"default": false,
"x-priority": "internal"
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["vitest", "none"],
"description": "Test runner to use for unit tests.",
"x-prompt": "Which unit test runner would you like to use?",
"default": "vitest"
"default": "none",
"x-priority": "important"
},
"inSourceTests": {
"type": "boolean",
Expand Down
8 changes: 6 additions & 2 deletions docs/generated/packages/vue/generators/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["vitest", "none"],
"description": "Test runner to use for unit tests.",
"x-prompt": "What unit test runner should be used?"
"x-prompt": "What unit test runner should be used?",
"default": "none",
"x-priority": "important"
},
"inSourceTests": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion e2e/eslint/src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ describe('Linter', () => {
const mylib = uniq('mylib');

runCLI(
`generate @nx/node:app --name=${myapp} --linter eslint --directory="." --no-interactive`
`generate @nx/node:app --name=${myapp} --linter=eslint --directory="." --e2eTestRunner=jest --no-interactive`
);
runCLI('reset', { env: { CI: 'false' } });
verifySuccessfulStandaloneSetup(myapp);
Expand Down
2 changes: 1 addition & 1 deletion e2e/jest/src/jest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('Jest', () => {
it('should be able to test node lib with babel-jest', async () => {
const libName = uniq('babel-test-lib');
runCLI(
`generate @nx/node:lib libs/${libName} --buildable --importPath=@some-org/babel-test --publishable --babelJest`
`generate @nx/node:lib libs/${libName} --buildable --importPath=@some-org/babel-test --publishable --babelJest --unitTestRunner=jest`
);

const cliResults = await runCLIAsync(`test ${libName}`);
Expand Down
2 changes: 1 addition & 1 deletion e2e/node/src/node-esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Node Applications + esbuild', () => {
const app = uniq('nodeapp');

runCLI(
`generate @nx/node:app apps/${app} --bundler=esbuild --no-interactive`
`generate @nx/node:app apps/${app} --bundler=esbuild --no-interactive --linter=eslint --unitTestRunner=jest`
);

checkFilesDoNotExist(`apps/${app}/webpack.config.js`);
Expand Down
22 changes: 13 additions & 9 deletions e2e/node/src/node-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,23 @@ describe('Node Applications + webpack', () => {
const nestApp = uniq('nest');

beforeAll(() => {
runCLI(`generate @nx/node:lib libs/${testLib1}`);
runCLI(`generate @nx/node:lib libs/${testLib2} --importPath=@acme/test2`);
runCLI(
`generate @nx/node:app apps/${expressApp} --framework=express --port=7000 --no-interactive`
`generate @nx/node:lib libs/${testLib1} --linter=eslint --unitTestRunner=jest --buildable=false`
);
runCLI(
`generate @nx/node:app apps/${fastifyApp} --framework=fastify --port=7001 --no-interactive`
`generate @nx/node:lib libs/${testLib2} --importPath=@acme/test2 --linter=eslint --unitTestRunner=jest --buildable=false`
);
runCLI(
`generate @nx/node:app apps/${koaApp} --framework=koa --port=7002 --no-interactive`
`generate @nx/node:app apps/${expressApp} --framework=express --port=7000 --no-interactive --linter=eslint --unitTestRunner=jest --e2eTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${nestApp} --framework=nest --port=7003 --bundler=webpack --no-interactive`
`generate @nx/node:app apps/${fastifyApp} --framework=fastify --port=7001 --no-interactive --linter=eslint --unitTestRunner=jest --e2eTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${koaApp} --framework=koa --port=7002 --no-interactive --linter=eslint --unitTestRunner=jest --e2eTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${nestApp} --framework=nest --port=7003 --bundler=webpack --no-interactive --linter=eslint --unitTestRunner=jest --e2eTestRunner=jest`
);

addLibImport(expressApp, testLib1);
Expand Down Expand Up @@ -165,7 +169,7 @@ describe('Node Applications + webpack', () => {
const expressApp = 'docker-express-app'; // needs to be consistent for the Dockerfile snapshot

runCLI(
`generate @nx/node:app apps/${expressApp} --framework=express --docker --no-interactive`
`generate @nx/node:app apps/${expressApp} --framework=express --docker --no-interactive --linter=eslint --unitTestRunner=jest`
);

checkFilesExist(`apps/${expressApp}/Dockerfile`);
Expand All @@ -179,10 +183,10 @@ describe('Node Applications + webpack', () => {

// Set ports to avoid conflicts with other tests that might run in parallel
runCLI(
`generate @nx/node:app apps/${nodeApp1} --framework=none --no-interactive --port=4444`
`generate @nx/node:app apps/${nodeApp1} --framework=none --no-interactive --port=4444 --linter=eslint --unitTestRunner=jest`
);
runCLI(
`generate @nx/node:app apps/${nodeApp2} --framework=none --no-interactive --port=4445`
`generate @nx/node:app apps/${nodeApp2} --framework=none --no-interactive --port=4445 --linter=eslint --unitTestRunner=jest`
);
updateJson(join('apps', nodeApp1, 'project.json'), (config) => {
config.targets.serve.options.waitUntilTargets = [`${nodeApp2}:build`];
Expand Down
Loading
Loading