Skip to content

Commit

Permalink
chore(nxext): update to Nx 19
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikPieper committed May 29, 2024
1 parent f5b8725 commit 6da0149
Show file tree
Hide file tree
Showing 68 changed files with 15,756 additions and 15,526 deletions.
98 changes: 0 additions & 98 deletions docs/docs/stencil/generators.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,104 +96,6 @@ Possible values: `jest`, `none`

Test runner to use for unit tests.

## @nxext/stencil:ionic-pwa

Generate Stencil ionic pwa

### Usage

```bash
nx generate ionic-pwa ...
```

```bash
nx g pwa ... # same
```

By default, Nx will search for `ionic-pwa` in the default collection provisioned in nx.json.

You can specify the collection explicitly as follows:

```bash
nx g @nxext/stencil:ionic-pwa ...
```

Show what will be generated without writing to disk:

```bash
nx g ionic-pwa ... --dry-run
```

### Options

#### name (_**required**_)

Type: `string`

#### directory

Alias(es): d

Type: `string`

A directory where the project is placed

#### e2eTestRunner

Default: `puppeteer`

Type: `string`

Possible values: `puppeteer`, `none`

Test runner to use for end to end (e2e) tests

#### linter

Default: `eslint`

Type: `string`

Possible values: `eslint`, `none`

The tool to use for running lint checks.

#### skipFormat

Default: `false`

Type: `boolean`

#### style

Alias(es): s

Default: `css`

Type: `string`

Possible values: `css`, `scss`, `styl`, `less`, `pcss`

The file extension to be used for style files.

#### tags

Alias(es): t

Type: `string`

Add tags to the project (used for linting)

#### unitTestRunner

Default: `jest`

Type: `string`

Possible values: `jest`, `none`

Test runner to use for unit tests.

## @nxext/stencil:library

Generate Stencil Library
Expand Down
12 changes: 0 additions & 12 deletions e2e/stencil-e2e/tests/application.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,4 @@ describe('application e2e', () => {
}).not.toThrow();
});
});

describe('pwa', () => {
it(`should build pwa app with scss`, async () => {
const plugin = uniq('pwa');
await runNxCommandAsync(
`generate @nxext/stencil:pwa ${plugin} --style='scss' --e2eTestRunner='none' --junitTestRunner='none'`
);

const result = await runNxCommandAsync(`build ${plugin} --dev`);
expect(result.stdout).toContain('build finished');
});
});
});
41 changes: 5 additions & 36 deletions migrations.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
{
"migrations": [
{
"version": "18.1.0-beta.3",
"description": "Moves affected.defaultBase to defaultBase in `nx.json`",
"implementation": "./src/migrations/update-17-2-0/move-default-base",
"package": "nx",
"name": "move-default-base-to-nx-json-root"
},
{
"cli": "nx",
"version": "18.1.0-beta.3",
"description": "Remove invalid baseUrl option from @nx/playwright:playwright targets in project.json.",
"implementation": "./src/migrations/update-18-1-0/remove-baseUrl-from-project-json",
"package": "@nx/playwright",
"name": "18-1-0-remove-baseUrl-from-project-json"
},
{
"cli": "nx",
"version": "18.1.0-beta.3",
"description": "Update to Cypress ^13.6.6 if the workspace is using Cypress v13 to ensure workspaces don't use v13.6.5 which has an issue when verifying Cypress.",
"implementation": "./src/migrations/update-18-1-0/update-cypress-version-13-6-6",
"package": "@nx/cypress",
"name": "update-cypress-version-13-6-6"
},
{
"cli": "nx",
"version": "18.1.1-beta.0",
"description": "Ensure targetDefaults inputs for task hashing when '@nx/webpack:webpack' is used are correct for Module Federation.",
"factory": "./src/migrations/update-18-1-1/fix-target-defaults-inputs",
"package": "@nx/react",
"name": "fix-target-defaults-for-webpack"
},
{
"cli": "nx",
"version": "18.1.1-beta.0",
"description": "Ensure targetDefaults inputs for task hashing when '@nx/angular:webpack-browser' is used are correct for Module Federation.",
"factory": "./src/migrations/update-18-1-1/fix-target-defaults-inputs",
"package": "@nx/angular",
"name": "fix-target-defaults-for-webpack-browser"
"version": "19.1.0-beta.6",
"description": "Migrate no-extra-semi rules into user config, out of nx extendable configs",
"implementation": "./src/migrations/update-19-1-0-migrate-no-extra-semi/migrate-no-extra-semi",
"package": "@nx/eslint-plugin",
"name": "update-19-1-0-rename-no-extra-semi"
}
]
}
35 changes: 17 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,34 @@
"prepare": "is-ci || husky install"
},
"private": true,
"packageManager": "pnpm@9.0.1+sha256.46d50ee2afecb42b185ebbd662dc7bdd52ef5be56bf035bb615cab81a75345df",
"devDependencies": {
"@angular-devkit/core": "16.0.0",
"@angular-devkit/schematics": "16.0.0",
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@eslint/eslintrc": "^2.1.1",
"@eslint/js": "8.49.0",
"@nx/angular": "18.2.4",
"@nx/cypress": "18.2.4",
"@nx/devkit": "18.2.4",
"@nx/eslint": "18.2.4",
"@nx/eslint-plugin": "18.2.4",
"@nx/jest": "18.2.4",
"@nx/js": "18.2.4",
"@nx/node": "18.2.4",
"@nx/playwright": "18.2.4",
"@nx/plugin": "18.2.4",
"@nx/react": "18.2.4",
"@nx/storybook": "18.2.4",
"@nx/vite": "18.2.4",
"@nx/web": "18.2.4",
"@nx/workspace": "18.2.4",
"@nx/angular": "19.1.0",
"@nx/cypress": "19.1.0",
"@nx/devkit": "19.1.0",
"@nx/eslint": "19.1.0",
"@nx/eslint-plugin": "19.1.0",
"@nx/jest": "19.1.0",
"@nx/js": "19.1.0",
"@nx/node": "19.1.0",
"@nx/playwright": "19.1.0",
"@nx/plugin": "19.1.0",
"@nx/react": "19.1.0",
"@nx/storybook": "19.1.0",
"@nx/vite": "19.1.0",
"@nx/web": "19.1.0",
"@nx/workspace": "19.1.0",
"@phenomnomnominal/tsquery": "~5.0.1",
"@preact/preset-vite": "^2.8.2",
"@schematics/angular": "16.0.0",
"@stencil/core": "4.12.6",
"@swc-node/register": "1.8.0",
"@swc/cli": "0.1.62",
"@swc/cli": "0.3.12",
"@swc/core": "1.3.91",
"@swc/helpers": "0.5.2",
"@swc/jest": "0.2.26",
Expand Down Expand Up @@ -107,7 +106,7 @@
"jsonc-parser": "^3.2.1",
"kill-port": "^2.0.1",
"lint-staged": "13.2.3",
"nx": "18.2.4",
"nx": "19.1.0",
"prettier": "2.7.1",
"pretty-quick": "^3.1.3",
"svelte": "^4.2.12",
Expand Down
7 changes: 1 addition & 6 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,5 @@
"bugs": {
"url": "https://github.com/nxext/nx-extensions/issues"
},
"dependencies": {
"tslib": "^2.3.0",
"@nx/devkit": "^18.0.8",
"typescript": "5.4.5",
"nx": "^18.0.8"
}
"dependencies": {}
}
2 changes: 1 addition & 1 deletion packages/common/src/lib/utils/ast-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ts from 'typescript';
import { findNodes } from 'nx/src/utils/typescript';
import { ChangeType, StringChange, Tree } from '@nx/devkit';
import { findNodes } from '@nx/js';

export function readTsSourceFile(host: Tree, path: string): ts.SourceFile {
if (!host.exists(path)) {
Expand Down
14 changes: 2 additions & 12 deletions packages/preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
},
"main": "src/index.js",
"generators": "./generators.json",
"peerDependencies": {
"@nx/jest": "^18.0.8",
"@nx/vite": "^18.0.8",
"@nx/cypress": "^18.0.8",
"typescript": "5.4.5",
"nx": "^18.0.8",
"@nx/eslint": "^18.0.8"
},
"dependencies": {
"tslib": "^2.3.0",
"@nx/devkit": "^18.0.8"
}
"peerDependencies": {},
"dependencies": {}
}
20 changes: 20 additions & 0 deletions packages/preact/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
offsetFromRoot,
Tree,
runTasksInSerial,
readNxJson,
} from '@nx/devkit';
import { NormalizedSchema, PreactApplicationSchema } from './schema';
import { addProject } from './lib/add-project';
Expand Down Expand Up @@ -35,11 +36,30 @@ function normalizeOptions(
? options.tags.split(',').map((s) => s.trim())
: [];

const nxJson = readNxJson(tree);

let e2eWebServerTarget = 'serve';
let e2ePort = 4200;
if (
nxJson.targetDefaults?.[e2eWebServerTarget] &&
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port
) {
e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
}

const e2eProjectName = `${name}-e2e`;
const e2eProjectRoot = `${projectRoot}-e2e`;
const e2eWebServerAddress = `http://localhost:${e2ePort}`;

return {
...options,
name: projectName,
projectRoot,
parsedTags,
e2eWebServerTarget,
e2eWebServerAddress,
e2eProjectName,
e2eProjectRoot,
fileName,
projectDirectory,
skipFormat: false,
Expand Down
55 changes: 47 additions & 8 deletions packages/preact/src/generators/application/lib/add-cypress.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,56 @@
import { Tree, ensurePackage, NX_VERSION } from '@nx/devkit';
import {
addProjectConfiguration,
ensurePackage,
joinPathFragments,
NX_VERSION,
Tree,
} from '@nx/devkit';
import { NormalizedSchema } from '../schema';

export async function addCypress(host: Tree, options: NormalizedSchema) {
export async function addCypress(tree: Tree, options: NormalizedSchema) {
if (options.e2eTestRunner !== 'cypress') {
// eslint-disable-next-line @typescript-eslint/no-empty-function
return () => {};
return () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
}
const { cypressProjectGenerator } = ensurePackage<

const { webStaticServeGenerator } = ensurePackage<typeof import('@nx/web')>(
'@nx/web',
NX_VERSION
);

await webStaticServeGenerator(tree, {
buildTarget: `${options.name}:build`,
targetName: 'serve-static',
spa: true,
});

const { configurationGenerator } = ensurePackage<
typeof import('@nx/cypress')
>('@nx/cypress', NX_VERSION);

return await cypressProjectGenerator(host, {
name: options.name + '-e2e',
project: options.name,
addProjectConfiguration(tree, options.e2eProjectName, {
projectType: 'application',
root: options.e2eProjectRoot,
sourceRoot: joinPathFragments(options.e2eProjectRoot, 'src'),
targets: {},
implicitDependencies: [options.name],
tags: [],
});

return await configurationGenerator(tree, {
...options,
project: options.e2eProjectName,
directory: 'src',
// the name and root are already normalized, instruct the generator to use them as is
bundler: 'webpack',
skipFormat: true,
devServerTarget: `${options.name}:${options.e2eWebServerTarget}`,
baseUrl: options.e2eWebServerAddress,
jsx: true,
rootProject: false,
webServerCommands: {
default: `nx run ${options.name}:${options.e2eWebServerTarget}`,
production: `nx run ${options.name}:preview`,
},
ciWebServerCommand: `nx run ${options.name}:serve-static`,
});
}
5 changes: 4 additions & 1 deletion packages/preact/src/generators/application/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Linter } from '@nx/eslint';
export interface PreactApplicationSchema {
name: string;
tags?: string;

linter: Linter;
unitTestRunner: 'vitest' | 'jest' | 'none';
e2eTestRunner: 'cypress' | 'none';
Expand All @@ -16,6 +15,10 @@ export interface NormalizedSchema extends PreactApplicationSchema {
projectRoot: string;
projectDirectory: string;
fileName: string;
e2eProjectName: string;
e2eProjectRoot: string;
e2eWebServerAddress: string;
e2eWebServerTarget: string;
parsedTags: string[];
skipFormat: boolean;
}
Loading

0 comments on commit 6da0149

Please sign in to comment.