@dynamicweb/cli 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/env.js +15 -3
- package/bin/commands/files.js +5 -2
- package/bin/commands/login.js +17 -3
- package/bin/index.js +9 -0
- package/package.json +1 -1
package/bin/commands/env.js
CHANGED
|
@@ -40,15 +40,27 @@ export function envCommand() {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export async function setupEnv(argv) {
|
|
43
|
-
let env;
|
|
44
|
-
|
|
43
|
+
let env = {};
|
|
44
|
+
let askEnv = true;
|
|
45
|
+
|
|
46
|
+
if (argv.host) {
|
|
47
|
+
askEnv = false;
|
|
48
|
+
env.host = argv.host;
|
|
49
|
+
if (argv.protocol) {
|
|
50
|
+
env.protocol = argv.protocol;
|
|
51
|
+
} else {
|
|
52
|
+
env.protocol = 'https';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (askEnv && getConfig().env) {
|
|
45
57
|
env = getConfig().env[argv.env] || getConfig().env[getConfig()?.current?.env];
|
|
46
58
|
if (!env.protocol) {
|
|
47
59
|
console.log('Protocol for environment not set, defaulting to https');
|
|
48
60
|
env.protocol = 'https';
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
|
-
if (
|
|
63
|
+
else if (askEnv) {
|
|
52
64
|
console.log('Current environment not set, please set it')
|
|
53
65
|
await interactiveEnv(argv, {
|
|
54
66
|
environment: {
|
package/bin/commands/files.js
CHANGED
|
@@ -194,6 +194,7 @@ async function download(env, user, dirPath, outPath, recursive, outname, raw, ia
|
|
|
194
194
|
let excludeDirectories = '';
|
|
195
195
|
if (!iamstupid) {
|
|
196
196
|
excludeDirectories = 'system/log';
|
|
197
|
+
console.log(dirPath)
|
|
197
198
|
if (dirPath === 'cache.net') {
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
@@ -213,7 +214,8 @@ async function download(env, user, dirPath, outPath, recursive, outname, raw, ia
|
|
|
213
214
|
console.log('Downloading', dirPath === '/.' ? 'Base' : dirPath, 'Recursive=' + recursive);
|
|
214
215
|
|
|
215
216
|
let filename;
|
|
216
|
-
|
|
217
|
+
console.log(data)
|
|
218
|
+
console.log(`${env.protocol}://${env.host}/Admin/Api/${endpoint}`)
|
|
217
219
|
fetch(`${env.protocol}://${env.host}/Admin/Api/${endpoint}`, {
|
|
218
220
|
method: 'POST',
|
|
219
221
|
body: JSON.stringify(data),
|
|
@@ -274,7 +276,7 @@ export async function uploadFiles(env, user, localFilePaths, destinationPath, cr
|
|
|
274
276
|
console.log(localPath)
|
|
275
277
|
form.append('files', fs.createReadStream(path.resolve(localPath)));
|
|
276
278
|
});
|
|
277
|
-
let res = await fetch(`${env.protocol}://${env.host}/Admin/Api/Upload?` + new URLSearchParams({"createEmptyFiles": createEmpty}), {
|
|
279
|
+
let res = await fetch(`${env.protocol}://${env.host}/Admin/Api/Upload?` + new URLSearchParams({"createEmptyFiles": createEmpty, "createMissingDirectories": true}), {
|
|
278
280
|
method: 'POST',
|
|
279
281
|
body: form,
|
|
280
282
|
headers: {
|
|
@@ -288,6 +290,7 @@ export async function uploadFiles(env, user, localFilePaths, destinationPath, cr
|
|
|
288
290
|
}
|
|
289
291
|
else {
|
|
290
292
|
console.log(res)
|
|
293
|
+
console.log(res.json())
|
|
291
294
|
return;
|
|
292
295
|
}
|
|
293
296
|
}
|
package/bin/commands/login.js
CHANGED
|
@@ -18,11 +18,24 @@ export function loginCommand() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export async function setupUser(argv, env) {
|
|
21
|
-
let user;
|
|
22
|
-
|
|
21
|
+
let user = {};
|
|
22
|
+
let askLogin = true;
|
|
23
|
+
|
|
24
|
+
if (argv.apiKey) {
|
|
25
|
+
user.apiKey = argv.apiKey;
|
|
26
|
+
askLogin = false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!user.apiKey && env.users) {
|
|
23
30
|
user = env.users[argv.user] || env.users[env.current.user];
|
|
31
|
+
askLogin = false;
|
|
24
32
|
}
|
|
25
|
-
|
|
33
|
+
|
|
34
|
+
if (askLogin && argv.host) {
|
|
35
|
+
console.log('Please add an --apiKey to the command as overriding the host requires that.')
|
|
36
|
+
process.exit();
|
|
37
|
+
}
|
|
38
|
+
else if (askLogin) {
|
|
26
39
|
console.log('Current user not set, please login')
|
|
27
40
|
await interactiveLogin(argv, {
|
|
28
41
|
environment: {
|
|
@@ -42,6 +55,7 @@ export async function setupUser(argv, env) {
|
|
|
42
55
|
})
|
|
43
56
|
user = env.users[env.current.user];
|
|
44
57
|
}
|
|
58
|
+
|
|
45
59
|
return user;
|
|
46
60
|
}
|
|
47
61
|
|
package/bin/index.js
CHANGED
|
@@ -31,6 +31,15 @@ yargs(hideBin(process.argv))
|
|
|
31
31
|
type: 'boolean',
|
|
32
32
|
description: 'Run with verbose logging'
|
|
33
33
|
})
|
|
34
|
+
.option('protocol', {
|
|
35
|
+
description: 'Allows setting the protocol used, only used together with --host, defaulting to https'
|
|
36
|
+
})
|
|
37
|
+
.option('host', {
|
|
38
|
+
description: 'Allows setting the host used, only allowed if an --apiKey is specified'
|
|
39
|
+
})
|
|
40
|
+
.option('apiKey', {
|
|
41
|
+
description: 'Allows setting the apiKey for an environmentless execution of the CLI command'
|
|
42
|
+
})
|
|
34
43
|
.demandCommand()
|
|
35
44
|
.parse()
|
|
36
45
|
|
package/package.json
CHANGED