@boltic/cli 1.0.16 → 1.0.18
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/commands/integration.js +37 -3
- package/package.json +1 -7
- package/utils/integration.js +197 -21
package/commands/integration.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { confirm, input, search } from "@inquirer/prompts";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import { execSync } from "child_process";
|
|
3
4
|
import fs from "fs";
|
|
4
5
|
import path from "path";
|
|
5
|
-
import { execSync } from "child_process";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
editIntegration,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "../helper/folder.js";
|
|
24
24
|
|
|
25
25
|
import { getCurrentEnv } from "../helper/env.js";
|
|
26
|
-
import {
|
|
26
|
+
import { getSvgFilePath } from "../utils/integration.js";
|
|
27
27
|
|
|
28
28
|
// Define commands and their descriptions
|
|
29
29
|
const commands = {
|
|
@@ -170,6 +170,23 @@ async function handleSync(args) {
|
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
const isPublished = await getIntegrationById(
|
|
174
|
+
apiUrl,
|
|
175
|
+
token,
|
|
176
|
+
accountId,
|
|
177
|
+
session,
|
|
178
|
+
specContent.id
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if (isPublished.status === "published") {
|
|
182
|
+
console.error(
|
|
183
|
+
chalk.red(
|
|
184
|
+
`Error: Integration is already published. You cannot sync a published integration, please use the "edit" command to create a copy of the integration.`
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
173
190
|
const updatedIntegration = await updateIntegration(
|
|
174
191
|
apiUrl,
|
|
175
192
|
token,
|
|
@@ -289,6 +306,23 @@ async function handleSubmit(args) {
|
|
|
289
306
|
return;
|
|
290
307
|
}
|
|
291
308
|
|
|
309
|
+
const isPublished = await getIntegrationById(
|
|
310
|
+
apiUrl,
|
|
311
|
+
token,
|
|
312
|
+
accountId,
|
|
313
|
+
session,
|
|
314
|
+
specContent.id
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
if (isPublished.status === "published") {
|
|
318
|
+
console.error(
|
|
319
|
+
chalk.red(
|
|
320
|
+
`Error: Integration is already published. You cannot submit a published integration, please use the "edit" command to create a copy of the integration.`
|
|
321
|
+
)
|
|
322
|
+
);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
292
326
|
const updatedIntegration = await updateIntegration(
|
|
293
327
|
apiUrl,
|
|
294
328
|
token,
|
|
@@ -480,7 +514,7 @@ async function handleCreate() {
|
|
|
480
514
|
transform: (input) => input.trim().replace(/\s+/g, "_"),
|
|
481
515
|
});
|
|
482
516
|
|
|
483
|
-
const iconPath = await
|
|
517
|
+
const iconPath = await getSvgFilePath();
|
|
484
518
|
|
|
485
519
|
if (!iconPath || !iconPath?.endsWith(".svg")) {
|
|
486
520
|
console.log(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boltic/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
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": {
|
|
@@ -43,12 +43,6 @@
|
|
|
43
43
|
"url": "https://github.com/bolticio/cli/issues",
|
|
44
44
|
"email": "support@boltic.io"
|
|
45
45
|
},
|
|
46
|
-
"funding": [
|
|
47
|
-
{
|
|
48
|
-
"type": "github",
|
|
49
|
-
"url": "https://github.com/sponsors/bolticio"
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
46
|
"scripts": {
|
|
53
47
|
"start": "node index.js",
|
|
54
48
|
"dev": "nodemon index.js",
|
package/utils/integration.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { execSync } from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
2
4
|
|
|
3
5
|
async function pickSvgFile() {
|
|
4
6
|
const platform = process.platform;
|
|
@@ -14,34 +16,208 @@ async function pickSvgFile() {
|
|
|
14
16
|
const filePath = execSync(`osascript -e '${script}'`)
|
|
15
17
|
.toString()
|
|
16
18
|
.trim();
|
|
19
|
+
|
|
20
|
+
// Check if file path is empty or file doesn't exist
|
|
21
|
+
if (!filePath || !fs.existsSync(filePath)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
return filePath;
|
|
18
26
|
} else if (platform === "win32") {
|
|
19
|
-
// Windows:
|
|
20
|
-
|
|
21
|
-
Add-Type -AssemblyName System.Windows.Forms
|
|
22
|
-
$dialog = New-Object System.Windows.Forms.OpenFileDialog
|
|
23
|
-
$dialog.Filter = "SVG files (*.svg)|*.svg"
|
|
24
|
-
if ($dialog.ShowDialog() -eq "OK") { $dialog.FileName }
|
|
25
|
-
`;
|
|
26
|
-
const filePath = execSync(`powershell -Command "${psScript}"`)
|
|
27
|
-
.toString()
|
|
28
|
-
.trim();
|
|
29
|
-
return filePath;
|
|
27
|
+
// Windows: Multiple fallback approaches for better compatibility
|
|
28
|
+
return await pickSvgFileWindows();
|
|
30
29
|
} else if (platform === "linux") {
|
|
31
|
-
// Linux: Use zenity if available
|
|
32
|
-
|
|
33
|
-
`zenity --file-selection --file-filter="*.svg"`
|
|
34
|
-
)
|
|
35
|
-
.toString()
|
|
36
|
-
.trim();
|
|
37
|
-
return filePath;
|
|
30
|
+
// Linux: Use zenity if available, with fallbacks
|
|
31
|
+
return await pickSvgFileLinux();
|
|
38
32
|
} else {
|
|
39
|
-
console.error("Unsupported platform for file picker");
|
|
40
33
|
return null;
|
|
41
34
|
}
|
|
42
|
-
} catch {
|
|
35
|
+
} catch (_error) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function pickSvgFileWindows() {
|
|
41
|
+
// Try multiple approaches for Windows compatibility
|
|
42
|
+
|
|
43
|
+
// Method 1: PowerShell with improved script and execution policy bypass
|
|
44
|
+
try {
|
|
45
|
+
const psScript = `
|
|
46
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
47
|
+
$openFileDialog = New-Object System.Windows.Forms.OpenFileDialog
|
|
48
|
+
$openFileDialog.Title = "Select an SVG file"
|
|
49
|
+
$openFileDialog.Filter = "SVG files (*.svg)|*.svg|All files (*.*)|*.*"
|
|
50
|
+
$openFileDialog.FilterIndex = 1
|
|
51
|
+
$openFileDialog.Multiselect = $false
|
|
52
|
+
$result = $openFileDialog.ShowDialog()
|
|
53
|
+
if ($result -eq [System.Windows.Forms.DialogResult]::OK) {
|
|
54
|
+
Write-Output $openFileDialog.FileName
|
|
55
|
+
} else {
|
|
56
|
+
Write-Output ""
|
|
57
|
+
}
|
|
58
|
+
`.trim();
|
|
59
|
+
|
|
60
|
+
// Create a temporary PowerShell script file to avoid command line escaping issues
|
|
61
|
+
const tempDir = process.env.TEMP || process.env.TMP || "C:\\temp";
|
|
62
|
+
const tempScriptPath = path.join(
|
|
63
|
+
tempDir,
|
|
64
|
+
`file-picker-${Date.now()}.ps1`
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
fs.writeFileSync(tempScriptPath, psScript, "utf8");
|
|
68
|
+
|
|
69
|
+
const filePath = execSync(
|
|
70
|
+
`powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "${tempScriptPath}"`,
|
|
71
|
+
{
|
|
72
|
+
encoding: "utf8",
|
|
73
|
+
timeout: 30000,
|
|
74
|
+
windowsHide: true,
|
|
75
|
+
}
|
|
76
|
+
).trim();
|
|
77
|
+
|
|
78
|
+
// Clean up temp file
|
|
79
|
+
try {
|
|
80
|
+
fs.unlinkSync(tempScriptPath);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// Ignore cleanup errors
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (filePath && filePath !== "" && fs.existsSync(filePath)) {
|
|
86
|
+
return filePath;
|
|
87
|
+
}
|
|
88
|
+
} catch (_error) {
|
|
89
|
+
// Ignore cleanup errors
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Method 2: VBScript fallback for older Windows systems
|
|
93
|
+
try {
|
|
94
|
+
const vbScript = `
|
|
95
|
+
Dim objDialog
|
|
96
|
+
Set objDialog = CreateObject("MSComDlg.CommonDialog")
|
|
97
|
+
objDialog.Filter = "SVG files (*.svg)|*.svg|All files (*.*)|*.*"
|
|
98
|
+
objDialog.FilterIndex = 1
|
|
99
|
+
objDialog.ShowOpen
|
|
100
|
+
If objDialog.FileName <> "" Then
|
|
101
|
+
WScript.Echo objDialog.FileName
|
|
102
|
+
End If
|
|
103
|
+
`.trim();
|
|
104
|
+
|
|
105
|
+
const tempDir = process.env.TEMP || process.env.TMP || "C:\\temp";
|
|
106
|
+
const tempScriptPath = path.join(
|
|
107
|
+
tempDir,
|
|
108
|
+
`file-picker-${Date.now()}.vbs`
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
fs.writeFileSync(tempScriptPath, vbScript, "utf8");
|
|
112
|
+
|
|
113
|
+
const filePath = execSync(`cscript //nologo "${tempScriptPath}"`, {
|
|
114
|
+
encoding: "utf8",
|
|
115
|
+
timeout: 30000,
|
|
116
|
+
windowsHide: true,
|
|
117
|
+
}).trim();
|
|
118
|
+
|
|
119
|
+
// Clean up temp file
|
|
120
|
+
try {
|
|
121
|
+
fs.unlinkSync(tempScriptPath);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
// Ignore cleanup errors
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (filePath && filePath !== "" && fs.existsSync(filePath)) {
|
|
127
|
+
return filePath;
|
|
128
|
+
}
|
|
129
|
+
} catch (_error) {
|
|
130
|
+
// Ignore cleanup errors
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Method 3: PowerShell Core (pwsh) for Windows 10/11 with PowerShell 7+
|
|
134
|
+
try {
|
|
135
|
+
const psScript = `
|
|
136
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
137
|
+
$dialog = [System.Windows.Forms.OpenFileDialog]::new()
|
|
138
|
+
$dialog.Title = "Select an SVG file"
|
|
139
|
+
$dialog.Filter = "SVG files (*.svg)|*.svg"
|
|
140
|
+
$dialog.ShowHelp = $false
|
|
141
|
+
if ($dialog.ShowDialog() -eq 'OK') { $dialog.FileName }
|
|
142
|
+
`.trim();
|
|
143
|
+
|
|
144
|
+
const filePath = execSync(
|
|
145
|
+
`pwsh -Command "${psScript.replace(/"/g, '`"')}"`,
|
|
146
|
+
{
|
|
147
|
+
encoding: "utf8",
|
|
148
|
+
timeout: 30000,
|
|
149
|
+
windowsHide: true,
|
|
150
|
+
}
|
|
151
|
+
).trim();
|
|
152
|
+
|
|
153
|
+
if (filePath && filePath !== "" && fs.existsSync(filePath)) {
|
|
154
|
+
return filePath;
|
|
155
|
+
}
|
|
156
|
+
} catch (_error) {
|
|
157
|
+
// Ignore cleanup errors
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Method 4: Use Windows built-in file associations as last resort
|
|
161
|
+
try {
|
|
162
|
+
execSync("explorer.exe", { windowsHide: false });
|
|
163
|
+
|
|
164
|
+
// Return null to trigger manual input fallback
|
|
165
|
+
return null;
|
|
166
|
+
} catch (_error) {
|
|
43
167
|
return null;
|
|
44
168
|
}
|
|
45
169
|
}
|
|
46
170
|
|
|
47
|
-
|
|
171
|
+
async function pickSvgFileLinux() {
|
|
172
|
+
// Try multiple Linux GUI file picker options
|
|
173
|
+
|
|
174
|
+
// Method 1: zenity (GNOME)
|
|
175
|
+
try {
|
|
176
|
+
const filePath = execSync(
|
|
177
|
+
`zenity --file-selection --title="Select an SVG file" --file-filter="SVG files | *.svg" --file-filter="All files | *"`,
|
|
178
|
+
{ encoding: "utf8", timeout: 30000 }
|
|
179
|
+
).trim();
|
|
180
|
+
|
|
181
|
+
if (filePath && filePath !== "" && fs.existsSync(filePath)) {
|
|
182
|
+
return filePath;
|
|
183
|
+
}
|
|
184
|
+
} catch (_error) {
|
|
185
|
+
// Ignore cleanup errors
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Method 2: kdialog (KDE)
|
|
189
|
+
try {
|
|
190
|
+
const filePath = execSync(
|
|
191
|
+
`kdialog --getopenfilename . "*.svg|SVG files"`,
|
|
192
|
+
{ encoding: "utf8", timeout: 30000 }
|
|
193
|
+
).trim();
|
|
194
|
+
|
|
195
|
+
if (filePath && filePath !== "" && fs.existsSync(filePath)) {
|
|
196
|
+
return filePath;
|
|
197
|
+
}
|
|
198
|
+
} catch (_error) {
|
|
199
|
+
// Ignore cleanup errors
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Method 3: Try to open file manager as fallback
|
|
203
|
+
try {
|
|
204
|
+
execSync("xdg-open .", { timeout: 5000 });
|
|
205
|
+
return null; // Trigger manual input
|
|
206
|
+
} catch (_error) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Helper function to get SVG file path with fallback to manual input
|
|
212
|
+
async function getSvgFilePath() {
|
|
213
|
+
const { input } = await import("@inquirer/prompts");
|
|
214
|
+
|
|
215
|
+
// First try the file picker
|
|
216
|
+
const pickedFile = await pickSvgFile();
|
|
217
|
+
|
|
218
|
+
if (pickedFile && fs.existsSync(pickedFile)) {
|
|
219
|
+
return pickedFile;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export { getSvgFilePath, pickSvgFile };
|