@xano/cli 1.0.2-beta.5 → 1.0.2-beta.7

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.
Files changed (156) hide show
  1. package/README.md +87 -0
  2. package/dist/base-command.d.ts +21 -1
  3. package/dist/base-command.js +92 -6
  4. package/dist/commands/branch/create/index.d.ts +0 -1
  5. package/dist/commands/branch/create/index.js +1 -38
  6. package/dist/commands/branch/delete/index.d.ts +0 -1
  7. package/dist/commands/branch/delete/index.js +1 -39
  8. package/dist/commands/branch/edit/index.d.ts +0 -1
  9. package/dist/commands/branch/edit/index.js +1 -39
  10. package/dist/commands/branch/get/index.d.ts +0 -1
  11. package/dist/commands/branch/get/index.js +1 -39
  12. package/dist/commands/branch/list/index.d.ts +0 -1
  13. package/dist/commands/branch/list/index.js +1 -39
  14. package/dist/commands/branch/set_live/index.d.ts +0 -1
  15. package/dist/commands/branch/set_live/index.js +1 -39
  16. package/dist/commands/function/create/index.d.ts +0 -1
  17. package/dist/commands/function/create/index.js +1 -38
  18. package/dist/commands/function/edit/index.d.ts +0 -1
  19. package/dist/commands/function/edit/index.js +1 -37
  20. package/dist/commands/function/get/index.d.ts +0 -1
  21. package/dist/commands/function/get/index.js +1 -38
  22. package/dist/commands/function/list/index.d.ts +0 -1
  23. package/dist/commands/function/list/index.js +1 -39
  24. package/dist/commands/platform/get/index.d.ts +0 -1
  25. package/dist/commands/platform/get/index.js +1 -33
  26. package/dist/commands/platform/list/index.d.ts +0 -1
  27. package/dist/commands/platform/list/index.js +1 -33
  28. package/dist/commands/profile/use/index.d.ts +33 -0
  29. package/dist/commands/profile/use/index.js +179 -0
  30. package/dist/commands/release/create/index.d.ts +0 -1
  31. package/dist/commands/release/create/index.js +1 -33
  32. package/dist/commands/release/delete/index.d.ts +0 -1
  33. package/dist/commands/release/delete/index.js +1 -33
  34. package/dist/commands/release/deploy/index.js +1 -12
  35. package/dist/commands/release/edit/index.d.ts +0 -1
  36. package/dist/commands/release/edit/index.js +1 -33
  37. package/dist/commands/release/export/index.d.ts +0 -1
  38. package/dist/commands/release/export/index.js +1 -31
  39. package/dist/commands/release/get/index.d.ts +0 -1
  40. package/dist/commands/release/get/index.js +1 -33
  41. package/dist/commands/release/import/index.d.ts +0 -1
  42. package/dist/commands/release/import/index.js +1 -32
  43. package/dist/commands/release/list/index.d.ts +0 -1
  44. package/dist/commands/release/list/index.js +1 -32
  45. package/dist/commands/release/pull/index.d.ts +0 -1
  46. package/dist/commands/release/pull/index.js +2 -38
  47. package/dist/commands/release/push/index.d.ts +0 -1
  48. package/dist/commands/release/push/index.js +1 -37
  49. package/dist/commands/static_host/build/create/index.d.ts +0 -1
  50. package/dist/commands/static_host/build/create/index.js +1 -39
  51. package/dist/commands/static_host/build/get/index.d.ts +0 -1
  52. package/dist/commands/static_host/build/get/index.js +1 -39
  53. package/dist/commands/static_host/build/list/index.d.ts +0 -1
  54. package/dist/commands/static_host/build/list/index.js +1 -39
  55. package/dist/commands/static_host/list/index.d.ts +0 -1
  56. package/dist/commands/static_host/list/index.js +1 -39
  57. package/dist/commands/tenant/backup/create/index.d.ts +0 -1
  58. package/dist/commands/tenant/backup/create/index.js +1 -33
  59. package/dist/commands/tenant/backup/delete/index.d.ts +0 -1
  60. package/dist/commands/tenant/backup/delete/index.js +1 -32
  61. package/dist/commands/tenant/backup/export/index.d.ts +0 -1
  62. package/dist/commands/tenant/backup/export/index.js +1 -31
  63. package/dist/commands/tenant/backup/import/index.d.ts +0 -1
  64. package/dist/commands/tenant/backup/import/index.js +1 -32
  65. package/dist/commands/tenant/backup/list/index.d.ts +0 -1
  66. package/dist/commands/tenant/backup/list/index.js +1 -33
  67. package/dist/commands/tenant/backup/restore/index.d.ts +0 -1
  68. package/dist/commands/tenant/backup/restore/index.js +1 -32
  69. package/dist/commands/tenant/cluster/create/index.d.ts +0 -1
  70. package/dist/commands/tenant/cluster/create/index.js +1 -31
  71. package/dist/commands/tenant/cluster/delete/index.d.ts +0 -1
  72. package/dist/commands/tenant/cluster/delete/index.js +1 -33
  73. package/dist/commands/tenant/cluster/edit/index.d.ts +0 -1
  74. package/dist/commands/tenant/cluster/edit/index.js +1 -33
  75. package/dist/commands/tenant/cluster/get/index.d.ts +0 -1
  76. package/dist/commands/tenant/cluster/get/index.js +1 -32
  77. package/dist/commands/tenant/cluster/license/get/index.d.ts +0 -1
  78. package/dist/commands/tenant/cluster/license/get/index.js +1 -31
  79. package/dist/commands/tenant/cluster/license/set/index.d.ts +0 -1
  80. package/dist/commands/tenant/cluster/license/set/index.js +1 -31
  81. package/dist/commands/tenant/cluster/list/index.d.ts +0 -1
  82. package/dist/commands/tenant/cluster/list/index.js +1 -32
  83. package/dist/commands/tenant/create/index.d.ts +0 -1
  84. package/dist/commands/tenant/create/index.js +1 -30
  85. package/dist/commands/tenant/delete/index.d.ts +0 -1
  86. package/dist/commands/tenant/delete/index.js +1 -33
  87. package/dist/commands/tenant/deploy_platform/index.d.ts +0 -1
  88. package/dist/commands/tenant/deploy_platform/index.js +1 -31
  89. package/dist/commands/tenant/deploy_release/index.d.ts +0 -1
  90. package/dist/commands/tenant/deploy_release/index.js +1 -32
  91. package/dist/commands/tenant/edit/index.d.ts +0 -1
  92. package/dist/commands/tenant/edit/index.js +1 -33
  93. package/dist/commands/tenant/env/delete/index.d.ts +0 -1
  94. package/dist/commands/tenant/env/delete/index.js +1 -32
  95. package/dist/commands/tenant/env/get/index.d.ts +0 -1
  96. package/dist/commands/tenant/env/get/index.js +1 -32
  97. package/dist/commands/tenant/env/get_all/index.d.ts +0 -1
  98. package/dist/commands/tenant/env/get_all/index.js +1 -30
  99. package/dist/commands/tenant/env/list/index.d.ts +0 -1
  100. package/dist/commands/tenant/env/list/index.js +1 -32
  101. package/dist/commands/tenant/env/set/index.d.ts +0 -1
  102. package/dist/commands/tenant/env/set/index.js +1 -32
  103. package/dist/commands/tenant/env/set_all/index.d.ts +0 -1
  104. package/dist/commands/tenant/env/set_all/index.js +1 -30
  105. package/dist/commands/tenant/get/index.d.ts +0 -1
  106. package/dist/commands/tenant/get/index.js +1 -32
  107. package/dist/commands/tenant/impersonate/index.d.ts +0 -1
  108. package/dist/commands/tenant/impersonate/index.js +1 -32
  109. package/dist/commands/tenant/license/get/index.d.ts +0 -1
  110. package/dist/commands/tenant/license/get/index.js +1 -31
  111. package/dist/commands/tenant/license/set/index.d.ts +0 -1
  112. package/dist/commands/tenant/license/set/index.js +1 -31
  113. package/dist/commands/tenant/list/index.d.ts +0 -1
  114. package/dist/commands/tenant/list/index.js +1 -32
  115. package/dist/commands/tenant/pull/index.d.ts +0 -1
  116. package/dist/commands/tenant/pull/index.js +1 -37
  117. package/dist/commands/tenant/unit_test/list/index.js +1 -12
  118. package/dist/commands/tenant/unit_test/run/index.js +1 -12
  119. package/dist/commands/tenant/unit_test/run_all/index.js +1 -12
  120. package/dist/commands/tenant/workflow_test/list/index.js +1 -12
  121. package/dist/commands/tenant/workflow_test/run/index.js +1 -12
  122. package/dist/commands/tenant/workflow_test/run_all/index.js +1 -12
  123. package/dist/commands/unit_test/list/index.d.ts +0 -1
  124. package/dist/commands/unit_test/list/index.js +1 -33
  125. package/dist/commands/unit_test/run/index.d.ts +0 -1
  126. package/dist/commands/unit_test/run/index.js +1 -33
  127. package/dist/commands/unit_test/run_all/index.d.ts +0 -1
  128. package/dist/commands/unit_test/run_all/index.js +1 -32
  129. package/dist/commands/workflow_test/delete/index.d.ts +0 -1
  130. package/dist/commands/workflow_test/delete/index.js +1 -33
  131. package/dist/commands/workflow_test/get/index.d.ts +0 -1
  132. package/dist/commands/workflow_test/get/index.js +1 -33
  133. package/dist/commands/workflow_test/list/index.d.ts +0 -1
  134. package/dist/commands/workflow_test/list/index.js +1 -33
  135. package/dist/commands/workflow_test/run/index.d.ts +0 -1
  136. package/dist/commands/workflow_test/run/index.js +1 -33
  137. package/dist/commands/workflow_test/run_all/index.d.ts +0 -1
  138. package/dist/commands/workflow_test/run_all/index.js +1 -32
  139. package/dist/commands/workspace/create/index.d.ts +0 -1
  140. package/dist/commands/workspace/create/index.js +1 -39
  141. package/dist/commands/workspace/delete/index.d.ts +0 -1
  142. package/dist/commands/workspace/delete/index.js +1 -39
  143. package/dist/commands/workspace/edit/index.d.ts +0 -1
  144. package/dist/commands/workspace/edit/index.js +1 -38
  145. package/dist/commands/workspace/get/index.d.ts +0 -1
  146. package/dist/commands/workspace/get/index.js +1 -38
  147. package/dist/commands/workspace/list/index.d.ts +0 -1
  148. package/dist/commands/workspace/list/index.js +1 -38
  149. package/dist/commands/workspace/pull/index.d.ts +0 -1
  150. package/dist/commands/workspace/pull/index.js +1 -37
  151. package/dist/utils/local-config.d.ts +43 -0
  152. package/dist/utils/local-config.js +88 -0
  153. package/dist/utils/multidoc-push.d.ts +25 -0
  154. package/dist/utils/multidoc-push.js +39 -18
  155. package/oclif.manifest.json +2490 -2403
  156. package/package.json +1 -1
@@ -1,6 +1,4 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
- import * as fs from 'node:fs';
4
2
  import BaseCommand from '../../../../base-command.js';
5
3
  export default class TenantEnvGet extends BaseCommand {
6
4
  static args = {
@@ -38,19 +36,7 @@ postgres://localhost:5432/mydb
38
36
  };
39
37
  async run() {
40
38
  const { args, flags } = await this.parse(TenantEnvGet);
41
- const profileName = flags.profile || this.getDefaultProfile();
42
- const credentials = this.loadCredentials();
43
- if (!(profileName in credentials.profiles)) {
44
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
45
- `Create a profile using 'xano profile create'`);
46
- }
47
- const profile = credentials.profiles[profileName];
48
- if (!profile.instance_origin) {
49
- this.error(`Profile '${profileName}' is missing instance_origin`);
50
- }
51
- if (!profile.access_token) {
52
- this.error(`Profile '${profileName}' is missing access_token`);
53
- }
39
+ const { profile } = this.resolveProfile(flags);
54
40
  const workspaceId = flags.workspace || profile.workspace;
55
41
  if (!workspaceId) {
56
42
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -90,21 +76,4 @@ postgres://localhost:5432/mydb
90
76
  }
91
77
  }
92
78
  }
93
- loadCredentials() {
94
- const credentialsPath = this.getCredentialsPath();
95
- if (!fs.existsSync(credentialsPath)) {
96
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
97
- }
98
- try {
99
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
100
- const parsed = yaml.load(fileContent);
101
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
102
- this.error('Credentials file has invalid format.');
103
- }
104
- return parsed;
105
- }
106
- catch (error) {
107
- this.error(`Failed to parse credentials file: ${error}`);
108
- }
109
- }
110
79
  }
@@ -15,5 +15,4 @@ export default class TenantEnvGetAll extends BaseCommand {
15
15
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
16
  };
17
17
  run(): Promise<void>;
18
- private loadCredentials;
19
18
  }
@@ -46,19 +46,7 @@ Environment variables saved to env_my-tenant.yaml
46
46
  };
47
47
  async run() {
48
48
  const { args, flags } = await this.parse(TenantEnvGetAll);
49
- const profileName = flags.profile || this.getDefaultProfile();
50
- const credentials = this.loadCredentials();
51
- if (!(profileName in credentials.profiles)) {
52
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
53
- `Create a profile using 'xano profile create'`);
54
- }
55
- const profile = credentials.profiles[profileName];
56
- if (!profile.instance_origin) {
57
- this.error(`Profile '${profileName}' is missing instance_origin`);
58
- }
59
- if (!profile.access_token) {
60
- this.error(`Profile '${profileName}' is missing access_token`);
61
- }
49
+ const { profile } = this.resolveProfile(flags);
62
50
  const workspaceId = flags.workspace || profile.workspace;
63
51
  if (!workspaceId) {
64
52
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -101,21 +89,4 @@ Environment variables saved to env_my-tenant.yaml
101
89
  }
102
90
  }
103
91
  }
104
- loadCredentials() {
105
- const credentialsPath = this.getCredentialsPath();
106
- if (!fs.existsSync(credentialsPath)) {
107
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
108
- }
109
- try {
110
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
111
- const parsed = yaml.load(fileContent);
112
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
113
- this.error('Credentials file has invalid format.');
114
- }
115
- return parsed;
116
- }
117
- catch (error) {
118
- this.error(`Failed to parse credentials file: ${error}`);
119
- }
120
- }
121
92
  }
@@ -13,5 +13,4 @@ export default class TenantEnvList extends BaseCommand {
13
13
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
14
  };
15
15
  run(): Promise<void>;
16
- private loadCredentials;
17
16
  }
@@ -1,6 +1,4 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
- import * as fs from 'node:fs';
4
2
  import BaseCommand from '../../../../base-command.js';
5
3
  export default class TenantEnvList extends BaseCommand {
6
4
  static args = {
@@ -36,19 +34,7 @@ Environment variables for tenant my-tenant:
36
34
  };
37
35
  async run() {
38
36
  const { args, flags } = await this.parse(TenantEnvList);
39
- const profileName = flags.profile || this.getDefaultProfile();
40
- const credentials = this.loadCredentials();
41
- if (!(profileName in credentials.profiles)) {
42
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
43
- `Create a profile using 'xano profile create'`);
44
- }
45
- const profile = credentials.profiles[profileName];
46
- if (!profile.instance_origin) {
47
- this.error(`Profile '${profileName}' is missing instance_origin`);
48
- }
49
- if (!profile.access_token) {
50
- this.error(`Profile '${profileName}' is missing access_token`);
51
- }
37
+ const { profile } = this.resolveProfile(flags);
52
38
  const workspaceId = flags.workspace || profile.workspace;
53
39
  if (!workspaceId) {
54
40
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -93,21 +79,4 @@ Environment variables for tenant my-tenant:
93
79
  }
94
80
  }
95
81
  }
96
- loadCredentials() {
97
- const credentialsPath = this.getCredentialsPath();
98
- if (!fs.existsSync(credentialsPath)) {
99
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
100
- }
101
- try {
102
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
103
- const parsed = yaml.load(fileContent);
104
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
105
- this.error('Credentials file has invalid format.');
106
- }
107
- return parsed;
108
- }
109
- catch (error) {
110
- this.error(`Failed to parse credentials file: ${error}`);
111
- }
112
- }
113
82
  }
@@ -15,5 +15,4 @@ export default class TenantEnvSet extends BaseCommand {
15
15
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
16
  };
17
17
  run(): Promise<void>;
18
- private loadCredentials;
19
18
  }
@@ -1,6 +1,4 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
- import * as fs from 'node:fs';
4
2
  import BaseCommand from '../../../../base-command.js';
5
3
  export default class TenantEnvSet extends BaseCommand {
6
4
  static args = {
@@ -42,19 +40,7 @@ Environment variable 'DATABASE_URL' set for tenant my-tenant
42
40
  };
43
41
  async run() {
44
42
  const { args, flags } = await this.parse(TenantEnvSet);
45
- const profileName = flags.profile || this.getDefaultProfile();
46
- const credentials = this.loadCredentials();
47
- if (!(profileName in credentials.profiles)) {
48
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
49
- `Create a profile using 'xano profile create'`);
50
- }
51
- const profile = credentials.profiles[profileName];
52
- if (!profile.instance_origin) {
53
- this.error(`Profile '${profileName}' is missing instance_origin`);
54
- }
55
- if (!profile.access_token) {
56
- this.error(`Profile '${profileName}' is missing access_token`);
57
- }
43
+ const { profile } = this.resolveProfile(flags);
58
44
  const workspaceId = flags.workspace || profile.workspace;
59
45
  if (!workspaceId) {
60
46
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -99,21 +85,4 @@ Environment variable 'DATABASE_URL' set for tenant my-tenant
99
85
  }
100
86
  }
101
87
  }
102
- loadCredentials() {
103
- const credentialsPath = this.getCredentialsPath();
104
- if (!fs.existsSync(credentialsPath)) {
105
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
106
- }
107
- try {
108
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
109
- const parsed = yaml.load(fileContent);
110
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
111
- this.error('Credentials file has invalid format.');
112
- }
113
- return parsed;
114
- }
115
- catch (error) {
116
- this.error(`Failed to parse credentials file: ${error}`);
117
- }
118
- }
119
88
  }
@@ -15,5 +15,4 @@ export default class TenantEnvSetAll extends BaseCommand {
15
15
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
16
  };
17
17
  run(): Promise<void>;
18
- private loadCredentials;
19
18
  }
@@ -56,19 +56,7 @@ Reads from env_my-tenant.yaml
56
56
  this.error('Invalid env file format. Expected a YAML map of key: value pairs.');
57
57
  }
58
58
  const envs = Object.entries(envMap).map(([name, value]) => ({ name, value: String(value) }));
59
- const profileName = flags.profile || this.getDefaultProfile();
60
- const credentials = this.loadCredentials();
61
- if (!(profileName in credentials.profiles)) {
62
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
63
- `Create a profile using 'xano profile create'`);
64
- }
65
- const profile = credentials.profiles[profileName];
66
- if (!profile.instance_origin) {
67
- this.error(`Profile '${profileName}' is missing instance_origin`);
68
- }
69
- if (!profile.access_token) {
70
- this.error(`Profile '${profileName}' is missing access_token`);
71
- }
59
+ const { profile } = this.resolveProfile(flags);
72
60
  const workspaceId = flags.workspace || profile.workspace;
73
61
  if (!workspaceId) {
74
62
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -109,21 +97,4 @@ Reads from env_my-tenant.yaml
109
97
  }
110
98
  }
111
99
  }
112
- loadCredentials() {
113
- const credentialsPath = this.getCredentialsPath();
114
- if (!fs.existsSync(credentialsPath)) {
115
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
116
- }
117
- try {
118
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
119
- const parsed = yaml.load(fileContent);
120
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
121
- this.error('Credentials file has invalid format.');
122
- }
123
- return parsed;
124
- }
125
- catch (error) {
126
- this.error(`Failed to parse credentials file: ${error}`);
127
- }
128
- }
129
100
  }
@@ -13,5 +13,4 @@ export default class TenantGet extends BaseCommand {
13
13
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
14
  };
15
15
  run(): Promise<void>;
16
- private loadCredentials;
17
16
  }
@@ -1,6 +1,4 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
- import * as fs from 'node:fs';
4
2
  import BaseCommand from '../../../base-command.js';
5
3
  export default class TenantGet extends BaseCommand {
6
4
  static args = {
@@ -38,19 +36,7 @@ Tenant: My Tenant (my-tenant)
38
36
  };
39
37
  async run() {
40
38
  const { args, flags } = await this.parse(TenantGet);
41
- const profileName = flags.profile || this.getDefaultProfile();
42
- const credentials = this.loadCredentials();
43
- if (!(profileName in credentials.profiles)) {
44
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
45
- `Create a profile using 'xano profile create'`);
46
- }
47
- const profile = credentials.profiles[profileName];
48
- if (!profile.instance_origin) {
49
- this.error(`Profile '${profileName}' is missing instance_origin`);
50
- }
51
- if (!profile.access_token) {
52
- this.error(`Profile '${profileName}' is missing access_token`);
53
- }
39
+ const { profile } = this.resolveProfile(flags);
54
40
  const workspaceId = flags.workspace || profile.workspace;
55
41
  if (!workspaceId) {
56
42
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -115,21 +101,4 @@ Tenant: My Tenant (my-tenant)
115
101
  }
116
102
  }
117
103
  }
118
- loadCredentials() {
119
- const credentialsPath = this.getCredentialsPath();
120
- if (!fs.existsSync(credentialsPath)) {
121
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
122
- }
123
- try {
124
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
125
- const parsed = yaml.load(fileContent);
126
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
127
- this.error('Credentials file has invalid format.');
128
- }
129
- return parsed;
130
- }
131
- catch (error) {
132
- this.error(`Failed to parse credentials file: ${error}`);
133
- }
134
- }
135
104
  }
@@ -16,5 +16,4 @@ export default class TenantImpersonate extends BaseCommand {
16
16
  run(): Promise<void>;
17
17
  private getImpersonateResponse;
18
18
  private getFrontendUrl;
19
- private loadCredentials;
20
19
  }
@@ -1,6 +1,4 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
- import * as fs from 'node:fs';
4
2
  import open from 'open';
5
3
  import BaseCommand from '../../../base-command.js';
6
4
  export default class TenantImpersonate extends BaseCommand {
@@ -41,19 +39,7 @@ Impersonation successful!
41
39
  };
42
40
  async run() {
43
41
  const { args, flags } = await this.parse(TenantImpersonate);
44
- const profileName = flags.profile || this.getDefaultProfile();
45
- const credentials = this.loadCredentials();
46
- if (!(profileName in credentials.profiles)) {
47
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
48
- `Create a profile using 'xano auth'`);
49
- }
50
- const profile = credentials.profiles[profileName];
51
- if (!profile.instance_origin) {
52
- this.error(`Profile '${profileName}' is missing instance_origin`);
53
- }
54
- if (!profile.access_token) {
55
- this.error(`Profile '${profileName}' is missing access_token`);
56
- }
42
+ const { profile } = this.resolveProfile(flags);
57
43
  const workspaceId = flags.workspace || profile.workspace;
58
44
  if (!workspaceId) {
59
45
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -123,21 +109,4 @@ Impersonation successful!
123
109
  }
124
110
  return instanceOrigin;
125
111
  }
126
- loadCredentials() {
127
- const credentialsPath = this.getCredentialsPath();
128
- if (!fs.existsSync(credentialsPath)) {
129
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano auth'`);
130
- }
131
- try {
132
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
133
- const parsed = yaml.load(fileContent);
134
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
135
- this.error('Credentials file has invalid format.');
136
- }
137
- return parsed;
138
- }
139
- catch (error) {
140
- this.error(`Failed to parse credentials file: ${error}`);
141
- }
142
- }
143
112
  }
@@ -15,5 +15,4 @@ export default class TenantLicenseGet extends BaseCommand {
15
15
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
16
  };
17
17
  run(): Promise<void>;
18
- private loadCredentials;
19
18
  }
@@ -1,5 +1,4 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
2
  import * as fs from 'node:fs';
4
3
  import * as path from 'node:path';
5
4
  import BaseCommand from '../../../../base-command.js';
@@ -48,19 +47,7 @@ License saved to my-license.yaml
48
47
  };
49
48
  async run() {
50
49
  const { args, flags } = await this.parse(TenantLicenseGet);
51
- const profileName = flags.profile || this.getDefaultProfile();
52
- const credentials = this.loadCredentials();
53
- if (!(profileName in credentials.profiles)) {
54
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
55
- `Create a profile using 'xano profile create'`);
56
- }
57
- const profile = credentials.profiles[profileName];
58
- if (!profile.instance_origin) {
59
- this.error(`Profile '${profileName}' is missing instance_origin`);
60
- }
61
- if (!profile.access_token) {
62
- this.error(`Profile '${profileName}' is missing access_token`);
63
- }
50
+ const { profile } = this.resolveProfile(flags);
64
51
  const workspaceId = flags.workspace || profile.workspace;
65
52
  if (!workspaceId) {
66
53
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -105,21 +92,4 @@ License saved to my-license.yaml
105
92
  }
106
93
  }
107
94
  }
108
- loadCredentials() {
109
- const credentialsPath = this.getCredentialsPath();
110
- if (!fs.existsSync(credentialsPath)) {
111
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
112
- }
113
- try {
114
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
115
- const parsed = yaml.load(fileContent);
116
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
117
- this.error('Credentials file has invalid format.');
118
- }
119
- return parsed;
120
- }
121
- catch (error) {
122
- this.error(`Failed to parse credentials file: ${error}`);
123
- }
124
- }
125
95
  }
@@ -16,5 +16,4 @@ export default class TenantLicenseSet extends BaseCommand {
16
16
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
17
  };
18
18
  run(): Promise<void>;
19
- private loadCredentials;
20
19
  }
@@ -1,5 +1,4 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
2
  import * as fs from 'node:fs';
4
3
  import * as path from 'node:path';
5
4
  import BaseCommand from '../../../../base-command.js';
@@ -66,19 +65,7 @@ Reads from license_my-tenant.yaml
66
65
  }
67
66
  licenseValue = fs.readFileSync(sourceFilePath, 'utf8');
68
67
  }
69
- const profileName = flags.profile || this.getDefaultProfile();
70
- const credentials = this.loadCredentials();
71
- if (!(profileName in credentials.profiles)) {
72
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
73
- `Create a profile using 'xano profile create'`);
74
- }
75
- const profile = credentials.profiles[profileName];
76
- if (!profile.instance_origin) {
77
- this.error(`Profile '${profileName}' is missing instance_origin`);
78
- }
79
- if (!profile.access_token) {
80
- this.error(`Profile '${profileName}' is missing access_token`);
81
- }
68
+ const { profile } = this.resolveProfile(flags);
82
69
  const workspaceId = flags.workspace || profile.workspace;
83
70
  if (!workspaceId) {
84
71
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -119,21 +106,4 @@ Reads from license_my-tenant.yaml
119
106
  }
120
107
  }
121
108
  }
122
- loadCredentials() {
123
- const credentialsPath = this.getCredentialsPath();
124
- if (!fs.existsSync(credentialsPath)) {
125
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
126
- }
127
- try {
128
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
129
- const parsed = yaml.load(fileContent);
130
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
131
- this.error('Credentials file has invalid format.');
132
- }
133
- return parsed;
134
- }
135
- catch (error) {
136
- this.error(`Failed to parse credentials file: ${error}`);
137
- }
138
- }
139
109
  }
@@ -10,5 +10,4 @@ export default class TenantList extends BaseCommand {
10
10
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
11
  };
12
12
  run(): Promise<void>;
13
- private loadCredentials;
14
13
  }
@@ -1,6 +1,4 @@
1
1
  import { Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
- import * as fs from 'node:fs';
4
2
  import BaseCommand from '../../../base-command.js';
5
3
  export default class TenantList extends BaseCommand {
6
4
  static description = 'List all tenants in a workspace';
@@ -34,19 +32,7 @@ Tenants in workspace 5:
34
32
  };
35
33
  async run() {
36
34
  const { flags } = await this.parse(TenantList);
37
- const profileName = flags.profile || this.getDefaultProfile();
38
- const credentials = this.loadCredentials();
39
- if (!(profileName in credentials.profiles)) {
40
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
41
- `Create a profile using 'xano profile create'`);
42
- }
43
- const profile = credentials.profiles[profileName];
44
- if (!profile.instance_origin) {
45
- this.error(`Profile '${profileName}' is missing instance_origin`);
46
- }
47
- if (!profile.access_token) {
48
- this.error(`Profile '${profileName}' is missing access_token`);
49
- }
35
+ const { profile } = this.resolveProfile(flags);
50
36
  const workspaceId = flags.workspace || profile.workspace;
51
37
  if (!workspaceId) {
52
38
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -113,21 +99,4 @@ Tenants in workspace 5:
113
99
  }
114
100
  }
115
101
  }
116
- loadCredentials() {
117
- const credentialsPath = this.getCredentialsPath();
118
- if (!fs.existsSync(credentialsPath)) {
119
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
120
- }
121
- try {
122
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
123
- const parsed = yaml.load(fileContent);
124
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
125
- this.error('Credentials file has invalid format.');
126
- }
127
- return parsed;
128
- }
129
- catch (error) {
130
- this.error(`Failed to parse credentials file: ${error}`);
131
- }
132
- }
133
102
  }
@@ -14,7 +14,6 @@ export default class Pull extends BaseCommand {
14
14
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
15
  };
16
16
  run(): Promise<void>;
17
- private loadCredentials;
18
17
  /**
19
18
  * Sanitize a document name for use as a filename.
20
19
  * Strips quotes, replaces spaces with underscores, and removes
@@ -1,5 +1,4 @@
1
1
  import { Flags } from '@oclif/core';
2
- import * as yaml from 'js-yaml';
3
2
  import * as fs from 'node:fs';
4
3
  import * as path from 'node:path';
5
4
  import snakeCase from 'lodash.snakecase';
@@ -58,23 +57,7 @@ Pulled 58 documents from tenant my-tenant
58
57
  };
59
58
  async run() {
60
59
  const { flags } = await this.parse(Pull);
61
- // Get profile name (default or from flag/env)
62
- const profileName = flags.profile || this.getDefaultProfile();
63
- // Load credentials
64
- const credentials = this.loadCredentials();
65
- // Get the profile configuration
66
- if (!(profileName in credentials.profiles)) {
67
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
68
- `Create a profile using 'xano profile:create'`);
69
- }
70
- const profile = credentials.profiles[profileName];
71
- // Validate required fields
72
- if (!profile.instance_origin) {
73
- this.error(`Profile '${profileName}' is missing instance_origin`);
74
- }
75
- if (!profile.access_token) {
76
- this.error(`Profile '${profileName}' is missing access_token`);
77
- }
60
+ const { profileName, profile } = this.resolveProfile(flags);
78
61
  // Determine workspace_id from flag or profile
79
62
  let workspaceId;
80
63
  if (flags.workspace) {
@@ -254,25 +237,6 @@ Pulled 58 documents from tenant my-tenant
254
237
  }
255
238
  this.log(`Pulled ${writtenCount} documents from tenant ${tenantName} to ${flags.directory}`);
256
239
  }
257
- loadCredentials() {
258
- const credentialsPath = this.getCredentialsPath();
259
- // Check if credentials file exists
260
- if (!fs.existsSync(credentialsPath)) {
261
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile:create'`);
262
- }
263
- // Read credentials file
264
- try {
265
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
266
- const parsed = yaml.load(fileContent);
267
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
268
- this.error('Credentials file has invalid format.');
269
- }
270
- return parsed;
271
- }
272
- catch (error) {
273
- this.error(`Failed to parse credentials file: ${error}`);
274
- }
275
- }
276
240
  /**
277
241
  * Sanitize a document name for use as a filename.
278
242
  * Strips quotes, replaces spaces with underscores, and removes
@@ -41,18 +41,7 @@ Unit tests for tenant my-tenant:
41
41
  };
42
42
  async run() {
43
43
  const { flags } = await this.parse(TenantUnitTestList);
44
- const profileName = flags.profile || this.getDefaultProfile();
45
- const credentials = this.loadCredentialsFile();
46
- if (!credentials || !(profileName in credentials.profiles)) {
47
- this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
48
- }
49
- const profile = credentials.profiles[profileName];
50
- if (!profile.instance_origin) {
51
- this.error(`Profile '${profileName}' is missing instance_origin`);
52
- }
53
- if (!profile.access_token) {
54
- this.error(`Profile '${profileName}' is missing access_token`);
55
- }
44
+ const { profile } = this.resolveProfile(flags);
56
45
  const workspaceId = flags.workspace || profile.workspace;
57
46
  if (!workspaceId) {
58
47
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -37,18 +37,7 @@ Result: PASS
37
37
  };
38
38
  async run() {
39
39
  const { args, flags } = await this.parse(TenantUnitTestRun);
40
- const profileName = flags.profile || this.getDefaultProfile();
41
- const credentials = this.loadCredentialsFile();
42
- if (!credentials || !(profileName in credentials.profiles)) {
43
- this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
44
- }
45
- const profile = credentials.profiles[profileName];
46
- if (!profile.instance_origin) {
47
- this.error(`Profile '${profileName}' is missing instance_origin`);
48
- }
49
- if (!profile.access_token) {
50
- this.error(`Profile '${profileName}' is missing access_token`);
51
- }
40
+ const { profile } = this.resolveProfile(flags);
52
41
  const workspaceId = flags.workspace || profile.workspace;
53
42
  if (!workspaceId) {
54
43
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');