@xano/cli 0.0.95-beta.2 → 0.0.95

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 (76) hide show
  1. package/README.md +2 -20
  2. package/dist/commands/tenant/create/index.d.ts +3 -1
  3. package/dist/commands/tenant/create/index.js +28 -6
  4. package/dist/commands/tenant/push/index.js +1 -1
  5. package/dist/help.d.ts +1 -2
  6. package/dist/help.js +1 -39
  7. package/oclif.manifest.json +2251 -5131
  8. package/package.json +1 -16
  9. package/dist/commands/ephemeral/access/index.d.ts +0 -15
  10. package/dist/commands/ephemeral/access/index.js +0 -78
  11. package/dist/commands/ephemeral/create/index.d.ts +0 -17
  12. package/dist/commands/ephemeral/create/index.js +0 -102
  13. package/dist/commands/ephemeral/delete/index.d.ts +0 -16
  14. package/dist/commands/ephemeral/delete/index.js +0 -99
  15. package/dist/commands/ephemeral/env/delete/index.d.ts +0 -17
  16. package/dist/commands/ephemeral/env/delete/index.js +0 -105
  17. package/dist/commands/ephemeral/env/get/index.d.ts +0 -15
  18. package/dist/commands/ephemeral/env/get/index.js +0 -81
  19. package/dist/commands/ephemeral/env/get_all/index.d.ts +0 -16
  20. package/dist/commands/ephemeral/env/get_all/index.js +0 -94
  21. package/dist/commands/ephemeral/env/list/index.d.ts +0 -14
  22. package/dist/commands/ephemeral/env/list/index.js +0 -83
  23. package/dist/commands/ephemeral/env/set/index.d.ts +0 -16
  24. package/dist/commands/ephemeral/env/set/index.js +0 -90
  25. package/dist/commands/ephemeral/env/set_all/index.d.ts +0 -16
  26. package/dist/commands/ephemeral/env/set_all/index.js +0 -102
  27. package/dist/commands/ephemeral/get/index.d.ts +0 -14
  28. package/dist/commands/ephemeral/get/index.js +0 -102
  29. package/dist/commands/ephemeral/impersonate/index.d.ts +0 -16
  30. package/dist/commands/ephemeral/impersonate/index.js +0 -110
  31. package/dist/commands/ephemeral/license/get/index.d.ts +0 -16
  32. package/dist/commands/ephemeral/license/get/index.js +0 -94
  33. package/dist/commands/ephemeral/license/set/index.d.ts +0 -17
  34. package/dist/commands/ephemeral/license/set/index.js +0 -111
  35. package/dist/commands/ephemeral/list/index.d.ts +0 -15
  36. package/dist/commands/ephemeral/list/index.js +0 -109
  37. package/dist/commands/ephemeral/pull/index.d.ts +0 -18
  38. package/dist/commands/ephemeral/pull/index.js +0 -197
  39. package/dist/commands/ephemeral/push/index.d.ts +0 -19
  40. package/dist/commands/ephemeral/push/index.js +0 -158
  41. package/dist/commands/ephemeral/shared/index.d.ts +0 -15
  42. package/dist/commands/ephemeral/shared/index.js +0 -108
  43. package/dist/commands/ephemeral/unit_test/list/index.d.ts +0 -14
  44. package/dist/commands/ephemeral/unit_test/list/index.js +0 -105
  45. package/dist/commands/ephemeral/unit_test/run/index.d.ts +0 -15
  46. package/dist/commands/ephemeral/unit_test/run/index.js +0 -93
  47. package/dist/commands/ephemeral/unit_test/run_all/index.d.ts +0 -14
  48. package/dist/commands/ephemeral/unit_test/run_all/index.js +0 -183
  49. package/dist/commands/ephemeral/workflow_test/delete/index.d.ts +0 -18
  50. package/dist/commands/ephemeral/workflow_test/delete/index.js +0 -75
  51. package/dist/commands/ephemeral/workflow_test/get/index.d.ts +0 -18
  52. package/dist/commands/ephemeral/workflow_test/get/index.js +0 -77
  53. package/dist/commands/ephemeral/workflow_test/list/index.d.ts +0 -13
  54. package/dist/commands/ephemeral/workflow_test/list/index.js +0 -98
  55. package/dist/commands/ephemeral/workflow_test/run/index.d.ts +0 -18
  56. package/dist/commands/ephemeral/workflow_test/run/index.js +0 -91
  57. package/dist/commands/ephemeral/workflow_test/run_all/index.d.ts +0 -13
  58. package/dist/commands/ephemeral/workflow_test/run_all/index.js +0 -169
  59. package/dist/commands/release/deploy/index.d.ts +0 -17
  60. package/dist/commands/release/deploy/index.js +0 -107
  61. package/dist/commands/tenant/unit_test/list/index.d.ts +0 -15
  62. package/dist/commands/tenant/unit_test/list/index.js +0 -140
  63. package/dist/commands/tenant/unit_test/run/index.d.ts +0 -16
  64. package/dist/commands/tenant/unit_test/run/index.js +0 -128
  65. package/dist/commands/tenant/unit_test/run_all/index.d.ts +0 -15
  66. package/dist/commands/tenant/unit_test/run_all/index.js +0 -215
  67. package/dist/commands/tenant/workflow_test/delete/index.d.ts +0 -19
  68. package/dist/commands/tenant/workflow_test/delete/index.js +0 -110
  69. package/dist/commands/tenant/workflow_test/get/index.d.ts +0 -19
  70. package/dist/commands/tenant/workflow_test/get/index.js +0 -112
  71. package/dist/commands/tenant/workflow_test/list/index.d.ts +0 -14
  72. package/dist/commands/tenant/workflow_test/list/index.js +0 -133
  73. package/dist/commands/tenant/workflow_test/run/index.d.ts +0 -19
  74. package/dist/commands/tenant/workflow_test/run/index.js +0 -126
  75. package/dist/commands/tenant/workflow_test/run_all/index.d.ts +0 -14
  76. package/dist/commands/tenant/workflow_test/run_all/index.js +0 -201
@@ -1,158 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import BaseCommand from '../../../base-command.js';
3
- import { findFilesWithGuid } from '../../../utils/document-parser.js';
4
- import * as fs from 'node:fs';
5
- import * as path from 'node:path';
6
- export default class EphemeralPush extends BaseCommand {
7
- static args = {
8
- directory: Args.string({
9
- description: 'Directory containing documents to push (as produced by ephemeral pull or workspace pull)',
10
- required: true,
11
- }),
12
- };
13
- static description = 'Push local documents to an ephemeral tenant via multidoc import';
14
- static examples = [
15
- `$ xano ephemeral push ./my-workspace -t my-tenant
16
- Pushed 42 documents to ephemeral tenant my-tenant from ./my-workspace
17
- `,
18
- `$ xano ephemeral push ./backup -t my-tenant --records --env`,
19
- `$ xano ephemeral push ./my-workspace -t my-tenant --truncate`,
20
- ];
21
- static flags = {
22
- ...BaseCommand.baseFlags,
23
- env: Flags.boolean({
24
- default: false,
25
- description: 'Include environment variables in import',
26
- required: false,
27
- }),
28
- records: Flags.boolean({
29
- default: false,
30
- description: 'Include records in import',
31
- required: false,
32
- }),
33
- tenant: Flags.string({
34
- char: 't',
35
- description: 'Ephemeral tenant name to push to',
36
- required: true,
37
- }),
38
- transaction: Flags.boolean({
39
- allowNo: true,
40
- default: true,
41
- description: 'Wrap import in a database transaction (use --no-transaction for debugging purposes)',
42
- required: false,
43
- }),
44
- truncate: Flags.boolean({
45
- default: false,
46
- description: 'Truncate all table records before importing',
47
- required: false,
48
- }),
49
- };
50
- async run() {
51
- const { args, flags } = await this.parse(EphemeralPush);
52
- const profileName = flags.profile || this.getDefaultProfile();
53
- const credentials = this.loadCredentialsFile();
54
- if (!credentials || !(profileName in credentials.profiles)) {
55
- this.error(`Profile '${profileName}' not found.\n` + `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
- }
64
- const tenantName = flags.tenant;
65
- const inputDir = path.resolve(args.directory);
66
- if (!fs.existsSync(inputDir)) {
67
- this.error(`Directory not found: ${inputDir}`);
68
- }
69
- if (!fs.statSync(inputDir).isDirectory()) {
70
- this.error(`Not a directory: ${inputDir}`);
71
- }
72
- const files = this.collectFiles(inputDir);
73
- if (files.length === 0) {
74
- this.error(`No .xs files found in ${args.directory}`);
75
- }
76
- const documentEntries = [];
77
- for (const filePath of files) {
78
- const content = fs.readFileSync(filePath, 'utf8').trim();
79
- if (content) {
80
- documentEntries.push({ content, filePath });
81
- }
82
- }
83
- if (documentEntries.length === 0) {
84
- this.error(`All .xs files in ${args.directory} are empty`);
85
- }
86
- const multidoc = documentEntries.map((d) => d.content).join('\n---\n');
87
- const queryParams = new URLSearchParams({
88
- env: flags.env.toString(),
89
- records: flags.records.toString(),
90
- transaction: flags.transaction.toString(),
91
- truncate: flags.truncate.toString(),
92
- });
93
- const apiUrl = `${profile.instance_origin}/api:meta/ephemeral/tenant/${tenantName}/multidoc?${queryParams.toString()}`;
94
- const startTime = Date.now();
95
- try {
96
- const response = await this.verboseFetch(apiUrl, {
97
- body: multidoc,
98
- headers: {
99
- accept: 'application/json',
100
- Authorization: `Bearer ${profile.access_token}`,
101
- 'Content-Type': 'text/x-xanoscript',
102
- },
103
- method: 'POST',
104
- }, flags.verbose, profile.access_token);
105
- if (!response.ok) {
106
- const errorText = await response.text();
107
- let errorMessage = `Push failed (${response.status})`;
108
- try {
109
- const errorJson = JSON.parse(errorText);
110
- errorMessage += `: ${errorJson.message}`;
111
- if (errorJson.payload?.param) {
112
- errorMessage += `\n Parameter: ${errorJson.payload.param}`;
113
- }
114
- }
115
- catch {
116
- errorMessage += `\n${errorText}`;
117
- }
118
- const guidMatch = errorMessage.match(/Duplicate \w+ guid: (\S+)/);
119
- if (guidMatch) {
120
- const dupeFiles = findFilesWithGuid(documentEntries, guidMatch[1]);
121
- if (dupeFiles.length > 0) {
122
- const relPaths = dupeFiles.map((f) => path.relative(inputDir, f));
123
- errorMessage += `\n Local files with this GUID:\n${relPaths.map((f) => ` ${f}`).join('\n')}`;
124
- }
125
- }
126
- this.error(errorMessage);
127
- }
128
- const responseText = await response.text();
129
- if (responseText && responseText !== 'null' && flags.verbose) {
130
- this.log(responseText);
131
- }
132
- }
133
- catch (error) {
134
- if (error instanceof Error) {
135
- this.error(`Failed to push multidoc: ${error.message}`);
136
- }
137
- else {
138
- this.error(`Failed to push multidoc: ${String(error)}`);
139
- }
140
- }
141
- const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
142
- this.log(`Pushed ${documentEntries.length} documents to ephemeral tenant ${tenantName} from ${args.directory} in ${elapsed}s`);
143
- }
144
- collectFiles(dir) {
145
- const files = [];
146
- const entries = fs.readdirSync(dir, { withFileTypes: true });
147
- for (const entry of entries) {
148
- const fullPath = path.join(dir, entry.name);
149
- if (entry.isDirectory()) {
150
- files.push(...this.collectFiles(fullPath));
151
- }
152
- else if (entry.isFile() && entry.name.endsWith('.xs')) {
153
- files.push(fullPath);
154
- }
155
- }
156
- return files.sort();
157
- }
158
- }
@@ -1,15 +0,0 @@
1
- import BaseCommand from '../../../base-command.js';
2
- export default class EphemeralShared extends BaseCommand {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- order: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
- page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
9
- per_page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
- sort: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
- profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
- };
14
- run(): Promise<void>;
15
- }
@@ -1,108 +0,0 @@
1
- import { Flags } from '@oclif/core';
2
- import BaseCommand from '../../../base-command.js';
3
- export default class EphemeralShared extends BaseCommand {
4
- static description = 'List all shared ephemeral tenants on the instance';
5
- static examples = [
6
- `$ xano ephemeral shared
7
- Shared ephemeral tenants:
8
- - My Tenant (e1a2-b3c4-x5y6) [ok] [shared]
9
- - CI Tenant (e2b3-c4d5-y6z7) [ok] [shared]
10
- `,
11
- `$ xano ephemeral shared -o json`,
12
- ];
13
- static flags = {
14
- ...BaseCommand.baseFlags,
15
- order: Flags.string({
16
- default: 'asc',
17
- description: 'Sort order',
18
- options: ['asc', 'desc'],
19
- required: false,
20
- }),
21
- output: Flags.string({
22
- char: 'o',
23
- default: 'summary',
24
- description: 'Output format',
25
- options: ['summary', 'json'],
26
- required: false,
27
- }),
28
- page: Flags.integer({
29
- default: 1,
30
- description: 'Page number',
31
- required: false,
32
- }),
33
- per_page: Flags.integer({
34
- default: 50,
35
- description: 'Items per page',
36
- required: false,
37
- }),
38
- sort: Flags.string({
39
- default: 'name',
40
- description: 'Sort field',
41
- options: ['name', 'created_at', 'state'],
42
- required: false,
43
- }),
44
- };
45
- async run() {
46
- const { flags } = await this.parse(EphemeralShared);
47
- const profileName = flags.profile || this.getDefaultProfile();
48
- const credentials = this.loadCredentialsFile();
49
- if (!credentials || !(profileName in credentials.profiles)) {
50
- this.error(`Profile '${profileName}' not found.\n` + `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
- }
59
- const params = new URLSearchParams({
60
- order: flags.order,
61
- page: String(flags.page),
62
- per_page: String(flags.per_page),
63
- sort: flags.sort,
64
- });
65
- const apiUrl = `${profile.instance_origin}/api:meta/ephemeral/tenant/shared?${params}`;
66
- try {
67
- const response = await this.verboseFetch(apiUrl, {
68
- headers: {
69
- accept: 'application/json',
70
- Authorization: `Bearer ${profile.access_token}`,
71
- },
72
- method: 'GET',
73
- }, flags.verbose, profile.access_token);
74
- if (!response.ok) {
75
- const errorText = await response.text();
76
- this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
77
- }
78
- const data = (await response.json());
79
- const tenants = data.items ?? [];
80
- if (flags.output === 'json') {
81
- this.log(JSON.stringify(data, null, 2));
82
- }
83
- else {
84
- if (tenants.length === 0) {
85
- this.log('No shared ephemeral tenants found');
86
- }
87
- else {
88
- this.log('Shared ephemeral tenants:');
89
- for (const tenant of tenants) {
90
- const state = tenant.state ? ` [${tenant.state}]` : '';
91
- this.log(` - ${tenant.display || tenant.name} (${tenant.name})${state}`);
92
- }
93
- if (data.nextPage) {
94
- this.log(`\nPage ${data.curPage} — more results available (use --page ${data.nextPage})`);
95
- }
96
- }
97
- }
98
- }
99
- catch (error) {
100
- if (error instanceof Error) {
101
- this.error(`Failed to list shared ephemeral tenants: ${error.message}`);
102
- }
103
- else {
104
- this.error(`Failed to list shared ephemeral tenants: ${String(error)}`);
105
- }
106
- }
107
- }
108
- }
@@ -1,14 +0,0 @@
1
- import BaseCommand from '../../../../base-command.js';
2
- export default class EphemeralUnitTestList extends BaseCommand {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- 'obj-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
- tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
- profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
- };
13
- run(): Promise<void>;
14
- }
@@ -1,105 +0,0 @@
1
- import { Flags } from '@oclif/core';
2
- import BaseCommand from '../../../../base-command.js';
3
- export default class EphemeralUnitTestList extends BaseCommand {
4
- static description = 'List all unit tests for an ephemeral tenant';
5
- static examples = [
6
- `$ xano ephemeral unit-test list -t e1a2-b3c4-x5y6
7
- Unit tests:
8
- - my-test (ID: abc-123) [function: math]
9
- `,
10
- `$ xano ephemeral unit-test list -t e1a2-b3c4-x5y6 -o json`,
11
- ];
12
- static flags = {
13
- ...BaseCommand.baseFlags,
14
- branch: Flags.string({
15
- char: 'b',
16
- description: 'Filter by branch name',
17
- required: false,
18
- }),
19
- 'obj-type': Flags.string({
20
- description: 'Filter by object type',
21
- options: ['function', 'query', 'middleware'],
22
- required: false,
23
- }),
24
- output: Flags.string({
25
- char: 'o',
26
- default: 'summary',
27
- description: 'Output format',
28
- options: ['summary', 'json'],
29
- required: false,
30
- }),
31
- tenant: Flags.string({
32
- char: 't',
33
- description: 'Ephemeral tenant name',
34
- required: true,
35
- }),
36
- };
37
- async run() {
38
- const { flags } = await this.parse(EphemeralUnitTestList);
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
- }
51
- const params = new URLSearchParams();
52
- params.set('per_page', '10000');
53
- if (flags.branch)
54
- params.set('branch', flags.branch);
55
- if (flags['obj-type'])
56
- params.set('obj_type', flags['obj-type']);
57
- const apiUrl = `${profile.instance_origin}/api:meta/ephemeral/tenant/${encodeURIComponent(flags.tenant)}/unit_test?${params}`;
58
- try {
59
- const response = await this.verboseFetch(apiUrl, {
60
- headers: {
61
- accept: 'application/json',
62
- Authorization: `Bearer ${profile.access_token}`,
63
- },
64
- method: 'GET',
65
- }, flags.verbose, profile.access_token);
66
- if (!response.ok) {
67
- const errorText = await response.text();
68
- this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
69
- }
70
- const data = (await response.json());
71
- let tests;
72
- if (Array.isArray(data)) {
73
- tests = data;
74
- }
75
- else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
76
- tests = data.items;
77
- }
78
- else {
79
- this.error('Unexpected API response format');
80
- }
81
- if (flags.output === 'json') {
82
- this.log(JSON.stringify(tests, null, 2));
83
- }
84
- else {
85
- if (tests.length === 0) {
86
- this.log('No unit tests found');
87
- }
88
- else {
89
- this.log(`Unit tests for tenant ${flags.tenant}:`);
90
- for (const test of tests) {
91
- this.log(` - ${test.name} (ID: ${test.id}) [${test.obj_type}: ${test.obj_name}]`);
92
- }
93
- }
94
- }
95
- }
96
- catch (error) {
97
- if (error instanceof Error) {
98
- this.error(`Failed to list unit tests: ${error.message}`);
99
- }
100
- else {
101
- this.error(`Failed to list unit tests: ${String(error)}`);
102
- }
103
- }
104
- }
105
- }
@@ -1,15 +0,0 @@
1
- import BaseCommand from '../../../../base-command.js';
2
- export default class EphemeralUnitTestRun extends BaseCommand {
3
- static args: {
4
- unit_test_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
- };
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
- tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
- profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
- };
14
- run(): Promise<void>;
15
- }
@@ -1,93 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import BaseCommand from '../../../../base-command.js';
3
- export default class EphemeralUnitTestRun extends BaseCommand {
4
- static args = {
5
- unit_test_id: Args.string({
6
- description: 'ID of the unit test to run',
7
- required: true,
8
- }),
9
- };
10
- static description = 'Run a unit test for an ephemeral tenant';
11
- static examples = [
12
- `$ xano ephemeral unit-test run abc-123 -t e1a2-b3c4-x5y6
13
- Running unit test abc-123...
14
- Result: PASS
15
- `,
16
- `$ xano ephemeral unit-test run abc-123 -t e1a2-b3c4-x5y6 -o json`,
17
- ];
18
- static flags = {
19
- ...BaseCommand.baseFlags,
20
- output: Flags.string({
21
- char: 'o',
22
- default: 'summary',
23
- description: 'Output format',
24
- options: ['summary', 'json'],
25
- required: false,
26
- }),
27
- tenant: Flags.string({
28
- char: 't',
29
- description: 'Ephemeral tenant name',
30
- required: true,
31
- }),
32
- };
33
- async run() {
34
- const { args, flags } = await this.parse(EphemeralUnitTestRun);
35
- const profileName = flags.profile || this.getDefaultProfile();
36
- const credentials = this.loadCredentialsFile();
37
- if (!credentials || !(profileName in credentials.profiles)) {
38
- this.error(`Profile '${profileName}' not found.\nCreate a profile using 'xano profile create'`);
39
- }
40
- const profile = credentials.profiles[profileName];
41
- if (!profile.instance_origin) {
42
- this.error(`Profile '${profileName}' is missing instance_origin`);
43
- }
44
- if (!profile.access_token) {
45
- this.error(`Profile '${profileName}' is missing access_token`);
46
- }
47
- const apiUrl = `${profile.instance_origin}/api:meta/ephemeral/tenant/${encodeURIComponent(flags.tenant)}/unit_test/${encodeURIComponent(args.unit_test_id)}/run`;
48
- try {
49
- if (flags.output === 'summary') {
50
- this.log(`Running unit test ${args.unit_test_id}...`);
51
- }
52
- const response = await this.verboseFetch(apiUrl, {
53
- headers: {
54
- accept: 'application/json',
55
- Authorization: `Bearer ${profile.access_token}`,
56
- 'Content-Type': 'application/json',
57
- },
58
- method: 'POST',
59
- }, flags.verbose, profile.access_token);
60
- if (!response.ok) {
61
- const errorText = await response.text();
62
- this.error(`API request failed with status ${response.status}: ${response.statusText}\n${errorText}`);
63
- }
64
- const result = (await response.json());
65
- if (flags.output === 'json') {
66
- this.log(JSON.stringify(result, null, 2));
67
- }
68
- else {
69
- if (result.status === 'ok') {
70
- this.log('Result: PASS');
71
- }
72
- else {
73
- this.log('Result: FAIL');
74
- const failedExpects = result.results?.filter((r) => r.status === 'fail') ?? [];
75
- for (const expect of failedExpects) {
76
- if (expect.message) {
77
- this.log(` Error: ${expect.message}`);
78
- }
79
- }
80
- this.exit(1);
81
- }
82
- }
83
- }
84
- catch (error) {
85
- if (error instanceof Error) {
86
- this.error(`Failed to run unit test: ${error.message}`);
87
- }
88
- else {
89
- this.error(`Failed to run unit test: ${String(error)}`);
90
- }
91
- }
92
- }
93
- }
@@ -1,14 +0,0 @@
1
- import BaseCommand from '../../../../base-command.js';
2
- export default class EphemeralUnitTestRunAll extends BaseCommand {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- 'obj-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
- tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
- profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
- };
13
- run(): Promise<void>;
14
- }