@intuned/runtime-dev 1.0.6-cli.8.2.1 → 1.0.6-cli.8.2.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.
@@ -15,6 +15,7 @@ var _inquirer = _interopRequireDefault(require("inquirer"));
15
15
  var _path = _interopRequireDefault(require("path"));
16
16
  var _boxen = _interopRequireDefault(require("boxen"));
17
17
  var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
18
+ var _constants = require("../../common/cli/constants");
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -158,9 +159,37 @@ function prepareCLITemplate(codeTree) {
158
159
  codeTree["parameters"] = {
159
160
  directory: {}
160
161
  };
162
+ if (_isFileNode(codeTree["package.json"]) && codeTree["package.json"].file) {
163
+ const packageJson = JSON.parse(codeTree["package.json"].file.contents);
164
+ packageJson.scripts = _constants.userCLIScripts;
165
+ codeTree["package.json"].file.contents = JSON.stringify(packageJson, null, 2);
166
+ }
161
167
  codeTree["README.md"] = {
162
168
  file: {
163
- contents: `# Intuned CLI Project`
169
+ contents: `# Intuned CLI Project
170
+
171
+ ## Usage Instructions
172
+
173
+ This CLI project is built with Intuned and provides the following commands:
174
+
175
+ ### Running the project
176
+ \`\`\`
177
+ npm run intuned-run
178
+ \`\`\`
179
+
180
+ ### Building the project
181
+ \`\`\`
182
+ npm run intuned-build
183
+ \`\`\`
184
+
185
+ ### Deploying the project
186
+ \`\`\`
187
+ npm run intuned-deploy
188
+ \`\`\`
189
+
190
+ ### Storage
191
+ Results from your runs will be stored in the \`./output/[runId]\` directory structure.
192
+ `
164
193
  }
165
194
  };
166
195
  }
@@ -12,31 +12,32 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
12
12
  _dotenv.default.config({
13
13
  path: `.env`
14
14
  });
15
- _commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-p, --parameters-file <file>", "JSON file containing API parameters").option("-o, --output-file <file>", "File to write the API output to").action(async (apiName, options) => {
15
+ _commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-i, --parameters-file <file>", "JSON file containing API parameters").option("-s, --store-results", "Store the results of the running API in a dedicated folder").action(async (apiName, options) => {
16
16
  try {
17
17
  if (!apiName) {
18
18
  throw new Error("API name is required, please provide it");
19
19
  }
20
20
  const inputData = await (0, _utils.loadParameters)(options.parametersFile);
21
- const outputFileId = options.outputFile;
22
- const result = await (0, _asyncLocalStorage.runWithContext)({
21
+ const runId = (0, _nanoid.nanoid)();
22
+ const {
23
+ result,
24
+ payloadToAppend
25
+ } = await (0, _asyncLocalStorage.runWithContext)({
23
26
  runEnvironment: _enums.RunEnvironment.IDE,
24
27
  extendedPayloads: [],
25
- runId: (0, _nanoid.nanoid)()
26
- }, () => (0, _utils.runApiViaCLI)(apiName, inputData, {
27
- outputFileId
28
- }));
28
+ runId
29
+ }, () => (0, _utils.runApiViaCLI)(apiName, inputData));
29
30
  if (!result) {
30
31
  console.log(_chalk.default.yellow("No result returned from the API"));
31
32
  return;
32
33
  }
33
- if (!options.outputFile) {
34
+ if (!options.storeResults) {
34
35
  console.log(_chalk.default.green(`✓ API executed successfully`));
35
36
  console.log(_chalk.default.green("Result:"));
36
37
  console.log(_chalk.default.white(JSON.stringify(result, null, 2)));
37
38
  return;
38
39
  }
39
- await (0, _utils.writeResultToFile)(outputFileId, result);
40
+ await (0, _utils.writeResultToFile)(runId, result, payloadToAppend);
40
41
  } catch (error) {
41
42
  console.error(_chalk.default.red(`\nError: ${error.message}`));
42
43
  process.exit(1);
@@ -1,5 +1,7 @@
1
+ import { Payload } from "../../runtime/export";
1
2
  export declare function loadParameters(parametersFile: string): Promise<object | null>;
2
- export declare function writeResultToFile(outputFileId: string, result: any, runId?: string): Promise<void>;
3
- export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined, options: {
4
- outputFileId?: string;
5
- }): Promise<any>;
3
+ export declare function writeResultToFile(runId: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
4
+ export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined): Promise<{
5
+ result: any;
6
+ payloadToAppend: Payload[] | undefined;
7
+ }>;
@@ -38,19 +38,28 @@ async function loadParameters(parametersFile) {
38
38
  throw new Error(`Error reading parameters file: ${error.message}`);
39
39
  }
40
40
  }
41
- async function writeResultToFile(outputFileId, result, runId) {
42
- const outputPath = _path.default.join(process.cwd(), `${outputFileId}.json`);
43
- await fs.ensureDir(_path.default.dirname(outputPath));
41
+ async function writeResultToFile(runId, result, payloadToAppend) {
42
+ const outputDir = _path.default.join(process.cwd(), "output", runId);
43
+ const resultsPath = _path.default.join(outputDir, "results.json");
44
+ const extendedPayloadsPath = _path.default.join(outputDir, "extendedPayloads.json");
45
+ await fs.ensureDir(outputDir);
44
46
  try {
45
- await fs.writeJSON(outputPath, result, {
47
+ await fs.writeJSON(resultsPath, result, {
46
48
  spaces: 2
47
49
  });
48
- console.log(_chalk.default.green(`✓ API executed successfully. Result written to ${outputPath}`));
50
+ if (payloadToAppend && payloadToAppend.length > 0) {
51
+ await fs.writeJSON(extendedPayloadsPath, payloadToAppend, {
52
+ spaces: 2
53
+ });
54
+ _Logger.logger.info(_chalk.default.underline.green.white(`Payloads to append saved into (${extendedPayloadsPath})`));
55
+ }
56
+ console.log(_chalk.default.underline.green.white(`✓ API executed successfully. Results stored in ${outputDir}`));
57
+ console.log(_chalk.default.blue(`Run ID: ${runId}`));
49
58
  } catch (error) {
50
59
  _Logger.logger.error(`Failed to write result to file: ${error.message}`);
51
60
  }
52
61
  }
53
- async function runApiViaCLI(apiName, inputData, options) {
62
+ async function runApiViaCLI(apiName, inputData) {
54
63
  const runApiResult = await (0, _runApi.runApi)({
55
64
  automationFunction: {
56
65
  name: `api/${apiName}`,
@@ -74,17 +83,12 @@ async function runApiViaCLI(apiName, inputData, options) {
74
83
  extendedPayloads: payloadToAppend
75
84
  } = runApiResult.value;
76
85
  const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
77
- if (hasPayloadToAppend && options.outputFileId) {
78
- const fileKey = `${options.outputFileId}-payloads-to-append.json`;
79
- const outputPath = _path.default.join(process.cwd(), fileKey);
80
- await fs.ensureDir(_path.default.dirname(outputPath));
81
- await fs.writeJson(outputPath, payloadToAppend, {
82
- spaces: 2
83
- });
84
- _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Payloads to append saved into (${outputPath})`));
85
- } else if (hasPayloadToAppend) {
86
+ if (hasPayloadToAppend) {
86
87
  _Logger.logger.info("payload to append:", payloadToAppend);
87
88
  _Logger.logger.info("This will only take an effect if this API run was part of a job.");
88
89
  }
89
- return result;
90
+ return {
91
+ result,
92
+ payloadToAppend
93
+ };
90
94
  }
@@ -1,3 +1,8 @@
1
1
  export declare const CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
2
2
  export declare const ProjectDeploymentStatus: string[];
3
3
  export declare const PROJECT_DEPLOY_TIMEOUT = 600000;
4
+ export declare const userCLIScripts: {
5
+ "intuned-run": string;
6
+ "intuned-build": string;
7
+ "intuned-deploy": string;
8
+ };
@@ -3,7 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
6
+ exports.userCLIScripts = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
7
7
  const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
8
8
  const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
9
- const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT = 600000;
9
+ const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT = 600000;
10
+ const userCLIScripts = exports.userCLIScripts = {
11
+ "intuned-run": "intuned-run",
12
+ "intuned-build": "intuned-build-project",
13
+ "intuned-deploy": "intuned-deploy"
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.0.6-cli.8.2.1",
3
+ "version": "1.0.6-cli.8.2.3",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",