@solidactions/cli 3.30.0 → 3.32.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/dist/command-manifest.json +1 -1
- package/dist/commands/deploy.js +49 -9
- package/dist/commands/pull.js +8 -1
- package/dist/commands/webhook-list.js +9 -4
- package/dist/commands/webhook-secret.js +20 -11
- package/dist/utils/deploy-ignore.js +2 -1
- package/dist/utils/sandbox-base.js +63 -0
- package/dist/utils/webhook-formatters.js +30 -5
- package/package.json +1 -1
package/dist/commands/deploy.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.PLAN_LIMIT_NON_INTERACTIVE_HINT = exports.SKILLS_TIP_LINES = void 0;
|
|
6
|
+
exports.PLAN_LIMIT_NON_INTERACTIVE_HINT = exports.SKILLS_TIP_LINES = exports.archiveMd5 = void 0;
|
|
7
7
|
exports.validateProject = validateProject;
|
|
8
8
|
exports.cacheBusterEntry = cacheBusterEntry;
|
|
9
9
|
exports.projectStatusUrl = projectStatusUrl;
|
|
@@ -34,6 +34,7 @@ const functions_sync_1 = require("../utils/functions-sync");
|
|
|
34
34
|
const api_1 = require("../utils/api");
|
|
35
35
|
const host_display_1 = require("../utils/host-display");
|
|
36
36
|
const deploy_ignore_1 = require("../utils/deploy-ignore");
|
|
37
|
+
const sandbox_base_1 = require("../utils/sandbox-base");
|
|
37
38
|
const slug_1 = require("../utils/slug");
|
|
38
39
|
const project_ref_1 = require("../utils/project-ref");
|
|
39
40
|
const skills_1 = require("../utils/skills");
|
|
@@ -41,6 +42,7 @@ const tar_archive_1 = require("../utils/tar-archive");
|
|
|
41
42
|
const deploy_status_poll_1 = require("../utils/deploy-status-poll");
|
|
42
43
|
const source_provenance_1 = require("../utils/source-provenance");
|
|
43
44
|
const project_view_1 = require("./project-view");
|
|
45
|
+
exports.archiveMd5 = null;
|
|
44
46
|
/** Printed when a deploy target has no SolidActions skill files installed. */
|
|
45
47
|
exports.SKILLS_TIP_LINES = [
|
|
46
48
|
'Tip: no SolidActions skill files found (.claude/skills/solidactions-*). Your AI assistant',
|
|
@@ -288,7 +290,7 @@ function formatSyncYamlWarnings(warnings) {
|
|
|
288
290
|
* (PM round #1127 finding 14: a failed sync must never be reported as
|
|
289
291
|
* success by the caller).
|
|
290
292
|
*/
|
|
291
|
-
async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
|
|
293
|
+
async function pushYamlDeclarations(config, projectSlug, yamlConfig, baseSourceHash) {
|
|
292
294
|
const parsedVars = (0, env_1.parseYamlEnvVars)(yamlConfig);
|
|
293
295
|
// Build the declarations array
|
|
294
296
|
const declarations = parsedVars.map(v => ({
|
|
@@ -299,7 +301,7 @@ async function pushYamlDeclarations(config, projectSlug, yamlConfig) {
|
|
|
299
301
|
yaml_default_docs_path: v.docsPath,
|
|
300
302
|
source: 'yaml',
|
|
301
303
|
}));
|
|
302
|
-
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations }, {
|
|
304
|
+
const response = await axios_1.default.post(`${config.host}/api/v1/projects/${projectSlug}/variable-mappings/sync-yaml`, { declarations, ...(baseSourceHash !== undefined ? { base_source_hash: baseSourceHash } : {}) }, {
|
|
303
305
|
headers: (0, api_1.getApiHeaders)(config, 'application/json'),
|
|
304
306
|
});
|
|
305
307
|
// Non-fatal: a warning means a declared resource doesn't exist in the
|
|
@@ -591,6 +593,10 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
591
593
|
process.exit(1);
|
|
592
594
|
}
|
|
593
595
|
}
|
|
596
|
+
const base = (0, sandbox_base_1.readSandboxBase)(sourceDir);
|
|
597
|
+
const guardedBase = base?.slug === projectSlug ? base : null;
|
|
598
|
+
const guardedBaseWire = guardedBase ? (0, sandbox_base_1.baseWireValue)(guardedBase) : null;
|
|
599
|
+
const staleBaseLine = () => `The dev copy moved since you pulled. Run "solidactions project pull ${projectSlug} . --yes" and redo your change.`;
|
|
594
600
|
// --config-only: sync YAML env declarations without building
|
|
595
601
|
if (options.configOnly) {
|
|
596
602
|
if (!yamlConfig) {
|
|
@@ -598,10 +604,13 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
598
604
|
process.exit(1);
|
|
599
605
|
}
|
|
600
606
|
try {
|
|
601
|
-
await pushYamlDeclarations(config, projectSlug, yamlConfig);
|
|
607
|
+
await pushYamlDeclarations(config, projectSlug, yamlConfig, guardedBaseWire ?? undefined);
|
|
602
608
|
}
|
|
603
609
|
catch (error) {
|
|
604
|
-
if (error.response?.status ===
|
|
610
|
+
if (error.response?.status === 409 && error.response.data?.code === 'stale_base') {
|
|
611
|
+
console.error(chalk_1.default.red(staleBaseLine()));
|
|
612
|
+
}
|
|
613
|
+
else if (error.response?.status === 401) {
|
|
605
614
|
console.error(chalk_1.default.red((0, api_1.authFailedLine)(config.host)));
|
|
606
615
|
}
|
|
607
616
|
else {
|
|
@@ -648,7 +657,13 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
648
657
|
process.exit(1);
|
|
649
658
|
}
|
|
650
659
|
const functionsPayload = (0, functions_sync_1.buildFunctionsSyncPayload)(functionFiles, functionSources, codeRef);
|
|
660
|
+
if (guardedBaseWire !== null)
|
|
661
|
+
functionsPayload.base_source_hash = guardedBaseWire;
|
|
651
662
|
const functionsResult = await (0, functions_sync_1.syncFunctions)(config, projectSlug, functionsPayload);
|
|
663
|
+
if (functionsResult.httpStatus === 409 && functionsResult.body?.code === 'stale_base') {
|
|
664
|
+
console.error(chalk_1.default.red(staleBaseLine()));
|
|
665
|
+
process.exit(1);
|
|
666
|
+
}
|
|
652
667
|
const functionRows = functionsResult.body?.functions ?? [];
|
|
653
668
|
const retiredFunctions = functionsResult.body?.retired ?? [];
|
|
654
669
|
const retireErrors = functionsResult.body?.retire_errors ?? [];
|
|
@@ -703,9 +718,6 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
703
718
|
const outcome = (0, functions_sync_1.joinSyncOutcomes)(functionsOutcome, pagesOutcome);
|
|
704
719
|
process.exit((0, pages_sync_1.terminalExitCode)({ buildFailed, yamlSyncFailed, outcome }));
|
|
705
720
|
};
|
|
706
|
-
if (!yamlConfig?.workflows) {
|
|
707
|
-
return finishDeploy({ deploymentId: null, buildFailed: false });
|
|
708
|
-
}
|
|
709
721
|
// Plan the file list BEFORE creating the archive write stream so a walk error
|
|
710
722
|
// (permission error, unreadable dir) aborts cleanly with no orphan tarball.
|
|
711
723
|
let plan;
|
|
@@ -743,7 +755,19 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
743
755
|
output.on('close', async () => {
|
|
744
756
|
console.log(chalk_1.default.gray(`Archived ${archive.pointer()} total bytes`));
|
|
745
757
|
try {
|
|
758
|
+
const hash = (0, crypto_1.createHash)('md5');
|
|
759
|
+
for await (const chunk of fs_1.default.createReadStream(archivePath)) {
|
|
760
|
+
hash.update(chunk);
|
|
761
|
+
}
|
|
762
|
+
const uploadedArchiveMd5 = hash.digest('hex');
|
|
763
|
+
exports.archiveMd5 = uploadedArchiveMd5;
|
|
746
764
|
const form = (0, source_provenance_1.buildDeployForm)(archivePath, sourceMetadata);
|
|
765
|
+
if (guardedBaseWire !== null) {
|
|
766
|
+
form.append('base_source_hash', guardedBaseWire);
|
|
767
|
+
}
|
|
768
|
+
if (!yamlConfig?.workflows) {
|
|
769
|
+
form.append('build', '0');
|
|
770
|
+
}
|
|
747
771
|
if (options.paused) {
|
|
748
772
|
form.append('paused', '1');
|
|
749
773
|
}
|
|
@@ -759,6 +783,19 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
759
783
|
maxContentLength: Infinity,
|
|
760
784
|
maxBodyLength: Infinity
|
|
761
785
|
});
|
|
786
|
+
if (guardedBase) {
|
|
787
|
+
if (deployResponse.data?.source_hash === uploadedArchiveMd5) {
|
|
788
|
+
(0, sandbox_base_1.writeSandboxBase)(sourceDir, { source_hash: uploadedArchiveMd5, slug: guardedBase.slug, restored_at: new Date().toISOString() });
|
|
789
|
+
}
|
|
790
|
+
else {
|
|
791
|
+
console.log(chalk_1.default.yellow('The server stored different bytes than this deploy uploaded; base.json was left unchanged.'));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (!yamlConfig?.workflows) {
|
|
795
|
+
console.log(chalk_1.default.green('Source archived.'));
|
|
796
|
+
cleanupArchive();
|
|
797
|
+
return await finishDeploy({ deploymentId: null, buildFailed: false });
|
|
798
|
+
}
|
|
762
799
|
const acceptedDeployment = (0, source_provenance_1.parseDeployAcceptance)(deployResponse.data);
|
|
763
800
|
if (acceptedDeployment.sourceMetadataRejected) {
|
|
764
801
|
console.log(chalk_1.default.yellow(`Warning: optional source metadata was not accepted (${acceptedDeployment.sourceMetadataRejected}); deployment continues.`));
|
|
@@ -837,7 +874,10 @@ async function deploy(projectName, sourcePath, options = {}) {
|
|
|
837
874
|
catch (error) {
|
|
838
875
|
console.error(chalk_1.default.red('Deployment failed:'));
|
|
839
876
|
if (error.response) {
|
|
840
|
-
if (error.response.status ===
|
|
877
|
+
if (error.response.status === 409 && error.response.data?.code === 'stale_base') {
|
|
878
|
+
console.error(chalk_1.default.red(staleBaseLine()));
|
|
879
|
+
}
|
|
880
|
+
else if (error.response.status === 404) {
|
|
841
881
|
console.error("Project not found.");
|
|
842
882
|
}
|
|
843
883
|
else if (error.response.status === 401) {
|
package/dist/commands/pull.js
CHANGED
|
@@ -15,6 +15,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
15
15
|
const prompts_1 = __importDefault(require("prompts"));
|
|
16
16
|
const api_1 = require("../utils/api");
|
|
17
17
|
const project_ref_1 = require("../utils/project-ref");
|
|
18
|
+
const sandbox_base_1 = require("../utils/sandbox-base");
|
|
18
19
|
async function pull(projectName, destPath, options = {}) {
|
|
19
20
|
const config = await (0, api_1.requireConfigWithWorkspace)();
|
|
20
21
|
const destination = destPath ? path_1.default.resolve(destPath) : process.cwd();
|
|
@@ -61,9 +62,15 @@ async function pull(projectName, destPath, options = {}) {
|
|
|
61
62
|
// version of the `tar` package).
|
|
62
63
|
filter: (entryPath) => {
|
|
63
64
|
const top = entryPath.split('/')[0];
|
|
64
|
-
|
|
65
|
+
// Belt and braces with the server strip: never lay the
|
|
66
|
+
// server-managed .solidactions/ down, at any depth.
|
|
67
|
+
return top === 'tenantcode' && !/\/sa-nocache-[0-9a-f-]+$/.test(entryPath) && !entryPath.split('/').includes('.solidactions');
|
|
65
68
|
},
|
|
66
69
|
}));
|
|
70
|
+
const sourceHash = response.headers['x-source-hash'];
|
|
71
|
+
if ((0, sandbox_base_1.isAppSandbox)() && typeof sourceHash === 'string') {
|
|
72
|
+
(0, sandbox_base_1.writeSandboxBase)(destination, { source_hash: sourceHash, slug: projectSlug, restored_at: new Date().toISOString() });
|
|
73
|
+
}
|
|
67
74
|
console.log(chalk_1.default.green(`Project "${projectName}" pulled successfully!`));
|
|
68
75
|
}
|
|
69
76
|
catch (error) {
|
|
@@ -3,12 +3,20 @@ 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.webhookListParams = webhookListParams;
|
|
6
7
|
exports.webhookList = webhookList;
|
|
7
8
|
const axios_1 = __importDefault(require("axios"));
|
|
8
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
const api_1 = require("../utils/api");
|
|
10
11
|
const project_ref_1 = require("../utils/project-ref");
|
|
11
12
|
const webhook_formatters_1 = require("../utils/webhook-formatters");
|
|
13
|
+
function webhookListParams(options) {
|
|
14
|
+
const params = { include: 'functions' };
|
|
15
|
+
if (options.showSecrets) {
|
|
16
|
+
params.show_secrets = 'true';
|
|
17
|
+
}
|
|
18
|
+
return params;
|
|
19
|
+
}
|
|
12
20
|
async function webhookList(projectName, options = {}) {
|
|
13
21
|
const format = options.format ?? 'table';
|
|
14
22
|
if (format !== 'table' && format !== 'json') {
|
|
@@ -22,10 +30,7 @@ async function webhookList(projectName, options = {}) {
|
|
|
22
30
|
}
|
|
23
31
|
try {
|
|
24
32
|
const projectSlug = await (0, project_ref_1.resolveProjectSlug)(config, projectName, environment);
|
|
25
|
-
const params =
|
|
26
|
-
if (options.showSecrets) {
|
|
27
|
-
params.show_secrets = 'true';
|
|
28
|
-
}
|
|
33
|
+
const params = webhookListParams(options);
|
|
29
34
|
const response = await axios_1.default.get(`${config.host}/api/v1/projects/${projectSlug}/webhooks`, {
|
|
30
35
|
headers: (0, api_1.getApiHeaders)(config),
|
|
31
36
|
params,
|
|
@@ -4,24 +4,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.formatSecretOutput = formatSecretOutput;
|
|
7
|
+
exports.formatSecretJson = formatSecretJson;
|
|
7
8
|
exports.webhookSecret = webhookSecret;
|
|
8
9
|
const axios_1 = __importDefault(require("axios"));
|
|
9
10
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
11
|
const api_1 = require("../utils/api");
|
|
11
12
|
const project_ref_1 = require("../utils/project-ref");
|
|
13
|
+
function workflowRowsOnly(rows) {
|
|
14
|
+
return rows.filter((r) => r.kind !== 'function');
|
|
15
|
+
}
|
|
12
16
|
function formatSecretOutput(rows, workflowFilter) {
|
|
17
|
+
const workflows = workflowRowsOnly(rows);
|
|
13
18
|
if (workflowFilter) {
|
|
14
|
-
const match =
|
|
19
|
+
const match = workflows.find((r) => r.workflow_name === workflowFilter);
|
|
15
20
|
if (!match)
|
|
16
21
|
return `No webhook named "${workflowFilter}" found.`;
|
|
17
22
|
return match.webhook_secret ?? '(secret not returned — check your access level)';
|
|
18
23
|
}
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
24
|
+
if (workflows.length === 1) {
|
|
25
|
+
return workflows[0].webhook_secret ?? '(secret not returned — check your access level)';
|
|
21
26
|
}
|
|
22
|
-
const lines =
|
|
27
|
+
const lines = workflows.map((r) => `${(r.workflow_name ?? '?').padEnd(32)}${r.webhook_secret ?? '(none)'}`);
|
|
23
28
|
return ['WORKFLOW'.padEnd(32) + 'SECRET', '-'.repeat(80), ...lines].join('\n');
|
|
24
29
|
}
|
|
30
|
+
function formatSecretJson(rows, workflowFilter) {
|
|
31
|
+
const workflows = workflowRowsOnly(rows);
|
|
32
|
+
const out = workflowFilter
|
|
33
|
+
? workflows
|
|
34
|
+
.filter((r) => r.workflow_name === workflowFilter)
|
|
35
|
+
.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }))
|
|
36
|
+
: workflows.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }));
|
|
37
|
+
return JSON.stringify(out, null, 2);
|
|
38
|
+
}
|
|
25
39
|
async function webhookSecret(projectName, options = {}) {
|
|
26
40
|
const format = options.format ?? 'text';
|
|
27
41
|
if (format !== 'text' && format !== 'json') {
|
|
@@ -39,18 +53,13 @@ async function webhookSecret(projectName, options = {}) {
|
|
|
39
53
|
headers: (0, api_1.getApiHeaders)(config),
|
|
40
54
|
params: { show_secrets: 'true' },
|
|
41
55
|
});
|
|
42
|
-
const rows = response.data.data ?? [];
|
|
56
|
+
const rows = workflowRowsOnly(response.data.data ?? []);
|
|
43
57
|
if (rows.length === 0) {
|
|
44
58
|
console.error(chalk_1.default.yellow(`No webhook workflows found for project "${projectName}"${environment !== 'production' ? ` (${environment})` : ''}.`));
|
|
45
59
|
process.exit(1);
|
|
46
60
|
}
|
|
47
61
|
if (format === 'json') {
|
|
48
|
-
|
|
49
|
-
? rows
|
|
50
|
-
.filter((r) => r.workflow_name === options.workflow)
|
|
51
|
-
.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }))
|
|
52
|
-
: rows.map((r) => ({ workflow: r.workflow_name, secret: r.webhook_secret }));
|
|
53
|
-
console.log(JSON.stringify(out, null, 2));
|
|
62
|
+
console.log(formatSecretJson(rows, options.workflow));
|
|
54
63
|
return;
|
|
55
64
|
}
|
|
56
65
|
console.log(formatSecretOutput(rows, options.workflow));
|
|
@@ -33,10 +33,11 @@ exports.DEFAULT_DEPLOY_IGNORES = [
|
|
|
33
33
|
* re-includable by any matcher negation. Covers:
|
|
34
34
|
* - `.env` and any `.env.*` (secret-leak fix). Anchored so `.envrc` and
|
|
35
35
|
* `environment.ts` do NOT match.
|
|
36
|
+
* - `.solidactions` (local CLI state at any depth).
|
|
36
37
|
* - `.steps-deploy.tar.gz` / `.steps-deploy.zip` (our own deploy artifacts,
|
|
37
38
|
* written into sourceDir while we walk).
|
|
38
39
|
*/
|
|
39
|
-
exports.HARD_DENY_BASENAMES = /^(?:\.env(?:$|\..*)|\.steps-deploy\.(?:tar\.gz|zip))$/;
|
|
40
|
+
exports.HARD_DENY_BASENAMES = /^(?:\.env(?:$|\..*)|\.solidactions|\.steps-deploy\.(?:tar\.gz|zip))$/;
|
|
40
41
|
/**
|
|
41
42
|
* True if a path is hard-denied (Layer 1). Checked before the matcher so that
|
|
42
43
|
* no `!` negation in deploy.exclude or .gitignore can re-include it.
|
|
@@ -0,0 +1,63 @@
|
|
|
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.SANDBOX_BASE_PATH = void 0;
|
|
7
|
+
exports.isAppSandbox = isAppSandbox;
|
|
8
|
+
exports.readSandboxBase = readSandboxBase;
|
|
9
|
+
exports.writeSandboxBase = writeSandboxBase;
|
|
10
|
+
exports.baseWireValue = baseWireValue;
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const crypto_1 = require("crypto");
|
|
14
|
+
exports.SANDBOX_BASE_PATH = path_1.default.join('.solidactions', 'base.json');
|
|
15
|
+
function isAppSandbox(env = process.env) {
|
|
16
|
+
return env.SOLIDACTIONS_APP_SANDBOX === '1';
|
|
17
|
+
}
|
|
18
|
+
function readSandboxBase(dir) {
|
|
19
|
+
try {
|
|
20
|
+
const base = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, exports.SANDBOX_BASE_PATH), 'utf8'));
|
|
21
|
+
if (base === null || typeof base !== 'object' || Array.isArray(base))
|
|
22
|
+
return null;
|
|
23
|
+
const candidate = base;
|
|
24
|
+
if (candidate.source_hash !== null && (typeof candidate.source_hash !== 'string' || !/^[a-f0-9]{32}$/i.test(candidate.source_hash)))
|
|
25
|
+
return null;
|
|
26
|
+
if (typeof candidate.slug !== 'string' || candidate.slug.length === 0 || typeof candidate.restored_at !== 'string' || candidate.restored_at.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return { source_hash: candidate.source_hash, slug: candidate.slug, restored_at: candidate.restored_at };
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function writeSandboxBase(dir, base) {
|
|
35
|
+
const target = path_1.default.join(dir, exports.SANDBOX_BASE_PATH);
|
|
36
|
+
fs_1.default.mkdirSync(path_1.default.dirname(target), { recursive: true });
|
|
37
|
+
const temporary = path_1.default.join(path_1.default.dirname(target), `.${path_1.default.basename(target)}.${(0, crypto_1.randomUUID)()}.tmp`);
|
|
38
|
+
let fd;
|
|
39
|
+
let owned = false;
|
|
40
|
+
try {
|
|
41
|
+
fd = fs_1.default.openSync(temporary, 'wx', 0o600);
|
|
42
|
+
owned = true;
|
|
43
|
+
fs_1.default.writeFileSync(fd, JSON.stringify(base));
|
|
44
|
+
fs_1.default.fsyncSync(fd);
|
|
45
|
+
fs_1.default.closeSync(fd);
|
|
46
|
+
fd = undefined;
|
|
47
|
+
fs_1.default.renameSync(temporary, target);
|
|
48
|
+
owned = false;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
try {
|
|
52
|
+
if (fd !== undefined)
|
|
53
|
+
fs_1.default.closeSync(fd);
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
if (owned)
|
|
57
|
+
fs_1.default.unlinkSync(temporary);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function baseWireValue(base) {
|
|
62
|
+
return base.source_hash ?? 'none';
|
|
63
|
+
}
|
|
@@ -12,7 +12,21 @@ const workflow_state_1 = require("./workflow-state");
|
|
|
12
12
|
function columnWidth(min, values) {
|
|
13
13
|
return Math.max(min, ...values.map(v => v.length)) + 2;
|
|
14
14
|
}
|
|
15
|
+
function isFunctionRow(webhook) {
|
|
16
|
+
return webhook.kind === 'function';
|
|
17
|
+
}
|
|
15
18
|
function webhookState(webhook) {
|
|
19
|
+
if (isFunctionRow(webhook)) {
|
|
20
|
+
if (webhook.retired === true)
|
|
21
|
+
return 'retired';
|
|
22
|
+
if (webhook.enabled === false)
|
|
23
|
+
return 'off';
|
|
24
|
+
if (webhook.project_enabled === false)
|
|
25
|
+
return 'blocked (project off)';
|
|
26
|
+
if (webhook.effective_enabled === false)
|
|
27
|
+
return 'not live';
|
|
28
|
+
return 'on';
|
|
29
|
+
}
|
|
16
30
|
return (0, workflow_state_1.workflowEffectiveState)(webhook);
|
|
17
31
|
}
|
|
18
32
|
function colorizeState(state, width) {
|
|
@@ -26,26 +40,30 @@ function colorizeState(state, width) {
|
|
|
26
40
|
return chalk_1.default.gray(padded);
|
|
27
41
|
}
|
|
28
42
|
function formatTable(webhooks, opts) {
|
|
29
|
-
const names = webhooks.map(w => w.workflow_name
|
|
43
|
+
const names = webhooks.map(w => w.name ?? w.workflow_name ?? w.slug ?? w.workflow_slug ?? '?');
|
|
44
|
+
const kinds = webhooks.map(w => w.kind ?? 'workflow');
|
|
30
45
|
const states = webhooks.map(webhookState);
|
|
31
46
|
const urls = webhooks.map(w => w.webhook_path_url || w.webhook_url || '?');
|
|
32
47
|
const nameWidth = columnWidth(30, names);
|
|
48
|
+
const kindWidth = columnWidth(8, kinds);
|
|
33
49
|
const stateWidth = columnWidth(22, states);
|
|
34
50
|
const urlWidth = columnWidth(60, urls);
|
|
35
51
|
const headerPlain = opts.showSecrets
|
|
36
|
-
? '
|
|
37
|
-
: '
|
|
52
|
+
? 'NAME'.padEnd(nameWidth) + 'KIND'.padEnd(kindWidth) + 'STATE'.padEnd(stateWidth) + 'URL'.padEnd(urlWidth) + 'SECRET'
|
|
53
|
+
: 'NAME'.padEnd(nameWidth) + 'KIND'.padEnd(kindWidth) + 'STATE'.padEnd(stateWidth) + 'URL';
|
|
38
54
|
const dividerWidth = opts.showSecrets
|
|
39
|
-
? nameWidth + stateWidth + urlWidth + 64
|
|
40
|
-
: nameWidth + stateWidth + urlWidth;
|
|
55
|
+
? nameWidth + kindWidth + stateWidth + urlWidth + 64
|
|
56
|
+
: nameWidth + kindWidth + stateWidth + urlWidth;
|
|
41
57
|
const lines = [];
|
|
42
58
|
lines.push(chalk_1.default.gray(headerPlain));
|
|
43
59
|
lines.push(chalk_1.default.gray('-'.repeat(dividerWidth)));
|
|
44
60
|
for (let i = 0; i < webhooks.length; i++) {
|
|
45
61
|
const name = names[i];
|
|
62
|
+
const kind = kinds[i];
|
|
46
63
|
const state = states[i];
|
|
47
64
|
const url = urls[i];
|
|
48
65
|
let line = name.padEnd(nameWidth)
|
|
66
|
+
+ kind.padEnd(kindWidth)
|
|
49
67
|
+ colorizeState(state, stateWidth)
|
|
50
68
|
+ chalk_1.default.cyan(url.padEnd(urlWidth));
|
|
51
69
|
if (opts.showSecrets) {
|
|
@@ -58,7 +76,11 @@ function formatTable(webhooks, opts) {
|
|
|
58
76
|
}
|
|
59
77
|
function formatJson(webhooks, opts) {
|
|
60
78
|
const rows = webhooks.map(w => {
|
|
79
|
+
const kind = w.kind ?? 'workflow';
|
|
61
80
|
const base = {
|
|
81
|
+
kind,
|
|
82
|
+
name: w.name ?? w.workflow_name ?? null,
|
|
83
|
+
slug: w.slug ?? w.workflow_slug ?? null,
|
|
62
84
|
workflow: w.workflow_name ?? w.workflow_slug ?? null,
|
|
63
85
|
url: w.webhook_path_url ?? w.webhook_url ?? null,
|
|
64
86
|
state: webhookState(w),
|
|
@@ -67,6 +89,9 @@ function formatJson(webhooks, opts) {
|
|
|
67
89
|
retired: w.retired,
|
|
68
90
|
effective_enabled: w.effective_enabled,
|
|
69
91
|
};
|
|
92
|
+
if (kind === 'function') {
|
|
93
|
+
base.status = w.status ?? null;
|
|
94
|
+
}
|
|
70
95
|
if (opts.showSecrets) {
|
|
71
96
|
base.secret = w.webhook_secret ?? '';
|
|
72
97
|
}
|