-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
79 lines (70 loc) · 1.97 KB
/
index.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
79
#!/usr/bin/env node
require(`dotenv`).config({ path: `${__dirname}/.env` });
const program = require(`commander`);
const readline = require(`readline-sync`);
const log = require(`./logger`);
const files = require(`./files`);
const nuget = require(`./nuget`);
const msbuild = require(`./msbuild`);
const logAll = (results) => {
log(`-----------`);
log(`found the following solutions:`);
for (let i = 0; i < results.length; i += 1) {
log(`${i + 1} -- ${results[i]}`);
}
log(`----------`);
log(``);
};
const build = (solution) => {
const getSources = () => {
const NUGET_ORG = `https://api.nuget.org/v3/index.json`;
if (process.env.NUGET_SOURCES !== undefined) {
return process.env.NUGET_SOURCES.split(`;`).push(NUGET_ORG);
}
return [NUGET_ORG];
};
nuget
.restore({
packages: solution,
source: getSources(),
})
.then(() => {
msbuild.build(solution, program.configuration, program.clean);
});
};
const buildAll = (allSolutions) => {
log(`building *all* solutions found`);
for (let i = 0; i < allSolutions.length; i += 1) {
build(allSolutions[i]);
}
};
program
.version(`1.0.0`)
.option(
`-c, --configuration <configurationProfile>`,
`configuration. Defaults to "Debug"`,
`Debug`,
)
.option(`-cl, --clean`, `cleans solution before building`, false)
.option(`-a, --all`, `flag to indicate that all solutions found should be compiled`, false)
.parse(process.argv);
files.find().then((results) => {
if (results.length === 0) {
log(`No solutions found`);
} else if (program.all) {
buildAll(results);
} else if (results.length === 1) {
build(results[0]);
} else {
logAll(results);
const response = readline.question(
`Which solution do you want to build? Enter the number or type "abort" to cancel:`,
);
if (response === `abort`) {
log(`build cancelled`);
return;
}
const solution = results[Number(response) - 1];
build(solution);
}
});