@boltic/cli 1.0.17 → 1.0.19

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.
@@ -23,7 +23,7 @@ import {
23
23
  } from "../helper/folder.js";
24
24
 
25
25
  import { getCurrentEnv } from "../helper/env.js";
26
- import { pickSvgFile } from "../utils/integration.js";
26
+ import { getSvgFilePath } from "../utils/integration.js";
27
27
 
28
28
  // Define commands and their descriptions
29
29
  const commands = {
@@ -514,7 +514,7 @@ async function handleCreate() {
514
514
  transform: (input) => input.trim().replace(/\s+/g, "_"),
515
515
  });
516
516
 
517
- const iconPath = await pickSvgFile();
517
+ const iconPath = await getSvgFilePath();
518
518
 
519
519
  if (!iconPath || !iconPath?.endsWith(".svg")) {
520
520
  console.log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boltic/cli",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
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": {
@@ -42,6 +42,20 @@ const authentication = {
42
42
  },
43
43
  },
44
44
  ],
45
+ validate: {
46
+ url: "https://test_url/events",
47
+ method: "get",
48
+ headers: {
49
+ Authorization: "Bearer {{secrets.api_key}}",
50
+ },
51
+ response: {
52
+ error: {
53
+ code: "{{response.status}}",
54
+ message: "{{response.data.error}}",
55
+ },
56
+ output: "{{response.data}}",
57
+ },
58
+ },
45
59
  },
46
60
  };
47
61
 
@@ -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: Use PowerShell to open file dialog
20
- const psScript = `
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
- const filePath = execSync(
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
- export { pickSvgFile };
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 };