@transposit/cli
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -43,6 +43,10 @@ "use strict"; | ||
const res = []; | ||
for (const { name, required } of op.function?.parameters || []) { | ||
const opParams = op.function?.parameters || []; | ||
function paramErr(msg) { | ||
throw new common_1.UIError(`${msg}; valid params are: ${JSON.stringify(opParams)}`); | ||
} | ||
for (const { name, required } of opParams) { | ||
if (name in params) { | ||
const value = JSON.stringify(params[name]); | ||
// TODO: validate type | ||
// TODO: validate type? | ||
res.push({ name, value }); | ||
@@ -52,7 +56,7 @@ delete params[name]; | ||
else if (required) { | ||
throw new common_1.UIError(`Missing required parameter: ${name}`); | ||
paramErr(`Missing required parameter: "${name}"`); | ||
} | ||
} | ||
if (Object.keys(params).length > 0) { | ||
throw new common_1.UIError(`Unknown parameters given: ${JSON.stringify(params)}`); | ||
paramErr(`Unknown parameters given: ${JSON.stringify(params)}`); | ||
} | ||
@@ -87,3 +91,2 @@ return res; | ||
filePath = path_1.default.relative(path_1.default.join(this.baseDir, "src"), filePath); | ||
// TODO: validate supplied params against those in op | ||
const op = this.findOpByPath(filePath); | ||
@@ -90,0 +93,0 @@ const parameters = buildParameters(op, params); |
@@ -50,3 +50,9 @@ "use strict"; | ||
parameterJson = await common_1.readStdin(); | ||
const params = JSON.parse(parameterJson); | ||
let params; | ||
try { | ||
params = JSON.parse(parameterJson); | ||
} | ||
catch { | ||
throw new common_1.UIError(`Parameters argument must be valid JSON; got: ${parameterJson}`); | ||
} | ||
const app = await app_1.default.fromCloneDir(path_1.default.dirname(scriptPath)); | ||
@@ -53,0 +59,0 @@ let res = await app.runSourceAsync(scriptPath, params, line => { |
{ | ||
"name": "@transposit/cli", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Transposit CLI", | ||
@@ -5,0 +5,0 @@ "main": "lib/app.js", |
@@ -65,1 +65,4 @@ # Transposit CLI | ||
`transposit run`. | ||
- If you edit the `manifest.json`, e.g. to change the parameters that an | ||
operation takes, you likewise will need to commit and push before running. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
72195
940
68