scripting-cli 1.1.2 → 1.1.4
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/dist/index.js +19 -5
- package/package.json +4 -2
- package/src/index.ts +19 -5
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
|
27
27
|
const chalk_1 = __importDefault(require("chalk"));
|
|
28
28
|
const child_process_1 = __importDefault(require("child_process"));
|
|
29
29
|
const os_1 = __importDefault(require("os"));
|
|
30
|
+
const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
|
|
30
31
|
const app = (0, express_1.default)();
|
|
31
32
|
const server = http_1.default.createServer(app);
|
|
32
33
|
const io = new socket_io_1.Server(server);
|
|
@@ -80,6 +81,7 @@ function startServer(port) {
|
|
|
80
81
|
"skipLibCheck": true,
|
|
81
82
|
"jsx": "react",
|
|
82
83
|
"jsxFactory": "createElement",
|
|
84
|
+
"jsxFragmentFactory": "Fragment",
|
|
83
85
|
"paths": {
|
|
84
86
|
"scripting": [
|
|
85
87
|
"./dts/scripting.d.ts"
|
|
@@ -232,8 +234,13 @@ function startServer(port) {
|
|
|
232
234
|
ack({
|
|
233
235
|
success: true,
|
|
234
236
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
// Open the entry file in VSCode after a delay
|
|
238
|
+
// to ensure the response is sent. Because the open file command
|
|
239
|
+
// may suspend the response and cause the client to not receive the ack.
|
|
240
|
+
setTimeout(() => {
|
|
241
|
+
const entryFilePath = path_1.default.join(scriptDir, "index.tsx");
|
|
242
|
+
tryOpenFileInVSCode(entryFilePath);
|
|
243
|
+
}, 1000);
|
|
237
244
|
}
|
|
238
245
|
catch (e) {
|
|
239
246
|
console.log(chalk_1.default.red(`Error: ${e}`));
|
|
@@ -294,8 +301,13 @@ function startServer(port) {
|
|
|
294
301
|
scriptFiles,
|
|
295
302
|
});
|
|
296
303
|
createWatcher(data.scriptName);
|
|
297
|
-
|
|
298
|
-
|
|
304
|
+
// Open the entry file in VSCode after a delay
|
|
305
|
+
// to ensure the response is sent. Because the open file command
|
|
306
|
+
// may suspend the response and cause the client to not receive the ack.
|
|
307
|
+
setTimeout(() => {
|
|
308
|
+
const entryFilePath = path_1.default.join(scriptDir, "index.tsx");
|
|
309
|
+
tryOpenFileInVSCode(entryFilePath);
|
|
310
|
+
}, 1000);
|
|
299
311
|
}
|
|
300
312
|
catch (e) {
|
|
301
313
|
ack({
|
|
@@ -367,7 +379,9 @@ function startServer(port) {
|
|
|
367
379
|
createVSCodeSettings(); // Create vscode settings.json when the server starts
|
|
368
380
|
const ipAddress = ip_1.default.address();
|
|
369
381
|
const address = `http://${ipAddress}:${PORT}`;
|
|
370
|
-
console.log(`Server listening on ${chalk_1.default.bold.blue(address)}\nYou can select this server in the Scripting app to connect
|
|
382
|
+
console.log(`Server listening on ${chalk_1.default.bold.blue(address)}\nYou can select this server in the Scripting app to connect.\n`);
|
|
383
|
+
console.log(`Alternatively, you can ${chalk_1.default.green.bold("use the Scripting app to scan")} the QR code and connect: `);
|
|
384
|
+
qrcode_terminal_1.default.generate(address, { small: true });
|
|
371
385
|
bonjour.publish({ name: 'Scripting-service', type: 'http', port: PORT });
|
|
372
386
|
process.on('SIGINT', () => {
|
|
373
387
|
bonjour.unpublishAll(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripting-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "This plugin integrates the desktop editor synchronization feature of the Scripting app.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"chokidar": "^4.0.3",
|
|
33
33
|
"express": "^4.21.2",
|
|
34
34
|
"ip": "^2.0.1",
|
|
35
|
+
"qrcode-terminal": "^0.12.0",
|
|
35
36
|
"socket.io": "^4.8.1",
|
|
36
37
|
"typescript": "^5.7.3",
|
|
37
38
|
"yargs": "^17.7.2"
|
|
@@ -41,8 +42,9 @@
|
|
|
41
42
|
"@types/express": "^5.0.0",
|
|
42
43
|
"@types/ip": "^1.1.3",
|
|
43
44
|
"@types/node": "^22.13.4",
|
|
45
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
44
46
|
"@types/socket.io": "^3.0.2",
|
|
45
47
|
"@types/yargs": "^17.0.33",
|
|
46
48
|
"ts-node": "^10.9.2"
|
|
47
49
|
}
|
|
48
|
-
}
|
|
50
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import crypto from 'crypto';
|
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import childProcess from 'child_process';
|
|
15
15
|
import os from 'os';
|
|
16
|
+
import qrcode from 'qrcode-terminal';
|
|
16
17
|
|
|
17
18
|
const app = express();
|
|
18
19
|
const server = http.createServer(app);
|
|
@@ -260,8 +261,13 @@ function startServer(port?: number) {
|
|
|
260
261
|
success: true,
|
|
261
262
|
});
|
|
262
263
|
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
// Open the entry file in VSCode after a delay
|
|
265
|
+
// to ensure the response is sent. Because the open file command
|
|
266
|
+
// may suspend the response and cause the client to not receive the ack.
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
const entryFilePath = path.join(scriptDir, "index.tsx")
|
|
269
|
+
tryOpenFileInVSCode(entryFilePath);
|
|
270
|
+
}, 1000);
|
|
265
271
|
|
|
266
272
|
} catch (e) {
|
|
267
273
|
console.log(chalk.red(`Error: ${e}`));
|
|
@@ -342,8 +348,13 @@ function startServer(port?: number) {
|
|
|
342
348
|
|
|
343
349
|
createWatcher(data.scriptName);
|
|
344
350
|
|
|
345
|
-
|
|
346
|
-
|
|
351
|
+
// Open the entry file in VSCode after a delay
|
|
352
|
+
// to ensure the response is sent. Because the open file command
|
|
353
|
+
// may suspend the response and cause the client to not receive the ack.
|
|
354
|
+
setTimeout(() => {
|
|
355
|
+
const entryFilePath = path.join(scriptDir, "index.tsx")
|
|
356
|
+
tryOpenFileInVSCode(entryFilePath);
|
|
357
|
+
}, 1000);
|
|
347
358
|
|
|
348
359
|
} catch (e) {
|
|
349
360
|
ack({
|
|
@@ -441,7 +452,10 @@ function startServer(port?: number) {
|
|
|
441
452
|
const ipAddress = ip.address()
|
|
442
453
|
const address = `http://${ipAddress}:${PORT}`;
|
|
443
454
|
|
|
444
|
-
console.log(`Server listening on ${chalk.bold.blue(address)}\nYou can select this server in the Scripting app to connect
|
|
455
|
+
console.log(`Server listening on ${chalk.bold.blue(address)}\nYou can select this server in the Scripting app to connect.\n`);
|
|
456
|
+
|
|
457
|
+
console.log(`Alternatively, you can ${chalk.green.bold("use the Scripting app to scan")} the QR code and connect: `);
|
|
458
|
+
qrcode.generate(address, { small: true });
|
|
445
459
|
|
|
446
460
|
bonjour.publish({ name: 'Scripting-service', type: 'http', port: PORT });
|
|
447
461
|
|