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

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 (154) 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/oclif.manifest.json +2399 -2312
  154. 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 ReleaseCreate extends BaseCommand {
6
4
  static args = {
@@ -52,19 +50,7 @@ Created release: v1.0 - ID: 10
52
50
  };
53
51
  async run() {
54
52
  const { args, flags } = await this.parse(ReleaseCreate);
55
- const profileName = flags.profile || this.getDefaultProfile();
56
- const credentials = this.loadCredentials();
57
- if (!(profileName in credentials.profiles)) {
58
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
59
- `Create a profile using 'xano profile create'`);
60
- }
61
- const profile = credentials.profiles[profileName];
62
- if (!profile.instance_origin) {
63
- this.error(`Profile '${profileName}' is missing instance_origin`);
64
- }
65
- if (!profile.access_token) {
66
- this.error(`Profile '${profileName}' is missing access_token`);
67
- }
53
+ const { profile } = this.resolveProfile(flags);
68
54
  const workspaceId = flags.workspace || profile.workspace;
69
55
  if (!workspaceId) {
70
56
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -115,22 +101,4 @@ Created release: v1.0 - ID: 10
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` +
122
- `Create a profile using 'xano profile create'`);
123
- }
124
- try {
125
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
126
- const parsed = yaml.load(fileContent);
127
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
128
- this.error('Credentials file has invalid format.');
129
- }
130
- return parsed;
131
- }
132
- catch (error) {
133
- this.error(`Failed to parse credentials file: ${error}`);
134
- }
135
- }
136
104
  }
@@ -15,6 +15,5 @@ export default class ReleaseDelete extends BaseCommand {
15
15
  };
16
16
  run(): Promise<void>;
17
17
  private confirm;
18
- private loadCredentials;
19
18
  private resolveReleaseName;
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 ReleaseDelete extends BaseCommand {
6
4
  static args = {
@@ -43,19 +41,7 @@ Deleted release 'v1.0'
43
41
  };
44
42
  async run() {
45
43
  const { args, flags } = await this.parse(ReleaseDelete);
46
- const profileName = flags.profile || this.getDefaultProfile();
47
- const credentials = this.loadCredentials();
48
- if (!(profileName in credentials.profiles)) {
49
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
50
- `Create a profile using 'xano profile create'`);
51
- }
52
- const profile = credentials.profiles[profileName];
53
- if (!profile.instance_origin) {
54
- this.error(`Profile '${profileName}' is missing instance_origin`);
55
- }
56
- if (!profile.access_token) {
57
- this.error(`Profile '${profileName}' is missing access_token`);
58
- }
44
+ const { profile } = this.resolveProfile(flags);
59
45
  const workspaceId = flags.workspace || profile.workspace;
60
46
  if (!workspaceId) {
61
47
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -111,24 +97,6 @@ Deleted release 'v1.0'
111
97
  });
112
98
  });
113
99
  }
114
- loadCredentials() {
115
- const credentialsPath = this.getCredentialsPath();
116
- if (!fs.existsSync(credentialsPath)) {
117
- this.error(`Credentials file not found at ${credentialsPath}\n` +
118
- `Create a profile using 'xano profile create'`);
119
- }
120
- try {
121
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
122
- const parsed = yaml.load(fileContent);
123
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
124
- this.error('Credentials file has invalid format.');
125
- }
126
- return parsed;
127
- }
128
- catch (error) {
129
- this.error(`Failed to parse credentials file: ${error}`);
130
- }
131
- }
132
100
  async resolveReleaseName(profile, workspaceId, releaseName, verbose) {
133
101
  const listUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/release`;
134
102
  const response = await this.verboseFetch(listUrl, {
@@ -52,18 +52,7 @@ Deployed release "v1.0" to workspace 40 (branch: v1.0)
52
52
  };
53
53
  async run() {
54
54
  const { args, flags } = await this.parse(ReleaseDeploy);
55
- const profileName = flags.profile || this.getDefaultProfile();
56
- const credentials = this.loadCredentialsFile();
57
- if (!credentials || !(profileName in credentials.profiles)) {
58
- this.error(`Profile '${profileName}' not found.\n` + `Create a profile using 'xano profile create'`);
59
- }
60
- const profile = credentials.profiles[profileName];
61
- if (!profile.instance_origin) {
62
- this.error(`Profile '${profileName}' is missing instance_origin`);
63
- }
64
- if (!profile.access_token) {
65
- this.error(`Profile '${profileName}' is missing access_token`);
66
- }
55
+ const { profile } = this.resolveProfile(flags);
67
56
  const workspaceId = flags.workspace || profile.workspace;
68
57
  if (!workspaceId) {
69
58
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -15,6 +15,5 @@ export default class ReleaseEdit extends BaseCommand {
15
15
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
16
  };
17
17
  run(): Promise<void>;
18
- private loadCredentials;
19
18
  private resolveReleaseName;
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 ReleaseEdit extends BaseCommand {
6
4
  static args = {
@@ -43,19 +41,7 @@ Updated release: v1.0-final - ID: 10
43
41
  };
44
42
  async run() {
45
43
  const { args, flags } = await this.parse(ReleaseEdit);
46
- const profileName = flags.profile || this.getDefaultProfile();
47
- const credentials = this.loadCredentials();
48
- if (!(profileName in credentials.profiles)) {
49
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
50
- `Create a profile using 'xano profile create'`);
51
- }
52
- const profile = credentials.profiles[profileName];
53
- if (!profile.instance_origin) {
54
- this.error(`Profile '${profileName}' is missing instance_origin`);
55
- }
56
- if (!profile.access_token) {
57
- this.error(`Profile '${profileName}' is missing access_token`);
58
- }
44
+ const { profile } = this.resolveProfile(flags);
59
45
  const workspaceId = flags.workspace || profile.workspace;
60
46
  if (!workspaceId) {
61
47
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -113,24 +99,6 @@ Updated release: v1.0-final - ID: 10
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
  async resolveReleaseName(profile, workspaceId, releaseName, verbose) {
135
103
  const listUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/release`;
136
104
  const response = await this.verboseFetch(listUrl, {
@@ -14,6 +14,5 @@ export default class ReleaseExport extends BaseCommand {
14
14
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
15
  };
16
16
  run(): Promise<void>;
17
- private loadCredentials;
18
17
  private resolveReleaseName;
19
18
  }
@@ -1,7 +1,6 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import * as fs from 'node:fs';
3
3
  import * as path from 'node:path';
4
- import * as yaml from 'js-yaml';
5
4
  import BaseCommand, { buildUserAgent } from '../../../base-command.js';
6
5
  export default class ReleaseExport extends BaseCommand {
7
6
  static args = {
@@ -39,19 +38,7 @@ Downloaded release 'v1.0' to ./release-v1.0.tar.gz
39
38
  };
40
39
  async run() {
41
40
  const { args, flags } = await this.parse(ReleaseExport);
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
- }
41
+ const { profile } = this.resolveProfile(flags);
55
42
  const workspaceId = flags.workspace || profile.workspace;
56
43
  if (!workspaceId) {
57
44
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -123,23 +110,6 @@ Downloaded release 'v1.0' to ./release-v1.0.tar.gz
123
110
  }
124
111
  }
125
112
  }
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 profile create'`);
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
113
  async resolveReleaseName(profile, workspaceId, releaseName, verbose) {
144
114
  const listUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/release`;
145
115
  const response = await this.verboseFetch(listUrl, {
@@ -13,6 +13,5 @@ export default class ReleaseGet extends BaseCommand {
13
13
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
14
  };
15
15
  run(): Promise<void>;
16
- private loadCredentials;
17
16
  private resolveReleaseName;
18
17
  }
@@ -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 ReleaseGet extends BaseCommand {
6
4
  static args = {
@@ -36,19 +34,7 @@ Release: v1.0 - ID: 10
36
34
  };
37
35
  async run() {
38
36
  const { args, flags } = await this.parse(ReleaseGet);
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.');
@@ -99,24 +85,6 @@ Release: v1.0 - ID: 10
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` +
106
- `Create a profile using 'xano profile create'`);
107
- }
108
- try {
109
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
110
- const parsed = yaml.load(fileContent);
111
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
112
- this.error('Credentials file has invalid format.');
113
- }
114
- return parsed;
115
- }
116
- catch (error) {
117
- this.error(`Failed to parse credentials file: ${error}`);
118
- }
119
- }
120
88
  async resolveReleaseName(profile, workspaceId, releaseName, verbose) {
121
89
  const listUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/release`;
122
90
  const response = await this.verboseFetch(listUrl, {
@@ -12,5 +12,4 @@ export default class ReleaseImport extends BaseCommand {
12
12
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
13
  };
14
14
  run(): Promise<void>;
15
- private loadCredentials;
16
15
  }
@@ -1,7 +1,6 @@
1
1
  import { Flags } from '@oclif/core';
2
2
  import * as fs from 'node:fs';
3
3
  import * as path from 'node:path';
4
- import * as yaml from 'js-yaml';
5
4
  import BaseCommand from '../../../base-command.js';
6
5
  export default class ReleaseImport extends BaseCommand {
7
6
  static args = {};
@@ -34,19 +33,7 @@ Imported release as #15
34
33
  };
35
34
  async run() {
36
35
  const { flags } = await this.parse(ReleaseImport);
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
- }
36
+ const { profile } = this.resolveProfile(flags);
50
37
  const workspaceId = flags.workspace || profile.workspace;
51
38
  if (!workspaceId) {
52
39
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -91,22 +78,4 @@ Imported release as #15
91
78
  }
92
79
  }
93
80
  }
94
- loadCredentials() {
95
- const credentialsPath = this.getCredentialsPath();
96
- if (!fs.existsSync(credentialsPath)) {
97
- this.error(`Credentials file not found at ${credentialsPath}\n` +
98
- `Create a profile using 'xano profile create'`);
99
- }
100
- try {
101
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
102
- const parsed = yaml.load(fileContent);
103
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
104
- this.error('Credentials file has invalid format.');
105
- }
106
- return parsed;
107
- }
108
- catch (error) {
109
- this.error(`Failed to parse credentials file: ${error}`);
110
- }
111
- }
112
81
  }
@@ -10,5 +10,4 @@ export default class ReleaseList 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 ReleaseList extends BaseCommand {
6
4
  static description = 'List all releases in a workspace';
@@ -29,19 +27,7 @@ Releases in workspace 5:
29
27
  };
30
28
  async run() {
31
29
  const { flags } = await this.parse(ReleaseList);
32
- const profileName = flags.profile || this.getDefaultProfile();
33
- const credentials = this.loadCredentials();
34
- if (!(profileName in credentials.profiles)) {
35
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
36
- `Create a profile using 'xano profile create'`);
37
- }
38
- const profile = credentials.profiles[profileName];
39
- if (!profile.instance_origin) {
40
- this.error(`Profile '${profileName}' is missing instance_origin`);
41
- }
42
- if (!profile.access_token) {
43
- this.error(`Profile '${profileName}' is missing access_token`);
44
- }
30
+ const { profile } = this.resolveProfile(flags);
45
31
  const workspaceId = flags.workspace || profile.workspace;
46
32
  if (!workspaceId) {
47
33
  this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
@@ -99,21 +85,4 @@ Releases in workspace 5:
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
  }
@@ -13,7 +13,6 @@ export default class ReleasePull extends BaseCommand {
13
13
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
14
  };
15
15
  run(): Promise<void>;
16
- private loadCredentials;
17
16
  private resolveReleaseName;
18
17
  /**
19
18
  * Sanitize a document name for use as a filename.
@@ -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';
@@ -52,23 +51,7 @@ Pulled 58 documents from release 'v1.0'
52
51
  };
53
52
  async run() {
54
53
  const { flags } = await this.parse(ReleasePull);
55
- // Get profile name (default or from flag/env)
56
- const profileName = flags.profile || this.getDefaultProfile();
57
- // Load credentials
58
- const credentials = this.loadCredentials();
59
- // Get the profile configuration
60
- if (!(profileName in credentials.profiles)) {
61
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
62
- `Create a profile using 'xano profile:create'`);
63
- }
64
- const profile = credentials.profiles[profileName];
65
- // Validate required fields
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
- }
54
+ const { profile } = this.resolveProfile(flags);
72
55
  // Determine workspace_id from flag or profile
73
56
  let workspaceId;
74
57
  if (flags.workspace) {
@@ -80,7 +63,7 @@ Pulled 58 documents from release 'v1.0'
80
63
  else {
81
64
  this.error(`Workspace ID is required. Either:\n` +
82
65
  ` 1. Provide it as a flag: xano release pull -r <release_name> -w <workspace_id>\n` +
83
- ` 2. Set it in your profile using: xano profile:edit ${profileName} -w <workspace_id>`);
66
+ ` 2. Set it in your profile using: xano profile:edit --workspace <workspace_id>`);
84
67
  }
85
68
  const releaseName = flags.release;
86
69
  const releaseId = await this.resolveReleaseName(profile, workspaceId, releaseName, flags.verbose);
@@ -248,25 +231,6 @@ Pulled 58 documents from release 'v1.0'
248
231
  }
249
232
  this.log(`Pulled ${writtenCount} documents from release '${releaseName}' to ${flags.directory}`);
250
233
  }
251
- loadCredentials() {
252
- const credentialsPath = this.getCredentialsPath();
253
- // Check if credentials file exists
254
- if (!fs.existsSync(credentialsPath)) {
255
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile:create'`);
256
- }
257
- // Read credentials file
258
- try {
259
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
260
- const parsed = yaml.load(fileContent);
261
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
262
- this.error('Credentials file has invalid format.');
263
- }
264
- return parsed;
265
- }
266
- catch (error) {
267
- this.error(`Failed to parse credentials file: ${error}`);
268
- }
269
- }
270
234
  async resolveReleaseName(profile, workspaceId, releaseName, verbose) {
271
235
  const listUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/release`;
272
236
  const response = await this.verboseFetch(listUrl, {
@@ -21,5 +21,4 @@ export default class ReleasePush extends BaseCommand {
21
21
  * type subdirectory name then filename for deterministic ordering.
22
22
  */
23
23
  private collectFiles;
24
- private loadCredentials;
25
24
  }
@@ -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 BaseCommand from '../../../base-command.js';
@@ -73,23 +72,7 @@ Output release details as JSON
73
72
  };
74
73
  async run() {
75
74
  const { flags } = await this.parse(ReleasePush);
76
- // Get profile name (default or from flag/env)
77
- const profileName = flags.profile || this.getDefaultProfile();
78
- // Load credentials
79
- const credentials = this.loadCredentials();
80
- // Get the profile configuration
81
- if (!(profileName in credentials.profiles)) {
82
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
83
- `Create a profile using 'xano profile:create'`);
84
- }
85
- const profile = credentials.profiles[profileName];
86
- // Validate required fields
87
- if (!profile.instance_origin) {
88
- this.error(`Profile '${profileName}' is missing instance_origin`);
89
- }
90
- if (!profile.access_token) {
91
- this.error(`Profile '${profileName}' is missing access_token`);
92
- }
75
+ const { profileName, profile } = this.resolveProfile(flags);
93
76
  // Determine workspace_id from flag or profile
94
77
  let workspaceId;
95
78
  if (flags.workspace) {
@@ -218,23 +201,4 @@ Output release details as JSON
218
201
  }
219
202
  return files.sort();
220
203
  }
221
- loadCredentials() {
222
- const credentialsPath = this.getCredentialsPath();
223
- // Check if credentials file exists
224
- if (!fs.existsSync(credentialsPath)) {
225
- this.error(`Credentials file not found at ${credentialsPath}\n` + `Create a profile using 'xano profile:create'`);
226
- }
227
- // Read credentials file
228
- try {
229
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
230
- const parsed = yaml.load(fileContent);
231
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
232
- this.error('Credentials file has invalid format.');
233
- }
234
- return parsed;
235
- }
236
- catch (error) {
237
- this.error(`Failed to parse credentials file: ${error}`);
238
- }
239
- }
240
204
  }
@@ -16,5 +16,4 @@ export default class StaticHostBuildCreate 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';
@@ -64,23 +63,7 @@ Description: Production build
64
63
  };
65
64
  async run() {
66
65
  const { args, flags } = await this.parse(StaticHostBuildCreate);
67
- // Get profile name (default or from flag/env)
68
- const profileName = flags.profile || this.getDefaultProfile();
69
- // Load credentials
70
- const credentials = this.loadCredentials();
71
- // Get the profile configuration
72
- if (!(profileName in credentials.profiles)) {
73
- this.error(`Profile '${profileName}' not found. Available profiles: ${Object.keys(credentials.profiles).join(', ')}\n` +
74
- `Create a profile using 'xano profile:create'`);
75
- }
76
- const profile = credentials.profiles[profileName];
77
- // Validate required fields
78
- if (!profile.instance_origin) {
79
- this.error(`Profile '${profileName}' is missing instance_origin`);
80
- }
81
- if (!profile.access_token) {
82
- this.error(`Profile '${profileName}' is missing access_token`);
83
- }
66
+ const { profile, profileName } = this.resolveProfile(flags);
84
67
  // Determine workspace_id from flag or profile
85
68
  let workspaceId;
86
69
  if (flags.workspace) {
@@ -114,7 +97,6 @@ Description: Production build
114
97
  // Construct the API URL
115
98
  const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/static_host/${args.static_host}/build`;
116
99
  // Create FormData
117
- const FormData = (await import('node:buffer')).Blob;
118
100
  const formData = new globalThis.FormData();
119
101
  // Read file and create blob
120
102
  const fileBuffer = fs.readFileSync(filePath);
@@ -169,24 +151,4 @@ Description: Production build
169
151
  }
170
152
  }
171
153
  }
172
- loadCredentials() {
173
- const credentialsPath = this.getCredentialsPath();
174
- // Check if credentials file exists
175
- if (!fs.existsSync(credentialsPath)) {
176
- this.error(`Credentials file not found at ${credentialsPath}\n` +
177
- `Create a profile using 'xano profile:create'`);
178
- }
179
- // Read credentials file
180
- try {
181
- const fileContent = fs.readFileSync(credentialsPath, 'utf8');
182
- const parsed = yaml.load(fileContent);
183
- if (!parsed || typeof parsed !== 'object' || !('profiles' in parsed)) {
184
- this.error('Credentials file has invalid format.');
185
- }
186
- return parsed;
187
- }
188
- catch (error) {
189
- this.error(`Failed to parse credentials file: ${error}`);
190
- }
191
- }
192
154
  }
@@ -14,5 +14,4 @@ export default class StaticHostBuildGet extends BaseCommand {
14
14
  verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
15
  };
16
16
  run(): Promise<void>;
17
- private loadCredentials;
18
17
  }