@stackone/cli 1.0.0 → 1.1.0
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/cli.cjs
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
2
|
const chalk = require_chunk.__toESM(require("chalk"));
|
|
3
3
|
const commander = require_chunk.__toESM(require("commander"));
|
|
4
|
-
const
|
|
4
|
+
const __stackone_connect_sdk = require_chunk.__toESM(require("@stackone/connect-sdk"));
|
|
5
5
|
const fs = require_chunk.__toESM(require("fs"));
|
|
6
|
+
const ora = require_chunk.__toESM(require("ora"));
|
|
6
7
|
const path = require_chunk.__toESM(require("path"));
|
|
7
8
|
const url = require_chunk.__toESM(require("url"));
|
|
8
9
|
|
|
@@ -33,6 +34,12 @@ var ValidateCommand = class {
|
|
|
33
34
|
console.info(chalk.default.yellow("Watch mode enabled. Press \"q\" to quit.\n"));
|
|
34
35
|
};
|
|
35
36
|
if (!fileOrDir) return;
|
|
37
|
+
try {
|
|
38
|
+
(0, fs.statSync)(fileOrDir);
|
|
39
|
+
} catch {
|
|
40
|
+
Logger.error(`File or directory not found: ${fileOrDir}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
36
43
|
if (watchMode) {
|
|
37
44
|
const { watch } = await Promise.resolve().then(() => require("./esm-Chmlhd00.cjs"));
|
|
38
45
|
const readline = await import("readline");
|
|
@@ -71,12 +78,55 @@ var ValidateCommand = class {
|
|
|
71
78
|
process.on("SIGINT", () => {
|
|
72
79
|
cleanup();
|
|
73
80
|
});
|
|
74
|
-
} else
|
|
81
|
+
} else {
|
|
82
|
+
await validateConnector(fileOrDir);
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
75
85
|
}
|
|
76
86
|
};
|
|
77
|
-
const validateConnector = async (
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
const validateConnector = async (fileOrDir) => {
|
|
88
|
+
const stats = (0, fs.statSync)(fileOrDir);
|
|
89
|
+
if (stats.isDirectory()) {
|
|
90
|
+
const files = (0, fs.readdirSync)(fileOrDir);
|
|
91
|
+
const yamlFiles = files.filter((file) => file.endsWith(".s1.yaml"));
|
|
92
|
+
if (yamlFiles.length === 0) {
|
|
93
|
+
Logger.error(`No StackOne connectors found in directory: ${fileOrDir}. Connector files need to have the extension .s1.yaml.\n`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
let validCount = 0;
|
|
97
|
+
let invalidCount = 0;
|
|
98
|
+
for (const file of yamlFiles) {
|
|
99
|
+
const filePath = `${fileOrDir}/${file}`;
|
|
100
|
+
const fileStats = (0, fs.statSync)(filePath);
|
|
101
|
+
if (fileStats.isFile()) {
|
|
102
|
+
const isValid = await validateSingleConnector(filePath);
|
|
103
|
+
if (isValid) validCount++;
|
|
104
|
+
else invalidCount++;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
Logger.info(`Validation completed: ${validCount} valid, ${invalidCount} invalid connectors.\n`);
|
|
108
|
+
} else if (stats.isFile() && fileOrDir.endsWith("s1.yaml")) await validateSingleConnector(fileOrDir);
|
|
109
|
+
else Logger.error(`No StackOne connector found: ${fileOrDir}. Connector files need to have the extension .s1.yaml.\n`);
|
|
110
|
+
};
|
|
111
|
+
const validateSingleConnector = async (path$1) => {
|
|
112
|
+
const fileContents = (0, fs.readFileSync)(path$1, "utf8");
|
|
113
|
+
const result = (0, __stackone_connect_sdk.validateYamlConnector)(fileContents);
|
|
114
|
+
const errors = result?.errors ?? [];
|
|
115
|
+
if (result.success) {
|
|
116
|
+
const filename = path$1.split("/").pop() || path$1;
|
|
117
|
+
Logger.success(`Connector ${filename} is valid!\n`);
|
|
118
|
+
return true;
|
|
119
|
+
} else if (errors.length > 0) {
|
|
120
|
+
Logger.error(`Connector ${path$1} is not valid. Please fix the following errors:\n`);
|
|
121
|
+
errors.forEach((error) => {
|
|
122
|
+
console.info(chalk.default.red(`- ${error.message} | Line: ${error.line}`));
|
|
123
|
+
});
|
|
124
|
+
console.info("\n");
|
|
125
|
+
return false;
|
|
126
|
+
} else {
|
|
127
|
+
Logger.error(`Connector ${path$1} is not valid. Please check the file for errors.`);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
80
130
|
};
|
|
81
131
|
|
|
82
132
|
//#endregion
|
|
@@ -122,6 +172,7 @@ var CLI = class {
|
|
|
122
172
|
});
|
|
123
173
|
this.program.command("version").description("Show version information").action(() => {
|
|
124
174
|
console.info(`${chalk.default.greenBright("StackOne")} ${chalk.default.grey("CLI")} ${chalk.default.whiteBright(this.version)}`);
|
|
175
|
+
process.exit(0);
|
|
125
176
|
});
|
|
126
177
|
}
|
|
127
178
|
run() {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { Argument, Command } from "commander";
|
|
3
|
+
import { validateYamlConnector } from "@stackone/connect-sdk";
|
|
4
|
+
import { readFileSync, readdirSync, statSync } from "fs";
|
|
3
5
|
import ora from "ora";
|
|
4
|
-
import { readFileSync } from "fs";
|
|
5
6
|
import { dirname, join } from "path";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
7
8
|
|
|
@@ -32,6 +33,12 @@ var ValidateCommand = class {
|
|
|
32
33
|
console.info(chalk.yellow("Watch mode enabled. Press \"q\" to quit.\n"));
|
|
33
34
|
};
|
|
34
35
|
if (!fileOrDir) return;
|
|
36
|
+
try {
|
|
37
|
+
statSync(fileOrDir);
|
|
38
|
+
} catch {
|
|
39
|
+
Logger.error(`File or directory not found: ${fileOrDir}`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
35
42
|
if (watchMode) {
|
|
36
43
|
const { watch: watch$1 } = await import("./esm-BenXeAeS.js");
|
|
37
44
|
const readline = await import("readline");
|
|
@@ -70,12 +77,55 @@ var ValidateCommand = class {
|
|
|
70
77
|
process.on("SIGINT", () => {
|
|
71
78
|
cleanup();
|
|
72
79
|
});
|
|
73
|
-
} else
|
|
80
|
+
} else {
|
|
81
|
+
await validateConnector(fileOrDir);
|
|
82
|
+
process.exit(0);
|
|
83
|
+
}
|
|
74
84
|
}
|
|
75
85
|
};
|
|
76
|
-
const validateConnector = async (
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
const validateConnector = async (fileOrDir) => {
|
|
87
|
+
const stats = statSync(fileOrDir);
|
|
88
|
+
if (stats.isDirectory()) {
|
|
89
|
+
const files = readdirSync(fileOrDir);
|
|
90
|
+
const yamlFiles = files.filter((file) => file.endsWith(".s1.yaml"));
|
|
91
|
+
if (yamlFiles.length === 0) {
|
|
92
|
+
Logger.error(`No StackOne connectors found in directory: ${fileOrDir}. Connector files need to have the extension .s1.yaml.\n`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let validCount = 0;
|
|
96
|
+
let invalidCount = 0;
|
|
97
|
+
for (const file of yamlFiles) {
|
|
98
|
+
const filePath = `${fileOrDir}/${file}`;
|
|
99
|
+
const fileStats = statSync(filePath);
|
|
100
|
+
if (fileStats.isFile()) {
|
|
101
|
+
const isValid = await validateSingleConnector(filePath);
|
|
102
|
+
if (isValid) validCount++;
|
|
103
|
+
else invalidCount++;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
Logger.info(`Validation completed: ${validCount} valid, ${invalidCount} invalid connectors.\n`);
|
|
107
|
+
} else if (stats.isFile() && fileOrDir.endsWith("s1.yaml")) await validateSingleConnector(fileOrDir);
|
|
108
|
+
else Logger.error(`No StackOne connector found: ${fileOrDir}. Connector files need to have the extension .s1.yaml.\n`);
|
|
109
|
+
};
|
|
110
|
+
const validateSingleConnector = async (path) => {
|
|
111
|
+
const fileContents = readFileSync(path, "utf8");
|
|
112
|
+
const result = validateYamlConnector(fileContents);
|
|
113
|
+
const errors = result?.errors ?? [];
|
|
114
|
+
if (result.success) {
|
|
115
|
+
const filename = path.split("/").pop() || path;
|
|
116
|
+
Logger.success(`Connector ${filename} is valid!\n`);
|
|
117
|
+
return true;
|
|
118
|
+
} else if (errors.length > 0) {
|
|
119
|
+
Logger.error(`Connector ${path} is not valid. Please fix the following errors:\n`);
|
|
120
|
+
errors.forEach((error) => {
|
|
121
|
+
console.info(chalk.red(`- ${error.message} | Line: ${error.line}`));
|
|
122
|
+
});
|
|
123
|
+
console.info("\n");
|
|
124
|
+
return false;
|
|
125
|
+
} else {
|
|
126
|
+
Logger.error(`Connector ${path} is not valid. Please check the file for errors.`);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
79
129
|
};
|
|
80
130
|
|
|
81
131
|
//#endregion
|
|
@@ -121,6 +171,7 @@ var CLI = class {
|
|
|
121
171
|
});
|
|
122
172
|
this.program.command("version").description("Show version information").action(() => {
|
|
123
173
|
console.info(`${chalk.greenBright("StackOne")} ${chalk.grey("CLI")} ${chalk.whiteBright(this.version)}`);
|
|
174
|
+
process.exit(0);
|
|
124
175
|
});
|
|
125
176
|
}
|
|
126
177
|
run() {
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "StackOne Connect CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
|
-
"types": "dist/
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
10
|
"stackone": "dist/cli.js"
|
|
11
11
|
},
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"author": "StackOne",
|
|
42
42
|
"license": "ISC",
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"@stackone/connect-sdk": "*",
|
|
44
45
|
"chalk": "^5.3.0",
|
|
45
46
|
"commander": "^12.1.0",
|
|
46
47
|
"inquirer": "^12.0.0",
|