portless 0.9.0 → 0.9.1
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/README.md +9 -1
- package/dist/cli.js +29 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,19 @@ Replace port numbers with stable, named .localhost URLs for local development. F
|
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
|
+
**Global (recommended):**
|
|
13
|
+
|
|
12
14
|
```bash
|
|
13
15
|
npm install -g portless
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
**Or as a project dev dependency:**
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -D portless
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> portless is pre-1.0. When installed per-project, different contributors may run different versions. The state directory format may change between releases, which can require re-running `portless trust`.
|
|
17
25
|
|
|
18
26
|
## Run your app
|
|
19
27
|
|
package/dist/cli.js
CHANGED
|
@@ -491,7 +491,10 @@ function createSNICallback(stateDir, defaultCert, defaultKey, tld = "localhost")
|
|
|
491
491
|
function trustCA(stateDir) {
|
|
492
492
|
const caCertPath = path.join(stateDir, CA_CERT_FILE);
|
|
493
493
|
if (!fileExists(caCertPath)) {
|
|
494
|
-
return {
|
|
494
|
+
return {
|
|
495
|
+
trusted: false,
|
|
496
|
+
error: "CA certificate not found. Run portless trust to generate it."
|
|
497
|
+
};
|
|
495
498
|
}
|
|
496
499
|
try {
|
|
497
500
|
if (process.platform === "darwin") {
|
|
@@ -735,6 +738,18 @@ function getEntryScript() {
|
|
|
735
738
|
}
|
|
736
739
|
return script;
|
|
737
740
|
}
|
|
741
|
+
function isLocallyInstalled() {
|
|
742
|
+
let dir = process.cwd();
|
|
743
|
+
for (; ; ) {
|
|
744
|
+
if (fs3.existsSync(path3.join(dir, "node_modules", "portless", "package.json"))) {
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
const parent = path3.dirname(dir);
|
|
748
|
+
if (parent === dir) break;
|
|
749
|
+
dir = parent;
|
|
750
|
+
}
|
|
751
|
+
return false;
|
|
752
|
+
}
|
|
738
753
|
function collectPortlessEnvArgs() {
|
|
739
754
|
const envArgs = [];
|
|
740
755
|
for (const key of Object.keys(process.env)) {
|
|
@@ -1276,8 +1291,8 @@ Eliminates port conflicts, memorizing port numbers, and cookie/storage
|
|
|
1276
1291
|
clashes by giving each dev server a stable .localhost URL.
|
|
1277
1292
|
|
|
1278
1293
|
${colors_default.bold("Install:")}
|
|
1279
|
-
${colors_default.cyan("npm install -g portless")}
|
|
1280
|
-
|
|
1294
|
+
${colors_default.cyan("npm install -g portless")} Global (recommended)
|
|
1295
|
+
${colors_default.cyan("npm install -D portless")} Project dev dependency
|
|
1281
1296
|
|
|
1282
1297
|
${colors_default.bold("Usage:")}
|
|
1283
1298
|
${colors_default.cyan("portless proxy start")} Start the proxy (HTTPS on port 443, daemon)
|
|
@@ -1378,11 +1393,18 @@ ${colors_default.bold("Reserved names:")}
|
|
|
1378
1393
|
process.exit(0);
|
|
1379
1394
|
}
|
|
1380
1395
|
function printVersion() {
|
|
1381
|
-
console.log("0.9.
|
|
1396
|
+
console.log("0.9.1");
|
|
1382
1397
|
process.exit(0);
|
|
1383
1398
|
}
|
|
1384
1399
|
async function handleTrust() {
|
|
1385
1400
|
const { dir } = await discoverState();
|
|
1401
|
+
if (!fs3.existsSync(dir)) {
|
|
1402
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
1403
|
+
}
|
|
1404
|
+
const { caGenerated } = ensureCerts(dir);
|
|
1405
|
+
if (caGenerated) {
|
|
1406
|
+
console.log(colors_default.gray("Generated local CA certificate."));
|
|
1407
|
+
}
|
|
1386
1408
|
const result = trustCA(dir);
|
|
1387
1409
|
if (result.trusted) {
|
|
1388
1410
|
console.log(colors_default.green("Local CA added to system trust store."));
|
|
@@ -2032,10 +2054,11 @@ async function main() {
|
|
|
2032
2054
|
const args = process.argv.slice(2);
|
|
2033
2055
|
const isNpx = process.env.npm_command === "exec" && !process.env.npm_lifecycle_event;
|
|
2034
2056
|
const isPnpmDlx = !!process.env.PNPM_SCRIPT_SRC_DIR && !process.env.npm_lifecycle_event;
|
|
2035
|
-
if (isNpx || isPnpmDlx) {
|
|
2057
|
+
if ((isNpx || isPnpmDlx) && !isLocallyInstalled()) {
|
|
2036
2058
|
console.error(colors_default.red("Error: portless should not be run via npx or pnpm dlx."));
|
|
2037
|
-
console.error(colors_default.blue("Install globally
|
|
2059
|
+
console.error(colors_default.blue("Install globally or as a project dependency:"));
|
|
2038
2060
|
console.error(colors_default.cyan(" npm install -g portless"));
|
|
2061
|
+
console.error(colors_default.cyan(" npm install -D portless"));
|
|
2039
2062
|
process.exit(1);
|
|
2040
2063
|
}
|
|
2041
2064
|
if (args[0] === "--name") {
|