@solidactions/cli 3.0.0 → 3.2.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 +16 -1
- package/dist/commands/connection-list.js +61 -0
- package/dist/commands/deploy.js +145 -14
- package/dist/commands/device-login.js +7 -5
- package/dist/commands/env-reset.js +60 -0
- package/dist/commands/env-set.js +19 -2
- package/dist/commands/login.js +201 -44
- package/dist/commands/project-view.js +134 -0
- package/dist/index.js +41 -3
- package/dist/utils/api.js +89 -5
- package/dist/utils/archiver-loader.cjs +1 -0
- package/dist/utils/config-write-target.js +47 -10
- package/dist/utils/source-provenance.js +241 -0
- package/dist/utils/tar-archive.js +12 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -142,6 +142,14 @@ deploy:
|
|
|
142
142
|
|
|
143
143
|
The CLI prints a one-line summary of what it bundled, e.g. `Bundling 312 files (.env excluded; .gitignore applied; 2 exclude rules)`, and warns about any symlinks it skipped.
|
|
144
144
|
|
|
145
|
+
Deploys also transmit client-reported Git provenance when it can be collected:
|
|
146
|
+
commit, branch/tag, subject/date, sanitized remote repository URL (with
|
|
147
|
+
credentials stripped), and whether the deployed subtree was dirty. The CLI
|
|
148
|
+
prints the local revision before upload and confirms the server-recorded
|
|
149
|
+
revision after the build. Use `--no-git-metadata` or
|
|
150
|
+
`SOLIDACTIONS_NO_GIT_METADATA=1` to opt out. Deploying a non-Git directory
|
|
151
|
+
continues normally without revision metadata.
|
|
152
|
+
|
|
145
153
|
## Commands
|
|
146
154
|
|
|
147
155
|
Use `solidactions <command> --help` for full flag details on any command.
|
|
@@ -161,11 +169,18 @@ Use `solidactions <command> --help` for full flag details on any command.
|
|
|
161
169
|
| Command | Key Flags | Description |
|
|
162
170
|
|---------|-----------|-------------|
|
|
163
171
|
| `project create <name>` | `-e` | Create an empty project (no source/build); `-e` defaults to `production` |
|
|
164
|
-
| `project deploy <name> [path]` | `-e`, `--create`, `--config-only` | Deploy or sync config only |
|
|
172
|
+
| `project deploy <name> [path]` | `-e`, `--create`, `--config-only`, `--no-git-metadata` | Deploy or sync config only |
|
|
173
|
+
| `project view <project>` | `-e` | View status and client-reported deployed revision |
|
|
165
174
|
| `project pull <name> [path]` | `-y` | Pull source (warns before overwriting) |
|
|
166
175
|
| `project logs <name>` | | View build logs |
|
|
167
176
|
| `project list` | | List all projects |
|
|
168
177
|
|
|
178
|
+
For `project view`, omitting `--env` treats `<project>` as an exact slug.
|
|
179
|
+
Passing `--env production` uses the supplied production name/slug unchanged;
|
|
180
|
+
`--env staging` and `--env dev` derive the same suffixed slug as deploy. This
|
|
181
|
+
is deliberately different from historical commands such as `run start`,
|
|
182
|
+
which default to dev.
|
|
183
|
+
|
|
169
184
|
### run
|
|
170
185
|
|
|
171
186
|
| Command | Key Flags | Description |
|
|
@@ -0,0 +1,61 @@
|
|
|
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.connectionList = connectionList;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const api_1 = require("../utils/api");
|
|
10
|
+
const table_1 = require("../utils/table");
|
|
11
|
+
const ERROR_SNIPPET_WIDTH = 40;
|
|
12
|
+
function connectionStatus(connection) {
|
|
13
|
+
const status = connection.status || '?';
|
|
14
|
+
const error = connection.error_message?.trim();
|
|
15
|
+
if (!error) {
|
|
16
|
+
return status;
|
|
17
|
+
}
|
|
18
|
+
return `${status} — ${(0, table_1.truncateCell)((0, table_1.sanitizeCell)(error), ERROR_SNIPPET_WIDTH)}`;
|
|
19
|
+
}
|
|
20
|
+
async function connectionList() {
|
|
21
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
22
|
+
try {
|
|
23
|
+
const response = await axios_1.default.get(`${config.host}/api/v1/connections`, {
|
|
24
|
+
headers: (0, api_1.getApiHeaders)(config),
|
|
25
|
+
});
|
|
26
|
+
const connections = response.data.data || [];
|
|
27
|
+
if (connections.length === 0) {
|
|
28
|
+
console.log(chalk_1.default.gray('No connections found.'));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.log(chalk_1.default.blue('Connections:\n'));
|
|
32
|
+
const rows = connections.map((connection) => [
|
|
33
|
+
connection.name || '?',
|
|
34
|
+
connection.provider || '?',
|
|
35
|
+
connectionStatus(connection),
|
|
36
|
+
connection.last_used_at || '-',
|
|
37
|
+
]);
|
|
38
|
+
const lines = (0, table_1.renderTable)(['NAME', 'PROVIDER', 'STATUS', 'LAST USED'], rows, {
|
|
39
|
+
minWidths: [24, 14, 20],
|
|
40
|
+
});
|
|
41
|
+
console.log(chalk_1.default.gray(lines[0]));
|
|
42
|
+
console.log(chalk_1.default.gray(lines[1]));
|
|
43
|
+
for (const line of lines.slice(2)) {
|
|
44
|
+
console.log(line);
|
|
45
|
+
}
|
|
46
|
+
console.log('');
|
|
47
|
+
console.log(chalk_1.default.gray(`${connections.length} connection(s)`));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error.response?.status === 401) {
|
|
51
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
|
|
52
|
+
}
|
|
53
|
+
else if (error.response) {
|
|
54
|
+
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
58
|
+
}
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -5,6 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PLAN_LIMIT_NON_INTERACTIVE_HINT = exports.SKILLS_TIP_LINES = void 0;
|
|
7
7
|
exports.cacheBusterEntry = cacheBusterEntry;
|
|
8
|
+
exports.projectStatusUrl = projectStatusUrl;
|
|
9
|
+
exports.fetchDeploymentConfirmation = fetchDeploymentConfirmation;
|
|
10
|
+
exports.isConfirmationMatch = isConfirmationMatch;
|
|
11
|
+
exports.confirmDeploymentWithRetry = confirmDeploymentWithRetry;
|
|
12
|
+
exports.formatDeploymentConfirmation = formatDeploymentConfirmation;
|
|
13
|
+
exports.safeCollectSourceMetadata = safeCollectSourceMetadata;
|
|
8
14
|
exports.shouldPrintWorkspaceMismatch = shouldPrintWorkspaceMismatch;
|
|
9
15
|
exports.isPlanLimitReachedError = isPlanLimitReachedError;
|
|
10
16
|
exports.handlePlanLimitReached = handlePlanLimitReached;
|
|
@@ -13,9 +19,7 @@ exports.shouldPrintWebhookSecretNotice = shouldPrintWebhookSecretNotice;
|
|
|
13
19
|
const fs_1 = __importDefault(require("fs"));
|
|
14
20
|
const path_1 = __importDefault(require("path"));
|
|
15
21
|
const crypto_1 = require("crypto");
|
|
16
|
-
const archiver_1 = __importDefault(require("archiver"));
|
|
17
22
|
const axios_1 = __importDefault(require("axios"));
|
|
18
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
19
23
|
const chalk_1 = __importDefault(require("chalk"));
|
|
20
24
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
21
25
|
const prompts_1 = __importDefault(require("prompts"));
|
|
@@ -24,6 +28,9 @@ const api_1 = require("../utils/api");
|
|
|
24
28
|
const deploy_ignore_1 = require("../utils/deploy-ignore");
|
|
25
29
|
const slug_1 = require("../utils/slug");
|
|
26
30
|
const skills_1 = require("../utils/skills");
|
|
31
|
+
const tar_archive_1 = require("../utils/tar-archive");
|
|
32
|
+
const source_provenance_1 = require("../utils/source-provenance");
|
|
33
|
+
const project_view_1 = require("./project-view");
|
|
27
34
|
/** Printed when a deploy target has no SolidActions skill files installed. */
|
|
28
35
|
exports.SKILLS_TIP_LINES = [
|
|
29
36
|
'Tip: no SolidActions skill files found (.claude/skills/solidactions-*). Your AI assistant',
|
|
@@ -117,6 +124,93 @@ function cacheBusterEntry(noCache) {
|
|
|
117
124
|
content: `force-rebuild ${uuid} ${Date.now()}`,
|
|
118
125
|
};
|
|
119
126
|
}
|
|
127
|
+
function projectStatusUrl(host, projectSlug) {
|
|
128
|
+
return `${host}/api/v1/projects/${encodeURIComponent(projectSlug)}`;
|
|
129
|
+
}
|
|
130
|
+
async function fetchDeploymentConfirmation(config, projectSlug) {
|
|
131
|
+
const response = await axios_1.default.get(`${projectStatusUrl(config.host, projectSlug)}?include=deployment`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
132
|
+
return response.data;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* True when the fetched project's recorded latest successful deployment is
|
|
136
|
+
* the one this deploy produced. A null `acceptedDeploymentId` (legacy server
|
|
137
|
+
* response) has nothing to confirm against, so it counts as a match.
|
|
138
|
+
*/
|
|
139
|
+
function isConfirmationMatch(project, acceptedDeploymentId) {
|
|
140
|
+
if (!acceptedDeploymentId) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const deployment = project.latest_successful_deployment ?? null;
|
|
144
|
+
return project.deployment_matches_deployed_hash === true
|
|
145
|
+
&& deployment !== null
|
|
146
|
+
&& deployment.id === acceptedDeploymentId;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Rebuild provenance can lag server-side (app #972): the instant status
|
|
150
|
+
* flips to "deployed", the confirmation record may not have caught up yet,
|
|
151
|
+
* so a healthy deploy can transiently look like a mismatch. Retries a short,
|
|
152
|
+
* bounded number of times before accepting whatever the last fetch reported.
|
|
153
|
+
* Exit code is unaffected either way — this only changes which message prints.
|
|
154
|
+
*/
|
|
155
|
+
async function confirmDeploymentWithRetry(acceptedDeploymentId, fetcher, options = {}) {
|
|
156
|
+
const attempts = options.attempts ?? 3;
|
|
157
|
+
const delayMs = options.delayMs ?? 500;
|
|
158
|
+
const wait = options.wait ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
159
|
+
let result;
|
|
160
|
+
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
161
|
+
result = await fetcher();
|
|
162
|
+
if (isConfirmationMatch(result, acceptedDeploymentId) || attempt === attempts) {
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
await wait(delayMs);
|
|
166
|
+
}
|
|
167
|
+
// Unreachable: the loop always returns on its final iteration.
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
function formatDeploymentConfirmation(project, acceptedDeploymentId, sourceMetadataRejected) {
|
|
171
|
+
if (!acceptedDeploymentId) {
|
|
172
|
+
return ['Build finished; revision confirmation unavailable (legacy server response).'];
|
|
173
|
+
}
|
|
174
|
+
const deployment = project.latest_successful_deployment ?? null;
|
|
175
|
+
if (!deployment) {
|
|
176
|
+
return ['Build finished, but the server has no successful deployment recorded yet for this project.'];
|
|
177
|
+
}
|
|
178
|
+
if (project.deployment_matches_deployed_hash !== true) {
|
|
179
|
+
return ["Build finished, but the running revision hash does not match the server's recorded successful deployment."];
|
|
180
|
+
}
|
|
181
|
+
if (deployment.id !== acceptedDeploymentId) {
|
|
182
|
+
return ['Build finished, but this deployment was not recorded as the latest successful deployment.'];
|
|
183
|
+
}
|
|
184
|
+
const revisionLines = (0, project_view_1.formatDeploymentRevision)(deployment);
|
|
185
|
+
const noRevisionReported = revisionLines[0] === 'No source revision was reported.';
|
|
186
|
+
const lines = [
|
|
187
|
+
noRevisionReported
|
|
188
|
+
? 'Deployment confirmed, but no source revision was reported for it.'
|
|
189
|
+
: 'Deployment revision confirmed.',
|
|
190
|
+
];
|
|
191
|
+
if (sourceMetadataRejected) {
|
|
192
|
+
const safeReason = (0, source_provenance_1.sanitizeDisplayText)(sourceMetadataRejected, 100) ?? 'invalid_metadata';
|
|
193
|
+
lines.push(`Optional source metadata was rejected by the server (${safeReason}).`);
|
|
194
|
+
}
|
|
195
|
+
lines.push(...(noRevisionReported ? revisionLines.slice(1) : revisionLines));
|
|
196
|
+
return lines;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Provenance collection is optional, best effort — a failure here must never
|
|
200
|
+
* fail the deploy. Wraps collectSourceMetadata() (or an injected collector,
|
|
201
|
+
* for testing) in a try/catch and degrades to null on throw.
|
|
202
|
+
*/
|
|
203
|
+
function safeCollectSourceMetadata(sourceDir, options, collector = source_provenance_1.collectSourceMetadata) {
|
|
204
|
+
if (!(0, source_provenance_1.shouldCollectGitMetadata)(options)) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
return collector(sourceDir);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
120
214
|
/**
|
|
121
215
|
* Push YAML env declarations to the project.
|
|
122
216
|
* This registers all YAML-declared vars and their mappings.
|
|
@@ -402,7 +496,12 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
402
496
|
console.log(chalk_1.default.green(`✓ Config synced for ${projectSlug}${envLabel}`));
|
|
403
497
|
return;
|
|
404
498
|
}
|
|
405
|
-
|
|
499
|
+
// Provenance is optional, best effort, and collected before archiving so
|
|
500
|
+
// the deploy artifact itself can never make the source look dirty.
|
|
501
|
+
const sourceMetadata = safeCollectSourceMetadata(sourceDir, options);
|
|
502
|
+
if (sourceMetadata) {
|
|
503
|
+
console.log(chalk_1.default.gray(`Revision to upload (client-reported): ${(0, source_provenance_1.formatRevisionSummary)(sourceMetadata)}`));
|
|
504
|
+
}
|
|
406
505
|
// Plan the file list BEFORE creating the archive write stream so a walk error
|
|
407
506
|
// (permission error, unreadable dir) aborts cleanly with no orphan tarball.
|
|
408
507
|
let plan;
|
|
@@ -414,6 +513,15 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
414
513
|
console.error(error.message);
|
|
415
514
|
process.exit(1);
|
|
416
515
|
}
|
|
516
|
+
const archiveLocation = (0, source_provenance_1.createDeployArchiveLocation)();
|
|
517
|
+
const archivePath = archiveLocation.archivePath;
|
|
518
|
+
let archiveCleaned = false;
|
|
519
|
+
const cleanupArchive = () => {
|
|
520
|
+
if (!archiveCleaned) {
|
|
521
|
+
archiveCleaned = true;
|
|
522
|
+
archiveLocation.cleanup();
|
|
523
|
+
}
|
|
524
|
+
};
|
|
417
525
|
// Summary line so silent truncation never reads as "shipped everything".
|
|
418
526
|
const parts = ['.env excluded'];
|
|
419
527
|
if (plan.summary.gitignoreApplied) {
|
|
@@ -426,18 +534,17 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
426
534
|
if (plan.summary.symlinksSkipped.length > 0) {
|
|
427
535
|
console.log(chalk_1.default.yellow(`⚠ Skipped ${plan.summary.symlinksSkipped.length} symlink(s) (not followed): ${plan.summary.symlinksSkipped.join(', ')}`));
|
|
428
536
|
}
|
|
537
|
+
const archive = await (0, tar_archive_1.createTarArchive)({ gzip: true, gzipOptions: { level: 9 } });
|
|
429
538
|
const output = fs_1.default.createWriteStream(archivePath);
|
|
430
|
-
const archive = (0, archiver_1.default)('tar', { gzip: true, gzipOptions: { level: 9 } });
|
|
431
539
|
output.on('close', async () => {
|
|
432
540
|
console.log(chalk_1.default.gray(`Archived ${archive.pointer()} total bytes`));
|
|
433
541
|
try {
|
|
434
|
-
const form =
|
|
435
|
-
form.append('source', fs_1.default.createReadStream(archivePath));
|
|
542
|
+
const form = (0, source_provenance_1.buildDeployForm)(archivePath, sourceMetadata);
|
|
436
543
|
console.log(chalk_1.default.yellow('Uploading...'));
|
|
437
544
|
if (process.env.SOLIDACTIONS_DEPLOY_DEBUG === '1') {
|
|
438
545
|
process.stderr.write(`[deploy-debug] POST ${config.host}/api/v1/projects/${projectSlug}/deploy (workspace=${config.workspaceId ?? '(none)'})\n`);
|
|
439
546
|
}
|
|
440
|
-
await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/deploy`, form, {
|
|
547
|
+
const deployResponse = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/deploy`, form, {
|
|
441
548
|
headers: {
|
|
442
549
|
...form.getHeaders(),
|
|
443
550
|
...(0, api_1.getApiHeaders)(config),
|
|
@@ -445,6 +552,13 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
445
552
|
maxContentLength: Infinity,
|
|
446
553
|
maxBodyLength: Infinity
|
|
447
554
|
});
|
|
555
|
+
const acceptedDeployment = (0, source_provenance_1.parseDeployAcceptance)(deployResponse.data);
|
|
556
|
+
if (acceptedDeployment.sourceMetadataRejected) {
|
|
557
|
+
console.log(chalk_1.default.yellow(`Warning: optional source metadata was not accepted (${acceptedDeployment.sourceMetadataRejected}); deployment continues.`));
|
|
558
|
+
}
|
|
559
|
+
if (process.env.SOLIDACTIONS_DEPLOY_DEBUG === '1') {
|
|
560
|
+
process.stderr.write(`[deploy-debug] accepted deployment=${acceptedDeployment.deploymentId ?? '(legacy response)'} metadata=${acceptedDeployment.sourceMetadata ? 'normalized' : 'none'}\n`);
|
|
561
|
+
}
|
|
448
562
|
console.log(chalk_1.default.green('Deployment successfully queued!'));
|
|
449
563
|
console.log(chalk_1.default.yellow('Waiting for build to complete...\n'));
|
|
450
564
|
if (process.env.SOLIDACTIONS_DEPLOY_DEBUG === '1') {
|
|
@@ -457,7 +571,7 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
457
571
|
const poll = setInterval(async () => {
|
|
458
572
|
try {
|
|
459
573
|
attempts++;
|
|
460
|
-
const statusRes = await axios_1.default.get(
|
|
574
|
+
const statusRes = await axios_1.default.get(projectStatusUrl(config.host, projectSlug), {
|
|
461
575
|
headers: (0, api_1.getApiHeaders)(config),
|
|
462
576
|
});
|
|
463
577
|
const { status, build_log } = statusRes.data;
|
|
@@ -478,6 +592,15 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
478
592
|
if (status === 'deployed') {
|
|
479
593
|
clearInterval(poll);
|
|
480
594
|
console.log(chalk_1.default.green(`\n✓ Deployed to ${projectSlug}${envLabel}!`));
|
|
595
|
+
try {
|
|
596
|
+
const confirmedProject = await confirmDeploymentWithRetry(acceptedDeployment.deploymentId, () => fetchDeploymentConfirmation(config, projectSlug));
|
|
597
|
+
for (const line of formatDeploymentConfirmation(confirmedProject, acceptedDeployment.deploymentId, acceptedDeployment.sourceMetadataRejected)) {
|
|
598
|
+
console.log(line);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
catch {
|
|
602
|
+
console.log(chalk_1.default.yellow('Build finished; server revision confirmation was unavailable.'));
|
|
603
|
+
}
|
|
481
604
|
// Always sync YAML declarations (registers variables and their mappings)
|
|
482
605
|
if (yamlConfig) {
|
|
483
606
|
await pushYamlDeclarations(config, projectSlug, yamlConfig);
|
|
@@ -488,7 +611,7 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
488
611
|
console.log(chalk_1.default.blue(`ℹ Webhook secret: run \`solidactions webhook secret ${projectName}${envFlag}\` to retrieve the generated secret.`));
|
|
489
612
|
console.log(chalk_1.default.gray(` Set the same value in your sender (e.g. Telegram setWebhook secret_token).`));
|
|
490
613
|
}
|
|
491
|
-
|
|
614
|
+
cleanupArchive();
|
|
492
615
|
process.exit(0);
|
|
493
616
|
}
|
|
494
617
|
else if (status === 'error') {
|
|
@@ -499,13 +622,13 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
499
622
|
console.log(chalk_1.default.gray(build_log));
|
|
500
623
|
console.log(chalk_1.default.yellow('--- End Build Log ---\n'));
|
|
501
624
|
}
|
|
502
|
-
|
|
625
|
+
cleanupArchive();
|
|
503
626
|
process.exit(1);
|
|
504
627
|
}
|
|
505
628
|
else if (attempts >= maxAttempts) {
|
|
506
629
|
clearInterval(poll);
|
|
507
630
|
console.error(chalk_1.default.red('\nTimeout waiting for build. It might still finish.'));
|
|
508
|
-
|
|
631
|
+
cleanupArchive();
|
|
509
632
|
process.exit(1);
|
|
510
633
|
}
|
|
511
634
|
}
|
|
@@ -527,13 +650,21 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
527
650
|
else {
|
|
528
651
|
console.error(error.message);
|
|
529
652
|
}
|
|
530
|
-
|
|
531
|
-
fs_1.default.unlinkSync(archivePath);
|
|
653
|
+
cleanupArchive();
|
|
532
654
|
process.exit(1);
|
|
533
655
|
}
|
|
534
656
|
});
|
|
535
657
|
archive.on('error', (err) => {
|
|
536
|
-
|
|
658
|
+
cleanupArchive();
|
|
659
|
+
console.error(chalk_1.default.red('Deployment failed:'));
|
|
660
|
+
console.error(err.message);
|
|
661
|
+
process.exit(1);
|
|
662
|
+
});
|
|
663
|
+
output.on('error', (err) => {
|
|
664
|
+
cleanupArchive();
|
|
665
|
+
console.error(chalk_1.default.red('Deployment failed:'));
|
|
666
|
+
console.error(err.message);
|
|
667
|
+
process.exit(1);
|
|
537
668
|
});
|
|
538
669
|
archive.pipe(output);
|
|
539
670
|
// User code goes under tenantcode/ so it never conflicts with our Dockerfile.
|
|
@@ -8,6 +8,7 @@ exports.pollForToken = pollForToken;
|
|
|
8
8
|
exports.deviceLogin = deviceLogin;
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
require("../utils/api");
|
|
11
12
|
const workspace_lookup_1 = require("../utils/workspace-lookup");
|
|
12
13
|
const login_1 = require("./login");
|
|
13
14
|
// Public device-flow client id — not a secret; matches the server-seeded
|
|
@@ -74,6 +75,7 @@ async function pollForToken(host, clientId, deviceCode, intervalSeconds, expires
|
|
|
74
75
|
async function deviceLogin(options) {
|
|
75
76
|
const resolved = (0, login_1.resolveLoginHost)(options);
|
|
76
77
|
const host = resolved.host;
|
|
78
|
+
const preflight = await (0, login_1.preflightDeviceLoginWrite)(options);
|
|
77
79
|
console.log(chalk_1.default.blue('Requesting device authorization...'));
|
|
78
80
|
const code = await requestDeviceCode(host);
|
|
79
81
|
// Deliberately the bare verification_uri, never verification_uri_complete:
|
|
@@ -95,8 +97,7 @@ async function deviceLogin(options) {
|
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
99
|
const config = { host, apiKey: token.access_token };
|
|
98
|
-
|
|
99
|
-
// exactly as login() does via the shared completeLogin() helper.
|
|
100
|
+
await (0, login_1.persistPreflightedLoginCredential)(config, preflight, options);
|
|
100
101
|
let workspaces;
|
|
101
102
|
let scope;
|
|
102
103
|
try {
|
|
@@ -104,13 +105,14 @@ async function deviceLogin(options) {
|
|
|
104
105
|
}
|
|
105
106
|
catch (e) {
|
|
106
107
|
if (e.response?.status === 401) {
|
|
107
|
-
console.error(chalk_1.default.red(`
|
|
108
|
+
console.error(chalk_1.default.red(`Authentication was saved to ${preflight.targetPath}, but the server rejected it during workspace discovery.`));
|
|
108
109
|
}
|
|
109
110
|
else {
|
|
110
|
-
console.error(chalk_1.default.red(`
|
|
111
|
+
console.error(chalk_1.default.red(`Authentication was saved to ${preflight.targetPath}, but workspace discovery failed: ${e.message}`));
|
|
111
112
|
}
|
|
113
|
+
console.error(chalk_1.default.yellow('Run `solidactions workspace set <name>` when workspace access is available.'));
|
|
112
114
|
process.exit(1);
|
|
113
115
|
return;
|
|
114
116
|
}
|
|
115
|
-
await (0, login_1.completeLogin)(config, workspaces, options, scope);
|
|
117
|
+
await (0, login_1.completeLogin)(config, workspaces, options, scope, preflight);
|
|
116
118
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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.envReset = envReset;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const api_1 = require("../utils/api");
|
|
10
|
+
function describeRestoredSource(mapping) {
|
|
11
|
+
const sourceType = mapping.source_type || mapping.source || 'unknown';
|
|
12
|
+
if (sourceType === 'oauth_connection') {
|
|
13
|
+
const connection = mapping.oauth_connection_name || mapping.oauth_connection_id;
|
|
14
|
+
return connection ? `oauth_connection "${connection}"` : 'oauth_connection';
|
|
15
|
+
}
|
|
16
|
+
if (sourceType === 'global_variable') {
|
|
17
|
+
const globalKey = mapping.global_variable_key;
|
|
18
|
+
return globalKey ? `global_variable "${globalKey}"` : 'global_variable';
|
|
19
|
+
}
|
|
20
|
+
return sourceType;
|
|
21
|
+
}
|
|
22
|
+
async function envReset(projectName, key, options = {}) {
|
|
23
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
24
|
+
const environment = options.env || 'dev';
|
|
25
|
+
const projectSlug = environment === 'production'
|
|
26
|
+
? projectName
|
|
27
|
+
: `${projectName}-${environment}`;
|
|
28
|
+
try {
|
|
29
|
+
const listResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
30
|
+
const mappings = listResponse.data || [];
|
|
31
|
+
const mapping = mappings.find((candidate) => candidate.env_name === key);
|
|
32
|
+
if (!mapping) {
|
|
33
|
+
console.error(chalk_1.default.red(`Variable "${key}" has no variable mapping in project "${projectName}" (${environment}).`));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
const resetResponse = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/${mapping.id}/reset`, {}, { headers: (0, api_1.getApiHeaders)(config, 'application/json') });
|
|
37
|
+
const restored = resetResponse.data.mapping;
|
|
38
|
+
console.log(chalk_1.default.green(`Variable "${key}" reset to ${describeRestoredSource(restored)} ` +
|
|
39
|
+
`in project "${projectName}" (${environment}).`));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error.response) {
|
|
43
|
+
if (error.response.status === 401) {
|
|
44
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
|
|
45
|
+
}
|
|
46
|
+
else if (error.response.status === 404) {
|
|
47
|
+
const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
|
|
48
|
+
console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment` +
|
|
49
|
+
`${envsList ? ` (exists in: ${envsList})` : ''}.`));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.error(chalk_1.default.red(`Failed: ${error.response.status}`), error.response.data);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
57
|
+
}
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
}
|
package/dist/commands/env-set.js
CHANGED
|
@@ -24,7 +24,12 @@ exports.GLOBAL_ENV_SCOPE_NOTE = [
|
|
|
24
24
|
].join('\n');
|
|
25
25
|
async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
|
|
26
26
|
// Detect mode based on arguments
|
|
27
|
-
const
|
|
27
|
+
const isOauthConnectionMode = options.oauthConnection !== undefined;
|
|
28
|
+
const isProjectMode = valueIfProject !== undefined || isOauthConnectionMode;
|
|
29
|
+
if (isOauthConnectionMode && (valueIfProject !== undefined || options.global)) {
|
|
30
|
+
process.stderr.write(chalk_1.default.red('env set: --oauth-connection binds a project key; give <project> <KEY> and no value\n'));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
28
33
|
// Jordan Wall #4 (Sweep C, → 1.23.0): a 2-positional-arg call used to fall
|
|
29
34
|
// through to GLOBAL scope silently, so a typo'd `env set KEY VALUE` (meant
|
|
30
35
|
// for a project) wrote a global var the workflow never reads. Global
|
|
@@ -65,6 +70,17 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
|
|
|
65
70
|
// Auto-detect secrets
|
|
66
71
|
const isSecret = options.secret || /secret|key|token|password|credential/i.test(key);
|
|
67
72
|
try {
|
|
73
|
+
if (isOauthConnectionMode) {
|
|
74
|
+
await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings`, {
|
|
75
|
+
project_key: key,
|
|
76
|
+
oauth_connection_name: options.oauthConnection,
|
|
77
|
+
}, {
|
|
78
|
+
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
79
|
+
});
|
|
80
|
+
console.log(chalk_1.default.green(`Variable "${key}" bound to OAuth connection "${options.oauthConnection}" ` +
|
|
81
|
+
`in project "${projectName}" (${environment}).`));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
68
84
|
// Check if variable already has a value
|
|
69
85
|
if (!options.yes) {
|
|
70
86
|
const mappingsResponse = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings?reveal=true`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
@@ -110,7 +126,8 @@ async function envSet(keyOrProject, valueOrKey, valueIfProject, options = {}) {
|
|
|
110
126
|
}
|
|
111
127
|
else if (error.response.status === 404) {
|
|
112
128
|
const envsList = await (0, api_1.describeProjectEnvironments)(config, projectName);
|
|
113
|
-
console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment${envsList ? ` (exists in: ${envsList})` : ''}.`
|
|
129
|
+
console.error(chalk_1.default.red(`Project "${projectName}" has no ${environment} environment${envsList ? ` (exists in: ${envsList})` : ''}.`
|
|
130
|
+
+ `\nRun 'solidactions project deploy ${projectName} -e ${environment} --create' first.`));
|
|
114
131
|
}
|
|
115
132
|
else if (error.response.status === 422) {
|
|
116
133
|
console.error(chalk_1.default.red((0, api_1.formatValidationError)(error.response.data)));
|