Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
first version of Yarn demo task just with simple inputs and commands
  • Loading branch information
lfraile committed Oct 31, 2016
1 parent 8049baa commit 9c73da7
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -29,9 +29,12 @@ build/Release
# Dependency directories
node_modules
jspm_packages
typings

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

**\*.vsix
1 change: 1 addition & 0 deletions .taskkey
@@ -0,0 +1 @@
7bc206b0-9f42-11e6-983d-8d7cfa884c5b
Binary file added luisfraile.yarn-simple-demo-0.1.1.vsix
Binary file not shown.
36 changes: 36 additions & 0 deletions vss-extension.json
@@ -0,0 +1,36 @@
{
"manifestVersion": 1,
"id": "yarn-simple-demo",
"name": "Yarn task demo",
"version": "0.1.1",
"publisher": "luisfraile",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"description": "Tasks for executing Yarn commands in builds",
"categories": [
"Build and release"
],
"icons": {
"default": "yarn-logo-big.png"
},
"files": [
{
"path": "yarnbuildtask"
}
],
"contributions": [
{
"id": "YarnDemoTask",
"type": "ms.vss-distributed-task.task",
"targets": [
"ms.vss-distributed-task.tasks"
],
"properties": {
"name": "yarnbuildtask"
}
}
]
}
Binary file added yarn-logo-big.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions yarnbuildtask/.taskkey
@@ -0,0 +1 @@
5f784990-9f44-11e6-a282-e3a23a340b02
Binary file added yarnbuildtask/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions yarnbuildtask/package.json
@@ -0,0 +1,22 @@
{
"name": "yarntask",
"version": "1.0.0",
"description": "A simple task for using Yarn package restore",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/lfraile/YarnTask.git"
},
"author": "Luis Fraile",
"license": "ISC",
"bugs": {
"url": "https://github.com/lfraile/YarnTask/issues"
},
"homepage": "https://github.com/lfraile/YarnTask#readme",
"dependencies": {
"vsts-task-lib": "^0.9.20"
}
}
64 changes: 64 additions & 0 deletions yarnbuildtask/task.json
@@ -0,0 +1,64 @@
{
"id": "DCB1BA6D-4031-48EB-839D-CFB54F4A75CA",
"name": "yarn",
"friendlyName": "Yarn Demo",
"description": "Run a yarn command",
"helpMarkDown": "Just a simple demo task for Yarn the fantabulous new package manager",
"category": "Package",
"author": "Luis Fraile",
"version": {
"Major": 0,
"Minor": 1,
"Patch": 2
},
"demands": [
"yarn"
],
"minimumAgentVersion": "1.91.0",
"groups": [
{
"name": "advanced",
"displayName": "Advanced",
"isExpanded": false
}
],
"instanceNameFormat": "yarn $(command)",
"inputs": [
{
"name": "command",
"type": "string",
"label": "Command",
"defaultValue": "install",
"helpMarkDown": "yarn command to run. [More Information](https://yarnpkg.com/).",
"required": true
},
{
"name": "arguments",
"type": "string",
"label": "Arguments",
"defaultValue": "",
"helpMarkDown": "Additional arguments passed to yarn.",
"required": false
},
{
"name": "cwd",
"type": "filePath",
"label": "Working Directory",
"defaultValue": "",
"required": false,
"helpMarkDown": "Current working directory where yarn command is run. Defaults to the root of the repo.",
"groupName": "advanced"
}
],
"execution": {
"Node": {
"target": "yarntask.js",
"argumentFormat": ""
}
},
"messages": {
"InvalidCommand": "Only one command should be used for yarn. Use arguments input for additional arguments.",
"YarnReturnCode": "yarn exited with return code: %d",
"YarnFailed": "yarn failed with error: %s"
}
}
6 changes: 6 additions & 0 deletions yarnbuildtask/tsconfig.json
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}
6 changes: 6 additions & 0 deletions yarnbuildtask/typings.json
@@ -0,0 +1,6 @@
{
"globalDependencies": {
"node": "registry:dt/node#6.0.0+20161019125345",
"q": "registry:dt/q#0.0.0+20161004185634"
}
}
97 changes: 97 additions & 0 deletions yarnbuildtask/yarn.lock
@@ -0,0 +1,97 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
balanced-match@^0.4.1:
version "0.4.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"

brace-expansion@^1.0.0:
version "1.1.6"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9"
dependencies:
balanced-match "^0.4.1"
concat-map "0.0.1"

concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

glob@^6.0.1:
version "6.0.4"
resolved "https://registry.yarnpkg.com/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22"
dependencies:
inflight "^1.0.4"
inherits "2"
minimatch "2 || 3"
once "^1.3.0"
path-is-absolute "^1.0.0"

inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"

inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"

minimatch@^3.0.0, "minimatch@2 || 3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
dependencies:
brace-expansion "^1.0.0"

mockery@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/mockery/-/mockery-1.7.0.tgz#f4ede0d8750c1c9727c272ea2c60629e2c9a1c4f"

node-uuid@^1.4.7:
version "1.4.7"
resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f"

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"

q@^1.0.1, q@^1.1.2:
version "1.4.1"
resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e"

semver@^5.1.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"

shelljs@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.3.0.tgz#3596e6307a781544f591f37da618360f31db57b1"

vso-node-api@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/vso-node-api/-/vso-node-api-0.6.1.tgz#9d3dd06a8dae2ff3682af8f28a845739a0bd6481"
dependencies:
q "^1.0.1"

vsts-task-lib@^0.9.20:
version "0.9.20"
resolved "https://registry.yarnpkg.com/vsts-task-lib/-/vsts-task-lib-0.9.20.tgz#31b14901791b3b2172b408990c5e1bce8a79ed9b"
dependencies:
glob "^6.0.1"
minimatch "^3.0.0"
mockery "^1.7.0"
node-uuid "^1.4.7"
q "^1.1.2"
semver "^5.1.0"
shelljs "^0.3.0"
vso-node-api "^0.6.1"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

22 changes: 22 additions & 0 deletions yarnbuildtask/yarntask.js
@@ -0,0 +1,22 @@
"use strict";
const path = require('path');
const tl = require('vsts-task-lib/task');
tl.setResourcePath(path.join(__dirname, 'task.json'));
var yarn = tl.tool(tl.which('yarn', true));
var cwd = tl.getPathInput('cwd', true, false);
tl.mkdirP(cwd);
tl.cd(cwd);
var command = tl.getInput('command', true);
if (command.indexOf(' ') >= 0) {
tl.setResult(tl.TaskResult.Failed, tl.loc("InvalidCommand"));
}
yarn.arg('install');
yarn.arg(tl.getInput('arguments', false));
yarn.exec()
.then(function (code) {
tl.setResult(code, tl.loc('YarnReturnCode', code));
})
.fail(function (err) {
tl.debug('taskRunner fail');
tl.setResult(tl.TaskResult.Failed, tl.loc('YarnFailed', err.message));
});
27 changes: 27 additions & 0 deletions yarnbuildtask/yarntask.ts
@@ -0,0 +1,27 @@
import path = require('path');
import tl = require('vsts-task-lib/task');

tl.setResourcePath(path.join( __dirname, 'task.json'));

var yarn = tl.tool(tl.which('yarn', true));

var cwd = tl.getPathInput('cwd', true, false);
tl.mkdirP(cwd);
tl.cd(cwd);

var command = tl.getInput('command', true);
if (command.indexOf(' ') >= 0) {
tl.setResult(tl.TaskResult.Failed, tl.loc("InvalidCommand"));
}
yarn.arg('install');

yarn.arg(tl.getInput('arguments', false));

yarn.exec()
.then(function(code) {
tl.setResult(code, tl.loc('YarnReturnCode', code));
})
.fail(function(err) {
tl.debug('taskRunner fail');
tl.setResult(tl.TaskResult.Failed, tl.loc('YarnFailed', err.message));
})

0 comments on commit 9c73da7

Please sign in to comment.