diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 5912779d2..3cff4de60 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,16 +1,23 @@ name: Release on: - - workflow_dispatch + push: + tags: + - v*.*.* + workflow_run: + jobs: release: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # needed for provenance data generation if: github.ref == 'refs/heads/main' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup uses: ./.github/actions/setup with: @@ -21,20 +28,9 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }} + NPM_CONFIG_PROVENANCE: true # Use npx instead of yarn because yarn automagically sets NPM_* environment variables # like NPM_CONFIG_REGISTRY so npm publish ends up ignoring the .npmrc file # which is set up by `setup-node` action. shell: bash - run: npx nx affected --base=last-release --target=version - - - name: Tag last-release - shell: bash - run: git tag -f last-release - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GH_TOKEN }} - branch: ${{ github.ref }} - force: true - tags: true + run: npx nx release publish diff --git a/jest.preset.js b/jest.preset.js index f078ddcec..92a790c53 100644 --- a/jest.preset.js +++ b/jest.preset.js @@ -1,3 +1,8 @@ const nxPreset = require('@nx/jest/preset').default; -module.exports = { ...nxPreset }; +module.exports = { + ...nxPreset, + maxWorkers: 1, + testEnvironment: 'node', + setupFiles: ['../../tools/scripts/unit-test-setup.js'], +}; diff --git a/nx.json b/nx.json index a7abe38df..547abc809 100644 --- a/nx.json +++ b/nx.json @@ -62,6 +62,12 @@ "devTargetName": "dev", "startTargetName": "start" } + }, + { + "plugin": "@nx/jest/plugin", + "options": { + "targetName": "test" + } } ], "generators": { @@ -72,5 +78,26 @@ } } }, - "nxCloudAccessToken": "OWEyN2E2OTktMWM2Ni00MmQwLWE1YmEtNjI2MDMwNDg1MWVjfHJlYWQtd3JpdGU=" + "nxCloudAccessToken": "OWEyN2E2OTktMWM2Ni00MmQwLWE1YmEtNjI2MDMwNDg1MWVjfHJlYWQtd3JpdGU=", + "release": { + "releaseTagPattern": "v{version}", + "projects": ["nx-cloudflare"], + "projectsRelationship": "independent", + "version": { + "conventionalCommits": true, + "generatorOptions": { + "updateDependents": true + } + }, + "git": { + "commit": true, + "commitArgs": "--no-verify" + }, + "changelog": { + "automaticFromRef": true, + "projectChangelogs": { + "createRelease": "github" + } + } + } } diff --git a/package.json b/package.json index 2c949c13f..d6a982072 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,12 @@ "devDependencies": { "@angular-devkit/core": "~17.3.7", "@cloudflare/next-on-pages": "^1.12.0", + "@cloudflare/vitest-pool-workers": "^0.4.7", "@cloudflare/workers-types": "^4.20240512.0", "@commitlint/cli": "^17.8.1", "@commitlint/config-conventional": "^17.8.1", "@eslint/eslintrc": "^2.1.2", "@eslint/js": "^8.52.0", - "@jscutlery/semver": "^5.2.0", "@nx/angular": "19.3.2", "@nx/devkit": "19.3.2", "@nx/esbuild": "19.3.2", @@ -62,7 +62,6 @@ "jest-environment-jsdom": "^29.4.1", "jest-environment-node": "^29.4.1", "kill-port": "^2.0.1", - "ngx-deploy-npm": "^7.1.0", "nx": "19.3.2", "nx-cloud": "19.0.0", "prettier": "^2.6.2", diff --git a/packages/e2e-utils/jest.config.ts b/packages/e2e-utils/jest.config.ts deleted file mode 100644 index 438ab5306..000000000 --- a/packages/e2e-utils/jest.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'e2e-utils', - preset: '../../jest.preset.js', - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/packages/e2e-utils', -}; diff --git a/packages/e2e-utils/project.json b/packages/e2e-utils/project.json index b84d7252d..a56553407 100644 --- a/packages/e2e-utils/project.json +++ b/packages/e2e-utils/project.json @@ -4,13 +4,5 @@ "sourceRoot": "packages/e2e-utils/src", "projectType": "library", "tags": [], - "targets": { - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "packages/e2e-utils/jest.config.ts" - } - } - } + "targets": {} } diff --git a/packages/nx-cloudflare-e2e/project.json b/packages/nx-cloudflare-e2e/project.json index ebf4522d9..2c5f5f50d 100644 --- a/packages/nx-cloudflare-e2e/project.json +++ b/packages/nx-cloudflare-e2e/project.json @@ -5,6 +5,9 @@ "sourceRoot": "packages/nx-cloudflare-e2e/src", "implicitDependencies": ["nx-cloudflare"], "targets": { + "test": { + "command": "echo 'Use e2e instead'" + }, "e2e": { "executor": "@nx/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], diff --git a/packages/nx-cloudflare/CHANGELOG.md b/packages/nx-cloudflare/CHANGELOG.md index 85d20444d..9c391c8a1 100644 --- a/packages/nx-cloudflare/CHANGELOG.md +++ b/packages/nx-cloudflare/CHANGELOG.md @@ -1,56 +1,45 @@ -# Changelog - -This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). - ## [3.0.0](https://github.com/naxodev/oss/compare/v2.2.0...v3.0.0) (2024-05-18) - ### ⚠ BREAKING CHANGES -* upgrade to nx 19 (#46) +- upgrade to nx 19 (#46) ### Features -* upgrade to nx 19 ([#46](https://github.com/naxodev/oss/issues/46)) ([da51f24](https://github.com/naxodev/oss/commit/da51f24498aa8762d3bbb35f7726ed1eb0a3193c)) +- upgrade to nx 19 ([#46](https://github.com/naxodev/oss/issues/46)) ([da51f24](https://github.com/naxodev/oss/commit/da51f24498aa8762d3bbb35f7726ed1eb0a3193c)) ## [2.2.0](https://github.com/naxodev/oss/compare/v2.1.0...v2.2.0) (2024-04-21) - ### Features -* update packages ([#44](https://github.com/naxodev/oss/issues/44)) ([bb71b17](https://github.com/naxodev/oss/commit/bb71b1738625b7bccf8bc68e93659b73f91e9828)) - +- update packages ([#44](https://github.com/naxodev/oss/issues/44)) ([bb71b17](https://github.com/naxodev/oss/commit/bb71b1738625b7bccf8bc68e93659b73f91e9828)) ### Bug Fixes -* compatibility warning on deploy ([#43](https://github.com/naxodev/oss/issues/43)) ([4ff171c](https://github.com/naxodev/oss/commit/4ff171c82f5d3edaaa5582894ec410aa10b3bfce)) +- compatibility warning on deploy ([#43](https://github.com/naxodev/oss/issues/43)) ([4ff171c](https://github.com/naxodev/oss/commit/4ff171c82f5d3edaaa5582894ec410aa10b3bfce)) ## [2.1.0](https://github.com/naxodev/oss/compare/v2.0.1...v2.1.0) (2024-04-12) - ### Features -* install vitest using crystal ([#41](https://github.com/naxodev/oss/issues/41)) ([72b6a97](https://github.com/naxodev/oss/commit/72b6a97d904950cccc856edef4de050f93e7a595)) +- install vitest using crystal ([#41](https://github.com/naxodev/oss/issues/41)) ([72b6a97](https://github.com/naxodev/oss/commit/72b6a97d904950cccc856edef4de050f93e7a595)) ## [2.0.1](https://github.com/naxodev/oss/compare/v2.0.0...v2.0.1) (2024-03-04) - ### Bug Fixes -* nx-cloudflare Readme ([72f8e27](https://github.com/naxodev/oss/commit/72f8e2768e8c69f1de734fdef4e9b5f589107694)) +- nx-cloudflare Readme ([72f8e27](https://github.com/naxodev/oss/commit/72f8e2768e8c69f1de734fdef4e9b5f589107694)) ## [2.0.0](https://github.com/naxodev/oss/compare/v1.0.2...v2.0.0) (2024-03-02) - ### ⚠ BREAKING CHANGES -* upgrade to nx 18 (#33) +- upgrade to nx 18 (#33) ### Bug Fixes -* release pipeline ([#34](https://github.com/naxodev/oss/issues/34)) ([50b3d3a](https://github.com/naxodev/oss/commit/50b3d3ad484df16202c44b257ee3fd4a2542c013)) - +- release pipeline ([#34](https://github.com/naxodev/oss/issues/34)) ([50b3d3a](https://github.com/naxodev/oss/commit/50b3d3ad484df16202c44b257ee3fd4a2542c013)) ### Miscellaneous Chores -* upgrade to nx 18 ([#33](https://github.com/naxodev/oss/issues/33)) ([2a3b3ef](https://github.com/naxodev/oss/commit/2a3b3ef1646989aa721aa38337b74aa1f8a5dd32)) +- upgrade to nx 18 ([#33](https://github.com/naxodev/oss/issues/33)) ([2a3b3ef](https://github.com/naxodev/oss/commit/2a3b3ef1646989aa721aa38337b74aa1f8a5dd32)) diff --git a/packages/nx-cloudflare/README.md b/packages/nx-cloudflare/README.md index bdfb15e80..cf291db93 100644 --- a/packages/nx-cloudflare/README.md +++ b/packages/nx-cloudflare/README.md @@ -155,22 +155,22 @@ nx g @naxodev/nx-cloudflare:library my-worker-lib Available options: -| Option | Type | Default | Description | -| ------------------------ | ------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| name | string | \*required | What name would you like to use? | -| directory | string | null | The directory of the new application. | -| projectNameAndRootFormat | as-provided, derived | as-provided | Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`). | -| linter | eslint, none | eslint | The tool to use for running lint checks. | -| unitTestRunner | vitest, none | vitest | Test runner to use for unit tests. | -| tags | string | null | Add tags to the application (used for linting). | -| skipFormat | boolean | false | Skip formatting files. | -| js | boolean | false | Use JavaScript instead of TypeScript | -| strict | boolean | true | Whether to enable tsconfig strict mode or not. | -| publishable | boolean | false | Generate a publishable library. | -| importPath | string | null | The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library. | -| bundler | swc, tsc, rollup, vite, esbuild, none | tsc | Which bundler would you like to use to build the library? Choose 'none' to skip build setup. | -| minimal | boolean | false | Generate a library with a minimal setup. No README.md generated. | -| simpleName | boolean | false | Don't include the directory in the generated file name. | +| Option | Type | Default | Description | +| ------------------------ | ----------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| name | string | \*required | What name would you like to use? | +| directory | string | null | The directory of the new application. | +| projectNameAndRootFormat | as-provided, derived | as-provided | Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`). | +| linter | eslint, none | eslint | The tool to use for running lint checks. | +| unitTestRunner | vitest, none | vitest | Test runner to use for unit tests. | +| tags | string | null | Add tags to the application (used for linting). | +| skipFormat | boolean | false | Skip formatting files. | +| js | boolean | false | Use JavaScript instead of TypeScript | +| strict | boolean | true | Whether to enable tsconfig strict mode or not. | +| publishable | boolean | false | Generate a publishable library. | +| importPath | string | null | The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library. | +| bundler | swc, tsc, vite, esbuild, none | tsc | Which bundler would you like to use to build the library? Choose 'none' to skip build setup. | +| minimal | boolean | false | Generate a library with a minimal setup. No README.md generated. | +| simpleName | boolean | false | Don't include the directory in the generated file name. | ### NextJS on Cloudflare diff --git a/packages/nx-cloudflare/package.json b/packages/nx-cloudflare/package.json index 880c600a8..a26fa8e50 100644 --- a/packages/nx-cloudflare/package.json +++ b/packages/nx-cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "@naxodev/nx-cloudflare", - "version": "3.0.0", + "version": "3.0.1", "description": "Nx plugin for Cloudflare", "homepage": "https://github.com/naxodev/oss/tree/main/packages/nx-cloudflare", "repository": { diff --git a/packages/nx-cloudflare/project.json b/packages/nx-cloudflare/project.json index a87cdb24b..b018389c4 100644 --- a/packages/nx-cloudflare/project.json +++ b/packages/nx-cloudflare/project.json @@ -36,37 +36,6 @@ } ] } - }, - "version": { - "dependsOn": ["build"], - "executor": "@jscutlery/semver:version", - "options": { - "preset": "conventional", - "tagPrefix": "v", - "noVerify": true, - "push": true, - "preid": "beta", - "syncVersions": false, - "commitMessageFormat": "release(${projectName}): 🎸 cut release to ${version}", - "postTargets": ["nx-cloudflare:github", "nx-cloudflare:npm-publish"] - } - }, - "github": { - "executor": "@jscutlery/semver:github", - "options": { - "tag": "${tag}", - "notes": "${notes}" - } - }, - "npm-publish": { - "executor": "ngx-deploy-npm:deploy", - "options": { - "access": "public" - } - }, - "publish": { - "command": "node tools/scripts/publish.mjs nx-cloudflare {args.ver} {args.tag}", - "dependsOn": ["build"] } } } diff --git a/packages/nx-cloudflare/src/generators/application/files/common/wrangler.toml__tmpl__ b/packages/nx-cloudflare/src/generators/application/files/common/wrangler.toml__tmpl__ index 1cd78a1b3..7442711eb 100644 --- a/packages/nx-cloudflare/src/generators/application/files/common/wrangler.toml__tmpl__ +++ b/packages/nx-cloudflare/src/generators/application/files/common/wrangler.toml__tmpl__ @@ -1,5 +1,6 @@ name = "<%=name %>" -compatibility_date = "2024-04-19" +compatibility_date = "2024-01-01" +compatibility_flags = ["nodejs_compat"] main = "src/index.<%=extension %>" <%-accountId %> diff --git a/packages/nx-cloudflare/src/generators/application/files/fetch-handler/index.integration.test.ts__tmpl__ b/packages/nx-cloudflare/src/generators/application/files/fetch-handler/index.integration.test.ts__tmpl__ new file mode 100644 index 000000000..1c07a54ff --- /dev/null +++ b/packages/nx-cloudflare/src/generators/application/files/fetch-handler/index.integration.test.ts__tmpl__ @@ -0,0 +1,9 @@ +import { SELF } from "cloudflare:test"; +<%-vitestImports %> +import "../src"; + +// an integration test using SELF +it("sends request (integration style)", async () => { + const response = await SELF.fetch("http://example.com"); + expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); +}); diff --git a/packages/nx-cloudflare/src/generators/application/files/fetch-handler/index.test.ts__tmpl__ b/packages/nx-cloudflare/src/generators/application/files/fetch-handler/index.test.ts__tmpl__ index da5a81e50..7a3de2d32 100644 --- a/packages/nx-cloudflare/src/generators/application/files/fetch-handler/index.test.ts__tmpl__ +++ b/packages/nx-cloudflare/src/generators/application/files/fetch-handler/index.test.ts__tmpl__ @@ -1,25 +1,13 @@ -import { unstable_dev } from 'wrangler'; -import type { UnstableDevWorker } from 'wrangler'; +import { env, createExecutionContext, waitOnExecutionContext, } from "cloudflare:test"; +import { worker } from './src' <%-vitestImports %> describe('Worker', () => { - let worker: UnstableDevWorker; - - beforeAll(async () => { - worker = await unstable_dev('src/index.ts', { - experimental: { disableExperimentalWarning: true }, - }); - }); - - afterAll(async () => { - await worker.stop(); - }); - it('should return Hello World', async () => { - const resp = await worker.fetch(); - if (resp) { - const text = await resp.text(); - expect(text).toMatchInlineSnapshot(`"Hello World!"`); - } + const request = new Request("http://example.com/"); + const ctx = createExecutionContext(); + const response = await worker.fetch(request, env, ctx); + await waitOnExecutionContext(ctx); + expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); }); }); diff --git a/packages/nx-cloudflare/src/generators/application/files/scheduled-handler/index.integration.test.ts__tmpl__ b/packages/nx-cloudflare/src/generators/application/files/scheduled-handler/index.integration.test.ts__tmpl__ new file mode 100644 index 000000000..592f1607d --- /dev/null +++ b/packages/nx-cloudflare/src/generators/application/files/scheduled-handler/index.integration.test.ts__tmpl__ @@ -0,0 +1,10 @@ + +import { SELF } from "cloudflare:test"; +<%-vitestImports %> +import "../src"; + +// an integration test using SELF +it("sends request (integration style)", async () => { + const response = await SELF.fetch("http://example.com"); + expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); +}); diff --git a/packages/nx-cloudflare/src/generators/application/files/scheduled-handler/index.test.ts__tmpl__ b/packages/nx-cloudflare/src/generators/application/files/scheduled-handler/index.test.ts__tmpl__ index da5a81e50..7a3de2d32 100644 --- a/packages/nx-cloudflare/src/generators/application/files/scheduled-handler/index.test.ts__tmpl__ +++ b/packages/nx-cloudflare/src/generators/application/files/scheduled-handler/index.test.ts__tmpl__ @@ -1,25 +1,13 @@ -import { unstable_dev } from 'wrangler'; -import type { UnstableDevWorker } from 'wrangler'; +import { env, createExecutionContext, waitOnExecutionContext, } from "cloudflare:test"; +import { worker } from './src' <%-vitestImports %> describe('Worker', () => { - let worker: UnstableDevWorker; - - beforeAll(async () => { - worker = await unstable_dev('src/index.ts', { - experimental: { disableExperimentalWarning: true }, - }); - }); - - afterAll(async () => { - await worker.stop(); - }); - it('should return Hello World', async () => { - const resp = await worker.fetch(); - if (resp) { - const text = await resp.text(); - expect(text).toMatchInlineSnapshot(`"Hello World!"`); - } + const request = new Request("http://example.com/"); + const ctx = createExecutionContext(); + const response = await worker.fetch(request, env, ctx); + await waitOnExecutionContext(ctx); + expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); }); }); diff --git a/packages/nx-cloudflare/src/generators/application/generator.spec.ts b/packages/nx-cloudflare/src/generators/application/generator.spec.ts index a82a59187..4b0ef848c 100644 --- a/packages/nx-cloudflare/src/generators/application/generator.spec.ts +++ b/packages/nx-cloudflare/src/generators/application/generator.spec.ts @@ -23,10 +23,12 @@ describe('app', () => { it('should update project config', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', port: 3001, }); - const project = readProjectConfiguration(tree, 'my-worker-app'); - expect(project.root).toEqual('my-worker-app'); + const project = readProjectConfiguration(tree, 'myWorkerApp'); + expect(project.root).toEqual('myWorkerApp'); expect(project.targets).toEqual( expect.objectContaining({ serve: { @@ -47,11 +49,13 @@ describe('app', () => { it('should update tags', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', tags: 'one,two', }); const projects = Object.fromEntries(getProjects(tree)); expect(projects).toMatchObject({ - 'my-worker-app': { + myWorkerApp: { tags: ['one', 'two'], }, }); @@ -60,11 +64,16 @@ describe('app', () => { it('should generate files', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', }); - expect(tree.exists('my-worker-app/src/index.ts')).toBeTruthy(); - expect(tree.exists('my-worker-app/src/index.test.ts')).toBeTruthy(); + expect(tree.exists('myWorkerApp/src/index.ts')).toBeTruthy(); + expect(tree.exists('myWorkerApp/src/index.test.ts')).toBeTruthy(); + expect( + tree.exists('myWorkerApp/src/index.integration.test.ts') + ).toBeTruthy(); - const tsconfig = readJson(tree, 'my-worker-app/tsconfig.json'); + const tsconfig = readJson(tree, 'myWorkerApp/tsconfig.json'); expect(tsconfig).toMatchInlineSnapshot(` { "compilerOptions": { @@ -77,11 +86,14 @@ describe('app', () => { { "path": "./tsconfig.app.json", }, + { + "path": "./tsconfig.spec.json", + }, ], } `); - const tsconfigApp = readJson(tree, 'my-worker-app/tsconfig.app.json'); + const tsconfigApp = readJson(tree, 'myWorkerApp/tsconfig.app.json'); expect(tsconfigApp.compilerOptions.outDir).toEqual('../dist/out-tsc'); expect(tsconfigApp.compilerOptions.target).toEqual('es2021'); expect(tsconfigApp.extends).toEqual('./tsconfig.json'); @@ -90,7 +102,7 @@ describe('app', () => { 'src/**/*.spec.ts', 'src/**/*.test.ts', ]); - const eslintrc = readJson(tree, 'my-worker-app/.eslintrc.json'); + const eslintrc = readJson(tree, 'myWorkerApp/.eslintrc.json'); expect(eslintrc).toMatchInlineSnapshot(` { "extends": [ @@ -131,29 +143,28 @@ describe('app', () => { it('should not generate files when template is none', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', template: 'none', }); - expect(tree.exists('my-worker-app/src/index.ts')).toBeFalsy(); - expect(tree.exists('my-worker-app/src/index.test.ts')).toBeFalsy(); + expect(tree.exists('myWorkerApp/src/index.ts')).toBeFalsy(); + expect(tree.exists('myWorkerApp/src/index.test.ts')).toBeFalsy(); + expect( + tree.exists('myWorkerApp/src/index.integration.test.ts') + ).toBeFalsy(); }); - // TODO: Uncomment when Jest support is added back - // it('should not generate import vitest when testRunner is jest', async () => { - // await applicationGenerator(tree, { - // name: 'myWorkerApp', - // unitTestRunner: 'jest', - // }); - // expect( - // tree.read(`my-worker-app/src/index.test.ts`, 'utf-8') - // ).not.toContain('vitest'); - // }); - it('should not have test files if the unitTestRunner is none', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', unitTestRunner: 'none', }); - expect(tree.exists(`my-worker-app/src/index.test.ts`)).toBeFalsy(); + expect(tree.exists(`myWorkerApp/src/index.test.ts`)).toBeFalsy(); + expect( + tree.exists(`myWorkerApp/src/index.integration.test.ts`) + ).toBeFalsy(); }); it('should extend from root tsconfig.json when no tsconfig.base.json', async () => { @@ -161,54 +172,98 @@ describe('app', () => { await applicationGenerator(tree, { name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', }); - const tsconfig = readJson(tree, 'my-worker-app/tsconfig.json'); + const tsconfig = readJson(tree, 'myWorkerApp/tsconfig.json'); expect(tsconfig.extends).toBe('../tsconfig.json'); }); it('should create the common configuration files', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', }); - expect(tree.exists('my-worker-app/.gitignore')).toBeTruthy(); - expect(tree.exists('my-worker-app/package.json')).toBeTruthy(); - expect(tree.read('my-worker-app/wrangler.toml', 'utf-8')) + expect(tree.exists('myWorkerApp/.gitignore')).toBeTruthy(); + expect(tree.exists('myWorkerApp/package.json')).toBeTruthy(); + expect(tree.read('myWorkerApp/wrangler.toml', 'utf-8')) .toMatchInlineSnapshot(` - "name = "my-worker-app" - compatibility_date = "2023-07-31" + "name = "myWorkerApp" + compatibility_date = "2024-01-01" + compatibility_flags = ["nodejs_compat"] main = "src/index.ts" " `); }); + + it('should generate a modified vite config file to allow the poolOptions when vitest is the test runner', async () => { + await applicationGenerator(tree, { + name: 'myWorkerApp', + directory: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + }); + expect(tree.read('myWorkerApp/vite.config.ts', 'utf-8')) + .toMatchInlineSnapshot(` + "import { defineConfig } from 'vite'; + + import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; + + export default defineConfig({ + root: __dirname, + cacheDir: '../node_modules/.vite/myWorkerApp', + + plugins: [nxViteTsPaths()], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + test: { + watch: false, + globals: true, + cache: { dir: '../node_modules/.vitest/myWorkerApp' }, + environment: 'node', + include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], + reporters: ['default'], + coverage: { reportsDirectory: '../coverage/myWorkerApp', provider: 'v8' }, + }, + }); + " + `); + }); }); describe('nested', () => { it('should update project config', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', - directory: 'myDir', + projectNameAndRootFormat: 'as-provided', + directory: 'myDir/myWorkerApp', }); - const project = readProjectConfiguration(tree, 'my-dir-my-worker-app'); + const project = readProjectConfiguration(tree, 'myWorkerApp'); - expect(project.root).toEqual('my-dir/my-worker-app'); + expect(project.root).toEqual('myDir/myWorkerApp'); - expect(() => - readProjectConfiguration(tree, 'my-dir-my-worker-app-e2e') - ).toThrow(/Cannot find/); + expect(() => readProjectConfiguration(tree, 'myWorkerApp-e2e')).toThrow( + /Cannot find/ + ); }); it('should update tags', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', - directory: 'myDir', + projectNameAndRootFormat: 'as-provided', + directory: 'myDir/myWorkerApp', tags: 'one,two', }); const projects = Object.fromEntries(getProjects(tree)); expect(projects).toMatchObject({ - 'my-dir-my-worker-app': { + myWorkerApp: { tags: ['one', 'two'], }, }); @@ -223,13 +278,15 @@ describe('app', () => { await applicationGenerator(tree, { name: 'myWorkerApp', - directory: 'myDir', + projectNameAndRootFormat: 'as-provided', + directory: 'myDir/myWorkerApp', }); // Make sure these exist [ - 'my-dir/my-worker-app/src/index.ts', - 'my-dir/my-worker-app/src/index.test.ts', + 'myDir/myWorkerApp/src/index.ts', + 'myDir/myWorkerApp/src/index.test.ts', + 'myDir/myWorkerApp/src/index.integration.test.ts', ].forEach((path) => { expect(tree.exists(path)).toBeTruthy(); }); @@ -237,22 +294,26 @@ describe('app', () => { // Make sure these have properties [ { - path: 'my-dir/my-worker-app/tsconfig.app.json', + path: 'myDir/myWorkerApp/tsconfig.app.json', lookupFn: (json) => json.compilerOptions.outDir, expectedValue: '../../dist/out-tsc', }, { - path: 'my-dir/my-worker-app/tsconfig.app.json', + path: 'myDir/myWorkerApp/tsconfig.app.json', lookupFn: (json) => json.compilerOptions.target, expectedValue: 'es2021', }, { - path: 'my-dir/my-worker-app/tsconfig.app.json', + path: 'myDir/myWorkerApp/tsconfig.app.json', lookupFn: (json) => json.compilerOptions.types, - expectedValue: ['node', '@cloudflare/workers-types'], + expectedValue: [ + 'node', + '@cloudflare/workers-types/experimental', + '@cloudflare/vitest-pool-workers', + ], }, { - path: 'my-dir/my-worker-app/tsconfig.app.json', + path: 'myDir/myWorkerApp/tsconfig.app.json', lookupFn: (json) => json.exclude, expectedValue: [ 'jest.config.ts', @@ -261,7 +322,7 @@ describe('app', () => { ], }, { - path: 'my-dir/my-worker-app/.eslintrc.json', + path: 'myDir/myWorkerApp/.eslintrc.json', lookupFn: (json) => json.extends, expectedValue: ['../../.eslintrc.json'], }, @@ -273,117 +334,44 @@ describe('app', () => { it('should not generate test configuration', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + directory: 'myWorkerApp', unitTestRunner: 'none', }); expect(tree.exists('jest.config.ts')).toBeFalsy(); - expect(tree.exists('my-worker-app/src/test-setup.ts')).toBeFalsy(); - expect(tree.exists('my-worker-app/src/test.ts')).toBeFalsy(); - expect(tree.exists('my-worker-app/tsconfig.spec.json')).toBeFalsy(); - expect(tree.exists('my-worker-app/jest.config.ts')).toBeFalsy(); - const project = readProjectConfiguration(tree, 'my-worker-app'); + expect(tree.exists('myWorkerApp/src/test-setup.ts')).toBeFalsy(); + expect(tree.exists('myWorkerApp/src/test.ts')).toBeFalsy(); + expect(tree.exists('myWorkerApp/tsconfig.spec.json')).toBeFalsy(); + expect(tree.exists('myWorkerApp/jest.config.ts')).toBeFalsy(); + expect(tree.exists('myWorkerApp/vite.config.ts')).toBeFalsy(); + const project = readProjectConfiguration(tree, 'myWorkerApp'); expect(project.targets.test).toBeUndefined(); - const packageJSON = devkit.readJson(tree, 'my-worker-app/package.json'); - expect(packageJSON.scripts.test).toBeUndefined(); expect(project.targets.lint).toMatchInlineSnapshot(`undefined`); }); }); - // describe('--frontendProject', () => { - // it('should configure proxy', async () => { - // await angularApplicationGenerator(tree, { name: 'my-frontend' }); - // - // await applicationGenerator(tree, { - // name: 'myWorkerApp', - // frontendProject: 'my-frontend', - // }); - // - // expect(tree.exists('my-frontend/proxy.conf.json')).toBeTruthy(); - // const project = readProjectConfiguration(tree, 'my-frontend'); - // const serve = project.targets.serve; - // expect(serve.options.proxyConfig).toEqual('my-frontend/proxy.conf.json'); - // }); - // - // it('should configure proxies for multiple node projects with the same frontend app', async () => { - // await angularApplicationGenerator(tree, { name: 'my-frontend' }); - // - // await applicationGenerator(tree, { - // name: 'cart', - // frontendProject: 'my-frontend', - // }); - // - // await applicationGenerator(tree, { - // name: 'billing', - // frontendProject: 'my-frontend', - // }); - // - // expect(tree.exists('my-frontend/proxy.conf.json')).toBeTruthy(); - // - // expect(readJson(tree, 'my-frontend/proxy.conf.json')).toEqual({ - // '/api': { target: 'http://localhost:3000', secure: false }, - // '/billing-api': { target: 'http://localhost:3000', secure: false }, - // }); - // }); - // - // it('should work with unnormalized project names', async () => { - // await angularApplicationGenerator(tree, { name: 'myFrontend' }); - // - // await applicationGenerator(tree, { - // name: 'myWorkerApp', - // frontendProject: 'myFrontend', - // }); - // - // expect(tree.exists('my-frontend/proxy.conf.json')).toBeTruthy(); - // const project = readProjectConfiguration(tree, 'my-frontend'); - // const serve = project.targets.serve; - // expect(serve.options.proxyConfig).toEqual('my-frontend/proxy.conf.json'); - // }); - // }); - - // TODO: Uncomment when jest support is added back - // describe('--swcJest', () => { - // it('should use @swc/jest for jest', async () => { - // await applicationGenerator(tree, { - // name: 'myWorkerApp', - // tags: 'one,two', - // swcJest: true, - // unitTestRunner: 'jest', - // } as Schema); - // - // expect(tree.read(`my-worker-app/jest.config.ts`, 'utf-8')) - // .toMatchInlineSnapshot(` - // "/* eslint-disable */ - // export default { - // displayName: 'my-worker-app', - // preset: '../jest.preset.js', - // testEnvironment: 'node', - // transform: { - // '^.+\\\\.[tj]s$': '@swc/jest', - // }, - // moduleFileExtensions: ['ts', 'js', 'html'], - // coverageDirectory: '../coverage/my-worker-app', - // }; - // " - // `); - // }); - // }); - describe('--js flag', () => { it('should generate js files instead of ts files', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + directory: 'myWorkerApp', js: true, } as Schema); - expect(tree.exists('my-worker-app/src/index.js')).toBeTruthy(); - expect(tree.exists('my-worker-app/src/index.test.js')).toBeTruthy(); + expect(tree.exists('myWorkerApp/src/index.js')).toBeTruthy(); + expect(tree.exists('myWorkerApp/src/index.test.js')).toBeTruthy(); + expect( + tree.exists('myWorkerApp/src/index.integration.test.js') + ).toBeTruthy(); - const tsConfig = readJson(tree, 'my-worker-app/tsconfig.json'); + const tsConfig = readJson(tree, 'myWorkerApp/tsconfig.json'); expect(tsConfig.compilerOptions).toEqual({ allowJs: true, esModuleInterop: true, }); - const tsConfigApp = readJson(tree, 'my-worker-app/tsconfig.app.json'); + const tsConfigApp = readJson(tree, 'myWorkerApp/tsconfig.app.json'); expect(tsConfigApp.include).toEqual(['src/**/*.ts', 'src/**/*.js']); expect(tsConfigApp.exclude).toEqual([ 'jest.config.ts', @@ -397,9 +385,11 @@ describe('app', () => { it('should add project config', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + directory: 'myWorkerApp', js: true, } as Schema); - const project = readProjectConfiguration(tree, 'my-worker-app'); + const project = readProjectConfiguration(tree, 'myWorkerApp'); const buildTarget = project.targets.build; const serveTarget = project.targets.serve; @@ -410,26 +400,31 @@ describe('app', () => { it('should generate js files for nested libs as well', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', - directory: 'myDir', + projectNameAndRootFormat: 'as-provided', + directory: 'myDir/myWorkerApp', js: true, } as Schema); - expect(tree.exists('my-dir/my-worker-app/src/index.js')).toBeTruthy(); + expect(tree.exists('myDir/myWorkerApp/src/index.js')).toBeTruthy(); + expect(tree.exists('myDir/myWorkerApp/src/index.test.js')).toBeTruthy(); expect( - tree.exists('my-dir/my-worker-app/src/index.test.js') + tree.exists('myDir/myWorkerApp/src/index.integration.test.js') ).toBeTruthy(); }); it('should create the common configuration files', async () => { await applicationGenerator(tree, { name: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + directory: 'myWorkerApp', js: true, }); - expect(tree.exists('my-worker-app/.gitignore')).toBeTruthy(); - expect(tree.exists('my-worker-app/package.json')).toBeTruthy(); - expect(tree.read('my-worker-app/wrangler.toml', 'utf-8')) + expect(tree.exists('myWorkerApp/.gitignore')).toBeTruthy(); + expect(tree.exists('myWorkerApp/package.json')).toBeTruthy(); + expect(tree.read('myWorkerApp/wrangler.toml', 'utf-8')) .toMatchInlineSnapshot(` - "name = "my-worker-app" - compatibility_date = "2023-07-31" + "name = "myWorkerApp" + compatibility_date = "2024-01-01" + compatibility_flags = ["nodejs_compat"] main = "src/index.js" @@ -441,13 +436,16 @@ describe('app', () => { const accountId = 'fake40q5pchj988766d696c1ajek9mcd'; await applicationGenerator(tree, { name: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + directory: 'myWorkerApp', js: true, accountId, }); - expect(tree.read('my-worker-app/wrangler.toml', 'utf-8')) + expect(tree.read('myWorkerApp/wrangler.toml', 'utf-8')) .toMatchInlineSnapshot(` - "name = "my-worker-app" - compatibility_date = "2023-07-31" + "name = "myWorkerApp" + compatibility_date = "2024-01-01" + compatibility_flags = ["nodejs_compat"] main = "src/index.js" account_id = "fake40q5pchj988766d696c1ajek9mcd" @@ -456,20 +454,15 @@ describe('app', () => { }); }); - describe('--pascalCaseFiles', () => { - it(`should notify that this flag doesn't do anything`, async () => { - await applicationGenerator(tree, { - name: 'myWorkerApp', - pascalCaseFiles: true, - } as Schema); - }); - }); - describe('--skipFormat', () => { it('should format files by default', async () => { jest.spyOn(devkit, 'formatFiles'); - await applicationGenerator(tree, { name: 'myWorkerApp' }); + await applicationGenerator(tree, { + name: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + directory: 'myWorkerApp', + }); expect(devkit.formatFiles).toHaveBeenCalled(); }); @@ -479,6 +472,8 @@ describe('app', () => { await applicationGenerator(tree, { name: 'myWorkerApp', + projectNameAndRootFormat: 'as-provided', + directory: 'myWorkerApp', skipFormat: true, }); @@ -495,13 +490,16 @@ describe('app', () => { it('should generate the correct snippet of code', async () => { await applicationGenerator(tree, { name: 'api', + projectNameAndRootFormat: 'as-provided', + directory: 'api', template, + unitTestRunner: 'none', }); const project = readProjectConfiguration(tree, 'api'); expect(project.targets.test).toBeUndefined(); const packageJSON = devkit.readJson(tree, 'api/package.json'); - expect(packageJSON.scripts.test).toBeDefined(); + expect(packageJSON.name).toEqual('api'); if (checkFile) { expect(tree.exists(`api/src/index.ts`)).toBeTruthy(); diff --git a/packages/nx-cloudflare/src/generators/application/generator.ts b/packages/nx-cloudflare/src/generators/application/generator.ts index 610b39d0c..80719492a 100644 --- a/packages/nx-cloudflare/src/generators/application/generator.ts +++ b/packages/nx-cloudflare/src/generators/application/generator.ts @@ -4,7 +4,6 @@ import { formatFiles, generateFiles, GeneratorCallback, - names, readProjectConfiguration, runTasksInSerial, toJS, @@ -18,7 +17,6 @@ import { join } from 'path'; import initGenerator from '../init/generator'; import { vitestImports } from './utils/vitest-imports'; import { getAccountId } from './utils/get-account-id'; -import { vitestScript } from './utils/vitest-script'; import { determineProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils'; import { nxVersion } from '@nx/node/src/utils/versions'; @@ -58,6 +56,11 @@ export async function applicationGenerator(tree: Tree, schema: Schema) { coverageProvider: 'v8', skipFormat: true, testEnvironment: 'node', + poolOptions: { + workers: { + wrangler: { configPath: './wrangler.toml' }, + }, + }, }); tasks.push(vitestTask); createOrEditViteConfig( @@ -115,7 +118,8 @@ function updateTsAppConfig(tree: Tree, options: NormalizedSchema) { }; json.compilerOptions.types = [ ...json.compilerOptions.types, - '@cloudflare/workers-types', + '@cloudflare/workers-types/experimental', + '@cloudflare/vitest-pool-workers', ]; return json; } @@ -140,7 +144,6 @@ function addCloudflareFiles(tree: Tree, options: NormalizedSchema) { name: options.name, extension: options.js ? 'js' : 'ts', accountId: options.accountId ? getAccountId(options.accountId) : '', - vitestScript: options.unitTestRunner === 'vitest' ? vitestScript : '', } ); @@ -196,6 +199,7 @@ function addTargets(tree: Tree, options: NormalizedSchema) { function removeTestFiles(tree: Tree, options: NormalizedSchema) { tree.delete(join(options.appProjectRoot, 'src', 'index.test.ts')); + tree.delete(join(options.appProjectRoot, 'src', 'index.integration.test.ts')); } // Transform the options to the normalized schema. Loads defaults options. @@ -221,11 +225,10 @@ async function normalizeOptions( return { addPlugin: process.env.NX_ADD_PLUGINS !== 'false', ...options, - name: names(appProjectName).fileName, - frontendProject: options.frontendProject - ? names(options.frontendProject).fileName - : undefined, + name: appProjectName, + frontendProject: options.frontendProject, appProjectRoot, + projectNameAndRootFormat: options.projectNameAndRootFormat ?? 'as-provided', unitTestRunner: options.unitTestRunner ?? 'vitest', rootProject: options.rootProject ?? false, template: options.template ?? 'fetch-handler', diff --git a/packages/nx-cloudflare/src/generators/application/utils/vitest-script.ts b/packages/nx-cloudflare/src/generators/application/utils/vitest-script.ts deleted file mode 100644 index 854749129..000000000 --- a/packages/nx-cloudflare/src/generators/application/utils/vitest-script.ts +++ /dev/null @@ -1 +0,0 @@ -export const vitestScript = `"test": "vitest run"`; diff --git a/packages/nx-cloudflare/src/generators/init/generator.spec.ts b/packages/nx-cloudflare/src/generators/init/generator.spec.ts index 77a5a13f1..f40fb88f0 100644 --- a/packages/nx-cloudflare/src/generators/init/generator.spec.ts +++ b/packages/nx-cloudflare/src/generators/init/generator.spec.ts @@ -40,9 +40,15 @@ describe('init', () => { expect( packageJson.dependencies['@cloudflare/workers-types'] ).toBeUndefined(); + expect( + packageJson.dependencies['@cloudflare/vitest-pool-workers'] + ).toBeUndefined(); expect( packageJson.devDependencies['@cloudflare/workers-types'] ).toBeDefined(); + expect( + packageJson.devDependencies['@cloudflare/vitest-pool-workers'] + ).toBeDefined(); // keep existing packages expect(packageJson.devDependencies[existing]).toBeDefined(); expect(packageJson.dependencies[existing]).toBeDefined(); diff --git a/packages/nx-cloudflare/src/generators/init/generator.ts b/packages/nx-cloudflare/src/generators/init/generator.ts index e88e14500..64f4723ad 100644 --- a/packages/nx-cloudflare/src/generators/init/generator.ts +++ b/packages/nx-cloudflare/src/generators/init/generator.ts @@ -12,6 +12,7 @@ import { cloudflareWorkersTypeVersions, honoVersion, nxCloudflareVersion, + vitestPoolWorkersVersion, wranglerVersion, } from '../../utils/versions'; @@ -46,6 +47,7 @@ function updateDependencies(tree: Tree, schema: InitGeneratorSchema) { { wrangler: wranglerVersion, '@cloudflare/workers-types': cloudflareWorkersTypeVersions, + '@cloudflare/vitest-pool-workers': vitestPoolWorkersVersion, '@naxodev/nx-cloudflare': nxCloudflareVersion, } ); diff --git a/packages/nx-cloudflare/src/generators/library/__snapshots__/generator.spec.ts.snap b/packages/nx-cloudflare/src/generators/library/__snapshots__/generator.spec.ts.snap index d6c10fa65..b4a1d35b2 100644 --- a/packages/nx-cloudflare/src/generators/library/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-cloudflare/src/generators/library/__snapshots__/generator.spec.ts.snap @@ -15,8 +15,7 @@ export default defineConfig({ nxViteTsPaths(), dts({ entryRoot: 'src', - tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), - skipDiagnostics: true, + tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'), }), ], @@ -29,6 +28,7 @@ export default defineConfig({ // See: https://vitejs.dev/guide/build.html#library-mode build: { outDir: '../dist/my-lib', + emptyOutDir: true, reportCompressedSize: true, commonjsOptions: { transformMixedEsModules: true, @@ -49,9 +49,10 @@ export default defineConfig({ }, test: { + watch: false, globals: true, cache: { - dir: '../node_modules/.vitest', + dir: '../node_modules/.vitest/my-lib', }, environment: 'jsdom', include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], @@ -87,7 +88,12 @@ exports[`lib --bundler=vite should add build and test targets with vite and vite "compilerOptions": { "outDir": "../dist/out-tsc", "declaration": true, - "types": ["node", "vite/client", "@cloudflare/workers-types"] + "types": [ + "node", + "vite/client", + "@cloudflare/workers-types/experimental", + "@cloudflare/vitest-pool-workers" + ] }, "include": ["src/**/*.ts"], "exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] diff --git a/packages/nx-cloudflare/src/generators/library/generator.spec.ts b/packages/nx-cloudflare/src/generators/library/generator.spec.ts index 1fae0c8d0..f66d0ad89 100644 --- a/packages/nx-cloudflare/src/generators/library/generator.spec.ts +++ b/packages/nx-cloudflare/src/generators/library/generator.spec.ts @@ -17,7 +17,6 @@ describe('lib', () => { skipFormat: false, linter: 'eslint', js: false, - pascalCaseFiles: false, strict: true, config: 'project', }; @@ -39,7 +38,7 @@ describe('lib', () => { expect(readJson(tree, '/my-lib/package.json')).toEqual({ name: '@proj/my-lib', version: '0.0.1', - type: 'commonjs', + private: true, scripts: { build: "echo 'implement build'", test: "echo 'implement test'", @@ -433,29 +432,6 @@ describe('lib', () => { expect(tsconfigJson.compilerOptions.paths['@acme/core']).toBeDefined(); }); }); - - describe('--pascalCaseFiles', () => { - it('should generate files with upper case names', async () => { - await libraryGenerator(tree, { - ...defaultOptions, - name: 'my-lib', - pascalCaseFiles: true, - projectNameAndRootFormat: 'as-provided', - }); - expect(tree.exists('my-lib/src/lib/MyLib.ts')).toBeTruthy(); - }); - - it('should generate files with upper case names for nested libs as well', async () => { - await libraryGenerator(tree, { - ...defaultOptions, - name: 'my-lib', - directory: 'my-dir/my-lib', - pascalCaseFiles: true, - projectNameAndRootFormat: 'as-provided', - }); - expect(tree.exists('my-dir/my-lib/src/lib/MyLib.ts')).toBeTruthy(); - }); - }); }); describe('--linter', () => { @@ -765,35 +741,6 @@ describe('lib', () => { }); }); - describe('--bundler=rollup', () => { - it('should add build with rollup', async () => { - await libraryGenerator(tree, { - ...defaultOptions, - name: 'my-lib', - bundler: 'rollup', - unitTestRunner: 'none', - projectNameAndRootFormat: 'as-provided', - }); - - const project = readProjectConfiguration(tree, 'my-lib'); - expect(project.targets.build).toMatchObject({ - executor: '@nx/rollup:rollup', - }); - expect(readJson(tree, 'my-lib/.eslintrc.json').overrides).toContainEqual({ - files: ['*.json'], - parser: 'jsonc-eslint-parser', - rules: { - '@nx/dependency-checks': [ - 'error', - { - ignoredFiles: ['{projectRoot}/rollup.config.{js,ts,mjs,mts}'], - }, - ], - }, - }); - }); - }); - describe('--minimal', () => { it('should generate a README.md when minimal is set to false', async () => { await libraryGenerator(tree, { diff --git a/packages/nx-cloudflare/src/generators/library/generator.ts b/packages/nx-cloudflare/src/generators/library/generator.ts index c98a1da7d..0d8133b35 100644 --- a/packages/nx-cloudflare/src/generators/library/generator.ts +++ b/packages/nx-cloudflare/src/generators/library/generator.ts @@ -96,7 +96,8 @@ function updateTsLibConfig(tree: Tree, options: NormalizedSchema) { (json) => { json.compilerOptions.types = [ ...json.compilerOptions.types, - '@cloudflare/workers-types', + '@cloudflare/workers-types/experimental', + '@cloudflare/vitest-pool-workers', ]; return json; } diff --git a/packages/nx-cloudflare/src/generators/library/schema.d.ts b/packages/nx-cloudflare/src/generators/library/schema.d.ts index f80f41ded..34a9a786e 100644 --- a/packages/nx-cloudflare/src/generators/library/schema.d.ts +++ b/packages/nx-cloudflare/src/generators/library/schema.d.ts @@ -8,7 +8,6 @@ export interface NxCloudflareLibraryGeneratorSchema { skipFormat?: boolean; skipPackageJson?: boolean; skipTsConfig?: boolean; - pascalCaseFiles?: boolean; js?: boolean; strict?: boolean; publishable?: boolean; diff --git a/packages/nx-cloudflare/src/generators/library/schema.json b/packages/nx-cloudflare/src/generators/library/schema.json index a8c993147..c62bfb6da 100644 --- a/packages/nx-cloudflare/src/generators/library/schema.json +++ b/packages/nx-cloudflare/src/generators/library/schema.json @@ -59,12 +59,6 @@ "default": false, "x-priority": "internal" }, - "pascalCaseFiles": { - "type": "boolean", - "description": "Use pascal case file names.", - "alias": "P", - "default": false - }, "js": { "type": "boolean", "description": "Generate JavaScript files rather than TypeScript files.", @@ -101,7 +95,7 @@ "bundler": { "description": "The bundler to use. Choosing 'none' means this library is not buildable.", "type": "string", - "enum": ["swc", "tsc", "rollup", "vite", "esbuild", "none"], + "enum": ["swc", "tsc", "vite", "esbuild", "none"], "default": "tsc", "x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.", "x-priority": "important" diff --git a/packages/nx-cloudflare/src/utils/versions.ts b/packages/nx-cloudflare/src/utils/versions.ts index 26f98f177..cdd9a00e5 100644 --- a/packages/nx-cloudflare/src/utils/versions.ts +++ b/packages/nx-cloudflare/src/utils/versions.ts @@ -4,3 +4,4 @@ export const nxCloudflareVersion = require('../../package.json').version; export const wranglerVersion = '^3.62.0'; export const cloudflareWorkersTypeVersions = '^4.20240512.0'; export const honoVersion = '^4.4.9'; +export const vitestPoolWorkersVersion = '^0.4.7'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e39bada2..657b66f3a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,6 +33,9 @@ importers: '@cloudflare/next-on-pages': specifier: ^1.12.0 version: 1.12.0(@cloudflare/workers-types@4.20240512.0)(vercel@34.2.0(@swc/core@1.5.7(@swc/helpers@0.5.11)))(wrangler@3.62.0(@cloudflare/workers-types@4.20240512.0)) + '@cloudflare/vitest-pool-workers': + specifier: ^0.4.7 + version: 0.4.7(@cloudflare/workers-types@4.20240512.0)(@vitest/runner@1.6.0)(@vitest/snapshot@1.6.0)(vitest@1.6.0(@edge-runtime/vm@3.2.0)(@types/node@20.12.12)(@vitest/ui@1.6.0)(jsdom@20.0.3)(less@4.1.3)(sass@1.77.2)(stylus@0.59.0)(terser@5.29.1)) '@cloudflare/workers-types': specifier: ^4.20240512.0 version: 4.20240512.0 @@ -48,9 +51,6 @@ importers: '@eslint/js': specifier: ^8.52.0 version: 8.57.0 - '@jscutlery/semver': - specifier: ^5.2.0 - version: 5.2.2(@nx/devkit@19.3.2(nx@19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11)))) '@nx/angular': specifier: 19.3.2 version: 19.3.2(@angular-devkit/build-angular@17.3.7(@angular/compiler-cli@17.3.9(@angular/compiler@17.3.9)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11))(@types/express@4.17.21)(@types/node@20.12.12)(chokidar@3.6.0)(jest-environment-jsdom@29.7.0)(jest@29.7.0(@types/node@20.12.12)(ts-node@10.9.1(@swc/core@1.5.7(@swc/helpers@0.5.11))(@types/node@20.12.12)(typescript@5.4.4)))(stylus@0.59.0)(typescript@5.4.4))(@angular-devkit/core@17.3.7(chokidar@3.6.0))(@angular-devkit/schematics@17.3.7(chokidar@3.6.0))(@babel/traverse@7.24.5)(@schematics/angular@17.3.7(chokidar@3.6.0))(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11))(@types/node@20.12.12)(@zkochan/js-yaml@0.0.7)(esbuild@0.19.12)(eslint@8.57.0)(nx@19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11)))(rxjs@7.8.1)(typescript@5.4.4)(verdaccio@5.31.0(typanion@3.14.0)) @@ -198,9 +198,6 @@ importers: kill-port: specifier: ^2.0.1 version: 2.0.1 - ngx-deploy-npm: - specifier: ^7.1.0 - version: 7.1.0(@nx/devkit@19.3.2(nx@19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11))))(tslib@2.6.2) nx: specifier: 19.3.2 version: 19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11)) @@ -1064,6 +1061,13 @@ packages: '@cloudflare/workers-types': optional: true + '@cloudflare/vitest-pool-workers@0.4.7': + resolution: {integrity: sha512-fX/qCPsQgi4w2xXpuCtz8LjvcANVC6KYpPDFO6UyhJ4q5F9VhN14CNesS8S8VWARzt8Q5rfVg9JlBysR3/8YQg==} + peerDependencies: + '@vitest/runner': 1.3.x - 1.5.x + '@vitest/snapshot': 1.3.x - 1.5.x + vitest: 1.3.x - 1.5.x + '@cloudflare/workerd-darwin-64@1.20240512.0': resolution: {integrity: sha512-VMp+CsSHFALQiBzPdQ5dDI4T1qwLu0mQ0aeKVNDosXjueN0f3zj/lf+mFil5/9jBbG3t4mG0y+6MMnalP9Lobw==} engines: {node: '>=16'} @@ -1691,10 +1695,6 @@ packages: '@humanwhocodes/object-schema@2.0.3': resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} - '@hutson/parse-repository-url@5.0.0': - resolution: {integrity: sha512-e5+YUKENATs1JgYHMzTr2MW/NDcXGfYFAuOQU8gJgF/kEh4EqKgfGrfLI67bMD4tbhZVlkigz/9YYwWcbOFthg==} - engines: {node: '>=10.13.0'} - '@istanbuljs/load-nyc-config@1.1.0': resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} engines: {node: '>=8'} @@ -1793,11 +1793,6 @@ packages: '@jridgewell/trace-mapping@0.3.9': resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} - '@jscutlery/semver@5.2.2': - resolution: {integrity: sha512-lhklWnwa5X4N6aiBLbybdsZ37agtxa0EBRdXmjOFA+LzViVR6QIYZpk+/X/XLw/TB6z1rLrmFp/MakmNyaJiYg==} - peerDependencies: - '@nx/devkit': ^18.0.0 - '@leichtgewicht/ip-codec@2.0.5': resolution: {integrity: sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==} @@ -3011,9 +3006,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - add-stream@1.0.0: - resolution: {integrity: sha512-qQLMr+8o0WC4FZGQTcJiKBVC59JylcPSrTtk6usvmIDFUOCKegapy1VHQwRbFMOFyb/inzUVqHs+eMYKDM1YeQ==} - address@1.2.2: resolution: {integrity: sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==} engines: {node: '>= 10.0.0'} @@ -3377,6 +3369,9 @@ packages: bindings@1.5.0: resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} + birpc@0.2.14: + resolution: {integrity: sha512-37FHE8rqsYM5JEKCnXFyHpBCzvgHEExwVVTq+nUmloInU7l8ezD1TpOhKpS8oe1DTYFqEK27rFZVKG43oTqXRA==} + bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} @@ -3557,10 +3552,6 @@ packages: resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==} engines: {node: '>=6'} - cli-width@3.0.0: - resolution: {integrity: sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==} - engines: {node: '>= 10'} - cli-width@4.1.0: resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==} engines: {node: '>= 12'} @@ -3697,82 +3688,15 @@ packages: resolution: {integrity: sha512-6qLgrBF4gueoC7AFVHu51nHL9pF9FRjXrH+ceVf7WmAfH3gs+gEYOkvxhjMPjZu57I4AGUGoNTY8V7Hrgf1uqg==} engines: {node: '>=14'} - conventional-changelog-angular@7.0.0: - resolution: {integrity: sha512-ROjNchA9LgfNMTTFSIWPzebCwOGFdgkEq45EnvvrmSLvCtAw0HSmrCs7/ty+wAeYUZyNay0YMUNYFTRL72PkBQ==} - engines: {node: '>=16'} - - conventional-changelog-atom@4.0.0: - resolution: {integrity: sha512-q2YtiN7rnT1TGwPTwjjBSIPIzDJCRE+XAUahWxnh+buKK99Kks4WLMHoexw38GXx9OUxAsrp44f9qXe5VEMYhw==} - engines: {node: '>=16'} - - conventional-changelog-codemirror@4.0.0: - resolution: {integrity: sha512-hQSojc/5imn1GJK3A75m9hEZZhc3urojA5gMpnar4JHmgLnuM3CUIARPpEk86glEKr3c54Po3WV/vCaO/U8g3Q==} - engines: {node: '>=16'} - conventional-changelog-conventionalcommits@6.1.0: resolution: {integrity: sha512-3cS3GEtR78zTfMzk0AizXKKIdN4OvSh7ibNz6/DPbhWWQu7LqE/8+/GqSodV+sywUR2gpJAdP/1JFf4XtN7Zpw==} engines: {node: '>=14'} - conventional-changelog-conventionalcommits@7.0.2: - resolution: {integrity: sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w==} - engines: {node: '>=16'} - - conventional-changelog-core@7.0.0: - resolution: {integrity: sha512-UYgaB1F/COt7VFjlYKVE/9tTzfU3VUq47r6iWf6lM5T7TlOxr0thI63ojQueRLIpVbrtHK4Ffw+yQGduw2Bhdg==} - engines: {node: '>=16'} - - conventional-changelog-ember@4.0.0: - resolution: {integrity: sha512-D0IMhwcJUg1Y8FSry6XAplEJcljkHVlvAZddhhsdbL1rbsqRsMfGx/PIkPYq0ru5aDgn+OxhQ5N5yR7P9mfsvA==} - engines: {node: '>=16'} - - conventional-changelog-eslint@5.0.0: - resolution: {integrity: sha512-6JtLWqAQIeJLn/OzUlYmzd9fKeNSWmQVim9kql+v4GrZwLx807kAJl3IJVc3jTYfVKWLxhC3BGUxYiuVEcVjgA==} - engines: {node: '>=16'} - - conventional-changelog-express@4.0.0: - resolution: {integrity: sha512-yWyy5c7raP9v7aTvPAWzqrztACNO9+FEI1FSYh7UP7YT1AkWgv5UspUeB5v3Ibv4/o60zj2o9GF2tqKQ99lIsw==} - engines: {node: '>=16'} - - conventional-changelog-jquery@5.0.0: - resolution: {integrity: sha512-slLjlXLRNa/icMI3+uGLQbtrgEny3RgITeCxevJB+p05ExiTgHACP5p3XiMKzjBn80n+Rzr83XMYfRInEtCPPw==} - engines: {node: '>=16'} - - conventional-changelog-jshint@4.0.0: - resolution: {integrity: sha512-LyXq1bbl0yG0Ai1SbLxIk8ZxUOe3AjnlwE6sVRQmMgetBk+4gY9EO3d00zlEt8Y8gwsITytDnPORl8al7InTjg==} - engines: {node: '>=16'} - - conventional-changelog-preset-loader@4.1.0: - resolution: {integrity: sha512-HozQjJicZTuRhCRTq4rZbefaiCzRM2pr6u2NL3XhrmQm4RMnDXfESU6JKu/pnKwx5xtdkYfNCsbhN5exhiKGJA==} - engines: {node: '>=16'} - - conventional-changelog-writer@7.0.1: - resolution: {integrity: sha512-Uo+R9neH3r/foIvQ0MKcsXkX642hdm9odUp7TqgFS7BsalTcjzRlIfWZrZR1gbxOozKucaKt5KAbjW8J8xRSmA==} - engines: {node: '>=16'} - hasBin: true - - conventional-changelog@5.1.0: - resolution: {integrity: sha512-aWyE/P39wGYRPllcCEZDxTVEmhyLzTc9XA6z6rVfkuCD2UBnhV/sgSOKbQrEG5z9mEZJjnopjgQooTKxEg8mAg==} - engines: {node: '>=16'} - - conventional-commits-filter@4.0.0: - resolution: {integrity: sha512-rnpnibcSOdFcdclpFwWa+pPlZJhXE7l+XK04zxhbWrhgpR96h33QLz8hITTXbcYICxVr3HZFtbtUAQ+4LdBo9A==} - engines: {node: '>=16'} - conventional-commits-parser@4.0.0: resolution: {integrity: sha512-WRv5j1FsVM5FISJkoYMR6tPk07fkKT0UodruX4je86V4owk451yjXAKzKAPOs9l7y59E2viHUS9eQ+dfUA9NSg==} engines: {node: '>=14'} hasBin: true - conventional-commits-parser@5.0.0: - resolution: {integrity: sha512-ZPMl0ZJbw74iS9LuX9YIAiW8pfM5p3yh2o/NbXHbkFuZzY5jvdi5jFycEOkmBW5H5I7nA+D6f3UcsCLP2vvSEA==} - engines: {node: '>=16'} - hasBin: true - - conventional-recommended-bump@9.0.0: - resolution: {integrity: sha512-HR1yD0G5HgYAu6K0wJjLd7QGRK8MQDqqj6Tn1n/ja1dFwBCE6QmV+iSgQ5F7hkx7OUR/8bHpxJqYtXj2f/opPQ==} - engines: {node: '>=16'} - hasBin: true - convert-hrtime@3.0.0: resolution: {integrity: sha512-7V+KqSvMiHp8yWDuwfww06XleMWVVB9b9tURBx+G7UTADuo5hYPuowKloz4OzOqbPezxgo+fdQ1522WzPG4OeA==} engines: {node: '>=8'} @@ -4005,10 +3929,6 @@ packages: resolution: {integrity: sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==} engines: {node: '>=8'} - dargs@8.1.0: - resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} - engines: {node: '>=12'} - dashdash@1.14.1: resolution: {integrity: sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==} engines: {node: '>=0.10'} @@ -4164,10 +4084,6 @@ packages: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} - detect-indent@6.1.0: - resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} - engines: {node: '>=8'} - detect-libc@2.0.3: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} @@ -4184,6 +4100,9 @@ packages: engines: {node: '>= 4.0.0'} hasBin: true + devalue@4.3.3: + resolution: {integrity: sha512-UH8EL6H2ifcY8TbD2QsxwCC/pr5xSwPvv85LrLXVihmHVC3T3YqTCIwnR5ak0yO1KYqlxrPVOA/JVZJYPy2ATg==} + diff-sequences@29.6.3: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -5169,16 +5088,6 @@ packages: engines: {node: '>=10'} hasBin: true - git-raw-commits@4.0.0: - resolution: {integrity: sha512-ICsMM1Wk8xSGMowkOmPrzo2Fgmfo4bMHLNX6ytHjajRJUqvHOw/TFapQ+QG75c3X/tTDDhOSRPGC52dDbNM8FQ==} - engines: {node: '>=16'} - hasBin: true - - git-semver-tags@7.0.1: - resolution: {integrity: sha512-NY0ZHjJzyyNXHTDZmj+GG7PyuAKtMsyWSwh07CR2hOZFa+/yoTsXci/nF2obzL8UDhakFNkD9gNdt/Ed+cxh2Q==} - engines: {node: '>=16'} - hasBin: true - glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -5477,10 +5386,6 @@ packages: ini@1.3.8: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} - inquirer@8.2.6: - resolution: {integrity: sha512-M1WuAmb7pn9zdFRtQYk26ZBoY043Sse0wVDdk4Bppr+JOXyQYybdtvK+l9wUibhtjdjvtoiNy8tk+EgsYIUqKg==} - engines: {node: '>=12.0.0'} - inquirer@9.2.15: resolution: {integrity: sha512-vI2w4zl/mDluHt9YEQ/543VTCwPKWiHzKtm9dM2V0NdFcqEexDAjUHzO1oA60HRNaVifGXXM1tRRNluLVHa0Kg==} engines: {node: '>=18'} @@ -5648,10 +5553,6 @@ packages: resolution: {integrity: sha512-xFuJpne9oFz5qDaodwmmG08e3CawH/2ZV8Qqza1Ko7Sk8POWbkRdwIoAWVhqvq0XeUzANEhKo2n0IXUGBm7A/w==} engines: {node: '>=0.10.0'} - is-text-path@2.0.0: - resolution: {integrity: sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw==} - engines: {node: '>=8'} - is-typed-array@1.1.13: resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==} engines: {node: '>= 0.4'} @@ -5930,10 +5831,6 @@ packages: json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - json-parse-even-better-errors@3.0.2: - resolution: {integrity: sha512-fi0NG4bPjCHunUJffmLd0gxssIgkNmArMvis4iNah6Owg1MCJjWhEcDLmsK6iGkJq3tHwbDkTlce70/tmXN4cQ==} - engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - json-schema-to-ts@1.6.4: resolution: {integrity: sha512-pR4yQ9DHz6itqswtHCm26mw45FSNfQ9rEQjosaZErhn5J3J2sIViQiz8rDaezjKAhFGpmsoczYVBgGHzFw/stA==} @@ -6266,10 +6163,6 @@ packages: resolution: {integrity: sha512-UERzLsxzllchadvbPs5aolHh65ISpKpM+ccLbOJ8/vvpBKmAWf+la7dXFy7Mr0ySHbdHrFv5kGFCUHHe6GFEmw==} engines: {node: '>= 4.0.0'} - meow@12.1.1: - resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} - engines: {node: '>=16.10'} - meow@8.1.2: resolution: {integrity: sha512-r85E3NdZ+mpYk1C6RjPFEMSE+s1iZMuHtsHAqY0DT3jZczl0diWUZ8g6oU7h0M9cD2EL+PzaYghhCLzR0ZNn5Q==} engines: {node: '>=10'} @@ -6449,9 +6342,6 @@ packages: resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==} hasBin: true - mute-stream@0.0.8: - resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} - mute-stream@1.0.0: resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -6505,13 +6395,6 @@ packages: sass: optional: true - ngx-deploy-npm@7.1.0: - resolution: {integrity: sha512-zUv/C9giRVrhmOu3dIG3tjjN+1/bOV5xQzPGgXBZL74M5dgZo+/Dui1JxrVCZH9m8QogR4Zg+0Xq6FeXo2xKrg==} - engines: {node: '>=18.0.0'} - peerDependencies: - '@nx/devkit': "^16.0.0 ||\_^17.0.0 ||\_^18.0.0" - tslib: ^2.3.0 - nice-napi@1.0.2: resolution: {integrity: sha512-px/KnJAJZf5RuBGcfD+Sp2pAKq0ytz8j+1NehvgIGFkvtvFrDM3T8E4x/JJODXK9WZow8RRGrbA9QQ3hs+pDhA==} os: ['!win32'] @@ -6584,10 +6467,6 @@ packages: resolution: {integrity: sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==} engines: {node: '>=10'} - normalize-package-data@6.0.1: - resolution: {integrity: sha512-6rvCfeRW+OEZagAB4lMLSNuTNYZWLVtKccK79VSTf//yTY5VOCgcpH80O+bZK8Neps7pUnd5G+QlMg1yV/2iZQ==} - engines: {node: ^16.14.0 || >=18.0.0} - normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -6800,10 +6679,6 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} - parse-json@7.1.1: - resolution: {integrity: sha512-SgOTCX/EZXtZxBE5eJ97P4yGM5n37BwRU+YMsH4vNzFqJV/oWFXXCmwFlgWUM4PrakybVOueJJ6pwHqSVhTFDw==} - engines: {node: '>=16'} - parse-ms@2.1.0: resolution: {integrity: sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA==} engines: {node: '>=6'} @@ -7358,10 +7233,6 @@ packages: read-cache@1.0.0: resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==} - read-pkg-up@10.1.0: - resolution: {integrity: sha512-aNtBq4jR8NawpKJQldrQcSW9y/d+KWH4v24HWkHljOZ7H0av+YTGANBzRh9A5pw7v/bLVsLVPpOhJ7gHNVy8lA==} - engines: {node: '>=16'} - read-pkg-up@7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -7370,10 +7241,6 @@ packages: resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} engines: {node: '>=8'} - read-pkg@8.1.0: - resolution: {integrity: sha512-PORM8AgzXeskHO/WEv312k9U03B8K9JSiWF/8N9sUuFjBa+9SF2u6K7VClzXwDXab51jCd8Nd36CNM+zR97ScQ==} - engines: {node: '>=16'} - readable-stream@2.3.8: resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} @@ -7538,10 +7405,6 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true - run-async@2.4.1: - resolution: {integrity: sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==} - engines: {node: '>=0.12.0'} - run-async@3.0.0: resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==} engines: {node: '>=0.12.0'} @@ -8120,10 +7983,6 @@ packages: resolution: {integrity: sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==} engines: {node: '>=0.10'} - text-extensions@2.4.0: - resolution: {integrity: sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g==} - engines: {node: '>=8'} - text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} @@ -8323,14 +8182,6 @@ packages: resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} engines: {node: '>=8'} - type-fest@3.13.1: - resolution: {integrity: sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==} - engines: {node: '>=14.16'} - - type-fest@4.18.2: - resolution: {integrity: sha512-+suCYpfJLAe4OXS6+PPXjW3urOS4IoP9waSiLuXfLgqZODKw/aWwASvzqE886wA0kQgGy0mIWyhd87VpqIy6Xg==} - engines: {node: '>=16'} - type-is@1.6.18: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} engines: {node: '>= 0.6'} @@ -10562,6 +10413,25 @@ snapshots: - supports-color - utf-8-validate + '@cloudflare/vitest-pool-workers@0.4.7(@cloudflare/workers-types@4.20240512.0)(@vitest/runner@1.6.0)(@vitest/snapshot@1.6.0)(vitest@1.6.0(@edge-runtime/vm@3.2.0)(@types/node@20.12.12)(@vitest/ui@1.6.0)(jsdom@20.0.3)(less@4.1.3)(sass@1.77.2)(stylus@0.59.0)(terser@5.29.1))': + dependencies: + '@vitest/runner': 1.6.0 + '@vitest/snapshot': 1.6.0 + birpc: 0.2.14 + cjs-module-lexer: 1.3.1 + devalue: 4.3.3 + esbuild: 0.17.19 + miniflare: 3.20240620.0 + semver: 7.6.2 + vitest: 1.6.0(@edge-runtime/vm@3.2.0)(@types/node@20.12.12)(@vitest/ui@1.6.0)(jsdom@20.0.3)(less@4.1.3)(sass@1.77.2)(stylus@0.59.0)(terser@5.29.1) + wrangler: 3.62.0(@cloudflare/workers-types@4.20240512.0) + zod: 3.23.8 + transitivePeerDependencies: + - '@cloudflare/workers-types' + - bufferutil + - supports-color + - utf-8-validate + '@cloudflare/workerd-darwin-64@1.20240512.0': optional: true @@ -11006,8 +10876,6 @@ snapshots: '@humanwhocodes/object-schema@2.0.3': {} - '@hutson/parse-repository-url@5.0.0': {} - '@istanbuljs/load-nyc-config@1.1.0': dependencies: camelcase: 5.3.1 @@ -11207,27 +11075,6 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 - '@jscutlery/semver@5.2.2(@nx/devkit@19.3.2(nx@19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11))))': - dependencies: - '@nx/devkit': 19.3.2(nx@19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11))) - chalk: 4.1.2 - conventional-changelog: 5.1.0 - conventional-changelog-angular: 7.0.0 - conventional-changelog-atom: 4.0.0 - conventional-changelog-codemirror: 4.0.0 - conventional-changelog-conventionalcommits: 7.0.2 - conventional-changelog-ember: 4.0.0 - conventional-changelog-eslint: 5.0.0 - conventional-changelog-express: 4.0.0 - conventional-changelog-jquery: 5.0.0 - conventional-changelog-jshint: 4.0.0 - conventional-commits-parser: 5.0.0 - conventional-recommended-bump: 9.0.0 - detect-indent: 6.1.0 - git-semver-tags: 7.0.1 - inquirer: 8.2.6 - rxjs: 7.8.1 - '@leichtgewicht/ip-codec@2.0.5': {} '@ljharb/through@2.3.13': @@ -13332,8 +13179,6 @@ snapshots: acorn@8.11.3: {} - add-stream@1.0.0: {} - address@1.2.2: {} adjust-sourcemap-loader@4.0.0: @@ -13788,6 +13633,8 @@ snapshots: dependencies: file-uri-to-path: 1.0.0 + birpc@0.2.14: {} + bl@4.1.0: dependencies: buffer: 5.7.1 @@ -14001,8 +13848,6 @@ snapshots: cli-spinners@2.9.2: {} - cli-width@3.0.0: {} - cli-width@4.1.0: {} client-only@0.0.1: {} @@ -14119,74 +13964,10 @@ snapshots: dependencies: compare-func: 2.0.0 - conventional-changelog-angular@7.0.0: - dependencies: - compare-func: 2.0.0 - - conventional-changelog-atom@4.0.0: {} - - conventional-changelog-codemirror@4.0.0: {} - conventional-changelog-conventionalcommits@6.1.0: dependencies: compare-func: 2.0.0 - conventional-changelog-conventionalcommits@7.0.2: - dependencies: - compare-func: 2.0.0 - - conventional-changelog-core@7.0.0: - dependencies: - '@hutson/parse-repository-url': 5.0.0 - add-stream: 1.0.0 - conventional-changelog-writer: 7.0.1 - conventional-commits-parser: 5.0.0 - git-raw-commits: 4.0.0 - git-semver-tags: 7.0.1 - hosted-git-info: 7.0.2 - normalize-package-data: 6.0.1 - read-pkg: 8.1.0 - read-pkg-up: 10.1.0 - - conventional-changelog-ember@4.0.0: {} - - conventional-changelog-eslint@5.0.0: {} - - conventional-changelog-express@4.0.0: {} - - conventional-changelog-jquery@5.0.0: {} - - conventional-changelog-jshint@4.0.0: - dependencies: - compare-func: 2.0.0 - - conventional-changelog-preset-loader@4.1.0: {} - - conventional-changelog-writer@7.0.1: - dependencies: - conventional-commits-filter: 4.0.0 - handlebars: 4.7.8 - json-stringify-safe: 5.0.1 - meow: 12.1.1 - semver: 7.6.2 - split2: 4.2.0 - - conventional-changelog@5.1.0: - dependencies: - conventional-changelog-angular: 7.0.0 - conventional-changelog-atom: 4.0.0 - conventional-changelog-codemirror: 4.0.0 - conventional-changelog-conventionalcommits: 7.0.2 - conventional-changelog-core: 7.0.0 - conventional-changelog-ember: 4.0.0 - conventional-changelog-eslint: 5.0.0 - conventional-changelog-express: 4.0.0 - conventional-changelog-jquery: 5.0.0 - conventional-changelog-jshint: 4.0.0 - conventional-changelog-preset-loader: 4.1.0 - - conventional-commits-filter@4.0.0: {} - conventional-commits-parser@4.0.0: dependencies: JSONStream: 1.3.5 @@ -14194,22 +13975,6 @@ snapshots: meow: 8.1.2 split2: 3.2.2 - conventional-commits-parser@5.0.0: - dependencies: - JSONStream: 1.3.5 - is-text-path: 2.0.0 - meow: 12.1.1 - split2: 4.2.0 - - conventional-recommended-bump@9.0.0: - dependencies: - conventional-changelog-preset-loader: 4.1.0 - conventional-commits-filter: 4.0.0 - conventional-commits-parser: 5.0.0 - git-raw-commits: 4.0.0 - git-semver-tags: 7.0.1 - meow: 12.1.1 - convert-hrtime@3.0.0: {} convert-source-map@1.9.0: {} @@ -14479,8 +14244,6 @@ snapshots: dargs@7.0.0: {} - dargs@8.1.0: {} - dashdash@1.14.1: dependencies: assert-plus: 1.0.0 @@ -14596,8 +14359,6 @@ snapshots: destroy@1.2.0: {} - detect-indent@6.1.0: {} - detect-libc@2.0.3: {} detect-newline@3.1.0: {} @@ -14611,6 +14372,8 @@ snapshots: transitivePeerDependencies: - supports-color + devalue@4.3.3: {} + diff-sequences@29.6.3: {} diff@4.0.2: {} @@ -15857,17 +15620,6 @@ snapshots: split2: 3.2.2 through2: 4.0.2 - git-raw-commits@4.0.0: - dependencies: - dargs: 8.1.0 - meow: 12.1.1 - split2: 4.2.0 - - git-semver-tags@7.0.1: - dependencies: - meow: 12.1.1 - semver: 7.6.2 - glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -16221,24 +15973,6 @@ snapshots: ini@1.3.8: {} - inquirer@8.2.6: - dependencies: - ansi-escapes: 4.3.2 - chalk: 4.1.2 - cli-cursor: 3.1.0 - cli-width: 3.0.0 - external-editor: 3.1.0 - figures: 3.2.0 - lodash: 4.17.21 - mute-stream: 0.0.8 - ora: 5.4.1 - run-async: 2.4.1 - rxjs: 7.8.1 - string-width: 4.2.3 - strip-ansi: 6.0.1 - through: 2.3.8 - wrap-ansi: 6.2.0 - inquirer@9.2.15: dependencies: '@ljharb/through': 2.3.13 @@ -16384,10 +16118,6 @@ snapshots: dependencies: text-extensions: 1.9.0 - is-text-path@2.0.0: - dependencies: - text-extensions: 2.4.0 - is-typed-array@1.1.13: dependencies: which-typed-array: 1.1.15 @@ -16885,8 +16615,6 @@ snapshots: json-parse-even-better-errors@2.3.1: {} - json-parse-even-better-errors@3.0.2: {} - json-schema-to-ts@1.6.4: dependencies: '@types/json-schema': 7.0.15 @@ -17235,8 +16963,6 @@ snapshots: dependencies: fs-monkey: 1.0.6 - meow@12.1.1: {} - meow@8.1.2: dependencies: '@types/minimist': 1.2.5 @@ -17423,8 +17149,6 @@ snapshots: mustache@4.2.0: {} - mute-stream@0.0.8: {} - mute-stream@1.0.0: {} mv@2.1.1: @@ -17477,11 +17201,6 @@ snapshots: - '@babel/core' - babel-plugin-macros - ngx-deploy-npm@7.1.0(@nx/devkit@19.3.2(nx@19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11))))(tslib@2.6.2): - dependencies: - '@nx/devkit': 19.3.2(nx@19.3.2(@swc-node/register@1.9.2(@swc/core@1.5.7(@swc/helpers@0.5.11))(@swc/types@0.1.7)(typescript@5.4.4))(@swc/core@1.5.7(@swc/helpers@0.5.11))) - tslib: 2.6.2 - nice-napi@1.0.2: dependencies: node-addon-api: 3.2.1 @@ -17540,13 +17259,6 @@ snapshots: semver: 7.6.2 validate-npm-package-license: 3.0.4 - normalize-package-data@6.0.1: - dependencies: - hosted-git-info: 7.0.2 - is-core-module: 2.13.1 - semver: 7.6.2 - validate-npm-package-license: 3.0.4 - normalize-path@3.0.0: {} normalize-range@0.1.2: {} @@ -17829,14 +17541,6 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 - parse-json@7.1.1: - dependencies: - '@babel/code-frame': 7.24.2 - error-ex: 1.3.2 - json-parse-even-better-errors: 3.0.2 - lines-and-columns: 2.0.4 - type-fest: 3.13.1 - parse-ms@2.1.0: {} parse-node-version@1.0.1: {} @@ -18350,12 +18054,6 @@ snapshots: dependencies: pify: 2.3.0 - read-pkg-up@10.1.0: - dependencies: - find-up: 6.3.0 - read-pkg: 8.1.0 - type-fest: 4.18.2 - read-pkg-up@7.0.1: dependencies: find-up: 4.1.0 @@ -18369,13 +18067,6 @@ snapshots: parse-json: 5.2.0 type-fest: 0.6.0 - read-pkg@8.1.0: - dependencies: - '@types/normalize-package-data': 2.4.4 - normalize-package-data: 6.0.1 - parse-json: 7.1.1 - type-fest: 4.18.2 - readable-stream@2.3.8: dependencies: core-util-is: 1.0.3 @@ -18572,8 +18263,6 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.17.2 fsevents: 2.3.3 - run-async@2.4.1: {} - run-async@3.0.0: {} run-parallel@1.2.0: @@ -19207,8 +18896,6 @@ snapshots: text-extensions@1.9.0: {} - text-extensions@2.4.0: {} - text-table@0.2.0: {} thread-stream@0.15.2: @@ -19429,10 +19116,6 @@ snapshots: type-fest@0.8.1: {} - type-fest@3.13.1: {} - - type-fest@4.18.2: {} - type-is@1.6.18: dependencies: media-typer: 0.3.0 diff --git a/project.json b/project.json index c56720295..cf3938e56 100644 --- a/project.json +++ b/project.json @@ -2,6 +2,9 @@ "name": "@naxodev/oss", "$schema": "node_modules/nx/schemas/project-schema.json", "targets": { + "test": { + "command": "echo 'no test for root project'" + }, "local-registry": { "executor": "@nx/js:verdaccio", "options": { diff --git a/tools/scripts/start-local-registry.ts b/tools/scripts/start-local-registry.ts index 874369bcc..891fafff7 100644 --- a/tools/scripts/start-local-registry.ts +++ b/tools/scripts/start-local-registry.ts @@ -4,6 +4,7 @@ */ import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry'; import { execFileSync } from 'child_process'; +import { releasePublish, releaseVersion } from 'nx/release'; export default async () => { // local registry target to run @@ -16,10 +17,19 @@ export default async () => { storage, verbose: false, }); - const nx = require.resolve('nx'); - execFileSync( - nx, - ['run-many', '--targets', 'publish', '--ver', '0.0.0-e2e', '--tag', 'e2e'], - { env: process.env, stdio: 'inherit' } - ); + + await releaseVersion({ + specifier: '0.0.0-e2e', + stageChanges: false, + gitCommit: false, + gitTag: false, + firstRelease: true, + generatorOptionsOverrides: { + skipLockFileUpdate: true, + }, + }); + await releasePublish({ + tag: 'e2e', + firstRelease: true, + }); }; diff --git a/tools/scripts/unit-test-setup.js b/tools/scripts/unit-test-setup.js new file mode 100644 index 000000000..8436818b0 --- /dev/null +++ b/tools/scripts/unit-test-setup.js @@ -0,0 +1,34 @@ +module.exports = () => { + /** + * When the daemon is enabled during unit tests, + * and the daemon is already running, the daemon-client.ts + * code will be used, but it will hit the already running + * daemon which is from the installed version of Nx. + * + * In the vast majority of cases, this is fine. However, + * if a new message type has been added to the daemon in + * the source code, and isn't yet in the installed version, + * any test that hits that codepath will fail. This is because + * the installed version of the daemon doesn't know how to + * handle the new message type. + * + * To prevent this, we disable the daemon during unit tests. + */ + process.env.NX_DAEMON = 'false'; + + /** + * When `createProjectGraphAsync` is called during tests, + * if its not mocked, it will return the Nx repo's project + * graph. We don't want any unit tests to depend on the structure + * of the Nx repo, so we mock it to return an empty project graph. + */ + jest.doMock('@nx/devkit', () => ({ + ...jest.requireActual('@nx/devkit'), + createProjectGraphAsync: jest.fn().mockImplementation(async () => { + return { + nodes: {}, + dependencies: {}, + }; + }), + })); +};