@stackone/cli 1.0.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/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # StackOne CLI
2
+
3
+ A command-line interface for StackOne Connect operations.
4
+
5
+ ## Installation
6
+
7
+ Install globally via npm:
8
+
9
+ ```bash
10
+ npm install -g @stackone/cli
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ After installation, you can use the `stackone` command from anywhere:
16
+
17
+ ```bash
18
+ stackone --help
19
+ stackone -h
20
+ ```
21
+
22
+ ## Commands
23
+
24
+ ### `validate`
25
+
26
+ Validate a StackOne connector file:
27
+
28
+ ```bash
29
+ stackone validate path/to/connector.s1.yaml
30
+ ```
31
+
32
+ Validate multiple connector files at once in a directory (recursive):
33
+
34
+ ```bash
35
+ stackone validate path/to/connectors/
36
+ ```
37
+
38
+ Options:
39
+
40
+ - `-w or --watch`: Watch for changes in the specified directory of file and validate connectors as they change.
41
+
42
+ Note: The file extension of a connector file needs to be `.s1.yaml`. The file extension can be omitted.
43
+
44
+ ### `version`
45
+
46
+ Show CLI version information. If a new version is available, it will prompt you to update:
47
+
48
+ ```bash
49
+ stackone version
50
+ ```
51
+
52
+ ### `--version`
53
+
54
+ Show the current version of the CLI:
55
+
56
+ ```bash
57
+ stackone --version
58
+ stackone -V
59
+ ```
60
+
61
+ ### Local Development
62
+
63
+ ```bash
64
+ # Install dependencies
65
+ npm install
66
+
67
+ # Build the package
68
+ npm run build
69
+
70
+ # Link for global testing
71
+ npm link
72
+
73
+ # Run tests
74
+ npm test
75
+
76
+ # Lint and format
77
+ npm run lint:fix
78
+ ```
79
+
80
+ ### Building
81
+
82
+ ```bash
83
+ npm run build
84
+ ```
85
+
86
+ ### Testing
87
+
88
+ ```bash
89
+ npm test
90
+ ```
91
+
92
+ ## Publishing
93
+
94
+ The package is configured to be published to NPM with public access:
95
+
96
+ ```bash
97
+ npm run publish-release
98
+ ```
99
+
100
+ ## Architecture
101
+
102
+ The CLI is built with:
103
+
104
+ - **Commander.js** - Command line parsing
105
+ - **Chalk** - Terminal colors and styling
106
+ - **Inquirer** - Interactive prompts
107
+ - **Ora** - Loading spinners
108
+ - **TypeScript** - Type safety
109
+ - **Tsdown** - Bundling
110
+ - **Vitest** - Testing
@@ -0,0 +1,30 @@
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
+ });
package/dist/cli.cjs ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ const require_cliCore = require('./cliCore-C1gzrk1Q.cjs');
3
+
4
+ //#region src/cli.ts
5
+ const cli = new require_cliCore.CLI();
6
+ cli.run();
7
+
8
+ //#endregion
package/dist/cli.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { CLI } from "./cliCore-DKDA_-me.js";
3
+
4
+ //#region src/cli.ts
5
+ const cli = new CLI();
6
+ cli.run();
7
+
8
+ //#endregion
@@ -0,0 +1,138 @@
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 ora = require_chunk.__toESM(require("ora"));
5
+ const fs = require_chunk.__toESM(require("fs"));
6
+ const path = require_chunk.__toESM(require("path"));
7
+ const url = require_chunk.__toESM(require("url"));
8
+
9
+ //#region src/utils/logger.ts
10
+ var Logger = class {
11
+ static info(message) {
12
+ console.info(chalk.default.blue("ℹ"), message);
13
+ }
14
+ static warn(message) {
15
+ console.info(chalk.default.yellow("⚠"), message);
16
+ }
17
+ static error(message) {
18
+ console.info(chalk.default.red("✗"), message);
19
+ }
20
+ static success(message) {
21
+ console.info(chalk.default.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 = (0, ora.default)("Watching for changes...");
31
+ const displayWatchModeEnabled = () => {
32
+ console.clear();
33
+ console.info(chalk.default.yellow("Watch mode enabled. Press \"q\" to quit.\n"));
34
+ };
35
+ if (!fileOrDir) return;
36
+ if (watchMode) {
37
+ const { watch } = await Promise.resolve().then(() => require("./esm-Chmlhd00.cjs"));
38
+ const readline = await import("readline");
39
+ const rl = readline.createInterface({
40
+ input: process.stdin,
41
+ output: process.stdout
42
+ });
43
+ process.stdin.setRawMode(true);
44
+ process.stdin.resume();
45
+ process.stdin.setEncoding("utf8");
46
+ const cleanup = () => {
47
+ console.info(chalk.default.grey("\n\nExiting watch mode..."));
48
+ watcher.close();
49
+ spinner.stop();
50
+ rl.close();
51
+ process.exit(0);
52
+ };
53
+ displayWatchModeEnabled();
54
+ console.info(chalk.default.blue(`Running connector(s) validations...`));
55
+ await validateConnector(fileOrDir);
56
+ spinner.start();
57
+ const watcher = watch(fileOrDir || ".", {
58
+ ignored: /(^|[/\\])\../,
59
+ persistent: true
60
+ });
61
+ watcher.on("change", async (path$1) => {
62
+ displayWatchModeEnabled();
63
+ spinner.stop();
64
+ console.info(chalk.default.blue(`File change detected. Running connector(s) validations...`));
65
+ await validateConnector(fileOrDir);
66
+ spinner.start();
67
+ });
68
+ process.stdin.on("data", (key) => {
69
+ if (key.toString() === "q") cleanup();
70
+ });
71
+ process.on("SIGINT", () => {
72
+ cleanup();
73
+ });
74
+ } else await validateConnector(fileOrDir);
75
+ }
76
+ };
77
+ const validateConnector = async (path$1) => {
78
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
79
+ Logger.success(`Connector ${path$1} is valid!\n`);
80
+ };
81
+
82
+ //#endregion
83
+ //#region src/utils/packageVersion.ts
84
+ const getPackageVersion = () => {
85
+ try {
86
+ const __filename$1 = (0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
87
+ const __dirname$1 = (0, path.dirname)(__filename$1);
88
+ const packageJsonPath = (0, path.join)(__dirname$1, "..", "package.json");
89
+ const packageJson = JSON.parse((0, fs.readFileSync)(packageJsonPath, "utf8"));
90
+ return packageJson.version;
91
+ } catch {
92
+ return "unknown";
93
+ }
94
+ };
95
+
96
+ //#endregion
97
+ //#region src/cliCore.ts
98
+ var CLI = class {
99
+ constructor(program = new commander.Command(), version = getPackageVersion()) {
100
+ this.program = program;
101
+ this.version = version;
102
+ this.setupProgram();
103
+ this.registerCommands();
104
+ }
105
+ setupProgram() {
106
+ this.program.name("stackone").description("StackOne Connect CLI tool").version(this.version);
107
+ }
108
+ registerCommands() {
109
+ const validateCommand = new ValidateCommand();
110
+ this.program.configureOutput({
111
+ writeOut: (str) => process.stdout.write(str),
112
+ writeErr: (str) => process.stderr.write(str),
113
+ outputError: (str, write) => {
114
+ write(chalk.default.red(str));
115
+ }
116
+ });
117
+ 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) => {
118
+ validateCommand.execute({
119
+ watchMode: options.watch,
120
+ fileOrDir
121
+ });
122
+ });
123
+ this.program.command("version").description("Show version information").action(() => {
124
+ console.info(`${chalk.default.greenBright("StackOne")} ${chalk.default.grey("CLI")} ${chalk.default.whiteBright(this.version)}`);
125
+ });
126
+ }
127
+ run() {
128
+ this.program.parse(process.argv);
129
+ }
130
+ };
131
+
132
+ //#endregion
133
+ Object.defineProperty(exports, 'CLI', {
134
+ enumerable: true,
135
+ get: function () {
136
+ return CLI;
137
+ }
138
+ });
@@ -0,0 +1,132 @@
1
+ import chalk from "chalk";
2
+ import { Argument, Command } from "commander";
3
+ import ora from "ora";
4
+ import { readFileSync } from "fs";
5
+ import { dirname, join } from "path";
6
+ import { fileURLToPath } from "url";
7
+
8
+ //#region src/utils/logger.ts
9
+ var Logger = class {
10
+ static info(message) {
11
+ console.info(chalk.blue("ℹ"), message);
12
+ }
13
+ static warn(message) {
14
+ console.info(chalk.yellow("⚠"), message);
15
+ }
16
+ static error(message) {
17
+ console.info(chalk.red("✗"), message);
18
+ }
19
+ static success(message) {
20
+ console.info(chalk.green("✓"), message);
21
+ }
22
+ };
23
+
24
+ //#endregion
25
+ //#region src/commands/validate.ts
26
+ var ValidateCommand = class {
27
+ async execute(options) {
28
+ const { watchMode, fileOrDir } = options;
29
+ const spinner = ora("Watching for changes...");
30
+ const displayWatchModeEnabled = () => {
31
+ console.clear();
32
+ console.info(chalk.yellow("Watch mode enabled. Press \"q\" to quit.\n"));
33
+ };
34
+ if (!fileOrDir) return;
35
+ if (watchMode) {
36
+ const { watch: watch$1 } = await import("./esm-BenXeAeS.js");
37
+ const readline = await import("readline");
38
+ const rl = readline.createInterface({
39
+ input: process.stdin,
40
+ output: process.stdout
41
+ });
42
+ process.stdin.setRawMode(true);
43
+ process.stdin.resume();
44
+ process.stdin.setEncoding("utf8");
45
+ const cleanup = () => {
46
+ console.info(chalk.grey("\n\nExiting watch mode..."));
47
+ watcher.close();
48
+ spinner.stop();
49
+ rl.close();
50
+ process.exit(0);
51
+ };
52
+ displayWatchModeEnabled();
53
+ console.info(chalk.blue(`Running connector(s) validations...`));
54
+ await validateConnector(fileOrDir);
55
+ spinner.start();
56
+ const watcher = watch$1(fileOrDir || ".", {
57
+ ignored: /(^|[/\\])\../,
58
+ persistent: true
59
+ });
60
+ watcher.on("change", async (path) => {
61
+ displayWatchModeEnabled();
62
+ spinner.stop();
63
+ console.info(chalk.blue(`File change detected. Running connector(s) validations...`));
64
+ await validateConnector(fileOrDir);
65
+ spinner.start();
66
+ });
67
+ process.stdin.on("data", (key) => {
68
+ if (key.toString() === "q") cleanup();
69
+ });
70
+ process.on("SIGINT", () => {
71
+ cleanup();
72
+ });
73
+ } else await validateConnector(fileOrDir);
74
+ }
75
+ };
76
+ const validateConnector = async (path) => {
77
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
78
+ Logger.success(`Connector ${path} is valid!\n`);
79
+ };
80
+
81
+ //#endregion
82
+ //#region src/utils/packageVersion.ts
83
+ const getPackageVersion = () => {
84
+ try {
85
+ const __filename = fileURLToPath(import.meta.url);
86
+ const __dirname = dirname(__filename);
87
+ const packageJsonPath = join(__dirname, "..", "package.json");
88
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
89
+ return packageJson.version;
90
+ } catch {
91
+ return "unknown";
92
+ }
93
+ };
94
+
95
+ //#endregion
96
+ //#region src/cliCore.ts
97
+ var CLI = class {
98
+ constructor(program = new Command(), version = getPackageVersion()) {
99
+ this.program = program;
100
+ this.version = version;
101
+ this.setupProgram();
102
+ this.registerCommands();
103
+ }
104
+ setupProgram() {
105
+ this.program.name("stackone").description("StackOne Connect CLI tool").version(this.version);
106
+ }
107
+ registerCommands() {
108
+ const validateCommand = new ValidateCommand();
109
+ this.program.configureOutput({
110
+ writeOut: (str) => process.stdout.write(str),
111
+ writeErr: (str) => process.stderr.write(str),
112
+ outputError: (str, write) => {
113
+ write(chalk.red(str));
114
+ }
115
+ });
116
+ 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) => {
117
+ validateCommand.execute({
118
+ watchMode: options.watch,
119
+ fileOrDir
120
+ });
121
+ });
122
+ this.program.command("version").description("Show version information").action(() => {
123
+ console.info(`${chalk.greenBright("StackOne")} ${chalk.grey("CLI")} ${chalk.whiteBright(this.version)}`);
124
+ });
125
+ }
126
+ run() {
127
+ this.program.parse(process.argv);
128
+ }
129
+ };
130
+
131
+ //#endregion
132
+ export { CLI };