@openfn/cli 1.18.1 → 1.18.3
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/index.js +23 -14
- package/dist/process/runner.js +60 -37
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -356,10 +356,10 @@ var getBaseDir = (opts2) => {
|
|
|
356
356
|
}
|
|
357
357
|
return basePath;
|
|
358
358
|
};
|
|
359
|
-
var
|
|
360
|
-
name: "project-
|
|
359
|
+
var projectId = {
|
|
360
|
+
name: "project-id",
|
|
361
361
|
yargs: {
|
|
362
|
-
description: "The
|
|
362
|
+
description: "The id or UUID of an openfn project",
|
|
363
363
|
string: true
|
|
364
364
|
},
|
|
365
365
|
ensure: (opts2) => {
|
|
@@ -1120,9 +1120,9 @@ var projectsCommand = {
|
|
|
1120
1120
|
var command_default11 = projectsCommand;
|
|
1121
1121
|
|
|
1122
1122
|
// src/checkout/command.ts
|
|
1123
|
-
var options10 = [
|
|
1123
|
+
var options10 = [projectId, projectPath, log];
|
|
1124
1124
|
var checkoutCommand = {
|
|
1125
|
-
command: "checkout <project-
|
|
1125
|
+
command: "checkout <project-id>",
|
|
1126
1126
|
describe: "Switch to a different openfn project in the same workspace",
|
|
1127
1127
|
handler: ensure("checkout", options10),
|
|
1128
1128
|
builder: (yargs2) => build(options10, yargs2)
|
|
@@ -1131,17 +1131,32 @@ var command_default12 = checkoutCommand;
|
|
|
1131
1131
|
|
|
1132
1132
|
// src/merge/command.ts
|
|
1133
1133
|
var options11 = [
|
|
1134
|
-
|
|
1134
|
+
projectId,
|
|
1135
1135
|
projectPath,
|
|
1136
1136
|
removeUnmapped,
|
|
1137
1137
|
workflowMappings,
|
|
1138
1138
|
log,
|
|
1139
|
+
// custom output because we don't want defaults or anything
|
|
1140
|
+
{
|
|
1141
|
+
name: "output-path",
|
|
1142
|
+
yargs: {
|
|
1143
|
+
alias: "o",
|
|
1144
|
+
description: "Optionally write the merged project file to a custom location"
|
|
1145
|
+
}
|
|
1146
|
+
},
|
|
1147
|
+
{
|
|
1148
|
+
name: "base",
|
|
1149
|
+
yargs: {
|
|
1150
|
+
alias: "target",
|
|
1151
|
+
description: "Path to the base (target) state file to merge into (ie, what main should be)"
|
|
1152
|
+
}
|
|
1153
|
+
},
|
|
1139
1154
|
override(force, {
|
|
1140
1155
|
description: "Force a merge even when workflows are incompatible"
|
|
1141
1156
|
})
|
|
1142
1157
|
];
|
|
1143
1158
|
var mergeCommand = {
|
|
1144
|
-
command: "merge
|
|
1159
|
+
command: "merge <project-id>",
|
|
1145
1160
|
describe: "Merges the specified project into the checked out project",
|
|
1146
1161
|
handler: ensure("merge", options11),
|
|
1147
1162
|
builder: (yargs2) => build(options11, yargs2)
|
|
@@ -1149,13 +1164,7 @@ var mergeCommand = {
|
|
|
1149
1164
|
var command_default13 = mergeCommand;
|
|
1150
1165
|
|
|
1151
1166
|
// src/version/command.ts
|
|
1152
|
-
var options12 = [
|
|
1153
|
-
workflow,
|
|
1154
|
-
projectName,
|
|
1155
|
-
projectPath,
|
|
1156
|
-
workflowMappings,
|
|
1157
|
-
json
|
|
1158
|
-
];
|
|
1167
|
+
var options12 = [workflow, projectPath, workflowMappings, json];
|
|
1159
1168
|
var workflowVersionCommand = {
|
|
1160
1169
|
command: "project version [workflow]",
|
|
1161
1170
|
describe: "Returns the version has of a workflow",
|
package/dist/process/runner.js
CHANGED
|
@@ -2127,12 +2127,16 @@ async function handler2(options, logger) {
|
|
|
2127
2127
|
const config = workspace.getConfig();
|
|
2128
2128
|
const { data } = await getProject(cfg, options.projectId);
|
|
2129
2129
|
const name = options.env || "project";
|
|
2130
|
-
const project = Project3.from(
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2130
|
+
const project = await Project3.from(
|
|
2131
|
+
"state",
|
|
2132
|
+
data,
|
|
2133
|
+
{
|
|
2134
|
+
endpoint: cfg.endpoint,
|
|
2135
|
+
env: name,
|
|
2136
|
+
fetched_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2137
|
+
},
|
|
2138
|
+
config
|
|
2139
|
+
);
|
|
2136
2140
|
const projectFileName = project.getIdentifier();
|
|
2137
2141
|
await fs4.mkdir(`${outputRoot}/.projects`, { recursive: true });
|
|
2138
2142
|
let stateOutputPath = `${outputRoot}/.projects/${projectFileName}`;
|
|
@@ -2285,15 +2289,15 @@ var projectsHandler = async (options, logger) => {
|
|
|
2285
2289
|
}
|
|
2286
2290
|
logger.success(`Available openfn projects
|
|
2287
2291
|
|
|
2288
|
-
${workspace.list().map((p) => describeProject(p, p.
|
|
2292
|
+
${workspace.list().map((p) => describeProject(p, p.id === workspace.activeProjectId)).join("\n\n")}
|
|
2289
2293
|
`);
|
|
2290
2294
|
};
|
|
2291
2295
|
function describeProject(project, active = false) {
|
|
2292
|
-
const
|
|
2293
|
-
return `${project.
|
|
2294
|
-
${
|
|
2296
|
+
const uuid = project.openfn?.uuid;
|
|
2297
|
+
return `${project.id} ${active ? "(active)" : ""}
|
|
2298
|
+
${uuid || "<project-id>"}
|
|
2295
2299
|
workflows:
|
|
2296
|
-
${project.workflows.map((w) => " - " + w.
|
|
2300
|
+
${project.workflows.map((w) => " - " + w.id).join("\n")}`;
|
|
2297
2301
|
}
|
|
2298
2302
|
var handler_default11 = projectsHandler;
|
|
2299
2303
|
|
|
@@ -2312,7 +2316,7 @@ var workflowVersionHandler = async (options, logger) => {
|
|
|
2312
2316
|
if (options.workflow) {
|
|
2313
2317
|
const workflow = activeProject?.getWorkflow(options.workflow);
|
|
2314
2318
|
if (!workflow) {
|
|
2315
|
-
logger.error(`No workflow found with id
|
|
2319
|
+
logger.error(`No workflow found with id ${options.workflow}`);
|
|
2316
2320
|
return;
|
|
2317
2321
|
}
|
|
2318
2322
|
output.set(workflow.name || workflow.id, workflow.getVersionHash());
|
|
@@ -2351,20 +2355,17 @@ var checkoutHandler = async (options, logger) => {
|
|
|
2351
2355
|
}
|
|
2352
2356
|
const { project: _, ...config } = workspace.getConfig();
|
|
2353
2357
|
let switchProject;
|
|
2354
|
-
if (/\.(yaml|json)$/.test(options.
|
|
2355
|
-
const filePath = path13.join(commandPath, options.
|
|
2358
|
+
if (/\.(yaml|json)$/.test(options.projectId)) {
|
|
2359
|
+
const filePath = options.projectId.startsWith("/") ? options.projectId : path13.join(commandPath, options.projectId);
|
|
2356
2360
|
logger.debug("Loading project from path ", filePath);
|
|
2357
|
-
switchProject = await Project5.from("path", filePath,
|
|
2358
|
-
config
|
|
2359
|
-
});
|
|
2361
|
+
switchProject = await Project5.from("path", filePath, config);
|
|
2360
2362
|
} else {
|
|
2361
|
-
switchProject = workspace.get(options.
|
|
2363
|
+
switchProject = workspace.get(options.projectId);
|
|
2362
2364
|
}
|
|
2363
2365
|
if (!switchProject) {
|
|
2364
|
-
|
|
2365
|
-
`Project with id
|
|
2366
|
+
throw new Error(
|
|
2367
|
+
`Project with id ${options.projectId} not found in the workspace`
|
|
2366
2368
|
);
|
|
2367
|
-
return;
|
|
2368
2369
|
}
|
|
2369
2370
|
await rimraf2(path13.join(commandPath, config.workflowRoot ?? "workflows"));
|
|
2370
2371
|
const files = switchProject.serialize("fs");
|
|
@@ -2393,32 +2394,41 @@ var mergeHandler = async (options, logger) => {
|
|
|
2393
2394
|
logger.error("Command was run in an invalid openfn workspace");
|
|
2394
2395
|
return;
|
|
2395
2396
|
}
|
|
2396
|
-
|
|
2397
|
-
if (
|
|
2398
|
-
|
|
2399
|
-
|
|
2397
|
+
let targetProject;
|
|
2398
|
+
if (options.base) {
|
|
2399
|
+
const basePath = path14.resolve(options.base);
|
|
2400
|
+
logger.debug("Loading target project from path", basePath);
|
|
2401
|
+
targetProject = await Project6.from("path", basePath);
|
|
2402
|
+
} else {
|
|
2403
|
+
targetProject = workspace.getActiveProject();
|
|
2404
|
+
if (!targetProject) {
|
|
2405
|
+
logger.error(`No project currently checked out`);
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
logger.debug(`Loading target project from workspace (${targetProject.id})`);
|
|
2400
2409
|
}
|
|
2401
2410
|
let sourceProject;
|
|
2402
|
-
if (/\.(yaml|json)$/.test(options.
|
|
2403
|
-
const filePath = path14.join(commandPath, options.
|
|
2411
|
+
if (/\.(yaml|json)$/.test(options.projectId)) {
|
|
2412
|
+
const filePath = path14.join(commandPath, options.projectId);
|
|
2404
2413
|
logger.debug("Loading source project from path ", filePath);
|
|
2405
2414
|
sourceProject = await Project6.from("path", filePath);
|
|
2406
2415
|
} else {
|
|
2407
|
-
|
|
2416
|
+
logger.debug(`Loading source project from workspace ${options.projectId}`);
|
|
2417
|
+
sourceProject = workspace.get(options.projectId);
|
|
2408
2418
|
}
|
|
2409
2419
|
if (!sourceProject) {
|
|
2410
|
-
logger.error(`Project "${options.
|
|
2420
|
+
logger.error(`Project "${options.projectId}" not found in the workspace`);
|
|
2411
2421
|
return;
|
|
2412
2422
|
}
|
|
2413
|
-
if (targetProject.
|
|
2423
|
+
if (targetProject.id === sourceProject.id) {
|
|
2414
2424
|
logger.error("Merging into the same project not allowed");
|
|
2415
2425
|
return;
|
|
2416
2426
|
}
|
|
2417
|
-
if (!targetProject.
|
|
2418
|
-
logger.error("The checked out project has no
|
|
2427
|
+
if (!targetProject.id) {
|
|
2428
|
+
logger.error("The checked out project has no id");
|
|
2419
2429
|
return;
|
|
2420
2430
|
}
|
|
2421
|
-
const finalPath = workspace.getProjectPath(targetProject.
|
|
2431
|
+
const finalPath = options.outputPath ?? workspace.getProjectPath(targetProject.id);
|
|
2422
2432
|
if (!finalPath) {
|
|
2423
2433
|
logger.error("Path to checked out project not found.");
|
|
2424
2434
|
return;
|
|
@@ -2428,19 +2438,32 @@ var mergeHandler = async (options, logger) => {
|
|
|
2428
2438
|
workflowMappings: options.workflowMappings,
|
|
2429
2439
|
force: options.force
|
|
2430
2440
|
});
|
|
2431
|
-
|
|
2432
|
-
|
|
2441
|
+
let outputFormat = workspace.config.formats.project;
|
|
2442
|
+
if (options.outputPath?.endsWith(".json")) {
|
|
2443
|
+
outputFormat = "json";
|
|
2444
|
+
} else if (options.outputPath?.endsWith(".yaml")) {
|
|
2445
|
+
outputFormat = "yaml";
|
|
2446
|
+
}
|
|
2447
|
+
let finalState = final.serialize("state", {
|
|
2448
|
+
format: outputFormat
|
|
2449
|
+
});
|
|
2450
|
+
if (outputFormat === "json") {
|
|
2451
|
+
finalState = JSON.stringify(finalState, null, 2);
|
|
2452
|
+
}
|
|
2453
|
+
await fs7.writeFile(finalPath, finalState);
|
|
2454
|
+
logger.info(`Updated statefile at `, finalPath);
|
|
2455
|
+
logger.info("Checking out merged project to filesystem");
|
|
2433
2456
|
await handler_default13(
|
|
2434
2457
|
{
|
|
2435
2458
|
command: "checkout",
|
|
2436
2459
|
projectPath: commandPath,
|
|
2437
|
-
|
|
2460
|
+
projectId: options.outputPath ? finalPath : final.id,
|
|
2438
2461
|
log: options.log
|
|
2439
2462
|
},
|
|
2440
2463
|
logger
|
|
2441
2464
|
);
|
|
2442
2465
|
logger.success(
|
|
2443
|
-
`Project ${sourceProject.
|
|
2466
|
+
`Project ${sourceProject.id} has been merged into Project ${targetProject.id} successfully`
|
|
2444
2467
|
);
|
|
2445
2468
|
};
|
|
2446
2469
|
var handler_default14 = mergeHandler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/cli",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.3",
|
|
4
4
|
"description": "CLI devtools for the OpenFn toolchain",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@openfn/compiler": "1.1.5",
|
|
51
51
|
"@openfn/deploy": "0.11.3",
|
|
52
52
|
"@openfn/describe-package": "0.1.5",
|
|
53
|
+
"@openfn/lexicon": "^1.2.6",
|
|
53
54
|
"@openfn/logger": "1.0.6",
|
|
54
|
-
"@openfn/project": "^0.7.
|
|
55
|
-
"@openfn/
|
|
56
|
-
"@openfn/runtime": "1.7.4"
|
|
55
|
+
"@openfn/project": "^0.7.2",
|
|
56
|
+
"@openfn/runtime": "1.7.5"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|
|
59
59
|
"dist",
|