@openfn/cli 1.13.6 → 1.14.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/dist/index.js +12 -1
- package/dist/process/runner.js +69 -44
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1052,9 +1052,20 @@ var command_default10 = {
|
|
|
1052
1052
|
builder: (yargs2) => build(options8, yargs2).example("test", "Run the test script")
|
|
1053
1053
|
};
|
|
1054
1054
|
|
|
1055
|
+
// src/projects/command.ts
|
|
1056
|
+
var options9 = [projectPath];
|
|
1057
|
+
var projectsCommand = {
|
|
1058
|
+
command: "projects [project-path]",
|
|
1059
|
+
describe: "List all the openfn projects available in the current directory",
|
|
1060
|
+
aliases: ["project"],
|
|
1061
|
+
handler: ensure("projects", options9),
|
|
1062
|
+
builder: (yargs2) => build(options9, yargs2)
|
|
1063
|
+
};
|
|
1064
|
+
var command_default11 = projectsCommand;
|
|
1065
|
+
|
|
1055
1066
|
// src/cli.ts
|
|
1056
1067
|
var y = yargs(hideBin(process.argv));
|
|
1057
|
-
var cmd = y.command(command_default7).command(command_default3).command(command_default2).command(command_default4).command(install).command(repo).command(command_default10).command(command_default6).command(command_default).command(command_default8).command(command_default5).command(command_default9).command({
|
|
1068
|
+
var cmd = y.command(command_default7).command(command_default3).command(command_default2).command(command_default4).command(install).command(repo).command(command_default10).command(command_default6).command(command_default).command(command_default8).command(command_default5).command(command_default9).command(command_default11).command({
|
|
1058
1069
|
command: "version",
|
|
1059
1070
|
describe: "Show the currently installed version of the CLI, compiler and runtime.",
|
|
1060
1071
|
handler: (argv) => {
|
package/dist/process/runner.js
CHANGED
|
@@ -127,14 +127,14 @@ var callApollo = async (apolloBaseUrl, serviceName, payload, logger) => {
|
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
129
|
};
|
|
130
|
-
var loadPayload = async (logger,
|
|
131
|
-
if (!
|
|
130
|
+
var loadPayload = async (logger, path13) => {
|
|
131
|
+
if (!path13) {
|
|
132
132
|
logger.warn("No JSON payload provided");
|
|
133
133
|
logger.warn("Most apollo services require JSON to be uploaded");
|
|
134
134
|
return {};
|
|
135
135
|
}
|
|
136
|
-
if (
|
|
137
|
-
const str = await readFile(
|
|
136
|
+
if (path13.endsWith(".json")) {
|
|
137
|
+
const str = await readFile(path13, "utf8");
|
|
138
138
|
const json = JSON.parse(str);
|
|
139
139
|
logger.debug("Loaded JSON payload");
|
|
140
140
|
return json;
|
|
@@ -256,13 +256,13 @@ var execute_default = async (plan, input, opts, logger) => {
|
|
|
256
256
|
};
|
|
257
257
|
function parseAdaptors(plan) {
|
|
258
258
|
const extractInfo = (specifier) => {
|
|
259
|
-
const [module,
|
|
259
|
+
const [module, path13] = specifier.split("=");
|
|
260
260
|
const { name, version } = getNameAndVersion(module);
|
|
261
261
|
const info = {
|
|
262
262
|
name
|
|
263
263
|
};
|
|
264
|
-
if (
|
|
265
|
-
info.path =
|
|
264
|
+
if (path13) {
|
|
265
|
+
info.path = path13;
|
|
266
266
|
}
|
|
267
267
|
if (version) {
|
|
268
268
|
info.version = version;
|
|
@@ -522,10 +522,10 @@ var stripVersionSpecifier = (specifier) => {
|
|
|
522
522
|
return specifier;
|
|
523
523
|
};
|
|
524
524
|
var resolveSpecifierPath = async (pattern, repoDir, log) => {
|
|
525
|
-
const [specifier,
|
|
526
|
-
if (
|
|
527
|
-
log.debug(`Resolved ${specifier} to path: ${
|
|
528
|
-
return
|
|
525
|
+
const [specifier, path13] = pattern.split("=");
|
|
526
|
+
if (path13) {
|
|
527
|
+
log.debug(`Resolved ${specifier} to path: ${path13}`);
|
|
528
|
+
return path13;
|
|
529
529
|
}
|
|
530
530
|
const repoPath = await getModulePath(specifier, repoDir, log);
|
|
531
531
|
if (repoPath) {
|
|
@@ -544,12 +544,12 @@ var loadTransformOptions = async (opts, log) => {
|
|
|
544
544
|
let exports;
|
|
545
545
|
const [specifier] = adaptorInput.split("=");
|
|
546
546
|
log.debug(`Trying to preload types for ${specifier}`);
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
547
|
+
const path13 = await resolveSpecifierPath(adaptorInput, opts.repoDir, log);
|
|
548
|
+
if (path13) {
|
|
549
549
|
try {
|
|
550
|
-
exports = await preloadAdaptorExports(
|
|
550
|
+
exports = await preloadAdaptorExports(path13, log);
|
|
551
551
|
} catch (e) {
|
|
552
|
-
log.error(`Failed to load adaptor typedefs from path ${
|
|
552
|
+
log.error(`Failed to load adaptor typedefs from path ${path13}`);
|
|
553
553
|
log.error(e);
|
|
554
554
|
}
|
|
555
555
|
}
|
|
@@ -1001,8 +1001,8 @@ var loadXPlan = async (plan, options, logger, defaultName = "") => {
|
|
|
1001
1001
|
};
|
|
1002
1002
|
|
|
1003
1003
|
// src/util/assert-path.ts
|
|
1004
|
-
var assert_path_default = (
|
|
1005
|
-
if (!
|
|
1004
|
+
var assert_path_default = (path13) => {
|
|
1005
|
+
if (!path13) {
|
|
1006
1006
|
console.error("ERROR: no path provided!");
|
|
1007
1007
|
console.error("\nUsage:");
|
|
1008
1008
|
console.error(" open path/to/job");
|
|
@@ -1687,20 +1687,20 @@ var RETRY_COUNT = 20;
|
|
|
1687
1687
|
var TIMEOUT_MS = 1e3 * 60;
|
|
1688
1688
|
var actualDocGen = (specifier) => describePackage(specifier, {});
|
|
1689
1689
|
var ensurePath = (filePath) => mkdirSync(path7.dirname(filePath), { recursive: true });
|
|
1690
|
-
var generatePlaceholder = (
|
|
1691
|
-
writeFileSync(
|
|
1690
|
+
var generatePlaceholder = (path13) => {
|
|
1691
|
+
writeFileSync(path13, `{ "loading": true, "timestamp": ${Date.now()}}`);
|
|
1692
1692
|
};
|
|
1693
1693
|
var finish = (logger, resultPath) => {
|
|
1694
1694
|
logger.success("Done! Docs can be found at:\n");
|
|
1695
1695
|
logger.print(` ${path7.resolve(resultPath)}`);
|
|
1696
1696
|
};
|
|
1697
|
-
var generateDocs = async (specifier,
|
|
1697
|
+
var generateDocs = async (specifier, path13, docgen, logger) => {
|
|
1698
1698
|
const result = await docgen(specifier);
|
|
1699
|
-
await writeFile5(
|
|
1700
|
-
finish(logger,
|
|
1701
|
-
return
|
|
1699
|
+
await writeFile5(path13, JSON.stringify(result, null, 2));
|
|
1700
|
+
finish(logger, path13);
|
|
1701
|
+
return path13;
|
|
1702
1702
|
};
|
|
1703
|
-
var waitForDocs = async (docs,
|
|
1703
|
+
var waitForDocs = async (docs, path13, logger, retryDuration = RETRY_DURATION) => {
|
|
1704
1704
|
try {
|
|
1705
1705
|
if (docs.hasOwnProperty("loading")) {
|
|
1706
1706
|
logger.info("Docs are being loaded by another process. Waiting.");
|
|
@@ -1712,19 +1712,19 @@ var waitForDocs = async (docs, path12, logger, retryDuration = RETRY_DURATION) =
|
|
|
1712
1712
|
clearInterval(i);
|
|
1713
1713
|
reject(new Error("Timed out waiting for docs to load"));
|
|
1714
1714
|
}
|
|
1715
|
-
const updated = JSON.parse(readFileSync(
|
|
1715
|
+
const updated = JSON.parse(readFileSync(path13, "utf8"));
|
|
1716
1716
|
if (!updated.hasOwnProperty("loading")) {
|
|
1717
1717
|
logger.info("Docs found!");
|
|
1718
1718
|
clearInterval(i);
|
|
1719
|
-
resolve(
|
|
1719
|
+
resolve(path13);
|
|
1720
1720
|
}
|
|
1721
1721
|
count++;
|
|
1722
1722
|
}, retryDuration);
|
|
1723
1723
|
});
|
|
1724
1724
|
} else {
|
|
1725
|
-
logger.info(`Docs already written to cache at ${
|
|
1726
|
-
finish(logger,
|
|
1727
|
-
return
|
|
1725
|
+
logger.info(`Docs already written to cache at ${path13}`);
|
|
1726
|
+
finish(logger, path13);
|
|
1727
|
+
return path13;
|
|
1728
1728
|
}
|
|
1729
1729
|
} catch (e) {
|
|
1730
1730
|
logger.error("Existing doc JSON corrupt. Aborting");
|
|
@@ -1741,28 +1741,28 @@ var docgenHandler = (options, logger, docgen = actualDocGen, retryDuration = RET
|
|
|
1741
1741
|
process.exit(9);
|
|
1742
1742
|
}
|
|
1743
1743
|
logger.success(`Generating docs for ${specifier}`);
|
|
1744
|
-
const
|
|
1745
|
-
ensurePath(
|
|
1744
|
+
const path13 = `${repoDir}/docs/${specifier}.json`;
|
|
1745
|
+
ensurePath(path13);
|
|
1746
1746
|
const handleError2 = () => {
|
|
1747
1747
|
logger.info("Removing placeholder");
|
|
1748
|
-
rmSync(
|
|
1748
|
+
rmSync(path13);
|
|
1749
1749
|
};
|
|
1750
1750
|
try {
|
|
1751
|
-
const existing = readFileSync(
|
|
1751
|
+
const existing = readFileSync(path13, "utf8");
|
|
1752
1752
|
const json = JSON.parse(existing);
|
|
1753
1753
|
if (json && json.timeout && Date.now() - json.timeout >= TIMEOUT_MS) {
|
|
1754
1754
|
logger.info(`Expired placeholder found. Removing.`);
|
|
1755
|
-
rmSync(
|
|
1755
|
+
rmSync(path13);
|
|
1756
1756
|
throw new Error("TIMEOUT");
|
|
1757
1757
|
}
|
|
1758
|
-
return waitForDocs(json,
|
|
1758
|
+
return waitForDocs(json, path13, logger, retryDuration);
|
|
1759
1759
|
} catch (e) {
|
|
1760
1760
|
if (e.message !== "TIMEOUT") {
|
|
1761
|
-
logger.info(`Docs JSON not found at ${
|
|
1761
|
+
logger.info(`Docs JSON not found at ${path13}`);
|
|
1762
1762
|
}
|
|
1763
1763
|
logger.debug("Generating placeholder");
|
|
1764
|
-
generatePlaceholder(
|
|
1765
|
-
return generateDocs(specifier,
|
|
1764
|
+
generatePlaceholder(path13);
|
|
1765
|
+
return generateDocs(specifier, path13, docgen, logger).catch((e2) => {
|
|
1766
1766
|
logger.error("Error generating documentation");
|
|
1767
1767
|
logger.error(e2);
|
|
1768
1768
|
handleError2();
|
|
@@ -1813,7 +1813,7 @@ var docsHandler = async (options, logger) => {
|
|
|
1813
1813
|
logger.success(`Showing docs for ${adaptorName} v${version}`);
|
|
1814
1814
|
}
|
|
1815
1815
|
logger.info("Generating/loading documentation...");
|
|
1816
|
-
const
|
|
1816
|
+
const path13 = await handler_default7(
|
|
1817
1817
|
{
|
|
1818
1818
|
specifier: `${name}@${version}`,
|
|
1819
1819
|
repoDir
|
|
@@ -1822,8 +1822,8 @@ var docsHandler = async (options, logger) => {
|
|
|
1822
1822
|
createNullLogger()
|
|
1823
1823
|
);
|
|
1824
1824
|
let didError = false;
|
|
1825
|
-
if (
|
|
1826
|
-
const source = await readFile4(
|
|
1825
|
+
if (path13) {
|
|
1826
|
+
const source = await readFile4(path13, "utf8");
|
|
1827
1827
|
const data = JSON.parse(source);
|
|
1828
1828
|
let desc;
|
|
1829
1829
|
if (operation) {
|
|
@@ -2269,9 +2269,33 @@ function pickFirst2(...args) {
|
|
|
2269
2269
|
}
|
|
2270
2270
|
var handler_default10 = pullHandler;
|
|
2271
2271
|
|
|
2272
|
+
// src/projects/handler.ts
|
|
2273
|
+
import { Workspace } from "@openfn/project";
|
|
2274
|
+
import path11 from "path";
|
|
2275
|
+
var projectsHandler = async (options, logger) => {
|
|
2276
|
+
const commandPath = path11.resolve(process.cwd(), options.projectPath ?? ".");
|
|
2277
|
+
const workspace = new Workspace(commandPath);
|
|
2278
|
+
if (!workspace.valid) {
|
|
2279
|
+
logger.error("Command was run in an invalid openfn workspace");
|
|
2280
|
+
return;
|
|
2281
|
+
}
|
|
2282
|
+
logger.success(`Available openfn projects
|
|
2283
|
+
|
|
2284
|
+
${workspace.list().map((p) => describeProject(p, p.name === workspace.activeProjectId)).join("\n\n")}
|
|
2285
|
+
`);
|
|
2286
|
+
};
|
|
2287
|
+
function describeProject(project, active = false) {
|
|
2288
|
+
const pId = project.openfn?.uuid;
|
|
2289
|
+
return `${project.name} ${active ? "(active)" : ""}
|
|
2290
|
+
${pId || "<project-id>"}
|
|
2291
|
+
workflows:
|
|
2292
|
+
${project.workflows.map((w) => " - " + w.name).join("\n")}`;
|
|
2293
|
+
}
|
|
2294
|
+
var handler_default11 = projectsHandler;
|
|
2295
|
+
|
|
2272
2296
|
// src/util/print-versions.ts
|
|
2273
2297
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2274
|
-
import
|
|
2298
|
+
import path12 from "node:path";
|
|
2275
2299
|
import url from "node:url";
|
|
2276
2300
|
import { getNameAndVersion as getNameAndVersion7 } from "@openfn/runtime";
|
|
2277
2301
|
import { mainSymbols } from "figures";
|
|
@@ -2283,7 +2307,7 @@ var { triangleRightSmall: t } = mainSymbols;
|
|
|
2283
2307
|
var loadVersionFromPath = (adaptorPath) => {
|
|
2284
2308
|
try {
|
|
2285
2309
|
const pkg = JSON.parse(
|
|
2286
|
-
readFileSync2(
|
|
2310
|
+
readFileSync2(path12.resolve(adaptorPath, "package.json"), "utf8")
|
|
2287
2311
|
);
|
|
2288
2312
|
return pkg.version;
|
|
2289
2313
|
} catch (e) {
|
|
@@ -2318,7 +2342,7 @@ var printVersions = async (logger, options = {}, includeComponents = false) => {
|
|
|
2318
2342
|
...[NODE, CLI2, RUNTIME2, COMPILER2, longestAdaptorName].map((s) => s.length)
|
|
2319
2343
|
);
|
|
2320
2344
|
const prefix = (str) => ` ${t} ${str.padEnd(longest + 4, " ")}`;
|
|
2321
|
-
const dirname3 =
|
|
2345
|
+
const dirname3 = path12.dirname(url.fileURLToPath(import.meta.url));
|
|
2322
2346
|
const pkg = JSON.parse(readFileSync2(`${dirname3}/../../package.json`, "utf8"));
|
|
2323
2347
|
const { version, dependencies } = pkg;
|
|
2324
2348
|
const compilerVersion = dependencies["@openfn/compiler"];
|
|
@@ -2371,6 +2395,7 @@ var handlers = {
|
|
|
2371
2395
|
docs: handler_default8,
|
|
2372
2396
|
metadata: handler_default9,
|
|
2373
2397
|
pull: handler_default10,
|
|
2398
|
+
projects: handler_default11,
|
|
2374
2399
|
["collections-get"]: handler_default4.get,
|
|
2375
2400
|
["collections-set"]: handler_default4.set,
|
|
2376
2401
|
["collections-remove"]: handler_default4.remove,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "CLI devtools for the OpenFn toolchain",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18",
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"yargs": "^17.7.2",
|
|
50
50
|
"@openfn/compiler": "1.1.2",
|
|
51
51
|
"@openfn/deploy": "0.11.3",
|
|
52
|
-
"@openfn/lexicon": "^1.2.3",
|
|
53
|
-
"@openfn/logger": "1.0.6",
|
|
54
52
|
"@openfn/describe-package": "0.1.5",
|
|
55
|
-
"@openfn/
|
|
56
|
-
"@openfn/
|
|
53
|
+
"@openfn/logger": "1.0.6",
|
|
54
|
+
"@openfn/lexicon": "^1.2.3",
|
|
55
|
+
"@openfn/runtime": "1.7.2",
|
|
56
|
+
"@openfn/project": "^0.3.1"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|
|
59
59
|
"dist",
|