cawplan 0.0.0 → 0.0.1

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.
@@ -49,19 +49,30 @@ export function registerAuthCommand(program) {
49
49
  const envNames = getEnvNames();
50
50
  const defaultEnv = existingConfig?.env ?? getDefaultEnvName();
51
51
  console.log("Open https://www.cawplan.com/account/api to generate an API Key");
52
- const env = await promptWithDefault(`Environment (${envNames.join(" / ")})`, defaultEnv);
53
- if (!envNames.includes(env)) {
54
- error(`Unknown environment '${env}'. Expected one of: ${envNames.join(", ")}`);
55
- process.exit(1);
52
+ let env;
53
+ let baseUrl;
54
+ let portalUrl;
55
+ if (envNames.length === 1) {
56
+ env = envNames[0] ?? getDefaultEnvName();
57
+ const envConfig = getProductEnvConfig(env);
58
+ baseUrl = envConfig.apiBase;
59
+ portalUrl = envConfig.portalBase;
60
+ }
61
+ else {
62
+ env = await promptWithDefault(`Environment (${envNames.join(" / ")})`, defaultEnv);
63
+ if (!envNames.includes(env)) {
64
+ error(`Unknown environment '${env}'. Expected one of: ${envNames.join(", ")}`);
65
+ process.exit(1);
66
+ }
67
+ const envConfig = getProductEnvConfig(env);
68
+ const useExistingUrls = existingConfig?.env === env;
69
+ const baseUrlDefault = useExistingUrls && existingConfig?.baseUrl ? existingConfig.baseUrl : envConfig.apiBase;
70
+ const portalUrlDefault = useExistingUrls && existingConfig?.portalUrl
71
+ ? existingConfig.portalUrl
72
+ : envConfig.portalBase;
73
+ baseUrl = await promptWithDefault("API base URL", baseUrlDefault);
74
+ portalUrl = await promptWithDefault("Portal URL", portalUrlDefault);
56
75
  }
57
- const envConfig = getProductEnvConfig(env);
58
- const useExistingUrls = existingConfig?.env === env;
59
- const baseUrlDefault = useExistingUrls && existingConfig?.baseUrl ? existingConfig.baseUrl : envConfig.apiBase;
60
- const portalUrlDefault = useExistingUrls && existingConfig?.portalUrl
61
- ? existingConfig.portalUrl
62
- : envConfig.portalBase;
63
- const baseUrl = await promptWithDefault("API base URL", baseUrlDefault);
64
- const portalUrl = await promptWithDefault("Portal URL", portalUrlDefault);
65
76
  const apiKey = await prompt("Paste your API Key: ");
66
77
  if (!apiKey) {
67
78
  error("API Key cannot be empty");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cawplan",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "CawPlan CLI",
5
5
  "author": "Ubiquiti UID",
6
6
  "license": "MIT",