forked from andnilsson/dyn365-deploy-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-init.ts
79 lines (73 loc) · 2.45 KB
/
deploy-init.ts
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
import { writeFiglet } from './figlet';
import { variables } from './ivariables';
var p = require('prompt');
var fs = require('fs');
var path = require('path');
async function init() {
await writeFiglet("init");
var configfilename = '.crmdeployconfig';
var config = await getvariablesAsync();
var dir = path.dirname(process.cwd()) + '\\' + path.basename(process.cwd());
config.baseurl = dir + '\\' + config.baseurl;
fs.writeFile(dir + '\\' + configfilename, JSON.stringify(config), (err) => {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
async function getvariablesAsync(): Promise<variables> {
return new Promise<variables>((resolve, reject) => {
var schema = {
properties: {
baseurl: {
message: 'build folder relative to this path',
default: "stq_",
required: true
},
username: {
message: 'dyn365 username to impersonate',
required: true
},
password: {
hidden: true
},
clientid: {
message: 'client id of azure ad app',
required: true
},
clientsecret: {
required: true
},
resource: {
message: 'Resource (usually the dyn 365 instance)',
required: true
},
commonAuthority: {
message: "Common Authority (usually something like : 'https://login.windows.net/<<tenant>>.onmicrosoft.com/oauth2/token')",
required: true
},
apiversion: {
default: "8.2",
message: 'crm api version',
required: true
},
publisher: {
default: "stq_",
message: 'crm default publisher prefix',
required: true
},
}
};
p.start();
var params = {} as variables;
p.get(schema, (err, result) => {
var params = {} as variables;
for (var key in result) {
params[key] = result[key];
}
resolve(params);
});
});
}
init();