Skip to content

Commit

Permalink
Preparing for release of the 3.1.0 version (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
egor-bryzgalov committed Feb 17, 2021
1 parent d431a26 commit 578d707
Show file tree
Hide file tree
Showing 55 changed files with 430 additions and 4,475 deletions.
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 10
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 10.23.0
inputs:
versionSpec: "10.23.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 10
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 5.10.1
displayName: (azure-pipelines-task-lib) use node 10.23.0
inputs:
versionSpec: "5.10.1"
versionSpec: "10.23.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 Expand Up @@ -135,23 +124,17 @@ jobs:
command: install
workingDir: node

# use node 5
# use node 10
- task: NodeTool@0
displayName: (azure-pipelines-task-lib) use node 5.10.1
displayName: (azure-pipelines-task-lib) use node 10.23.0
inputs:
versionSpec: "5.10.1"
versionSpec: "10.23.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
16 changes: 14 additions & 2 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,31 @@ Cross platform tasks are written in TypeScript. It is the preferred way to writ

[![NPM version][npm-lib-image]][npm-lib-url]

Step by Step: [Create Task](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=vsts)
Step by Step: [Create Task](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=vsts)

Documentation: [TypeScript API](docs/azure-pipelines-task-lib.md), [task JSON schema](https://aka.ms/vsts-tasks.schema.json)

Guidance: [Finding Files](docs/findingfiles.md), [Minimum agent version](docs/minagent.md), [Proxy](docs/proxy.md), [Certificate](docs/cert.md)

## Node 10 Upgrade Notice

Azure DevOps is currently working to establish Node 10 as the new preferred runtime for tasks, upgrading from Node 6.
Relevant work is happening in the `master`` branch and the major version should be used with Node 10 is 3.
Previous major version is stored in the `releases/2.x`

### Upgrading to Node 10

Upgrading your tasks from Node 6 should be relatively painless, however there are some things to note:
* Typescript has been upgraded to TS 4. Older versions of TS may or may not work with Node 14 or the 3.x branch. We recommend upgrading to TS 4 when upgrading to task-lib 3.x.
* Node has made some changes to `fs` between Node 6 and Node 10. It is worth reviewing and testing your tasks thoroughly before publishing updates to Node 10.

## Reference Examples

The [ShellScript Task](https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks/ShellScriptV2) and the [XCode Task](https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks/XcodeV5) are good examples.

## Contributing

We are accepting contributions and we try to stay on top of issues.
We are accepting contributions and we try to stay on top of issues.

[Contribution Guide](../CONTRIBUTING.md).

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 = 'v10.23.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.

8 changes: 4 additions & 4 deletions node/docs/nodeEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ To leverage this capability, simply add `Node10` as an execution target:

```
"execution": {
"Node10": {
"target": "path/to/entry"
}
},
"Node10": {
"target": "path/to/entry"
}
},
```

Existing `Node` execution targets will still resolve to a Node 6 environment for now to maintain back-compat.
Expand Down
2 changes: 1 addition & 1 deletion node/docs/nodeVersioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If the `execution` property is specified to be `Node`, the task will run on the
[Unit testing](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops#step-2-unit-testing-your-task-scripts) of tasks can be done using the task-lib's built in mock-task functionality.
To ensure tests are run in the same environment as the agent, this library looks for a `task.json` file in the same directory as the supplied task entry point.
If no `task.json` is found it searches all ancestor directories as well.
If the `task.json` is still not found, the library defaults to node 10, otherwise it uses the appropriate handler based on the `execution` property.
If the `task.json` is still not found, the library defaults to Node 10, otherwise it uses the appropriate handler based on the `execution` property.
If this version of node is not found on the path, the library downloads the appropriate version.

### Behavior overrides
Expand Down
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');
20 changes: 10 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,6 @@ 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.
* @param ignoreWarnings Won't throw warnings if path already set.
* @returns void
Expand Down Expand Up @@ -177,7 +176,7 @@ export function _setResourcePath(path: string, ignoreWarnings: boolean = false):

/**
* 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 @@ -224,7 +223,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 @@ -301,9 +300,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 @@ -322,7 +321,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 @@ -337,7 +336,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 @@ -723,10 +722,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'); // Don't throw an exception when tests fail
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
8 changes: 4 additions & 4 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 Expand Up @@ -200,8 +200,8 @@ export class MockTestRunner {
}

if (!nodeVersionFound) {
console.warn('Unable to determine execution type from task.json, defaulting to use Node 14');
return 14;
console.warn('Unable to determine execution type from task.json, defaulting to use Node 10');
return 10;
}

return 6;
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

0 comments on commit 578d707

Please sign in to comment.