Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully support Node 14 and TS 4 #665

Merged
merged 10 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 11 additions & 28 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ jobs:
command: install
workingDir: node

# use node 5
- powershell: |
& "$(build.sourcesDirectory)/res/UseNode5.ps1"
displayName: (azure-pipelines-task-lib) use node 5.10.1
# use node 14
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 14.11.0
inputs:
versionSpec: "14.11.0"

# build/test
- script: |
Expand All @@ -35,12 +36,6 @@ jobs:
workingDirectory: node
displayName: (azure-pipelines-task-lib) node make.js test

# use node 6
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 6.10.3
inputs:
versionSpec: "6.10.3"

# build/test
- script: |
chcp 437
Expand Down Expand Up @@ -83,23 +78,17 @@ jobs:
command: install
workingDir: node

# use node 5
# use node 14
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 5.10.1
displayName: (azure-pipelines-task-lib) use node 14.11.0
inputs:
versionSpec: "5.10.1"
versionSpec: "14.11.0"

# build/test
- script: node make.js test
workingDirectory: node
displayName: (azure-pipelines-task-lib) node make.js test

# use node 6
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 6.10.3
inputs:
versionSpec: "6.10.3"

# build/test
- script: node make.js test
displayName: (azure-pipelines-task-lib) node make.js test
Expand All @@ -124,23 +113,17 @@ jobs:
command: install
workingDir: node

# use node 5
# use node 14
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 5.10.1
displayName: (azure-pipelines-task-lib) use node 14.11.0
inputs:
versionSpec: "5.10.1"
versionSpec: "14.11.0"

# build/test
- script: node make.js test
workingDirectory: node
displayName: (azure-pipelines-task-lib) node make.js test

# use node 6
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 6.10.3
inputs:
versionSpec: "6.10.3"

# build/test
- script: node make.js test
displayName: (azure-pipelines-task-lib) node make.js test
Expand Down
2 changes: 1 addition & 1 deletion node/buildutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.getExternals = function () {
// download the same version of node used by the agent
// and add node to the PATH
var nodeUrl = 'https://nodejs.org/dist';
var nodeVersion = 'v6.17.1';
var nodeVersion = 'v14.11.0';
switch (platform) {
case 'darwin':
var nodeArchivePath = downloadArchive(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-darwin-x64.tar.gz');
Expand Down
8 changes: 0 additions & 8 deletions node/dependencies/typings.json

This file was deleted.

2 changes: 0 additions & 2 deletions node/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/// <reference path="typings/index.d.ts" />

import trm = require('./task');
21 changes: 11 additions & 10 deletions node/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export var _vault: vm.Vault;

// async await needs generators in node 4.x+
if (semver.lt(process.versions.node, '4.2.0')) {
this.warning('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later');
_warning('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later');
}

//-----------------------------------------------------
Expand Down Expand Up @@ -140,7 +140,7 @@ function _loadLocStrings(resourceFile: string, culture: string): { [key: string]
/**
* Sets the location of the resources json. This is typically the task.json file.
* Call once at the beginning of the script before any calls to loc.
*
*
* @param path Full path to the json.
* @returns void
*/
Expand Down Expand Up @@ -172,7 +172,7 @@ export function _setResourcePath(path: string): void {

/**
* Gets the localized string from the json resource file. Optionally formats with additional params.
*
*
* @param key key of the resources string in the resource file
* @param param additional params for formatting the string
* @returns string
Expand Down Expand Up @@ -219,7 +219,7 @@ export function _loc(key: string, ...param: any[]): string {

/**
* Gets a variable value that is defined on the build/release definition or set at runtime.
*
*
* @param name name of the variable to get
* @returns string
*/
Expand Down Expand Up @@ -296,9 +296,9 @@ export function _debug(message: string): void {

/**
* Returns whether a path exists.
*
*
* @param path path to check
* @returns boolean
* @returns boolean
*/
export function _exist(path: string): boolean {
var exist = false;
Expand All @@ -317,7 +317,7 @@ export function _exist(path: string): boolean {
/**
* Checks whether a path exists.
* If the path does not exist, it will throw.
*
*
* @param p path to check
* @param name name only used in error message to identify the path
* @returns void
Expand All @@ -332,7 +332,7 @@ export function _checkPath(p: string, name: string): void {
/**
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
* If you check and the tool does not exist, it will throw.
*
*
* @param tool name of the tool
* @param check whether to check if tool exists
* @returns string
Expand Down Expand Up @@ -718,10 +718,11 @@ export function _loadData(): void {
}

// store the secret
if (process.env[envvar]) {
var value = process.env[envvar];
if (value) {
++loaded;
_debug('loading ' + envvar);
_vault.storeSecret(envvar, process.env[envvar]);
_vault.storeSecret(envvar, value);
delete process.env[envvar];
}
}
Expand Down
3 changes: 1 addition & 2 deletions node/make.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

require('shelljs/make');
var fs = require('fs');
var path = require('path');
Expand Down Expand Up @@ -28,7 +27,6 @@ target.build = function() {
target.loc();

run('tsc --outDir ' + buildPath);
cp(rp('dependencies/typings.json'), buildPath);
cp(rp('package.json'), buildPath);
cp(rp('package-lock.json'), buildPath);
cp(rp('README.md'), buildPath);
Expand All @@ -48,6 +46,7 @@ target.test = function() {
cp('-Rf', rp('test/scripts'), testPath);
cp('-Rf', rp('test/fakeTasks'), testPath);
process.env['TASKLIB_INPROC_UNITS'] = '1'; // export task-lib internals for internal unit testing
set('+e');
alex-peck marked this conversation as resolved.
Show resolved Hide resolved
run('mocha ' + testPath);
}

Expand Down
2 changes: 0 additions & 2 deletions node/mock-answer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as path from 'path';
import * as fs from 'fs';
import * as task from './task';

export interface TaskLibAnswerExecResult {
Expand Down
1 change: 0 additions & 1 deletion node/mock-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import ma = require('./mock-answer');
import mockery = require('mockery');
import im = require('./internal');


export class TaskMockRunner {
constructor(taskPath: string) {
this._taskPath = taskPath;
Expand Down
4 changes: 4 additions & 0 deletions node/mock-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ export class FsStats implements fs.Stats {
mtime: Date = new Date();
ctime: Date = new Date();
birthtime: Date = new Date();
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
birthtimeMs: number;

setAnswers(mockResponses: any): void {
this.m_isFile = mockResponses['isFile'] || this.m_isFile;
Expand Down
4 changes: 2 additions & 2 deletions node/mock-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import os = require('os');
import path = require('path');
import cmdm = require('./taskcommand');
import shelljs = require('shelljs');
import syncRequest = require('sync-request');
import syncRequest from 'sync-request';

const COMMAND_TAG = '[command]';
const COMMAND_LENGTH = COMMAND_TAG.length;
const downloadDirectory = path.join(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, 'azure-pipelines-task-lib', '_download');
const downloadDirectory = path.join(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE as string, 'azure-pipelines-task-lib', '_download');

export class MockTestRunner {
constructor(testPath: string, taskJsonPath?: string) {
Expand Down
4 changes: 2 additions & 2 deletions node/mock-toolrunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface IExecOptions extends IExecSyncOptions {

export interface IExecSyncOptions {
cwd?: string;
env?: { [key: string]: string };
env?: { [key: string]: string | undefined };
silent?: boolean;
outStream: NodeJS.WritableStream;
errStream: NodeJS.WritableStream;
Expand Down Expand Up @@ -152,7 +152,7 @@ export class ToolRunner extends events.EventEmitter {
this._debug('tempPath=' + process.env['MOCK_TEMP_PATH']);
if (process.env['MOCK_IGNORE_TEMP_PATH'] === 'true') {
// Using split/join to replace the temp path
cmdString = cmdString.split(process.env['MOCK_TEMP_PATH']).join('');
cmdString = cmdString.split(process.env['MOCK_TEMP_PATH'] || "").join('');
}

return cmdString;
Expand Down
Loading