Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 5f06a45

Browse files
committed
init
0 parents commit 5f06a45

File tree

13 files changed

+2323
-0
lines changed

13 files changed

+2323
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
3+
*.vsix
4+
5+
/.vs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cc7779f6-0c03-4c37-ae9a-678e91495508
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
return new (P || (P = Promise))(function (resolve, reject) {
4+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7+
step((generator = generator.apply(thisArg, _arguments || [])).next());
8+
});
9+
};
10+
var __generator = (this && this.__generator) || function (thisArg, body) {
11+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13+
function verb(n) { return function (v) { return step([n, v]); }; }
14+
function step(op) {
15+
if (f) throw new TypeError("Generator is already executing.");
16+
while (_) try {
17+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18+
if (y = 0, t) op = [op[0] & 2, t.value];
19+
switch (op[0]) {
20+
case 0: case 1: t = op; break;
21+
case 4: _.label++; return { value: op[1], done: false };
22+
case 5: _.label++; y = op[1]; op = [0]; continue;
23+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
24+
default:
25+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29+
if (t[2]) _.ops.pop();
30+
_.trys.pop(); continue;
31+
}
32+
op = body.call(thisArg, _);
33+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35+
}
36+
};
37+
var __importStar = (this && this.__importStar) || function (mod) {
38+
if (mod && mod.__esModule) return mod;
39+
var result = {};
40+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
41+
result["default"] = mod;
42+
return result;
43+
};
44+
Object.defineProperty(exports, "__esModule", { value: true });
45+
var taskLib = __importStar(require("azure-pipelines-task-lib/task"));
46+
var toolLib = __importStar(require("azure-pipelines-tool-lib/tool"));
47+
var util = __importStar(require("util"));
48+
var exec = util.promisify(require('child_process').exec);
49+
function execCommand(command) {
50+
return __awaiter(this, void 0, void 0, function () {
51+
var _a, stdout, stderr;
52+
return __generator(this, function (_b) {
53+
switch (_b.label) {
54+
case 0:
55+
console.log('command: ' + command);
56+
return [4 /*yield*/, exec(command)];
57+
case 1:
58+
_a = _b.sent(), stdout = _a.stdout, stderr = _a.stderr;
59+
if (stdout) {
60+
console.log('stdout: ' + stdout);
61+
}
62+
if (stderr) {
63+
console.log('stderr: ' + stderr);
64+
}
65+
return [2 /*return*/];
66+
}
67+
});
68+
});
69+
}
70+
function run() {
71+
return __awaiter(this, void 0, void 0, function () {
72+
var version, downloadUrl, msiPath, uninstallCommand, installCommand, err_1;
73+
return __generator(this, function (_a) {
74+
switch (_a.label) {
75+
case 0:
76+
_a.trys.push([0, 4, , 5]);
77+
version = taskLib.getInput('WinAppDriverVersion', false);
78+
if (!version) {
79+
version = 'v1.1';
80+
}
81+
downloadUrl = "https://github.com/microsoft/WinAppDriver/releases/download/" + version + "/WindowsApplicationDriver.msi";
82+
console.log('Download WinAppDriver from ' + downloadUrl);
83+
return [4 /*yield*/, toolLib.downloadTool(downloadUrl)];
84+
case 1:
85+
msiPath = _a.sent();
86+
console.log('Downloaded File: ' + msiPath);
87+
uninstallCommand = 'msiexec /uninstall {C4903086-429C-4455-86DD-044914BBA07B} /qn';
88+
return [4 /*yield*/, execCommand(uninstallCommand).catch(function () { })];
89+
case 2:
90+
_a.sent();
91+
installCommand = "msiexec /i " + msiPath + " /qn";
92+
return [4 /*yield*/, execCommand(installCommand)];
93+
case 3:
94+
_a.sent();
95+
taskLib.setResult(taskLib.TaskResult.Succeeded, 'Install Complete');
96+
return [3 /*break*/, 5];
97+
case 4:
98+
err_1 = _a.sent();
99+
taskLib.warning(err_1);
100+
taskLib.setResult(taskLib.TaskResult.Failed, err_1.message);
101+
return [3 /*break*/, 5];
102+
case 5: return [2 /*return*/];
103+
}
104+
});
105+
});
106+
}
107+
run();
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as taskLib from 'azure-pipelines-task-lib/task';
2+
import * as toolLib from 'azure-pipelines-tool-lib/tool';
3+
4+
import * as util from 'util';
5+
const exec = util.promisify(require('child_process').exec);
6+
7+
async function execCommand(command: string) {
8+
console.log('command: ' + command);
9+
const { stdout, stderr } = await exec(command);
10+
if (stdout) {
11+
console.log('stdout: ' + stdout);
12+
}
13+
if (stderr) {
14+
console.log('stderr: ' + stderr);
15+
}
16+
}
17+
18+
19+
async function run() {
20+
try {
21+
let version = taskLib.getInput('WinAppDriverVersion', false);
22+
23+
if (!version) {
24+
version = 'v1.1';
25+
}
26+
27+
const downloadUrl = `https://github.com/microsoft/WinAppDriver/releases/download/${version}/WindowsApplicationDriver.msi`;
28+
29+
console.log('Download WinAppDriver from ' + downloadUrl);
30+
const msiPath = await toolLib.downloadTool(downloadUrl);
31+
console.log('Downloaded File: ' + msiPath);
32+
33+
const uninstallCommand = 'msiexec /uninstall {C4903086-429C-4455-86DD-044914BBA07B} /qn'
34+
await execCommand(uninstallCommand).catch(() => { });
35+
36+
const installCommand = `msiexec /i ${msiPath} /qn`;
37+
await execCommand(installCommand);
38+
39+
taskLib.setResult(taskLib.TaskResult.Succeeded, 'Install Complete')
40+
}
41+
catch (err) {
42+
taskLib.warning(err);
43+
taskLib.setResult(taskLib.TaskResult.Failed, err.message);
44+
}
45+
}
46+
47+
run();

BuildTasks/WinAppDriverInstaller/package-lock.json

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "winappdriverinstaller",
3+
"version": "0.0.1",
4+
"description": "Install WinAppDriver",
5+
"main": "installer.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"tsc": "tsc"
9+
},
10+
"keywords": [
11+
"WinAppDriver",
12+
"Automation"
13+
],
14+
"author": "Canhua Li <licanhua@live.com> (https://github.com/licanhua)",
15+
"license": "ISC",
16+
"dependencies": {
17+
"azure-pipelines-task-lib": "^2.9.3",
18+
"azure-pipelines-tool-lib": "^0.12.0"
19+
},
20+
"devDependencies": {
21+
"@types/node": "^12.7.9",
22+
"@types/q": "^1.5.2"
23+
}
24+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/Microsoft/azure-pipelines-task-lib/master/tasks.schema.json",
3+
"id": "8cc922ae-6951-48d4-861e-d306b6c6fbc3",
4+
"name": "WinAppDriverInstaller",
5+
"friendlyName": "WinAppDriver Installer",
6+
"description": "Install WinAppDriver",
7+
"helpMarkDown": "https://github.com/react-native-windows/WinAppDriverInstaller",
8+
"category": "Utility",
9+
"visibility": [
10+
"Build",
11+
"Release"
12+
],
13+
"author": "Canhua Li",
14+
"version": {
15+
"Major": 0,
16+
"Minor": 1,
17+
"Patch": 0
18+
},
19+
"instanceNameFormat": "Echo $(WinAppDriverVersion)",
20+
"inputs": [
21+
{
22+
"name": "WinAppDriverVersion",
23+
"type": "string",
24+
"label": "WinAppDriver Version",
25+
"defaultValue": "v1.1",
26+
"required": true
27+
}
28+
],
29+
"execution": {
30+
"Node10": {
31+
"target": "installer.js"
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)