momentic 0.0.8 → 0.0.10
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/bin/cli.js +22 -7
- package/dist/index.js +1 -0
- package/package.json +5 -2
package/bin/cli.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
+
import exec from "@actions/exec";
|
|
5
|
+
import io from "@actions/io";
|
|
4
6
|
import chalk from "chalk";
|
|
5
7
|
import { Command as Command4, Option } from "commander";
|
|
6
|
-
import
|
|
8
|
+
import quote from "quote";
|
|
9
|
+
import parseArgsStringToArgv2 from "string-argv";
|
|
7
10
|
import waitOnFn from "wait-on";
|
|
8
11
|
|
|
9
12
|
// ../../packages/types/src/commands.ts
|
|
@@ -258,6 +261,7 @@ var AIAssertionResultSchema = z4.object({
|
|
|
258
261
|
});
|
|
259
262
|
|
|
260
263
|
// ../../packages/types/src/ai-command-generation.ts
|
|
264
|
+
import parseArgsStringToArgv from "string-argv";
|
|
261
265
|
import { z as z5 } from "zod";
|
|
262
266
|
|
|
263
267
|
// ../../packages/types/src/errors.ts
|
|
@@ -2931,7 +2935,7 @@ var executeTest = async ({
|
|
|
2931
2935
|
return failed;
|
|
2932
2936
|
};
|
|
2933
2937
|
|
|
2934
|
-
// src/
|
|
2938
|
+
// src/logger.ts
|
|
2935
2939
|
var consoleLogger = {
|
|
2936
2940
|
info: console.log,
|
|
2937
2941
|
error: console.error,
|
|
@@ -2941,6 +2945,8 @@ var consoleLogger = {
|
|
|
2941
2945
|
flush: () => {
|
|
2942
2946
|
}
|
|
2943
2947
|
};
|
|
2948
|
+
|
|
2949
|
+
// src/run-test.ts
|
|
2944
2950
|
async function runTest({
|
|
2945
2951
|
testId,
|
|
2946
2952
|
apiClient,
|
|
@@ -2975,6 +2981,7 @@ async function runTest({
|
|
|
2975
2981
|
}
|
|
2976
2982
|
});
|
|
2977
2983
|
} catch (err) {
|
|
2984
|
+
consoleLogger.error(err);
|
|
2978
2985
|
await apiClient.updateRun(run.id, {
|
|
2979
2986
|
status: "FAILED",
|
|
2980
2987
|
finishedAt: /* @__PURE__ */ new Date()
|
|
@@ -3009,8 +3016,7 @@ program.command("run-tests").addOption(
|
|
|
3009
3016
|
new Option("--api-key <key>", "API key for authenticating").env("MOMENTIC_API_KEY").makeOptionMandatory(true)
|
|
3010
3017
|
).action(async (options) => {
|
|
3011
3018
|
const { tests, start, waitOn, waitOnTimeout, apiKey } = options;
|
|
3012
|
-
|
|
3013
|
-
void $`${start}`;
|
|
3019
|
+
await execCommand(start, false);
|
|
3014
3020
|
await waitOnFn({
|
|
3015
3021
|
resources: [waitOn],
|
|
3016
3022
|
timeout: waitOnTimeout * 1e3
|
|
@@ -3023,8 +3029,8 @@ program.command("run-tests").addOption(
|
|
|
3023
3029
|
baseURL: "https://api.momentic.ai",
|
|
3024
3030
|
apiKey
|
|
3025
3031
|
});
|
|
3026
|
-
const promises = tests.map((testId) => {
|
|
3027
|
-
const failed = runTest({
|
|
3032
|
+
const promises = tests.map(async (testId) => {
|
|
3033
|
+
const failed = await runTest({
|
|
3028
3034
|
testId,
|
|
3029
3035
|
apiClient,
|
|
3030
3036
|
generator: apiGenerator
|
|
@@ -3036,7 +3042,7 @@ program.command("run-tests").addOption(
|
|
|
3036
3042
|
if (failedResults.length > 0) {
|
|
3037
3043
|
console.log(
|
|
3038
3044
|
chalk.red(
|
|
3039
|
-
`Failed ${failedResults.length} out of ${results.length} tests
|
|
3045
|
+
`Failed ${failedResults.length} out of ${results.length} tests:`
|
|
3040
3046
|
)
|
|
3041
3047
|
);
|
|
3042
3048
|
failedResults.forEach((result) => {
|
|
@@ -3046,6 +3052,15 @@ program.command("run-tests").addOption(
|
|
|
3046
3052
|
}
|
|
3047
3053
|
console.log(chalk.green(`All ${results.length} tests passed!`));
|
|
3048
3054
|
});
|
|
3055
|
+
var execCommand = async (fullCommand, waitToFinish = true) => {
|
|
3056
|
+
const args = parseArgsStringToArgv2(fullCommand);
|
|
3057
|
+
const toolPath = await io.which(args[0], true);
|
|
3058
|
+
const toolArguments = args.slice(1);
|
|
3059
|
+
const promise = exec.exec(quote(toolPath), toolArguments);
|
|
3060
|
+
if (waitToFinish) {
|
|
3061
|
+
return promise;
|
|
3062
|
+
}
|
|
3063
|
+
};
|
|
3049
3064
|
async function main() {
|
|
3050
3065
|
await program.parseAsync(process.argv);
|
|
3051
3066
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "momentic",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "The Momentic SDK for Node.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,16 +37,19 @@
|
|
|
37
37
|
"selenium"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
+
"@actions/exec": "^1.1.1",
|
|
41
|
+
"@actions/io": "^1.1.3",
|
|
40
42
|
"@playwright/browser-chromium": "1.39.0",
|
|
41
43
|
"chalk": "^5.3.0",
|
|
42
44
|
"commander": "^11.1.0",
|
|
43
45
|
"cron-validator": "^1.3.1",
|
|
44
46
|
"dedent": "^1.5.1",
|
|
45
47
|
"diff-lines": "^1.1.1",
|
|
46
|
-
"execa": "^8.0.1",
|
|
47
48
|
"fetch-retry": "^5.0.6",
|
|
48
49
|
"playwright": "1.39.0",
|
|
50
|
+
"quote": "^0.4.0",
|
|
49
51
|
"set-cookie-parser": "^2.6.0",
|
|
52
|
+
"string-argv": "^0.3.2",
|
|
50
53
|
"wait-on": "^7.2.0",
|
|
51
54
|
"zod": "^3.22.4"
|
|
52
55
|
}
|