From 05b93090a95d3c67abe11d7155ad509660175e9d Mon Sep 17 00:00:00 2001 From: Zachary Williams Date: Sat, 26 Mar 2022 01:00:15 -0500 Subject: [PATCH] merge in all updates, bump to nx 13.9 --- .circleci/config.yml | 4 +- apps/nuxt-e2e/tests/nuxt.test.ts | 12 +- apps/vite-e2e/project.json | 4 +- apps/vite-e2e/tests/vite.spec.ts | 2 +- apps/vue-e2e/tests/utils.ts | 2 +- apps/vue-e2e/tests/vue-2.test.ts | 38 +- apps/vue-e2e/tests/vue-3.test.ts | 24 +- libs/docusaurus/README.md | 2 +- libs/docusaurus/package.json | 4 +- libs/docusaurus/project.json | 11 +- .../src/executors/browser/executor.ts | 4 +- .../src/executors/dev-server/executor.ts | 2 +- .../generators/application/generator.spec.ts | 14 +- .../src/generators/application/generator.ts | 13 +- libs/nuxt/README.md | 6 +- libs/nuxt/package.json | 12 +- libs/nuxt/project.json | 8 +- libs/nuxt/src/executors/browser/executor.ts | 11 +- libs/nuxt/src/executors/server/executor.ts | 18 +- libs/nuxt/src/executors/static/executor.ts | 22 +- .../files/assets/README.md.template | 7 - .../files/components/Logo.vue.template | 35 - .../files/components/NuxtLogo.vue.template | 11 + .../components/NuxtTutorial.vue.template | 46 + .../files/components/README.md.template | 7 - .../files/layouts/README.md.template | 7 - .../files/layouts/default.vue.template | 55 - .../files/middleware/README.md.template | 8 - .../application/files/nuxt.config.js.template | 76 +- .../files/pages/README.md.template | 6 - .../files/pages/index.vue.template | 60 +- .../files/plugins/README.md.template | 7 - .../files/static/README.md.template | 11 - .../files/test/Logo.spec.js.template | 9 - .../files/test/NuxtLogo.spec.js.template | 9 + .../generators/application/generator.spec.ts | 217 ++- .../src/generators/application/generator.ts | 29 +- libs/nuxt/src/utils.ts | 10 +- libs/vite/README.md | 6 +- libs/vite/package.json | 12 +- libs/vite/project.json | 2 +- libs/vite/src/executors/build/executor.ts | 4 +- libs/vite/src/executors/utils.ts | 2 +- .../generators/application/generator.spec.ts | 20 +- .../src/generators/application/generator.ts | 31 +- libs/vite/src/utils.ts | 8 +- libs/vue/package.json | 26 +- libs/vue/project.json | 11 +- libs/vue/src/executors/browser/executor.ts | 5 +- libs/vue/src/executors/dev-server/executor.ts | 20 +- libs/vue/src/executors/library/executor.ts | 9 +- .../generators/application/generator.spec.ts | 129 +- .../src/generators/application/generator.ts | 35 +- .../generators/component/generator.spec.ts | 11 +- .../src/generators/library/generator.spec.ts | 58 +- libs/vue/src/generators/library/generator.ts | 4 +- libs/vue/src/generators/shared.ts | 12 +- .../vue/src/generators/vuex/generator.spec.ts | 4 +- libs/vue/src/generators/vuex/generator.ts | 10 +- libs/vue/src/utils.ts | 10 +- libs/vue/src/webpack.ts | 38 +- nx.json | 2 +- package.json | 41 +- tools/scripts/utils.js | 2 +- yarn.lock | 1579 ++++++----------- 65 files changed, 1170 insertions(+), 1744 deletions(-) delete mode 100644 libs/nuxt/src/generators/application/files/assets/README.md.template delete mode 100644 libs/nuxt/src/generators/application/files/components/Logo.vue.template create mode 100644 libs/nuxt/src/generators/application/files/components/NuxtLogo.vue.template create mode 100644 libs/nuxt/src/generators/application/files/components/NuxtTutorial.vue.template delete mode 100644 libs/nuxt/src/generators/application/files/components/README.md.template delete mode 100644 libs/nuxt/src/generators/application/files/layouts/README.md.template delete mode 100644 libs/nuxt/src/generators/application/files/layouts/default.vue.template delete mode 100644 libs/nuxt/src/generators/application/files/middleware/README.md.template delete mode 100644 libs/nuxt/src/generators/application/files/pages/README.md.template delete mode 100644 libs/nuxt/src/generators/application/files/plugins/README.md.template delete mode 100644 libs/nuxt/src/generators/application/files/static/README.md.template delete mode 100644 libs/nuxt/src/generators/application/files/test/Logo.spec.js.template create mode 100644 libs/nuxt/src/generators/application/files/test/NuxtLogo.spec.js.template diff --git a/.circleci/config.yml b/.circleci/config.yml index 48a6b9d8..7c529dd2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ orbs: jobs: all: docker: - - image: cypress/base:14.17.3 + - image: cypress/base:16.14.0 steps: - checkout - node/install-packages: @@ -17,7 +17,7 @@ jobs: no_output_timeout: 40m affected: docker: - - image: cypress/base:14.17.3 + - image: cypress/base:16.14.0 steps: - checkout - node/install-packages: diff --git a/apps/nuxt-e2e/tests/nuxt.test.ts b/apps/nuxt-e2e/tests/nuxt.test.ts index 8b325342..1d4d632a 100644 --- a/apps/nuxt-e2e/tests/nuxt.test.ts +++ b/apps/nuxt-e2e/tests/nuxt.test.ts @@ -26,7 +26,7 @@ describe('nuxt e2e', () => { Snapshots: 0 total `); - const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e --headless`); + const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e`); expect(e2eResult.stdout).toContain('All specs passed!'); await runNxCommandAsync(`build ${appName}`); @@ -52,9 +52,7 @@ describe('nuxt e2e', () => { ) ).not.toThrow(); - const prodE2eResult = await runNxCommandAsync( - `e2e ${appName}-e2e --prod --headless` - ); + const prodE2eResult = await runNxCommandAsync(`e2e ${appName}-e2e --prod`); expect(prodE2eResult.stdout).toContain('All specs passed!'); }, 300000); @@ -84,8 +82,7 @@ describe('nuxt e2e', () => { `dist/apps/${appName}/dist/.nojekyll`, `dist/apps/${appName}/dist/200.html`, `dist/apps/${appName}/dist/favicon.ico`, - `dist/apps/${appName}/dist/index.html`, - `dist/apps/${appName}/dist/README.md` + `dist/apps/${appName}/dist/index.html` ) ).not.toThrow(); }, 300000); @@ -134,8 +131,7 @@ describe('nuxt e2e', () => { `dist/apps/subdir/${appName}/dist/.nojekyll`, `dist/apps/subdir/${appName}/dist/200.html`, `dist/apps/subdir/${appName}/dist/favicon.ico`, - `dist/apps/subdir/${appName}/dist/index.html`, - `dist/apps/subdir/${appName}/dist/README.md` + `dist/apps/subdir/${appName}/dist/index.html` ) ).not.toThrow(); }, 300000); diff --git a/apps/vite-e2e/project.json b/apps/vite-e2e/project.json index d61a04f1..20d248e6 100644 --- a/apps/vite-e2e/project.json +++ b/apps/vite-e2e/project.json @@ -10,5 +10,7 @@ "jestConfig": "apps/vite-e2e/jest.config.js" } } - } + }, + "tags": [], + "implicitDependencies": ["vite"] } diff --git a/apps/vite-e2e/tests/vite.spec.ts b/apps/vite-e2e/tests/vite.spec.ts index 6d36856d..a60dcf19 100644 --- a/apps/vite-e2e/tests/vite.spec.ts +++ b/apps/vite-e2e/tests/vite.spec.ts @@ -37,7 +37,7 @@ describe('vite e2e', () => { // see: https://github.com/vitejs/vite/issues/2944 expect(buildResult.stdout).toContain(`dist/apps/${appName}/assets/logo`); - const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e --headless`); + const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e`); expect(e2eResult.stdout).toContain('All specs passed!'); }, 200000); }); diff --git a/apps/vue-e2e/tests/utils.ts b/apps/vue-e2e/tests/utils.ts index c4665079..3bbfe1f4 100644 --- a/apps/vue-e2e/tests/utils.ts +++ b/apps/vue-e2e/tests/utils.ts @@ -31,7 +31,7 @@ export async function testGeneratedApp( } if (options.e2e) { - const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e --headless`); + const e2eResult = await runNxCommandAsync(`e2e ${appName}-e2e`); expect(e2eResult.stdout).toContain('All specs passed!'); } diff --git a/apps/vue-e2e/tests/vue-2.test.ts b/apps/vue-e2e/tests/vue-2.test.ts index 4f754f21..e6c0918e 100644 --- a/apps/vue-e2e/tests/vue-2.test.ts +++ b/apps/vue-e2e/tests/vue-2.test.ts @@ -8,7 +8,7 @@ import { } from '@nrwl/nx-plugin/testing'; import { runNxProdCommandAsync, testGeneratedApp } from './utils'; -describe.skip('vue 2 e2e', () => { +describe('vue 2 e2e', () => { describe('app', () => { beforeAll(() => { ensureNxProject('@nx-plus/vue', 'dist/libs/vue'); @@ -200,12 +200,12 @@ describe.skip('vue 2 e2e', () => { expect(() => checkFilesExist( `dist/libs/${lib}/demo.html`, - `dist/libs/${lib}/${lib}.common.js`, - `dist/libs/${lib}/${lib}.common.js.map`, - `dist/libs/${lib}/${lib}.umd.js`, - `dist/libs/${lib}/${lib}.umd.js.map`, - `dist/libs/${lib}/${lib}.umd.min.js`, - `dist/libs/${lib}/${lib}.umd.min.js.map`, + `dist/libs/${lib}/build.common.js`, + `dist/libs/${lib}/build.common.js.map`, + `dist/libs/${lib}/build.umd.js`, + `dist/libs/${lib}/build.umd.js.map`, + `dist/libs/${lib}/build.umd.min.js`, + `dist/libs/${lib}/build.umd.min.js.map`, `dist/libs/${lib}/package.json`, `dist/libs/${lib}/README.md` ) @@ -228,16 +228,16 @@ describe.skip('vue 2 e2e', () => { ); expect(() => checkFilesExist( - `dist/libs/${lib}/${lib}.common.js`, - `dist/libs/${lib}/${lib}.common.js.map` + `dist/libs/${lib}/build.common.js`, + `dist/libs/${lib}/build.common.js.map` ) ).not.toThrow(); expect(() => checkFilesExist( - `dist/libs/${lib}/${lib}.umd.js`, - `dist/libs/${lib}/${lib}.umd.js.map`, - `dist/libs/${lib}/${lib}.umd.min.js`, - `dist/libs/${lib}/${lib}.umd.min.js.map` + `dist/libs/${lib}/build.umd.js`, + `dist/libs/${lib}/build.umd.js.map`, + `dist/libs/${lib}/build.umd.min.js`, + `dist/libs/${lib}/build.umd.min.js.map` ) ).toThrow(); }, 300000); @@ -255,12 +255,12 @@ describe.skip('vue 2 e2e', () => { expect(() => checkFilesExist( `dist/libs/subdir/${lib}/demo.html`, - `dist/libs/subdir/${lib}/subdir-${lib}.common.js`, - `dist/libs/subdir/${lib}/subdir-${lib}.common.js.map`, - `dist/libs/subdir/${lib}/subdir-${lib}.umd.js`, - `dist/libs/subdir/${lib}/subdir-${lib}.umd.js.map`, - `dist/libs/subdir/${lib}/subdir-${lib}.umd.min.js`, - `dist/libs/subdir/${lib}/subdir-${lib}.umd.min.js.map`, + `dist/libs/subdir/${lib}/build.common.js`, + `dist/libs/subdir/${lib}/build.common.js.map`, + `dist/libs/subdir/${lib}/build.umd.js`, + `dist/libs/subdir/${lib}/build.umd.js.map`, + `dist/libs/subdir/${lib}/build.umd.min.js`, + `dist/libs/subdir/${lib}/build.umd.min.js.map`, `dist/libs/subdir/${lib}/package.json` ) ).not.toThrow(); diff --git a/apps/vue-e2e/tests/vue-3.test.ts b/apps/vue-e2e/tests/vue-3.test.ts index 157c07ed..80cbe1cb 100644 --- a/apps/vue-e2e/tests/vue-3.test.ts +++ b/apps/vue-e2e/tests/vue-3.test.ts @@ -160,12 +160,12 @@ describe('vue 3 e2e', () => { expect(() => checkFilesExist( `dist/libs/${lib}/demo.html`, - `dist/libs/${lib}/${lib}.common.js`, - `dist/libs/${lib}/${lib}.common.js.map`, - `dist/libs/${lib}/${lib}.umd.js`, - `dist/libs/${lib}/${lib}.umd.js.map`, - `dist/libs/${lib}/${lib}.umd.min.js`, - `dist/libs/${lib}/${lib}.umd.min.js.map`, + `dist/libs/${lib}/build.common.js`, + `dist/libs/${lib}/build.common.js.map`, + `dist/libs/${lib}/build.umd.js`, + `dist/libs/${lib}/build.umd.js.map`, + `dist/libs/${lib}/build.umd.min.js`, + `dist/libs/${lib}/build.umd.min.js.map`, `dist/libs/${lib}/package.json`, `dist/libs/${lib}/README.md` ) @@ -188,16 +188,16 @@ describe('vue 3 e2e', () => { ); expect(() => checkFilesExist( - `dist/libs/${lib}/${lib}.common.js`, - `dist/libs/${lib}/${lib}.common.js.map` + `dist/libs/${lib}/build.common.js`, + `dist/libs/${lib}/build.common.js.map` ) ).not.toThrow(); expect(() => checkFilesExist( - `dist/libs/${lib}/${lib}.umd.js`, - `dist/libs/${lib}/${lib}.umd.js.map`, - `dist/libs/${lib}/${lib}.umd.min.js`, - `dist/libs/${lib}/${lib}.umd.min.js.map` + `dist/libs/${lib}/build.umd.js`, + `dist/libs/${lib}/build.umd.js.map`, + `dist/libs/${lib}/build.umd.min.js`, + `dist/libs/${lib}/build.umd.min.js.map` ) ).toThrow(); }, 300000); diff --git a/libs/docusaurus/README.md b/libs/docusaurus/README.md index 21bf2625..f5a29acb 100644 --- a/libs/docusaurus/README.md +++ b/libs/docusaurus/README.md @@ -20,7 +20,7 @@ If you have not already, [create an Nx workspace](https://github.com/nrwl/nx#creating-an-nx-workspace) with the following: ``` -npx create-nx-workspace@^12.0.0 +npx create-nx-workspace@^13.0.0 ``` ## Getting Started diff --git a/libs/docusaurus/package.json b/libs/docusaurus/package.json index f6299361..2f8998d3 100644 --- a/libs/docusaurus/package.json +++ b/libs/docusaurus/package.json @@ -1,6 +1,6 @@ { "name": "@nx-plus/docusaurus", - "version": "12.4.3", + "version": "13.0.0", "main": "src/index.js", "generators": "./generators.json", "executors": "./executors.json", @@ -28,6 +28,6 @@ "@nrwl/workspace": "^13.0.0" }, "dependencies": { - "@nrwl/devkit": "^13.0.0" + "@nrwl/devkit": "^13.9.3" } } diff --git a/libs/docusaurus/project.json b/libs/docusaurus/project.json index 43bb6dcb..4adca30f 100644 --- a/libs/docusaurus/project.json +++ b/libs/docusaurus/project.json @@ -26,7 +26,7 @@ "outputs": ["coverage/libs/docusaurus"] }, "build": { - "executor": "@nrwl/node:package", + "executor": "@nrwl/js:tsc", "options": { "outputPath": "dist/libs/docusaurus", "tsConfig": "libs/docusaurus/tsconfig.lib.json", @@ -41,17 +41,12 @@ }, { "input": "./libs/docusaurus", - "glob": "collection.json", + "glob": "generators.json", "output": "." }, { "input": "./libs/docusaurus", - "glob": "builders.json", - "output": "." - }, - { - "input": "./libs/docusaurus", - "glob": "migrations.json", + "glob": "executors.json", "output": "." } ], diff --git a/libs/docusaurus/src/executors/browser/executor.ts b/libs/docusaurus/src/executors/browser/executor.ts index 16b4d9c3..fba9b422 100644 --- a/libs/docusaurus/src/executors/browser/executor.ts +++ b/libs/docusaurus/src/executors/browser/executor.ts @@ -10,7 +10,7 @@ export default async function* runExecutor( ) { const projectRoot = path.join( context.root, - context.workspace.projects[context.projectName].root + context.workspace.projects[context.projectName ?? ''].root ); try { @@ -24,9 +24,9 @@ export default async function* runExecutor( success: true, }; } catch (err) { + console.error(err); yield { success: false, - error: err, }; } } diff --git a/libs/docusaurus/src/executors/dev-server/executor.ts b/libs/docusaurus/src/executors/dev-server/executor.ts index 1f2ef248..81100d56 100644 --- a/libs/docusaurus/src/executors/dev-server/executor.ts +++ b/libs/docusaurus/src/executors/dev-server/executor.ts @@ -9,7 +9,7 @@ export default async function* runExecutor( ) { const projectRoot = path.join( context.root, - context.workspace.projects[context.projectName].root + context.workspace.projects[context.projectName ?? ''].root ); const port = options.port.toString(); diff --git a/libs/docusaurus/src/generators/application/generator.spec.ts b/libs/docusaurus/src/generators/application/generator.spec.ts index dc660ec0..46d05696 100644 --- a/libs/docusaurus/src/generators/application/generator.spec.ts +++ b/libs/docusaurus/src/generators/application/generator.spec.ts @@ -58,7 +58,7 @@ describe('docusaurus schematic', () => { await applicationGenerator(appTree, options); const config = readProjectConfiguration(appTree, 'my-app'); - const { build, serve } = config.targets; + const { build, serve } = config.targets || {}; expect(config.root).toBe('apps/my-app'); expect(build.executor).toBe('@nx-plus/docusaurus:browser'); @@ -76,15 +76,13 @@ describe('docusaurus schematic', () => { .map((file) => `apps/my-app/${file}`) .forEach((path) => expect(appTree.exists(path)).toBeTruthy()); - expect(appTree.read('.gitignore').toString()).toContain(stripIndents` + expect(appTree.read('.gitignore', 'utf-8')).toContain(stripIndents` # Generated Docusaurus files .docusaurus/ .cache-loader/ `); - expect(appTree.read('.prettierignore').toString()).toContain( - '.docusaurus/' - ); + expect(appTree.read('.prettierignore', 'utf-8')).toContain('.docusaurus/'); }); describe('--directory', () => { @@ -92,7 +90,7 @@ describe('docusaurus schematic', () => { await applicationGenerator(appTree, { ...options, directory: 'subdir' }); const config = readProjectConfiguration(appTree, 'subdir-my-app'); - const { build } = config.targets; + const { build } = config.targets || {}; expect(config.root).toBe('apps/subdir/my-app'); expect(build.options).toEqual({ outputPath: 'dist/apps/subdir/my-app' }); @@ -105,7 +103,7 @@ describe('docusaurus schematic', () => { describe('workspaceLayout', () => { beforeEach(() => { - const nxJson = JSON.parse(appTree.read('nx.json').toString()); + const nxJson = JSON.parse(appTree.read('nx.json', 'utf-8') || ''); const updateNxJson = { ...nxJson, workspaceLayout: { appsDir: 'custom-apps-dir' }, @@ -117,7 +115,7 @@ describe('docusaurus schematic', () => { await applicationGenerator(appTree, options); const config = readProjectConfiguration(appTree, 'my-app'); - const { build } = config.targets; + const { build } = config.targets || {}; expect(config.root).toBe('custom-apps-dir/my-app'); expect(build.options).toEqual({ diff --git a/libs/docusaurus/src/generators/application/generator.ts b/libs/docusaurus/src/generators/application/generator.ts index c8f60663..09533bdc 100644 --- a/libs/docusaurus/src/generators/application/generator.ts +++ b/libs/docusaurus/src/generators/application/generator.ts @@ -66,10 +66,8 @@ function updateGitIgnore(host: Tree) { if (!host.exists(gitIgnorePath)) return; - const gitIgnoreSource = host - .read(gitIgnorePath) - .toString('utf-8') - .trimRight(); + const gitIgnoreSource = host.read(gitIgnorePath, 'utf-8')?.trimRight() ?? ''; + const ignorePatterns = ['.docusaurus/', '.cache-loader/'].filter( (ip) => !gitIgnoreSource.includes(ip) ); @@ -95,10 +93,9 @@ function updatePrettierIgnore(host: Tree) { if (!host.exists(prettierIgnorePath)) return; - const prettierIgnoreSource = host - .read(prettierIgnorePath) - .toString('utf-8') - .trimRight(); + const prettierIgnoreSource = + host.read(prettierIgnorePath, 'utf-8')?.trimRight() ?? ''; + const ignorePattern = '.docusaurus/'; if (prettierIgnoreSource.includes(ignorePattern)) return; diff --git a/libs/nuxt/README.md b/libs/nuxt/README.md index e2e79b6c..35717589 100644 --- a/libs/nuxt/README.md +++ b/libs/nuxt/README.md @@ -22,7 +22,7 @@ If you have not already, [create an Nx workspace](https://github.com/nrwl/nx#creating-an-nx-workspace) with the following: ``` -npx create-nx-workspace@^12.0.0 +npx create-nx-workspace@^13.0.0 ``` ### Peer Dependencies @@ -31,10 +31,10 @@ If you have not already, install peer dependencies with the following: ``` # npm -npm install @nrwl/cypress@^12.0.0 @nrwl/jest@^12.0.0 @nrwl/linter@^12.0.0 --save-dev +npm install @nrwl/cypress@^13.0.0 @nrwl/jest@^13.0.0 @nrwl/linter@^13.0.0 --save-dev # yarn -yarn add @nrwl/cypress@^12.0.0 @nrwl/jest@^12.0.0 @nrwl/linter@^12.0.0 --dev +yarn add @nrwl/cypress@^13.0.0 @nrwl/jest@^13.0.0 @nrwl/linter@^13.0.0 --dev ``` ## Getting Started diff --git a/libs/nuxt/package.json b/libs/nuxt/package.json index 9aa5d975..f3162bc7 100644 --- a/libs/nuxt/package.json +++ b/libs/nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@nx-plus/nuxt", - "version": "12.4.3", + "version": "13.0.0", "main": "src/index.js", "generators": "./generators.json", "executors": "./executors.json", @@ -27,13 +27,13 @@ }, "homepage": "https://github.com/ZachJW34/nx-plus/tree/master/libs/nuxt#readme", "peerDependencies": { - "@nrwl/cypress": "^13.4.3", - "@nrwl/jest": "^13.4.3", - "@nrwl/linter": "^13.4.3", - "@nrwl/workspace": "^13.4.3" + "@nrwl/cypress": "^13.9.3", + "@nrwl/jest": "^13.9.3", + "@nrwl/linter": "^13.9.3", + "@nrwl/workspace": "^13.9.3" }, "dependencies": { - "@nrwl/devkit": "^13.4.3", + "@nrwl/devkit": "^13.9.3", "fs-extra": "^10.0.0", "rxjs": "7.5.1", "semver": "^7.3.5", diff --git a/libs/nuxt/project.json b/libs/nuxt/project.json index 4edb8312..ff94a991 100644 --- a/libs/nuxt/project.json +++ b/libs/nuxt/project.json @@ -26,7 +26,7 @@ "outputs": ["coverage/libs/nuxt"] }, "build": { - "executor": "@nrwl/node:package", + "executor": "@nrwl/js:tsc", "options": { "outputPath": "dist/libs/nuxt", "tsConfig": "libs/nuxt/tsconfig.lib.json", @@ -41,17 +41,17 @@ }, { "input": "./libs/nuxt", - "glob": "collection.json", + "glob": "generators.json", "output": "." }, { "input": "./libs/nuxt", - "glob": "builders.json", + "glob": "executors.json", "output": "." }, { "input": "./libs/nuxt", - "glob": "migrations.json", + "glob": "patch-nx-dep-graph.js", "output": "." } ], diff --git a/libs/nuxt/src/executors/browser/executor.ts b/libs/nuxt/src/executors/browser/executor.ts index 09457518..ec580b99 100644 --- a/libs/nuxt/src/executors/browser/executor.ts +++ b/libs/nuxt/src/executors/browser/executor.ts @@ -1,10 +1,12 @@ -import { build, loadNuxt } from 'nuxt'; import { BrowserExecutorSchema } from './schema'; import { getProjectRoot } from '../../utils'; import { modifyTypescriptAliases } from '../../webpack'; import { ExecutorContext } from '@nrwl/devkit'; import * as path from 'path'; +// eslint-disable-next-line @typescript-eslint/no-var-requires +const { build, loadNuxt } = require('nuxt'); + export default async function* runExecutor( options: BrowserExecutorSchema, context: ExecutorContext @@ -17,7 +19,10 @@ export default async function* runExecutor( configOverrides: { buildDir: path.join(context.root, options.buildDir, '.nuxt'), build: { - extend(config, ctx) { + extend( + config: Record, + ctx: Record + ) { modifyTypescriptAliases(config, projectRoot); // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -40,9 +45,9 @@ export default async function* runExecutor( success: true, }; } catch (err) { + console.error(err); yield { success: false, - error: err, }; } } diff --git a/libs/nuxt/src/executors/server/executor.ts b/libs/nuxt/src/executors/server/executor.ts index 43affa10..92c50c16 100644 --- a/libs/nuxt/src/executors/server/executor.ts +++ b/libs/nuxt/src/executors/server/executor.ts @@ -4,13 +4,15 @@ import { parseTargetString, readTargetOptions, } from '@nrwl/devkit'; -import { build, loadNuxt } from 'nuxt'; import { getProjectRoot } from '../../utils'; import { modifyTypescriptAliases } from '../../webpack'; import { ServerExecutorSchema } from './schema'; import * as path from 'path'; -const serverBuilderOverriddenKeys = []; +// eslint-disable-next-line @typescript-eslint/no-var-requires +const { build, loadNuxt } = require('nuxt'); + +const serverBuilderOverriddenKeys: string[] = []; export default async function* runExecutor( options: ServerExecutorSchema, @@ -18,12 +20,12 @@ export default async function* runExecutor( ) { const browserTarget = parseTargetString(options.browserTarget); const rawBrowserOptions = readTargetOptions(browserTarget, context); - const overrides = Object.keys(options) + const overrides = Object.entries(options) .filter( - (key) => - options[key] !== undefined && serverBuilderOverriddenKeys.includes(key) + ([key, val]) => + val !== undefined && serverBuilderOverriddenKeys.includes(key) ) - .reduce((previous, key) => ({ ...previous, [key]: options[key] }), {}); + .reduce((previous, [key, val]) => ({ ...previous, [key]: val }), {}); const browserOptions = { ...rawBrowserOptions, ...overrides }; const projectRoot = await getProjectRoot(context); @@ -34,7 +36,7 @@ export default async function* runExecutor( configOverrides: { buildDir: path.join(context.root, browserOptions.buildDir, '.nuxt'), build: { - extend(config, ctx) { + extend(config: Record, ctx: Record) { modifyTypescriptAliases(config, projectRoot); // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -55,8 +57,6 @@ export default async function* runExecutor( await build(nuxt); } - console.log(nuxt); - const result = await nuxt.listen(nuxt.options.server.port); const baseUrl = options.dev ? nuxt.server.listeners[0].url : result.url; diff --git a/libs/nuxt/src/executors/static/executor.ts b/libs/nuxt/src/executors/static/executor.ts index 28ce322b..0627029c 100644 --- a/libs/nuxt/src/executors/static/executor.ts +++ b/libs/nuxt/src/executors/static/executor.ts @@ -3,14 +3,16 @@ import { parseTargetString, readTargetOptions, } from '@nrwl/devkit'; -import { Builder, Generator, loadNuxtConfig, Nuxt } from 'nuxt'; import * as path from 'path'; import { getProjectRoot } from '../../utils'; import { modifyTypescriptAliases } from '../../webpack'; import { default as browserExecutor } from '../browser/executor'; import { StaticExecutorSchema } from './schema'; -const serverBuilderOverriddenKeys = []; +// eslint-disable-next-line @typescript-eslint/no-var-requires +const { Builder, Generator, loadNuxtConfig, Nuxt } = require('nuxt'); + +const serverBuilderOverriddenKeys: string[] = []; export default async function* runExecutor( options: StaticExecutorSchema, @@ -19,13 +21,12 @@ export default async function* runExecutor( try { const browserTarget = parseTargetString(options.browserTarget); const rawBrowserOptions = readTargetOptions(browserTarget, context); - const overrides = Object.keys(options) + const overrides = Object.entries(options) .filter( - (key) => - options[key] !== undefined && - serverBuilderOverriddenKeys.includes(key) + ([key, val]) => + val !== undefined && serverBuilderOverriddenKeys.includes(key) ) - .reduce((previous, key) => ({ ...previous, [key]: options[key] }), {}); + .reduce((previous, [key, val]) => ({ ...previous, [key]: val }), {}); const browserOptions = { ...rawBrowserOptions, ...overrides }; await browserExecutor(browserOptions, context).next(); @@ -41,7 +42,10 @@ export default async function* runExecutor( dir: path.join(context.root, browserOptions.buildDir, 'dist'), }, build: { - extend(config, ctx) { + extend( + config: Record, + ctx: Record + ) { modifyTypescriptAliases(config, projectRoot); // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -69,9 +73,9 @@ export default async function* runExecutor( success: true, }; } catch (error) { + console.error(error); yield { success: false, - error, }; } } diff --git a/libs/nuxt/src/generators/application/files/assets/README.md.template b/libs/nuxt/src/generators/application/files/assets/README.md.template deleted file mode 100644 index 34766f93..00000000 --- a/libs/nuxt/src/generators/application/files/assets/README.md.template +++ /dev/null @@ -1,7 +0,0 @@ -# ASSETS - -**This directory is not required, you can delete it if you don't want to use it.** - -This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. - -More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked). diff --git a/libs/nuxt/src/generators/application/files/components/Logo.vue.template b/libs/nuxt/src/generators/application/files/components/Logo.vue.template deleted file mode 100644 index bf7c01aa..00000000 --- a/libs/nuxt/src/generators/application/files/components/Logo.vue.template +++ /dev/null @@ -1,35 +0,0 @@ - - - diff --git a/libs/nuxt/src/generators/application/files/components/NuxtLogo.vue.template b/libs/nuxt/src/generators/application/files/components/NuxtLogo.vue.template new file mode 100644 index 00000000..970eba0e --- /dev/null +++ b/libs/nuxt/src/generators/application/files/components/NuxtLogo.vue.template @@ -0,0 +1,11 @@ + + + diff --git a/libs/nuxt/src/generators/application/files/components/NuxtTutorial.vue.template b/libs/nuxt/src/generators/application/files/components/NuxtTutorial.vue.template new file mode 100644 index 00000000..6440b8fb --- /dev/null +++ b/libs/nuxt/src/generators/application/files/components/NuxtTutorial.vue.template @@ -0,0 +1,46 @@ + + diff --git a/libs/nuxt/src/generators/application/files/components/README.md.template b/libs/nuxt/src/generators/application/files/components/README.md.template deleted file mode 100644 index a079f106..00000000 --- a/libs/nuxt/src/generators/application/files/components/README.md.template +++ /dev/null @@ -1,7 +0,0 @@ -# COMPONENTS - -**This directory is not required, you can delete it if you don't want to use it.** - -The components directory contains your Vue.js Components. - -_Nuxt.js doesn't supercharge these components._ diff --git a/libs/nuxt/src/generators/application/files/layouts/README.md.template b/libs/nuxt/src/generators/application/files/layouts/README.md.template deleted file mode 100644 index cad1ad57..00000000 --- a/libs/nuxt/src/generators/application/files/layouts/README.md.template +++ /dev/null @@ -1,7 +0,0 @@ -# LAYOUTS - -**This directory is not required, you can delete it if you don't want to use it.** - -This directory contains your Application Layouts. - -More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts). diff --git a/libs/nuxt/src/generators/application/files/layouts/default.vue.template b/libs/nuxt/src/generators/application/files/layouts/default.vue.template deleted file mode 100644 index 2170b7d0..00000000 --- a/libs/nuxt/src/generators/application/files/layouts/default.vue.template +++ /dev/null @@ -1,55 +0,0 @@ - - - diff --git a/libs/nuxt/src/generators/application/files/middleware/README.md.template b/libs/nuxt/src/generators/application/files/middleware/README.md.template deleted file mode 100644 index 01595ded..00000000 --- a/libs/nuxt/src/generators/application/files/middleware/README.md.template +++ /dev/null @@ -1,8 +0,0 @@ -# MIDDLEWARE - -**This directory is not required, you can delete it if you don't want to use it.** - -This directory contains your application middleware. -Middleware let you define custom functions that can be run before rendering either a page or a group of pages. - -More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware). diff --git a/libs/nuxt/src/generators/application/files/nuxt.config.js.template b/libs/nuxt/src/generators/application/files/nuxt.config.js.template index c3380df5..40dbe2cd 100644 --- a/libs/nuxt/src/generators/application/files/nuxt.config.js.template +++ b/libs/nuxt/src/generators/application/files/nuxt.config.js.template @@ -1,51 +1,43 @@ export default { - /* - ** Nuxt target - ** See https://nuxtjs.org/api/configuration-target - */ - target: 'server', - /* - ** Headers of the page - ** See https://nuxtjs.org/api/configuration-head - */ + // Global page headers: https://go.nuxtjs.dev/config-head head: { - title: process.env.npm_package_name || '', + title: 'nuxt-app', + htmlAttrs: { + lang: 'en' + }, meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, - { - hid: 'description', - name: 'description', - content: process.env.npm_package_description || '', - }, + { hid: 'description', name: 'description', content: '' }, + { name: 'format-detection', content: 'telephone=no' } ], - link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }], + link: [ + { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } + ] }, - /* - ** Global CSS - */ - css: [], - /* - ** Plugins to load before mounting the App - ** https://nuxtjs.org/guide/plugins - */ - plugins: [], - /* - ** Auto import components - ** See https://nuxtjs.org/api/configuration-components - */ + + // Global CSS: https://go.nuxtjs.dev/config-css + css: [ + ], + + // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins + plugins: [ + ], + + // Auto import components: https://go.nuxtjs.dev/config-components components: true, - /* - ** Nuxt.js dev-modules - */ - buildModules: ['@nuxt/typescript-build'], - /* - ** Nuxt.js modules - */ - modules: [], - /* - ** Build configuration - ** See https://nuxtjs.org/api/configuration-build/ - */ - build: {}, + + // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules + buildModules: [ + // https://go.nuxtjs.dev/typescript + '@nuxt/typescript-build', + ], + + // Modules: https://go.nuxtjs.dev/config-modules + modules: [ + ], + + // Build Configuration: https://go.nuxtjs.dev/config-build + build: { + } } diff --git a/libs/nuxt/src/generators/application/files/pages/README.md.template b/libs/nuxt/src/generators/application/files/pages/README.md.template deleted file mode 100644 index 1d5d48b2..00000000 --- a/libs/nuxt/src/generators/application/files/pages/README.md.template +++ /dev/null @@ -1,6 +0,0 @@ -# PAGES - -This directory contains your Application Views and Routes. -The framework reads all the `*.vue` files inside this directory and creates the router of your application. - -More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing). diff --git a/libs/nuxt/src/generators/application/files/pages/index.vue.template b/libs/nuxt/src/generators/application/files/pages/index.vue.template index a053a798..8adb3aa5 100644 --- a/libs/nuxt/src/generators/application/files/pages/index.vue.template +++ b/libs/nuxt/src/generators/application/files/pages/index.vue.template @@ -1,30 +1,5 @@ - - diff --git a/libs/nuxt/src/generators/application/files/plugins/README.md.template b/libs/nuxt/src/generators/application/files/plugins/README.md.template deleted file mode 100644 index ca1f9d8a..00000000 --- a/libs/nuxt/src/generators/application/files/plugins/README.md.template +++ /dev/null @@ -1,7 +0,0 @@ -# PLUGINS - -**This directory is not required, you can delete it if you don't want to use it.** - -This directory contains Javascript plugins that you want to run before mounting the root Vue.js application. - -More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins). diff --git a/libs/nuxt/src/generators/application/files/static/README.md.template b/libs/nuxt/src/generators/application/files/static/README.md.template deleted file mode 100644 index cf004353..00000000 --- a/libs/nuxt/src/generators/application/files/static/README.md.template +++ /dev/null @@ -1,11 +0,0 @@ -# STATIC - -**This directory is not required, you can delete it if you don't want to use it.** - -This directory contains your static files. -Each file inside this directory is mapped to `/`. -Thus you'd want to delete this README.md before deploying to production. - -Example: `/static/robots.txt` is mapped as `/robots.txt`. - -More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static). diff --git a/libs/nuxt/src/generators/application/files/test/Logo.spec.js.template b/libs/nuxt/src/generators/application/files/test/Logo.spec.js.template deleted file mode 100644 index 14a399e5..00000000 --- a/libs/nuxt/src/generators/application/files/test/Logo.spec.js.template +++ /dev/null @@ -1,9 +0,0 @@ -import { mount } from '@vue/test-utils'; -import Logo from '../components/Logo.vue'; - -describe('Logo', () => { - test('is a Vue instance', () => { - const wrapper = mount(Logo); - expect(wrapper.vm).toBeTruthy(); - }); -}); diff --git a/libs/nuxt/src/generators/application/files/test/NuxtLogo.spec.js.template b/libs/nuxt/src/generators/application/files/test/NuxtLogo.spec.js.template new file mode 100644 index 00000000..322b901e --- /dev/null +++ b/libs/nuxt/src/generators/application/files/test/NuxtLogo.spec.js.template @@ -0,0 +1,9 @@ +import { mount } from '@vue/test-utils' +import NuxtLogo from '../components/NuxtLogo.vue' + +describe('NuxtLogo', () => { + test('is a Vue instance', () => { + const wrapper = mount(NuxtLogo) + expect(wrapper.vm).toBeTruthy() + }) +}) diff --git a/libs/nuxt/src/generators/application/generator.spec.ts b/libs/nuxt/src/generators/application/generator.spec.ts index 290fc6d1..b13b8343 100644 --- a/libs/nuxt/src/generators/application/generator.spec.ts +++ b/libs/nuxt/src/generators/application/generator.spec.ts @@ -1,10 +1,14 @@ import { readProjectConfiguration, Tree } from '@nrwl/devkit'; import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; +import { join } from 'path'; import { applicationGenerator } from './generator'; import { ApplicationGeneratorSchema } from './schema'; describe('nuxt schematic', () => { let appTree: Tree; + + const treeRead = (path: string) => appTree.read(path, 'utf-8') ?? ''; + const options: ApplicationGeneratorSchema = { name: 'my-app', unitTestRunner: 'jest', @@ -12,36 +16,75 @@ describe('nuxt schematic', () => { skipFormat: false, }; + const nuxtFiles = [ + 'tsconfig.json', + 'nuxt.config.js', + '.eslintrc.json', + 'static/favicon.ico', + 'pages/index.vue', + 'components/NuxtLogo.vue', + 'components/NuxtTutorial.vue', + ]; + + const testFiles = [ + 'tsconfig.spec.json', + 'jest.config.js', + 'test/NuxtLogo.spec.js', + ]; + + const getGenFiles = (dir = 'apps/my-app') => + [...nuxtFiles, ...testFiles].map((file) => join(dir, file)); + + const getGenTestFiles = (dir = 'apps/my-app') => + testFiles.map((file) => join(dir, file)); + + const getEslintConfigWithOffset = (offset: string) => ({ + env: { + browser: true, + node: true, + }, + extends: [ + `${offset}.eslintrc.json`, + '@nuxtjs/eslint-config-typescript', + 'plugin:nuxt/recommended', + 'prettier', + ], + parserOptions: { + extraFileExtensions: ['.vue'], + }, + ignorePatterns: ['!**/*'], + rules: {}, + }); + beforeEach(() => { appTree = createTreeWithEmptyWorkspace(); }); it('should update workspace.json', async () => { await applicationGenerator(appTree, options); - const { - root, - targets: { build, serve, test, lint, static: staticGenerate }, - } = readProjectConfiguration(appTree, 'my-app'); - - expect(root).toBe('apps/my-app'); - expect(build.executor).toBe('@nx-plus/nuxt:browser'); - expect(build.options).toEqual({ buildDir: 'dist/apps/my-app' }); - expect(build.configurations.production).toEqual({}); - expect(serve.executor).toBe('@nx-plus/nuxt:server'); - expect(serve.options).toEqual({ + const config = readProjectConfiguration(appTree, 'my-app'); + + expect(config.root).toBe('apps/my-app'); + expect(config.targets?.build.executor).toBe('@nx-plus/nuxt:browser'); + expect(config.targets?.build.options).toEqual({ + buildDir: 'dist/apps/my-app', + }); + expect(config.targets?.build.configurations?.production).toEqual({}); + expect(config.targets?.serve.executor).toBe('@nx-plus/nuxt:server'); + expect(config.targets?.serve.options).toEqual({ browserTarget: 'my-app:build', dev: true, }); - expect(serve.configurations.production).toEqual({ + expect(config.targets?.serve.configurations?.production).toEqual({ browserTarget: 'my-app:build:production', dev: false, }); - expect(staticGenerate.executor).toBe('@nx-plus/nuxt:static'); - expect(staticGenerate.options).toEqual({ + expect(config.targets?.static.executor).toBe('@nx-plus/nuxt:static'); + expect(config.targets?.static.options).toEqual({ browserTarget: 'my-app:build:production', }); - expect(lint.executor).toBe('@nrwl/linter:eslint'); - expect(test.executor).toBe('@nrwl/jest:jest'); + expect(config.targets?.lint.executor).toBe('@nrwl/linter:eslint'); + expect(config.targets?.test.executor).toBe('@nrwl/jest:jest'); expect(readProjectConfiguration(appTree, 'my-app-e2e')).toBeDefined(); }); @@ -49,27 +92,16 @@ describe('nuxt schematic', () => { it('should generate files', async () => { await applicationGenerator(appTree, options); - [ - 'apps/my-app/tsconfig.spec.json', - 'apps/my-app/tsconfig.json', - 'apps/my-app/nuxt.config.js', - 'apps/my-app/jest.config.js', - 'apps/my-app/.eslintrc.json', - 'apps/my-app/test/Logo.spec.js', - 'apps/my-app/static/favicon.ico', - 'apps/my-app/pages/index.vue', - 'apps/my-app/layouts/default.vue', - 'apps/my-app/components/Logo.vue', - ].forEach((path) => expect(appTree.exists(path)).toBeTruthy()); + getGenFiles().forEach((path) => expect(appTree.exists(path)).toBeTruthy()); const eslintConfig = JSON.parse( - appTree.read('apps/my-app/.eslintrc.json').toString() + appTree.read('apps/my-app/.eslintrc.json', 'utf-8') ?? '' ); expect(eslintConfig).toEqual(getEslintConfigWithOffset('../../')); - expect( - appTree.read('apps/my-app-e2e/src/integration/app.spec.ts').toString() - ).toContain("'my-app'"); + expect(treeRead('apps/my-app-e2e/src/integration/app.spec.ts')).toContain( + "'my-app'" + ); }); describe('--unitTestRunner none', () => { @@ -79,17 +111,13 @@ describe('nuxt schematic', () => { unitTestRunner: 'none', }); - const { - targets: { test }, - } = readProjectConfiguration(appTree, 'my-app'); + const config = readProjectConfiguration(appTree, 'my-app'); - expect(test).toBeUndefined(); + expect(config.targets?.test).toBeUndefined(); - [ - 'apps/my-app/tsconfig.spec.json', - 'apps/my-app/jest.config.js', - 'apps/my-app/test/Logo.spec.js', - ].forEach((path) => expect(appTree.exists(path)).toBeFalsy()); + getGenTestFiles().forEach((path) => + expect(appTree.exists(path)).toBeFalsy() + ); }); }); @@ -111,30 +139,29 @@ describe('nuxt schematic', () => { it('should update workspace.json', async () => { await applicationGenerator(appTree, { ...options, directory: 'subdir' }); - const { - root, - targets: { build, serve, test, lint, static: staticGenerate }, - } = readProjectConfiguration(appTree, 'subdir-my-app'); - - expect(root).toBe('apps/subdir/my-app'); - expect(build.executor).toBe('@nx-plus/nuxt:browser'); - expect(build.options).toEqual({ buildDir: 'dist/apps/subdir/my-app' }); - expect(build.configurations.production).toEqual({}); - expect(serve.executor).toBe('@nx-plus/nuxt:server'); - expect(serve.options).toEqual({ + const config = readProjectConfiguration(appTree, 'subdir-my-app'); + + expect(config.root).toBe('apps/subdir/my-app'); + expect(config.targets?.build.executor).toBe('@nx-plus/nuxt:browser'); + expect(config.targets?.build.options).toEqual({ + buildDir: 'dist/apps/subdir/my-app', + }); + expect(config.targets?.build.configurations?.production).toEqual({}); + expect(config.targets?.serve.executor).toBe('@nx-plus/nuxt:server'); + expect(config.targets?.serve.options).toEqual({ browserTarget: 'subdir-my-app:build', dev: true, }); - expect(serve.configurations.production).toEqual({ + expect(config.targets?.serve.configurations?.production).toEqual({ browserTarget: 'subdir-my-app:build:production', dev: false, }); - expect(staticGenerate.executor).toBe('@nx-plus/nuxt:static'); - expect(staticGenerate.options).toEqual({ + expect(config.targets?.static.executor).toBe('@nx-plus/nuxt:static'); + expect(config.targets?.static.options).toEqual({ browserTarget: 'subdir-my-app:build:production', }); - expect(lint.executor).toBe('@nrwl/linter:eslint'); - expect(test.executor).toBe('@nrwl/jest:jest'); + expect(config.targets?.lint.executor).toBe('@nrwl/linter:eslint'); + expect(config.targets?.test.executor).toBe('@nrwl/jest:jest'); expect( readProjectConfiguration(appTree, 'subdir-my-app-e2e') @@ -147,35 +174,24 @@ describe('nuxt schematic', () => { directory: 'subdir', }); - [ - 'apps/subdir/my-app/tsconfig.spec.json', - 'apps/subdir/my-app/tsconfig.json', - 'apps/subdir/my-app/nuxt.config.js', - 'apps/subdir/my-app/jest.config.js', - 'apps/subdir/my-app/.eslintrc.json', - 'apps/subdir/my-app/test/Logo.spec.js', - 'apps/subdir/my-app/static/favicon.ico', - 'apps/subdir/my-app/pages/index.vue', - 'apps/subdir/my-app/layouts/default.vue', - 'apps/subdir/my-app/components/Logo.vue', - ].forEach((path) => expect(appTree.exists(path)).toBeTruthy()); + getGenFiles('apps/subdir/my-app').forEach((path) => + expect(appTree.exists(path)).toBeTruthy() + ); const eslintConfig = JSON.parse( - appTree.read('apps/subdir/my-app/.eslintrc.json').toString() + treeRead('apps/subdir/my-app/.eslintrc.json') ); expect(eslintConfig).toEqual(getEslintConfigWithOffset('../../../')); expect( - appTree - .read('apps/subdir/my-app-e2e/src/integration/app.spec.ts') - .toString() + treeRead('apps/subdir/my-app-e2e/src/integration/app.spec.ts') ).toContain("'subdir-my-app'"); }); }); describe('workspaceLayout', () => { beforeEach(() => { - const nxJson = JSON.parse(appTree.read('nx.json').toString()); + const nxJson = JSON.parse(treeRead('nx.json')); const updateNxJson = { ...nxJson, workspaceLayout: { appsDir: 'custom-apps-dir' }, @@ -185,20 +201,17 @@ describe('nuxt schematic', () => { it('should update workspace.json', async () => { await applicationGenerator(appTree, options); - const { - root, - targets: { build, serve }, - } = readProjectConfiguration(appTree, 'my-app'); + const config = readProjectConfiguration(appTree, 'my-app'); - expect(root).toBe('custom-apps-dir/my-app'); - expect(build.options).toEqual({ + expect(config.root).toBe('custom-apps-dir/my-app'); + expect(config.targets?.build.options).toEqual({ buildDir: 'dist/custom-apps-dir/my-app', }); - expect(serve.options).toEqual({ + expect(config.targets?.serve.options).toEqual({ browserTarget: 'my-app:build', dev: true, }); - expect(serve.configurations.production).toEqual({ + expect(config.targets?.serve.configurations?.production).toEqual({ browserTarget: 'my-app:build:production', dev: false, }); @@ -207,48 +220,18 @@ describe('nuxt schematic', () => { it('should generate files', async () => { await applicationGenerator(appTree, options); - [ - 'custom-apps-dir/my-app/tsconfig.spec.json', - 'custom-apps-dir/my-app/tsconfig.json', - 'custom-apps-dir/my-app/nuxt.config.js', - 'custom-apps-dir/my-app/jest.config.js', - 'custom-apps-dir/my-app/.eslintrc.json', - 'custom-apps-dir/my-app/test/Logo.spec.js', - 'custom-apps-dir/my-app/static/favicon.ico', - 'custom-apps-dir/my-app/pages/index.vue', - 'custom-apps-dir/my-app/layouts/default.vue', - 'custom-apps-dir/my-app/components/Logo.vue', - ].forEach((path) => expect(appTree.exists(path)).toBeTruthy()); + getGenFiles('custom-apps-dir/my-app').forEach((path) => + expect(appTree.exists(path)).toBeTruthy() + ); const eslintConfig = JSON.parse( - appTree.read('custom-apps-dir/my-app/.eslintrc.json').toString() + treeRead('custom-apps-dir/my-app/.eslintrc.json') ); expect(eslintConfig).toEqual(getEslintConfigWithOffset('../../')); expect( - appTree - .read('custom-apps-dir/my-app-e2e/src/integration/app.spec.ts') - .toString() + treeRead('custom-apps-dir/my-app-e2e/src/integration/app.spec.ts') ).toContain("'my-app'"); }); }); }); - -function getEslintConfigWithOffset(offset: string) { - return { - env: { - browser: true, - node: true, - }, - extends: [ - `${offset}.eslintrc.json`, - '@nuxtjs/eslint-config-typescript', - 'plugin:nuxt/recommended', - 'prettier', - ], - parserOptions: { - extraFileExtensions: ['.vue'], - }, - ignorePatterns: ['!**/*'], - }; -} diff --git a/libs/nuxt/src/generators/application/generator.ts b/libs/nuxt/src/generators/application/generator.ts index 8281f67e..46eb42b9 100644 --- a/libs/nuxt/src/generators/application/generator.ts +++ b/libs/nuxt/src/generators/application/generator.ts @@ -60,10 +60,13 @@ function addFiles(tree: Tree, options: NormalizedSchema) { templateOptions ); if (options.unitTestRunner === 'none') { - const { path } = tree - .listChanges() - .find(({ path }) => path.includes('test/Logo.spec.js')); - tree.delete(path); + const { path } = + tree + .listChanges() + .find(({ path }) => path.includes('test/NuxtLogo.spec.js')) || {}; + if (path) { + tree.delete(path); + } } } @@ -171,7 +174,7 @@ async function addCypress(tree: Tree, options: NormalizedSchema) { '@nrwl/cypress' ); const { Linter } = await import('@nrwl/linter'); - const cypressInitTask = await cypressInitGenerator(tree); + const cypressInitTask = await cypressInitGenerator(tree, {}); const cypressTask = await cypressProjectGenerator(tree, { project: options.projectName, name: options.name + '-e2e', @@ -183,10 +186,13 @@ async function addCypress(tree: Tree, options: NormalizedSchema) { const appSpecPath = options.projectRoot + '-e2e/src/integration/app.spec.ts'; tree.write( appSpecPath, - tree - .read(appSpecPath) - .toString('utf-8') - .replace(`Welcome to ${options.projectName}!`, options.projectName) + `describe('${options.projectName}', () => { + it('should display welcome message', () => { + cy.visit('/') + cy.contains('h2', 'Welcome to your Nuxt Application') + }); +}); +` ); return [cypressInitTask, cypressTask]; @@ -270,10 +276,11 @@ export async function applicationGenerator( nuxt: '^2.15.7', }, { - '@nuxtjs/eslint-config-typescript': '^6.0.1', + '@nuxtjs/eslint-config-typescript': '^9.0.0', '@nuxt/types': '^2.15.7', '@nuxt/typescript-build': '^2.1.0', - 'eslint-plugin-nuxt': '^2.0.0', + 'eslint-plugin-nuxt': '^3.2.0', + 'ts-loader': '^8.3.0', } ); diff --git a/libs/nuxt/src/utils.ts b/libs/nuxt/src/utils.ts index 2b012e04..3769e38a 100644 --- a/libs/nuxt/src/utils.ts +++ b/libs/nuxt/src/utils.ts @@ -7,14 +7,14 @@ import { ApplicationGeneratorSchema } from './generators/application/schema'; export function getProjectRoot(context: ExecutorContext) { return path.join( context.root, - context.workspace.projects[context.projectName].root + context.workspace.projects[context.projectName || ''].root ); } // eslint-disable-next-line @typescript-eslint/no-var-requires const Module = require('module'); -export function loadModule(request, context, force = false) { +export function loadModule(request: string, context: string, force = false) { try { return createRequire(path.resolve(context, 'package.json'))(request); } catch (e) { @@ -35,7 +35,7 @@ export function loadModule(request, context, force = false) { const createRequire = Module.createRequire || Module.createRequireFromPath || - function (filename) { + function (filename: string) { const mod = new Module(filename, null); mod.filename = filename; mod.paths = Module._nodeModulePaths(path.dirname(filename)); @@ -45,7 +45,7 @@ const createRequire = return mod.exports; }; -function clearRequireCache(id, map = new Map()) { +function clearRequireCache(id: string, map = new Map()) { const module = require.cache[id]; if (module) { map.set(id, true); @@ -58,7 +58,7 @@ function clearRequireCache(id, map = new Map()) { } export function checkPeerDeps(options: ApplicationGeneratorSchema): void { - const expectedVersion = '^12.0.0'; + const expectedVersion = '^13.0.0'; const unmetPeerDeps = [ ...(options.e2eTestRunner === 'cypress' ? ['@nrwl/cypress'] : []), ...(options.unitTestRunner === 'jest' ? ['@nrwl/jest'] : []), diff --git a/libs/vite/README.md b/libs/vite/README.md index 6ebda71a..ac49a1fa 100644 --- a/libs/vite/README.md +++ b/libs/vite/README.md @@ -22,7 +22,7 @@ If you have not already, [create an Nx workspace](https://github.com/nrwl/nx#creating-an-nx-workspace) with the following: ``` -npx create-nx-workspace@^12.0.0 +npx create-nx-workspace@^13.0.0 ``` ### Peer Dependencies @@ -31,10 +31,10 @@ If you have not already, install peer dependencies with the following: ``` # npm -npm install @nrwl/cypress@^12.0.0 @nrwl/jest@^12.0.0 @nrwl/linter@^12.0.0 --save-dev +npm install @nrwl/cypress@^13.0.0 @nrwl/jest@^13.0.0 @nrwl/linter@^13.0.0 --save-dev # yarn -yarn add @nrwl/cypress@^12.0.0 @nrwl/jest@^12.0.0 @nrwl/linter@^12.0.0 --dev +yarn add @nrwl/cypress@^13.0.0 @nrwl/jest@^13.0.0 @nrwl/linter@^13.0.0 --dev ``` ## Getting Started diff --git a/libs/vite/package.json b/libs/vite/package.json index 0ed14c4a..abf827b2 100644 --- a/libs/vite/package.json +++ b/libs/vite/package.json @@ -1,6 +1,6 @@ { "name": "@nx-plus/vite", - "version": "12.4.3", + "version": "13.0.0", "main": "src/index.js", "generators": "./generators.json", "executors": "./executors.json", @@ -25,13 +25,13 @@ }, "homepage": "https://github.com/ZachJW34/nx-plus/tree/master/libs/vite#readme", "peerDependencies": { - "@nrwl/cypress": "^13.4.3", - "@nrwl/jest": "^13.4.3", - "@nrwl/linter": "^13.4.3", - "@nrwl/workspace": "^13.4.3" + "@nrwl/cypress": "^13.9.3", + "@nrwl/jest": "^13.9.3", + "@nrwl/linter": "^13.9.3", + "@nrwl/workspace": "^13.9.3" }, "dependencies": { - "@nrwl/devkit": "^13.4.3", + "@nrwl/devkit": "^13.9.3", "semver": "^7.3.5" } } diff --git a/libs/vite/project.json b/libs/vite/project.json index 13d0e755..d8b6f728 100644 --- a/libs/vite/project.json +++ b/libs/vite/project.json @@ -18,7 +18,7 @@ } }, "build": { - "executor": "@nrwl/node:package", + "executor": "@nrwl/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/vite", diff --git a/libs/vite/src/executors/build/executor.ts b/libs/vite/src/executors/build/executor.ts index 4234d86a..03ba560f 100644 --- a/libs/vite/src/executors/build/executor.ts +++ b/libs/vite/src/executors/build/executor.ts @@ -21,9 +21,9 @@ export default async function* runExecutor(options: ViteBuildExecutorSchema) { await new Promise<{ success: boolean }>(() => {}); } } catch (err) { - return { + console.error(err); + yield { success: false, - error: err, }; } } diff --git a/libs/vite/src/executors/utils.ts b/libs/vite/src/executors/utils.ts index c87b26e7..947a7e11 100644 --- a/libs/vite/src/executors/utils.ts +++ b/libs/vite/src/executors/utils.ts @@ -2,7 +2,7 @@ import { ViteBuildExecutorSchema } from './build/schema'; import { ViteServerExecutorSchema } from './server/schema'; export function cleanViteOptions( - options: ViteServerExecutorSchema | ViteBuildExecutorSchema + options: Partial | Partial ) { const ret = { ...options }; delete ret.debug; diff --git a/libs/vite/src/generators/application/generator.spec.ts b/libs/vite/src/generators/application/generator.spec.ts index 81690d23..56deace1 100644 --- a/libs/vite/src/generators/application/generator.spec.ts +++ b/libs/vite/src/generators/application/generator.spec.ts @@ -12,6 +12,8 @@ describe('application generator', () => { e2eTestRunner: 'cypress', }; + const treeRead = (path: string) => appTree.read(path, 'utf-8') ?? ''; + beforeEach(() => { appTree = createTreeWithEmptyWorkspace(); }); @@ -23,17 +25,17 @@ describe('application generator', () => { expect(config.root).toBe('apps/my-app'); expect(config.sourceRoot).toBe('apps/my-app/src'); - expect(config.targets.build.executor).toBe('@nx-plus/vite:build'); - expect(config.targets.build.options).toEqual({ + expect(config.targets?.build.executor).toBe('@nx-plus/vite:build'); + expect(config.targets?.build.options).toEqual({ config: 'apps/my-app/vite.config.ts', }); - expect(config.targets.serve.executor).toBe('@nx-plus/vite:server'); - expect(config.targets.serve.options).toEqual({ + expect(config.targets?.serve.executor).toBe('@nx-plus/vite:server'); + expect(config.targets?.serve.options).toEqual({ config: 'apps/my-app/vite.config.ts', }); - expect(config.targets.lint.executor).toBe('@nrwl/linter:eslint'); - expect(config.targets.test.executor).toBe('@nrwl/jest:jest'); + expect(config.targets?.lint.executor).toBe('@nrwl/linter:eslint'); + expect(config.targets?.test.executor).toBe('@nrwl/jest:jest'); const e2eConfig = readProjectConfiguration(appTree, 'my-app-e2e'); expect(e2eConfig).toBeDefined(); @@ -73,7 +75,7 @@ describe('application generator', () => { }); const config = readProjectConfiguration(appTree, 'my-app'); - expect(config.targets.test).toBeUndefined(); + expect(config.targets?.test).toBeUndefined(); [ 'apps/my-app/tsconfig.spec.json', @@ -87,9 +89,7 @@ describe('application generator', () => { ); expect(tsconfigAppJson.exclude).toBeUndefined(); - expect(appTree.read('apps/my-app/.eslintrc.js').toString()).not.toContain( - 'overrides:' - ); + expect(treeRead('apps/my-app/.eslintrc.js')).not.toContain('overrides:'); const tsConfigJson = readJson(appTree, 'apps/my-app/tsconfig.json'); expect(tsConfigJson.references[1]).toBeUndefined(); diff --git a/libs/vite/src/generators/application/generator.ts b/libs/vite/src/generators/application/generator.ts index b9137cf9..2db9d861 100644 --- a/libs/vite/src/generators/application/generator.ts +++ b/libs/vite/src/generators/application/generator.ts @@ -61,10 +61,13 @@ function addFiles(tree: Tree, options: NormalizedSchema) { templateOptions ); if (options.unitTestRunner === 'none') { - const { path } = tree - .listChanges() - .find(({ path }) => path.includes('example.spec.ts')); - tree.delete(path); + const { path } = + tree.listChanges().find(({ path }) => path.includes('example.spec.ts')) || + {}; + + if (path) { + tree.delete(path); + } } } @@ -136,7 +139,7 @@ async function addCypress(tree: Tree, options: NormalizedSchema) { '@nrwl/cypress' ); const { Linter } = await import('@nrwl/linter'); - const cypressInitTask = await cypressInitGenerator(tree); + const cypressInitTask = await cypressInitGenerator(tree, {}); const cypressTask = await cypressProjectGenerator(tree, { project: options.projectName, name: options.name + '-e2e', @@ -148,13 +151,13 @@ async function addCypress(tree: Tree, options: NormalizedSchema) { const appSpecPath = options.projectRoot + '-e2e/src/integration/app.spec.ts'; tree.write( appSpecPath, - tree - .read(appSpecPath) - .toString('utf-8') - .replace( - `Welcome to ${options.projectName}!`, - 'Hello Vue 3 + TypeScript + Vite' - ) + `describe('${options.projectName}', () => { + it('should display welcome message', () => { + cy.visit('/') + cy.contains('h1', 'Hello Vue 3 + TypeScript + Vite') + }); +}); +` ); return [cypressInitTask, cypressTask]; @@ -174,7 +177,9 @@ async function addJest(tree: Tree, options: NormalizedSchema) { babelJest: false, }); updateJson(tree, `${options.projectRoot}/tsconfig.spec.json`, (json) => { - json.include = json.include.filter((pattern) => !/\.jsx?$/.test(pattern)); + json.include = json.include.filter( + (pattern: string) => !/\.jsx?$/.test(pattern) + ); json.compilerOptions = { ...json.compilerOptions, jsx: 'preserve', diff --git a/libs/vite/src/utils.ts b/libs/vite/src/utils.ts index f03ac0b2..c0505b34 100644 --- a/libs/vite/src/utils.ts +++ b/libs/vite/src/utils.ts @@ -7,7 +7,7 @@ import { ApplicationGeneratorSchema } from './generators/application/schema'; // eslint-disable-next-line @typescript-eslint/no-var-requires const Module = require('module'); -export function loadModule(request, context, force = false) { +export function loadModule(request: string, context: string, force = false) { try { return createRequire(path.resolve(context, 'package.json'))(request); } catch (e) { @@ -28,7 +28,7 @@ export function loadModule(request, context, force = false) { const createRequire = Module.createRequire || Module.createRequireFromPath || - function (filename) { + function (filename: string) { const mod = new Module(filename, null); mod.filename = filename; mod.paths = Module._nodeModulePaths(path.dirname(filename)); @@ -38,7 +38,7 @@ const createRequire = return mod.exports; }; -function clearRequireCache(id, map = new Map()) { +function clearRequireCache(id: string, map = new Map()) { const module = require.cache[id]; if (module) { map.set(id, true); @@ -51,7 +51,7 @@ function clearRequireCache(id, map = new Map()) { } export function checkPeerDeps(options: ApplicationGeneratorSchema): void { - const expectedVersion = '^12.0.0'; + const expectedVersion = '^13.0.0'; const unmetPeerDeps = [ ...(options.e2eTestRunner === 'cypress' ? ['@nrwl/cypress'] : []), ...(options.unitTestRunner === 'jest' ? ['@nrwl/jest'] : []), diff --git a/libs/vue/package.json b/libs/vue/package.json index 7fde8266..72eef61d 100644 --- a/libs/vue/package.json +++ b/libs/vue/package.json @@ -1,6 +1,6 @@ { "name": "@nx-plus/vue", - "version": "12.4.3", + "version": "13.0.0", "main": "src/index.js", "generators": "./generators.json", "executors": "./executors.json", @@ -27,24 +27,24 @@ }, "homepage": "https://github.com/ZachJW34/nx-plus/tree/master/libs/vue#readme", "peerDependencies": { - "@nrwl/cypress": "^13.4.3", - "@nrwl/jest": "^13.4.3", - "@nrwl/linter": "^13.4.3", - "@nrwl/workspace": "^13.4.3" + "@nrwl/cypress": "^13.9.3", + "@nrwl/jest": "^13.9.3", + "@nrwl/linter": "^13.9.3", + "@nrwl/workspace": "^13.9.3" }, "dependencies": { - "@nrwl/devkit": "^13.4.3", + "@nrwl/devkit": "^13.9.3", "@vue/cli-shared-utils": "~4.5.15", - "copy-webpack-plugin": "^10.2.0", + "copy-webpack-plugin": "^5.1.1", "fs-extra": "^10.0.0", - "less": "^4.1.2", - "less-loader": "^10.2.0", + "less": "^3.0.4", + "less-loader": "^5.0.0", "rxjs": "7.5.1", - "sass": "^1.45.2", - "sass-loader": "^12.4.0", + "sass": "^1.26.5", + "sass-loader": "^8.0.2", "semver": "^7.3.5", - "stylus": "^0.56.0", - "stylus-loader": "^6.2.0", + "stylus": "^0.54.7", + "stylus-loader": "^3.0.2", "tsconfig-paths-webpack-plugin": "3.5.2", "typescript": "4.5.4" }, diff --git a/libs/vue/project.json b/libs/vue/project.json index 46e60002..d19ed692 100644 --- a/libs/vue/project.json +++ b/libs/vue/project.json @@ -26,7 +26,7 @@ "outputs": ["coverage/libs/vue"] }, "build": { - "executor": "@nrwl/node:package", + "executor": "@nrwl/js:tsc", "options": { "outputPath": "dist/libs/vue", "tsConfig": "libs/vue/tsconfig.lib.json", @@ -41,23 +41,18 @@ }, { "input": "./libs/vue", - "glob": "collection.json", + "glob": "generators.json", "output": "." }, { "input": "./libs/vue", - "glob": "builders.json", + "glob": "executors.json", "output": "." }, { "input": "./libs/vue", "glob": "patch-nx-dep-graph.js", "output": "." - }, - { - "input": "./libs/vue", - "glob": "migrations.json", - "output": "." } ], "srcRootForCompilationRoot": "libs/vue" diff --git a/libs/vue/src/executors/browser/executor.ts b/libs/vue/src/executors/browser/executor.ts index e2ee71e1..0ac44cfe 100644 --- a/libs/vue/src/executors/browser/executor.ts +++ b/libs/vue/src/executors/browser/executor.ts @@ -49,7 +49,7 @@ export default async function* runExecutor( const babelConfig = await getBabelConfig(projectRoot); const inlineOptions = { - chainWebpack: (config) => { + chainWebpack: (config: unknown) => { modifyIndexHtmlPath(config, options, context); modifyEntryPoint(config, options, context); modifyTsConfigPaths(config, options, context); @@ -99,6 +99,7 @@ export default async function* runExecutor( await new Promise<{ success: boolean }>(() => {}); } } catch (err) { - yield { success: false, error: err }; + console.error(err); + yield { success: false }; } } diff --git a/libs/vue/src/executors/dev-server/executor.ts b/libs/vue/src/executors/dev-server/executor.ts index 69a9833d..8a86eb0b 100644 --- a/libs/vue/src/executors/dev-server/executor.ts +++ b/libs/vue/src/executors/dev-server/executor.ts @@ -33,6 +33,10 @@ const devServerBuilderOverriddenKeys = [ 'stdin', ]; +// Deal with this later +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type ANY = any; + function modifyChalk(context: ExecutorContext) { // The vue-cli build command is not suitable for an nx project. // We spy on chalk to intercept the console output and replace @@ -59,31 +63,31 @@ export default async function* runExecutor( // `undefined`. // TODO: Handle this less obtrusively. if ( + options.css && options.css.requireModuleExtension === undefined && options.css.extract === undefined && options.css.sourceMap === undefined && !Object.keys(options.css.loaderOptions).length ) { - options.css = undefined; + (options as ANY).css = undefined; } const browserTarget = parseTargetString(options.browserTarget); const rawBrowserOptions = readTargetOptions(browserTarget, context); - const overrides = Object.keys(options) + const overrides = Object.entries(options) .filter( - (key) => - options[key] !== undefined && - devServerBuilderOverriddenKeys.includes(key) + ([key, val]) => + val !== undefined && devServerBuilderOverriddenKeys.includes(key) ) - .reduce((previous, key) => ({ ...previous, [key]: options[key] }), {}); + .reduce((previous, [key, val]) => ({ ...previous, [key]: val }), {}); const browserOptions = { ...rawBrowserOptions, ...overrides }; const projectRoot = getProjectRoot(context); const babelConfig = await getBabelConfig(projectRoot); const inlineOptions = { - chainWebpack: (config) => { + chainWebpack: (config: ANY) => { modifyIndexHtmlPath(config, browserOptions, context); modifyEntryPoint(config, browserOptions, context); modifyTsConfigPaths(config, browserOptions, context); @@ -97,7 +101,7 @@ export default async function* runExecutor( // There is no option to disable file watching in `webpack-dev-server`, // but webpack's file watcher can be overriden. config.plugin('vue-cli').use({ - apply: (compiler) => { + apply: (compiler: ANY) => { compiler.hooks.afterEnvironment.tap('vue-cli', () => { // eslint-disable-next-line @typescript-eslint/no-empty-function compiler.watchFileSystem = { watch: () => {} }; diff --git a/libs/vue/src/executors/library/executor.ts b/libs/vue/src/executors/library/executor.ts index 6d3f6b29..aadbfecd 100644 --- a/libs/vue/src/executors/library/executor.ts +++ b/libs/vue/src/executors/library/executor.ts @@ -37,6 +37,10 @@ function modifyChalk(options: LibraryExecutorSchema) { ); } +// Deal with this later +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type ANY = any; + export default async function* runExecutor( options: LibraryExecutorSchema, context: ExecutorContext @@ -48,7 +52,7 @@ export default async function* runExecutor( const babelConfig = await getBabelConfig(projectRoot); const inlineOptions = { - chainWebpack: (config) => { + chainWebpack: (config: ANY) => { modifyTsConfigPaths(config, options, context); modifyCachePaths(config, context); modifyTypescriptAliases(config, options, context); @@ -96,6 +100,7 @@ export default async function* runExecutor( await new Promise<{ success: boolean }>(() => {}); } } catch (err) { - yield { success: false, error: err }; + console.error(err); + yield { success: false }; } } diff --git a/libs/vue/src/generators/application/generator.spec.ts b/libs/vue/src/generators/application/generator.spec.ts index 20c5c7bb..1ea62be2 100644 --- a/libs/vue/src/generators/application/generator.spec.ts +++ b/libs/vue/src/generators/application/generator.spec.ts @@ -17,6 +17,8 @@ export const options: ApplicationGeneratorSchema = { describe('application schematic', () => { let appTree: Tree; + const treeRead = (path: string) => appTree.read(path, 'utf-8') || ''; + beforeEach(() => { appTree = createTreeWithEmptyWorkspace(); }); @@ -24,22 +26,18 @@ describe('application schematic', () => { it('should update workspace.json', async () => { await applicationGenerator(appTree, options); - const { - root, - sourceRoot, - targets: { build, serve, test, lint }, - } = readProjectConfiguration(appTree, 'my-app'); + const config = readProjectConfiguration(appTree, 'my-app'); - expect(root).toBe('apps/my-app'); - expect(sourceRoot).toBe('apps/my-app/src'); - expect(build.executor).toBe('@nx-plus/vue:browser'); - expect(build.options).toEqual({ + expect(config.root).toBe('apps/my-app'); + expect(config.sourceRoot).toBe('apps/my-app/src'); + expect(config.targets?.build.executor).toBe('@nx-plus/vue:browser'); + expect(config.targets?.build.options).toEqual({ dest: 'dist/apps/my-app', index: 'apps/my-app/public/index.html', main: 'apps/my-app/src/main.ts', tsConfig: 'apps/my-app/tsconfig.app.json', }); - expect(build.configurations.production).toEqual({ + expect(config.targets?.build.configurations?.production).toEqual({ mode: 'production', filenameHashing: true, productionSourceMap: true, @@ -48,15 +46,15 @@ describe('application schematic', () => { sourceMap: false, }, }); - expect(serve.executor).toBe('@nx-plus/vue:dev-server'); - expect(serve.options).toEqual({ + expect(config.targets?.serve.executor).toBe('@nx-plus/vue:dev-server'); + expect(config.targets?.serve.options).toEqual({ browserTarget: 'my-app:build', }); - expect(serve.configurations.production).toEqual({ + expect(config.targets?.serve.configurations?.production).toEqual({ browserTarget: 'my-app:build:production', }); - expect(lint.executor).toBe('@nrwl/linter:eslint'); - expect(test.executor).toBe('@nrwl/jest:jest'); + expect(config.targets?.lint.executor).toBe('@nrwl/linter:eslint'); + expect(config.targets?.test.executor).toBe('@nrwl/jest:jest'); expect(readProjectConfiguration(appTree, 'my-app-e2e')).toBeDefined(); }); @@ -82,16 +80,14 @@ describe('application schematic', () => { const tsconfigAppJson = readJson(appTree, 'apps/my-app/tsconfig.app.json'); expect(tsconfigAppJson.exclude).toEqual(['**/*.spec.ts', '**/*.spec.tsx']); - const eslintConfig = JSON.parse( - appTree.read('apps/my-app/.eslintrc.json').toString() - ); + const eslintConfig = JSON.parse(treeRead('apps/my-app/.eslintrc.json')); expect(eslintConfig).toEqual(getEslintConfigWithOffset('../../')); - expect( - appTree.read('apps/my-app-e2e/src/integration/app.spec.ts').toString() - ).toContain("'Welcome to Your Vue.js + TypeScript App'"); + expect(treeRead('apps/my-app-e2e/src/integration/app.spec.ts')).toContain( + "'Welcome to Your Vue.js + TypeScript App'" + ); - expect(appTree.read('apps/my-app/src/App.vue').toString()).toContain(` + expect(treeRead('apps/my-app/src/App.vue')).toContain(` `); - expect(appTree.read('apps/my-app/src/components/HelloWorld.vue').toString()) - .toContain(` + expect(treeRead('apps/my-app/src/components/HelloWorld.vue')).toContain(` `); - expect( - appTree.read('apps/my-app/src/components/HelloWorld.vue').toString() - ).toContain(` + expect(treeRead('apps/my-app/src/components/HelloWorld.vue')).toContain(`