@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
@@ -46,18 +46,7 @@ Results: 4 passed, 1 failed
46
46
  };
47
47
  async run() {
48
48
  const { flags } = await this.parse(TenantUnitTestRunAll);
49
- const profileName = flags.profile || this.getDefaultProfile();
50
- const credentials = this.loadCredentialsFile();
51
- if (!credentials || !(profileName in credentials.profiles)) {
52
- this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
53
- }
54
- const profile = credentials.profiles[profileName];
55
- if (!profile.instance_origin) {
56
- this.error(`Profile '${profileName}' is missing instance_origin`);
57
- }
58
- if (!profile.access_token) {
59
- this.error(`Profile '${profileName}' is missing access_token`);
60
- }
49
+ const { profile } = this.resolveProfile(flags);
61
50
  const workspaceId = flags.workspace || profile.workspace;
62
51
  if (!workspaceId) {
63
52
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -36,18 +36,7 @@ Workflow tests for tenant my-tenant:
36
36
  };
37
37
  async run() {
38
38
  const { flags } = await this.parse(TenantWorkflowTestList);
39
- const profileName = flags.profile || this.getDefaultProfile();
40
- const credentials = this.loadCredentialsFile();
41
- if (!credentials || !(profileName in credentials.profiles)) {
42
- this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
43
- }
44
- const profile = credentials.profiles[profileName];
45
- if (!profile.instance_origin) {
46
- this.error(`Profile '${profileName}' is missing instance_origin`);
47
- }
48
- if (!profile.access_token) {
49
- this.error(`Profile '${profileName}' is missing access_token`);
50
- }
39
+ const { profile } = this.resolveProfile(flags);
51
40
  const workspaceId = flags.workspace || profile.workspace;
52
41
  if (!workspaceId) {
53
42
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -37,18 +37,7 @@ Result: PASS (0.25s)
37
37
  };
38
38
  async run() {
39
39
  const { args, flags } = await this.parse(TenantWorkflowTestRun);
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.');
@@ -41,18 +41,7 @@ Results: 2 passed, 1 failed
41
41
  };
42
42
  async run() {
43
43
  const { flags } = await this.parse(TenantWorkflowTestRunAll);
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.');
@@ -12,5 +12,4 @@ export default class UnitTestList extends BaseCommand {
12
12
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
13
  };
14
14
  run(): Promise<void>;
15
- private loadCredentials;
16
15
  }
@@ -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 UnitTestList extends BaseCommand {
6
4
  static description = 'List all unit tests in a workspace';
@@ -40,19 +38,7 @@ Unit tests in workspace 5:
40
38
  };
41
39
  async run() {
42
40
  const { flags } = await this.parse(UnitTestList);
43
- const profileName = flags.profile || this.getDefaultProfile();
44
- const credentials = this.loadCredentials();
45
- if (!(profileName in credentials.profiles)) {
46
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
47
- `Create 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
- }
41
+ const { profile } = this.resolveProfile(flags);
56
42
  const workspaceId = flags.workspace || profile.workspace;
57
43
  if (!workspaceId) {
58
44
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -113,22 +99,4 @@ Unit tests 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` +
120
- `Create a profile using 'xano profile create'`);
121
- }
122
- try {
123
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
124
- const parsed = yaml.load(fileContent);
125
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
126
- this.error('Credentials file has invalid format.');
127
- }
128
- return parsed;
129
- }
130
- catch (error) {
131
- this.error(`Failed to parse credentials file: ${error}`);
132
- }
133
- }
134
102
  }
@@ -13,5 +13,4 @@ export default class UnitTestRun 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 UnitTestRun extends BaseCommand {
6
4
  static args = {
@@ -34,19 +32,7 @@ Result: PASS
34
32
  };
35
33
  async run() {
36
34
  const { args, flags } = await this.parse(UnitTestRun);
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.');
@@ -97,22 +83,4 @@ Result: PASS
97
83
  }
98
84
  }
99
85
  }
100
- loadCredentials() {
101
- const credentialsPath = this.getCredentialsPath();
102
- if (!fs.existsSync(credentialsPath)) {
103
- this.error(`Credentials file not found at ${credentialsPath}\n` +
104
- `Create a profile using 'xano profile create'`);
105
- }
106
- try {
107
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
108
- const parsed = yaml.load(fileContent);
109
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
110
- this.error('Credentials file has invalid format.');
111
- }
112
- return parsed;
113
- }
114
- catch (error) {
115
- this.error(`Failed to parse credentials file: ${error}`);
116
- }
117
- }
118
86
  }
@@ -12,5 +12,4 @@ export default class UnitTestRunAll extends BaseCommand {
12
12
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
13
  };
14
14
  run(): Promise<void>;
15
- private loadCredentials;
16
15
  }
@@ -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 UnitTestRunAll extends BaseCommand {
6
4
  static description = 'Run all unit tests in a workspace';
@@ -44,19 +42,7 @@ Results: 2 passed, 1 failed
44
42
  };
45
43
  async run() {
46
44
  const { flags } = await this.parse(UnitTestRunAll);
47
- const profileName = flags.profile || this.getDefaultProfile();
48
- const credentials = this.loadCredentials();
49
- if (!(profileName in credentials.profiles)) {
50
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
51
- `Create a profile using 'xano profile create'`);
52
- }
53
- const profile = credentials.profiles[profileName];
54
- if (!profile.instance_origin) {
55
- this.error(`Profile '${profileName}' is missing instance_origin`);
56
- }
57
- if (!profile.access_token) {
58
- this.error(`Profile '${profileName}' is missing access_token`);
59
- }
45
+ const { profile } = this.resolveProfile(flags);
60
46
  const workspaceId = flags.workspace || profile.workspace;
61
47
  if (!workspaceId) {
62
48
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -192,21 +178,4 @@ Results: 2 passed, 1 failed
192
178
  }
193
179
  }
194
180
  }
195
- loadCredentials() {
196
- const credentialsPath = this.getCredentialsPath();
197
- if (!fs.existsSync(credentialsPath)) {
198
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
199
- }
200
- try {
201
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
202
- const parsed = yaml.load(fileContent);
203
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
204
- this.error('Credentials file has invalid format.');
205
- }
206
- return parsed;
207
- }
208
- catch (error) {
209
- this.error(`Failed to parse credentials file: ${error}`);
210
- }
211
- }
212
181
  }
@@ -18,5 +18,4 @@ export default class WorkflowTestDelete extends BaseCommand {
18
18
  };
19
19
  run(): Promise<void>;
20
20
  private confirm;
21
- private loadCredentials;
22
21
  }
@@ -1,7 +1,5 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import * as readline from 'node:readline';
3
- import * as yaml from 'js-yaml';
4
- import * as fs from 'node:fs';
5
3
  import BaseCommand from '../../../base-command.js';
6
4
  export default class WorkflowTestDelete extends BaseCommand {
7
5
  static args = {
@@ -41,19 +39,7 @@ Deleted workflow test 1
41
39
  };
42
40
  async run() {
43
41
  const { args, flags } = await this.parse(WorkflowTestDelete);
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 profile create'`);
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.');
@@ -106,22 +92,4 @@ Deleted workflow test 1
106
92
  });
107
93
  });
108
94
  }
109
- loadCredentials() {
110
- const credentialsPath = this.getCredentialsPath();
111
- if (!fs.existsSync(credentialsPath)) {
112
- this.error(`Credentials file not found at ${credentialsPath}\n` +
113
- `Create a profile using 'xano profile create'`);
114
- }
115
- try {
116
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
117
- const parsed = yaml.load(fileContent);
118
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
119
- this.error('Credentials file has invalid format.');
120
- }
121
- return parsed;
122
- }
123
- catch (error) {
124
- this.error(`Failed to parse credentials file: ${error}`);
125
- }
126
- }
127
95
  }
@@ -17,5 +17,4 @@ export default class WorkflowTestGet extends BaseCommand {
17
17
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
18
  };
19
19
  run(): Promise<void>;
20
- private loadCredentials;
21
20
  }
@@ -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 WorkflowTestGet extends BaseCommand {
6
4
  static args = {
@@ -41,19 +39,7 @@ Workflow Test: my-test (ID: 1)
41
39
  };
42
40
  async run() {
43
41
  const { args, flags } = await this.parse(WorkflowTestGet);
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 profile create'`);
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.');
@@ -118,22 +104,4 @@ Workflow Test: my-test (ID: 1)
118
104
  }
119
105
  }
120
106
  }
121
- loadCredentials() {
122
- const credentialsPath = this.getCredentialsPath();
123
- if (!fs.existsSync(credentialsPath)) {
124
- this.error(`Credentials file not found at ${credentialsPath}\n` +
125
- `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
107
  }
@@ -11,5 +11,4 @@ export default class WorkflowTestList extends BaseCommand {
11
11
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
12
  };
13
13
  run(): Promise<void>;
14
- private loadCredentials;
15
14
  }
@@ -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 WorkflowTestList extends BaseCommand {
6
4
  static description = 'List all workflow tests in a workspace';
@@ -35,19 +33,7 @@ Workflow tests in workspace 5:
35
33
  };
36
34
  async run() {
37
35
  const { flags } = await this.parse(WorkflowTestList);
38
- const profileName = flags.profile || this.getDefaultProfile();
39
- const credentials = this.loadCredentials();
40
- if (!(profileName in credentials.profiles)) {
41
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
42
- `Create a profile using 'xano profile create'`);
43
- }
44
- const profile = credentials.profiles[profileName];
45
- if (!profile.instance_origin) {
46
- this.error(`Profile '${profileName}' is missing instance_origin`);
47
- }
48
- if (!profile.access_token) {
49
- this.error(`Profile '${profileName}' is missing access_token`);
50
- }
36
+ const { profile } = this.resolveProfile(flags);
51
37
  const workspaceId = flags.workspace || profile.workspace;
52
38
  if (!workspaceId) {
53
39
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -105,22 +91,4 @@ Workflow tests in workspace 5:
105
91
  }
106
92
  }
107
93
  }
108
- loadCredentials() {
109
- const credentialsPath = this.getCredentialsPath();
110
- if (!fs.existsSync(credentialsPath)) {
111
- this.error(`Credentials file not found at ${credentialsPath}\n` +
112
- `Create a profile using 'xano profile create'`);
113
- }
114
- try {
115
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
116
- const parsed = yaml.load(fileContent);
117
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
118
- this.error('Credentials file has invalid format.');
119
- }
120
- return parsed;
121
- }
122
- catch (error) {
123
- this.error(`Failed to parse credentials file: ${error}`);
124
- }
125
- }
126
94
  }
@@ -16,5 +16,4 @@ export default class WorkflowTestRun extends BaseCommand {
16
16
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
17
  };
18
18
  run(): Promise<void>;
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 BaseCommand from '../../../base-command.js';
5
3
  export default class WorkflowTestRun extends BaseCommand {
6
4
  static args = {
@@ -34,19 +32,7 @@ Result: PASS (1.234s)
34
32
  };
35
33
  async run() {
36
34
  const { args, flags } = await this.parse(WorkflowTestRun);
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.');
@@ -95,22 +81,4 @@ Result: PASS (1.234s)
95
81
  }
96
82
  }
97
83
  }
98
- loadCredentials() {
99
- const credentialsPath = this.getCredentialsPath();
100
- if (!fs.existsSync(credentialsPath)) {
101
- this.error(`Credentials file not found at ${credentialsPath}\n` +
102
- `Create a profile using 'xano profile create'`);
103
- }
104
- try {
105
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
106
- const parsed = yaml.load(fileContent);
107
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
108
- this.error('Credentials file has invalid format.');
109
- }
110
- return parsed;
111
- }
112
- catch (error) {
113
- this.error(`Failed to parse credentials file: ${error}`);
114
- }
115
- }
116
84
  }
@@ -11,5 +11,4 @@ export default class WorkflowTestRunAll extends BaseCommand {
11
11
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
12
  };
13
13
  run(): Promise<void>;
14
- private loadCredentials;
15
14
  }
@@ -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 WorkflowTestRunAll extends BaseCommand {
6
4
  static description = 'Run all workflow tests in a workspace';
@@ -39,19 +37,7 @@ Results: 2 passed, 1 failed (2.691s total)
39
37
  };
40
38
  async run() {
41
39
  const { flags } = await this.parse(WorkflowTestRunAll);
42
- const profileName = flags.profile || this.getDefaultProfile();
43
- const credentials = this.loadCredentials();
44
- if (!(profileName in credentials.profiles)) {
45
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
46
- `Create a profile using 'xano profile create'`);
47
- }
48
- const profile = credentials.profiles[profileName];
49
- if (!profile.instance_origin) {
50
- this.error(`Profile '${profileName}' is missing instance_origin`);
51
- }
52
- if (!profile.access_token) {
53
- this.error(`Profile '${profileName}' is missing access_token`);
54
- }
40
+ const { profile } = this.resolveProfile(flags);
55
41
  const workspaceId = flags.workspace || profile.workspace;
56
42
  if (!workspaceId) {
57
43
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -180,21 +166,4 @@ Results: 2 passed, 1 failed (2.691s total)
180
166
  }
181
167
  }
182
168
  }
183
- loadCredentials() {
184
- const credentialsPath = this.getCredentialsPath();
185
- if (!fs.existsSync(credentialsPath)) {
186
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile create'`);
187
- }
188
- try {
189
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
190
- const parsed = yaml.load(fileContent);
191
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
192
- this.error('Credentials file has invalid format.');
193
- }
194
- return parsed;
195
- }
196
- catch (error) {
197
- this.error(`Failed to parse credentials file: ${error}`);
198
- }
199
- }
200
169
  }
@@ -13,5 +13,4 @@ export default class WorkspaceCreate 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 WorkspaceCreate extends BaseCommand {
6
4
  static args = {
@@ -43,23 +41,7 @@ Created workspace: my-app (ID: 456)
43
41
  };
44
42
  async run() {
45
43
  const { args, flags } = await this.parse(WorkspaceCreate);
46
- // Get profile name (default or from flag/env)
47
- const profileName = flags.profile || this.getDefaultProfile();
48
- // Load credentials
49
- const credentials = this.loadCredentials();
50
- // Get the profile configuration
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
- // Validate required fields
57
- if (!profile.instance_origin) {
58
- this.error(`Profile '${profileName}' is missing instance_origin`);
59
- }
60
- if (!profile.access_token) {
61
- this.error(`Profile '${profileName}' is missing access_token`);
62
- }
44
+ const { profile } = this.resolveProfile(flags);
63
45
  // Construct the API URL
64
46
  const apiUrl = `${profile.instance_origin}/api:meta/workspace`;
65
47
  // Build request body
@@ -106,24 +88,4 @@ Created workspace: my-app (ID: 456)
106
88
  }
107
89
  }
108
90
  }
109
- loadCredentials() {
110
- const credentialsPath = this.getCredentialsPath();
111
- // Check if credentials file exists
112
- if (!fs.existsSync(credentialsPath)) {
113
- this.error(`Credentials file not found at ${credentialsPath}\n` +
114
- `Create a profile using 'xano profile create'`);
115
- }
116
- // Read credentials file
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
91
  }
@@ -12,5 +12,4 @@ export default class WorkspaceDelete extends BaseCommand {
12
12
  };
13
13
  run(): Promise<void>;
14
14
  private confirm;
15
- private loadCredentials;
16
15
  }