Skip to content

Commit 4082f53

Browse files
committed
Merge remote-tracking branch 'remotes/origin/master' into print-tag-name
2 parents 7bcee66 + 9cf4692 commit 4082f53

44 files changed

Lines changed: 743 additions & 269 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/api-extractor/src/analyzer/test/PackageMetadataManager.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('PackageMetadataManager', () => {
3535
packageJson
3636
} = getPackageMetadata('package-inferred-from-tsdoc-metadata');
3737
expect(PackageMetadataManager.resolveTsdocMetadataPath(packageFolder, packageJson, tsdocMetadataPath))
38-
.toBe(path.resolve(packageFolder, packageJson.tsdocMetadata));
38+
.toBe(path.resolve(packageFolder, packageJson.tsdocMetadata as string));
3939
});
4040
});
4141
describe('given a package.json where the field "typings" is defined and "tsdocMetadata" is not defined', () => {

‎apps/rush-lib/package.json‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
"@microsoft/ts-command-line": "4.2.6",
2828
"@pnpm/link-bins": "~1.0.1",
2929
"@pnpm/logger": "~1.0.1",
30+
"@types/inquirer": "0.0.43",
3031
"@yarnpkg/lockfile": "~1.0.2",
3132
"builtins": "~1.0.3",
33+
"cli-table": "~0.3.1",
3234
"colors": "~1.2.1",
3335
"git-repo-info": "~2.1.0",
3436
"glob": "~7.0.5",
3537
"glob-escape": "~0.0.1",
3638
"https-proxy-agent": "~2.2.1",
37-
"@types/inquirer": "0.0.43",
3839
"inquirer": "~6.2.0",
3940
"js-yaml": "~3.13.1",
4041
"lodash": "~4.17.5",
@@ -49,18 +50,18 @@
4950
"z-schema": "~3.18.3"
5051
},
5152
"devDependencies": {
52-
"@microsoft/rush-stack-compiler-3.2": "0.3.19",
5353
"@microsoft/node-library-build": "6.0.67",
54-
"@types/node": "8.5.8",
55-
"@types/node-fetch": "1.6.9",
56-
"@types/tar": "4.0.0",
57-
"@types/z-schema": "3.16.31",
58-
"gulp": "~3.9.1",
54+
"@microsoft/rush-stack-compiler-3.2": "0.3.19",
5955
"@types/glob": "5.0.30",
6056
"@types/jest": "23.3.11",
6157
"@types/js-yaml": "3.12.1",
6258
"@types/lodash": "4.14.116",
6359
"@types/minimatch": "2.0.29",
64-
"@types/semver": "5.3.33"
60+
"@types/node": "8.5.8",
61+
"@types/node-fetch": "1.6.9",
62+
"@types/semver": "5.3.33",
63+
"@types/tar": "4.0.0",
64+
"@types/z-schema": "3.16.31",
65+
"gulp": "~3.9.1"
6566
}
6667
}

‎apps/rush-lib/src/cli/RushCommandLineParser.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { UpdateAction } from './actions/UpdateAction';
2222
import { InstallAction } from './actions/InstallAction';
2323
import { InitAction } from './actions/InitAction';
2424
import { LinkAction } from './actions/LinkAction';
25+
import { ListAction } from './actions/ListAction';
2526
import { PublishAction } from './actions/PublishAction';
2627
import { PurgeAction } from './actions/PurgeAction';
2728
import { UnlinkAction } from './actions/UnlinkAction';
@@ -140,6 +141,7 @@ export class RushCommandLineParser extends CommandLineParser {
140141
this.addAction(new InstallAction(this));
141142
this.addAction(new InitAction(this));
142143
this.addAction(new LinkAction(this));
144+
this.addAction(new ListAction(this));
143145
this.addAction(new PublishAction(this));
144146
this.addAction(new PurgeAction(this));
145147
this.addAction(new ScanAction(this));
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { BaseRushAction } from './BaseRushAction';
2+
import { RushCommandLineParser } from '../RushCommandLineParser';
3+
import { CommandLineFlagParameter } from '@microsoft/ts-command-line';
4+
import { RushConfigurationProject } from '../../api/RushConfigurationProject';
5+
import * as Table from 'cli-table';
6+
7+
export class ListAction extends BaseRushAction {
8+
private _version: CommandLineFlagParameter;
9+
private _path: CommandLineFlagParameter;
10+
private _fullPath: CommandLineFlagParameter;
11+
12+
constructor(parser: RushCommandLineParser) {
13+
super({
14+
actionName: 'list',
15+
summary: 'List package information for all projects in the repo',
16+
documentation:
17+
'List package names, and optionally version (--version) and ' +
18+
'path (--path) or full path (--full-path), for projects in the ' +
19+
'current rush config.',
20+
parser
21+
});
22+
}
23+
24+
protected onDefineParameters(): void {
25+
this._version = this.defineFlagParameter({
26+
parameterLongName: '--version',
27+
parameterShortName: '-v',
28+
description: 'If this flag is specified, the project version will be ' +
29+
'displayed in a column along with the package name.'
30+
});
31+
32+
this._path = this.defineFlagParameter({
33+
parameterLongName: '--path',
34+
parameterShortName: '-p',
35+
description: 'If this flag is specified, the project path will be ' +
36+
'displayed in a column along with the package name.'
37+
});
38+
39+
this._fullPath = this.defineFlagParameter({
40+
parameterLongName: '--full-path',
41+
parameterShortName: '-f',
42+
description: 'If this flag is specified, the project full path will ' +
43+
'be displayed in a column along with the package name.'
44+
});
45+
}
46+
47+
protected run(): Promise<void> {
48+
return Promise.resolve().then(() => {
49+
const allPackages: Map<string, RushConfigurationProject> = this.rushConfiguration.projectsByName;
50+
if (this._version.value || this._path.value || this._fullPath.value) {
51+
this._printListTable(allPackages);
52+
} else {
53+
this._printList(allPackages);
54+
}
55+
});
56+
}
57+
58+
private _printList(allPackages: Map<string, RushConfigurationProject>): void {
59+
allPackages.forEach((_config: RushConfigurationProject, name: string) => {
60+
console.log(name);
61+
});
62+
}
63+
64+
private _printListTable(allPackages: Map<string, RushConfigurationProject>): void {
65+
const tableHeader: string[] = ['Project'];
66+
if (this._version.value) {
67+
tableHeader.push('Version');
68+
}
69+
if (this._path.value) {
70+
tableHeader.push('Path');
71+
}
72+
if (this._fullPath.value) {
73+
tableHeader.push('Full Path');
74+
}
75+
const table: Table = new Table({
76+
head: tableHeader
77+
});
78+
79+
allPackages.forEach((config: RushConfigurationProject, name: string) => {
80+
const packageRow: string[] = [name];
81+
if (this._version.value) {
82+
packageRow.push(config.packageJson.version);
83+
}
84+
if (this._path.value) {
85+
packageRow.push(config.projectRelativeFolder);
86+
}
87+
if (this._fullPath.value) {
88+
packageRow.push(config.projectFolder);
89+
}
90+
table.push(packageRow);
91+
});
92+
console.log(table.toString());
93+
}
94+
}

‎apps/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Positional arguments:
2626
according to the shrinkwrap file
2727
init Initializes a new repository to be managed by Rush
2828
link Create node_modules symlinks for all projects
29+
list List package information for all projects in the repo
2930
publish Reads and processes package publishing change requests
3031
generated by \\"rush change\\".
3132
purge For diagnostic purposes, use this command to delete caches
@@ -318,6 +319,23 @@ Optional arguments:
318319
"
319320
`;
320321
322+
exports[`CommandLineHelp prints the help for each action: list 1`] = `
323+
"usage: rush list [-h] [-v] [-p] [-f]
324+
325+
List package names, and optionally version (--version) and path (--path) or
326+
full path (--full-path), for projects in the current rush config.
327+
328+
Optional arguments:
329+
-h, --help Show this help message and exit.
330+
-v, --version If this flag is specified, the project version will be
331+
displayed in a column along with the package name.
332+
-p, --path If this flag is specified, the project path will be
333+
displayed in a column along with the package name.
334+
-f, --full-path If this flag is specified, the project full path will be
335+
displayed in a column along with the package name.
336+
"
337+
`;
338+
321339
exports[`CommandLineHelp prints the help for each action: publish 1`] = `
322340
"usage: rush publish [-h] [-a] [-b BRANCH] [-p] [--add-commit-details]
323341
[--regenerate-changelogs] [-r REGISTRY] [-n TOKEN]

‎apps/rush-lib/src/logic/taskRunner/ProjectTask.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,17 @@ export class ProjectTask implements ITaskDefinition {
164164
);
165165

166166
// Hook into events, in order to get live streaming of build log
167-
task.stdout.on('data', (data: string) => {
168-
writer.write(data);
169-
});
170-
171-
task.stderr.on('data', (data: string) => {
172-
writer.writeError(data);
173-
this._hasWarningOrError = true;
174-
});
167+
if (task.stdout !== null) {
168+
task.stdout.on('data', (data: string) => {
169+
writer.write(data);
170+
});
171+
}
172+
if (task.stderr !== null) {
173+
task.stderr.on('data', (data: string) => {
174+
writer.writeError(data);
175+
this._hasWarningOrError = true;
176+
});
177+
}
175178

176179
return new Promise((resolve: (status: TaskStatus) => void, reject: (error: TaskError) => void) => {
177180
task.on('close', (code: number) => {

‎apps/rush-lib/src/utilities/Utilities.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
FileConstants
1515
} from '@microsoft/node-core-library';
1616
import { RushConfiguration } from '../api/RushConfiguration';
17+
import { Stream } from 'stream';
1718

1819
export interface IEnvironment {
1920
// NOTE: the process.env doesn't actually support "undefined" as a value.
@@ -107,9 +108,13 @@ export class Utilities {
107108
const unresolvedUserFolder: string | undefined = process.env[
108109
(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'
109110
];
111+
const dirError: string = 'Unable to determine the current user\'s home directory';
112+
if (unresolvedUserFolder === undefined) {
113+
throw new Error(dirError);
114+
}
110115
const homeFolder: string = path.resolve(unresolvedUserFolder);
111116
if (!FileSystem.exists(homeFolder)) {
112-
throw new Error('Unable to determine the current user\'s home directory');
117+
throw new Error(dirError);
113118
}
114119

115120
return homeFolder;
@@ -680,7 +685,7 @@ export class Utilities {
680685
*/
681686
private static _executeCommandInternal(
682687
command: string, args: string[], workingDirectory: string,
683-
stdio: (string|number)[] | undefined,
688+
stdio: 'pipe'|'ignore'|'inherit'|(number|'pipe'|'ignore'|'inherit'|'ipc'|Stream|null|undefined)[]|undefined,
684689
environment?: IEnvironment,
685690
keepEnvironment: boolean = false
686691
): child_process.SpawnSyncReturns<Buffer> {

‎apps/rush-lib/tsconfig.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.2/includes/tsconfig-node.json",
33
"compilerOptions": {
44
"types": [
5-
"jest"
5+
"jest",
6+
"node"
67
]
78
},
89
"include": [

‎apps/rush/tsconfig.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.2/includes/tsconfig-node.json",
33
"compilerOptions": {
44
"types": [
5-
"mocha"
5+
"mocha",
6+
"node"
67
]
78
}
89
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "",
5+
"packageName": "@microsoft/api-documenter",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/api-documenter",
10+
"email": "halfnibble@users.noreply.github.com"
11+
}

0 commit comments

Comments
 (0)