checkpoint-cli 0.1.1 → 0.1.3
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 +42 -9
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -79,17 +79,21 @@ function requireAuth() {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
/* ── Checkpoint Tracking Script (injected into HTML responses) ── */
|
|
82
|
-
function trackingScript(
|
|
82
|
+
function trackingScript() {
|
|
83
83
|
return `
|
|
84
84
|
<script data-checkpoint>
|
|
85
85
|
(function(){
|
|
86
|
-
var
|
|
86
|
+
var lastPath='';
|
|
87
87
|
function report(){
|
|
88
88
|
try{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
var p=location.pathname+location.search+location.hash;
|
|
90
|
+
if(p!==lastPath){
|
|
91
|
+
lastPath=p;
|
|
92
|
+
window.parent.postMessage({
|
|
93
|
+
type:'checkpoint:navigate',
|
|
94
|
+
path:p
|
|
95
|
+
},'*');
|
|
96
|
+
}
|
|
93
97
|
}catch(e){}
|
|
94
98
|
}
|
|
95
99
|
report();
|
|
@@ -97,13 +101,14 @@ function trackingScript(checkpointOrigin) {
|
|
|
97
101
|
history.pushState=function(){_ps.apply(this,arguments);report();};
|
|
98
102
|
history.replaceState=function(){_rs.apply(this,arguments);report();};
|
|
99
103
|
window.addEventListener('popstate',report);
|
|
104
|
+
window.addEventListener('hashchange',report);
|
|
105
|
+
setInterval(report,500);
|
|
100
106
|
})();
|
|
101
107
|
</script>`.trim();
|
|
102
108
|
}
|
|
103
109
|
/* ── Injection Proxy ── */
|
|
104
110
|
function startInjectionProxy(targetPort) {
|
|
105
|
-
const
|
|
106
|
-
const SCRIPT = trackingScript(APP_URL);
|
|
111
|
+
const SCRIPT = trackingScript();
|
|
107
112
|
return new Promise((resolve, reject) => {
|
|
108
113
|
const server = http_1.default.createServer((req, res) => {
|
|
109
114
|
const fwdHeaders = { ...req.headers, host: `localhost:${targetPort}` };
|
|
@@ -205,6 +210,16 @@ function hasBinary(name) {
|
|
|
205
210
|
return false;
|
|
206
211
|
}
|
|
207
212
|
}
|
|
213
|
+
function checkLocalServer(port) {
|
|
214
|
+
return new Promise((resolve) => {
|
|
215
|
+
const req = http_1.default.request({ hostname: 'localhost', port, method: 'HEAD', timeout: 2000 }, () => {
|
|
216
|
+
resolve(true);
|
|
217
|
+
});
|
|
218
|
+
req.on('error', () => resolve(false));
|
|
219
|
+
req.on('timeout', () => { req.destroy(); resolve(false); });
|
|
220
|
+
req.end();
|
|
221
|
+
});
|
|
222
|
+
}
|
|
208
223
|
const VALID_PROVIDERS = ['cloudflared', 'ngrok'];
|
|
209
224
|
function isValidProvider(provider) {
|
|
210
225
|
return VALID_PROVIDERS.includes(provider);
|
|
@@ -486,8 +501,26 @@ program
|
|
|
486
501
|
console.log('');
|
|
487
502
|
// Prompt for tunnel name if not provided
|
|
488
503
|
if (!opts.name) {
|
|
489
|
-
opts.name = await prompt('Give this tunnel a name'
|
|
504
|
+
opts.name = await prompt('Give this tunnel a name');
|
|
505
|
+
if (!opts.name) {
|
|
506
|
+
console.log(chalk_1.default.red(' A tunnel name is required.'));
|
|
507
|
+
console.log('');
|
|
508
|
+
process.exit(1);
|
|
509
|
+
}
|
|
510
|
+
console.log('');
|
|
511
|
+
}
|
|
512
|
+
// Check if local server is running
|
|
513
|
+
const isRunning = await checkLocalServer(port);
|
|
514
|
+
if (!isRunning) {
|
|
515
|
+
console.log(chalk_1.default.red(` Nothing is running on localhost:${port}`));
|
|
490
516
|
console.log('');
|
|
517
|
+
console.log(chalk_1.default.white(' You need two terminals:'));
|
|
518
|
+
console.log(chalk_1.default.gray(' Terminal 1:') + chalk_1.default.cyan(` npm run dev`) + chalk_1.default.gray(' (start your app)'));
|
|
519
|
+
console.log(chalk_1.default.gray(' Terminal 2:') + chalk_1.default.cyan(` checkpoint start -p ${port}`) + chalk_1.default.gray(' (start the tunnel)'));
|
|
520
|
+
console.log('');
|
|
521
|
+
console.log(chalk_1.default.gray(' Start your dev server first, then run this command again.'));
|
|
522
|
+
console.log('');
|
|
523
|
+
process.exit(1);
|
|
491
524
|
}
|
|
492
525
|
// Authenticate
|
|
493
526
|
const sb = await getAuthenticatedClient();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "checkpoint-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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"
|