Skip to content

Commit c630819

Browse files
tintse-thxsky-MSFTTatyana Kostromskaya (Akvelon)Tatyana KostromskayaAnatoly Bolshakovmpodriezov
authored
Migrate NpmAuthenticateV0 to Node 10 (#16650)
* First iteration * Bumped version to 207 * Update package.json Co-authored-by: Tatyana Kostromskaya (Akvelon) <[email protected]> Co-authored-by: Tatyana Kostromskaya <[email protected]> Co-authored-by: Anatoly Bolshakov <[email protected]> Co-authored-by: Max Podriezov <[email protected]>
1 parent c1b7dd3 commit c630819

File tree

7 files changed

+510
-139
lines changed

7 files changed

+510
-139
lines changed

Tasks/NpmAuthenticateV0/make.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

Tasks/NpmAuthenticateV0/npmauth.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import * as tl from 'azure-pipelines-task-lib/task';
33
import * as URL from 'url';
44
import * as fs from 'fs';
55
import * as constants from './constants';
6-
import * as npmregistry from 'packaging-common/npm/npmregistry';
7-
import * as util from 'packaging-common/util';
8-
import * as npmutil from 'packaging-common/npm/npmutil';
6+
import * as npmregistry from 'azure-pipelines-tasks-packaging-common-v3/npm/npmregistry';
7+
import * as util from 'azure-pipelines-tasks-packaging-common-v3/util';
8+
import * as npmutil from 'azure-pipelines-tasks-packaging-common-v3/npm/npmutil';
99
import * as os from 'os';
10-
import * as npmrcparser from 'packaging-common/npm/npmrcparser';
11-
import * as pkgLocationUtils from 'packaging-common/locationUtilities';
10+
import * as npmrcparser from 'azure-pipelines-tasks-packaging-common-v3/npm/npmrcparser';
11+
import * as pkgLocationUtils from 'azure-pipelines-tasks-packaging-common-v3/locationUtilities';
1212

1313
async function main(): Promise<void> {
1414
tl.setResourcePath(path.join(__dirname, 'task.json'));
@@ -26,13 +26,13 @@ async function main(): Promise<void> {
2626
}
2727

2828
if (tl.getVariable("SAVE_NPMRC_PATH")) {
29-
saveNpmrcPath = tl.getVariable("SAVE_NPMRC_PATH");
29+
saveNpmrcPath = tl.getVariable("SAVE_NPMRC_PATH");
3030
}
3131
else {
3232
let tempPath = tl.getVariable('Agent.BuildDirectory') || tl.getVariable('Agent.TempDirectory');
3333
tempPath = path.join(tempPath, 'npmAuthenticate');
3434
tl.mkdirP(tempPath);
35-
saveNpmrcPath = fs.mkdtempSync(tempPath + path.sep);
35+
saveNpmrcPath = fs.mkdtempSync(tempPath + path.sep);
3636
tl.setVariable("SAVE_NPMRC_PATH", saveNpmrcPath, false);
3737
tl.setVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY", tempPath, false);
3838
}
@@ -45,7 +45,7 @@ async function main(): Promise<void> {
4545

4646
if (fs.existsSync(indexFile)) { //If the file exists, add to it.
4747
npmrcTable = JSON.parse(fs.readFileSync(indexFile, 'utf8'));
48-
48+
4949
}
5050
else { //If the file doesn't exist, create it.
5151
npmrcTable = new Object();
@@ -85,7 +85,7 @@ async function main(): Promise<void> {
8585
for (let serviceEndpoint of endpointRegistries) {
8686

8787
if (util.toNerfDart(serviceEndpoint.url) == util.toNerfDart(RegistryURLString)) {
88-
let serviceURL = URL.parse(serviceEndpoint.url);
88+
let serviceURL = URL.parse(serviceEndpoint.url);
8989
console.log(tl.loc("AddingEndpointCredentials", registryURL.host));
9090
registry = serviceEndpoint;
9191
npmrcFile = clearFileOfReferences(npmrc, npmrcFile, serviceURL);
@@ -110,13 +110,13 @@ async function main(): Promise<void> {
110110
npmrcFile.push(os.EOL + registry.auth + os.EOL);
111111
}
112112
else {
113-
console.log(tl.loc("IgnoringRegistry", registryURL.host ));
113+
console.log(tl.loc("IgnoringRegistry", registryURL.host));
114114
}
115115
}
116116
}
117117

118118
main().catch(error => {
119-
if(tl.getVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY")) {
119+
if (tl.getVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY")) {
120120
tl.rmRF(tl.getVariable("NPM_AUTHENTICATE_TEMP_DIRECTORY"));
121121
// Clear the variables after we rm-rf the main root directory
122122
tl.setVariable("SAVE_NPMRC_PATH", "", false);

Tasks/NpmAuthenticateV0/npmauthcleanup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as util from 'packaging-common/util';
1+
import * as util from 'azure-pipelines-tasks-packaging-common-v3/util';
22
import * as constants from './constants';
33
import * as tl from 'azure-pipelines-task-lib/task';
44
import * as fs from 'fs';

0 commit comments

Comments
 (0)