Skip to content

Merge release/0.5.0 to master #17

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

Merged
merged 5 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 5 additions & 7 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
branches:
dev(elop)?(ment)?$:
tag: alpha
features?[/-]:
feature:
regex: features?[/-]
tag: alpha.{BranchName}
releases?[/-]:
mode: ContinuousDeployment
hotfix(es)?[/-]:
mode: ContinuousDeployment
develop:
regex: dev(elop)?(ment)?$
tag: alpha
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
# gl-vsts-tasks-build

This package provides npm utility commands to ease **VSTS Build And Release Tasks** extensions developement.
This currently powers the development process behind [Geek Learning's VSTS extensions](https://marketplace.visualstudio.com/search?term=publisher%3A%22Geek%20Learning%22&target=VSTS&sortBy=Relevance).
[![Build status](https://geeklearning.visualstudio.com/gl-github/_apis/build/status/gl-vsts-tasks-build-scripts)](https://geeklearning.visualstudio.com/gl-github/_build/latest?definitionId=97)
[![NPM@dev](https://img.shields.io/npm/v/gl-vsts-tasks-build-scripts/dev.svg)](https://www.npmjs.com/package/gl-vsts-tasks-build-scripts/v/dev)
[![NPM@latest](https://img.shields.io/npm/v/gl-vsts-tasks-build-scripts/latest.svg?color=green)](https://www.npmjs.com/package/gl-vsts-tasks-build-scripts/v/latest)

This package provides NPM utility commands to ease **Azure Pipelines Tasks** extensions developement.
This currently powers the development process behind [Geek Learning's extensions](https://marketplace.visualstudio.com/publishers/geeklearningio).

## Features

* **Multiple packages generation** : This allows you to generate testing versions of the extension using unique ids, so you can easily
test your extension and setup staged deployment to the store. At Geek Learning our CI builds 3 versions of the extension
(Dev, Preview, Production) and stores them as build artifacts. We then use Release Management to publish them to the marketplace.
(Dev, Preview, Production) and stores them as build artifacts. We then use Release Pipelines to publish them to the marketplace.
Dev package is always published automatically upon successfull build. Preview and Production are manually pushed if it passes our
final review. Ids and packages settings, are defined in the `Configuration.json` file
* **Manifest automation** : We automatically populate the contributions in the vss-extension in order to reduced manual maintainance
of this file.
* **Common shared code** : We provide an easy way to share powershell or node scripts accros your tasks without the need to make a
package of them. Place them in the right subfolder of `Common` and they will be automatically copied where appropriate on build.
* **Node : Automic dependency installation** : Vsts Agent node execution engine requires npm dependencies to be bundled with your task
* **Node : Automic dependency installation** : Azure Pipelines Agent node execution engine requires npm dependencies to be bundled with your task
We automatically install two dependencies as a postbuild step after a successfull `npm install` at root.
* **Automatic versionning** : Visual Studio Marketplace does not support semver, but we always rely on it when it comes to versionnning.
As a result we needed a way to encode our semver to a Major.Minor.Patch format. This feature can be switched of if you rely on another
source of versionning.
As a result we needed a way to encode our semver to a Major.Minor.Patch format. This feature can be switched of if you rely on another source of versionning.

## Project structure

At the moment, if you wish to use this tooling, your project will need to comply with the architecture we designed.

Directory Structure
```
Root
|-- package.json
Expand Down Expand Up @@ -80,10 +81,14 @@ Then to get the best of this tooling we recommand that you tweak your `package.j
```

You can now restore or update dependencies and task bundled dependencies by running a single `npm install` at the root.

You can clean common files using `npm run clean`

You can build node tasks using `npm run build`

You can package your extension by running `npm run package`. Output will be placed in the `.BuildOutput` subdirectory at root.

### Versioning
## Versioning
You can set version by packaging with `npm run package -- --version <version>`.

You can disable the default behavior which would encode the semver metadata into the patch component with the additional flag `--noversiontransform`.
9 changes: 4 additions & 5 deletions dist/clean.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs-extra");
var path = require("path");
var tasks = require("./tasks");
var lodash_1 = require("lodash");
var minimist = require("minimist");
var path = require("path");
var tasks = require("./tasks");
var options = minimist(process.argv.slice(2), {});
fs.emptyDirSync('.BuildOutput');
fs.emptyDirSync(".BuildOutput");
lodash_1.forEach(tasks.getTasks(options.taskroot), function (task) {
var targetNodeCommonDir = path.join(task.directory, "common");
var taskNodeModules = path.join(task.directory, "node_modules");
var targetPowershellCommonDir = path.join(task.directory, "ps_modules");
fs.removeSync(targetNodeCommonDir);
fs.removeSync(targetPowershellCommonDir);
if (options.modules == "true") {
if (options.modules === "true") {
fs.removeSync(taskNodeModules);
}
;
});
3 changes: 1 addition & 2 deletions dist/configuration.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var path = require("path");
;
function getConfiguration() {
var currentDirectory = process.cwd();
return require(path.join(currentDirectory, 'configuration.json'));
return require(path.join(currentDirectory, "configuration.json"));
}
exports.getConfiguration = getConfiguration;
10 changes: 5 additions & 5 deletions dist/endpoints.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var path = require("path");
var fs = require("fs-extra");
var path = require("path");
function getEndpoints(endpointsRoot) {
if (!endpointsRoot) {
var currentDirectory = process.cwd();
endpointsRoot = path.join(currentDirectory, 'Endpoints');
endpointsRoot = path.join(currentDirectory, "Endpoints");
}
if (!fs.existsSync(endpointsRoot)) {
return [];
}
return fs.readdirSync(endpointsRoot).map(function (file) {
var endpointPath = path.join(endpointsRoot, file);
var manifest = JSON.parse(fs.readFileSync(endpointPath, { encoding: 'utf8' }));
var manifest = JSON.parse(fs.readFileSync(endpointPath, { encoding: "utf8" }));
return {
path: endpointPath,
name: manifest.properties.name,
manifest: manifest,
name: manifest.properties.name,
path: endpointPath,
};
});
}
Expand Down
16 changes: 7 additions & 9 deletions dist/extension-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ function getSemanticVersion() {
var version = options.version;
if (!version) {
version = "0.0.0";
console.log('No version argument provided, fallback to default version: ' + version);
console.log("No version argument provided, fallback to default version: " + version);
}
else {
console.log('Found version: ' + version);
console.log("Found version: " + version);
}
if (!semver.valid(version)) {
throw new Error('Package: invalid semver version: ' + version);
throw new Error("Package: invalid semver version: " + version);
}
var patch = semver.patch(version);
if (!options.noversiontransform) {
patch *= 1000;
var prerelease = semver.prerelease(version);
if (prerelease) {
;
patch += parseInt(prerelease[1]);
patch += parseInt(prerelease[1], 10);
}
else {
patch += 999;
Expand All @@ -32,11 +31,10 @@ function getSemanticVersion() {
minor: semver.minor(version),
patch: patch,
getVersionString: function () {
return this.major.toString() + '.' + this.minor.toString() + '.' + this.patch.toString();
}
return this.major.toString() + "." + this.minor.toString() + "." + this.patch.toString();
},
};
console.log('Extension Version: ' + result.getVersionString());
console.log("Extension Version: " + result.getVersionString());
return result;
}
exports.getSemanticVersion = getSemanticVersion;
;
24 changes: 12 additions & 12 deletions dist/install.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var async_1 = require("async");
var path = require("path");
var child_process_1 = require("child_process");
var path = require("path");
var tasks_1 = require("./tasks");
var npmInstall = function (project) {
return function (done) {
var isYarn = path.basename(process.env.npm_execpath || "npm").startsWith("yarn");
var installer = isYarn ? 'yarn' : 'npm';
var child = child_process_1.exec(isYarn ? 'yarn' : 'npm install', {
cwd: project.directory
var installer = isYarn ? "yarn" : "npm";
child_process_1.exec(isYarn ? "yarn" : "npm install", {
cwd: project.directory,
}, function (error, stdout, stderr) {
if (error) {
console.error('execution error:', error);
console.error("execution error:", error);
done(error);
return;
}
Expand All @@ -23,18 +23,18 @@ var npmInstall = function (project) {
if (stderr) {
console.error(stderr);
}
var nodeModulesPath = path.join(project.directory, 'node_modules');
var powerShellModules = require("glob").sync(path.join(project.directory, "node_modules", "**", "*.psm1"));
var powerShellModules = require("glob")
.sync(path.join(project.directory, "node_modules", "**", "*.psm1"));
if (powerShellModules.length > 0) {
var fs = require("fs-extra");
var taskFilePath = path.join(project.directory, 'task.json');
var taskFilePath = path.join(project.directory, "task.json");
var task = fs.existsSync(taskFilePath) ? fs.readJsonSync(taskFilePath) : {};
if (task.execution.PowerShell3) {
var psModulesPath = path.join(project.directory, 'ps_modules');
var psModulesPath = path.join(project.directory, "ps_modules");
fs.ensureDirSync(psModulesPath);
for (var i = 0; i < powerShellModules.length; i++) {
var powerShellModulePath = powerShellModules[i];
var powerShellModuleDirName = path.dirname(powerShellModulePath);
for (var _i = 0, powerShellModules_1 = powerShellModules; _i < powerShellModules_1.length; _i++) {
var modulePath = powerShellModules_1[_i];
var powerShellModuleDirName = path.dirname(modulePath);
var powerShellModuleFolderName = path.basename(powerShellModuleDirName);
fs.copySync(powerShellModuleDirName, path.join(psModulesPath, powerShellModuleFolderName), { clobber: true, dereference: true });
console.log(powerShellModuleFolderName + " copied in ps_modules for " + project.name);
Expand Down
17 changes: 9 additions & 8 deletions dist/node-modclean.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var minimist = require("minimist");
var tasks = require("./tasks");
var async_1 = require("async");
var path = require("path");
var fs = require("fs");
var modclean = require('modclean');
var minimist = require("minimist");
var path = require("path");
var tasks = require("./tasks");
// tslint:disable-next-line: no-var-requires
var modclean = require("modclean");
var runModclean = function (project) {
return function (done) {
if (fs.existsSync(path.join(project.directory, "node_modules"))) {
var modcleanOptions = {
cwd: project.directory
cwd: project.directory,
};
var options = minimist(process.argv.slice(2), {});
if (options.patterns) {
modcleanOptions.patterns = options.patterns.split(',');
modcleanOptions.patterns = options.patterns.split(",");
}
if (options.additionalpatterns) {
modcleanOptions.additionalPatterns = options.additionalpatterns.split(',');
modcleanOptions.additionalPatterns = options.additionalpatterns.split(",");
}
if (options.ignorepatterns) {
modcleanOptions.ignorePatterns = options.ignorepatterns.split(',');
modcleanOptions.ignorePatterns = options.ignorepatterns.split(",");
}
modclean(modcleanOptions, function (err, results) {
// called once cleaning is complete.
Expand Down
Loading