@softr/cli 0.1.1-se21216.9 → 0.1.1
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 +2 -2
- package/dist/cli.mjs +29 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ ones. A workflow directory remembers the target it was pulled from.
|
|
|
49
49
|
| `workspaces` | The workspaces the stored token reaches, with your role in each and the default one. Commands that take `--workspace` default to `SOFTR_WORKSPACE_ID` when it is set, else to your only or default workspace. |
|
|
50
50
|
| `integrations [--workspace <id>] [--type <TYPE>]` | List the workspace's connected integrations (id, name, type, account, auth kind) from the studio API; the id goes into a node's `integrationId` input. Inside a workflow directory the workspace is the workflow's; `--type` filters. Credentials are never shown. |
|
|
51
51
|
|
|
52
|
-
Every command accepts `--json`. `SOFTR_TOKEN` overrides the stored token; `SOFTR_WORKSPACE_ID` is the default workspace; `
|
|
52
|
+
Every command accepts `--json`. `SOFTR_TOKEN` overrides the stored token; `SOFTR_WORKSPACE_ID` is the default workspace; `SOFTR_PINNED_APP_ID` pins the workflows `init` creates to that application.
|
|
53
53
|
|
|
54
54
|
## Workflows
|
|
55
55
|
|
|
@@ -136,7 +136,7 @@ node still on 1.0.0 or 1.1.0 keeps its synchronous runtime without `fetch`, and
|
|
|
136
136
|
| `workflows list [--workspace <id>] [--app <id>]` | List the workflows you can access, one table per workspace; `--app` keeps only those linked to that application. A workspace whose listing fails is reported at the end and skipped. |
|
|
137
137
|
| `workflows pull [<workflowId>] [--dir <path>] [--force]` | Download a workflow into a directory (new `./<title-slug>/` by default). Without an id, list what you can pull. |
|
|
138
138
|
| `workflows push [--dir <path>] [--dry-run] [--force]` | Inline `@@` references and code files, save as a new draft. Sends nothing when the files match the last sync, and refuses when the server copy changed since then (`--force` overrides both). Warns about placeholders that no saved test data backs. |
|
|
139
|
-
| `workflows init <title> [--workspace <id>] [--app <id>] [--trigger <TYPE>] [--dir <path>]`
|
|
139
|
+
| `workflows init <title> [--workspace <id>] [--pin-to-app <id>] [--trigger <TYPE>] [--dir <path>]` | Create a workflow on the server with one trigger (default `WEBHOOK`) and the local directory for it; `--pin-to-app` pins it to an application, so the app lists it. |
|
|
140
140
|
| `workflows upgrade [<nodeId>...] [--dir <path>]` | Move nodes on an older version of their type to the current one (CUSTOM_CODE 1.0.0 and 1.1.0 become 1.2.0: the integrations list is added, the code file keeps its body and gets the new header). Every command that touches a workflow lists such nodes in a note. |
|
|
141
141
|
| `workflows add <TYPE> [--id <id>] [--after <nodeId>] [--in-loop <loopId>] [--to <actionId>] [--lang JAVASCRIPT\|PYTHON] [--title <t>]` | Append an action after a node (default: the only node without a successor) and the path to it, or append a trigger (`--to` connects it). Custom code gets `actions/<id>.js\|py` with an empty function. Comments in the config survive. |
|
|
142
142
|
| `workflows replace <nodeId> <TYPE>` | Give a node another type of the same kind: id, title and paths stay, inputs start from the new template. |
|
package/dist/cli.mjs
CHANGED
|
@@ -14397,7 +14397,7 @@ function updateWorkflow(client, workflowId, body) {
|
|
|
14397
14397
|
function getWorkflowOutputs(client, workflowId) {
|
|
14398
14398
|
return apiRequest(client, "GET", `/v1/workflows/${workflowId}/outputs`);
|
|
14399
14399
|
}
|
|
14400
|
-
function listWorkflows(client, workspaceId, applicationId) {
|
|
14400
|
+
function listWorkflows(client, workspaceId, { applicationId } = {}) {
|
|
14401
14401
|
const query = new URLSearchParams({ workspaceId, ...applicationId ? { applicationId } : {}, limit: "500" });
|
|
14402
14402
|
return apiRequest(client, "GET", `/v1/workflows?${query}`);
|
|
14403
14403
|
}
|
|
@@ -14549,6 +14549,9 @@ function tokenKind(token) {
|
|
|
14549
14549
|
var TOKEN_ENV_VAR = "SOFTR_TOKEN";
|
|
14550
14550
|
var AUTH_ENV_VAR = "SOFTR_AUTH";
|
|
14551
14551
|
var PROXY_AUTH = "proxy";
|
|
14552
|
+
function isProxyAuth() {
|
|
14553
|
+
return process.env[AUTH_ENV_VAR] === PROXY_AUTH;
|
|
14554
|
+
}
|
|
14552
14555
|
var REFRESH_MARGIN_MS = 5 * 60 * 1e3;
|
|
14553
14556
|
function credentialsPath() {
|
|
14554
14557
|
return path6.join(homedir(), ".softr", "credentials.json");
|
|
@@ -14613,7 +14616,7 @@ async function refreshedAccessToken(target, stored) {
|
|
|
14613
14616
|
}
|
|
14614
14617
|
}
|
|
14615
14618
|
async function authenticatedClient(target) {
|
|
14616
|
-
if (
|
|
14619
|
+
if (isProxyAuth()) {
|
|
14617
14620
|
return { target, kind: "proxy" };
|
|
14618
14621
|
}
|
|
14619
14622
|
const fromEnv = process.env[TOKEN_ENV_VAR];
|
|
@@ -14725,7 +14728,7 @@ function toRow(workflow, workspace) {
|
|
|
14725
14728
|
updatedAt: workflow.updatedAt ?? null
|
|
14726
14729
|
};
|
|
14727
14730
|
}
|
|
14728
|
-
async function collectWorkflows(client, workspaceId, applicationId) {
|
|
14731
|
+
async function collectWorkflows(client, { workspaceId, applicationId } = {}) {
|
|
14729
14732
|
const workspaces = await listWorkspaces(client);
|
|
14730
14733
|
const selected = workspaceId ? workspaces.filter((workspace) => workspace.id === workspaceId) : workspaces;
|
|
14731
14734
|
if (workspaceId && !selected.length) {
|
|
@@ -14737,7 +14740,7 @@ async function collectWorkflows(client, workspaceId, applicationId) {
|
|
|
14737
14740
|
const listing = { workspaces: [], workflows: [], failures: [] };
|
|
14738
14741
|
for (const workspace of selected) {
|
|
14739
14742
|
try {
|
|
14740
|
-
const page = await listWorkflows(client, workspace.id, applicationId);
|
|
14743
|
+
const page = await listWorkflows(client, workspace.id, { applicationId });
|
|
14741
14744
|
listing.workspaces.push({ id: workspace.id, name: workspace.name });
|
|
14742
14745
|
listing.workflows.push(...page.items.map((workflow) => toRow(workflow, workspace)));
|
|
14743
14746
|
} catch (error) {
|
|
@@ -14788,8 +14791,8 @@ ${workflowTable(rows)}` : `${heading}
|
|
|
14788
14791
|
}
|
|
14789
14792
|
return blocks.join("\n\n");
|
|
14790
14793
|
}
|
|
14791
|
-
async function emitWorkflowList(options, client, workspaceId,
|
|
14792
|
-
const listing = await collectWorkflows(client, workspaceId, applicationId);
|
|
14794
|
+
async function emitWorkflowList(options, client, { workspaceId, applicationId, human } = {}) {
|
|
14795
|
+
const listing = await collectWorkflows(client, { workspaceId, applicationId });
|
|
14793
14796
|
emit(options, [human, renderWorkflows(listing)].filter(Boolean).join("\n\n"), { ...listing });
|
|
14794
14797
|
}
|
|
14795
14798
|
function registerList(program3) {
|
|
@@ -14797,7 +14800,10 @@ function registerList(program3) {
|
|
|
14797
14800
|
const options = globalOptions(command);
|
|
14798
14801
|
const target = resolveTarget(await readState(process.cwd()));
|
|
14799
14802
|
const client = await authenticatedClient(target);
|
|
14800
|
-
await emitWorkflowList(options, client,
|
|
14803
|
+
await emitWorkflowList(options, client, {
|
|
14804
|
+
workspaceId: opts.workspace ?? process.env["SOFTR_WORKSPACE_ID"],
|
|
14805
|
+
applicationId: opts.app
|
|
14806
|
+
});
|
|
14801
14807
|
});
|
|
14802
14808
|
}
|
|
14803
14809
|
|
|
@@ -15060,12 +15066,9 @@ function registerPull(program3) {
|
|
|
15060
15066
|
const target = resolveTarget(remembered);
|
|
15061
15067
|
const client = await authenticatedClient(target);
|
|
15062
15068
|
if (!workflowId) {
|
|
15063
|
-
await emitWorkflowList(
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
void 0,
|
|
15067
|
-
"Pick a workflow and run: softr workflows pull <workflowId>"
|
|
15068
|
-
);
|
|
15069
|
+
await emitWorkflowList(options, client, {
|
|
15070
|
+
human: "Pick a workflow and run: softr workflows pull <workflowId>"
|
|
15071
|
+
});
|
|
15069
15072
|
return;
|
|
15070
15073
|
}
|
|
15071
15074
|
const workflow = await getWorkflow(client, workflowId);
|
|
@@ -15268,7 +15271,7 @@ function registerInit(program3) {
|
|
|
15268
15271
|
program3.command("init").description("Create a new workflow with one trigger, on the server and as a local directory").argument("<title>", "the workflow title").option(
|
|
15269
15272
|
"--workspace <id>",
|
|
15270
15273
|
"workspace to create it in (default: $SOFTR_WORKSPACE_ID, else your only or default workspace)"
|
|
15271
|
-
).option("--app <id>", "application to
|
|
15274
|
+
).option("--pin-to-app <id>", "application to pin the workflow to (default: $SOFTR_PINNED_APP_ID when set)").option("--trigger <TYPE>", 'trigger type from "spec" (default WEBHOOK)', "WEBHOOK").option("--dir <path>", "directory to create (default: ./<title-slug>)").action(
|
|
15272
15275
|
async (title, opts, command) => {
|
|
15273
15276
|
const options = globalOptions(command);
|
|
15274
15277
|
const cwd = process.cwd();
|
|
@@ -15280,12 +15283,11 @@ function registerInit(program3) {
|
|
|
15280
15283
|
const target = resolveTarget();
|
|
15281
15284
|
const client = await authenticatedClient(target);
|
|
15282
15285
|
const workspaceId = await resolveWorkspace(client, opts.workspace ?? process.env["SOFTR_WORKSPACE_ID"]);
|
|
15283
|
-
const
|
|
15286
|
+
const pinToApplicationId = opts.pinToApp ?? process.env["SOFTR_PINNED_APP_ID"];
|
|
15284
15287
|
const created = await createWorkflow(client, {
|
|
15285
15288
|
workspaceId,
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
...applicationId ? { pinToApplicationId: applicationId } : {},
|
|
15289
|
+
applicationId: null,
|
|
15290
|
+
...pinToApplicationId ? { pinToApplicationId } : {},
|
|
15289
15291
|
title,
|
|
15290
15292
|
thumbnail: null,
|
|
15291
15293
|
triggers: [{ id: TRIGGER_ID, type: trigger.type, version: trigger.version, inputs: trigger.template }],
|
|
@@ -15309,14 +15311,14 @@ function registerInit(program3) {
|
|
|
15309
15311
|
const studioUrl = `${target.studioUrl}/workflow/${created.id}`;
|
|
15310
15312
|
emit(
|
|
15311
15313
|
options,
|
|
15312
|
-
`Created "${title}" (${created.id}) with a ${trigger.type} trigger "${TRIGGER_ID}" in workspace ${workspaceId}${
|
|
15314
|
+
`Created "${title}" (${created.id}) with a ${trigger.type} trigger "${TRIGGER_ID}" in workspace ${workspaceId}${pinToApplicationId ? `, linked to application ${pinToApplicationId}` : ""}.
|
|
15313
15315
|
${path10.relative(cwd, configFile)}
|
|
15314
15316
|
${studioUrl}
|
|
15315
15317
|
Next: softr workflows add <TYPE> --dir ${path10.relative(cwd, dir) || "."} (see "spec" for the types), then push and test.`,
|
|
15316
15318
|
{
|
|
15317
15319
|
workflowId: created.id,
|
|
15318
15320
|
workspaceId,
|
|
15319
|
-
|
|
15321
|
+
pinnedToApplicationId: pinToApplicationId ?? null,
|
|
15320
15322
|
title,
|
|
15321
15323
|
triggerId: TRIGGER_ID,
|
|
15322
15324
|
triggerType: trigger.type,
|
|
@@ -15553,7 +15555,7 @@ function registerLogin(program3) {
|
|
|
15553
15555
|
).option("--no-browser", "browser login, but print the URL instead of opening it (for remote shells and agents)").action(async (opts, command) => {
|
|
15554
15556
|
const options = globalOptions(command);
|
|
15555
15557
|
const target = resolveTarget();
|
|
15556
|
-
if (
|
|
15558
|
+
if (isProxyAuth()) {
|
|
15557
15559
|
throw new CliError(
|
|
15558
15560
|
`Login is not needed: the target authenticates the requests itself ($${AUTH_ENV_VAR}=proxy).`
|
|
15559
15561
|
);
|
|
@@ -15566,6 +15568,11 @@ function registerLogin(program3) {
|
|
|
15566
15568
|
program3.command("logout").description("Forget the stored token of the current target").action(async (_opts, command) => {
|
|
15567
15569
|
const options = globalOptions(command);
|
|
15568
15570
|
const target = resolveTarget();
|
|
15571
|
+
if (isProxyAuth()) {
|
|
15572
|
+
throw new CliError(
|
|
15573
|
+
`Nothing to log out from: the target authenticates the requests itself ($${AUTH_ENV_VAR}=proxy).`
|
|
15574
|
+
);
|
|
15575
|
+
}
|
|
15569
15576
|
const removed = await forgetToken(target);
|
|
15570
15577
|
emit(
|
|
15571
15578
|
options,
|
|
@@ -16696,7 +16703,7 @@ Pass --workspace <id> to a command, or set SOFTR_WORKSPACE_ID, to work in one of
|
|
|
16696
16703
|
// package.json
|
|
16697
16704
|
var package_default = {
|
|
16698
16705
|
name: "@softr/cli",
|
|
16699
|
-
version: "0.1.1
|
|
16706
|
+
version: "0.1.1",
|
|
16700
16707
|
description: "The Softr command line: build, test and publish Softr workflows from local files; more Softr APIs to come",
|
|
16701
16708
|
keywords: [
|
|
16702
16709
|
"softr",
|