Ver código fonte

@uppy/angular: upgrade to Angular 16.x (#4642)

Antoine du Hamel 1 ano atrás
pai
commit
eddc105fcc

+ 1 - 1
package.json

@@ -114,7 +114,7 @@
     "build:companion": "yarn workspace @uppy/companion build",
     "build:css": "yarn node ./bin/build-css.js",
     "build:svelte": "yarn workspace @uppy/svelte build",
-    "build:angular": "yarn workspace angular build:release",
+    "build:angular": "yarn workspace angular build",
     "build:js": "npm-run-all build:lib build:companion build:locale-pack build:svelte build:angular build:bundle",
     "build:lib": "yarn node ./bin/build-lib.js",
     "build:locale-pack": "yarn workspace @uppy-dev/locale-pack build && eslint packages/@uppy/locales/src/en_US.js --fix && yarn workspace @uppy-dev/locale-pack test unused",

+ 21 - 16
packages/@uppy/angular/.eslintrc.json

@@ -7,28 +7,32 @@
       "files": [
         "*.ts"
       ],
-      "parserOptions": {
-        "project": [
-          "packages/@uppy/angular/tsconfig.json"
-        ],
-        "createDefaultProgram": true
-      },
       "extends": [
-        "plugin:@angular-eslint/ng-cli-compat",
-        "plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
+        "eslint:recommended",
+        "plugin:@typescript-eslint/recommended",
+        "plugin:@angular-eslint/recommended",
         "plugin:@angular-eslint/template/process-inline-templates"
       ],
       "rules": {
+        "@angular-eslint/directive-selector": [
+          "error",
+          {
+            "type": "attribute",
+            "prefix": "app",
+            "style": "camelCase"
+          }
+        ],
         "@typescript-eslint/semi": ["error", "never"],
-        "dot-notation": "error",
         "import/no-unresolved": "off",
         "import/prefer-default-export": "off",
-        "indent": "error",
-        "no-empty-function": "off",
-        "no-shadow": "error",
-        "no-unused-expressions": "error",
-        "no-use-before-define": "off",
-        "quotes": "error",
+        "@angular-eslint/component-selector": [
+          "error",
+          {
+            "type": "element",
+            "prefix": "app",
+            "style": "kebab-case"
+          }
+        ],
         "semi": ["error", "never"]
       }
     },
@@ -37,7 +41,8 @@
         "*.html"
       ],
       "extends": [
-        "plugin:@angular-eslint/template/recommended"
+        "plugin:@angular-eslint/template/recommended",
+        "plugin:@angular-eslint/template/accessibility"
       ],
       "rules": {}
     }

+ 9 - 15
packages/@uppy/angular/.gitignore

@@ -1,22 +1,18 @@
 # See http://help.github.com/ignore-files/ for more about ignoring files.
 
-!lib/
-
-# compiled output
+# Compiled output
 /dist
 /tmp
 /out-tsc
-# Only exists if Bazel was run
 /bazel-out
 
-# dependencies
+# Node
 /node_modules
-
-# profiling files
-chrome-profiler-events*.json
+npm-debug.log
+yarn-error.log
 
 # IDEs and editors
-/.idea
+.idea/
 .project
 .classpath
 .c9/
@@ -24,7 +20,7 @@ chrome-profiler-events*.json
 .settings/
 *.sublime-workspace
 
-# IDE - VSCode
+# Visual Studio Code
 .vscode/*
 !.vscode/settings.json
 !.vscode/tasks.json
@@ -32,17 +28,15 @@ chrome-profiler-events*.json
 !.vscode/extensions.json
 .history/*
 
-# misc
+# Miscellaneous
 /.angular/cache
-/.sass-cache
+.sass-cache/
 /connect.lock
 /coverage
 /libpeerconnection.log
-npm-debug.log
-yarn-error.log
 testem.log
 /typings
 
-# System Files
+# System files
 .DS_Store
 Thumbs.db

+ 0 - 15
packages/@uppy/angular/.storybook/main.js

@@ -1,15 +0,0 @@
-module.exports = {
-  "stories": [
-    "../stories/**/*.stories.mdx",
-    "../stories/**/*.stories.@(js|jsx|ts|tsx)"
-  ],
-  "addons": [
-    "@storybook/addon-links",
-    "@storybook/addon-essentials",
-    "@storybook/addon-interactions"
-  ],
-  "framework": "@storybook/angular",
-  "core": {
-    "builder": "webpack5"
-  }
-}

+ 0 - 14
packages/@uppy/angular/.storybook/preview.js

@@ -1,14 +0,0 @@
-import { setCompodocJson } from "@storybook/addon-docs/angular";
-import docJson from "../documentation.json";
-setCompodocJson(docJson);
-
-export const parameters = {
-  actions: { argTypesRegex: "^on[A-Z].*" },
-  controls: {
-    matchers: {
-      color: /(background|color)$/i,
-      date: /Date$/,
-    },
-  },
-  docs: { inlineStories: true },
-}

+ 0 - 21
packages/@uppy/angular/.storybook/tsconfig.json

@@ -1,21 +0,0 @@
-{
-  "extends": "../projects/uppy/angular/tsconfig.lib.json",
-  "compilerOptions": {
-    "types": [
-      "node"
-    ],
-    "allowSyntheticDefaultImports": true
-  },
-  "exclude": [
-    "../src/test.ts",
-    "../src/**/*.spec.ts",
-    "../projects/**/*.spec.ts"
-  ],
-  "include": [
-    "../src/**/*",
-    "../projects/**/*"
-  ],
-  "files": [
-    "./typings.d.ts"
-  ]
-}

+ 0 - 4
packages/@uppy/angular/.storybook/typings.d.ts

@@ -1,4 +0,0 @@
-declare module '*.md' {
-  const content: string;
-  export default content;
-}

+ 4 - 0
packages/@uppy/angular/.vscode/extensions.json

@@ -0,0 +1,4 @@
+{
+  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
+  "recommendations": ["angular.ng-template"]
+}

+ 20 - 0
packages/@uppy/angular/.vscode/launch.json

@@ -0,0 +1,20 @@
+{
+  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "name": "ng serve",
+      "type": "chrome",
+      "request": "launch",
+      "preLaunchTask": "npm: start",
+      "url": "http://localhost:4200/"
+    },
+    {
+      "name": "ng test",
+      "type": "chrome",
+      "request": "launch",
+      "preLaunchTask": "npm: test",
+      "url": "http://localhost:9876/debug.html"
+    }
+  ]
+}

+ 42 - 0
packages/@uppy/angular/.vscode/tasks.json

@@ -0,0 +1,42 @@
+{
+  // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
+  "version": "2.0.0",
+  "tasks": [
+    {
+      "type": "npm",
+      "script": "start",
+      "isBackground": true,
+      "problemMatcher": {
+        "owner": "typescript",
+        "pattern": "$tsc",
+        "background": {
+          "activeOnStart": true,
+          "beginsPattern": {
+            "regexp": "(.*?)"
+          },
+          "endsPattern": {
+            "regexp": "bundle generation complete"
+          }
+        }
+      }
+    },
+    {
+      "type": "npm",
+      "script": "test",
+      "isBackground": true,
+      "problemMatcher": {
+        "owner": "typescript",
+        "pattern": "$tsc",
+        "background": {
+          "activeOnStart": true,
+          "beginsPattern": {
+            "regexp": "(.*?)"
+          },
+          "endsPattern": {
+            "regexp": "bundle generation complete"
+          }
+        }
+      }
+    }
+  ]
+}

+ 10 - 6
packages/@uppy/angular/README.md

@@ -1,23 +1,27 @@
 # Angular
 
-This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.0.4.
+This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 16.2.0.
 
 ## Development server
 
-Run `yarn workspace angular start` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
+Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
 
 ## Code scaffolding
 
-Run `yarn workspace angular ng generate component component-name` to generate a new component. You can also use `yarn workspace angular ng generate directive|pipe|service|class|guard|interface|enum|module`.
+Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
 
 ## Build
 
-Run `yarn build:angular` to build the project. The build artifacts will be stored in the `dist/` directory.
+Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
 
 ## Running unit tests
 
-Run `yarn workspace angular test` to execute the unit tests via [Karma](https://karma-runner.github.io).
+Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
+
+## Running end-to-end tests
+
+Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
 
 ## Further help
 
-To get more help on the Angular CLI use `yarn workspace angular ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
+To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

+ 4 - 6
packages/@uppy/angular/angular.json

@@ -27,16 +27,14 @@
         "test": {
           "builder": "@angular-devkit/build-angular:karma",
           "options": {
-            "main": "projects/uppy/angular/src/test.ts",
             "tsConfig": "projects/uppy/angular/tsconfig.spec.json",
-            "karmaConfig": "projects/uppy/angular/karma.conf.js"
+            "polyfills": [
+              "zone.js",
+              "zone.js/testing"
+            ]
           }
         }
       }
     }
-  },
-  "defaultProject": "@uppy/angular",
-  "cli": {
-    "analytics": false
   }
 }

+ 27 - 42
packages/@uppy/angular/package.json

@@ -4,58 +4,43 @@
   "scripts": {
     "ng": "ng",
     "start": "ng serve",
-    "build": "ng build @uppy/angular --configuration development",
-    "build:release": "ng build",
-    "build-storybook": "npm run docs:json && build-storybook",
-    "docs:json": "compodoc -p ./tsconfig.json -e json -d .",
-    "storybook": "npm run docs:json && start-storybook -p 6006",
+    "build": "ng build",
     "watch": "ng build --watch --configuration development",
     "test": "ng test"
   },
   "private": true,
   "dependencies": {
-    "@angular/animations": ">= 14",
-    "@angular/common": ">= 14",
-    "@angular/compiler": ">= 14",
-    "@angular/core": ">= 14",
-    "@angular/forms": ">= 14",
-    "@angular/platform-browser": ">= 14",
-    "@angular/platform-browser-dynamic": ">= 14",
-    "@angular/router": ">= 14",
-    "@uppy/dashboard": "workspace:^",
-    "@uppy/drag-drop": "workspace:^",
-    "@uppy/progress-bar": "workspace:^",
-    "@uppy/status-bar": "workspace:^",
-    "prop-types": "^15.7.2",
-    "rxjs": "~7.5.0",
+    "@angular/animations": "^16.2.0",
+    "@angular/common": "^16.2.0",
+    "@angular/compiler": "^16.2.0",
+    "@angular/core": "^16.2.0",
+    "@angular/forms": "^16.2.0",
+    "@angular/platform-browser": "^16.2.0",
+    "@angular/platform-browser-dynamic": "^16.2.0",
+    "@angular/router": "^16.2.0",
+    "rxjs": "~7.8.0",
     "tslib": "^2.3.0",
-    "zone.js": "~0.11.4"
-  },
-  "peerDependencies": {
-    "@uppy/core": "workspace:^"
+    "zone.js": "~0.13.0"
   },
   "devDependencies": {
-    "@angular-devkit/build-angular": ">= 14",
-    "@angular/cli": ">= 14",
-    "@angular/compiler-cli": ">= 14",
-    "@babel/core": "^7.17.5",
-    "@compodoc/compodoc": "^1.1.19",
-    "@storybook/addon-actions": "^6.5.0-alpha.42",
-    "@storybook/addon-essentials": "^6.5.0-alpha.42",
-    "@storybook/addon-interactions": "^6.5.0-alpha.42",
-    "@storybook/addon-links": "^6.5.0-alpha.42",
-    "@storybook/angular": "^6.5.0-alpha.42",
-    "@storybook/builder-webpack5": "^6.5.0-alpha.42",
-    "@storybook/manager-webpack5": "^6.5.0-alpha.42",
-    "@storybook/testing-library": "^0.0.9",
-    "@types/jasmine": "~4.0.0",
-    "babel-loader": "^8.2.3",
-    "jasmine-core": "~4.2.0",
+    "@angular-devkit/build-angular": "^16.2.0",
+    "@angular-eslint/builder": "16.1.1",
+    "@angular-eslint/eslint-plugin": "16.1.1",
+    "@angular-eslint/eslint-plugin-template": "16.1.1",
+    "@angular-eslint/schematics": "16.1.1",
+    "@angular-eslint/template-parser": "16.1.1",
+    "@angular/cli": "~16.2.0",
+    "@angular/compiler-cli": "^16.2.0",
+    "@types/jasmine": "~4.3.0",
+    "@typescript-eslint/eslint-plugin": "5.62.0",
+    "@typescript-eslint/parser": "5.62.0",
+    "jasmine-core": "~4.6.0",
     "karma": "~6.4.0",
+    "karma-chrome-launcher": "~3.2.0",
     "karma-coverage": "~2.2.0",
     "karma-jasmine": "~5.1.0",
-    "karma-jasmine-html-reporter": "~2.0.0",
-    "ng-packagr": "^13.0.0",
-    "typescript": "~4.8"
+    "karma-jasmine-html-reporter": "~2.1.0",
+    "ng-packagr": "^16.2.0",
+    "typescript": "~5.1"
   }
 }

+ 0 - 34
packages/@uppy/angular/projects/uppy/angular/karma.conf.js

@@ -1,34 +0,0 @@
-// Karma configuration file, see link for more information
-// https://karma-runner.github.io/1.0/config/configuration-file.html
-
-module.exports = function karmaConfig (config) {
-  config.set({
-    basePath: '',
-    frameworks: ['jasmine', '@angular-devkit/build-angular'],
-    plugins: [
-      /* eslint-disable */
-      require('karma-jasmine'), 
-      require('karma-chrome-launcher'), 
-      require('karma-jasmine-html-reporter'), 
-      require('karma-coverage-istanbul-reporter'), 
-      require('@angular-devkit/build-angular/plugins/karma'), 
-      /* eslint-enable */
-    ],
-    client: {
-      clearContext: false, // leave Jasmine Spec Runner output visible in browser
-    },
-    coverageIstanbulReporter: {
-      dir: require('path').join(__dirname, '../../coverage/angular'),
-      reports: ['html', 'lcovonly', 'text-summary'],
-      fixWebpackSourcePaths: true,
-    },
-    reporters: ['progress', 'kjhtml'],
-    port: 9876,
-    colors: true,
-    logLevel: config.LOG_INFO,
-    autoWatch: true,
-    browsers: ['Chrome'],
-    singleRun: false,
-    restartOnFileChange: true,
-  })
-}

+ 2 - 2
packages/@uppy/angular/projects/uppy/angular/ng-package.json

@@ -1,6 +1,6 @@
 {
-  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
-  "dest": "../../dist/angular",
+  "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
+  "dest": "../../../dist/uppy/angular",
   "lib": {
     "entryFile": "src/public-api.ts"
   }

+ 5 - 4
packages/@uppy/angular/projects/uppy/angular/package.json

@@ -19,19 +19,20 @@
     "url": "git+https://github.com/transloadit/uppy.git"
   },
   "scripts": {
-    "prepublishOnly": "rm -fr * && cp -r ../../dist/angular .."
+    "prepublishOnly": "rm -fr * && cp -r ../../../dist/uppy/angular .."
   },
   "dependencies": {
     "tslib": "^2.0.0"
   },
   "peerDependencies": {
-    "@angular/common": ">= 14",
-    "@angular/core": ">= 14",
+    "@angular/common": "^16.2.0",
+    "@angular/core": "^16.2.0",
     "@uppy/core": "workspace:^",
     "@uppy/dashboard": "workspace:^",
     "@uppy/drag-drop": "workspace:^",
     "@uppy/progress-bar": "workspace:^",
     "@uppy/status-bar": "workspace:^",
     "@uppy/utils": "workspace:^"
-  }
+  },
+  "sideEffects": false
 }

+ 0 - 26
packages/@uppy/angular/projects/uppy/angular/src/test.ts

@@ -1,26 +0,0 @@
-// This file is required by karma.conf.js and loads recursively all the .spec and framework files
-
-import 'zone.js/dist/zone'
-import 'zone.js/dist/zone-testing'
-import { getTestBed } from '@angular/core/testing'
-import {
-  BrowserDynamicTestingModule,
-  platformBrowserDynamicTesting,
-} from '@angular/platform-browser-dynamic/testing'
-
-declare const require: {
-  context(path: string, deep?: boolean, filter?: RegExp): {
-    keys(): string[];
-    <T>(id: string): T;
-  };
-}
-
-// First, initialize the Angular testing environment.
-getTestBed().initTestEnvironment(
-  BrowserDynamicTestingModule,
-  platformBrowserDynamicTesting()
-)
-// Then we find all the tests.
-const context = require.context('./', true, /\.spec\.ts$/)
-// And load the modules.
-context.keys().map(context)

+ 5 - 16
packages/@uppy/angular/projects/uppy/angular/tsconfig.lib.json

@@ -1,25 +1,14 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
 {
   "extends": "../../../tsconfig.json",
   "compilerOptions": {
-    "outDir": "../../out-tsc/lib",
-    "target": "es2015",
+    "outDir": "../../../out-tsc/lib",
     "declaration": true,
+    "declarationMap": true,
     "inlineSources": true,
-    "types": [],
-    "lib": [
-      "dom",
-      "es2018"
-    ]
-  },
-  "angularCompilerOptions": {
-    "skipTemplateCodegen": true,
-    "strictMetadataEmit": true,
-    "enableResourceInlining": true
+    "types": []
   },
   "exclude": [
-    "src/test.ts",
-    "**/*.stories.ts",
-    "**/*.spec.ts",
-    "**/*.stories.ts"
+    "**/*.spec.ts"
   ]
 }

+ 4 - 0
packages/@uppy/angular/projects/uppy/angular/tsconfig.lib.prod.json

@@ -1,6 +1,10 @@
 /* To learn more about this file see: https://angular.io/config/tsconfig. */
 {
   "extends": "./tsconfig.lib.json",
+  "compilerOptions": {
+    "declarationMap": false
+  },
   "angularCompilerOptions": {
+    "compilationMode": "partial"
   }
 }

+ 1 - 4
packages/@uppy/angular/projects/uppy/angular/tsconfig.spec.json

@@ -2,14 +2,11 @@
 {
   "extends": "../../../tsconfig.json",
   "compilerOptions": {
-    "outDir": "../../out-tsc/spec",
+    "outDir": "../../../out-tsc/spec",
     "types": [
       "jasmine"
     ]
   },
-  "files": [
-    "src/test.ts"
-  ],
   "include": [
     "**/*.spec.ts",
     "**/*.d.ts"

+ 4 - 4
packages/@uppy/angular/tsconfig.json

@@ -4,7 +4,6 @@
   "compilerOptions": {
     "paths": {
       "@uppy/angular": [
-        "dist/uppy/angular/uppy-angular",
         "dist/uppy/angular"
       ]
     },
@@ -22,10 +21,11 @@
     "experimentalDecorators": true,
     "moduleResolution": "node",
     "importHelpers": true,
-    "target": "es2017",
-    "module": "es2020",
+    "target": "ES2022",
+    "module": "ES2022",
+    "useDefineForClassFields": false,
     "lib": [
-      "es2020",
+      "ES2022",
       "dom"
     ]
   },

Diferenças do arquivo suprimidas por serem muito extensas
+ 474 - 144
yarn.lock


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff