localssl-cli 0.1.9 → 0.1.10
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 +6 -0
- package/package.json +1 -1
- package/src/postinstall.js +26 -0
package/README.md
CHANGED
|
@@ -51,12 +51,18 @@ Then run your app as usual (`npm run dev` / `npm start`).
|
|
|
51
51
|
- Adds `preserve: "localssl-cli use"` if `serve` exists
|
|
52
52
|
- If pre-hooks already exist, prepends `localssl-cli use && ...`
|
|
53
53
|
- Skips if already configured
|
|
54
|
+
- Also runs one-time auto setup during install (best-effort) so native commands keep working as-is (`ng serve`, `vite`, `next dev`, etc.)
|
|
54
55
|
|
|
55
56
|
Disable this behavior:
|
|
56
57
|
```bash
|
|
57
58
|
LOCALSSL_SKIP_POSTINSTALL=1 npm i -D localssl-cli
|
|
58
59
|
```
|
|
59
60
|
|
|
61
|
+
Disable only auto-run setup (keep hook wiring):
|
|
62
|
+
```bash
|
|
63
|
+
LOCALSSL_SKIP_AUTO_SETUP=1 npm i -D localssl-cli
|
|
64
|
+
```
|
|
65
|
+
|
|
60
66
|
---
|
|
61
67
|
|
|
62
68
|
## Commands
|
package/package.json
CHANGED
package/src/postinstall.js
CHANGED
|
@@ -51,11 +51,37 @@ async function run() {
|
|
|
51
51
|
changed = ensureHook(targetPackage.scripts, 'preserve', 'localssl-cli use', 'serve') || changed;
|
|
52
52
|
|
|
53
53
|
if (!changed) {
|
|
54
|
+
await autoSetupForNativeCommands(initCwd, targetPackage);
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
await fs.writeJson(targetPackageJsonPath, targetPackage, { spaces: 2 });
|
|
58
59
|
console.log('localssl-cli: added predev/prestart/preserve HTTPS setup hooks');
|
|
60
|
+
await autoSetupForNativeCommands(initCwd, targetPackage);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function autoSetupForNativeCommands(projectDir, targetPackage) {
|
|
64
|
+
if (process.env.LOCALSSL_SKIP_AUTO_SETUP === '1' || process.env.CI === 'true' || process.env.CI === '1') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const scripts = targetPackage.scripts || {};
|
|
69
|
+
const hasWebScript = scripts.dev || scripts.start || scripts.serve;
|
|
70
|
+
if (!hasWebScript) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const originalCwd = process.cwd();
|
|
75
|
+
try {
|
|
76
|
+
process.chdir(projectDir);
|
|
77
|
+
const { useProject } = require('./use');
|
|
78
|
+
await useProject([], { open: false });
|
|
79
|
+
console.log('localssl-cli: project HTTPS auto-configured during install');
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.log(`localssl-cli: auto-setup skipped (${error.message})`);
|
|
82
|
+
} finally {
|
|
83
|
+
process.chdir(originalCwd);
|
|
84
|
+
}
|
|
59
85
|
}
|
|
60
86
|
|
|
61
87
|
run().catch(() => {});
|