Skip to content

Commit

Permalink
[automate-1640] Automate-ui version bump from Angular 6 -> Angu… (#1707)
Browse files Browse the repository at this point in the history
* Remove incompatible npm package

Attempts to upgrade Angular reported that the "ngrx-tslint-oftype"
package was not compatible.
But this package was only needed for preparing a particular ngrx transition
between versions, so its work is done and it can be removed.

Signed-off-by: michael sorens <msorens@chef.io>

* `ng update` generated changes

Signed-off-by: michael sorens <msorens@chef.io>

* Reverted typescript from 3.5.3 to 3.4.5

The update of @angular/core failed because it found
3.5.3 -- that the upgrade had installed itself.
I edited the package.json from  ^3.4.5 to ~3.4.5
to keep it to 3.4.x, then npm install,
and it updated this package-lock.json.

Signed-off-by: michael sorens <msorens@chef.io>

* @ViewChild fixes

These are auto-generated from:
ng update @angular/core --from 7 --to 8 --migrate-only

Signed-off-by: michael sorens <msorens@chef.io>

* @angular/material fixes

These are auto-generated from:
ng update @angular/material --from 7 --to 8 --migrate-only

Signed-off-by: michael sorens <msorens@chef.io>

* Try to fix npm issue

webpack/webpack#8656 (comment)
Add acorn to package.json.

Signed-off-by: michael sorens <msorens@chef.io>

* Import fresh wallaby.js

Commit 060eccd8d6e72997b769e7ddb8570d50e310d43b
from https://github.com/wallabyjs/ngCliWebpackSample/o
dated 2019-07-09

Signed-off-by: michael sorens <msorens@chef.io>

* Re-apply Chef customization from old wallaby.js

Signed-off-by: michael sorens <msorens@chef.io>

* Import fresh wallaby.js (again)

After I submitted an issue, they updated the config file for Angular 8.
wallabyjs/public#2141

Signed-off-by: michael sorens <msorens@chef.io>

* Import fresh wallaby.js (one more time)

Wallaby team adjusted the config file again; this time it worked.
wallabyjs/public#2141

Signed-off-by: michael sorens <msorens@chef.io>

* Update angular-devkit deps

Signed-off-by: Scott Christopherson <scott@chef.io>

* Update router-store initialization

Signed-off-by: Scott Christopherson <scott@chef.io>

* Re-sync after rebase

* Minor fix

Signed-off-by: michael sorens <msorens@chef.io>

* Use the updated action types in routerReducer

ngrx/platform@466e2cd#diff-c0c42c418c07609d7feedc294175d164

* Configure route serializer via StoreRouterConnectingModule

Old way still works but the new way is how it's currently documented now and it requires less imports.

* Lint cleanup

Teardown the kludgy lint command needed to filter out
the deprecated deprecation (really!) of `select`.

Also suppress one essentially invalid lint complaint.

Signed-off-by: michael sorens <msorens@chef.io>

* Fix compile error in e2e (protractor) tests

Was getting this error:
e2e/compliance-reporting.e2e-spec.ts(2,10): error TS2305:
Module '"...e2e/helpers/accessibility_helpers"' has no exported member 'expectUrlToBeAccessible'.

Not clear what the problem was but this change fixed it

Signed-off-by: michael sorens <msorens@chef.io>

* Upgrade lots of npm packages

Ran `npm update` and got package updates shown.
Also includes just one code change needed to get a successful build.
All unit tests pass.

+ @angular/cdk@8.2.0
+ @angular/cli@8.3.5
+ @angular-devkit/core@8.3.5
+ @angular-devkit/schematics@8.3.5
+ @angular/forms@8.2.7
+ @angular/material@8.2.0
+ @angular/animations@8.2.7
+ @types/faker@4.1.5
+ @angular/platform-browser-dynamic@8.2.7
+ @angular/language-service@8.2.7
+ @angular/platform-browser@8.2.7
+ @angular/router@8.2.7
+ @angular/core@8.2.7
+ @angular/compiler@8.2.7
+ @types/jasminewd2@2.0.6
+ ajv@6.10.2
+ @types/lodash@4.14.138
+ codelyzer@5.1.1
+ axe-webdriverjs@2.3.0
+ d3@5.12.0
+ install@0.12.2
+ @types/node@10.14.18
+ core-js@2.6.9
+ karma-coverage-istanbul-reporter@2.1.0
+ karma-firefox-launcher@1.2.0
+ karma-jasmine-html-reporter@1.4.2
+ lodash@4.17.15
+ rxjs@6.5.3
+ moment@2.24.0
+ @angular/common@8.2.7
+ ngx-cookie@4.1.2
+ karma@3.1.4
+ @types/jasmine@2.8.16
+ tslib@1.10.0
+ sass-lint@1.13.1
+ tslint@5.20.0
+ rxjs-tslint@0.1.7
+ sniffr@1.2.0
+ tslint-defocus@2.0.6
+ wallaby-webpack@3.9.15
+ diff2html@2.11.3
+ @angular-devkit/build-angular@0.801.3
+ typescript@3.6.3
+ @angular/compiler-cli@8.2.7

added 397 packages from 78 contributors, removed 283 packages, updated 242 packages, moved 24 packages and audited 18418 packages in 134.542s

Signed-off-by: michael sorens <msorens@chef.io>

* More npm package updates

Signed-off-by: michael sorens <msorens@chef.io>

* and still more package updates

Signed-off-by: michael sorens <msorens@chef.io>

* Tighten version lock to patch only

@types/jasmine - generated error from `make unit`:
Per https://stackoverflow.com/a/57592510
need to wait for a patch

jasmine-core - just too new; came out yesterday! let's wait a bit on this one

tyepscript: generated error from `make server` that it needed angular < 3.6
so locking it at 3.5 until a later angular release

Signed-off-by: michael sorens <msorens@chef.io>

* Fix build warning

Warning message for the two SCSS files:
"start value has mixed support, consider using flex-start instead"

Signed-off-by: michael sorens <msorens@chef.io>

* Add reference comment

Signed-off-by: michael sorens <msorens@chef.io>

* Suppress ngrx runtime checks warnings

```
WARN: '@ngrx/store: runtime checks are currently opt-in but will be the default in the next major version with the possibility to opt-out, see https://ngrx.io/guide/migration/v8 for more information.'
```

Signed-off-by: Scott Christopherson <scott@chef.io>

* Suppress momentjs parse warning

```
WARN: 'Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
```

The test is purposefully testing an invalid string passed to `moment`. The warning is expected.

Signed-off-by: Scott Christopherson <scott@chef.io>

* Suppress unhandled router promise warning

```
ERROR: 'Unhandled Promise rejection:', 'Cannot match any routes. URL Segment: 'projects/uuid-1'', '; Zone:', 'ProxyZone', '; Task:', 'Promise.then', '; Value:', Error: Cannot match any routes. URL Segment: 'projects/uuid-1'
Error: Cannot match any routes. URL Segment: 'projects/uuid-1'
```

Signed-off-by: Scott Christopherson <scott@chef.io>

* Ensure ui-lib is installed w/ other dependencies

Unit tests fail to run if ui-lib assets are not installed.

```
ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/styles.scss)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Failed to find 'assets/chef-ui-library/chef/chef.css'
  in [
    /go/src/github.com/chef/automate/components/automate-ui/src
  ]
    at resolveModule.catch.catch (/go/src/github.com/chef/automate/components/automate-ui/node_modules/postcss-import/lib/resolve-id.js:35:13)
 @ ./src/styles.scss 1:14-241
 @ multi ./src/styles.scss
```

Signed-off-by: Scott Christopherson <scott@chef.io>

* Reduce unit test noise

WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'

This was being generated by the following components:
 - ClientRunsComponent
 - ServiceGroupsComponent
 - ReportingComponent
 - HttpClientAuthInterceptor

The warning stems from this issue introduced by Angular 7:
angular/angular#25837

The first two components are fixed by this commit,
cutting the test "noise" in half.
Unfortunately applying the same fix to ReportingComponent
breaks several unit tests.
And I have not yet found the place to hook into to
fix HttpClientAuthInterceptor.

Signed-off-by: michael sorens <msorens@chef.io>

* One more pass of `npm update`

Have to move fast to keep on top of these changes.

This pass did these updates:
$ npm update
+ @angular-devkit/core@8.3.6
+ @angular/common@8.2.8
+ @angular/cdk@8.2.1
+ @angular/cli@8.3.6
+ @angular-devkit/schematics@8.3.6
+ @angular-devkit/build-angular@0.803.6
+ @angular/compiler-cli@8.2.8
+ @angular/language-service@8.2.8
+ @angular/platform-browser@8.2.8
+ @angular/core@8.2.8
+ @angular/platform-server@8.2.8
+ @angular/material@8.2.1
+ jasmine-core@3.5.0
+ @types/lodash@4.14.141
+ @angular/forms@8.2.8
+ @angular/platform-browser-dynamic@8.2.8
+ @types/node@10.14.19
+ @angular/router@8.2.8
+ codelyzer@5.1.2
+ @angular/compiler@8.2.8
+ @angular/animations@8.2.8

Signed-off-by: michael sorens <msorens@chef.io>

* Document package.json constraints

Certain few packages are specifically not updated
to their latest versions.
As package.json cannot contain comments,
I documented the reasons in the next best thing, the readme.

Signed-off-by: michael sorens <msorens@chef.io>

* Suppress ngZone warnings in reporting.component.spec

```
    applyParamFilters()
      ✔ parses multiple filters
      ✔ parses single filters
      ✔ parse interval
INFO: 'getEndDate calling router.navigate'
INFO: 'getEndDate calling router.navigate'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
      ✔ parse bad end date
INFO: 'getDateInterval calling router.navigate'
INFO: 'getDateInterval calling router.navigate'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
      ✔ parse invaild interval 2
INFO: 'getDateInterval calling router.navigate'
INFO: 'getDateInterval calling router.navigate'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
      ✔ parse invaild interval 1
INFO: 'getDateInterval calling router.navigate'
INFO: 'getDateInterval calling router.navigate'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
WARN: 'Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?'
      ✔ parse bad interval
```

The `getEndDate` and `getDateInterval` methods call `router.navigate` which seems unexpected for methods that are named for getting and returning a value.

* Suppress ngZone warnings in service-groups.component.spec

Signed-off-by: Scott Christopherson <scott@chef.io>

* Suppress ngZone warnings in client-runs.component.spec

Signed-off-by: Scott Christopherson <scott@chef.io>

* Remove unused routing-helper

Ended up not needing it after refactoring specs to not rely on calling through `router.navigate`.

Signed-off-by: Scott Christopherson <scott@chef.io>
  • Loading branch information
msorens committed Oct 7, 2019
1 parent 574dd33 commit 6b3840d
Show file tree
Hide file tree
Showing 68 changed files with 11,174 additions and 11,172 deletions.
3 changes: 1 addition & 2 deletions components/automate-ui/Makefile
Expand Up @@ -9,6 +9,7 @@ NG_CMD := npm run ng --

install:
npm install
npm run install:ui-library

build:
hab studio run "source .studiorc; build"
Expand All @@ -34,8 +35,6 @@ lint-html:

lint-typescript:
npm run lint
@echo "⚠️ The warning 'select is deprecated' is no longer true as of 7.0 \
so it is suppressed from the output: see https://github.com/ngrx/platform/pull/1361."

pr-ready: unit-all-browsers lint e2e

Expand Down
41 changes: 41 additions & 0 deletions components/automate-ui/README.md
Expand Up @@ -10,6 +10,7 @@ With the plugin installed, this TOC will update automatically when you save the
<!-- TOC depthFrom:2 depthTo:2 -->

- [Requirements](#requirements)
- [Dependency Management](#dependency-management)
- [Angular Module Architecture](#angular-module-architecture)
- [Developing against the Hab Studio](#developing-against-the-hab-studio)
- [Project History](#project-history)
Expand Down Expand Up @@ -48,6 +49,46 @@ git) to access private repositories in a secure way that is more granularly
revokable than using ssh or a password. [Read more about
accessing git and Github with tokens in this post from the Github blog..](https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth)

## Dependency Management

Certain packages in package.json are constrained for the reasons detailed here.
At any future moment though, the reasons for constraint here could be invalidated, so this should be updated as needed when package.json is updated.
While it is problematic to document this information due to the maintenance burden, the value of having this in one place outweighs that burden.

**Package @types/jasmine: =3.3.10**

Reason: `make unit` generates this error:
```
error TS6200: Definitions of the following identifiers conflict with those in another file: ImplementationCallback, Expected, SpyObjMethodNames, CustomEqualityTester, CustomMatcherFactory, ExpectationFailed, SpecFunction, SpyObj, jasmine
```
Reference: https://stackoverflow.com/a/57592510

**Package @types/jasminewd2: =2.0.6**

Reason: `make serve` generates this error:
```
ERROR in ../node_modules/@types/jasminewd2/index.d.ts:8:23 - error TS2688: Cannot find type definition file for 'jasmine/v2'.
```

**Package @types/node: ^10.14.19**

Reason: The major version should match our node version, which is 10.15.2 (this is a guess on my part, could neither confirm nor deny it), so I have constrained it to 10.14.* as shown.

**Package immutable: ^3.8.2**

Reason: Later releases are release candidates; should only be using production-releases.

**Package typescript: ~3.5.3**

Reason: `make serve` reported error that it needs angular < 3.6 so locking it at 3.5.* until a later Angular release.

**Package zone.js: ~0.9.1**

Reason: Trying to install the next version `npm install zone.js@0.10.2` reports that @angular/core requires it:
```
@angular/core@8.2.8 requires a peer of zone.js@~0.9.1
```

## Angular Module Architecture

As a very brief introduction to the Angular architecture, it all starts with app.module.ts,
Expand Down
4 changes: 1 addition & 3 deletions components/automate-ui/e2e/helpers/accessibility_helpers.js
Expand Up @@ -35,9 +35,7 @@ const expectPageToBeAccessible = function(done) {
};

// Navigates protractor's browser to the desired URL then runs an a11y test.
const expectUrlToBeAccessible = function(url, done) {
export const expectUrlToBeAccessible = function(url, done) {
browser.get(url);
expectPageToBeAccessible(done);
};

module.exports = { expectUrlToBeAccessible };

0 comments on commit 6b3840d

Please sign in to comment.