@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.
Files changed (44) hide show
  1. package/README.md +3 -3
  2. package/dist/command-manifest.json +1 -1
  3. package/dist/commands/connection-list.js +1 -1
  4. package/dist/commands/crew-env-delete.js +2 -2
  5. package/dist/commands/crew-env-list.js +2 -2
  6. package/dist/commands/crew-env-push.js +5 -2
  7. package/dist/commands/crew-env-set.js +2 -2
  8. package/dist/commands/deploy.js +41 -26
  9. package/dist/commands/doc-pull.js +432 -88
  10. package/dist/commands/doc-push.js +54 -3
  11. package/dist/commands/doc-upload.js +5 -2
  12. package/dist/commands/env-delete.js +12 -5
  13. package/dist/commands/env-list.js +12 -7
  14. package/dist/commands/env-map.js +7 -5
  15. package/dist/commands/env-pull.js +5 -6
  16. package/dist/commands/env-push.js +10 -6
  17. package/dist/commands/env-reset.js +12 -8
  18. package/dist/commands/env-set.js +15 -11
  19. package/dist/commands/login.js +8 -7
  20. package/dist/commands/oauth-action-list.js +2 -2
  21. package/dist/commands/oauth-action-platforms.js +2 -2
  22. package/dist/commands/oauth-action-search.js +2 -2
  23. package/dist/commands/oauth-action-view.js +2 -2
  24. package/dist/commands/project-create.js +1 -1
  25. package/dist/commands/project-list.js +2 -2
  26. package/dist/commands/project-logs.js +7 -3
  27. package/dist/commands/project-view.js +26 -9
  28. package/dist/commands/pull.js +4 -2
  29. package/dist/commands/run-list.js +24 -3
  30. package/dist/commands/run-start.js +12 -9
  31. package/dist/commands/run-view.js +2 -2
  32. package/dist/commands/schedule-delete.js +5 -10
  33. package/dist/commands/schedule-list.js +5 -10
  34. package/dist/commands/schedule-set.js +39 -44
  35. package/dist/commands/schedule-state.js +12 -16
  36. package/dist/commands/state.js +3 -3
  37. package/dist/commands/webhook-list.js +12 -4
  38. package/dist/commands/webhook-secret.js +12 -4
  39. package/dist/commands/workflow-view.js +3 -3
  40. package/dist/commands/workspaces.js +53 -2
  41. package/dist/utils/api.js +35 -2
  42. package/dist/utils/crew.js +6 -1
  43. package/dist/utils/project-ref.js +91 -0
  44. package/package.json +2 -2
@@ -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
- try {
156
- slug = projectSlugForView(project, environment);
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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);
@@ -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 response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectName}/source`, {
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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
- const response = await axios_1.default.get(`${config.host}/api/v1/runs`, {
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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(`Failed: ${error.response.status}`), error.response.data);
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
72
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
74
73
  }
75
74
  else if (error.response.status === 404) {
76
- const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
77
- if (envsList) {
78
- console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envsList}). Pass -e <env> to target a different environment.`));
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('Project or workflow not found.'));
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(`Failed: ${error.response.status}`), error.response.data);
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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(`Failed: ${error.response.status}`), error.response.data);
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
- let projectSlug;
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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(`Failed: ${error.response.status}`), error.response.data);
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
- let projectSlug;
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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(`Failed: ${error.response.status}`), error.response.data);
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
- let projectSlug;
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
- // Check for existing schedule on the same workflow
70
- if (!options.yes) {
71
- try {
72
- const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/schedules`, {
73
- headers: (0, api_1.getApiHeaders)(config),
74
- });
75
- const schedules = listResponse.data.data || listResponse.data || [];
76
- const existing = schedules.find((s) => {
77
- if (options.workflow) {
78
- return s.workflow_name === options.workflow || s.workflow_slug === options.workflow;
79
- }
80
- return true; // No workflow specified — any existing schedule is a match
81
- });
82
- if (existing) {
83
- const workflowName = existing.workflow_name || existing.workflow_slug || 'unknown';
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 (confirm.action === 'cancel' || confirm.action === undefined) {
92
- console.log(chalk_1.default.gray('Cancelled.'));
93
- return;
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
- // The API owns the one-schedule-per-workflow invariant and
96
- // updates the existing row. Do not delete first: deletion
97
- // loses YAML provenance and any persistent override state.
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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:'), error.response.data.message || error.response.data.errors);
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(`Failed: ${error.response.status}`), error.response.data);
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('Authentication failed. Run "solidactions login --global" to re-configure.'));
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(`Failed: ${error.response.status}`), error.response.data?.message ?? error.response.data);
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
- const projectSlug = resolveProjectSlug(projectName, options);
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
  }
@@ -73,12 +73,12 @@ function printInverseCommand(target, environment, enabled) {
73
73
  : `solidactions project ${verb} ${target.project} --env ${environment}`;
74
74
  console.log(chalk_1.default.gray(`Undo: ${command}`));
75
75
  }
76
- function errorMessage(error, target) {
76
+ function errorMessage(error, target, host) {
77
77
  if (!error.response) {
78
78
  return `Connection failed: ${error.message}`;
79
79
  }
80
80
  if (error.response.status === 401) {
81
- return 'Authentication failed. Run "solidactions login --global" to re-configure.';
81
+ return (0, api_1.authFailedLine)(host);
82
82
  }
83
83
  if (error.response.status === 422) {
84
84
  return (0, api_1.formatValidationError)(error.response.data);
@@ -117,7 +117,7 @@ async function setStateWithConfig(target, enabled, options, config) {
117
117
  printInverseCommand(target, environment, enabled);
118
118
  }
119
119
  catch (error) {
120
- console.error(chalk_1.default.red(errorMessage(error, target)));
120
+ console.error(chalk_1.default.red(errorMessage(error, target, config.host)));
121
121
  process.exit(1);
122
122
  }
123
123
  }
@@ -7,6 +7,7 @@ exports.webhookList = webhookList;
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 webhook_formatters_1 = require("../utils/webhook-formatters");
11
12
  async function webhookList(projectName, options = {}) {
12
13
  const format = options.format ?? 'table';
@@ -16,11 +17,11 @@ async function webhookList(projectName, options = {}) {
16
17
  }
17
18
  const config = await (0, api_1.requireConfigWithWorkspace)();
18
19
  const environment = options.env || 'dev';
19
- const projectSlug = environment === 'production' ? projectName : `${projectName}-${environment}`;
20
20
  if (format === 'table') {
21
21
  console.log(chalk_1.default.blue(`Webhooks for project "${projectName}"${environment !== 'production' ? ` (${environment})` : ''}:`));
22
22
  }
23
23
  try {
24
+ const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
24
25
  const params = {};
25
26
  if (options.showSecrets) {
26
27
  params.show_secrets = 'true';
@@ -50,13 +51,20 @@ async function webhookList(projectName, options = {}) {
50
51
  catch (error) {
51
52
  if (error.response) {
52
53
  if (error.response.status === 401) {
53
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
54
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
54
55
  }
55
56
  else if (error.response.status === 404) {
56
- console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
57
+ const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
58
+ const envs = family?.environments ?? [];
59
+ if (envs.length > 0 && !envs.includes(environment)) {
60
+ console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}). Pass -e <env> to target a different environment.`));
61
+ }
62
+ else {
63
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
64
+ }
57
65
  }
58
66
  else {
59
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
67
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
60
68
  }
61
69
  }
62
70
  else {
@@ -8,6 +8,7 @@ exports.webhookSecret = webhookSecret;
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
  function formatSecretOutput(rows, workflowFilter) {
12
13
  if (workflowFilter) {
13
14
  const match = rows.find((r) => r.workflow_name === workflowFilter);
@@ -29,11 +30,11 @@ async function webhookSecret(projectName, options = {}) {
29
30
  }
30
31
  const config = await (0, api_1.requireConfigWithWorkspace)();
31
32
  const environment = options.env || 'dev';
32
- const projectSlug = environment === 'production' ? projectName : `${projectName}-${environment}`;
33
33
  if (format === 'text') {
34
34
  process.stderr.write(chalk_1.default.dim(`(environment: ${environment} — pass -e <env> to change)\n`));
35
35
  }
36
36
  try {
37
+ const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
37
38
  const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/webhooks`, {
38
39
  headers: (0, api_1.getApiHeaders)(config),
39
40
  params: { show_secrets: 'true' },
@@ -57,13 +58,20 @@ async function webhookSecret(projectName, options = {}) {
57
58
  catch (error) {
58
59
  if (error.response) {
59
60
  if (error.response.status === 401) {
60
- console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
61
+ console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
61
62
  }
62
63
  else if (error.response.status === 404) {
63
- console.error(chalk_1.default.red(`Project "${projectName}" not found.`));
64
+ const family = await (0, api_1.lookupProjectFamilyEnvironments)(config, projectName);
65
+ const envs = family?.environments ?? [];
66
+ if (envs.length > 0 && !envs.includes(environment)) {
67
+ console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment (exists in: ${envs.join(', ')}). Pass -e <env> to target a different environment.`));
68
+ }
69
+ else {
70
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(404, error.response.data)));
71
+ }
64
72
  }
65
73
  else {
66
- console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
74
+ console.error(chalk_1.default.red((0, api_1.formatApiFailure)(error.response.status, error.response.data)));
67
75
  }
68
76
  }
69
77
  else {