From 87eb0d086189ed76434931b2dbc8a28026e02eb1 Mon Sep 17 00:00:00 2001 From: mrmeku Date: Thu, 16 May 2019 00:18:08 -0600 Subject: [PATCH] perf: No longer poll for updates --- .nvmrc | 2 +- .yarnrc | 1 + angular.json | 3 -- apps/angular-console/src/polyfills.ts | 18 ++++++++++-- apps/electron/src/assets/new-workspace | 7 ----- apps/electron/src/package.json | 5 ++-- apps/intellij/src/package.json | 5 ++-- apps/vscode/src/package.json | 5 ++-- .../lib/extensions/extensions.component.ts | 18 +++++------- .../lib/schematics/schematics.component.ts | 20 ++++++------- .../src/lib/targets/targets.component.ts | 28 ++++++++----------- .../src/lib/projects/projects.component.ts | 6 ++-- .../src/lib/workspace/workspace.component.ts | 17 +++-------- libs/server/src/lib/api/run-command.ts | 6 ++-- package.json | 3 +- tsconfig.json | 4 +-- yarn.lock | 18 +++--------- 17 files changed, 66 insertions(+), 100 deletions(-) create mode 100644 .yarnrc diff --git a/.nvmrc b/.nvmrc index 97dd9aa830..cc5875fabb 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v11.13.0 +v10.15.3 diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 0000000000..a92b0fb916 --- /dev/null +++ b/.yarnrc @@ -0,0 +1 @@ +no-optional true diff --git a/angular.json b/angular.json index 6f753cce93..3511c39bb0 100644 --- a/angular.json +++ b/angular.json @@ -176,7 +176,6 @@ "externalDependencies": [ "vscode", "source-map-explorer", - "semver", "tmp", "fast-glob", "node-pty-prebuilt" @@ -228,7 +227,6 @@ "externalDependencies": [ "electron", "source-map-explorer", - "semver", "tmp", "node-pty-prebuilt" ], @@ -277,7 +275,6 @@ "extractLicenses": true, "externalDependencies": [ "source-map-explorer", - "semver", "tmp", "node-pty-prebuilt" ], diff --git a/apps/angular-console/src/polyfills.ts b/apps/angular-console/src/polyfills.ts index 5a9ce72037..c1caa757eb 100644 --- a/apps/angular-console/src/polyfills.ts +++ b/apps/angular-console/src/polyfills.ts @@ -55,9 +55,21 @@ * user can disable parts of macroTask/DomEvents patch by setting following flags */ -// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame -// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick -// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames +(window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame +(window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick +(window as any).__zone_symbol__BLACK_LISTED_EVENTS = [ + 'scroll', + 'resize', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseover', + 'mouseout', + 'mousewheel', + 'pointermove', + 'keypress', + 'keyup' +]; // disable patch specified eventNames /* * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js diff --git a/apps/electron/src/assets/new-workspace b/apps/electron/src/assets/new-workspace index aff6a2453c..18d36ee357 100755 --- a/apps/electron/src/assets/new-workspace +++ b/apps/electron/src/assets/new-workspace @@ -3,7 +3,6 @@ const { execSync } = require('child_process'); const { dirSync } = require('tmp'); -const { lt } = require('semver'); const path = require('path'); const ngNewArgs = process.argv.slice(2); @@ -15,12 +14,6 @@ const collection = ( try { // check the correct version of the NPM is installed const output = execSync('npm --version').toString(); - if (lt(output, '5.0.0')) { - console.error( - 'To create a workspace you must have NPM >= 5.0.0 installed.' - ); - process.exit(1); - } } catch (e) { throw new Error('Cannot find npm. Do you have node installed?'); } diff --git a/apps/electron/src/package.json b/apps/electron/src/package.json index 4579c0ae33..a84fbbb0c6 100644 --- a/apps/electron/src/package.json +++ b/apps/electron/src/package.json @@ -9,9 +9,8 @@ "main": "main.js", "license": "MIT", "dependencies": { - "semver": "5.6.0", - "tmp": "^0.1.0", + "tmp": "0.1.0", "node-pty-prebuilt": "0.7.6", - "source-map-explorer": "^1.7.0" + "source-map-explorer": "1.8.0" } } diff --git a/apps/intellij/src/package.json b/apps/intellij/src/package.json index 4fed4b6dba..759475bdfa 100644 --- a/apps/intellij/src/package.json +++ b/apps/intellij/src/package.json @@ -12,9 +12,8 @@ "main": "main.js", "license": "MIT", "dependencies": { - "semver": "5.6.0", - "tmp": "^0.1.0", + "tmp": "0.1.0", "node-pty-prebuilt": "0.7.6", - "source-map-explorer": "^1.7.0" + "source-map-explorer": "1.8.0" } } diff --git a/apps/vscode/src/package.json b/apps/vscode/src/package.json index b320ca0a69..28bdfa23ee 100644 --- a/apps/vscode/src/package.json +++ b/apps/vscode/src/package.json @@ -2,7 +2,7 @@ "name": "angular-console", "displayName": "Angular Console", "description": "Angular Console for Visual Studio Code. The user interface app for the Angular CLI", - "version": "7.4.21", + "version": "7.4.22", "repository": { "type": "git", "url": "https://github.com/nrwl/angular-console" @@ -61,10 +61,9 @@ } }, "dependencies": { - "semver": "5.6.0", "tmp": "^0.1.0", "node-pty-prebuilt": "0.7.6", "fast-glob": "^2.2.6", - "source-map-explorer": "^1.7.0" + "source-map-explorer": "1.8.0" } } diff --git a/libs/feature-extensions/src/lib/extensions/extensions.component.ts b/libs/feature-extensions/src/lib/extensions/extensions.component.ts index 8b1d928933..6dca817ee9 100644 --- a/libs/feature-extensions/src/lib/extensions/extensions.component.ts +++ b/libs/feature-extensions/src/lib/extensions/extensions.component.ts @@ -1,6 +1,8 @@ +import { Extension } from '@angular-console/schema'; +import { Task, TaskCollection, TaskCollections } from '@angular-console/ui'; +import { RouterNavigation } from '@angular-console/utils'; import { ChangeDetectionStrategy, Component } from '@angular/core'; import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; -import { Extension } from '@angular-console/schema'; import { combineLatest, Observable } from 'rxjs'; import { distinctUntilChanged, @@ -10,8 +12,7 @@ import { startWith, switchMap } from 'rxjs/operators'; -import { TaskCollection, TaskCollections, Task } from '@angular-console/ui'; -import { EXTENSIONS_POLLING, RouterNavigation } from '@angular-console/utils'; + import { WorkspaceAndExtensionsGQL } from '../generated/graphql'; interface ExtensionId { @@ -34,14 +35,9 @@ export class ExtensionsComponent { > = this.route.params.pipe( map(m => m.path), switchMap(path => { - return this.workspaceAndExtensionsGQL.watch( - { - path - }, - { - pollInterval: EXTENSIONS_POLLING - } - ).valueChanges; + return this.workspaceAndExtensionsGQL.fetch({ + path + }); }), map(r => { const availableExtensions: Array = (r as any).data diff --git a/libs/feature-generate/src/lib/schematics/schematics.component.ts b/libs/feature-generate/src/lib/schematics/schematics.component.ts index 6394667332..391e71f812 100644 --- a/libs/feature-generate/src/lib/schematics/schematics.component.ts +++ b/libs/feature-generate/src/lib/schematics/schematics.component.ts @@ -1,7 +1,8 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; -import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; +import { Schematic, SchematicCollection } from '@angular-console/schema'; import { Task, TaskCollection, TaskCollections } from '@angular-console/ui'; -import { SchematicCollection, Schematic } from '@angular-console/schema'; +import { RouterNavigation } from '@angular-console/utils'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { combineLatest, Observable } from 'rxjs'; import { distinctUntilChanged, @@ -11,7 +12,7 @@ import { startWith, switchMap } from 'rxjs/operators'; -import { RouterNavigation, SCHEMATICS_POLLING } from '@angular-console/utils'; + import { SchematicCollectionsGQL } from '../generated/graphql'; interface SchematicId { @@ -30,14 +31,9 @@ export class SchematicsComponent { > = this.route.params.pipe( map(m => m.path), switchMap(path => { - return this.schematicCollectionsGQL.watch( - { - path - }, - { - pollInterval: SCHEMATICS_POLLING - } - ).valueChanges; + return this.schematicCollectionsGQL.fetch({ + path + }); }), map(r => { const collections: Array = (r as any).data.workspace diff --git a/libs/feature-run/src/lib/targets/targets.component.ts b/libs/feature-run/src/lib/targets/targets.component.ts index c6cb68d82a..82f2bca701 100644 --- a/libs/feature-run/src/lib/targets/targets.component.ts +++ b/libs/feature-run/src/lib/targets/targets.component.ts @@ -1,16 +1,17 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; -import { ActivatedRoute, Router, NavigationEnd } from '@angular/router'; -import { Task, TaskCollection, TaskCollections } from '@angular-console/ui'; import { NpmScripts, Project } from '@angular-console/schema'; -import { Observable, combineLatest } from 'rxjs'; +import { Task, TaskCollection, TaskCollections } from '@angular-console/ui'; +import { RouterNavigation } from '@angular-console/utils'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; +import { combineLatest, Observable } from 'rxjs'; import { - map, - switchMap, + distinctUntilChanged, filter, + map, startWith, - distinctUntilChanged + switchMap } from 'rxjs/operators'; -import { RouterNavigation, TARGET_POLLING } from '@angular-console/utils'; + import { WorkspaceAndProjectsGQL } from '../generated/graphql'; interface Target { @@ -29,14 +30,9 @@ export class TargetsComponent { > = this.route.params.pipe( map(m => m.path), switchMap(path => { - return this.workspaceAndProjectsGQL.watch( - { - path - }, - { - pollInterval: TARGET_POLLING - } - ).valueChanges; + return this.workspaceAndProjectsGQL.fetch({ + path + }); }), map(r => { const sortedProjects = (r as any).data.workspace.projects diff --git a/libs/feature-workspaces/src/lib/projects/projects.component.ts b/libs/feature-workspaces/src/lib/projects/projects.component.ts index d9fd5e67ce..69464aa16b 100644 --- a/libs/feature-workspaces/src/lib/projects/projects.component.ts +++ b/libs/feature-workspaces/src/lib/projects/projects.component.ts @@ -52,10 +52,8 @@ export class ProjectsComponent implements OnInit { return combineLatest( this.workspaceGQL.watch({ path }, POLLING).valueChanges, this.workspaceSchematicsGQL - .watch({ path }, POLLING) - .valueChanges.pipe( - catchError(() => SCHEMATIC_COLLECTION_ERROR_RESPONSE) - ) + .fetch({ path }) + .pipe(catchError(() => SCHEMATIC_COLLECTION_ERROR_RESPONSE)) ); }), filter(([r1, r2]) => Boolean(r1 && r2)), diff --git a/libs/feature-workspaces/src/lib/workspace/workspace.component.ts b/libs/feature-workspaces/src/lib/workspace/workspace.component.ts index 362cf9e412..00ad86fc0a 100644 --- a/libs/feature-workspaces/src/lib/workspace/workspace.component.ts +++ b/libs/feature-workspaces/src/lib/workspace/workspace.component.ts @@ -1,10 +1,6 @@ import { IS_ELECTRON, IS_INTELLIJ } from '@angular-console/environment'; import { FADE_IN } from '@angular-console/ui'; -import { - BASIC_WORKSPACE_POLLING, - EditorSupport, - Settings -} from '@angular-console/utils'; +import { EditorSupport, Settings } from '@angular-console/utils'; import { animate, state, @@ -130,14 +126,9 @@ export class WorkspaceComponent implements OnDestroy { }> = this.route.params.pipe( map(m => m.path), switchMap(path => { - return this.basicWorkspaceGQL.watch( - { - path - }, - { - pollInterval: BASIC_WORKSPACE_POLLING - } - ).valueChanges; + return this.basicWorkspaceGQL.fetch({ + path + }); }), map((r: any) => r.data.workspace), publishReplay(1), diff --git a/libs/server/src/lib/api/run-command.ts b/libs/server/src/lib/api/run-command.ts index 36869279c6..4e24cf996a 100644 --- a/libs/server/src/lib/api/run-command.ts +++ b/libs/server/src/lib/api/run-command.ts @@ -108,14 +108,14 @@ export const nodePtyPseudoTerminalFactory: PseudoTerminalFactory = ({ cwd }; - const nodePtyPrebilt = require('node-pty-prebuilt'); + const nodePty = require('node-pty-prebuilt'); const commandRunning = isWsl - ? nodePtyPrebilt.spawn( + ? nodePty.spawn( 'wsl.exe', ['-e', 'bash', '-l', '-i', '-c', `${program} ${args.join(' ')}`], opts ) - : nodePtyPrebilt.spawn(program, args, opts); + : nodePty.spawn(program, args, opts); let currentCols = DEFAULT_COLS; let terminated = false; diff --git a/package.json b/package.json index 91376e5bf5..0ee632bf1b 100644 --- a/package.json +++ b/package.json @@ -80,8 +80,7 @@ "@nrwl/nx": "7.7.2", "ij-rpc-client": "^0.3.2", "node-pty-prebuilt": "0.7.6", - "semver": "5.6.0", - "source-map-explorer": "^1.7.0", + "source-map-explorer": "^1.8.0", "stylelint": "^9.10.1", "stylelint-config-standard": "^18.2.0", "tmp": "^0.1.0" diff --git a/tsconfig.json b/tsconfig.json index 3e9082002c..3904d6850c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,13 +13,13 @@ "noUnusedLocals": true, "noUnusedParameters": true, "allowUnreachableCode": false, - "allowUnusedLabels": false, + "allowUnusedLabels": true, "noImplicitAny": true, "noImplicitThis": true, "strictFunctionTypes": true, "typeRoots": [ "node_modules/@types", - "node_modules/node-pty-prebuilt/typings" + "node_modules/node-pty/typings" ], "downlevelIteration": true, "lib": ["es2017", "dom", "esnext.asynciterable"], diff --git a/yarn.lock b/yarn.lock index 458f51f0ae..17e92e847a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -659,16 +659,6 @@ ts-simple-ast "^21.0.0" uuid "3.3.2" -"@ngrx/schematics@7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@ngrx/schematics/-/schematics-7.2.0.tgz#2802a6f7533904967416de09c306e4149f58d1e6" - integrity sha512-BG1Sg3bWjrJBmwbCgmrjmaeWwqOHcQsZeavWx1oCkrrSR+7u2h6mwzIFiVZUqhs8DQw5THr91pe6rtpHKcQ6Yw== - -"@ngrx/store-devtools@7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@ngrx/store-devtools/-/store-devtools-7.2.0.tgz#91e2287f0d67d4e79c51bd3d649a5013e71bbcad" - integrity sha512-t+8K1IG8+MvFqLIuRSM+ZE1EkZIuUExJ0JsqZR4r4K3MRPRoGy1ZqlStBWYaYLumEToesiCOGxuJYQ4zyVwlZg== - "@ngtools/json-schema@^1.1.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@ngtools/json-schema/-/json-schema-1.1.0.tgz#c3a0c544d62392acc2813a42c8a0dc6f58f86922" @@ -10903,9 +10893,9 @@ postcss@7.0.14, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.13, postcss@^7.0.14 supports-color "^6.1.0" prebuild-install@^5.0.0: - version "5.2.5" - resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.2.5.tgz#c7485911fe98950b7f7cd15bb9daee11b875cc44" - integrity sha512-6uZgMVg7yDfqlP5CPurVhtq3hUKBFNufiar4J5hZrlHTo59DDBEtyxw01xCdFss9j0Zb9+qzFVf/s4niayba3w== + version "5.3.0" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.3.0.tgz#58b4d8344e03590990931ee088dd5401b03004c8" + integrity sha512-aaLVANlj4HgZweKttFNUVNRxDukytuIuxeK2boIMHjagNJCiVKWFsKF4tCE3ql3GbrD2tExPQ7/pwtEJcHNZeg== dependencies: detect-libc "^1.0.3" expand-template "^2.0.3" @@ -12405,7 +12395,7 @@ source-list-map@~0.1.7: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.8.tgz#c550b2ab5427f6b3f21f5afead88c4f5587b2106" integrity sha1-xVCyq1Qn9rPyH1r+rYjE9Vh7IQY= -source-map-explorer@^1.7.0: +source-map-explorer@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/source-map-explorer/-/source-map-explorer-1.8.0.tgz#61cb8ffaff65d10ae2e6b60228fc625f523c41ff" integrity sha512-1Q0lNSw5J7pChKmjqniOCLbvLFi4KJfrtixk99CzvRcqFiGBJvRHMrw0PjLwKOvbuAo8rNOukJhEPA0Nj85xDw==