Skip to content

Commit

Permalink
fix(@angular-devkit/schematics): hide install output by default
Browse files Browse the repository at this point in the history
Current output:
```
kamik@RED-X1C6 MINGW64 /d/sandbox/latest-app (master)
$ ng update @angular/cli --next --force
Using package manager: 'yarn'
Collecting installed dependencies...
Found 30 dependencies.
Fetching dependency metadata from registry...
                  Package "@angular-devkit/build-angular" has a missing peer dependency of "@angular/localize" @ "^9.0.0-next.11".
    Updating package.json with dependency @angular/cli @ "9.0.0-next.15" (was "9.0.0-next.14")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.900.0-next.15" (was "0.900.0-next.14")...
    Updating package.json with dependency typescript @ "3.6.4" (was "3.5.3")...
UPDATE package.json (1353 bytes)
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @ngtools/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular/[email protected]: The engine "pnpm" appears to be invalid.
warning @schematics/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @schematics/[email protected]: The engine "pnpm" appears to be invalid.
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/animations/browser/testing : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/common/http/testing : es2015 as esm2015
Compiling @angular/router/testing : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
```

New success output:
```
kamik@RED-X1C6 MINGW64 /d/sandbox/latest-app (master)
$ ng update @angular/cli --next --force
Using package manager: 'yarn'
Collecting installed dependencies...
Found 30 dependencies.
Fetching dependency metadata from registry...
                  Package "@angular-devkit/build-angular" has a missing peer dependency of "@angular/localize" @ "^9.0.0-next.11".
    Updating package.json with dependency @angular/cli @ "9.0.0-next.15" (was "9.0.0-next.14")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.900.0-next.15" (was "0.900.0-next.14")...
    Updating package.json with dependency typescript @ "3.6.4" (was "3.5.3")...
UPDATE package.json (1353 bytes)
Installing packages...
Packages installed successfully.
```

New error output:
```
kamik@RED-X1C6 MINGW64 /d/sandbox/latest-app (master)
$ ng update @angular/cli --next --force
Using package manager: 'yarn'
Collecting installed dependencies...
Found 30 dependencies.
Fetching dependency metadata from registry...
                  Package "@angular-devkit/build-angular" has a missing peer dependency of "@angular/localize" @ "^9.0.0-next.11".
    Updating package.json with dependency @angular/cli @ "9.0.0-next.15" (was "9.0.0-next.14")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.900.0-next.15" (was "0.900.0-next.14")...
    Updating package.json with dependency typescript @ "3.6.4" (was "3.5.3")...
UPDATE package.json (1353 bytes)
Installing packages...
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @ngtools/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular/[email protected]: The engine "pnpm" appears to be invalid.
warning @schematics/[email protected]: The engine "pnpm" appears to be invalid.
warning @angular-devkit/[email protected]: The engine "pnpm" appears to be invalid.
warning @schematics/[email protected]: The engine "pnpm" appears to be invalid.
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/animations/browser/testing : es2015 as esm2015
Compiling @angular/core/testing : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/common/testing : es2015 as esm2015
Compiling @angular/platform-browser/testing : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @angular/common/http/testing : es2015 as esm2015
Compiling @angular/platform-browser-dynamic/testing : es2015 as esm2015
Compiling @angular/router/testing : es2015 as esm2015
Package install failed, see above.
```
  • Loading branch information
filipesilva authored and vikerman committed Oct 29, 2019
1 parent 5df7767 commit 4d23a0f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions etc/api/angular_devkit/schematics/tasks/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export declare class NodePackageInstallTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
hideOutput: boolean;
packageManager?: string;
packageName?: string;
quiet: boolean;
Expand Down
20 changes: 16 additions & 4 deletions packages/angular_devkit/schematics/tasks/node-package/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ export default function(
taskPackageManagerName = options.packageManager;
}

const outputStream = process.stdout;
const errorStream = process.stderr;
const bufferedOutput: {stream: NodeJS.WriteStream, data: Buffer}[] = [];
const spawnOptions: SpawnOptions = {
stdio: [ process.stdin, outputStream, errorStream ],
stdio: !!options.hideOutput ? 'pipe' : 'inherit',
shell: true,
cwd: path.join(rootDirectory, options.workingDirectory || ''),
};
Expand All @@ -100,16 +99,29 @@ export default function(
}

return new Observable(obs => {
spawn(taskPackageManagerName, args, spawnOptions)
// tslint:disable-next-line: no-console
console.log('Installing packages...');
const childProcess = spawn(taskPackageManagerName, args, spawnOptions)
.on('close', (code: number) => {
if (code === 0) {
// tslint:disable-next-line: no-console
console.log('Packages installed successfully.');
obs.next();
obs.complete();
} else {
if (options.hideOutput) {
bufferedOutput.forEach(({ stream, data }) => stream.write(data));
}
const message = 'Package install failed, see above.';
obs.error(new Error(message));
}
});
if (options.hideOutput) {
childProcess.stdout.on('data', (data: Buffer) =>
bufferedOutput.push({ stream: process.stdout, data: data }));
childProcess.stderr.on('data', (data: Buffer) =>
bufferedOutput.push({ stream: process.stderr, data: data }));
}
});

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export class NodePackageInstallTaskOptions {
packageName: string;
workingDirectory: string;
quiet: boolean;
hideOutput: boolean;
}

export class NodePackageInstallTask implements TaskConfigurationGenerator<NodePackageTaskOptions> {
quiet = true;
hideOutput = true;
workingDirectory?: string;
packageManager?: string;
packageName?: string;
Expand All @@ -30,6 +32,9 @@ export class NodePackageInstallTask implements TaskConfigurationGenerator<NodePa
if (options.quiet != undefined) {
this.quiet = options.quiet;
}
if (options.hideOutput != undefined) {
this.hideOutput = options.hideOutput;
}
if (options.workingDirectory != undefined) {
this.workingDirectory = options.workingDirectory;
}
Expand All @@ -48,6 +53,7 @@ export class NodePackageInstallTask implements TaskConfigurationGenerator<NodePa
options: {
command: 'install',
quiet: this.quiet,
hideOutput: this.hideOutput,
workingDirectory: this.workingDirectory,
packageManager: this.packageManager,
packageName: this.packageName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface NodePackageTaskFactoryOptions {
export interface NodePackageTaskOptions {
command: string;
quiet?: boolean;
hideOutput?: boolean;
workingDirectory?: string;
packageName?: string;
packageManager?: string;
Expand Down

0 comments on commit 4d23a0f

Please sign in to comment.