diff --git a/.gitignore b/.gitignore index 1ec0aa30b1cf3..71311c125c843 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ tmp *.log jest.debug.config.js .tool-versions +/.nx /.nx-cache /.verdaccio/build/local-registry /graph/client/src/assets/environment.js @@ -19,7 +20,6 @@ jest.debug.config.js /graph/client/src/assets/generated-task-graphs /nx-dev/nx-dev/public/documentation /nx-dev/nx-dev/public/images/open-graph - # Issues scraper creates these files, stored by github's cache /scripts/issues-scraper/cached diff --git a/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap b/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap index 863c64eefd538..6255454a5b971 100644 --- a/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap +++ b/packages/vite/src/generators/configuration/__snapshots__/configuration.spec.ts.snap @@ -175,7 +175,6 @@ export default defineConfig({ ], test: { - dir: '../../node_modules/.vitest', globals: true, cache: { dir: '../../node_modules/.vitest' }, environment: 'jsdom', diff --git a/packages/vite/src/utils/vite-config-edit-utils.ts b/packages/vite/src/utils/vite-config-edit-utils.ts index 3bb7e3d06ba99..ec515a45e9361 100644 --- a/packages/vite/src/utils/vite-config-edit-utils.ts +++ b/packages/vite/src/utils/vite-config-edit-utils.ts @@ -68,12 +68,12 @@ function handleBuildOrTestNode( name: 'build' | 'test' ): string | undefined { const { tsquery } = require('@phenomnomnominal/tsquery'); - const buildNode = tsquery.query( + const buildOrTestNode = tsquery.query( updatedFileContent, `PropertyAssignment:has(Identifier[name="${name}"])` ); - if (buildNode.length) { + if (buildOrTestNode.length) { return tsquery.replace( updatedFileContent, `PropertyAssignment:has(Identifier[name="${name}"])`, @@ -85,7 +85,7 @@ function handleBuildOrTestNode( let updatedPropsString = ''; for (const prop of existingProperties) { const propName = prop.name.getText(); - if (!configContentObject[propName]) { + if (!configContentObject[propName] && propName !== 'dir') { updatedPropsString += `'${propName}': ${prop.initializer.getText()},\n`; } } diff --git a/packages/vue/index.ts b/packages/vue/index.ts index 046a425889e33..6d0ccd97c3617 100644 --- a/packages/vue/index.ts +++ b/packages/vue/index.ts @@ -1,4 +1,5 @@ export * from './src/utils/versions'; +export { applicationGenerator } from './src/generators/application/application'; export { libraryGenerator } from './src/generators/library/library'; export { componentGenerator } from './src/generators/component/component'; export { type InitSchema } from './src/generators/init/schema'; diff --git a/packages/vue/package.json b/packages/vue/package.json index 106a0d7366a83..50ac98eb7a244 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -29,12 +29,15 @@ }, "dependencies": { "tslib": "^2.3.0", + "@nx/cypress": "file:../cypress", "@nx/devkit": "file:../devkit", "@nx/jest": "file:../jest", "@nx/js": "file:../js", "@nx/linter": "file:../linter", + "@nx/playwright": "file:../playwright", "@nx/vite": "file:../vite", - "@nx/web": "file:../web" + "@nx/web": "file:../web", + "@phenomnomnominal/tsquery": "~5.0.1" }, "publishConfig": { "access": "public" diff --git a/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap index 93de798a0a270..f484e817a4731 100644 --- a/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/vue/src/generators/application/__snapshots__/application.spec.ts.snap @@ -27,7 +27,6 @@ export default defineConfig({ // }, test: { - dir: '../node_modules/.vitest', globals: true, cache: { dir: '../node_modules/.vitest' }, environment: 'jsdom', @@ -107,6 +106,12 @@ exports[`application generator should set up project correctly with given option "passWithNoTests": true, "reportsDirectory": "../coverage/test" } + }, + "serve-static": { + "executor": "@nx/web:file-server", + "options": { + "buildTarget": "test:build" + } } } } @@ -164,13 +169,22 @@ exports[`application generator should set up project correctly with given option ".prettierrc", "nx.json", "package.json", + "test-e2e/.eslintrc.json", + "test-e2e/cypress.config.ts", + "test-e2e/project.json", + "test-e2e/src/e2e/app.cy.ts", + "test-e2e/src/fixtures/example.json", + "test-e2e/src/support/app.po.ts", + "test-e2e/src/support/commands.ts", + "test-e2e/src/support/e2e.ts", + "test-e2e/tsconfig.json", "test/.eslintrc.json", "test/index.html", "test/project.json", "test/src/__tests__/App.spec.ts", "test/src/App.vue", + "test/src/components/NxWelcome.vue", "test/src/main.ts", - "test/src/NxWelcome.vue", "test/src/styles.css", "test/tsconfig.app.json", "test/tsconfig.json", diff --git a/packages/vue/src/generators/application/application.ts b/packages/vue/src/generators/application/application.ts index 374884da8d67d..a5cd37b07a2b0 100644 --- a/packages/vue/src/generators/application/application.ts +++ b/packages/vue/src/generators/application/application.ts @@ -88,6 +88,7 @@ export async function applicationGenerator( linter: options.linter ?? Linter.EsLint, unitTestRunner: options.unitTestRunner, setParserOptionsProject: options.setParserOptionsProject, + rootProject: options.rootProject, }, 'app' ); diff --git a/packages/vue/src/generators/component/component.spec.ts b/packages/vue/src/generators/component/component.spec.ts index d86a0aacc3489..5b305a15c761e 100644 --- a/packages/vue/src/generators/component/component.spec.ts +++ b/packages/vue/src/generators/component/component.spec.ts @@ -1,25 +1,15 @@ -import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version'; import { logger, readJson, Tree } from '@nx/devkit'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { componentGenerator } from './component'; import { createLib } from '../../utils/test-utils'; -// need to mock cypress otherwise it'll use the nx installed version from package.json -// which is v9 while we are testing for the new v10 version -jest.mock('@nx/cypress/src/utils/cypress-version'); - describe('component', () => { let appTree: Tree; let projectName: string; - let mockedInstalledCypressVersion: jest.Mock< - ReturnType - > = installedCypressVersion as never; beforeEach(async () => { - mockedInstalledCypressVersion.mockReturnValue(10); projectName = 'my-lib'; appTree = createTreeWithEmptyWorkspace(); - // await createApp(appTree, 'my-app'); await createLib(appTree, projectName); jest.spyOn(logger, 'warn').mockImplementation(() => {}); jest.spyOn(logger, 'debug').mockImplementation(() => {}); diff --git a/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap b/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap index 356fe3434b66d..835f26c6d9bbf 100644 --- a/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap +++ b/packages/vue/src/generators/library/__snapshots__/library.spec.ts.snap @@ -148,7 +148,6 @@ export default defineConfig({ }, test: { - dir: '../node_modules/.vitest', globals: true, cache: { dir: '../node_modules/.vitest' }, environment: 'jsdom', diff --git a/packages/vue/src/generators/library/library.spec.ts b/packages/vue/src/generators/library/library.spec.ts index 2f448041e2603..2dfe6f03919bb 100644 --- a/packages/vue/src/generators/library/library.spec.ts +++ b/packages/vue/src/generators/library/library.spec.ts @@ -1,4 +1,3 @@ -import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version'; import { getProjects, readJson, @@ -13,12 +12,9 @@ import libraryGenerator from './library'; import { Schema } from './schema'; // need to mock cypress otherwise it'll use the nx installed version from package.json // which is v9 while we are testing for the new v10 version -jest.mock('@nx/cypress/src/utils/cypress-version'); describe('lib', () => { let tree: Tree; - let mockedInstalledCypressVersion: jest.Mock< - ReturnType - > = installedCypressVersion as never; + let defaultSchema: Schema = { name: 'myLib', linter: Linter.EsLint, @@ -31,7 +27,6 @@ describe('lib', () => { }; beforeEach(() => { - mockedInstalledCypressVersion.mockReturnValue(10); tree = createTreeWithEmptyWorkspace(); updateJson(tree, '/package.json', (json) => { json.devDependencies = { diff --git a/packages/vue/src/utils/add-linting.ts b/packages/vue/src/utils/add-linting.ts index f3a6d6dc4fe31..a4fb12c1b57cc 100644 --- a/packages/vue/src/utils/add-linting.ts +++ b/packages/vue/src/utils/add-linting.ts @@ -18,6 +18,7 @@ export async function addLinting( unitTestRunner?: 'jest' | 'vitest' | 'none'; setParserOptionsProject?: boolean; skipPackageJson?: boolean; + rootProject?: boolean; }, projectType: 'lib' | 'app' ) { @@ -32,6 +33,7 @@ export async function addLinting( eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx,vue}`], skipFormat: true, setParserOptionsProject: options.setParserOptionsProject, + rootProject: options.rootProject, }); if (isEslintConfigSupported(host)) {