Skip to content

Commit 331075d

Browse files
committed
Merge branch 'master' into ianc/tsc-in-wbt
2 parents 90d32a5 + b5e4042 commit 331075d

20 files changed

Lines changed: 352 additions & 214 deletions

File tree

‎apps/rush-lib/src/cli/actions/PublishAction.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,11 @@ export class PublishAction extends BaseRushAction {
388388
const destFolder: string = this._releaseFolder.value ?
389389
this._releaseFolder.value : path.join(this.rushConfiguration.commonTempFolder, 'artifacts', 'packages');
390390

391-
FileSystem.move(tarballPath, path.join(destFolder, tarballName), { overwrite: true });
391+
FileSystem.move({
392+
sourcePath: tarballPath,
393+
destinationPath: path.join(destFolder, tarballName),
394+
overwrite: true
395+
});
392396
}
393397
}
394398

@@ -417,7 +421,10 @@ export class PublishAction extends BaseRushAction {
417421
const toApiFolderPath: string = path.join(project.projectFolder, toApiFolder);
418422
if (FileSystem.exists(fromApiFolderPath) && FileSystem.exists(toApiFolderPath)) {
419423
FileSystem.readFolder(fromApiFolderPath).forEach(fileName => {
420-
FileSystem.copyFile(path.join(fromApiFolderPath, fileName), path.join(toApiFolderPath, fileName));
424+
FileSystem.copyFile({
425+
sourcePath: path.join(fromApiFolderPath, fileName),
426+
destinationPath: path.join(toApiFolderPath, fileName)
427+
});
421428
console.log(`Copied file ${fileName} from ${fromApiFolderPath} to ${toApiFolderPath}`);
422429
});
423430
}

‎apps/rush-lib/src/logic/InstallManager.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ export class InstallManager {
333333
}
334334
}
335335

336-
FileSystem.createSymbolicLinkJunction(packageManagerToolFolder, localPackageManagerToolFolder);
336+
FileSystem.createSymbolicLinkJunction({
337+
linkTargetPath: packageManagerToolFolder,
338+
newLinkPath: localPackageManagerToolFolder
339+
});
337340

338341
lock.release();
339342
});
@@ -976,17 +979,17 @@ export class InstallManager {
976979
}
977980

978981
/**
979-
* Copies the file "sourcePath" to "targetPath", overwriting the target file location.
982+
* Copies the file "sourcePath" to "destinationPath", overwriting the target file location.
980983
* If the source file does not exist, then the target file is deleted.
981984
*/
982-
private _syncFile(sourcePath: string, targetPath: string): void {
985+
private _syncFile(sourcePath: string, destinationPath: string): void {
983986
if (FileSystem.exists(sourcePath)) {
984-
console.log('Updating ' + targetPath);
985-
FileSystem.copyFile(sourcePath, targetPath);
987+
console.log('Updating ' + destinationPath);
988+
FileSystem.copyFile({sourcePath, destinationPath});
986989
} else {
987-
if (FileSystem.exists(targetPath)) {
988-
console.log('Deleting ' + targetPath);
989-
FileSystem.deleteFile(targetPath);
990+
if (FileSystem.exists(destinationPath)) {
991+
console.log('Deleting ' + destinationPath);
992+
FileSystem.deleteFile(destinationPath);
990993
}
991994
}
992995
}

‎apps/rush-lib/src/logic/StandardScriptUpdater.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ export class StandardScriptUpdater {
7474
+ ' for this Rush version. Please run "rush update" and commit the changes.');
7575
} else {
7676
console.log(`Script is out of date; updating "${targetFilePath}"`);
77-
FileSystem.copyFile(sourceFilePath, targetFilePath);
77+
FileSystem.copyFile({
78+
sourcePath: sourceFilePath,
79+
destinationPath: targetFilePath
80+
});
7881
}
7982
}
8083

‎apps/rush-lib/src/logic/base/BaseLinkManager.ts‎

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as fs from 'fs';
66
import * as os from 'os';
77
import * as path from 'path';
88

9-
import { FileSystem } from '@microsoft/node-core-library';
9+
import { FileSystem, IFileSystemCreateLinkOptions } from '@microsoft/node-core-library';
1010

1111
import { RushConfiguration } from '../../api/RushConfiguration';
1212
import { Utilities } from '../../utilities/Utilities';
@@ -18,24 +18,37 @@ export enum SymlinkKind {
1818
Directory
1919
}
2020

21+
export interface IBaseLinkManagerCreateSymlinkOptions extends IFileSystemCreateLinkOptions {
22+
symlinkKind: SymlinkKind;
23+
}
24+
2125
export abstract class BaseLinkManager {
2226
protected _rushConfiguration: RushConfiguration;
2327

24-
protected static _createSymlink(linkTarget: string, linkSource: string, symlinkKind: SymlinkKind): void {
25-
FileSystem.ensureFolder(path.dirname(linkSource));
28+
protected static _createSymlink(options: IBaseLinkManagerCreateSymlinkOptions): void {
29+
FileSystem.ensureFolder(path.dirname(options.newLinkPath));
2630

27-
if (symlinkKind === SymlinkKind.Directory) {
31+
if (options.symlinkKind === SymlinkKind.Directory) {
2832
// For directories, we use a Windows "junction". On Unix, this produces a regular symlink.
29-
FileSystem.createSymbolicLinkJunction(linkTarget, linkSource);
33+
FileSystem.createSymbolicLinkJunction({
34+
linkTargetPath: options.linkTargetPath,
35+
newLinkPath: options.newLinkPath
36+
});
3037
} else {
3138
if (process.platform === 'win32') {
3239
// For files, we use a Windows "hard link", because creating a symbolic link requires
3340
// administrator permission.
34-
FileSystem.createHardLink(linkTarget, linkSource);
41+
FileSystem.createHardLink({
42+
linkTargetPath: options.linkTargetPath,
43+
newLinkPath: options.newLinkPath
44+
});
3545
} else {
3646
// However hard links seem to cause build failures on Mac, so for all other operating systems
3747
// we use symbolic links for this case.
38-
FileSystem.createSymbolicLinkFile(linkTarget, linkSource);
48+
FileSystem.createSymbolicLinkFile({
49+
linkTargetPath: options.linkTargetPath,
50+
newLinkPath: options.newLinkPath
51+
});
3952
}
4053
}
4154
}
@@ -91,10 +104,11 @@ export abstract class BaseLinkManager {
91104

92105
if (localPackage.children.length === 0) {
93106
// If there are no children, then we can symlink the entire folder
94-
BaseLinkManager._createSymlink(
95-
localPackage.symlinkTargetFolderPath,
96-
localPackage.folderPath,
97-
SymlinkKind.Directory);
107+
BaseLinkManager._createSymlink({
108+
linkTargetPath: localPackage.symlinkTargetFolderPath,
109+
newLinkPath: localPackage.folderPath,
110+
symlinkKind: SymlinkKind.Directory
111+
});
98112
} else {
99113
// If there are children, then we need to symlink each item in the folder individually
100114
Utilities.createFolderWithRetry(localPackage.folderPath);
@@ -126,7 +140,11 @@ export abstract class BaseLinkManager {
126140
symlinkKind = SymlinkKind.Directory;
127141
}
128142

129-
BaseLinkManager._createSymlink(linkTarget, linkSource, symlinkKind);
143+
BaseLinkManager._createSymlink({
144+
linkTargetPath: linkTarget,
145+
newLinkPath: linkSource,
146+
symlinkKind
147+
});
130148
}
131149
}
132150
}

‎apps/rush-lib/src/logic/npm/NpmLinkManager.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,11 @@ export class NpmLinkManager extends BaseLinkManager {
324324
const projectBinFolder: string = path.join(localProjectPackage.folderPath, 'node_modules', '.bin');
325325

326326
if (FileSystem.exists(commonBinFolder)) {
327-
NpmLinkManager._createSymlink(commonBinFolder, projectBinFolder, SymlinkKind.Directory);
327+
NpmLinkManager._createSymlink({
328+
linkTargetPath: commonBinFolder,
329+
newLinkPath: projectBinFolder,
330+
symlinkKind: SymlinkKind.Directory
331+
});
328332
}
329333
}
330334
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class AsyncRecycler {
7474
}
7575

7676
Utilities.retryUntilTimeout(
77-
() => FileSystem.move(folderPath, newFolderPath),
77+
() => FileSystem.move({ sourcePath: folderPath, destinationPath: newFolderPath }),
7878
maxWaitTimeMs,
7979
(e) => new Error(`Error: ${e}${os.EOL}Often this is caused by a file lock ` +
8080
'from a process like the virus scanner.'),
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/gulp-core-build",
5+
"comment": "Update to use new node-core-library API",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/gulp-core-build",
10+
"email": "pgonzal@users.noreply.github.com"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/node-core-library",
5+
"comment": "(Breaking API change) The FileSystem move/copy/createLink operations now require the source/target parameters to be explicitly specified, to avoid confusion",
6+
"type": "major"
7+
}
8+
],
9+
"packageName": "@microsoft/node-core-library",
10+
"email": "pgonzal@users.noreply.github.com"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "Fix regression causing \"ERROR: EEXIST: file already exists\"",
5+
"packageName": "@microsoft/rush",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush",
10+
"email": "pgonzal@users.noreply.github.com"
11+
}

‎common/reviews/api/node-core-library.api.ts‎

Lines changed: 54 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class FileDiffTest {
1919
// @public
2020
class FileSystem {
2121
static changePosixModeBits(path: string, mode: PosixModeBits): void;
22-
static copyFile(sourcePath: string, destinationPath: string): void;
23-
static createHardLink(linkTarget: string, linkSource: string): void;
24-
static createSymbolicLinkFile(linkTarget: string, linkSource: string): void;
25-
static createSymbolicLinkFolder(linkTarget: string, linkSource: string): void;
26-
static createSymbolicLinkJunction(linkTarget: string, linkSource: string): void;
27-
static deleteFile(filePath: string, options?: IDeleteFileOptions): void;
22+
static copyFile(options: IFileSystemCopyFileOptions): void;
23+
static createHardLink(options: IFileSystemCreateLinkOptions): void;
24+
static createSymbolicLinkFile(options: IFileSystemCreateLinkOptions): void;
25+
static createSymbolicLinkFolder(options: IFileSystemCreateLinkOptions): void;
26+
static createSymbolicLinkJunction(options: IFileSystemCreateLinkOptions): void;
27+
static deleteFile(filePath: string, options?: IFileSystemDeleteFileOptions): void;
2828
static deleteFolder(folderPath: string): void;
2929
static ensureEmptyFolder(folderPath: string): void;
3030
static ensureFolder(folderPath: string): void;
@@ -34,12 +34,12 @@ class FileSystem {
3434
static getPosixModeBits(path: string): PosixModeBits;
3535
static getRealPath(linkPath: string): string;
3636
static getStatistics(path: string): fs.Stats;
37-
static move(sourcePath: string, targetPath: string, options?: IFileSystemMoveOptions): void;
38-
static readFile(filePath: string, options?: IReadFileOptions): string;
37+
static move(options: IFileSystemMoveOptions): void;
38+
static readFile(filePath: string, options?: IFileSystemReadFileOptions): string;
3939
static readFileToBuffer(filePath: string): Buffer;
40-
static readFolder(folderPath: string, options?: IReadFolderOptions): Array<string>;
41-
static updateTimes(path: string, times: IUpdateTimeParameters): void;
42-
static writeFile(filePath: string, contents: string | Buffer, options?: IWriteFileOptions): void;
40+
static readFolder(folderPath: string, options?: IFileSystemReadFolderOptions): Array<string>;
41+
static updateTimes(path: string, times: IFileSystemUpdateTimeParameters): void;
42+
static writeFile(filePath: string, contents: string | Buffer, options?: IFileSystemWriteFileOptions): void;
4343
}
4444

4545
// @public
@@ -55,11 +55,6 @@ enum FolderConstants {
5555
NodeModules = "node_modules"
5656
}
5757

58-
// @public
59-
interface IDeleteFileOptions {
60-
throwIfNotExists?: boolean;
61-
}
62-
6358
// @beta
6459
interface IExecutableResolveOptions {
6560
currentWorkingDirectory?: string;
@@ -74,10 +69,53 @@ interface IExecutableSpawnSyncOptions extends IExecutableResolveOptions {
7469
timeoutMs?: number;
7570
}
7671

72+
// @public
73+
interface IFileSystemCopyFileOptions {
74+
destinationPath: string;
75+
sourcePath: string;
76+
}
77+
78+
// @public
79+
interface IFileSystemCreateLinkOptions {
80+
linkTargetPath: string;
81+
newLinkPath: string;
82+
}
83+
84+
// @public
85+
interface IFileSystemDeleteFileOptions {
86+
throwIfNotExists?: boolean;
87+
}
88+
7789
// @public
7890
interface IFileSystemMoveOptions {
91+
destinationPath: string;
7992
ensureFolderExists?: boolean;
8093
overwrite?: boolean;
94+
sourcePath: string;
95+
}
96+
97+
// @public
98+
interface IFileSystemReadFileOptions {
99+
convertLineEndings?: NewlineKind;
100+
encoding?: Encoding;
101+
}
102+
103+
// @public
104+
interface IFileSystemReadFolderOptions {
105+
absolutePaths?: boolean;
106+
}
107+
108+
// @public
109+
interface IFileSystemUpdateTimeParameters {
110+
accessedTime: number | Date;
111+
modifiedTime: number | Date;
112+
}
113+
114+
// @public
115+
interface IFileSystemWriteFileOptions {
116+
convertLineEndings?: NewlineKind;
117+
encoding?: Encoding;
118+
ensureFolderExists?: boolean;
81119
}
82120

83121
// @public
@@ -173,30 +211,6 @@ interface IProtectableMapParameters<K, V> {
173211
onSet?: (source: ProtectableMap<K, V>, key: K, value: V) => V;
174212
}
175213

176-
// @public
177-
interface IReadFileOptions {
178-
convertLineEndings?: NewlineKind;
179-
encoding?: Encoding;
180-
}
181-
182-
// @public
183-
interface IReadFolderOptions {
184-
absolutePaths?: boolean;
185-
}
186-
187-
// @public
188-
interface IUpdateTimeParameters {
189-
accessedTime: number | Date;
190-
modifiedTime: number | Date;
191-
}
192-
193-
// @public
194-
interface IWriteFileOptions {
195-
convertLineEndings?: NewlineKind;
196-
encoding?: Encoding;
197-
ensureFolderExists?: boolean;
198-
}
199-
200214
// @public
201215
class JsonFile {
202216
static load(jsonFilename: string): any;

0 commit comments

Comments
 (0)