Browse Source

Upgrade to Nx 16.1

pull/1929/head
Thomas 2 years ago
parent
commit
1668c7b7a8
  1. 11
      .eslintrc.json
  2. 7
      .storybook/main.js
  3. 4
      apps/api/project.json
  4. 2
      apps/client-e2e/project.json
  5. 2
      apps/client-e2e/src/plugins/index.js
  6. 2
      apps/client/project.json
  7. 9
      apps/client/src/app/core/auth.guard.ts
  8. 2
      apps/ui-e2e/project.json
  9. 2
      apps/ui-e2e/src/plugins/index.js
  10. 30
      decorate-angular-cli.js
  11. 2
      jest.config.ts
  12. 2
      jest.preset.js
  13. 2
      libs/common/.babelrc
  14. 2
      libs/common/project.json
  15. 4
      libs/ui/.eslintrc.json
  16. 2
      libs/ui/project.json
  17. 10
      nx.json
  18. 91
      package.json
  19. 66
      storybook-migration-summary.md
  20. 0
      tools/generators/.gitkeep
  21. 10202
      yarn.lock

11
.eslintrc.json

@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
@ -23,12 +23,12 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
@ -113,5 +113,6 @@
"radix": "error"
}
}
]
],
"extends": [null, "plugin:storybook/recommended"]
}

7
.storybook/main.js

@ -1,4 +1,11 @@
module.exports = {
framework: {
name: '@storybook/angular',
options: {}
},
docs: {
autodocs: true
}
// uncomment the property below if you want to apply some webpack config globally
// webpackFinal: async (config, { configType }) => {
// // Make whatever fine-grained changes you need that should apply to all storybook configs

4
apps/api/project.json

@ -33,7 +33,7 @@
"outputs": ["{options.outputPath}"]
},
"serve": {
"executor": "@nrwl/node:node",
"executor": "@nx/node:node",
"options": {
"buildTarget": "api:build"
}
@ -45,7 +45,7 @@
}
},
"test": {
"executor": "@nrwl/jest:jest",
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/api/jest.config.ts",
"passWithNoTests": true

2
apps/client-e2e/project.json

@ -5,7 +5,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/client-e2e/cypress.json",
"tsConfig": "apps/client-e2e/tsconfig.e2e.json",

2
apps/client-e2e/src/plugins/index.js

@ -11,7 +11,7 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');
const { preprocessTypescript } = require('@nx/cypress/plugins/preprocessor');
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits

2
apps/client/project.json

@ -195,7 +195,7 @@
}
},
"test": {
"executor": "@nrwl/jest:jest",
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/client/jest.config.ts",
"passWithNoTests": true

9
apps/client/src/app/core/auth.guard.ts

@ -1,10 +1,5 @@
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
CanActivate,
Router,
RouterStateSnapshot
} from '@angular/router';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
import { DataService } from '@ghostfolio/client/services/data.service';
import { SettingsStorageService } from '@ghostfolio/client/services/settings-storage.service';
import { UserService } from '@ghostfolio/client/services/user/user.service';
@ -12,7 +7,7 @@ import { EMPTY } from 'rxjs';
import { catchError } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class AuthGuard implements CanActivate {
export class AuthGuard {
private static PUBLIC_PAGE_ROUTES = [
'/about',
'/about/changelog',

2
apps/ui-e2e/project.json

@ -5,7 +5,7 @@
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/ui-e2e/cypress.json",
"devServerTarget": "ui:storybook",

2
apps/ui-e2e/src/plugins/index.js

@ -11,7 +11,7 @@
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');
const { preprocessTypescript } = require('@nx/cypress/plugins/preprocessor');
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits

30
decorate-angular-cli.js

@ -27,9 +27,11 @@ const cp = require('child_process');
const isWindows = os.platform() === 'win32';
let output;
try {
output = require('@nrwl/workspace').output;
output = require('@nx/workspace').output;
} catch (e) {
console.warn('Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.');
console.warn(
'Angular CLI could not be decorated to enable computation caching. Please ensure @nx/workspace is installed.'
);
process.exit(0);
}
@ -46,16 +48,20 @@ function symlinkNgCLItoNxCLI() {
* This is the most reliable way to create symlink-like behavior on Windows.
* Such that it works in all shells and works with npx.
*/
['', '.cmd', '.ps1'].forEach(ext => {
if (fs.existsSync(nxPath + ext)) fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext));
['', '.cmd', '.ps1'].forEach((ext) => {
if (fs.existsSync(nxPath + ext))
fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext));
});
} else {
// If unix-based, symlink
cp.execSync(`ln -sf ./nx ${ngPath}`);
}
}
catch(e) {
output.error({ title: 'Unable to create a symlink from the Angular CLI to the Nx CLI:' + e.message });
} catch (e) {
output.error({
title:
'Unable to create a symlink from the Angular CLI to the Nx CLI:' +
e.message
});
throw e;
}
}
@ -63,7 +69,11 @@ function symlinkNgCLItoNxCLI() {
try {
symlinkNgCLItoNxCLI();
require('@nrwl/cli/lib/decorate-cli').decorateCli();
output.log({ title: 'Angular CLI has been decorated to enable computation caching.' });
} catch(e) {
output.error({ title: 'Decoration of the Angular CLI did not complete successfully' });
output.log({
title: 'Angular CLI has been decorated to enable computation caching.'
});
} catch (e) {
output.error({
title: 'Decoration of the Angular CLI did not complete successfully'
});
}

2
jest.config.ts

@ -1,3 +1,3 @@
const { getJestProjects } = require('@nrwl/jest');
const { getJestProjects } = require('@nx/jest');
export default { projects: getJestProjects() };

2
jest.preset.js

@ -1,3 +1,3 @@
const nxPreset = require('@nrwl/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default;
module.exports = { ...nxPreset };

2
libs/common/.babelrc

@ -1,3 +1,3 @@
{
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
"presets": []
}

2
libs/common/project.json

@ -11,7 +11,7 @@
}
},
"test": {
"executor": "@nrwl/jest:jest",
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/libs/common"],
"options": {
"jestConfig": "libs/common/jest.config.ts",

4
libs/ui/.eslintrc.json

@ -5,7 +5,7 @@
{
"files": ["*.ts"],
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
@ -29,7 +29,7 @@
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]

2
libs/ui/project.json

@ -11,7 +11,7 @@
"prefix": "gf",
"targets": {
"test": {
"executor": "@nrwl/jest:jest",
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/libs/ui"],
"options": {
"jestConfig": "libs/ui/jest.config.ts",

10
nx.json

@ -5,7 +5,7 @@
"npmScope": "ghostfolio",
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"runner": "nx-cloud",
"options": {
"accessToken": "Mjg0ZGQ2YjAtNGI4NS00NmYwLThhOWEtMWZmNmQzODM4YzU4fHJlYWQ=",
"cacheableOperations": [
@ -21,17 +21,17 @@
},
"defaultProject": "api",
"generators": {
"@nrwl/angular:application": {
"@nx/angular:application": {
"linter": "eslint",
"unitTestRunner": "jest",
"e2eTestRunner": "cypress"
},
"@nrwl/angular:library": {
"@nx/angular:library": {
"linter": "eslint",
"unitTestRunner": "jest"
},
"@nrwl/nest": {},
"@nrwl/angular:component": {}
"@nx/angular:component": {},
"@nx/nest": {}
},
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"targetDefaults": {

91
package.json

@ -36,7 +36,7 @@
"lint": "nx workspace-lint && ng lint",
"ng": "nx",
"nx": "nx",
"postinstall": "prisma generate && ngcc --properties es2020 browser module main",
"postinstall": "prisma generate",
"replace-placeholders-in-build": "node ./replace.build.js",
"start": "node dist/apps/api/main",
"start:client": "nx run client:serve --configuration=development-en --hmr -o",
@ -52,17 +52,17 @@
"workspace-generator": "nx workspace-generator"
},
"dependencies": {
"@angular/animations": "15.2.5",
"@angular/cdk": "15.2.6",
"@angular/common": "15.2.5",
"@angular/compiler": "15.2.5",
"@angular/core": "15.2.5",
"@angular/forms": "15.2.5",
"@angular/material": "15.2.6",
"@angular/platform-browser": "15.2.5",
"@angular/platform-browser-dynamic": "15.2.5",
"@angular/router": "15.2.5",
"@angular/service-worker": "15.2.5",
"@angular/animations": "16.0.0",
"@angular/cdk": "16.0.0",
"@angular/common": "16.0.0",
"@angular/compiler": "16.0.0",
"@angular/core": "16.0.0",
"@angular/forms": "16.0.0",
"@angular/material": "16.0.0",
"@angular/platform-browser": "16.0.0",
"@angular/platform-browser-dynamic": "16.0.0",
"@angular/router": "16.0.0",
"@angular/service-worker": "16.0.0",
"@codewithdan/observable-store": "2.2.15",
"@dfinity/agent": "0.15.1",
"@dfinity/auth-client": "0.15.1",
@ -71,15 +71,14 @@
"@dfinity/principal": "0.15.1",
"@dinero.js/currencies": "2.0.0-alpha.8",
"@nestjs/bull": "0.6.3",
"@nestjs/common": "9.1.4",
"@nestjs/common": "9.4.0",
"@nestjs/config": "2.2.0",
"@nestjs/core": "9.1.4",
"@nestjs/core": "9.4.0",
"@nestjs/jwt": "9.0.0",
"@nestjs/passport": "9.0.0",
"@nestjs/platform-express": "9.1.4",
"@nestjs/platform-express": "9.4.0",
"@nestjs/schedule": "2.1.0",
"@nestjs/serve-static": "3.0.0",
"@nrwl/angular": "15.9.2",
"@prisma/client": "4.12.0",
"@simplewebauthn/browser": "5.2.1",
"@simplewebauthn/server": "5.2.1",
@ -128,38 +127,31 @@
"twitter-api-v2": "1.14.2",
"uuid": "9.0.0",
"yahoo-finance2": "2.3.10",
"zone.js": "0.12.0"
"zone.js": "0.13.0",
"@nx/angular": "16.1.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "15.2.5",
"@angular-devkit/core": "15.2.5",
"@angular-devkit/schematics": "15.2.5",
"@angular-eslint/eslint-plugin": "15.2.0",
"@angular-eslint/eslint-plugin-template": "15.2.0",
"@angular-eslint/template-parser": "15.2.0",
"@angular/cli": "15.2.5",
"@angular/compiler-cli": "15.2.5",
"@angular/language-service": "15.2.5",
"@angular/localize": "15.2.5",
"@angular-devkit/build-angular": "16.0.0",
"@angular-devkit/core": "16.0.0",
"@angular-devkit/schematics": "16.0.0",
"@angular-eslint/eslint-plugin": "16.0.1",
"@angular-eslint/eslint-plugin-template": "16.0.1",
"@angular-eslint/template-parser": "16.0.1",
"@angular/cli": "~16.0.0",
"@angular/compiler-cli": "16.0.0",
"@angular/language-service": "16.0.0",
"@angular/localize": "16.0.0",
"@angular/pwa": "15.2.5",
"@nestjs/schematics": "9.1.0",
"@nestjs/testing": "9.4.0",
"@nrwl/cli": "15.9.2",
"@nrwl/cypress": "15.9.2",
"@nrwl/eslint-plugin-nx": "15.9.2",
"@nrwl/jest": "15.9.2",
"@nrwl/nest": "15.9.2",
"@nrwl/node": "15.9.2",
"@nrwl/nx-cloud": "15.3.5",
"@nrwl/storybook": "15.9.2",
"@nrwl/workspace": "15.9.2",
"@schematics/angular": "15.2.5",
"@nx/cypress": "16.1.0",
"@nx/storybook": "16.1.0",
"@nx/workspace": "16.1.0",
"@schematics/angular": "16.0.0",
"@simplewebauthn/typescript-types": "5.2.1",
"@storybook/addon-essentials": "6.5.16",
"@storybook/angular": "6.5.16",
"@storybook/builder-webpack5": "6.5.16",
"@storybook/core-server": "6.5.16",
"@storybook/manager-webpack5": "6.5.16",
"@storybook/addon-essentials": "7.0.8",
"@storybook/angular": "7.0.8",
"@storybook/core-server": "7.0.8",
"@types/big.js": "6.1.6",
"@types/body-parser": "1.19.2",
"@types/cache-manager": "3.4.2",
@ -179,20 +171,29 @@
"eslint-config-prettier": "8.6.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-storybook": "0.6.12",
"import-sort-cli": "6.0.0",
"import-sort-parser-typescript": "6.0.0",
"import-sort-style-module": "6.0.0",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"jest-preset-angular": "13.0.0",
"nx": "15.9.2",
"nx": "16.1.0",
"nx-cloud": "16.0.5",
"prettier": "2.8.4",
"prettier-plugin-organize-attributes": "0.0.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"replace-in-file": "6.3.5",
"ts-jest": "29.0.5",
"storybook": "7.0.8",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"tslib": "2.0.0",
"typescript": "4.9.5"
"typescript": "5.0.4",
"@nx/eslint-plugin": "16.1.0",
"@nx/node": "16.1.0",
"@nx/jest": "16.1.0",
"@nx/nest": "16.1.0"
},
"engines": {
"node": ">=16"

66
storybook-migration-summary.md

@ -0,0 +1,66 @@
# Storybook 7 Migration Summary
## Upgrade Storybook packages
The following command was ran to upgrade the Storybook packages:
```bash
npx storybook@latest upgrade
```
## Your `.storybook/main.js|ts` files were prepared for Storybook's automigration scripts
Some adjustments were made to your `.storybook/main.js|ts` files so that
the Storybook automigration scripts could run successfully. The changes that were made are as follows:
- Remove the `as StorybookConfig` typecast from the main.ts files, if any,
since it is not needed any more.
- Remove the `path.resolve` calls from the Next.js Storybook configuration, if any, since it breaks the Storybook automigration scripts.
## The Storybook automigration scripts were ran
### Some migrations failed
The following commands failed and your Storybook configuration for these projects was not
migrated to the latest version 7:
- `npx storybook@latest automigrate --config-dir libs/ui/.storybook --renderer @storybook/angular`
You can run these commands again, manually, and follow the instructions in the
output of these commands to migrate your Storybook configuration to the latest version 7.
Also, we may have missed something. Please make sure to check the logs of the Storybook CLI commands that were run, and look for
the `❌ Failed trying to evaluate` message or `❌ The migration failed to update` message. This will indicate if a command was
unsuccessful, and will help you run the migration again, manually.
## Final adjustments
After the Storybook automigration scripts have run, some additional adjustments were made to your
workspace, to make sure that everything is working as expected. These adjustments are as follows:
- The `vite-tsconfig-paths` plugin was removed from the Storybook configuration files since it's no longer needed.
- The `viteConfigPath` option was added to the Storybook builder, where needed.
- The import package for the `StorybookConfig` type was changed to be framework specific.
- The `uiFramework` option was removed from your project's Storybook targets.
- The `lit` package was added to your workspace, if you are using the
Web Components `@storybook/web-components` package. Please note that the `lit-html` package is
no longer needed by Storybook v7. So, if you are not using it anywhere else, you can safely remove it.
## Next steps
You can make sure everything is working as expected by trying
to build or serve your Storybook as you normally would.
```bash
npx nx build-storybook project-name
```
```bash
npx nx storybook project-name
```
Please read the [Storybook 7.0.0 release article](https://storybook.js.org/blog/storybook-7-0/) and the
official [Storybook 7.0.0 migration guide](https://storybook.js.org/docs/react/migration-guide)
for more information.
You can also read the docs for the [@nx/storybook:migrate-7 generator](https://nx.dev/packages/storybook/generators/migrate-7) and our [Storybook 7 setup guide](https://nx.dev/packages/storybook/documents/storybook-7-setup).

0
tools/generators/.gitkeep

10202
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save