@solidactions/cli 3.21.0 → 3.23.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 +7 -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-map-database.js +4 -1
- package/dist/commands/crew-env-push.js +5 -2
- package/dist/commands/crew-env-set.js +2 -2
- package/dist/commands/database-push.js +2 -1
- package/dist/commands/deploy.js +44 -28
- package/dist/commands/device-login.js +3 -2
- package/dist/commands/doc-pull.js +628 -90
- 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 +84 -20
- 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/skill-exec.js +4 -1
- package/dist/commands/skill-run.js +4 -1
- 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 +20 -4
- package/dist/commands/workspaces.js +53 -2
- package/dist/index.js +2 -1
- package/dist/utils/api.js +18 -4
- package/dist/utils/config.js +5 -4
- package/dist/utils/crew.js +6 -1
- package/dist/utils/host-display.js +47 -0
- package/dist/utils/project-ref.js +91 -0
- package/dist/utils/workspace-lookup.js +11 -1
- package/package.json +2 -2
|
@@ -38,10 +38,10 @@ async function oauthActionList(platform, options) {
|
|
|
38
38
|
console.error(chalk_1.default.red(`Unknown platform "${platform}". Run \`solidactions oauth-action platforms\` to see available platforms.`));
|
|
39
39
|
}
|
|
40
40
|
else if (error.response?.status === 401) {
|
|
41
|
-
console.error(chalk_1.default.red(
|
|
41
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
42
42
|
}
|
|
43
43
|
else if (error.response) {
|
|
44
|
-
console.error(chalk_1.default.red(
|
|
44
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
47
|
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
@@ -28,10 +28,10 @@ async function oauthActionPlatforms(options) {
|
|
|
28
28
|
}
|
|
29
29
|
catch (error) {
|
|
30
30
|
if (error.response?.status === 401) {
|
|
31
|
-
console.error(chalk_1.default.red(
|
|
31
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
32
32
|
}
|
|
33
33
|
else if (error.response) {
|
|
34
|
-
console.error(chalk_1.default.red(
|
|
34
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
@@ -49,10 +49,10 @@ async function oauthActionSearch(platform, query, options) {
|
|
|
49
49
|
console.error(chalk_1.default.red(`Unknown platform "${platform}". Run \`solidactions oauth-action platforms\` to see available platforms.`));
|
|
50
50
|
}
|
|
51
51
|
else if (error.response?.status === 401) {
|
|
52
|
-
console.error(chalk_1.default.red(
|
|
52
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
53
53
|
}
|
|
54
54
|
else if (error.response) {
|
|
55
|
-
console.error(chalk_1.default.red(
|
|
55
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
58
|
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
@@ -26,10 +26,10 @@ async function oauthActionView(platform, actionId, options) {
|
|
|
26
26
|
console.error(chalk_1.default.red(`Action not found: ${platform}/${actionId}`));
|
|
27
27
|
}
|
|
28
28
|
else if (error.response?.status === 401) {
|
|
29
|
-
console.error(chalk_1.default.red(
|
|
29
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
30
30
|
}
|
|
31
31
|
else if (error.response) {
|
|
32
|
-
console.error(chalk_1.default.red(
|
|
32
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
@@ -45,7 +45,7 @@ async function projectCreateWithConfig(name, options, config) {
|
|
|
45
45
|
catch (error) {
|
|
46
46
|
if (error.response) {
|
|
47
47
|
if (error.response.status === 401) {
|
|
48
|
-
console.error(chalk_1.default.red(
|
|
48
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
console.error(chalk_1.default.red('Failed to create project:'), error.response.data?.message || error.message);
|
|
@@ -68,10 +68,10 @@ async function projectList(options = {}) {
|
|
|
68
68
|
catch (error) {
|
|
69
69
|
if (error.response) {
|
|
70
70
|
if (error.response.status === 401) {
|
|
71
|
-
console.error(chalk_1.default.red(
|
|
71
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
console.error(chalk_1.default.red(
|
|
74
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
@@ -9,6 +9,7 @@ exports.logsBuild = logsBuild;
|
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
11
|
const api_1 = require("../utils/api");
|
|
12
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
12
13
|
function buildBuildLogUrl(host, projectName, environment) {
|
|
13
14
|
if (environment) {
|
|
14
15
|
return `${host}/api/v1/projects/resolve/build-log`;
|
|
@@ -27,8 +28,11 @@ function buildBuildLogRequest(host, projectName, environment) {
|
|
|
27
28
|
async function logsBuild(projectName, environment) {
|
|
28
29
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
29
30
|
console.log(chalk_1.default.blue(`Fetching build logs for project "${projectName}"...`));
|
|
30
|
-
const { url, params } = buildBuildLogRequest(config.host, projectName, environment);
|
|
31
31
|
try {
|
|
32
|
+
// Only the path without -e resolves here; the -e path already asks
|
|
33
|
+
// the server to resolve the name.
|
|
34
|
+
const name = environment === undefined ? await (0, project_ref_1.resolveProjectSlug)(config, projectName) : projectName;
|
|
35
|
+
const { url, params } = buildBuildLogRequest(config.host, name, environment);
|
|
32
36
|
const response = await axios_1.default.get(url, {
|
|
33
37
|
headers: (0, api_1.getApiHeaders)(config),
|
|
34
38
|
params,
|
|
@@ -45,7 +49,7 @@ async function logsBuild(projectName, environment) {
|
|
|
45
49
|
catch (error) {
|
|
46
50
|
if (error.response) {
|
|
47
51
|
if (error.response.status === 401) {
|
|
48
|
-
console.error(chalk_1.default.red(
|
|
52
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
49
53
|
}
|
|
50
54
|
else if (error.response.status === 404) {
|
|
51
55
|
console.error(chalk_1.default.red(error.response.data?.message ?? `Project "${projectName}" not found.`));
|
|
@@ -55,7 +59,7 @@ async function logsBuild(projectName, environment) {
|
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
else {
|
|
58
|
-
console.error(chalk_1.default.red(
|
|
62
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
else {
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.projectViewJsonProjection = projectViewJsonProjection;
|
|
7
7
|
exports.quoteCommandArg = quoteCommandArg;
|
|
8
|
+
exports.isUsableProjectRef = isUsableProjectRef;
|
|
8
9
|
exports.projectSlugForView = projectSlugForView;
|
|
9
10
|
exports.formatDeploymentRevision = formatDeploymentRevision;
|
|
10
11
|
exports.formatProjectView = formatProjectView;
|
|
@@ -13,6 +14,7 @@ exports.projectView = projectView;
|
|
|
13
14
|
const axios_1 = __importDefault(require("axios"));
|
|
14
15
|
const chalk_1 = __importDefault(require("chalk"));
|
|
15
16
|
const api_1 = require("../utils/api");
|
|
17
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
16
18
|
const slug_1 = require("../utils/slug");
|
|
17
19
|
const source_provenance_1 = require("../utils/source-provenance");
|
|
18
20
|
/**
|
|
@@ -64,6 +66,24 @@ function projectViewJsonProjection(project) {
|
|
|
64
66
|
function quoteCommandArg(arg) {
|
|
65
67
|
return /^[A-Za-z0-9._/-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, "'\\''")}'`;
|
|
66
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Fail fast on a bad project reference before any HTTP (cli#161 kept
|
|
71
|
+
* resolution; validation still refuses locally). Returns true when the
|
|
72
|
+
* reference is usable. On a bad reference prints the long-standing message
|
|
73
|
+
* to stderr and exits 1; the false return only matters when process.exit is
|
|
74
|
+
* a test double, so the caller still stops.
|
|
75
|
+
*/
|
|
76
|
+
function isUsableProjectRef(project, environment) {
|
|
77
|
+
try {
|
|
78
|
+
projectSlugForView(project, environment);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error(chalk_1.default.red(error.message));
|
|
83
|
+
process.exit(1);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
67
87
|
function projectSlugForView(project, environment) {
|
|
68
88
|
if (environment === undefined) {
|
|
69
89
|
return project;
|
|
@@ -151,16 +171,13 @@ function formatProjectView(project) {
|
|
|
151
171
|
}
|
|
152
172
|
async function projectViewWithConfig(project, options, config, writeLine = console.log) {
|
|
153
173
|
const environment = options.env ?? 'dev';
|
|
154
|
-
let slug;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
catch (error) {
|
|
159
|
-
console.error(chalk_1.default.red(error.message));
|
|
160
|
-
process.exit(1);
|
|
174
|
+
let slug = '';
|
|
175
|
+
// Local input validation first (cli#161 kept resolution; validation
|
|
176
|
+
// still fails fast before any HTTP).
|
|
177
|
+
if (!isUsableProjectRef(project, environment))
|
|
161
178
|
return;
|
|
162
|
-
}
|
|
163
179
|
try {
|
|
180
|
+
slug = await (0, project_ref_1.resolveProjectSlug)(config, project, environment);
|
|
164
181
|
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${encodeURIComponent(slug)}?include=deployment`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
165
182
|
if (options.json) {
|
|
166
183
|
writeLine(JSON.stringify(projectViewJsonProjection(response.data), null, 2));
|
|
@@ -173,7 +190,7 @@ async function projectViewWithConfig(project, options, config, writeLine = conso
|
|
|
173
190
|
}
|
|
174
191
|
catch (error) {
|
|
175
192
|
if (error.response?.status === 401) {
|
|
176
|
-
console.error(chalk_1.default.red(
|
|
193
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
177
194
|
}
|
|
178
195
|
else if (error.response?.status === 404) {
|
|
179
196
|
const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, project);
|
package/dist/commands/pull.js
CHANGED
|
@@ -14,6 +14,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
14
14
|
const chalk_1 = __importDefault(require("chalk"));
|
|
15
15
|
const prompts_1 = __importDefault(require("prompts"));
|
|
16
16
|
const api_1 = require("../utils/api");
|
|
17
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
17
18
|
async function pull(projectName, destPath, options = {}) {
|
|
18
19
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
19
20
|
const destination = destPath ? path_1.default.resolve(destPath) : process.cwd();
|
|
@@ -37,7 +38,8 @@ async function pull(projectName, destPath, options = {}) {
|
|
|
37
38
|
}
|
|
38
39
|
console.log(chalk_1.default.blue(`Pulling project "${projectName}"...`));
|
|
39
40
|
try {
|
|
40
|
-
const
|
|
41
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName);
|
|
42
|
+
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/source`, {
|
|
41
43
|
headers: { ...(0, api_1.getApiHeaders)(config), 'Accept': 'application/octet-stream' },
|
|
42
44
|
responseType: 'arraybuffer',
|
|
43
45
|
});
|
|
@@ -70,7 +72,7 @@ async function pull(projectName, destPath, options = {}) {
|
|
|
70
72
|
console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
|
|
71
73
|
}
|
|
72
74
|
else if (error.response.status === 401) {
|
|
73
|
-
console.error(chalk_1.default.red(
|
|
75
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
74
76
|
}
|
|
75
77
|
else {
|
|
76
78
|
console.error(chalk_1.default.red(`Failed: ${error.response.status}`));
|
|
@@ -13,6 +13,7 @@ exports.displayDetailedList = displayDetailedList;
|
|
|
13
13
|
const axios_1 = __importDefault(require("axios"));
|
|
14
14
|
const chalk_1 = __importDefault(require("chalk"));
|
|
15
15
|
const api_1 = require("../utils/api");
|
|
16
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
16
17
|
const run_status_1 = require("../utils/run-status");
|
|
17
18
|
const table_1 = require("../utils/table");
|
|
18
19
|
const source_provenance_1 = require("../utils/source-provenance");
|
|
@@ -49,10 +50,30 @@ async function runs(projectName, options = {}) {
|
|
|
49
50
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
50
51
|
try {
|
|
51
52
|
const params = buildRunListParams(projectName, options);
|
|
52
|
-
|
|
53
|
+
let response = await axios_1.default.get(`${config.host}/api/v1/runs`, {
|
|
53
54
|
headers: (0, api_1.getApiHeaders)(config),
|
|
54
55
|
params,
|
|
55
56
|
});
|
|
57
|
+
// cli#161: the filter text may be a name whose slug differs (or the
|
|
58
|
+
// other way round) — look the project up once and retry with its
|
|
59
|
+
// exact name (PM ruling 4: an ambiguous match refuses instead).
|
|
60
|
+
if (response.data?.error === 'project_not_found' && projectName) {
|
|
61
|
+
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
62
|
+
const rows = listResponse.data?.data ?? listResponse.data ?? [];
|
|
63
|
+
const match = (0, project_ref_1.matchProjectRungs)(rows, projectName);
|
|
64
|
+
if (match.ambiguous.length > 0) {
|
|
65
|
+
const names = match.ambiguous.map((p) => `${p.name} (${p.slug})`).join(', ');
|
|
66
|
+
console.error(chalk_1.default.red(`"${projectName}" matches more than one project: ${names} — re-run with the exact name or slug.`));
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const hit = match.project;
|
|
70
|
+
if (hit && typeof hit.name === 'string' && hit.name !== projectName) {
|
|
71
|
+
response = await axios_1.default.get(`${config.host}/api/v1/runs`, {
|
|
72
|
+
headers: (0, api_1.getApiHeaders)(config),
|
|
73
|
+
params: { ...params, project: hit.name },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
56
77
|
const runsList = response.data.data || response.data;
|
|
57
78
|
// Check server-side error fields FIRST (project_not_found comes back as 200 with data:[])
|
|
58
79
|
const serverError = response.data.error;
|
|
@@ -90,10 +111,10 @@ async function runs(projectName, options = {}) {
|
|
|
90
111
|
console.error(chalk_1.default.yellow(`Pass -e <env> to disambiguate, e.g.: solidactions run list ${projectName} -e dev`));
|
|
91
112
|
}
|
|
92
113
|
else if (error.response.status === 401) {
|
|
93
|
-
console.error(chalk_1.default.red(
|
|
114
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
94
115
|
}
|
|
95
116
|
else {
|
|
96
|
-
console.error(chalk_1.default.red(
|
|
117
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
97
118
|
}
|
|
98
119
|
}
|
|
99
120
|
else {
|
|
@@ -7,13 +7,11 @@ exports.run = run;
|
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const api_1 = require("../utils/api");
|
|
10
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
10
11
|
const run_status_1 = require("../utils/run-status");
|
|
11
12
|
async function run(projectName, workflowName, options) {
|
|
12
13
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
13
14
|
const environment = options.env || 'dev';
|
|
14
|
-
const projectSlug = environment === 'production'
|
|
15
|
-
? projectName
|
|
16
|
-
: `${projectName}-${environment}`;
|
|
17
15
|
console.log(chalk_1.default.blue(`Running workflow "${workflowName}" in project "${projectName}" (${environment})...`));
|
|
18
16
|
let inputData = {};
|
|
19
17
|
if (options.input) {
|
|
@@ -26,6 +24,7 @@ async function run(projectName, workflowName, options) {
|
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
try {
|
|
27
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
|
|
29
28
|
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/workflows/${workflowName}/trigger`, { input: inputData }, {
|
|
30
29
|
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
31
30
|
});
|
|
@@ -70,22 +69,26 @@ async function run(projectName, workflowName, options) {
|
|
|
70
69
|
catch (error) {
|
|
71
70
|
if (error.response) {
|
|
72
71
|
if (error.response.status === 401) {
|
|
73
|
-
console.error(chalk_1.default.red(
|
|
72
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
74
73
|
}
|
|
75
74
|
else if (error.response.status === 404) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
// Claim the environment is missing only when the family
|
|
76
|
+
// genuinely lacks it (project view's pattern): otherwise the
|
|
77
|
+
// 404 names a missing workflow, not a missing environment.
|
|
78
|
+
const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
|
|
79
|
+
const envs = family?.environments ?? [];
|
|
80
|
+
if (envs.length > 0 && !envs.includes(environment)) {
|
|
81
|
+
console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}). Pass -e <env> to target a different environment.`));
|
|
79
82
|
}
|
|
80
83
|
else {
|
|
81
|
-
console.error(chalk_1.default.red(
|
|
84
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
else if (error.response.status === 422) {
|
|
85
88
|
console.error(chalk_1.default.red('Validation error:'), error.response.data.message);
|
|
86
89
|
}
|
|
87
90
|
else {
|
|
88
|
-
console.error(chalk_1.default.red(
|
|
91
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
else {
|
|
@@ -119,13 +119,13 @@ async function runView(runId, options) {
|
|
|
119
119
|
catch (error) {
|
|
120
120
|
if (error.response) {
|
|
121
121
|
if (error.response.status === 401) {
|
|
122
|
-
console.error(chalk_1.default.red(
|
|
122
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
123
123
|
}
|
|
124
124
|
else if (error.response.status === 404) {
|
|
125
125
|
console.error(chalk_1.default.red('Run not found.'));
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
|
-
console.error(chalk_1.default.red(
|
|
128
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
else {
|
|
@@ -8,20 +8,15 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const prompts_1 = __importDefault(require("prompts"));
|
|
10
10
|
const api_1 = require("../utils/api");
|
|
11
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
11
12
|
const project_view_1 = require("./project-view");
|
|
12
13
|
async function scheduleDelete(projectName, scheduleId, options = {}) {
|
|
13
14
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
projectSlug = (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
console.error(chalk_1.default.red(error.message));
|
|
20
|
-
process.exit(1);
|
|
15
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
21
16
|
return;
|
|
22
|
-
}
|
|
23
17
|
console.log(chalk_1.default.blue(`Deleting schedule ${scheduleId} from project "${projectName}"...`));
|
|
24
18
|
try {
|
|
19
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
25
20
|
// First, get the schedule details for confirmation
|
|
26
21
|
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
27
22
|
headers: (0, api_1.getApiHeaders)(config),
|
|
@@ -56,13 +51,13 @@ async function scheduleDelete(projectName, scheduleId, options = {}) {
|
|
|
56
51
|
catch (error) {
|
|
57
52
|
if (error.response) {
|
|
58
53
|
if (error.response.status === 401) {
|
|
59
|
-
console.error(chalk_1.default.red(
|
|
54
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
60
55
|
}
|
|
61
56
|
else if (error.response.status === 404) {
|
|
62
57
|
console.error(chalk_1.default.red(`Project "${projectName}" or schedule ${scheduleId} not found.`));
|
|
63
58
|
}
|
|
64
59
|
else {
|
|
65
|
-
console.error(chalk_1.default.red(
|
|
60
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
66
61
|
}
|
|
67
62
|
}
|
|
68
63
|
else {
|
|
@@ -8,6 +8,7 @@ exports.scheduleList = scheduleList;
|
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const api_1 = require("../utils/api");
|
|
11
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
11
12
|
const project_view_1 = require("./project-view");
|
|
12
13
|
function formatScheduleState(schedule) {
|
|
13
14
|
const effective = schedule.enabled ? 'yes' : 'no';
|
|
@@ -23,17 +24,11 @@ function formatScheduleState(schedule) {
|
|
|
23
24
|
}
|
|
24
25
|
async function scheduleList(projectName, options = {}) {
|
|
25
26
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
projectSlug = (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
console.error(chalk_1.default.red(error.message));
|
|
32
|
-
process.exit(1);
|
|
27
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
33
28
|
return;
|
|
34
|
-
}
|
|
35
29
|
console.log(chalk_1.default.blue(`Schedules for project "${projectName}":`));
|
|
36
30
|
try {
|
|
31
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
37
32
|
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
38
33
|
headers: (0, api_1.getApiHeaders)(config),
|
|
39
34
|
});
|
|
@@ -67,13 +62,13 @@ async function scheduleList(projectName, options = {}) {
|
|
|
67
62
|
catch (error) {
|
|
68
63
|
if (error.response) {
|
|
69
64
|
if (error.response.status === 401) {
|
|
70
|
-
console.error(chalk_1.default.red(
|
|
65
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
71
66
|
}
|
|
72
67
|
else if (error.response.status === 404) {
|
|
73
68
|
console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
|
|
74
69
|
}
|
|
75
70
|
else {
|
|
76
|
-
console.error(chalk_1.default.red(
|
|
71
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
77
72
|
}
|
|
78
73
|
}
|
|
79
74
|
else {
|
|
@@ -12,6 +12,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
13
|
const prompts_1 = __importDefault(require("prompts"));
|
|
14
14
|
const api_1 = require("../utils/api");
|
|
15
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
15
16
|
const project_view_1 = require("./project-view");
|
|
16
17
|
function buildSchedulePayload(cron, options, inputData) {
|
|
17
18
|
const payload = { cron };
|
|
@@ -46,15 +47,8 @@ exports.EXISTING_SCHEDULE_CHOICES = [
|
|
|
46
47
|
];
|
|
47
48
|
async function scheduleSet(projectName, cron, options) {
|
|
48
49
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
projectSlug = (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
console.error(chalk_1.default.red(error.message));
|
|
55
|
-
process.exit(1);
|
|
50
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
56
51
|
return;
|
|
57
|
-
}
|
|
58
52
|
// Parse input JSON if provided
|
|
59
53
|
let inputData;
|
|
60
54
|
if (options.input) {
|
|
@@ -66,43 +60,44 @@ async function scheduleSet(projectName, cron, options) {
|
|
|
66
60
|
process.exit(1);
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log(chalk_1.default.yellow(`"${workflowName}" already has a schedule: ${existing.cron_expression}`));
|
|
85
|
-
const confirm = await (0, prompts_1.default)({
|
|
86
|
-
type: 'select',
|
|
87
|
-
name: 'action',
|
|
88
|
-
message: 'What would you like to do?',
|
|
89
|
-
choices: exports.EXISTING_SCHEDULE_CHOICES,
|
|
63
|
+
console.log(chalk_1.default.blue(`Setting schedule for project "${projectName}"...`));
|
|
64
|
+
try {
|
|
65
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
66
|
+
// Check for existing schedule on the same workflow
|
|
67
|
+
if (!options.yes) {
|
|
68
|
+
try {
|
|
69
|
+
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
|
|
70
|
+
headers: (0, api_1.getApiHeaders)(config),
|
|
71
|
+
});
|
|
72
|
+
const schedules = listResponse.data.data || listResponse.data || [];
|
|
73
|
+
const existing = schedules.find((s) => {
|
|
74
|
+
if (options.workflow) {
|
|
75
|
+
return s.workflow_name === options.workflow || s.workflow_slug === options.workflow;
|
|
76
|
+
}
|
|
77
|
+
return true; // No workflow specified — any existing schedule is a match
|
|
90
78
|
});
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
if (existing) {
|
|
80
|
+
const workflowName = existing.workflow_name || existing.workflow_slug || 'unknown';
|
|
81
|
+
console.log(chalk_1.default.yellow(`"${workflowName}" already has a schedule: ${existing.cron_expression}`));
|
|
82
|
+
const confirm = await (0, prompts_1.default)({
|
|
83
|
+
type: 'select',
|
|
84
|
+
name: 'action',
|
|
85
|
+
message: 'What would you like to do?',
|
|
86
|
+
choices: exports.EXISTING_SCHEDULE_CHOICES,
|
|
87
|
+
});
|
|
88
|
+
if (confirm.action === 'cancel' || confirm.action === undefined) {
|
|
89
|
+
console.log(chalk_1.default.gray('Cancelled.'));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// The API owns the one-schedule-per-workflow invariant and
|
|
93
|
+
// updates the existing row. Do not delete first: deletion
|
|
94
|
+
// loses YAML provenance and any persistent override state.
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// If we can't check, proceed anyway
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
catch {
|
|
101
|
-
// If we can't check, proceed anyway
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
console.log(chalk_1.default.blue(`Setting schedule for project "${projectName}"...`));
|
|
105
|
-
try {
|
|
106
101
|
const payload = buildSchedulePayload(cron, options, inputData);
|
|
107
102
|
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/schedules`, payload, {
|
|
108
103
|
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
@@ -135,16 +130,16 @@ async function scheduleSet(projectName, cron, options) {
|
|
|
135
130
|
catch (error) {
|
|
136
131
|
if (error.response) {
|
|
137
132
|
if (error.response.status === 401) {
|
|
138
|
-
console.error(chalk_1.default.red(
|
|
133
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
139
134
|
}
|
|
140
135
|
else if (error.response.status === 404) {
|
|
141
136
|
console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
|
|
142
137
|
}
|
|
143
138
|
else if (error.response.status === 422) {
|
|
144
|
-
console.error(chalk_1.default.red('Validation error:'),
|
|
139
|
+
console.error(chalk_1.default.red('Validation error:'), (0, api_1.formatValidationError)(error.response.data));
|
|
145
140
|
}
|
|
146
141
|
else {
|
|
147
|
-
console.error(chalk_1.default.red(
|
|
142
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
148
143
|
}
|
|
149
144
|
}
|
|
150
145
|
else {
|
|
@@ -9,11 +9,12 @@ exports.scheduleReset = scheduleReset;
|
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
11
|
const api_1 = require("../utils/api");
|
|
12
|
+
const project_ref_1 = require("../utils/project-ref");
|
|
12
13
|
const project_view_1 = require("./project-view");
|
|
13
|
-
function renderScheduleStateError(error, projectName, scheduleId) {
|
|
14
|
+
function renderScheduleStateError(error, projectName, scheduleId, host) {
|
|
14
15
|
if (error.response) {
|
|
15
16
|
if (error.response.status === 401) {
|
|
16
|
-
console.error(chalk_1.default.red(
|
|
17
|
+
console.error(chalk_1.default.red((0, api_1.authFailedLine)(host)));
|
|
17
18
|
}
|
|
18
19
|
else if (error.response.status === 404) {
|
|
19
20
|
console.error(chalk_1.default.red(error.response.data?.message ?? `Project "${projectName}" or schedule ${scheduleId} not found.`));
|
|
@@ -22,7 +23,7 @@ function renderScheduleStateError(error, projectName, scheduleId) {
|
|
|
22
23
|
console.error(chalk_1.default.red(error.response.data?.message ?? 'Validation error.'));
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
|
-
console.error(chalk_1.default.red(
|
|
26
|
+
console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
@@ -30,26 +31,19 @@ function renderScheduleStateError(error, projectName, scheduleId) {
|
|
|
30
31
|
}
|
|
31
32
|
process.exit(1);
|
|
32
33
|
}
|
|
33
|
-
function resolveProjectSlug(projectName, options) {
|
|
34
|
-
try {
|
|
35
|
-
return (0, project_view_1.projectSlugForView)(projectName, options.env);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error(chalk_1.default.red(error.message));
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
34
|
async function setScheduleTarget(projectName, scheduleId, target, options = {}) {
|
|
43
35
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
44
|
-
const projectSlug = resolveProjectSlug(projectName, options);
|
|
45
36
|
const enabled = target === 'enable';
|
|
37
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
38
|
+
return;
|
|
46
39
|
try {
|
|
40
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
47
41
|
await axios_1.default.patch(`${config.host}/api/v1/projects/${encodeURIComponent(projectSlug)}/schedules/${encodeURIComponent(scheduleId)}`, { enabled }, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
|
|
48
42
|
console.log(chalk_1.default.green(`Schedule ${scheduleId} ${enabled ? 'enabled' : 'disabled'}.`));
|
|
49
43
|
console.log(chalk_1.default.gray('This is a sticky override and survives redeploy until changed or reset.'));
|
|
50
44
|
}
|
|
51
45
|
catch (error) {
|
|
52
|
-
renderScheduleStateError(error, projectName, scheduleId);
|
|
46
|
+
renderScheduleStateError(error, projectName, scheduleId, config.host);
|
|
53
47
|
}
|
|
54
48
|
}
|
|
55
49
|
async function scheduleEnable(projectName, scheduleId, options = {}) {
|
|
@@ -60,12 +54,14 @@ async function scheduleDisable(projectName, scheduleId, options = {}) {
|
|
|
60
54
|
}
|
|
61
55
|
async function scheduleReset(projectName, scheduleId, options = {}) {
|
|
62
56
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
63
|
-
|
|
57
|
+
if (!(0, project_view_1.isUsableProjectRef)(projectName, options.env))
|
|
58
|
+
return;
|
|
64
59
|
try {
|
|
60
|
+
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, options.env);
|
|
65
61
|
await axios_1.default.post(`${config.host}/api/v1/projects/${encodeURIComponent(projectSlug)}/schedules/${encodeURIComponent(scheduleId)}/reset`, {}, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
|
|
66
62
|
console.log(chalk_1.default.green(`Schedule ${scheduleId} reset. YAML controls this schedule again.`));
|
|
67
63
|
}
|
|
68
64
|
catch (error) {
|
|
69
|
-
renderScheduleStateError(error, projectName, scheduleId);
|
|
65
|
+
renderScheduleStateError(error, projectName, scheduleId, config.host);
|
|
70
66
|
}
|
|
71
67
|
}
|