@xano/cli 1.0.6-beta.1 → 1.0.6-beta.10
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.
- package/README.md +96 -4
- package/dist/commands/branch/list/index.js +5 -1
- package/dist/commands/ephemeral/impersonate/index.d.ts +1 -0
- package/dist/commands/ephemeral/impersonate/index.js +11 -3
- package/dist/commands/ephemeral/list/index.js +2 -1
- package/dist/commands/ephemeral/pull/index.d.ts +0 -6
- package/dist/commands/ephemeral/pull/index.js +10 -95
- package/dist/commands/ephemeral/push/index.d.ts +10 -0
- package/dist/commands/ephemeral/push/index.js +77 -0
- package/dist/commands/ephemeral/static_host/build/list/index.d.ts +2 -3
- package/dist/commands/ephemeral/static_host/build/list/index.js +19 -40
- package/dist/commands/ephemeral/static_host/list/index.d.ts +2 -3
- package/dist/commands/ephemeral/static_host/list/index.js +20 -40
- package/dist/commands/flatten/index.d.ts +34 -0
- package/dist/commands/flatten/index.js +140 -0
- package/dist/commands/function/list/index.d.ts +4 -4
- package/dist/commands/function/list/index.js +30 -38
- package/dist/commands/knowledge/list/index.js +2 -1
- package/dist/commands/platform/list/index.js +13 -14
- package/dist/commands/release/list/index.js +13 -14
- package/dist/commands/release/pull/index.d.ts +0 -6
- package/dist/commands/release/pull/index.js +10 -95
- package/dist/commands/sandbox/env/list/index.js +4 -0
- package/dist/commands/sandbox/pull/index.d.ts +0 -1
- package/dist/commands/sandbox/pull/index.js +10 -77
- package/dist/commands/sandbox/unit_test/list/index.d.ts +2 -0
- package/dist/commands/sandbox/unit_test/list/index.js +9 -14
- package/dist/commands/sandbox/unit_test/run_all/index.d.ts +1 -0
- package/dist/commands/sandbox/unit_test/run_all/index.js +67 -37
- package/dist/commands/sandbox/workflow_test/list/index.d.ts +2 -0
- package/dist/commands/sandbox/workflow_test/list/index.js +9 -14
- package/dist/commands/sandbox/workflow_test/run_all/index.d.ts +1 -0
- package/dist/commands/sandbox/workflow_test/run_all/index.js +65 -35
- package/dist/commands/static_host/build/list/index.d.ts +2 -3
- package/dist/commands/static_host/build/list/index.js +19 -40
- package/dist/commands/static_host/build/pull/index.js +12 -9
- package/dist/commands/static_host/list/index.d.ts +2 -3
- package/dist/commands/static_host/list/index.js +20 -40
- package/dist/commands/static_host/migrate/index.js +14 -10
- package/dist/commands/tenant/backup/list/index.js +13 -14
- package/dist/commands/tenant/cluster/list/index.js +9 -10
- package/dist/commands/tenant/env/list/index.js +4 -0
- package/dist/commands/tenant/list/index.js +19 -20
- package/dist/commands/tenant/pull/index.d.ts +0 -6
- package/dist/commands/tenant/pull/index.js +10 -95
- package/dist/commands/tenant/snapshot/list/index.js +5 -1
- package/dist/commands/tenant/unit_test/list/index.d.ts +4 -2
- package/dist/commands/tenant/unit_test/list/index.js +9 -14
- package/dist/commands/tenant/unit_test/run_all/index.d.ts +1 -0
- package/dist/commands/tenant/unit_test/run_all/index.js +67 -37
- package/dist/commands/tenant/workflow_test/list/index.d.ts +4 -2
- package/dist/commands/tenant/workflow_test/list/index.js +9 -14
- package/dist/commands/tenant/workflow_test/run_all/index.d.ts +1 -0
- package/dist/commands/tenant/workflow_test/run_all/index.js +65 -35
- package/dist/commands/unit_test/list/index.d.ts +3 -1
- package/dist/commands/unit_test/list/index.js +9 -14
- package/dist/commands/unit_test/run_all/index.d.ts +1 -0
- package/dist/commands/unit_test/run_all/index.js +68 -40
- package/dist/commands/workflow_test/list/index.d.ts +3 -1
- package/dist/commands/workflow_test/list/index.js +10 -13
- package/dist/commands/workflow_test/run_all/index.d.ts +1 -0
- package/dist/commands/workflow_test/run_all/index.js +67 -36
- package/dist/commands/workspace/git/pull/index.js +53 -3
- package/dist/commands/workspace/list/index.js +7 -13
- package/dist/commands/workspace/pull/index.d.ts +0 -6
- package/dist/commands/workspace/pull/index.js +10 -95
- package/dist/utils/concurrency.d.ts +29 -0
- package/dist/utils/concurrency.js +54 -0
- package/dist/utils/document-parser.d.ts +116 -0
- package/dist/utils/document-parser.js +274 -1
- package/dist/utils/flatten.d.ts +36 -0
- package/dist/utils/flatten.js +68 -0
- package/dist/utils/knowledge-sync.d.ts +1 -0
- package/dist/utils/knowledge-sync.js +11 -5
- package/dist/utils/microservice-wait.d.ts +53 -0
- package/dist/utils/microservice-wait.js +83 -0
- package/dist/utils/multidoc-push.d.ts +12 -0
- package/dist/utils/multidoc-push.js +84 -0
- package/dist/utils/paging.d.ts +145 -0
- package/dist/utils/paging.js +199 -0
- package/dist/utils/reference-checker.js +13 -0
- package/oclif.manifest.json +2762 -2550
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import snakeCase from 'lodash.snakecase';
|
|
3
3
|
import BaseCommand from '../../../base-command.js';
|
|
4
|
-
import { buildApiGroupFolderResolver, parseDocument } from '../../../utils/document-parser.js';
|
|
4
|
+
import { buildApiGroupFolderResolver, buildChannelServerResolver, parseDocument, resolveDocumentPath, } from '../../../utils/document-parser.js';
|
|
5
5
|
import { fetchKnowledge, writeKnowledge } from '../../../utils/knowledge-sync.js';
|
|
6
6
|
import * as fs from 'node:fs';
|
|
7
7
|
import * as path from 'node:path';
|
|
@@ -92,82 +92,18 @@ Pulled 42 documents from sandbox environment to ./my-sandbox
|
|
|
92
92
|
const outputDir = path.resolve(flags.directory);
|
|
93
93
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
94
94
|
const getApiGroupFolder = buildApiGroupFolderResolver(documents, snakeCase);
|
|
95
|
+
// Resolve a realtime v2 channel path -> owning realtime_server name, so
|
|
96
|
+
// messages can nest under their channel's server (see resolver docs).
|
|
97
|
+
const getChannelServer = buildChannelServerResolver(documents);
|
|
95
98
|
const filenameCounters = new Map();
|
|
96
99
|
let writtenCount = 0;
|
|
97
100
|
for (const doc of documents) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
else if (doc.type === 'workspace_trigger') {
|
|
105
|
-
typeDir = path.join(outputDir, 'workspace', 'trigger');
|
|
106
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
107
|
-
}
|
|
108
|
-
else if (doc.type === 'error_trigger') {
|
|
109
|
-
// error_trigger → workspace/trigger/{name}.xs (singleton, colocated with workspace triggers)
|
|
110
|
-
typeDir = path.join(outputDir, 'workspace', 'trigger');
|
|
111
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
112
|
-
}
|
|
113
|
-
else if (doc.type === 'agent') {
|
|
114
|
-
typeDir = path.join(outputDir, 'ai', 'agent');
|
|
115
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
116
|
-
}
|
|
117
|
-
else if (doc.type === 'mcp_server') {
|
|
118
|
-
typeDir = path.join(outputDir, 'ai', 'mcp_server');
|
|
119
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
120
|
-
}
|
|
121
|
-
else if (doc.type === 'tool') {
|
|
122
|
-
typeDir = path.join(outputDir, 'ai', 'tool');
|
|
123
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
124
|
-
}
|
|
125
|
-
else if (doc.type === 'agent_trigger') {
|
|
126
|
-
typeDir = path.join(outputDir, 'ai', 'agent', 'trigger');
|
|
127
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
128
|
-
}
|
|
129
|
-
else if (doc.type === 'mcp_server_trigger') {
|
|
130
|
-
typeDir = path.join(outputDir, 'ai', 'mcp_server', 'trigger');
|
|
131
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
132
|
-
}
|
|
133
|
-
else if (doc.type === 'table_trigger') {
|
|
134
|
-
typeDir = path.join(outputDir, 'table', 'trigger');
|
|
135
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
136
|
-
}
|
|
137
|
-
else if (doc.type === 'realtime_channel') {
|
|
138
|
-
typeDir = path.join(outputDir, 'realtime', 'channel');
|
|
139
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
140
|
-
}
|
|
141
|
-
else if (doc.type === 'realtime_trigger') {
|
|
142
|
-
typeDir = path.join(outputDir, 'realtime', 'trigger');
|
|
143
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
144
|
-
}
|
|
145
|
-
else if (doc.type === 'api_group') {
|
|
146
|
-
const groupFolder = getApiGroupFolder(doc.name);
|
|
147
|
-
typeDir = path.join(outputDir, 'api', groupFolder);
|
|
148
|
-
baseName = this.sanitizeFilename(doc.name);
|
|
149
|
-
}
|
|
150
|
-
else if (doc.type === 'query' && doc.apiGroup) {
|
|
151
|
-
const groupFolder = getApiGroupFolder(doc.apiGroup);
|
|
152
|
-
const nameParts = doc.name.split('/');
|
|
153
|
-
const leafName = nameParts.pop();
|
|
154
|
-
const folderParts = nameParts.map((part) => snakeCase(part));
|
|
155
|
-
typeDir = path.join(outputDir, 'api', groupFolder, ...folderParts);
|
|
156
|
-
baseName = this.sanitizeFilename(leafName);
|
|
157
|
-
if (doc.verb) {
|
|
158
|
-
baseName = `${baseName}_${doc.verb}`;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
const nameParts = doc.name.split('/');
|
|
163
|
-
const leafName = nameParts.pop();
|
|
164
|
-
const folderParts = nameParts.map((part) => snakeCase(part));
|
|
165
|
-
typeDir = path.join(outputDir, doc.type, ...folderParts);
|
|
166
|
-
baseName = this.sanitizeFilename(leafName);
|
|
167
|
-
if (doc.verb) {
|
|
168
|
-
baseName = `${baseName}_${doc.verb}`;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
101
|
+
const { baseName, typeDir } = resolveDocumentPath(doc, outputDir, {
|
|
102
|
+
getApiGroupFolder,
|
|
103
|
+
getChannelServer,
|
|
104
|
+
join: path.join,
|
|
105
|
+
snakeCase,
|
|
106
|
+
});
|
|
171
107
|
fs.mkdirSync(typeDir, { recursive: true });
|
|
172
108
|
const dirKey = path.relative(outputDir, typeDir);
|
|
173
109
|
if (!filenameCounters.has(dirKey)) {
|
|
@@ -194,7 +130,4 @@ Pulled 42 documents from sandbox environment to ./my-sandbox
|
|
|
194
130
|
parts.push(`${knowledgeCount} knowledge file${knowledgeCount === 1 ? '' : 's'}`);
|
|
195
131
|
this.log(`Pulled ${parts.join(' + ')} from sandbox environment to ${flags.directory}`);
|
|
196
132
|
}
|
|
197
|
-
sanitizeFilename(name) {
|
|
198
|
-
return snakeCase(name.replaceAll('"', ''));
|
|
199
|
-
}
|
|
200
133
|
}
|
|
@@ -3,6 +3,8 @@ export default class SandboxUnitTestList extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
per_page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
8
|
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
9
|
'obj-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
10
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import BaseCommand from '../../../../base-command.js';
|
|
3
|
+
import { buildPagingJson, buildPagingParams, formatPagingFooter, normalizeListResponse, pagingFlags } from '../../../../utils/paging.js';
|
|
3
4
|
export default class SandboxUnitTestList extends BaseCommand {
|
|
4
5
|
static description = 'List all unit tests for a sandbox environment';
|
|
5
6
|
static examples = [
|
|
@@ -28,12 +29,12 @@ Unit tests:
|
|
|
28
29
|
options: ['summary', 'json'],
|
|
29
30
|
required: false,
|
|
30
31
|
}),
|
|
32
|
+
...pagingFlags('envelope', { maxPerPage: 10_000 }),
|
|
31
33
|
};
|
|
32
34
|
async run() {
|
|
33
35
|
const { flags } = await this.parse(SandboxUnitTestList);
|
|
34
36
|
const { profile } = this.resolveProfile(flags);
|
|
35
|
-
const params = new URLSearchParams();
|
|
36
|
-
params.set('per_page', '10000');
|
|
37
|
+
const params = new URLSearchParams(buildPagingParams(flags, 'envelope'));
|
|
37
38
|
if (flags.branch)
|
|
38
39
|
params.set('branch', flags.branch);
|
|
39
40
|
if (flags['obj-type'])
|
|
@@ -51,19 +52,10 @@ Unit tests:
|
|
|
51
52
|
const message = await this.parseApiError(response, 'API request failed');
|
|
52
53
|
this.error(message);
|
|
53
54
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
if (Array.isArray(data)) {
|
|
57
|
-
tests = data;
|
|
58
|
-
}
|
|
59
|
-
else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
|
|
60
|
-
tests = data.items;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.error('Unexpected API response format');
|
|
64
|
-
}
|
|
55
|
+
const list = normalizeListResponse(await response.json());
|
|
56
|
+
const tests = list.items;
|
|
65
57
|
if (flags.output === 'json') {
|
|
66
|
-
this.log(JSON.stringify(
|
|
58
|
+
this.log(JSON.stringify(buildPagingJson(list, { page: flags.page, perPage: flags.per_page, tier: 'envelope' }), null, 2));
|
|
67
59
|
}
|
|
68
60
|
else {
|
|
69
61
|
if (tests.length === 0) {
|
|
@@ -75,6 +67,9 @@ Unit tests:
|
|
|
75
67
|
this.log(` - ${test.name} (ID: ${test.id}) [${test.obj_type}: ${test.obj_name}]`);
|
|
76
68
|
}
|
|
77
69
|
}
|
|
70
|
+
const footer = formatPagingFooter(list, { noun: 'unit test', page: flags.page, tier: 'envelope' });
|
|
71
|
+
if (footer)
|
|
72
|
+
this.log(footer);
|
|
78
73
|
}
|
|
79
74
|
}
|
|
80
75
|
catch (error) {
|
|
@@ -4,6 +4,7 @@ export default class SandboxUnitTestRunAll extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
'obj-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
9
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import BaseCommand from '../../../../base-command.js';
|
|
3
|
+
import { createOrderedEmitter, mapWithConcurrency } from '../../../../utils/concurrency.js';
|
|
4
|
+
import { collectAllPages, INTERNAL_PAGE_SIZE, normalizeListResponse } from '../../../../utils/paging.js';
|
|
3
5
|
export default class SandboxUnitTestRunAll extends BaseCommand {
|
|
4
6
|
static description = 'Run all unit tests for a sandbox environment';
|
|
5
7
|
static examples = [
|
|
@@ -21,6 +23,11 @@ Results: 4 passed, 1 failed
|
|
|
21
23
|
description: 'Filter by branch name',
|
|
22
24
|
required: false,
|
|
23
25
|
}),
|
|
26
|
+
concurrency: Flags.integer({
|
|
27
|
+
default: 1,
|
|
28
|
+
description: 'Run this many tests in parallel. Tests share the workspace database, so raise this only when your tests do not depend on shared state.',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
24
31
|
'obj-type': Flags.string({
|
|
25
32
|
description: 'Filter by object type',
|
|
26
33
|
options: ['function', 'query', 'middleware'],
|
|
@@ -40,34 +47,36 @@ Results: 4 passed, 1 failed
|
|
|
40
47
|
const baseUrl = `${profile.instance_origin}/api:meta/sandbox/unit_test`;
|
|
41
48
|
try {
|
|
42
49
|
// Step 1: List all unit tests
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
// Page the list rather than asking for everything at once: 100 per
|
|
51
|
+
// request is plenty for typical suites and does not make the instance
|
|
52
|
+
// build one enormous response. Termination is the server's own nextPage,
|
|
53
|
+
// never "the page came back full".
|
|
54
|
+
const branchValue = flags.branch;
|
|
55
|
+
const tests = await collectAllPages(async (page) => {
|
|
56
|
+
const listParams = new URLSearchParams();
|
|
57
|
+
listParams.set('page', String(page));
|
|
58
|
+
listParams.set('per_page', String(INTERNAL_PAGE_SIZE));
|
|
59
|
+
if (branchValue)
|
|
60
|
+
listParams.set('branch', branchValue);
|
|
61
|
+
if (flags['obj-type'])
|
|
62
|
+
listParams.set('obj_type', flags['obj-type']);
|
|
63
|
+
const listResponse = await this.verboseFetch(`${baseUrl}?${listParams}`, {
|
|
64
|
+
headers: {
|
|
65
|
+
accept: 'application/json',
|
|
66
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
67
|
+
},
|
|
68
|
+
method: 'GET',
|
|
69
|
+
}, flags.verbose, profile.access_token);
|
|
70
|
+
if (!listResponse.ok) {
|
|
71
|
+
const errorText = await listResponse.text();
|
|
72
|
+
this.error(`Failed to list unit tests: ${listResponse.status}: ${listResponse.statusText}\n${errorText}`);
|
|
73
|
+
}
|
|
74
|
+
return normalizeListResponse(await listResponse.json());
|
|
75
|
+
}, {
|
|
76
|
+
onTruncate: (collected) => {
|
|
77
|
+
this.warn(`Stopped after ${collected} unit tests — the list did not terminate. Some tests may not have run.`);
|
|
53
78
|
},
|
|
54
|
-
|
|
55
|
-
}, flags.verbose, profile.access_token);
|
|
56
|
-
if (!listResponse.ok) {
|
|
57
|
-
const errorText = await listResponse.text();
|
|
58
|
-
this.error(`Failed to list unit tests: ${listResponse.status}: ${listResponse.statusText}\n${errorText}`);
|
|
59
|
-
}
|
|
60
|
-
const data = (await listResponse.json());
|
|
61
|
-
let tests;
|
|
62
|
-
if (Array.isArray(data)) {
|
|
63
|
-
tests = data;
|
|
64
|
-
}
|
|
65
|
-
else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
|
|
66
|
-
tests = data.items;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
this.error('Unexpected API response format');
|
|
70
|
-
}
|
|
79
|
+
});
|
|
71
80
|
if (tests.length === 0) {
|
|
72
81
|
this.log('No unit tests found');
|
|
73
82
|
return;
|
|
@@ -77,7 +86,15 @@ Results: 4 passed, 1 failed
|
|
|
77
86
|
}
|
|
78
87
|
// Step 2: Run each test
|
|
79
88
|
const results = [];
|
|
80
|
-
|
|
89
|
+
const runOne = async (test) => {
|
|
90
|
+
// Shadowed accumulators: the body below is the original sequential
|
|
91
|
+
// logic, but it records output instead of printing it so a concurrent
|
|
92
|
+
// run can still emit in input order.
|
|
93
|
+
const results = [];
|
|
94
|
+
const lines = [];
|
|
95
|
+
const log = (message) => {
|
|
96
|
+
lines.push(message);
|
|
97
|
+
};
|
|
81
98
|
const runUrl = `${baseUrl}/${test.id}/run`;
|
|
82
99
|
try {
|
|
83
100
|
const runResponse = await this.verboseFetch(runUrl, {
|
|
@@ -98,10 +115,10 @@ Results: 4 passed, 1 failed
|
|
|
98
115
|
status: 'fail',
|
|
99
116
|
});
|
|
100
117
|
if (flags.output === 'summary') {
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
log(`FAIL ${test.name} [${test.obj_type}: ${test.obj_name}]`);
|
|
119
|
+
log(` Error: API error ${runResponse.status}`);
|
|
103
120
|
}
|
|
104
|
-
|
|
121
|
+
return { lines, results };
|
|
105
122
|
}
|
|
106
123
|
const runResult = (await runResponse.json());
|
|
107
124
|
const passed = runResult.status === 'ok';
|
|
@@ -115,13 +132,13 @@ Results: 4 passed, 1 failed
|
|
|
115
132
|
});
|
|
116
133
|
if (flags.output === 'summary') {
|
|
117
134
|
if (passed) {
|
|
118
|
-
|
|
135
|
+
log(`PASS ${test.name} [${test.obj_type}: ${test.obj_name}]`);
|
|
119
136
|
}
|
|
120
137
|
else {
|
|
121
|
-
|
|
138
|
+
log(`FAIL ${test.name} [${test.obj_type}: ${test.obj_name}]`);
|
|
122
139
|
for (const expect of failedExpects) {
|
|
123
140
|
if (expect.message) {
|
|
124
|
-
|
|
141
|
+
log(` Error: ${expect.message}`);
|
|
125
142
|
}
|
|
126
143
|
}
|
|
127
144
|
}
|
|
@@ -139,11 +156,24 @@ Results: 4 passed, 1 failed
|
|
|
139
156
|
status: 'fail',
|
|
140
157
|
});
|
|
141
158
|
if (flags.output === 'summary') {
|
|
142
|
-
|
|
143
|
-
|
|
159
|
+
log(`FAIL ${test.name} [${test.obj_type}: ${test.obj_name}]`);
|
|
160
|
+
log(` Error: ${message}`);
|
|
144
161
|
}
|
|
145
162
|
}
|
|
146
|
-
|
|
163
|
+
return { lines, results };
|
|
164
|
+
};
|
|
165
|
+
// Print in input order as each test settles, so concurrent output stays
|
|
166
|
+
// diffable against a sequential run.
|
|
167
|
+
const emitter = createOrderedEmitter((settled) => {
|
|
168
|
+
for (const line of settled.lines)
|
|
169
|
+
this.log(line);
|
|
170
|
+
});
|
|
171
|
+
const perTest = await mapWithConcurrency(tests, flags.concurrency, async (test, index) => {
|
|
172
|
+
const settled = await runOne(test);
|
|
173
|
+
emitter.settle(index, settled);
|
|
174
|
+
return settled;
|
|
175
|
+
});
|
|
176
|
+
results.push(...perTest.flatMap((r) => r.results));
|
|
147
177
|
// Step 3: Summary
|
|
148
178
|
const passed = results.filter((r) => r.status === 'pass').length;
|
|
149
179
|
const failed = results.filter((r) => r.status === 'fail').length;
|
|
@@ -3,6 +3,8 @@ export default class SandboxWorkflowTestList extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
per_page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
8
|
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
9
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
10
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import BaseCommand from '../../../../base-command.js';
|
|
3
|
+
import { buildPagingJson, buildPagingParams, formatPagingFooter, normalizeListResponse, pagingFlags } from '../../../../utils/paging.js';
|
|
3
4
|
export default class SandboxWorkflowTestList extends BaseCommand {
|
|
4
5
|
static description = 'List workflow tests for a sandbox environment';
|
|
5
6
|
static examples = [
|
|
@@ -23,12 +24,12 @@ Workflow tests:
|
|
|
23
24
|
options: ['summary', 'json'],
|
|
24
25
|
required: false,
|
|
25
26
|
}),
|
|
27
|
+
...pagingFlags('envelope', { maxPerPage: 10_000 }),
|
|
26
28
|
};
|
|
27
29
|
async run() {
|
|
28
30
|
const { flags } = await this.parse(SandboxWorkflowTestList);
|
|
29
31
|
const { profile } = this.resolveProfile(flags);
|
|
30
|
-
const params = new URLSearchParams();
|
|
31
|
-
params.set('per_page', '10000');
|
|
32
|
+
const params = new URLSearchParams(buildPagingParams(flags, 'envelope'));
|
|
32
33
|
if (flags.branch)
|
|
33
34
|
params.set('branch', flags.branch);
|
|
34
35
|
const apiUrl = `${profile.instance_origin}/api:meta/sandbox/workflow_test?${params}`;
|
|
@@ -44,19 +45,10 @@ Workflow tests:
|
|
|
44
45
|
const message = await this.parseApiError(response, 'API request failed');
|
|
45
46
|
this.error(message);
|
|
46
47
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
if (Array.isArray(data)) {
|
|
50
|
-
tests = data;
|
|
51
|
-
}
|
|
52
|
-
else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
|
|
53
|
-
tests = data.items;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.error('Unexpected API response format');
|
|
57
|
-
}
|
|
48
|
+
const list = normalizeListResponse(await response.json());
|
|
49
|
+
const tests = list.items;
|
|
58
50
|
if (flags.output === 'json') {
|
|
59
|
-
this.log(JSON.stringify(
|
|
51
|
+
this.log(JSON.stringify(buildPagingJson(list, { page: flags.page, perPage: flags.per_page, tier: 'envelope' }), null, 2));
|
|
60
52
|
}
|
|
61
53
|
else {
|
|
62
54
|
if (tests.length === 0) {
|
|
@@ -68,6 +60,9 @@ Workflow tests:
|
|
|
68
60
|
this.log(` - ${test.name} (ID: ${test.id})`);
|
|
69
61
|
}
|
|
70
62
|
}
|
|
63
|
+
const footer = formatPagingFooter(list, { noun: 'workflow test', page: flags.page, tier: 'envelope' });
|
|
64
|
+
if (footer)
|
|
65
|
+
this.log(footer);
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
catch (error) {
|
|
@@ -4,6 +4,7 @@ export default class SandboxWorkflowTestRunAll extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
9
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import BaseCommand from '../../../../base-command.js';
|
|
3
|
+
import { createOrderedEmitter, mapWithConcurrency } from '../../../../utils/concurrency.js';
|
|
4
|
+
import { collectAllPages, INTERNAL_PAGE_SIZE, normalizeListResponse } from '../../../../utils/paging.js';
|
|
3
5
|
export default class SandboxWorkflowTestRunAll extends BaseCommand {
|
|
4
6
|
static description = 'Run all workflow tests for a sandbox environment';
|
|
5
7
|
static examples = [
|
|
@@ -21,6 +23,11 @@ Results: 2 passed, 1 failed
|
|
|
21
23
|
description: 'Filter by branch name',
|
|
22
24
|
required: false,
|
|
23
25
|
}),
|
|
26
|
+
concurrency: Flags.integer({
|
|
27
|
+
default: 1,
|
|
28
|
+
description: 'Run this many tests in parallel. Tests share the workspace database, so raise this only when your tests do not depend on shared state.',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
24
31
|
output: Flags.string({
|
|
25
32
|
char: 'o',
|
|
26
33
|
default: 'summary',
|
|
@@ -35,32 +42,34 @@ Results: 2 passed, 1 failed
|
|
|
35
42
|
const baseUrl = `${profile.instance_origin}/api:meta/sandbox/workflow_test`;
|
|
36
43
|
try {
|
|
37
44
|
// Step 1: List all workflow tests
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
// Page the list rather than asking for everything at once: 100 per
|
|
46
|
+
// request is plenty for typical suites and does not make the instance
|
|
47
|
+
// build one enormous response. Termination is the server's own nextPage,
|
|
48
|
+
// never "the page came back full".
|
|
49
|
+
const branchValue = flags.branch;
|
|
50
|
+
const tests = await collectAllPages(async (page) => {
|
|
51
|
+
const listParams = new URLSearchParams();
|
|
52
|
+
listParams.set('page', String(page));
|
|
53
|
+
listParams.set('per_page', String(INTERNAL_PAGE_SIZE));
|
|
54
|
+
if (branchValue)
|
|
55
|
+
listParams.set('branch', branchValue);
|
|
56
|
+
const listResponse = await this.verboseFetch(`${baseUrl}?${listParams}`, {
|
|
57
|
+
headers: {
|
|
58
|
+
accept: 'application/json',
|
|
59
|
+
Authorization: `Bearer ${profile.access_token}`,
|
|
60
|
+
},
|
|
61
|
+
method: 'GET',
|
|
62
|
+
}, flags.verbose, profile.access_token);
|
|
63
|
+
if (!listResponse.ok) {
|
|
64
|
+
const errorText = await listResponse.text();
|
|
65
|
+
this.error(`Failed to list workflow tests: ${listResponse.status}: ${listResponse.statusText}\n${errorText}`);
|
|
66
|
+
}
|
|
67
|
+
return normalizeListResponse(await listResponse.json());
|
|
68
|
+
}, {
|
|
69
|
+
onTruncate: (collected) => {
|
|
70
|
+
this.warn(`Stopped after ${collected} workflow tests — the list did not terminate. Some tests may not have run.`);
|
|
46
71
|
},
|
|
47
|
-
|
|
48
|
-
}, flags.verbose, profile.access_token);
|
|
49
|
-
if (!listResponse.ok) {
|
|
50
|
-
const errorText = await listResponse.text();
|
|
51
|
-
this.error(`Failed to list workflow tests: ${listResponse.status}: ${listResponse.statusText}\n${errorText}`);
|
|
52
|
-
}
|
|
53
|
-
const data = (await listResponse.json());
|
|
54
|
-
let tests;
|
|
55
|
-
if (Array.isArray(data)) {
|
|
56
|
-
tests = data;
|
|
57
|
-
}
|
|
58
|
-
else if (data && typeof data === 'object' && 'items' in data && Array.isArray(data.items)) {
|
|
59
|
-
tests = data.items;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.error('Unexpected API response format');
|
|
63
|
-
}
|
|
72
|
+
});
|
|
64
73
|
if (tests.length === 0) {
|
|
65
74
|
this.log('No workflow tests found');
|
|
66
75
|
return;
|
|
@@ -70,7 +79,15 @@ Results: 2 passed, 1 failed
|
|
|
70
79
|
}
|
|
71
80
|
// Step 2: Run each test
|
|
72
81
|
const results = [];
|
|
73
|
-
|
|
82
|
+
const runOne = async (test) => {
|
|
83
|
+
// Shadowed accumulators: the body below is the original sequential
|
|
84
|
+
// logic, but it records output instead of printing it so a concurrent
|
|
85
|
+
// run can still emit in input order.
|
|
86
|
+
const results = [];
|
|
87
|
+
const lines = [];
|
|
88
|
+
const log = (message) => {
|
|
89
|
+
lines.push(message);
|
|
90
|
+
};
|
|
74
91
|
const runUrl = `${baseUrl}/${test.id}/run`;
|
|
75
92
|
try {
|
|
76
93
|
const runResponse = await this.verboseFetch(runUrl, {
|
|
@@ -89,10 +106,10 @@ Results: 2 passed, 1 failed
|
|
|
89
106
|
status: 'fail',
|
|
90
107
|
});
|
|
91
108
|
if (flags.output === 'summary') {
|
|
92
|
-
|
|
93
|
-
|
|
109
|
+
log(`FAIL ${test.name}`);
|
|
110
|
+
log(` Error: API error ${runResponse.status}`);
|
|
94
111
|
}
|
|
95
|
-
|
|
112
|
+
return { lines, results };
|
|
96
113
|
}
|
|
97
114
|
const runResult = (await runResponse.json());
|
|
98
115
|
const passed = runResult.status === 'ok';
|
|
@@ -105,12 +122,12 @@ Results: 2 passed, 1 failed
|
|
|
105
122
|
if (flags.output === 'summary') {
|
|
106
123
|
const timing = runResult.timing ? ` (${runResult.timing}s)` : '';
|
|
107
124
|
if (passed) {
|
|
108
|
-
|
|
125
|
+
log(`PASS ${test.name}${timing}`);
|
|
109
126
|
}
|
|
110
127
|
else {
|
|
111
|
-
|
|
128
|
+
log(`FAIL ${test.name}${timing}`);
|
|
112
129
|
if (runResult.message) {
|
|
113
|
-
|
|
130
|
+
log(` Error: ${runResult.message}`);
|
|
114
131
|
}
|
|
115
132
|
}
|
|
116
133
|
}
|
|
@@ -125,11 +142,24 @@ Results: 2 passed, 1 failed
|
|
|
125
142
|
status: 'fail',
|
|
126
143
|
});
|
|
127
144
|
if (flags.output === 'summary') {
|
|
128
|
-
|
|
129
|
-
|
|
145
|
+
log(`FAIL ${test.name}`);
|
|
146
|
+
log(` Error: ${message}`);
|
|
130
147
|
}
|
|
131
148
|
}
|
|
132
|
-
|
|
149
|
+
return { lines, results };
|
|
150
|
+
};
|
|
151
|
+
// Print in input order as each test settles, so concurrent output stays
|
|
152
|
+
// diffable against a sequential run.
|
|
153
|
+
const emitter = createOrderedEmitter((settled) => {
|
|
154
|
+
for (const line of settled.lines)
|
|
155
|
+
this.log(line);
|
|
156
|
+
});
|
|
157
|
+
const perTest = await mapWithConcurrency(tests, flags.concurrency, async (test, index) => {
|
|
158
|
+
const settled = await runOne(test);
|
|
159
|
+
emitter.settle(index, settled);
|
|
160
|
+
return settled;
|
|
161
|
+
});
|
|
162
|
+
results.push(...perTest.flatMap((r) => r.results));
|
|
133
163
|
// Step 3: Summary
|
|
134
164
|
const passed = results.filter((r) => r.status === 'pass').length;
|
|
135
165
|
const failed = results.filter((r) => r.status === 'fail').length;
|
|
@@ -6,10 +6,9 @@ export default class StaticHostBuildList extends BaseCommand {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
-
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
per_page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
9
|
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
12
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
13
|
profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
14
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|