-
Notifications
You must be signed in to change notification settings - Fork 62
/
deploy.js
80 lines (70 loc) · 2.17 KB
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Deploys nupkg to local cache dir for testing
*/
var fs = require("fs-extra");
var del = require('del');
const bu = require('.\\build-utils');
const localNugetCacheDir = process.env.LOCALAPPDATA + '\\NuGet\\Test';
const version = '3.1.4';
const debugOrRelease = 'Release'
var baseNames = [
'Breeze.AspNetCore.NetCore',
'Breeze.Core',
'Breeze.Persistence',
'Breeze.Persistence.EFCore',
'Breeze.Persistence.NH',
];
const arg = bu.getArg();
argl = arg.toLowerCase();
if (argl == 'local') {
deployLocal();
} else if (argl == 'remote') {
deployRemote();
} else {
console.log(`You must pass in either 'local' or 'remote'. You passed: ${argl}`);
}
// should ONLY be called manually after testing locally installed nugets from nugetPack step.
// deliberately does NOT have a dependency on nugetPack
function deployLocal() {
deleteLocalAppCache(baseNames);
const nupkgs = getNupkgs(baseNames);
nupkgs.forEach(nupkg => {
// call will look something like the line below
// --> nuget add .\Breeze.Core\bin\Debug\Breeze.Core.5.0.2.nupkg -Source C:/Users/Jay/AppData/Local/NuGet/Test
cmd = `nuget add ${nupkg} -Source ${localNugetCacheDir}`;
console.log(cmd);
bu.execCmd(cmd);
});
}
function deployRemote() {
// Before running, put the nuget key in a file 2 levels above (outside the repo)
const key = bu.readFirstLine('../../~nugetkey.txt');
const nupkgs = getNupkgs(baseNames);
nupkgs.forEach(nupkg => {
var cmd = `nuget push ${nupkg} ${key} -Source https://www.nuget.org`;
console.log(cmd);
bu.execCmd(cmd);
});
}
function getNupkgs(baseNames) {
const nupkgs = baseNames.map(baseName => {
// check if nupkg exists.
var fn = `.\\${baseName}\\bin\\${debugOrRelease}\\${baseName}.${version}.nupkg`;
if (!fs.existsSync(fn)) {
console.log('Unable to locate: ' + fn);
process.exit(1);
}
return fn;
});
return nupkgs;
}
function deleteLocalAppCache(baseNames) {
baseNames.forEach(baseName => {
const cacheDir = localNugetCacheDir + '\\' + baseName;
console.log(cacheDir);
if (fs.existsSync(cacheDir)) {
console.log('Deleting: ' + cacheDir)
del(cacheDir, { force: true} );
}
})
};