@dynamicweb/cli 1.0.2 → 1.0.3

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.
@@ -40,15 +40,27 @@ export function envCommand() {
40
40
  }
41
41
 
42
42
  export async function setupEnv(argv) {
43
- let env;
44
- if (getConfig().env) {
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 (!env) {
63
+ else if (askEnv) {
52
64
  console.log('Current environment not set, please set it')
53
65
  await interactiveEnv(argv, {
54
66
  environment: {
@@ -18,11 +18,24 @@ export function loginCommand() {
18
18
  }
19
19
 
20
20
  export async function setupUser(argv, env) {
21
- let user;
22
- if (env.users) {
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
- if (!user) {
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
@@ -2,7 +2,7 @@
2
2
  "name": "@dynamicweb/cli",
3
3
  "type": "module",
4
4
  "description": "Dynamicweb CLI is a commandline tool for interacting with Dynamicweb 10 solutions.",
5
- "version": "1.0.2",
5
+ "version": "1.0.3",
6
6
  "main": "bin/index.js",
7
7
  "files": [
8
8
  "bin/*"