@boltic/cli 1.0.24 → 1.0.26
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/cli.js +42 -17
- package/helper/folder.js +30 -16
- package/package.json +1 -4
package/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
4
5
|
import EnvironmentCommands from "./commands/env.js";
|
|
5
6
|
import IntegrationCommands from "./commands/integration.js";
|
|
6
7
|
import AuthCommands from "./commands/login.js";
|
|
@@ -108,17 +109,33 @@ const createCLI = (consoleUrl, apiUrl, serviceName, env) => {
|
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
async function showHelp(commands) {
|
|
111
|
-
let
|
|
112
|
+
let version = "1.0.0";
|
|
112
113
|
try {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
let baseDir;
|
|
115
|
+
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
116
|
+
// Resolve module directory in a cross-platform (Windows-safe) way
|
|
117
|
+
const filename = fileURLToPath(import.meta.url);
|
|
118
|
+
baseDir = path.dirname(filename);
|
|
119
|
+
} else {
|
|
120
|
+
baseDir = process.cwd();
|
|
121
|
+
}
|
|
122
|
+
const packageJsonPath = path.join(baseDir, "package.json");
|
|
123
|
+
const packageJson = JSON.parse(
|
|
124
|
+
fs.readFileSync(packageJsonPath, "utf-8")
|
|
116
125
|
);
|
|
126
|
+
version = packageJson.version || version;
|
|
117
127
|
} catch {
|
|
118
|
-
//
|
|
119
|
-
|
|
128
|
+
// Best-effort secondary attempt from current working directory
|
|
129
|
+
try {
|
|
130
|
+
const fallbackPath = path.join(process.cwd(), "package.json");
|
|
131
|
+
const packageJson = JSON.parse(
|
|
132
|
+
fs.readFileSync(fallbackPath, "utf-8")
|
|
133
|
+
);
|
|
134
|
+
version = packageJson.version || version;
|
|
135
|
+
} catch {
|
|
136
|
+
// keep default version
|
|
137
|
+
}
|
|
120
138
|
}
|
|
121
|
-
const version = packageJson.version;
|
|
122
139
|
|
|
123
140
|
console.log(chalk.bold.yellow(`\nBoltic CLI Version: ${version}\n`));
|
|
124
141
|
console.log("\nUsage: boltic [command]\n");
|
|
@@ -141,24 +158,32 @@ async function handleEnvironment(args) {
|
|
|
141
158
|
}
|
|
142
159
|
|
|
143
160
|
async function showVersion() {
|
|
144
|
-
let version = "1.0.0";
|
|
161
|
+
let version = "1.0.0";
|
|
145
162
|
try {
|
|
146
|
-
let
|
|
163
|
+
let baseDir;
|
|
147
164
|
if (typeof import.meta !== "undefined" && import.meta.url) {
|
|
148
|
-
//
|
|
149
|
-
const
|
|
150
|
-
|
|
165
|
+
// Windows-safe resolution for ESM modules
|
|
166
|
+
const filename = fileURLToPath(import.meta.url);
|
|
167
|
+
baseDir = path.dirname(filename);
|
|
151
168
|
} else {
|
|
152
|
-
|
|
153
|
-
packageJsonPath = path.join(process.cwd(), "package.json");
|
|
169
|
+
baseDir = process.cwd();
|
|
154
170
|
}
|
|
155
|
-
|
|
171
|
+
const packageJsonPath = path.join(baseDir, "package.json");
|
|
156
172
|
const packageJson = JSON.parse(
|
|
157
173
|
fs.readFileSync(packageJsonPath, "utf-8")
|
|
158
174
|
);
|
|
159
|
-
version = packageJson.version;
|
|
175
|
+
version = packageJson.version || version;
|
|
160
176
|
} catch {
|
|
161
|
-
//
|
|
177
|
+
// Best-effort secondary attempt from current working directory
|
|
178
|
+
try {
|
|
179
|
+
const fallbackPath = path.join(process.cwd(), "package.json");
|
|
180
|
+
const packageJson = JSON.parse(
|
|
181
|
+
fs.readFileSync(fallbackPath, "utf-8")
|
|
182
|
+
);
|
|
183
|
+
version = packageJson.version || version;
|
|
184
|
+
} catch {
|
|
185
|
+
// fallback already defined
|
|
186
|
+
}
|
|
162
187
|
}
|
|
163
188
|
console.log(`Boltic CLI Version: ${version}`);
|
|
164
189
|
}
|
package/helper/folder.js
CHANGED
|
@@ -86,12 +86,22 @@ export const createIntegrationFolderStructure = async (
|
|
|
86
86
|
export const createExistingIntegrationsFolder = async (payload) => {
|
|
87
87
|
const {
|
|
88
88
|
integration,
|
|
89
|
-
authentication,
|
|
90
|
-
webhook,
|
|
91
|
-
configuration,
|
|
92
|
-
resources,
|
|
93
|
-
operations,
|
|
94
|
-
} = payload;
|
|
89
|
+
authentication = {},
|
|
90
|
+
webhook = {},
|
|
91
|
+
configuration = {},
|
|
92
|
+
resources = [],
|
|
93
|
+
operations = [],
|
|
94
|
+
} = payload || {};
|
|
95
|
+
|
|
96
|
+
// Validate required payload fields early to prevent null dereferences
|
|
97
|
+
if (!integration || !integration.name) {
|
|
98
|
+
console.error(
|
|
99
|
+
chalk.red(
|
|
100
|
+
"\n❌ Invalid integration payload received. Missing integration or name."
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
95
105
|
|
|
96
106
|
const {
|
|
97
107
|
id,
|
|
@@ -137,15 +147,17 @@ export const createExistingIntegrationsFolder = async (payload) => {
|
|
|
137
147
|
const resourcesDir = path.join(schemasDir, "resources");
|
|
138
148
|
fs.mkdirSync(resourcesDir, { recursive: true });
|
|
139
149
|
|
|
140
|
-
const authentication_documentation = authentication
|
|
150
|
+
const authentication_documentation = authentication?.documentation || "";
|
|
141
151
|
|
|
142
152
|
// Define files and content
|
|
143
153
|
const files = {
|
|
144
|
-
|
|
145
|
-
authentication.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
...(authentication && {
|
|
155
|
+
"schemas/authentication.json": JSON.stringify(
|
|
156
|
+
authentication?.content || {},
|
|
157
|
+
null,
|
|
158
|
+
4
|
|
159
|
+
),
|
|
160
|
+
}),
|
|
149
161
|
"schemas/base.json": JSON.stringify(
|
|
150
162
|
configuration?.content || {},
|
|
151
163
|
null,
|
|
@@ -153,7 +165,9 @@ export const createExistingIntegrationsFolder = async (payload) => {
|
|
|
153
165
|
),
|
|
154
166
|
"schemas/webhook.json": JSON.stringify(webhook?.content || {}, null, 4),
|
|
155
167
|
"spec.json": JSON.stringify(spec, null, 4),
|
|
156
|
-
|
|
168
|
+
...(authentication && {
|
|
169
|
+
"Authentication.mdx": authentication_documentation || "",
|
|
170
|
+
}),
|
|
157
171
|
"Documentation.mdx": documentation || "",
|
|
158
172
|
};
|
|
159
173
|
|
|
@@ -163,7 +177,7 @@ export const createExistingIntegrationsFolder = async (payload) => {
|
|
|
163
177
|
const resourceName = resource.name.toLowerCase().replace(/\s+/g, "-");
|
|
164
178
|
const resourcePath = path.join(resourcesDir, `${resourceName}.json`);
|
|
165
179
|
|
|
166
|
-
const resourceOperations = operations.filter(
|
|
180
|
+
const resourceOperations = (operations || []).filter(
|
|
167
181
|
(operation) => operation.resource_id === resource_id
|
|
168
182
|
);
|
|
169
183
|
|
|
@@ -172,14 +186,14 @@ export const createExistingIntegrationsFolder = async (payload) => {
|
|
|
172
186
|
const operationName = operation.name
|
|
173
187
|
.toLowerCase()
|
|
174
188
|
.replace(/\s+/g, "-");
|
|
175
|
-
acc[operationName] = operation
|
|
189
|
+
acc[operationName] = operation?.content;
|
|
176
190
|
return acc;
|
|
177
191
|
},
|
|
178
192
|
{}
|
|
179
193
|
);
|
|
180
194
|
|
|
181
195
|
const resourceFileContent = {
|
|
182
|
-
...resource
|
|
196
|
+
...resource?.content,
|
|
183
197
|
...operationsContent,
|
|
184
198
|
};
|
|
185
199
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boltic/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "A powerful CLI tool for managing Boltic Workflow integrations - create, sync, test, and publish integrations with ease",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -129,9 +129,6 @@
|
|
|
129
129
|
"nodemon": "^3.1.10",
|
|
130
130
|
"prettier": "^3.6.2"
|
|
131
131
|
},
|
|
132
|
-
"peerDependencies": {
|
|
133
|
-
"node": ">=18.0.0"
|
|
134
|
-
},
|
|
135
132
|
"os": [
|
|
136
133
|
"darwin",
|
|
137
134
|
"linux",
|