@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/dist/commands/login.js
CHANGED
|
@@ -3,19 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.API_KEY_PROMPT = void 0;
|
|
6
|
+
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = exports.API_KEY_PROMPT = void 0;
|
|
7
7
|
exports.resolveLoginApiKey = resolveLoginApiKey;
|
|
8
8
|
exports.getConfig = getConfig;
|
|
9
9
|
exports.saveConfig = saveConfig;
|
|
10
10
|
exports.clearConfig = clearConfig;
|
|
11
11
|
exports.resolveLoginHost = resolveLoginHost;
|
|
12
12
|
exports.backupPathFor = backupPathFor;
|
|
13
|
+
exports.preflightDeviceLoginWrite = preflightDeviceLoginWrite;
|
|
14
|
+
exports.persistPreflightedLoginCredential = persistPreflightedLoginCredential;
|
|
13
15
|
exports.loginHostLines = loginHostLines;
|
|
16
|
+
exports.selectWorkspaceInteractively = selectWorkspaceInteractively;
|
|
14
17
|
exports.completeLogin = completeLogin;
|
|
15
18
|
exports.login = login;
|
|
16
19
|
exports.logout = logout;
|
|
17
20
|
exports.whoami = whoami;
|
|
18
21
|
const fs_1 = __importDefault(require("fs"));
|
|
22
|
+
const path_1 = __importDefault(require("path"));
|
|
19
23
|
const readline_1 = __importDefault(require("readline"));
|
|
20
24
|
const chalk_1 = __importDefault(require("chalk"));
|
|
21
25
|
const prompts_1 = __importDefault(require("prompts"));
|
|
@@ -101,20 +105,120 @@ function backupPathFor(targetPath, now = new Date()) {
|
|
|
101
105
|
const LOGIN_REFUSAL_MESSAGE = 'Refusing to write config non-interactively. Pass --global to update the machine-wide config ' +
|
|
102
106
|
'at ~/.solidactions/config.json (a backup is kept if one exists), or --local to write ' +
|
|
103
107
|
'./.solidactions/config.json for just this directory.';
|
|
108
|
+
exports.DEVICE_LOGIN_REFUSAL_MESSAGE = 'No TTY detected. Re-run with the config destination made explicit: '
|
|
109
|
+
+ 'solidactions login --device --global --workspace <name>';
|
|
110
|
+
function nearestExistingPath(startPath) {
|
|
111
|
+
let candidate = startPath;
|
|
112
|
+
while (!fs_1.default.existsSync(candidate)) {
|
|
113
|
+
const parent = path_1.default.dirname(candidate);
|
|
114
|
+
if (parent === candidate)
|
|
115
|
+
break;
|
|
116
|
+
candidate = parent;
|
|
117
|
+
}
|
|
118
|
+
return candidate;
|
|
119
|
+
}
|
|
120
|
+
function failWritePreflight(targetPath, reason) {
|
|
121
|
+
console.error(chalk_1.default.red(`Cannot save configuration to ${targetPath}: ${reason}. `
|
|
122
|
+
+ 'Choose a writable destination with --local or --global and retry.'));
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
function assertDirectoryWritable(directoryPath, targetPath) {
|
|
126
|
+
let stat;
|
|
127
|
+
try {
|
|
128
|
+
stat = fs_1.default.statSync(directoryPath);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
failWritePreflight(targetPath, `could not inspect ${directoryPath} (${error.message})`);
|
|
132
|
+
}
|
|
133
|
+
if (!stat.isDirectory()) {
|
|
134
|
+
failWritePreflight(targetPath, `${directoryPath} is not a directory`);
|
|
135
|
+
}
|
|
136
|
+
// accessSync is authoritative for the current identity. The mode check
|
|
137
|
+
// also catches deliberately read-only fixtures when tests run as root.
|
|
138
|
+
if ((stat.mode & 0o222) === 0 || (stat.mode & 0o111) === 0) {
|
|
139
|
+
failWritePreflight(targetPath, `${directoryPath} is not writable/searchable`);
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
fs_1.default.accessSync(directoryPath, fs_1.default.constants.W_OK | fs_1.default.constants.X_OK);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
failWritePreflight(targetPath, `${directoryPath} is not writable/searchable`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Resolve and validate the device-login destination before requesting a
|
|
150
|
+
* browser approval. The returned path is reused after authorization.
|
|
151
|
+
*/
|
|
152
|
+
async function preflightDeviceLoginWrite(options, dependencies = {}) {
|
|
153
|
+
const target = await (0, config_write_target_1.decideWriteTarget)(options, undefined, exports.DEVICE_LOGIN_REFUSAL_MESSAGE, {
|
|
154
|
+
isTTY: dependencies.isTTY,
|
|
155
|
+
question: dependencies.destinationQuestion,
|
|
156
|
+
});
|
|
157
|
+
const targetPath = (0, config_write_target_1.pathForTarget)(target);
|
|
158
|
+
if (fs_1.default.existsSync(targetPath)) {
|
|
159
|
+
let stat;
|
|
160
|
+
try {
|
|
161
|
+
stat = fs_1.default.statSync(targetPath);
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
failWritePreflight(targetPath, error.message);
|
|
165
|
+
}
|
|
166
|
+
if (!stat.isFile()) {
|
|
167
|
+
failWritePreflight(targetPath, 'the config path is not a regular file');
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
fs_1.default.accessSync(targetPath, fs_1.default.constants.R_OK);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
failWritePreflight(targetPath, 'the existing config is not readable for backup');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const existingParent = nearestExistingPath(path_1.default.dirname(targetPath));
|
|
177
|
+
assertDirectoryWritable(existingParent, targetPath);
|
|
178
|
+
let backupPath = null;
|
|
179
|
+
if (fs_1.default.existsSync(targetPath)) {
|
|
180
|
+
backupPath = backupPathFor(targetPath);
|
|
181
|
+
const proceed = await (0, config_write_target_1.confirmOverwrite)(targetPath, backupPath, {
|
|
182
|
+
isTTY: dependencies.isTTY,
|
|
183
|
+
question: dependencies.overwriteQuestion,
|
|
184
|
+
});
|
|
185
|
+
if (!proceed) {
|
|
186
|
+
console.log(chalk_1.default.yellow('Aborted. No changes were made and no device code was requested.'));
|
|
187
|
+
process.exit(0);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
target,
|
|
192
|
+
targetPath,
|
|
193
|
+
backupPath,
|
|
194
|
+
backupCreated: false,
|
|
195
|
+
credentialPersisted: false,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Persist the approved base credential before workspace discovery. Existing
|
|
200
|
+
* device-login configs are backed up exactly once.
|
|
201
|
+
*/
|
|
202
|
+
async function persistPreflightedLoginCredential(config, preflight, options) {
|
|
203
|
+
if (preflight.backupPath && !preflight.backupCreated) {
|
|
204
|
+
fs_1.default.copyFileSync(preflight.targetPath, preflight.backupPath);
|
|
205
|
+
preflight.backupCreated = true;
|
|
206
|
+
console.log(chalk_1.default.gray(`Backup saved to ${preflight.backupPath}`));
|
|
207
|
+
}
|
|
208
|
+
(0, config_1.writeConfigFile)(preflight.targetPath, config);
|
|
209
|
+
preflight.credentialPersisted = true;
|
|
210
|
+
if (preflight.target === 'local') {
|
|
211
|
+
const targetRoot = path_1.default.dirname(path_1.default.dirname(preflight.targetPath));
|
|
212
|
+
await (0, config_write_target_1.ensureGitignoreCovers)(targetRoot, !!options.gitignore);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
104
215
|
function loginHostLines(resolved) {
|
|
105
216
|
if (resolved.isDefault) {
|
|
106
|
-
return [
|
|
107
|
-
`Logging into ${resolved.host} (SolidActions Cloud)`,
|
|
108
|
-
' Self-hosted or local dev? Pass --host <url> (or --dev for http://localhost:8000)',
|
|
109
|
-
];
|
|
217
|
+
return [`Logging into ${resolved.host} (SolidActions Cloud)`];
|
|
110
218
|
}
|
|
111
219
|
return [`Host: ${resolved.host}`];
|
|
112
220
|
}
|
|
113
|
-
|
|
114
|
-
* Prompt the user to pick a workspace from an already-fetched list. Auto-
|
|
115
|
-
* selects when there's exactly one. Returns undefined if none exist.
|
|
116
|
-
*/
|
|
117
|
-
async function selectWorkspaceInteractively(workspaces) {
|
|
221
|
+
async function selectWorkspaceInteractively(workspaces, dependencies = {}) {
|
|
118
222
|
if (workspaces.length === 0) {
|
|
119
223
|
console.log(chalk_1.default.yellow('No workspaces found. Create one at your SolidActions dashboard, then run `solidactions workspace set <name>`.'));
|
|
120
224
|
return undefined;
|
|
@@ -128,41 +232,86 @@ async function selectWorkspaceInteractively(workspaces) {
|
|
|
128
232
|
console.log(` ${chalk_1.default.white(`${i + 1}.`)} ${ws.name}`);
|
|
129
233
|
});
|
|
130
234
|
console.log('');
|
|
131
|
-
const rl =
|
|
132
|
-
|
|
133
|
-
|
|
235
|
+
const rl = dependencies.question
|
|
236
|
+
? null
|
|
237
|
+
: readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
238
|
+
const question = dependencies.question ?? (async () => {
|
|
239
|
+
if (!rl || rl.closed)
|
|
240
|
+
return undefined;
|
|
241
|
+
return new Promise((resolve) => {
|
|
242
|
+
let answered = false;
|
|
243
|
+
const onClose = () => {
|
|
244
|
+
if (!answered)
|
|
245
|
+
resolve(undefined);
|
|
246
|
+
};
|
|
247
|
+
rl.once('close', onClose);
|
|
248
|
+
rl.question(chalk_1.default.blue('Enter number: '), (answer) => {
|
|
249
|
+
answered = true;
|
|
250
|
+
rl.removeListener('close', onClose);
|
|
251
|
+
resolve(answer);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
134
254
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
255
|
+
try {
|
|
256
|
+
while (true) {
|
|
257
|
+
const answer = await question();
|
|
258
|
+
if (answer === undefined) {
|
|
259
|
+
console.log(chalk_1.default.yellow('Workspace selection cancelled. Run `solidactions workspace list`, then '
|
|
260
|
+
+ '`solidactions workspace set <name>` when ready.'));
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
const index = parseInt(answer, 10) - 1;
|
|
264
|
+
if (!isNaN(index) && index >= 0 && index < workspaces.length) {
|
|
265
|
+
return workspaces[index];
|
|
266
|
+
}
|
|
267
|
+
console.error(chalk_1.default.red('Invalid selection. Enter one of the numbers shown.'));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
rl?.close();
|
|
140
272
|
}
|
|
141
|
-
return workspaces[index];
|
|
142
273
|
}
|
|
143
274
|
/**
|
|
144
|
-
* Shared tail of
|
|
145
|
-
*
|
|
146
|
-
*
|
|
275
|
+
* Shared tail of API-key and device login: resolve the workspace against an
|
|
276
|
+
* already-fetched list, persist the final config, and print success output.
|
|
277
|
+
* Device login passes its already-written, preflighted destination.
|
|
147
278
|
*/
|
|
148
|
-
async function completeLogin(config, workspaces, options, scope = null) {
|
|
279
|
+
async function completeLogin(config, workspaces, options, scope = null, preflight = null) {
|
|
149
280
|
// Device-flow tokens carry a scope (mode + workspace_ids) that later
|
|
150
281
|
// gates `workspace set`; absent for user-scoped Sanctum PATs.
|
|
151
282
|
if (scope) {
|
|
152
283
|
config.scopeMode = scope.mode;
|
|
153
284
|
config.scopedWorkspaceIds = scope.workspace_ids;
|
|
154
285
|
}
|
|
155
|
-
//
|
|
286
|
+
// Resolve the workspace. Device login has already persisted its base
|
|
287
|
+
// credential; API-key login still resolves before its first write.
|
|
156
288
|
if (options.workspace) {
|
|
157
289
|
const match = (0, workspace_lookup_1.matchWorkspace)(options.workspace, workspaces);
|
|
158
290
|
if (!match) {
|
|
159
|
-
|
|
291
|
+
if (preflight?.credentialPersisted) {
|
|
292
|
+
(0, config_1.writeConfigFile)(preflight.targetPath, config);
|
|
293
|
+
console.error(chalk_1.default.yellow(`Workspace "${options.workspace}" was not found. Authentication was saved to ${preflight.targetPath}.`));
|
|
294
|
+
console.error(chalk_1.default.yellow('Run `solidactions workspace list`, then `solidactions workspace set <name>` to finish setup.'));
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
console.error(chalk_1.default.red(`Workspace "${options.workspace}" not found. Run \`solidactions workspace list\` to list available workspaces.`));
|
|
298
|
+
}
|
|
160
299
|
process.exit(1);
|
|
161
300
|
return;
|
|
162
301
|
}
|
|
163
302
|
config.workspace = match.slug ?? match.name;
|
|
164
303
|
config.workspaceId = match.id;
|
|
165
304
|
}
|
|
305
|
+
else if (workspaces.length === 1) {
|
|
306
|
+
const selected = workspaces[0];
|
|
307
|
+
console.log(chalk_1.default.gray(`Auto-selected workspace: ${selected.name}`));
|
|
308
|
+
config.workspace = selected.slug ?? selected.name;
|
|
309
|
+
config.workspaceId = selected.id;
|
|
310
|
+
}
|
|
311
|
+
else if (workspaces.length === 0) {
|
|
312
|
+
console.log(chalk_1.default.yellow('No workspaces found. Create one at your SolidActions dashboard, then '
|
|
313
|
+
+ 'run `solidactions workspace set <name>`.'));
|
|
314
|
+
}
|
|
166
315
|
else if (process.stdin.isTTY) {
|
|
167
316
|
const selected = await selectWorkspaceInteractively(workspaces);
|
|
168
317
|
if (selected) {
|
|
@@ -171,29 +320,37 @@ async function completeLogin(config, workspaces, options, scope = null) {
|
|
|
171
320
|
}
|
|
172
321
|
}
|
|
173
322
|
else {
|
|
174
|
-
console.log(chalk_1.default.yellow('
|
|
323
|
+
console.log(chalk_1.default.yellow('Multiple workspaces are available, so no workspace was selected. '
|
|
324
|
+
+ 'Run `solidactions workspace list`, then `solidactions workspace set <name>`.'));
|
|
175
325
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const wouldChange = existingRaw !== null && existingRaw.trim() !== JSON.stringify(config, null, 2).trim();
|
|
181
|
-
if (wouldChange) {
|
|
182
|
-
const backupPath = backupPathFor(targetPath);
|
|
183
|
-
const proceed = await (0, config_write_target_1.confirmOverwrite)(targetPath, backupPath);
|
|
184
|
-
if (!proceed) {
|
|
185
|
-
console.log(chalk_1.default.yellow('Aborted. No changes were made.'));
|
|
186
|
-
process.exit(0);
|
|
187
|
-
}
|
|
188
|
-
fs_1.default.copyFileSync(targetPath, backupPath);
|
|
189
|
-
console.log(chalk_1.default.gray(`Backup saved to ${backupPath}`));
|
|
326
|
+
let savedTargetPath;
|
|
327
|
+
if (preflight) {
|
|
328
|
+
savedTargetPath = preflight.targetPath;
|
|
329
|
+
(0, config_1.writeConfigFile)(preflight.targetPath, config);
|
|
190
330
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
331
|
+
else {
|
|
332
|
+
const target = await (0, config_write_target_1.decideWriteTarget)({ local: options.local, global: options.global }, undefined, LOGIN_REFUSAL_MESSAGE);
|
|
333
|
+
const targetPath = (0, config_write_target_1.pathForTarget)(target);
|
|
334
|
+
savedTargetPath = targetPath;
|
|
335
|
+
const existingRaw = fs_1.default.existsSync(targetPath) ? fs_1.default.readFileSync(targetPath, 'utf-8') : null;
|
|
336
|
+
const wouldChange = existingRaw !== null && existingRaw.trim() !== JSON.stringify(config, null, 2).trim();
|
|
337
|
+
if (wouldChange) {
|
|
338
|
+
const backupPath = backupPathFor(targetPath);
|
|
339
|
+
const proceed = await (0, config_write_target_1.confirmOverwrite)(targetPath, backupPath);
|
|
340
|
+
if (!proceed) {
|
|
341
|
+
console.log(chalk_1.default.yellow('Aborted. No changes were made.'));
|
|
342
|
+
process.exit(0);
|
|
343
|
+
}
|
|
344
|
+
fs_1.default.copyFileSync(targetPath, backupPath);
|
|
345
|
+
console.log(chalk_1.default.gray(`Backup saved to ${backupPath}`));
|
|
346
|
+
}
|
|
347
|
+
(0, config_1.writeConfigFile)(targetPath, config);
|
|
348
|
+
if (target === 'local') {
|
|
349
|
+
await (0, config_write_target_1.ensureGitignoreCovers)(process.cwd(), !!options.gitignore);
|
|
350
|
+
}
|
|
194
351
|
}
|
|
195
352
|
console.log(chalk_1.default.green('Logged in successfully!'));
|
|
196
|
-
console.log(chalk_1.default.gray(`Configuration saved to ${
|
|
353
|
+
console.log(chalk_1.default.gray(`Configuration saved to ${savedTargetPath}`));
|
|
197
354
|
console.log('');
|
|
198
355
|
console.log(chalk_1.default.blue('Next step — scaffold a new project (includes AI tooling):'));
|
|
199
356
|
console.log(chalk_1.default.gray(' solidactions init <project-name> Creates ./<project-name>/ with scaffold + AI skills'));
|
|
@@ -0,0 +1,134 @@
|
|
|
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.projectSlugForView = projectSlugForView;
|
|
7
|
+
exports.formatDeploymentRevision = formatDeploymentRevision;
|
|
8
|
+
exports.formatProjectView = formatProjectView;
|
|
9
|
+
exports.projectViewWithConfig = projectViewWithConfig;
|
|
10
|
+
exports.projectView = projectView;
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const api_1 = require("../utils/api");
|
|
14
|
+
const slug_1 = require("../utils/slug");
|
|
15
|
+
const source_provenance_1 = require("../utils/source-provenance");
|
|
16
|
+
function projectSlugForView(project, environment) {
|
|
17
|
+
if (environment === undefined) {
|
|
18
|
+
return project;
|
|
19
|
+
}
|
|
20
|
+
if (!['production', 'staging', 'dev'].includes(environment)) {
|
|
21
|
+
throw new Error('Environment must be production, staging, or dev.');
|
|
22
|
+
}
|
|
23
|
+
return environment === 'production'
|
|
24
|
+
? project
|
|
25
|
+
: (0, slug_1.buildProjectSlug)(project, environment);
|
|
26
|
+
}
|
|
27
|
+
function metadataSourceLabel(source) {
|
|
28
|
+
const labels = {
|
|
29
|
+
git: 'Git',
|
|
30
|
+
github_actions: 'GitHub Actions',
|
|
31
|
+
gitlab_ci: 'GitLab CI',
|
|
32
|
+
circleci: 'CircleCI',
|
|
33
|
+
bitbucket_pipelines: 'Bitbucket Pipelines',
|
|
34
|
+
};
|
|
35
|
+
const safe = (0, source_provenance_1.sanitizeDisplayText)(source, 32);
|
|
36
|
+
return safe ? labels[safe] ?? safe : null;
|
|
37
|
+
}
|
|
38
|
+
function formatDeploymentRevision(deployment) {
|
|
39
|
+
const sha = (0, source_provenance_1.sanitizeDisplayText)(deployment.short_sha, 16)
|
|
40
|
+
?? (0, source_provenance_1.sanitizeDisplayText)(deployment.commit_sha, 64);
|
|
41
|
+
if (!sha) {
|
|
42
|
+
const archiveHash = (0, source_provenance_1.sanitizeDisplayText)(deployment.source_hash, 64);
|
|
43
|
+
return [
|
|
44
|
+
'No source revision was reported.',
|
|
45
|
+
...(archiveHash ? [`Archive: ${archiveHash}`] : []),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
const lines = [
|
|
49
|
+
`Revision (Client-reported): ${(0, source_provenance_1.formatRevisionSummary)(deployment)}`,
|
|
50
|
+
];
|
|
51
|
+
const source = metadataSourceLabel(deployment.metadata_source);
|
|
52
|
+
if (source) {
|
|
53
|
+
lines.push(`Source: ${source}`);
|
|
54
|
+
}
|
|
55
|
+
const branch = (0, source_provenance_1.sanitizeDisplayText)(deployment.branch, 255);
|
|
56
|
+
const tag = (0, source_provenance_1.sanitizeDisplayText)(deployment.tag, 255);
|
|
57
|
+
if (branch) {
|
|
58
|
+
lines.push(`Branch: ${branch}`);
|
|
59
|
+
}
|
|
60
|
+
if (tag) {
|
|
61
|
+
lines.push(`Tag: ${tag}`);
|
|
62
|
+
}
|
|
63
|
+
const subject = (0, source_provenance_1.sanitizeDisplayText)(deployment.commit_subject, 500);
|
|
64
|
+
const authorDate = (0, source_provenance_1.sanitizeDisplayText)(deployment.commit_author_date, 40);
|
|
65
|
+
// Defense in depth: sanitizeRemoteUrl already strips credentials at
|
|
66
|
+
// collection time (source-provenance.ts), but a legacy or unnormalized
|
|
67
|
+
// server response could still carry them, so re-sanitize at this display
|
|
68
|
+
// boundary too — remote_url must never reach the terminal with a token.
|
|
69
|
+
const remote = (0, source_provenance_1.sanitizeRemoteUrl)((0, source_provenance_1.sanitizeDisplayText)(deployment.remote_url, 2048) ?? undefined);
|
|
70
|
+
if (subject) {
|
|
71
|
+
lines.push(`Subject: ${subject}`);
|
|
72
|
+
}
|
|
73
|
+
if (authorDate) {
|
|
74
|
+
lines.push(`Author date: ${authorDate}`);
|
|
75
|
+
}
|
|
76
|
+
if (remote) {
|
|
77
|
+
lines.push(`Remote: ${remote}`);
|
|
78
|
+
}
|
|
79
|
+
return lines;
|
|
80
|
+
}
|
|
81
|
+
function formatProjectView(project) {
|
|
82
|
+
const slug = (0, source_provenance_1.sanitizeDisplayText)(project.slug ?? project.name, 255) ?? 'unknown';
|
|
83
|
+
const status = (0, source_provenance_1.sanitizeDisplayText)(project.status, 64) ?? 'unknown';
|
|
84
|
+
const lines = [`Project: ${slug}`, `Status: ${status}`];
|
|
85
|
+
const deployment = project.latest_successful_deployment ?? null;
|
|
86
|
+
if (!project.deployed_hash && !deployment) {
|
|
87
|
+
lines.push('No deployment provenance recorded (deployed before tracking).');
|
|
88
|
+
return lines;
|
|
89
|
+
}
|
|
90
|
+
if (project.deployment_matches_deployed_hash !== true || !deployment) {
|
|
91
|
+
lines.push('Revision unknown for the running build.');
|
|
92
|
+
return lines;
|
|
93
|
+
}
|
|
94
|
+
lines.push(...formatDeploymentRevision(deployment));
|
|
95
|
+
return lines;
|
|
96
|
+
}
|
|
97
|
+
async function projectViewWithConfig(project, options, config, writeLine = console.log) {
|
|
98
|
+
let slug;
|
|
99
|
+
try {
|
|
100
|
+
slug = projectSlugForView(project, options.env);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error(chalk_1.default.red(error.message));
|
|
104
|
+
process.exit(1);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${encodeURIComponent(slug)}?include=deployment`, { headers: (0, api_1.getApiHeaders)(config) });
|
|
109
|
+
for (const line of formatProjectView(response.data)) {
|
|
110
|
+
writeLine(line);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error.response?.status === 401) {
|
|
115
|
+
console.error(chalk_1.default.red('Authentication failed. Run "solidactions login --global" to re-configure.'));
|
|
116
|
+
}
|
|
117
|
+
else if (error.response?.status === 404) {
|
|
118
|
+
const message = (0, source_provenance_1.sanitizeDisplayText)(error.response.data?.message, 500)
|
|
119
|
+
?? `Project "${slug}" not found.`;
|
|
120
|
+
console.error(chalk_1.default.red(message));
|
|
121
|
+
}
|
|
122
|
+
else if (error.response) {
|
|
123
|
+
console.error(chalk_1.default.red(`Failed to view project: ${error.response.status}`));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.error(chalk_1.default.red('Connection failed:'), error.message);
|
|
127
|
+
}
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function projectView(project, options) {
|
|
132
|
+
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
133
|
+
await projectViewWithConfig(project, options, config);
|
|
134
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const init_1 = require("./commands/init");
|
|
|
45
45
|
const pull_1 = require("./commands/pull");
|
|
46
46
|
const project_list_1 = require("./commands/project-list");
|
|
47
47
|
const project_create_1 = require("./commands/project-create");
|
|
48
|
+
const project_view_1 = require("./commands/project-view");
|
|
48
49
|
const project_logs_1 = require("./commands/project-logs");
|
|
49
50
|
const run_start_1 = require("./commands/run-start");
|
|
50
51
|
const run_list_1 = require("./commands/run-list");
|
|
@@ -54,6 +55,7 @@ const env_delete_1 = require("./commands/env-delete");
|
|
|
54
55
|
const env_map_1 = require("./commands/env-map");
|
|
55
56
|
const env_pull_1 = require("./commands/env-pull");
|
|
56
57
|
const env_push_1 = require("./commands/env-push");
|
|
58
|
+
const env_reset_1 = require("./commands/env-reset");
|
|
57
59
|
const env_set_1 = require("./commands/env-set");
|
|
58
60
|
const schedule_set_1 = require("./commands/schedule-set");
|
|
59
61
|
const schedule_list_1 = require("./commands/schedule-list");
|
|
@@ -67,6 +69,7 @@ const oauth_action_search_1 = require("./commands/oauth-action-search");
|
|
|
67
69
|
const oauth_action_list_1 = require("./commands/oauth-action-list");
|
|
68
70
|
const oauth_action_view_1 = require("./commands/oauth-action-view");
|
|
69
71
|
const oauth_action_platforms_1 = require("./commands/oauth-action-platforms");
|
|
72
|
+
const connection_list_1 = require("./commands/connection-list");
|
|
70
73
|
const workspaces_1 = require("./commands/workspaces");
|
|
71
74
|
const skill_push_1 = require("./commands/skill-push");
|
|
72
75
|
const skill_publish_1 = require("./commands/skill-publish");
|
|
@@ -145,9 +148,9 @@ program
|
|
|
145
148
|
.argument('[api-key]', 'Legacy positional API key (prefer the masked prompt, --stdin, or --device)')
|
|
146
149
|
.option('--stdin', 'Read the API key from stdin (for non-interactive automation)')
|
|
147
150
|
.option('--device', 'Authenticate via browser using OAuth device authorization')
|
|
148
|
-
.
|
|
149
|
-
.
|
|
150
|
-
.option('--workspace <name-or-id>', 'Set workspace by name, slug, or ID
|
|
151
|
+
.addOption(new commander_1.Option('--dev', 'Use local development server (http://localhost:8000)').hideHelp())
|
|
152
|
+
.addOption(new commander_1.Option('--host <url>', 'Custom API host URL').hideHelp())
|
|
153
|
+
.option('--workspace <name-or-id>', 'Set workspace by name, slug, or ID. A sole workspace is auto-selected; use --workspace to choose among multiple workspaces.')
|
|
151
154
|
.option('--local', 'Save config to ./.solidactions/config.json in the current folder')
|
|
152
155
|
.option('--global', 'Save config to ~/.solidactions/config.json (default if prompted)')
|
|
153
156
|
.option('--gitignore', 'With --local, add .solidactions/ to .gitignore without prompting')
|
|
@@ -205,6 +208,19 @@ program
|
|
|
205
208
|
// project <subcommand>
|
|
206
209
|
// =============================================================================
|
|
207
210
|
const project = program.command('project').description('Manage projects');
|
|
211
|
+
project
|
|
212
|
+
.command('view')
|
|
213
|
+
.description('View project status and the client-reported deployed revision')
|
|
214
|
+
.argument('<project>', 'Exact project slug (or project family/name when --env is explicit)')
|
|
215
|
+
.option('-e, --env <environment>', 'Resolve an explicit environment (production/staging/dev)')
|
|
216
|
+
.addHelpText('after', `
|
|
217
|
+
Without --env, <project> is used as an exact slug. With --env production it is
|
|
218
|
+
used unchanged; staging/dev use the same "-<env>" suffix rule as deploy.
|
|
219
|
+
Unlike historical commands such as \`run start\`, project view has no implicit
|
|
220
|
+
dev environment default.`)
|
|
221
|
+
.action(async (projectName, options) => {
|
|
222
|
+
await (0, project_view_1.projectView)(projectName, options);
|
|
223
|
+
});
|
|
208
224
|
project
|
|
209
225
|
.command('create')
|
|
210
226
|
.description('Create an empty project (and environment) without deploying source')
|
|
@@ -223,6 +239,7 @@ project
|
|
|
223
239
|
.option('--config-only', 'Sync YAML env declarations without building/deploying')
|
|
224
240
|
.option('--no-cache', 'Force a fresh build, bypassing all build caches')
|
|
225
241
|
.option('--force-rebuild', 'Force a fresh build, bypassing all build caches (alias for --no-cache)')
|
|
242
|
+
.option('--no-git-metadata', 'Do not transmit Git provenance (branch, commit subject, and sanitized remote repository URL; credentials are stripped); also available as SOLIDACTIONS_NO_GIT_METADATA=1')
|
|
226
243
|
.action((projectName, path, options) => {
|
|
227
244
|
// Commander's negation convention maps --no-cache to options.cache === false
|
|
228
245
|
// (NOT options.noCache). Normalize both flags to a single boolean.
|
|
@@ -311,6 +328,7 @@ env
|
|
|
311
328
|
.argument('[value]', 'Variable value (when first arg is project)')
|
|
312
329
|
.option('-s, --secret', 'Mark as encrypted secret')
|
|
313
330
|
.option('-e, --env <environment>', 'Target environment (production/staging/dev)', 'dev')
|
|
331
|
+
.option('--oauth-connection <name>', 'Bind the project key to an OAuth connection')
|
|
314
332
|
.option('--global', 'Set a global variable (no project) — required for the 2-arg form')
|
|
315
333
|
.option('--staging-value <value>', 'Staging environment value (global only)')
|
|
316
334
|
.option('--dev-value <value>', 'Dev environment value (global only)')
|
|
@@ -340,6 +358,16 @@ env
|
|
|
340
358
|
.action((keyOrProject, key, options) => {
|
|
341
359
|
(0, env_delete_1.envDelete)(keyOrProject, key, options);
|
|
342
360
|
});
|
|
361
|
+
env
|
|
362
|
+
.command('reset')
|
|
363
|
+
.description('Reset a project variable mapping to its YAML-declared source')
|
|
364
|
+
.argument('<project>', 'Project name')
|
|
365
|
+
.argument('<KEY>', 'Variable key')
|
|
366
|
+
.allowExcessArguments(false)
|
|
367
|
+
.option('-e, --env <environment>', 'Environment to reset in', 'dev')
|
|
368
|
+
.action(async (projectName, key, options) => {
|
|
369
|
+
await (0, env_reset_1.envReset)(projectName, key, options);
|
|
370
|
+
});
|
|
343
371
|
env
|
|
344
372
|
.command('map')
|
|
345
373
|
.description('Map a global variable to a project-specific key')
|
|
@@ -536,6 +564,16 @@ oauthActionCmd
|
|
|
536
564
|
(0, oauth_action_platforms_1.oauthActionPlatforms)(options);
|
|
537
565
|
});
|
|
538
566
|
// =============================================================================
|
|
567
|
+
// connection <subcommand>
|
|
568
|
+
// =============================================================================
|
|
569
|
+
const connection = program.command('connection').description('Manage OAuth connections');
|
|
570
|
+
connection
|
|
571
|
+
.command('list')
|
|
572
|
+
.description('List OAuth connections in the active workspace')
|
|
573
|
+
.action(() => {
|
|
574
|
+
(0, connection_list_1.connectionList)();
|
|
575
|
+
});
|
|
576
|
+
// =============================================================================
|
|
539
577
|
// ai <subcommand>
|
|
540
578
|
// =============================================================================
|
|
541
579
|
const ai = program.command('ai').description('AI helper tools');
|