Skip to content

Commit 4e271fd

Browse files
authored
Merge pull request #2 from geeklearningio/feature/npm-package
Npm Package
2 parents 504c6be + 76d8748 commit 4e271fd

11 files changed

+116
-4
lines changed

README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,87 @@
1-
# gl-vsts-tasks-build
1+
# gl-vsts-tasks-build
2+
3+
This package provides npm utility commands to ease **VSTS Build And Release Tasks** extensions developement.
4+
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).
5+
6+
## Features
7+
8+
* **Multiple packages generation** : This allows you to generate testing versions of the extension using unique ids, so you can easily
9+
test your extension and setup staged deployment to the store. At Geek Learning our CI builds 3 versions of the extension
10+
(Dev, Preview, Production) and stores them as build artifacts. We then use Release Management to publish them to the marketplace.
11+
Dev package is always published automatically upon successfull build. Preview and Production are manually pushed if it passes our
12+
final review. Ids and packages settings, are defined in the `Configuration.json` file
13+
* **Manifest automation** : We automatically populate the contributions in the vss-extension in order to reduced manual maintainance
14+
of this file.
15+
* **Common shared code** : We provide an easy way to share powershell or node scripts accros your tasks without the need to make a
16+
package of them. Place them in the right subfolder of `Common` and they will be automatically copied where appropriate on build.
17+
* **Node : Automic dependency installation** : Vsts Agent node execution engine requires npm dependencies to be bundled with your task
18+
We automatically install two dependencies as a postbuild step after a successfull `npm install` at root.
19+
* **Automatic versionning** : Visual Studio Marketplace does not support semver, but we always rely on it when it comes to versionnning.
20+
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
21+
source of versionning.
22+
23+
## Project structure
24+
25+
At the moment, if you wish to use this tooling, your project will need to comply with the architecture we designed.
26+
27+
Directory Structure
28+
```
29+
Root
30+
|-- package.json
31+
|-- Configuration.json
32+
|-- tsconfig.json // Optional if not using typescript
33+
|-- Common // Optional
34+
| |-- Node // Node common scripts
35+
| | |-- *.ts
36+
| |
37+
| |-- Powershell3 // Powershell3 common scripts
38+
| | |-- *.ps1
39+
|
40+
|-- Extension
41+
| |-- vss-extension.json // Extension Manifest
42+
| |-- ...
43+
|
44+
|-- Tasks // Task Directory
45+
| |-- NodeTask1
46+
| | |-- task.json // Task manifest
47+
| | |-- icon.png // Task icon
48+
| | |-- package.json // Package.json, this is where this task dependencies must be listed
49+
| | |-- *.ts // Task source files
50+
| | |-- ...
51+
| |
52+
| |-- PowershellTask1
53+
| | |-- task.json
54+
| | |-- icon.png
55+
| | |-- *.ps1 // Task powershell scripts
56+
| | |-- ...
57+
| |
58+
| | -- ...
59+
```
60+
61+
## Root `Package.json`
62+
63+
First you should install this package
64+
65+
```bash
66+
npm install gl-vsts-tasks-build-scripts --save-dev
67+
```
68+
69+
Then to get the best of this tooling we recommand that you tweak your `package.json` file a little by adding a few `scripts` :
70+
```json
71+
{
72+
"scripts": {
73+
"clean": "vsts-build-tools-clean",
74+
"postinstall": "vsts-build-tools-install",
75+
"prebuild": "vsts-build-tools-prebuild",
76+
"build": "tsc",
77+
"package": "vsts-build-tools-package"
78+
}
79+
}
80+
```
81+
82+
You can now restore or update dependencies and task bundled dependencies by running a single `npm install` at the root.
83+
You can clean common files using `npm run clean`
84+
You can build node tasks using `npm run build`
85+
You can package your extension by running `npm run package`. Output will be placed in the `.BuildOutput` subdirectory at root.
86+
87+

extension-version.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ exports.getSemanticVersion = () => {
1212
console.log('Found version: ' + version);
1313
}
1414

15+
if (options.disable-version-transform){
16+
return version;
17+
}
18+
1519
if (!semver.valid(version)) {
1620
throw new Error('Package: invalid semver version: ' + version);
1721
}

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"name": "gl-vsts-tasks-build-scripts",
3-
"private": true,
3+
"private": false,
44
"version": "0.0.0",
5+
"bin": {
6+
"vsts-build-tools-clean": "./run/vsts-build-tools-clean",
7+
"vsts-build-tools-install": "./run/vsts-build-tools-install",
8+
"vsts-build-tools-package": "./run/vsts-build-tools-package",
9+
"vsts-build-tools-prebuild": "./run/vsts-build-tools-prebuild"
10+
},
511
"devDependencies": {
612
"async": "^2.0.1",
713
"fs-extra": "0.30.0",
@@ -11,9 +17,9 @@
1117
"tslint": "^3.6.0",
1218
"typescript": "^1.8.10",
1319
"typings": "1.3.2",
14-
"jasmine" : "2.4.1",
20+
"jasmine": "2.4.1",
1521
"semver": "5.3.0",
1622
"tfx-cli": "0.3.23",
1723
"glob": "7.0.5"
1824
}
19-
}
25+
}

run/vsts-build-tools-clean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../clean');

run/vsts-build-tools-clean.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@node "%~dpn0" %*

run/vsts-build-tools-install

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../install');

run/vsts-build-tools-install.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@node "%~dpn0" %*

run/vsts-build-tools-package

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../package');

run/vsts-build-tools-package.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@node "%~dpn0" %*

run/vsts-build-tools-prebuild

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../prebuild');

0 commit comments

Comments
 (0)