checkpoint-cli 0.1.1 → 0.1.2
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 +29 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -205,6 +205,16 @@ function hasBinary(name) {
|
|
|
205
205
|
return false;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
+
function checkLocalServer(port) {
|
|
209
|
+
return new Promise((resolve) => {
|
|
210
|
+
const req = http_1.default.request({ hostname: 'localhost', port, method: 'HEAD', timeout: 2000 }, () => {
|
|
211
|
+
resolve(true);
|
|
212
|
+
});
|
|
213
|
+
req.on('error', () => resolve(false));
|
|
214
|
+
req.on('timeout', () => { req.destroy(); resolve(false); });
|
|
215
|
+
req.end();
|
|
216
|
+
});
|
|
217
|
+
}
|
|
208
218
|
const VALID_PROVIDERS = ['cloudflared', 'ngrok'];
|
|
209
219
|
function isValidProvider(provider) {
|
|
210
220
|
return VALID_PROVIDERS.includes(provider);
|
|
@@ -486,9 +496,27 @@ program
|
|
|
486
496
|
console.log('');
|
|
487
497
|
// Prompt for tunnel name if not provided
|
|
488
498
|
if (!opts.name) {
|
|
489
|
-
opts.name = await prompt('Give this tunnel a name'
|
|
499
|
+
opts.name = await prompt('Give this tunnel a name');
|
|
500
|
+
if (!opts.name) {
|
|
501
|
+
console.log(chalk_1.default.red(' A tunnel name is required.'));
|
|
502
|
+
console.log('');
|
|
503
|
+
process.exit(1);
|
|
504
|
+
}
|
|
490
505
|
console.log('');
|
|
491
506
|
}
|
|
507
|
+
// Check if local server is running
|
|
508
|
+
const isRunning = await checkLocalServer(port);
|
|
509
|
+
if (!isRunning) {
|
|
510
|
+
console.log(chalk_1.default.red(` Nothing is running on localhost:${port}`));
|
|
511
|
+
console.log('');
|
|
512
|
+
console.log(chalk_1.default.white(' You need two terminals:'));
|
|
513
|
+
console.log(chalk_1.default.gray(' Terminal 1:') + chalk_1.default.cyan(` npm run dev`) + chalk_1.default.gray(' (start your app)'));
|
|
514
|
+
console.log(chalk_1.default.gray(' Terminal 2:') + chalk_1.default.cyan(` checkpoint start -p ${port}`) + chalk_1.default.gray(' (start the tunnel)'));
|
|
515
|
+
console.log('');
|
|
516
|
+
console.log(chalk_1.default.gray(' Start your dev server first, then run this command again.'));
|
|
517
|
+
console.log('');
|
|
518
|
+
process.exit(1);
|
|
519
|
+
}
|
|
492
520
|
// Authenticate
|
|
493
521
|
const sb = await getAuthenticatedClient();
|
|
494
522
|
if (!sb) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "checkpoint-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Share your localhost with reviewers — get visual feedback directly on the page",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"checkpoint",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"bin": {
|
|
17
|
-
"checkpoint": "
|
|
17
|
+
"checkpoint": "dist/index.js"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|