@stackone/cli 1.1.0 → 1.1.1

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.
@@ -1,30 +1 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
-
25
- Object.defineProperty(exports, '__toESM', {
26
- enumerable: true,
27
- get: function () {
28
- return __toESM;
29
- }
30
- });
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,`__toESM`,{enumerable:!0,get:function(){return s}});
package/dist/cli.cjs CHANGED
@@ -1,8 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const require_cliCore = require('./cliCore-Cgoai805.cjs');
3
-
4
- //#region src/cli.ts
5
- const cli = new require_cliCore.CLI();
6
- cli.run();
7
-
8
- //#endregion
2
+ const e=require(`./cliCore-Cgoai805.cjs`),t=new e.CLI;t.run();
package/dist/cli.js CHANGED
@@ -1,8 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import { CLI } from "./cliCore-jii80_E0.js";
3
-
4
- //#region src/cli.ts
5
- const cli = new CLI();
6
- cli.run();
7
-
8
- //#endregion
2
+ import{CLI as e}from"./cliCore-jii80_E0.js";const t=new e;t.run();
@@ -1,189 +1,5 @@
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"));
1
+ const e=require(`./chunk-CUT6urMc.cjs`),t=e.__toESM(require(`chalk`)),n=e.__toESM(require(`commander`)),r=e.__toESM(require(`@stackone/connect-sdk`)),i=e.__toESM(require(`fs`)),a=e.__toESM(require(`ora`)),o=e.__toESM(require(`path`)),s=e.__toESM(require(`url`));var c=class{static info(e){console.info(t.default.blue(`ℹ`),e)}static warn(e){console.info(t.default.yellow(`⚠`),e)}static error(e){console.info(t.default.red(`✗`),e)}static success(e){console.info(t.default.green(`✓`),e)}},l=class{async execute(e){let{watchMode:n,fileOrDir:r}=e,o=(0,a.default)(`Watching for changes...`),s=()=>{console.clear(),console.info(t.default.yellow(`Watch mode enabled. Press "q" to quit.
2
+ `))};if(r){try{(0,i.statSync)(r)}catch{c.error(`File or directory not found: ${r}`),process.exit(1)}if(n){let{watch:e}=await Promise.resolve().then(()=>require(`./esm-Chmlhd00.cjs`)),n=await import(`readline`),i=n.createInterface({input:process.stdin,output:process.stdout});process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding(`utf8`);let a=()=>{console.info(t.default.grey(`
9
3
 
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
- });
4
+ Exiting watch mode...`)),c.close(),o.stop(),i.close(),process.exit(0)};s(),console.info(t.default.blue(`Running connector(s) validations...`)),await u(r),o.start();let c=e(r||`.`,{ignored:/(^|[/\\])\../,persistent:!0});c.on(`change`,async e=>{s(),o.stop(),console.info(t.default.blue(`File change detected. Running connector(s) validations...`)),await u(r),o.start()}),process.stdin.on(`data`,e=>{e.toString()===`q`&&a()}),process.on(`SIGINT`,()=>{a()})}else await u(r),process.exit(0)}}};const u=async e=>{let t=(0,i.statSync)(e);if(t.isDirectory()){let t=(0,i.readdirSync)(e),n=t.filter(e=>e.endsWith(`.s1.yaml`));if(n.length===0){c.error(`No StackOne connectors found in directory: ${e}. Connector files need to have the extension .s1.yaml.\n`);return}let r=0,a=0;for(let t of n){let n=`${e}/${t}`,o=(0,i.statSync)(n);if(o.isFile()){let e=await d(n);e?r++:a++}}c.info(`Validation completed: ${r} valid, ${a} invalid connectors.\n`)}else t.isFile()&&e.endsWith(`s1.yaml`)?await d(e):c.error(`No StackOne connector found: ${e}. Connector files need to have the extension .s1.yaml.\n`)},d=async e=>{let n=(0,i.readFileSync)(e,`utf8`),a=(0,r.validateYamlConnector)(n),o=a?.errors??[];if(a.success){let t=e.split(`/`).pop()||e;return c.success(`Connector ${t} is valid!\n`),!0}else if(o.length>0)return c.error(`Connector ${e} is not valid. Please fix the following errors:\n`),o.forEach(e=>{console.info(t.default.red(`- ${e.message} | Line: ${e.line}`))}),console.info(`
5
+ `),!1;else return c.error(`Connector ${e} is not valid. Please check the file for errors.`),!1},f=()=>{try{let e=(0,s.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),t=(0,o.dirname)(e),n=(0,o.join)(t,`..`,`package.json`),r=JSON.parse((0,i.readFileSync)(n,`utf8`));return r.version}catch{return`unknown`}};var p=class{constructor(e=new n.Command,t=f()){this.program=e,this.version=t,this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne Connect CLI tool`).version(this.version)}registerCommands(){let e=new l;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(e,n)=>{n(t.default.red(e))}}),this.program.command(`validate`).option(`-w, --watch`,`Run in watch mode`).addArgument(new n.Argument(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((t,n)=>{e.execute({watchMode:n.watch,fileOrDir:t})}),this.program.command(`version`).description(`Show version information`).action(()=>{console.info(`${t.default.greenBright(`StackOne`)} ${t.default.grey(`CLI`)} ${t.default.whiteBright(this.version)}`),process.exit(0)})}run(){this.program.parse(process.argv)}};Object.defineProperty(exports,`CLI`,{enumerable:!0,get:function(){return p}});
@@ -1,183 +1,5 @@
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";
1
+ import e from"chalk";import{Argument as t,Command as n}from"commander";import{validateYamlConnector as r}from"@stackone/connect-sdk";import{readFileSync as i,readdirSync as a,statSync as o}from"fs";import s from"ora";import{dirname as c,join as l}from"path";import{fileURLToPath as u}from"url";var d=class{static info(t){console.info(e.blue(`ℹ`),t)}static warn(t){console.info(e.yellow(`⚠`),t)}static error(t){console.info(e.red(`✗`),t)}static success(t){console.info(e.green(`✓`),t)}},f=class{async execute(t){let{watchMode:n,fileOrDir:r}=t,i=s(`Watching for changes...`),a=()=>{console.clear(),console.info(e.yellow(`Watch mode enabled. Press "q" to quit.
2
+ `))};if(r){try{o(r)}catch{d.error(`File or directory not found: ${r}`),process.exit(1)}if(n){let{watch:t}=await import(`./esm-BenXeAeS.js`),n=await import(`readline`),o=n.createInterface({input:process.stdin,output:process.stdout});process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding(`utf8`);let s=()=>{console.info(e.grey(`
8
3
 
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 };
4
+ Exiting watch mode...`)),c.close(),i.stop(),o.close(),process.exit(0)};a(),console.info(e.blue(`Running connector(s) validations...`)),await p(r),i.start();let c=t(r||`.`,{ignored:/(^|[/\\])\../,persistent:!0});c.on(`change`,async t=>{a(),i.stop(),console.info(e.blue(`File change detected. Running connector(s) validations...`)),await p(r),i.start()}),process.stdin.on(`data`,e=>{e.toString()===`q`&&s()}),process.on(`SIGINT`,()=>{s()})}else await p(r),process.exit(0)}}};const p=async e=>{let t=o(e);if(t.isDirectory()){let t=a(e),n=t.filter(e=>e.endsWith(`.s1.yaml`));if(n.length===0){d.error(`No StackOne connectors found in directory: ${e}. Connector files need to have the extension .s1.yaml.\n`);return}let r=0,i=0;for(let t of n){let n=`${e}/${t}`,a=o(n);if(a.isFile()){let e=await m(n);e?r++:i++}}d.info(`Validation completed: ${r} valid, ${i} invalid connectors.\n`)}else t.isFile()&&e.endsWith(`s1.yaml`)?await m(e):d.error(`No StackOne connector found: ${e}. Connector files need to have the extension .s1.yaml.\n`)},m=async t=>{let n=i(t,`utf8`),a=r(n),o=a?.errors??[];if(a.success){let e=t.split(`/`).pop()||t;return d.success(`Connector ${e} is valid!\n`),!0}else if(o.length>0)return d.error(`Connector ${t} is not valid. Please fix the following errors:\n`),o.forEach(t=>{console.info(e.red(`- ${t.message} | Line: ${t.line}`))}),console.info(`
5
+ `),!1;else return d.error(`Connector ${t} is not valid. Please check the file for errors.`),!1},h=()=>{try{let e=u(import.meta.url),t=c(e),n=l(t,`..`,`package.json`),r=JSON.parse(i(n,`utf8`));return r.version}catch{return`unknown`}};var g=class{constructor(e=new n,t=h()){this.program=e,this.version=t,this.setupProgram(),this.registerCommands()}setupProgram(){this.program.name(`stackone`).description(`StackOne Connect CLI tool`).version(this.version)}registerCommands(){let n=new f;this.program.configureOutput({writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),outputError:(t,n)=>{n(e.red(t))}}),this.program.command(`validate`).option(`-w, --watch`,`Run in watch mode`).addArgument(new t(`<path>`,`Connector file or directory with connectors to validate`)).description(`Validate a StackOne connector`).action((e,t)=>{n.execute({watchMode:t.watch,fileOrDir:e})}),this.program.command(`version`).description(`Show version information`).action(()=>{console.info(`${e.greenBright(`StackOne`)} ${e.grey(`CLI`)} ${e.whiteBright(this.version)}`),process.exit(0)})}run(){this.program.parse(process.argv)}};export{g as CLI};