@intuned/runtime-dev 1.0.6-cli.8.2.0 → 1.0.6-cli.8.2.2
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/commands/deploy/deploy.js +2 -2
- package/dist/commands/deploy/utils.js +2 -2
- package/dist/commands/init/utils.js +42 -2
- package/dist/commands/intuned-run/intuned-run.js +11 -8
- package/dist/commands/intuned-run/utils.d.ts +6 -4
- package/dist/commands/intuned-run/utils.js +20 -16
- package/dist/common/cli/constants.d.ts +5 -0
- package/dist/common/cli/constants.js +7 -2
- package/package.json +1 -1
|
@@ -33,8 +33,8 @@ _commander.program.description("Deploy an Intuned project to be public").argumen
|
|
|
33
33
|
if (!deployStarted) {
|
|
34
34
|
throw new Error("Project not deployed");
|
|
35
35
|
}
|
|
36
|
-
const url = `https://
|
|
37
|
-
console.log(_chalk.default.green(`\n✅ Project "${_projectName}" deployed successfully!` + `\n\nYou can check your project on the platform: ${_chalk.default.bold(url)}\n`));
|
|
36
|
+
const url = process.env.DOMAIN || `https://app.intuned.io`;
|
|
37
|
+
console.log(_chalk.default.green(`\n✅ Project "${_projectName}" deployed successfully!` + `\n\nYou can check your project on the platform: ${_chalk.default.bold(`${url}/projects`)}\n`));
|
|
38
38
|
} catch (error) {
|
|
39
39
|
console.error(_chalk.default.red(`\n${error.message}`));
|
|
40
40
|
process.exit(1);
|
|
@@ -149,7 +149,7 @@ async function deployProject(projectName, auth) {
|
|
|
149
149
|
workspaceId,
|
|
150
150
|
apiKey
|
|
151
151
|
} = auth;
|
|
152
|
-
const baseUrl =
|
|
152
|
+
const baseUrl = process.env.DOMAIN || `https://app.intuned.io`;
|
|
153
153
|
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create`;
|
|
154
154
|
const headers = {
|
|
155
155
|
"x-api-key": apiKey,
|
|
@@ -308,7 +308,7 @@ const validateIntunedProject = async () => {
|
|
|
308
308
|
exports.validateIntunedProject = validateIntunedProject;
|
|
309
309
|
const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
|
|
310
310
|
try {
|
|
311
|
-
const baseUrl =
|
|
311
|
+
const baseUrl = process.env.DOMAIN || `https://app.intuned.io`;
|
|
312
312
|
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create/${projectName}/result`;
|
|
313
313
|
const headers = {
|
|
314
314
|
"x-api-key": apiKey,
|
|
@@ -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; }
|
|
@@ -128,9 +129,10 @@ async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
|
|
|
128
129
|
console.log(_chalk.default.cyan(`\n🚀 Initializing ${_chalk.default.bold(templateId)} project...\n`));
|
|
129
130
|
console.log(_chalk.default.cyan("📦 Fetching template..."));
|
|
130
131
|
const template = await fetchProjectTemplate(templateId);
|
|
131
|
-
console.log(_chalk.default.green(`✓ Template "${
|
|
132
|
+
console.log(_chalk.default.green(`✓ Template "${templateId}" fetched successfully`));
|
|
132
133
|
console.log(_chalk.default.cyan("🔨 Creating project files..."));
|
|
133
134
|
const codeTree = template;
|
|
135
|
+
prepareCLITemplate(codeTree);
|
|
134
136
|
await mountFiles(cwd, codeTree);
|
|
135
137
|
console.log(_chalk.default.green("✓ Project files created"));
|
|
136
138
|
console.log((0, _boxen.default)(_chalk.default.green(`✅ Project initialized successfully`) + `\n\n${_chalk.default.cyan("Project details:")}` + `\n• Template: ${_chalk.default.bold(templateId)}` + `\n• Directory: ${_chalk.default.bold(process.cwd())}` + `\n\n${_chalk.default.cyan("Next steps:")}` + `\n1. ${_chalk.default.bold("cd")} into your project directory (if not already there)` + `\n2. Run ${_chalk.default.bold("npm/yarn install")} to install dependencies` + `\n3. Develop, test and run your automation APIs`, {
|
|
@@ -141,7 +143,7 @@ async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
|
|
|
141
143
|
}));
|
|
142
144
|
}
|
|
143
145
|
async function fetchProjectTemplate(templateId) {
|
|
144
|
-
const baseUrl =
|
|
146
|
+
const baseUrl = process.env.DOMAIN || `https://app.intuned.io`;
|
|
145
147
|
const url = `${baseUrl}/api/templates/${templateId}`;
|
|
146
148
|
const response = await fetch(url);
|
|
147
149
|
if (!response.ok) {
|
|
@@ -152,4 +154,42 @@ async function fetchProjectTemplate(templateId) {
|
|
|
152
154
|
throw new Error("Template not found");
|
|
153
155
|
}
|
|
154
156
|
return data.template;
|
|
157
|
+
}
|
|
158
|
+
function prepareCLITemplate(codeTree) {
|
|
159
|
+
codeTree["parameters"] = {
|
|
160
|
+
directory: {}
|
|
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
|
+
}
|
|
167
|
+
codeTree["README.md"] = {
|
|
168
|
+
file: {
|
|
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
|
+
`
|
|
193
|
+
}
|
|
194
|
+
};
|
|
155
195
|
}
|
|
@@ -12,20 +12,21 @@ 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("-
|
|
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
|
|
22
|
-
const
|
|
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
|
|
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;
|
|
@@ -36,7 +37,9 @@ _commander.program.name("intuned-run").description("Run an Intuned API with para
|
|
|
36
37
|
console.log(_chalk.default.white(JSON.stringify(result, null, 2)));
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
if (options.storeResults) {
|
|
41
|
+
await (0, _utils.writeResultToFile)(runId, result, payloadToAppend);
|
|
42
|
+
}
|
|
40
43
|
} catch (error) {
|
|
41
44
|
console.error(_chalk.default.red(`\nError: ${error.message}`));
|
|
42
45
|
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(
|
|
3
|
-
export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined
|
|
4
|
-
|
|
5
|
-
|
|
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(
|
|
42
|
-
const
|
|
43
|
-
|
|
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(
|
|
47
|
+
await fs.writeJSON(resultsPath, result, {
|
|
46
48
|
spaces: 2
|
|
47
49
|
});
|
|
48
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
+
};
|