@boltic/cli 1.0.6-beta.2 โ 1.0.6-beta.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.
- package/.claude/settings.local.json +2 -1
- package/commands/integration.js +102 -1
- package/helper/folder.js +14 -3
- package/package.json +1 -1
package/commands/integration.js
CHANGED
|
@@ -50,6 +50,10 @@ const commands = {
|
|
|
50
50
|
description: "Show detailed information about an integration",
|
|
51
51
|
action: handleStatus,
|
|
52
52
|
},
|
|
53
|
+
test: {
|
|
54
|
+
description: "Run tests for the integration",
|
|
55
|
+
action: handleTest,
|
|
56
|
+
},
|
|
53
57
|
help: {
|
|
54
58
|
description: "Show help for integration commands",
|
|
55
59
|
action: showHelp,
|
|
@@ -574,7 +578,10 @@ async function handleCreate() {
|
|
|
574
578
|
);
|
|
575
579
|
|
|
576
580
|
// Create folder structure with the integration name
|
|
577
|
-
await createIntegrationFolderStructure(
|
|
581
|
+
await createIntegrationFolderStructure(
|
|
582
|
+
integration,
|
|
583
|
+
create_catalogue
|
|
584
|
+
);
|
|
578
585
|
|
|
579
586
|
// Also share Documentation URL to the user: https://docs.boltic.io/docs/integration-builder/develop/boilerplate
|
|
580
587
|
const documentationUrl =
|
|
@@ -1000,6 +1007,100 @@ async function handleStatus() {
|
|
|
1000
1007
|
}
|
|
1001
1008
|
}
|
|
1002
1009
|
|
|
1010
|
+
async function handleTest(args) {
|
|
1011
|
+
// Parse command line arguments
|
|
1012
|
+
let currentDir = process.cwd();
|
|
1013
|
+
const pathIndex = args.indexOf("--path");
|
|
1014
|
+
|
|
1015
|
+
if (pathIndex !== -1 && args[pathIndex + 1]) {
|
|
1016
|
+
currentDir = args[pathIndex + 1];
|
|
1017
|
+
// Validate the provided path
|
|
1018
|
+
if (!fs.existsSync(currentDir)) {
|
|
1019
|
+
console.error(
|
|
1020
|
+
chalk.red(
|
|
1021
|
+
`Error: The specified path does not exist: ${currentDir}`
|
|
1022
|
+
)
|
|
1023
|
+
);
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
const { spawn } = await import("child_process");
|
|
1029
|
+
|
|
1030
|
+
console.log(chalk.cyan.bold("\n๐งช Running integration tests...\n"));
|
|
1031
|
+
|
|
1032
|
+
// Look for test directory
|
|
1033
|
+
const testDirs = ["test", "tests", "__tests__"];
|
|
1034
|
+
let testDir = null;
|
|
1035
|
+
|
|
1036
|
+
for (const dir of testDirs) {
|
|
1037
|
+
if (fs.existsSync(dir)) {
|
|
1038
|
+
testDir = dir;
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
if (!testDir) {
|
|
1044
|
+
console.log(
|
|
1045
|
+
chalk.yellow(
|
|
1046
|
+
"โ ๏ธ No test directory found. Looked for: test, tests, __tests__"
|
|
1047
|
+
)
|
|
1048
|
+
);
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
console.log(chalk.dim(`๐ Found test directory: ${testDir}`));
|
|
1053
|
+
|
|
1054
|
+
// Check if Jest is available
|
|
1055
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
1056
|
+
let hasJest = false;
|
|
1057
|
+
|
|
1058
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
1059
|
+
try {
|
|
1060
|
+
const packageJson = JSON.parse(
|
|
1061
|
+
fs.readFileSync(packageJsonPath, "utf-8")
|
|
1062
|
+
);
|
|
1063
|
+
hasJest = !!(
|
|
1064
|
+
packageJson.devDependencies?.jest ||
|
|
1065
|
+
packageJson.dependencies?.jest
|
|
1066
|
+
);
|
|
1067
|
+
} catch (error) {
|
|
1068
|
+
console.log(chalk.yellow("โ ๏ธ Could not read package.json"));
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
if (!hasJest) {
|
|
1073
|
+
console.log(
|
|
1074
|
+
chalk.red(
|
|
1075
|
+
"โ Jest is not installed. Please install Jest to run tests."
|
|
1076
|
+
)
|
|
1077
|
+
);
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// Run Jest with the test directory
|
|
1082
|
+
return new Promise((resolve, reject) => {
|
|
1083
|
+
const jestProcess = spawn("npx", ["jest", testDir, "--verbose"], {
|
|
1084
|
+
stdio: "inherit",
|
|
1085
|
+
shell: true,
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
jestProcess.on("close", (code) => {
|
|
1089
|
+
if (code === 0) {
|
|
1090
|
+
console.log(chalk.green.bold("\nโ
All tests passed!"));
|
|
1091
|
+
} else {
|
|
1092
|
+
console.log(chalk.red.bold("\nโ Some tests failed."));
|
|
1093
|
+
}
|
|
1094
|
+
resolve(code);
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
jestProcess.on("error", (error) => {
|
|
1098
|
+
console.error(chalk.red("โ Error running tests:"), error.message);
|
|
1099
|
+
reject(error);
|
|
1100
|
+
});
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1003
1104
|
export default {
|
|
1004
1105
|
execute,
|
|
1005
1106
|
};
|
package/helper/folder.js
CHANGED
|
@@ -9,7 +9,10 @@ import {
|
|
|
9
9
|
webhook,
|
|
10
10
|
} from "../templates/schemas.js";
|
|
11
11
|
|
|
12
|
-
export const createIntegrationFolderStructure = async (
|
|
12
|
+
export const createIntegrationFolderStructure = async (
|
|
13
|
+
integration,
|
|
14
|
+
create_catalogue
|
|
15
|
+
) => {
|
|
13
16
|
const { id, name, description, icon, activity_type, trigger_type, meta } =
|
|
14
17
|
integration;
|
|
15
18
|
|
|
@@ -47,13 +50,21 @@ export const createIntegrationFolderStructure = async (integration) => {
|
|
|
47
50
|
// Create template files
|
|
48
51
|
const files = {
|
|
49
52
|
"schemas/resources/resource1.json": JSON.stringify(resource1, null, 4),
|
|
50
|
-
|
|
53
|
+
...(create_catalogue && {
|
|
54
|
+
"schemas/authentication.json": JSON.stringify(
|
|
55
|
+
authentication,
|
|
56
|
+
null,
|
|
57
|
+
4
|
|
58
|
+
),
|
|
59
|
+
}),
|
|
51
60
|
"schemas/base.json": JSON.stringify(base(name), null, 4),
|
|
52
61
|
...(!isEmpty(trigger_type) && {
|
|
53
62
|
"schemas/webhook.json": JSON.stringify(webhook(name), null, 4),
|
|
54
63
|
}),
|
|
55
64
|
"spec.json": JSON.stringify(spec, null, 4),
|
|
56
|
-
|
|
65
|
+
...(create_catalogue && {
|
|
66
|
+
"Authentication.mdx": `# ${name} Authentication`,
|
|
67
|
+
}),
|
|
57
68
|
"Documentation.mdx": `# ${name} Documentation`,
|
|
58
69
|
};
|
|
59
70
|
|