Skip to content

Commit 1d29d2d

Browse files
committed
fix(@angular-devkit/schematics): show spinner for package install
1 parent 07fad74 commit 1d29d2d

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"minimatch": "^3.0.4",
130130
"minimist": "^1.2.0",
131131
"npm-registry-client": "8.6.0",
132+
"ora": "^4.0.2",
132133
"pacote": "^9.2.3",
133134
"pidtree": "^0.3.0",
134135
"pidusage": "^2.0.17",

packages/angular_devkit/schematics/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ ts_library(
9191
"//packages/angular_devkit/core",
9292
"//packages/angular_devkit/core:node",
9393
"@npm//@types/node",
94+
"@npm//ora",
9495
"@npm//rxjs",
9596
"@npm//tslint",
9697
"@npm//typescript",

packages/angular_devkit/schematics/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
],
1515
"dependencies": {
1616
"@angular-devkit/core": "0.0.0",
17+
"ora": "4.0.2",
1718
"rxjs": "6.5.3"
1819
}
1920
}

packages/angular_devkit/schematics/tasks/node-package/executor.ts

+11-7
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
*/
88
import { BaseException } from '@angular-devkit/core';
99
import { SpawnOptions, spawn } from 'child_process';
10+
import * as ora from 'ora';
1011
import * as path from 'path';
1112
import { Observable } from 'rxjs';
12-
import { TaskExecutor } from '../../src';
13+
import { TaskExecutor, UnsuccessfulWorkflowExecution } from '../../src';
1314
import { NodePackageTaskFactoryOptions, NodePackageTaskOptions } from './options';
1415

1516
type PackageManagerProfile = {
@@ -99,21 +100,24 @@ export default function(
99100
}
100101

101102
return new Observable(obs => {
102-
// tslint:disable-next-line: no-console
103-
console.log('Installing packages...');
103+
const spinner = ora({
104+
text: 'Installing packages...',
105+
// Workaround for https://github.com/sindresorhus/ora/issues/136.
106+
discardStdin: process.platform != 'win32',
107+
}).start();
104108
const childProcess = spawn(taskPackageManagerName, args, spawnOptions)
105109
.on('close', (code: number) => {
106110
if (code === 0) {
107-
// tslint:disable-next-line: no-console
108-
console.log('Packages installed successfully.');
111+
spinner.succeed('Packages installed successfully.');
112+
spinner.stop();
109113
obs.next();
110114
obs.complete();
111115
} else {
112116
if (options.hideOutput) {
113117
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
114118
}
115-
const message = 'Package install failed, see above.';
116-
obs.error(new Error(message));
119+
spinner.fail('Package install failed, see above.');
120+
obs.error(new UnsuccessfulWorkflowExecution());
117121
}
118122
});
119123
if (options.hideOutput) {

yarn.lock

+49
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,11 @@ cli-cursor@^3.1.0:
28052805
dependencies:
28062806
restore-cursor "^3.1.0"
28072807

2808+
cli-spinners@^2.2.0:
2809+
version "2.2.0"
2810+
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.2.0.tgz#e8b988d9206c692302d8ee834e7a85c0144d8f77"
2811+
integrity sha512-tgU3fKwzYjiLEQgPMD9Jt+JjHVL9kW93FiIMX/l7rivvOD4/LL0Mf7gda3+4U2KJBloybwgj5KEoQgGRioMiKQ==
2812+
28082813
cli-width@^2.0.0:
28092814
version "2.2.0"
28102815
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
@@ -2844,6 +2849,11 @@ clone-response@^1.0.2:
28442849
dependencies:
28452850
mimic-response "^1.0.0"
28462851

2852+
clone@^1.0.2:
2853+
version "1.0.4"
2854+
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
2855+
integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4=
2856+
28472857
clone@^2.1.1, clone@^2.1.2:
28482858
version "2.1.2"
28492859
resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f"
@@ -3628,6 +3638,13 @@ default-require-extensions@^2.0.0:
36283638
dependencies:
36293639
strip-bom "^3.0.0"
36303640

3641+
defaults@^1.0.3:
3642+
version "1.0.3"
3643+
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
3644+
integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=
3645+
dependencies:
3646+
clone "^1.0.2"
3647+
36313648
defer-to-connect@^1.0.1:
36323649
version "1.0.2"
36333650
resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.0.2.tgz#4bae758a314b034ae33902b5aac25a8dd6a8633e"
@@ -5603,6 +5620,11 @@ is-installed-globally@^0.1.0:
56035620
global-dirs "^0.1.0"
56045621
is-path-inside "^1.0.0"
56055622

5623+
is-interactive@^1.0.0:
5624+
version "1.0.0"
5625+
resolved "https://registry.yarnpkg.com/is-interactive/-/is-interactive-1.0.0.tgz#cea6e6ae5c870a7b0a0004070b7b587e0252912e"
5626+
integrity sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==
5627+
56065628
is-module@^1.0.0:
56075629
version "1.0.0"
56085630
resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591"
@@ -6677,6 +6699,13 @@ [email protected], lodash@^4.16.6, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.1
66776699
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
66786700
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
66796701

6702+
log-symbols@^3.0.0:
6703+
version "3.0.0"
6704+
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4"
6705+
integrity sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==
6706+
dependencies:
6707+
chalk "^2.4.2"
6708+
66806709
log4js@^3.0.0:
66816710
version "3.0.6"
66826711
resolved "https://registry.yarnpkg.com/log4js/-/log4js-3.0.6.tgz#e6caced94967eeeb9ce399f9f8682a4b2b28c8ff"
@@ -7681,6 +7710,19 @@ optionator@^0.8.1:
76817710
type-check "~0.3.2"
76827711
wordwrap "~1.0.0"
76837712

7713+
[email protected], ora@^4.0.2:
7714+
version "4.0.2"
7715+
resolved "https://registry.yarnpkg.com/ora/-/ora-4.0.2.tgz#0e1e68fd45b135d28648b27cf08081fa6e8a297d"
7716+
integrity sha512-YUOZbamht5mfLxPmk4M35CD/5DuOkAacxlEUbStVXpBAt4fyhBf+vZHI/HRkI++QUp3sNoeA2Gw4C+hi4eGSig==
7717+
dependencies:
7718+
chalk "^2.4.2"
7719+
cli-cursor "^3.1.0"
7720+
cli-spinners "^2.2.0"
7721+
is-interactive "^1.0.0"
7722+
log-symbols "^3.0.0"
7723+
strip-ansi "^5.2.0"
7724+
wcwidth "^1.0.1"
7725+
76847726
original@^1.0.0:
76857727
version "1.0.2"
76867728
resolved "https://registry.yarnpkg.com/original/-/original-1.0.2.tgz#e442a61cffe1c5fd20a65f3261c26663b303f25f"
@@ -10917,6 +10959,13 @@ wbuf@^1.1.0, wbuf@^1.7.3:
1091710959
dependencies:
1091810960
minimalistic-assert "^1.0.0"
1091910961

10962+
wcwidth@^1.0.1:
10963+
version "1.0.1"
10964+
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
10965+
integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=
10966+
dependencies:
10967+
defaults "^1.0.3"
10968+
1092010969
1092110970
version "2.1.0"
1092210971
resolved "https://registry.yarnpkg.com/webdriver-js-extender/-/webdriver-js-extender-2.1.0.tgz#57d7a93c00db4cc8d556e4d3db4b5db0a80c3bb7"

0 commit comments

Comments
 (0)