Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit 728b23b

Browse files
authored
Merge pull request #2 from microsoft/dev
Dev
2 parents 2b1d463 + 2421c30 commit 728b23b

18 files changed

+1867
-0
lines changed

.github/workflows/ci-tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI Tests
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, macos-latest, windows-latest]
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
name: Checkout repo
16+
17+
- name: Setup node
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: 10.x
21+
22+
- name: Install dependencies
23+
run: |
24+
npm install -g typescript
25+
npm install -g ts-node
26+
npm install -g mocha
27+
npm install
28+
29+
- name: Build code
30+
run: npm run build
31+
32+
- name: Run all tests
33+
run: npm run test
34+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
*.vsix
4+
.taskkey
5+
**/.taskkey

.mocharc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"diff": true,
3+
"extension": ["js"],
4+
"opts": false,
5+
"package": "./package.json",
6+
"reporter": "spec",
7+
"slow": 75,
8+
"timeout": 15000,
9+
"watch-files": ["dist/test/**/*.js"]
10+
}

ado-extension.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"manifestVersion": 1,
3+
"id": "android-app-size-diff",
4+
"name": "Android app size changes",
5+
"version": "0.0.19",
6+
"publisher": "PraveenPendyala",
7+
"targets": [
8+
{
9+
"id": "Microsoft.VisualStudio.Services"
10+
}
11+
],
12+
"description": "Tools for Android app size changes",
13+
"categories": [
14+
"Azure Pipelines"
15+
],
16+
"icons": {
17+
"default": "dist/src/assets/appSizeChangesIcon.png"
18+
},
19+
"files": [
20+
{
21+
"path": "dist/src/"
22+
}
23+
],
24+
"contributions": [
25+
{
26+
"id": "android-app-size-diff-task",
27+
"type": "ms.vss-distributed-task.task",
28+
"targets": [
29+
"ms.vss-distributed-task.tasks"
30+
],
31+
"properties": {
32+
"name": "dist/src/"
33+
}
34+
}
35+
]
36+
}

bumpVersion.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import fs from 'fs'
2+
3+
const bumpMetric = process.argv[2];
4+
const supportedBumps = ["major", "minor", "patch"]
5+
6+
const nodePackagJsonPath = 'package.json';
7+
const adoExtensionJsonPath = 'ado-extension.json';
8+
const adoTaskJsonPath = 'ado-task.json';
9+
10+
if (process.argv.length != 3) {
11+
throw "Need exactly one argument!"
12+
}
13+
14+
if (!supportedBumps.includes(bumpMetric)) {
15+
console.error("Cannot bump `" + bumpMetric + "`. Can only bump one of " + supportedBumps.join("/"))
16+
throw "Invalid bump requested!"
17+
}
18+
19+
var nodePackageJson = JSON.parse(fs.readFileSync(nodePackagJsonPath,'utf8'));
20+
var adoExtensionJson = JSON.parse(fs.readFileSync(adoExtensionJsonPath,'utf8'));
21+
var adoTaskJson = JSON.parse(fs.readFileSync(adoTaskJsonPath,'utf8'));
22+
23+
const versions = nodePackageJson['version'].split(".");
24+
var major = Number(versions[0]);
25+
var minor = Number(versions[1]);
26+
var patch = Number(versions[2]);
27+
28+
if (bumpMetric == 'major') {
29+
major += 1;
30+
minor = 0;
31+
patch = 0;
32+
} else if (bumpMetric == 'minor') {
33+
minor += 1;
34+
patch = 0;
35+
} else {
36+
patch += 1;
37+
}
38+
39+
const newVersion = major + "." + minor + "." + patch;
40+
41+
// Update each jsons
42+
nodePackageJson['version'] = newVersion;
43+
adoExtensionJson['version'] = newVersion;
44+
adoTaskJson['version']['Major'] = major;
45+
adoTaskJson['version']['Minor'] = minor;
46+
adoTaskJson['version']['Patch'] = patch;
47+
48+
fs.writeFileSync(nodePackagJsonPath, JSON.stringify(nodePackageJson, null, 4));
49+
fs.writeFileSync(adoExtensionJsonPath, JSON.stringify(adoExtensionJson, null, 4));
50+
fs.writeFileSync(adoTaskJsonPath, JSON.stringify(adoTaskJson, null, 4));
51+
52+
console.log("New version is: " + newVersion);

copyFiles.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as shell from "shelljs";
2+
3+
console.log('Copying files..');
4+
shell.cp("-R", "src/assets", "dist/src");
5+
shell.cp("-R", "node_modules", "dist/src");
6+
shell.cp("src/task.json", "dist/src/task.json");
7+
shell.cp("-R", "test/assets", "dist/test");

downloadAndroidSdk.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import download from 'download'
2+
import * as shell from "shelljs";
3+
4+
const platform = process.argv[2];
5+
const platforms: any = {
6+
'Darwin' : {
7+
'sdk-tools-url': 'https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip',
8+
'build-tools-url': 'https://dl.google.com/android/repository/build-tools_r28-macosx.zip'
9+
},
10+
'Linux' : {
11+
'sdk-tools-url': 'https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip',
12+
'build-tools-url': 'https://dl.google.com/android/repository/build-tools_r28-linux.zip'
13+
},
14+
'Windows_NT' : {
15+
'sdk-tools-url': 'https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip',
16+
'build-tools-url': 'https://dl.google.com/android/repository/build-tools_r28-windows.zip'
17+
}
18+
}
19+
20+
if (process.argv.length != 3) {
21+
throw "Need exactly one argument!"
22+
}
23+
24+
if (!['Darwin', 'Linux', 'Windows_NT'].includes(platform)) {
25+
console.error("Invalid platform `" + platform + "`. Can only select one of Darwin/Linux/Windows_NT" );
26+
throw "Invalid platform selection!"
27+
}
28+
29+
async function downloadAndExtract() {
30+
const destPath = 'dist/src/bin/' + platform + '/'
31+
const sdkToolsUrl = platforms[platform]['sdk-tools-url']
32+
const buildToolsUrl = platforms[platform]['build-tools-url']
33+
34+
console.log('Downloading Android sdk tools for ' + platform + '..');
35+
await download(sdkToolsUrl, destPath, {'extract': true});
36+
37+
console.log('Downloading Android build tools for ' + platform + '..');
38+
await download(buildToolsUrl, destPath + 'build-tools', {'extract': true});
39+
40+
console.log('Moving build tools to correct path..');
41+
shell.mv(destPath + 'build-tools/android-9', destPath + 'build-tools/28.0.0');
42+
43+
console.log('Removing unnecessary files..');
44+
const toolsPath = destPath + 'tools/';
45+
shell.rm('-rf', toolsPath + 'proguard');
46+
shell.rm('-rf', toolsPath + 'support');
47+
shell.rm('-rf', toolsPath + 'lib/monitor*');
48+
shell.rm('-rf', toolsPath + 'lib/x86*');
49+
}
50+
51+
downloadAndExtract();

0 commit comments

Comments
 (0)