@solidactions/cli 3.21.0 → 3.22.0
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 +3 -3
- package/dist/command-manifest.json +1 -1
- package/dist/commands/connection-list.js +1 -1
- package/dist/commands/crew-env-delete.js +2 -2
- package/dist/commands/crew-env-list.js +2 -2
- package/dist/commands/crew-env-push.js +5 -2
- package/dist/commands/crew-env-set.js +2 -2
- package/dist/commands/deploy.js +41 -26
- package/dist/commands/doc-pull.js +432 -88
- package/dist/commands/doc-push.js +54 -3
- package/dist/commands/doc-upload.js +5 -2
- package/dist/commands/env-delete.js +12 -5
- package/dist/commands/env-list.js +12 -7
- package/dist/commands/env-map.js +7 -5
- package/dist/commands/env-pull.js +5 -6
- package/dist/commands/env-push.js +10 -6
- package/dist/commands/env-reset.js +12 -8
- package/dist/commands/env-set.js +15 -11
- package/dist/commands/login.js +8 -7
- package/dist/commands/oauth-action-list.js +2 -2
- package/dist/commands/oauth-action-platforms.js +2 -2
- package/dist/commands/oauth-action-search.js +2 -2
- package/dist/commands/oauth-action-view.js +2 -2
- package/dist/commands/project-create.js +1 -1
- package/dist/commands/project-list.js +2 -2
- package/dist/commands/project-logs.js +7 -3
- package/dist/commands/project-view.js +26 -9
- package/dist/commands/pull.js +4 -2
- package/dist/commands/run-list.js +24 -3
- package/dist/commands/run-start.js +12 -9
- package/dist/commands/run-view.js +2 -2
- package/dist/commands/schedule-delete.js +5 -10
- package/dist/commands/schedule-list.js +5 -10
- package/dist/commands/schedule-set.js +39 -44
- package/dist/commands/schedule-state.js +12 -16
- package/dist/commands/state.js +3 -3
- package/dist/commands/webhook-list.js +12 -4
- package/dist/commands/webhook-secret.js +12 -4
- package/dist/commands/workflow-view.js +3 -3
- package/dist/commands/workspaces.js +53 -2
- package/dist/utils/api.js +35 -2
- package/dist/utils/crew.js +6 -1
- package/dist/utils/project-ref.js +91 -0
- package/package.json +2 -2
|
@@ -57,13 +57,13 @@ function printAmbiguity(error) {
|
|
|
57
57
|
}
|
|
58
58
|
console.error('Re-run with an exact slug.');
|
|
59
59
|
}
|
|
60
|
-
function printWorkflowViewError(error) {
|
|
60
|
+
function printWorkflowViewError(error, host) {
|
|
61
61
|
if (!error.response) {
|
|
62
62
|
console.error(chalk_1.default.red('Connection failed:'), display(error.message, 'Unknown network error.', 500));
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (error.response.status === 401) {
|
|
66
|
-
console.error(chalk_1.default.red(
|
|
66
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(host)));
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
// The GET workflow endpoint uses the v1 {code, message} convention;
|
|
@@ -102,7 +102,7 @@ async function workflowViewWithConfig(project, workflow, options, config) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
|
-
printWorkflowViewError(error);
|
|
105
|
+
printWorkflowViewError(error, config.host);
|
|
106
106
|
process.exit(1);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -11,7 +11,8 @@ const config_1 = require("../utils/config");
|
|
|
11
11
|
const config_write_target_1 = require("../utils/config-write-target");
|
|
12
12
|
const workspace_lookup_1 = require("../utils/workspace-lookup");
|
|
13
13
|
async function workspacesList() {
|
|
14
|
-
const
|
|
14
|
+
const resolved = (0, api_1.requireResolvedConfig)();
|
|
15
|
+
const config = resolved.config;
|
|
15
16
|
// Grouping keys are tenant ids (app#1214), so the org header and the
|
|
16
17
|
// same-name disambiguation both come from per-row tenant data, never
|
|
17
18
|
// from the key.
|
|
@@ -20,12 +21,21 @@ async function workspacesList() {
|
|
|
20
21
|
({ workspaces } = await (0, workspace_lookup_1.fetchWorkspaces)(config));
|
|
21
22
|
}
|
|
22
23
|
catch (error) {
|
|
23
|
-
|
|
24
|
+
if (error.response?.status === 401) {
|
|
25
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
26
|
+
}
|
|
27
|
+
else if (error.response) {
|
|
28
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
32
|
+
}
|
|
24
33
|
process.exit(1);
|
|
25
34
|
}
|
|
26
35
|
console.log(chalk_1.default.blue(`\nYour workspaces:\n`));
|
|
27
36
|
if (workspaces.length === 0) {
|
|
28
37
|
console.log(chalk_1.default.yellow('No workspaces found.'));
|
|
38
|
+
warnDanglingPin(config.workspace, config.workspaceId, resolved.sources.workspaceId, true);
|
|
29
39
|
return;
|
|
30
40
|
}
|
|
31
41
|
for (const group of (0, workspace_lookup_1.groupWorkspacesByOrg)(workspaces)) {
|
|
@@ -39,7 +49,48 @@ async function workspacesList() {
|
|
|
39
49
|
console.log(chalk_1.default.gray(` ID: ${ws.id}`));
|
|
40
50
|
}
|
|
41
51
|
}
|
|
52
|
+
// cli#113: a pin the list doesn't contain gets no "← current" — say so instead of looking normal.
|
|
53
|
+
if (config.workspaceId && !workspaces.some((ws) => ws.id === config.workspaceId)) {
|
|
54
|
+
warnDanglingPin(config.workspace, config.workspaceId, resolved.sources.workspaceId, false);
|
|
55
|
+
}
|
|
56
|
+
console.log('');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Warn about a pinned workspace the server's list does not contain (cli#113).
|
|
60
|
+
* Runs against an empty list too: losing access to every workspace is exactly
|
|
61
|
+
* the lost-access case, so the pin is evaluated rather than skipped. With
|
|
62
|
+
* nothing listed there is nothing to pick from, so the remedy says how to
|
|
63
|
+
* clear or change the pin instead of pointing at the list.
|
|
64
|
+
*/
|
|
65
|
+
function warnDanglingPin(workspace, workspaceId, workspaceIdSource, emptyList) {
|
|
66
|
+
if (!workspaceId)
|
|
67
|
+
return;
|
|
68
|
+
const label = workspace ? `${workspace} (${workspaceId})` : workspaceId;
|
|
69
|
+
const from = workspaceIdSource === 'env'
|
|
70
|
+
? '$SOLIDACTIONS_WORKSPACE_ID'
|
|
71
|
+
: workspaceIdSource === 'cli'
|
|
72
|
+
? 'the -w/--workspace-override flag'
|
|
73
|
+
: workspaceIdSource;
|
|
42
74
|
console.log('');
|
|
75
|
+
console.log(chalk_1.default.yellow(`warn: the active workspace ${label} (from ${from}) is not in this list — it may belong to another host, or you may no longer have access.`));
|
|
76
|
+
if (workspaceIdSource === 'env') {
|
|
77
|
+
// `workspace set` refuses while $SOLIDACTIONS_WORKSPACE_ID is set, list or no list.
|
|
78
|
+
console.log(chalk_1.default.yellow(`Unset $SOLIDACTIONS_WORKSPACE_ID, then select a workspace with \`solidactions workspace set <slug>\`${emptyList ? ' once `workspace list` shows one' : ''}.`));
|
|
79
|
+
}
|
|
80
|
+
else if (emptyList) {
|
|
81
|
+
// `workspace set` resolves an accessible workspace first, so it cannot
|
|
82
|
+
// clear or change a pin when the list is empty: name the action that
|
|
83
|
+
// applies to where this pin came from instead.
|
|
84
|
+
if (workspaceIdSource === 'cli') {
|
|
85
|
+
console.log(chalk_1.default.yellow('Re-run without -w/--workspace-override, then select a workspace with `solidactions workspace set <slug>` once `workspace list` shows one.'));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.log(chalk_1.default.yellow(`Remove the workspace pin (workspaceId and related keys) from ${from}, then select a workspace with \`solidactions workspace set <slug>\` once \`workspace list\` shows one.`));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log(chalk_1.default.yellow('Pick one from the list with `solidactions workspace set <slug> --local` (or --global).'));
|
|
93
|
+
}
|
|
43
94
|
}
|
|
44
95
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
45
96
|
function looksLikeUuid(input) {
|
package/dist/utils/api.js
CHANGED
|
@@ -15,8 +15,10 @@ exports.describeProjectEnvironments = describeProjectEnvironments;
|
|
|
15
15
|
exports.formatValidationError = formatValidationError;
|
|
16
16
|
exports.requireResolvedConfig = requireResolvedConfig;
|
|
17
17
|
exports.requireConfig = requireConfig;
|
|
18
|
+
exports.displayHost = displayHost;
|
|
18
19
|
exports.authFailureMessage = authFailureMessage;
|
|
19
20
|
exports.formatApiFailure = formatApiFailure;
|
|
21
|
+
exports.authFailedLine = authFailedLine;
|
|
20
22
|
exports.ensureWorkspaceSelected = ensureWorkspaceSelected;
|
|
21
23
|
exports.buildWorkspaceConfirmPrompt = buildWorkspaceConfirmPrompt;
|
|
22
24
|
exports.applyWorkspaceGuard = applyWorkspaceGuard;
|
|
@@ -28,6 +30,7 @@ const prompts_1 = __importDefault(require("prompts"));
|
|
|
28
30
|
const config_1 = require("./config");
|
|
29
31
|
const workspace_lookup_1 = require("./workspace-lookup");
|
|
30
32
|
const mutating_commands_1 = require("./mutating-commands");
|
|
33
|
+
const project_ref_1 = require("./project-ref");
|
|
31
34
|
const workspace_guard_1 = require("./workspace-guard");
|
|
32
35
|
// Backend (solidactions-app PR #128) returns: "Project '<slug>' not found in your active workspace '<workspace-slug>'."
|
|
33
36
|
// We require the literal single-quotes around the slug so plausible future error messages
|
|
@@ -204,7 +207,13 @@ async function lookupProjectFamilyEnvironments(config, projectName) {
|
|
|
204
207
|
try {
|
|
205
208
|
const res = await axios_1.default.get(`${config.host}/api/v1/projects`, { headers: getApiHeaders(config) });
|
|
206
209
|
const rows = res.data?.data ?? res.data ?? [];
|
|
207
|
-
|
|
210
|
+
// The same rungs `run list` retries with (cli#161): an ambiguous
|
|
211
|
+
// case-insensitive match yields no hint rather than a guess.
|
|
212
|
+
const match = (0, project_ref_1.matchProjectRungs)(rows, projectName);
|
|
213
|
+
if (match.ambiguous.length > 0) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const hit = match.project;
|
|
208
217
|
const environments = hit?.environments;
|
|
209
218
|
if (!environments?.length) {
|
|
210
219
|
return null;
|
|
@@ -291,6 +300,26 @@ function requireResolvedConfig() {
|
|
|
291
300
|
function requireConfig() {
|
|
292
301
|
return requireResolvedConfig().config;
|
|
293
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Host as shown in user-facing output: a URL with any userinfo stripped
|
|
305
|
+
* (credentials must never reach the terminal), otherwise shown as
|
|
306
|
+
* configured. Shared by every authentication-failure message (cli#156).
|
|
307
|
+
*/
|
|
308
|
+
function displayHost(host) {
|
|
309
|
+
let shown = host;
|
|
310
|
+
try {
|
|
311
|
+
const url = new URL(host);
|
|
312
|
+
if (url.username || url.password) {
|
|
313
|
+
url.username = '';
|
|
314
|
+
url.password = '';
|
|
315
|
+
shown = url.toString().replace(/\/$/, '');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
// Not a URL: show it as configured.
|
|
320
|
+
}
|
|
321
|
+
return shown;
|
|
322
|
+
}
|
|
294
323
|
/**
|
|
295
324
|
* Contextual 401 message — names the host being called and where the (now
|
|
296
325
|
* apparently invalid/expired) API key came from, instead of a bare
|
|
@@ -298,7 +327,7 @@ function requireConfig() {
|
|
|
298
327
|
*/
|
|
299
328
|
function authFailureMessage(config, sources) {
|
|
300
329
|
const keySource = sources?.apiKey ?? 'config';
|
|
301
|
-
return `Authentication failed against ${config.host} (key from ${keySource}). Run \`solidactions login --global\` to re-configure.`;
|
|
330
|
+
return `Authentication failed against ${displayHost(config.host)} (key from ${keySource}). Run \`solidactions login --global\` to re-configure.`;
|
|
302
331
|
}
|
|
303
332
|
/**
|
|
304
333
|
* One line for a failed API response: the server's `message` when it sent one, else the
|
|
@@ -313,6 +342,10 @@ function formatApiFailure(status, data) {
|
|
|
313
342
|
? `Failed: ${status} ${message.trim()}`
|
|
314
343
|
: `Failed: ${status}`;
|
|
315
344
|
}
|
|
345
|
+
/** The one-line 401 every command prints: names the host that refused the key (cli#156), never its userinfo. */
|
|
346
|
+
function authFailedLine(host) {
|
|
347
|
+
return `Authentication failed against ${displayHost(host)}. Run "solidactions login --global" to re-configure.`;
|
|
348
|
+
}
|
|
316
349
|
async function ensureWorkspaceSelected(config, dependencies = {}) {
|
|
317
350
|
if (config.workspaceId) {
|
|
318
351
|
return config;
|
package/dist/utils/crew.js
CHANGED
|
@@ -58,7 +58,12 @@ async function resolveCrewId(config, input) {
|
|
|
58
58
|
crews = await fetchCrews(config);
|
|
59
59
|
}
|
|
60
60
|
catch (error) {
|
|
61
|
-
|
|
61
|
+
if (error.response?.status === 401) {
|
|
62
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.error(chalk_1.default.red('Failed to list crews:'), error.response?.data?.message || error.message);
|
|
66
|
+
}
|
|
62
67
|
process.exit(1);
|
|
63
68
|
}
|
|
64
69
|
const result = matchCrewByName(input, crews);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getProjectBySlugOrCanonical = getProjectBySlugOrCanonical;
|
|
7
|
+
exports.projectSlugCandidates = projectSlugCandidates;
|
|
8
|
+
exports.resolveProjectSlug = resolveProjectSlug;
|
|
9
|
+
exports.matchProjectRungs = matchProjectRungs;
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
const api_1 = require("./api");
|
|
12
|
+
const slug_1 = require("./slug");
|
|
13
|
+
/**
|
|
14
|
+
* GET a project by the name as typed, then — on a 404 only — by its canonical slug when
|
|
15
|
+
* that differs (cli#102). The server stores `Issue970-QX` as `issue970-qx`; without the
|
|
16
|
+
* retry a redeploy 404s, tries to create, and collides with the slug that already exists.
|
|
17
|
+
* The typed spelling goes first so a legacy slug the slugifier would rewrite still resolves.
|
|
18
|
+
*/
|
|
19
|
+
async function getProjectBySlugOrCanonical(config, typed, canonical) {
|
|
20
|
+
try {
|
|
21
|
+
return await axios_1.default.get(`${config.host}/api/v1/projects/${typed}`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error.response?.status !== 404 || canonical === '' || canonical === typed) {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
return axios_1.default.get(`${config.host}/api/v1/projects/${canonical}`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** The slug a command used before cli#161, then the canonical slug — no duplicates, no empty canonical. */
|
|
31
|
+
function projectSlugCandidates(typed, environment) {
|
|
32
|
+
const today = environment === undefined || environment === 'production' ? typed : `${typed}-${environment}`;
|
|
33
|
+
const out = [today];
|
|
34
|
+
if ((0, slug_1.slugifyName)(typed) !== '') {
|
|
35
|
+
const canonical = (0, slug_1.buildProjectSlug)(typed, environment ?? 'production');
|
|
36
|
+
if (!out.includes(canonical))
|
|
37
|
+
out.push(canonical);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolve a user-typed project to the slug the server stores (cli#161): try each candidate, move on only
|
|
43
|
+
* on a 404, and return the server's slug. Any other error propagates to the command's own handling. When
|
|
44
|
+
* every candidate 404s, return the first so the command's existing not-found message runs unchanged.
|
|
45
|
+
*/
|
|
46
|
+
async function resolveProjectSlug(config, typed, environment) {
|
|
47
|
+
const candidates = projectSlugCandidates(typed, environment);
|
|
48
|
+
for (const candidate of candidates) {
|
|
49
|
+
try {
|
|
50
|
+
// Unencoded, as the commands put the slug into their own URLs (PM ruling 6).
|
|
51
|
+
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${candidate}`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
52
|
+
return (typeof response.data?.slug === 'string' && response.data.slug) || candidate;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
// PM ruling 3: a token may be allowed the command's own route but not the project read —
|
|
56
|
+
// a 403 here is not a failure; let the command's own request decide.
|
|
57
|
+
if (error.response?.status === 403)
|
|
58
|
+
return candidates[0];
|
|
59
|
+
if (error.response?.status !== 404)
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return candidates[0];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Match a typed project against `GET /api/v1/projects` rows in rungs, stopping
|
|
67
|
+
* at the first rung with a hit: exact name, exact slug, canonical slug, then a
|
|
68
|
+
* case-insensitive name (PM ruling 4: more than one hit there is ambiguous).
|
|
69
|
+
* Shared by `run list`'s retry and `lookupProjectFamilyEnvironments`.
|
|
70
|
+
*/
|
|
71
|
+
function matchProjectRungs(projects, typed) {
|
|
72
|
+
if (!Array.isArray(projects))
|
|
73
|
+
return { project: null, ambiguous: [] };
|
|
74
|
+
const byName = projects.find((p) => p?.name === typed);
|
|
75
|
+
if (byName)
|
|
76
|
+
return { project: byName, ambiguous: [] };
|
|
77
|
+
const bySlug = projects.find((p) => p?.slug === typed);
|
|
78
|
+
if (bySlug)
|
|
79
|
+
return { project: bySlug, ambiguous: [] };
|
|
80
|
+
const canonical = (0, slug_1.slugifyName)(typed);
|
|
81
|
+
if (canonical !== '') {
|
|
82
|
+
const byCanonical = projects.find((p) => p?.slug === canonical);
|
|
83
|
+
if (byCanonical)
|
|
84
|
+
return { project: byCanonical, ambiguous: [] };
|
|
85
|
+
}
|
|
86
|
+
const lowered = typed.toLowerCase();
|
|
87
|
+
const ci = projects.filter((p) => typeof p?.name === 'string' && p.name.toLowerCase() === lowered);
|
|
88
|
+
if (ci.length > 1)
|
|
89
|
+
return { project: null, ambiguous: ci };
|
|
90
|
+
return { project: ci[0] ?? null, ambiguous: [] };
|
|
91
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidactions/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.0",
|
|
4
4
|
"description": "SolidActions CLI - Deploy and manage workflow automation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -62,6 +62,6 @@
|
|
|
62
62
|
"@types/prompts": "^2.4.9",
|
|
63
63
|
"@types/tar": "^6.1.13",
|
|
64
64
|
"typescript": "^5.0.0",
|
|
65
|
-
"vitest": "^4.1.
|
|
65
|
+
"vitest": "^4.1.11"
|
|
66
66
|
}
|
|
67
67
|
}
|