@stackone/cli 1.1.0 → 1.2.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/chunk-CUT6urMc.cjs +1 -30
- package/dist/cli.cjs +1 -7
- package/dist/cli.js +1 -7
- package/dist/cliCore-B4dGs2_5.js +5 -0
- package/dist/cliCore-BxOV5Evf.cjs +5 -0
- package/dist/esm-BenXeAeS.js +1 -1572
- package/dist/esm-Chmlhd00.cjs +1 -1573
- package/dist/index.cjs +1 -3
- package/dist/index.js +1 -3
- package/package.json +3 -2
- package/dist/cliCore-Cgoai805.cjs +0 -189
- package/dist/cliCore-jii80_E0.js +0 -183
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "StackOne Connect CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"clean": "rimraf dist",
|
|
19
19
|
"prebuild": "npm run clean",
|
|
20
|
-
"build": "tsdown --env.NODE_ENV=production",
|
|
20
|
+
"build": "tsdown --env.NODE_ENV=production --minify",
|
|
21
21
|
"prebuild:dev": "npm run clean",
|
|
22
22
|
"build:dev": "tsdown --env.NODE_ENV=development",
|
|
23
23
|
"code:format": "biome format ./src ./*.mjs",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"lint:fix": "npm run code:check:fix",
|
|
31
31
|
"test": "FORCE_COLOR=1 vitest run",
|
|
32
32
|
"test:watch": "FORCE_COLOR=1 vitest watch --silent",
|
|
33
|
+
"test:typecheck": "tsc --noEmit --project tsconfig.tests.json",
|
|
33
34
|
"publish-release": "npm publish --access=public"
|
|
34
35
|
},
|
|
35
36
|
"keywords": [
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const chalk = require_chunk.__toESM(require("chalk"));
|
|
3
|
-
const commander = require_chunk.__toESM(require("commander"));
|
|
4
|
-
const __stackone_connect_sdk = require_chunk.__toESM(require("@stackone/connect-sdk"));
|
|
5
|
-
const fs = require_chunk.__toESM(require("fs"));
|
|
6
|
-
const ora = require_chunk.__toESM(require("ora"));
|
|
7
|
-
const path = require_chunk.__toESM(require("path"));
|
|
8
|
-
const url = require_chunk.__toESM(require("url"));
|
|
9
|
-
|
|
10
|
-
//#region src/utils/logger.ts
|
|
11
|
-
var Logger = class {
|
|
12
|
-
static info(message) {
|
|
13
|
-
console.info(chalk.default.blue("ℹ"), message);
|
|
14
|
-
}
|
|
15
|
-
static warn(message) {
|
|
16
|
-
console.info(chalk.default.yellow("⚠"), message);
|
|
17
|
-
}
|
|
18
|
-
static error(message) {
|
|
19
|
-
console.info(chalk.default.red("✗"), message);
|
|
20
|
-
}
|
|
21
|
-
static success(message) {
|
|
22
|
-
console.info(chalk.default.green("✓"), message);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/commands/validate.ts
|
|
28
|
-
var ValidateCommand = class {
|
|
29
|
-
async execute(options) {
|
|
30
|
-
const { watchMode, fileOrDir } = options;
|
|
31
|
-
const spinner = (0, ora.default)("Watching for changes...");
|
|
32
|
-
const displayWatchModeEnabled = () => {
|
|
33
|
-
console.clear();
|
|
34
|
-
console.info(chalk.default.yellow("Watch mode enabled. Press \"q\" to quit.\n"));
|
|
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
|
-
}
|
|
43
|
-
if (watchMode) {
|
|
44
|
-
const { watch } = await Promise.resolve().then(() => require("./esm-Chmlhd00.cjs"));
|
|
45
|
-
const readline = await import("readline");
|
|
46
|
-
const rl = readline.createInterface({
|
|
47
|
-
input: process.stdin,
|
|
48
|
-
output: process.stdout
|
|
49
|
-
});
|
|
50
|
-
process.stdin.setRawMode(true);
|
|
51
|
-
process.stdin.resume();
|
|
52
|
-
process.stdin.setEncoding("utf8");
|
|
53
|
-
const cleanup = () => {
|
|
54
|
-
console.info(chalk.default.grey("\n\nExiting watch mode..."));
|
|
55
|
-
watcher.close();
|
|
56
|
-
spinner.stop();
|
|
57
|
-
rl.close();
|
|
58
|
-
process.exit(0);
|
|
59
|
-
};
|
|
60
|
-
displayWatchModeEnabled();
|
|
61
|
-
console.info(chalk.default.blue(`Running connector(s) validations...`));
|
|
62
|
-
await validateConnector(fileOrDir);
|
|
63
|
-
spinner.start();
|
|
64
|
-
const watcher = watch(fileOrDir || ".", {
|
|
65
|
-
ignored: /(^|[/\\])\../,
|
|
66
|
-
persistent: true
|
|
67
|
-
});
|
|
68
|
-
watcher.on("change", async (path$1) => {
|
|
69
|
-
displayWatchModeEnabled();
|
|
70
|
-
spinner.stop();
|
|
71
|
-
console.info(chalk.default.blue(`File change detected. Running connector(s) validations...`));
|
|
72
|
-
await validateConnector(fileOrDir);
|
|
73
|
-
spinner.start();
|
|
74
|
-
});
|
|
75
|
-
process.stdin.on("data", (key) => {
|
|
76
|
-
if (key.toString() === "q") cleanup();
|
|
77
|
-
});
|
|
78
|
-
process.on("SIGINT", () => {
|
|
79
|
-
cleanup();
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
await validateConnector(fileOrDir);
|
|
83
|
-
process.exit(0);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
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
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/utils/packageVersion.ts
|
|
134
|
-
const getPackageVersion = () => {
|
|
135
|
-
try {
|
|
136
|
-
const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
137
|
-
const __dirname$1 = (0, path.dirname)(__filename$1);
|
|
138
|
-
const packageJsonPath = (0, path.join)(__dirname$1, "..", "package.json");
|
|
139
|
-
const packageJson = JSON.parse((0, fs.readFileSync)(packageJsonPath, "utf8"));
|
|
140
|
-
return packageJson.version;
|
|
141
|
-
} catch {
|
|
142
|
-
return "unknown";
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/cliCore.ts
|
|
148
|
-
var CLI = class {
|
|
149
|
-
constructor(program = new commander.Command(), version = getPackageVersion()) {
|
|
150
|
-
this.program = program;
|
|
151
|
-
this.version = version;
|
|
152
|
-
this.setupProgram();
|
|
153
|
-
this.registerCommands();
|
|
154
|
-
}
|
|
155
|
-
setupProgram() {
|
|
156
|
-
this.program.name("stackone").description("StackOne Connect CLI tool").version(this.version);
|
|
157
|
-
}
|
|
158
|
-
registerCommands() {
|
|
159
|
-
const validateCommand = new ValidateCommand();
|
|
160
|
-
this.program.configureOutput({
|
|
161
|
-
writeOut: (str) => process.stdout.write(str),
|
|
162
|
-
writeErr: (str) => process.stderr.write(str),
|
|
163
|
-
outputError: (str, write) => {
|
|
164
|
-
write(chalk.default.red(str));
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
this.program.command("validate").option("-w, --watch", "Run in watch mode").addArgument(new commander.Argument("<path>", "Connector file or directory with connectors to validate")).description("Validate a StackOne connector").action((fileOrDir, options) => {
|
|
168
|
-
validateCommand.execute({
|
|
169
|
-
watchMode: options.watch,
|
|
170
|
-
fileOrDir
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
this.program.command("version").description("Show version information").action(() => {
|
|
174
|
-
console.info(`${chalk.default.greenBright("StackOne")} ${chalk.default.grey("CLI")} ${chalk.default.whiteBright(this.version)}`);
|
|
175
|
-
process.exit(0);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
run() {
|
|
179
|
-
this.program.parse(process.argv);
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
//#endregion
|
|
184
|
-
Object.defineProperty(exports, 'CLI', {
|
|
185
|
-
enumerable: true,
|
|
186
|
-
get: function () {
|
|
187
|
-
return CLI;
|
|
188
|
-
}
|
|
189
|
-
});
|
package/dist/cliCore-jii80_E0.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { Argument, Command } from "commander";
|
|
3
|
-
import { validateYamlConnector } from "@stackone/connect-sdk";
|
|
4
|
-
import { readFileSync, readdirSync, statSync } from "fs";
|
|
5
|
-
import ora from "ora";
|
|
6
|
-
import { dirname, join } from "path";
|
|
7
|
-
import { fileURLToPath } from "url";
|
|
8
|
-
|
|
9
|
-
//#region src/utils/logger.ts
|
|
10
|
-
var Logger = class {
|
|
11
|
-
static info(message) {
|
|
12
|
-
console.info(chalk.blue("ℹ"), message);
|
|
13
|
-
}
|
|
14
|
-
static warn(message) {
|
|
15
|
-
console.info(chalk.yellow("⚠"), message);
|
|
16
|
-
}
|
|
17
|
-
static error(message) {
|
|
18
|
-
console.info(chalk.red("✗"), message);
|
|
19
|
-
}
|
|
20
|
-
static success(message) {
|
|
21
|
-
console.info(chalk.green("✓"), message);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/commands/validate.ts
|
|
27
|
-
var ValidateCommand = class {
|
|
28
|
-
async execute(options) {
|
|
29
|
-
const { watchMode, fileOrDir } = options;
|
|
30
|
-
const spinner = ora("Watching for changes...");
|
|
31
|
-
const displayWatchModeEnabled = () => {
|
|
32
|
-
console.clear();
|
|
33
|
-
console.info(chalk.yellow("Watch mode enabled. Press \"q\" to quit.\n"));
|
|
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
|
-
}
|
|
42
|
-
if (watchMode) {
|
|
43
|
-
const { watch: watch$1 } = await import("./esm-BenXeAeS.js");
|
|
44
|
-
const readline = await import("readline");
|
|
45
|
-
const rl = readline.createInterface({
|
|
46
|
-
input: process.stdin,
|
|
47
|
-
output: process.stdout
|
|
48
|
-
});
|
|
49
|
-
process.stdin.setRawMode(true);
|
|
50
|
-
process.stdin.resume();
|
|
51
|
-
process.stdin.setEncoding("utf8");
|
|
52
|
-
const cleanup = () => {
|
|
53
|
-
console.info(chalk.grey("\n\nExiting watch mode..."));
|
|
54
|
-
watcher.close();
|
|
55
|
-
spinner.stop();
|
|
56
|
-
rl.close();
|
|
57
|
-
process.exit(0);
|
|
58
|
-
};
|
|
59
|
-
displayWatchModeEnabled();
|
|
60
|
-
console.info(chalk.blue(`Running connector(s) validations...`));
|
|
61
|
-
await validateConnector(fileOrDir);
|
|
62
|
-
spinner.start();
|
|
63
|
-
const watcher = watch$1(fileOrDir || ".", {
|
|
64
|
-
ignored: /(^|[/\\])\../,
|
|
65
|
-
persistent: true
|
|
66
|
-
});
|
|
67
|
-
watcher.on("change", async (path) => {
|
|
68
|
-
displayWatchModeEnabled();
|
|
69
|
-
spinner.stop();
|
|
70
|
-
console.info(chalk.blue(`File change detected. Running connector(s) validations...`));
|
|
71
|
-
await validateConnector(fileOrDir);
|
|
72
|
-
spinner.start();
|
|
73
|
-
});
|
|
74
|
-
process.stdin.on("data", (key) => {
|
|
75
|
-
if (key.toString() === "q") cleanup();
|
|
76
|
-
});
|
|
77
|
-
process.on("SIGINT", () => {
|
|
78
|
-
cleanup();
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
await validateConnector(fileOrDir);
|
|
82
|
-
process.exit(0);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
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
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/utils/packageVersion.ts
|
|
133
|
-
const getPackageVersion = () => {
|
|
134
|
-
try {
|
|
135
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
136
|
-
const __dirname = dirname(__filename);
|
|
137
|
-
const packageJsonPath = join(__dirname, "..", "package.json");
|
|
138
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
139
|
-
return packageJson.version;
|
|
140
|
-
} catch {
|
|
141
|
-
return "unknown";
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/cliCore.ts
|
|
147
|
-
var CLI = class {
|
|
148
|
-
constructor(program = new Command(), version = getPackageVersion()) {
|
|
149
|
-
this.program = program;
|
|
150
|
-
this.version = version;
|
|
151
|
-
this.setupProgram();
|
|
152
|
-
this.registerCommands();
|
|
153
|
-
}
|
|
154
|
-
setupProgram() {
|
|
155
|
-
this.program.name("stackone").description("StackOne Connect CLI tool").version(this.version);
|
|
156
|
-
}
|
|
157
|
-
registerCommands() {
|
|
158
|
-
const validateCommand = new ValidateCommand();
|
|
159
|
-
this.program.configureOutput({
|
|
160
|
-
writeOut: (str) => process.stdout.write(str),
|
|
161
|
-
writeErr: (str) => process.stderr.write(str),
|
|
162
|
-
outputError: (str, write) => {
|
|
163
|
-
write(chalk.red(str));
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
this.program.command("validate").option("-w, --watch", "Run in watch mode").addArgument(new Argument("<path>", "Connector file or directory with connectors to validate")).description("Validate a StackOne connector").action((fileOrDir, options) => {
|
|
167
|
-
validateCommand.execute({
|
|
168
|
-
watchMode: options.watch,
|
|
169
|
-
fileOrDir
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
this.program.command("version").description("Show version information").action(() => {
|
|
173
|
-
console.info(`${chalk.greenBright("StackOne")} ${chalk.grey("CLI")} ${chalk.whiteBright(this.version)}`);
|
|
174
|
-
process.exit(0);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
run() {
|
|
178
|
-
this.program.parse(process.argv);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
//#endregion
|
|
183
|
-
export { CLI };
|