@lensmcp/cluster 1.0.0
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/LICENSE +202 -0
- package/README.md +130 -0
- package/basic-ssl.d.ts +7 -0
- package/basic-ssl.d.ts.map +1 -0
- package/basic-ssl.js +158 -0
- package/build-scope-patterns.d.ts +12 -0
- package/build-scope-patterns.d.ts.map +1 -0
- package/build-scope-patterns.js +40 -0
- package/create-webpack-dev.d.ts +27 -0
- package/create-webpack-dev.d.ts.map +1 -0
- package/create-webpack-dev.js +151 -0
- package/create-webpack-prod.d.ts +28 -0
- package/create-webpack-prod.d.ts.map +1 -0
- package/create-webpack-prod.js +169 -0
- package/executors/build/build.impl.d.ts +19 -0
- package/executors/build/build.impl.d.ts.map +1 -0
- package/executors/build/build.impl.js +98 -0
- package/executors/build/schema.d.ts +35 -0
- package/executors/build/schema.json +135 -0
- package/executors/gateway/gateway.impl.d.ts +23 -0
- package/executors/gateway/gateway.impl.d.ts.map +1 -0
- package/executors/gateway/gateway.impl.js +39 -0
- package/executors/gateway/gateway.lib.d.ts +130 -0
- package/executors/gateway/gateway.lib.d.ts.map +1 -0
- package/executors/gateway/gateway.lib.js +797 -0
- package/executors/gateway/jwks-verify.d.ts +28 -0
- package/executors/gateway/jwks-verify.d.ts.map +1 -0
- package/executors/gateway/jwks-verify.js +121 -0
- package/executors/gateway/main.prod-gateway.d.ts +2 -0
- package/executors/gateway/main.prod-gateway.d.ts.map +1 -0
- package/executors/gateway/main.prod-gateway.js +290 -0
- package/executors/gateway/main.rollout.d.ts +2 -0
- package/executors/gateway/main.rollout.d.ts.map +1 -0
- package/executors/gateway/main.rollout.js +130 -0
- package/executors/gateway/manifest.d.ts +275 -0
- package/executors/gateway/manifest.d.ts.map +1 -0
- package/executors/gateway/manifest.js +344 -0
- package/executors/gateway/prod-gateway.lib.d.ts +58 -0
- package/executors/gateway/prod-gateway.lib.d.ts.map +1 -0
- package/executors/gateway/prod-gateway.lib.js +535 -0
- package/executors/gateway/providers-prod.d.ts +46 -0
- package/executors/gateway/providers-prod.d.ts.map +1 -0
- package/executors/gateway/providers-prod.js +199 -0
- package/executors/gateway/registry-source.d.ts +68 -0
- package/executors/gateway/registry-source.d.ts.map +1 -0
- package/executors/gateway/registry-source.js +131 -0
- package/executors/gateway/rollout-ops.d.ts +54 -0
- package/executors/gateway/rollout-ops.d.ts.map +1 -0
- package/executors/gateway/rollout-ops.js +167 -0
- package/executors/gateway/schema.d.ts +10 -0
- package/executors/gateway/schema.json +30 -0
- package/executors/serve/schema.d.ts +53 -0
- package/executors/serve/schema.json +196 -0
- package/executors/serve/serve.impl.d.ts +25 -0
- package/executors/serve/serve.impl.d.ts.map +1 -0
- package/executors/serve/serve.impl.js +243 -0
- package/executors/trust/schema.d.ts +6 -0
- package/executors/trust/schema.json +20 -0
- package/executors/trust/trust.impl.d.ts +42 -0
- package/executors/trust/trust.impl.d.ts.map +1 -0
- package/executors/trust/trust.impl.js +126 -0
- package/executors.json +24 -0
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -0
- package/index.js +9 -0
- package/main.devserver.d.ts +16 -0
- package/main.devserver.d.ts.map +1 -0
- package/main.devserver.js +812 -0
- package/package.json +66 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = trustExecutor;
|
|
4
|
+
exports.collectHosts = collectHosts;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const node_child_process_1 = require("node:child_process");
|
|
7
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
8
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
9
|
+
const basic_ssl_1 = require("../../basic-ssl");
|
|
10
|
+
/**
|
|
11
|
+
* `trust` executor — one idempotent command that makes the HTTPS dev gateway
|
|
12
|
+
* green in real browsers:
|
|
13
|
+
*
|
|
14
|
+
* 1. mints the local dev CA if missing (same CA the gateway serves),
|
|
15
|
+
* 2. adds it ONCE to the macOS System keychain (`sudo security
|
|
16
|
+
* add-trusted-cert`) — every leaf rotation / new hostname then chains
|
|
17
|
+
* to it with no interstitial,
|
|
18
|
+
* 3. writes BOTH `/etc/hosts` families (`127.0.0.1` + `::1`) for every
|
|
19
|
+
* gateway route hostname — the missing `::1` line is what sends `.local`
|
|
20
|
+
* AAAA lookups to Bonjour/mDNS and costs ~5s per resolution,
|
|
21
|
+
* 4. flushes the DNS cache.
|
|
22
|
+
*
|
|
23
|
+
* Hostnames come from the project's serve target gateway routes (wildcards
|
|
24
|
+
* skipped — they can't live in /etc/hosts) plus any `hosts` option extras.
|
|
25
|
+
* Run it from a terminal: sudo prompts for your password inline.
|
|
26
|
+
*/
|
|
27
|
+
async function trustExecutor(options, context) {
|
|
28
|
+
const cacheDir = path.join(context.root, 'node_modules', '.cache', 'davnx-webpack');
|
|
29
|
+
const caPath = (0, basic_ssl_1.ensureCaSync)(cacheDir);
|
|
30
|
+
const hosts = collectHosts(options, context);
|
|
31
|
+
if (hosts.length === 0) {
|
|
32
|
+
console.log('[trust] no concrete hostnames found (only wildcards?) — keychain step only.');
|
|
33
|
+
}
|
|
34
|
+
if (process.platform !== 'darwin') {
|
|
35
|
+
console.log('[trust] non-macOS platform — do these manually:');
|
|
36
|
+
console.log(` • trust ${caPath} in your OS/browser store (Linux: update-ca-certificates / certutil)`);
|
|
37
|
+
for (const h of hosts)
|
|
38
|
+
console.log(` • /etc/hosts: "127.0.0.1 ${h}" and "::1 ${h}"`);
|
|
39
|
+
return { success: true };
|
|
40
|
+
}
|
|
41
|
+
// --- 1) CA into the System keychain (skip when already there) -----------
|
|
42
|
+
const present = (0, node_child_process_1.spawnSync)('security', ['find-certificate', '-c', 'davnx local dev CA', '/Library/Keychains/System.keychain'], {
|
|
43
|
+
stdio: 'ignore',
|
|
44
|
+
}).status === 0;
|
|
45
|
+
if (present) {
|
|
46
|
+
console.log('[trust] CA already in the System keychain — skipping.');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log(`[trust] adding CA to the System keychain (sudo will prompt): ${caPath}`);
|
|
50
|
+
const r = (0, node_child_process_1.spawnSync)('sudo', ['security', 'add-trusted-cert', '-d', '-r', 'trustRoot', '-k', '/Library/Keychains/System.keychain', caPath], { stdio: 'inherit' });
|
|
51
|
+
if (r.status !== 0) {
|
|
52
|
+
console.error('[trust] add-trusted-cert failed — rerun in a terminal so sudo can prompt.');
|
|
53
|
+
return { success: false };
|
|
54
|
+
}
|
|
55
|
+
console.log('[trust] CA trusted. Restart your browser once (it caches certificate verdicts).');
|
|
56
|
+
}
|
|
57
|
+
// --- 2) /etc/hosts: both address families per hostname ------------------
|
|
58
|
+
const etcHosts = fs.readFileSync('/etc/hosts', 'utf8');
|
|
59
|
+
const hasEntry = (ip, host) => etcHosts.split('\n').some((line) => {
|
|
60
|
+
const t = line.trim();
|
|
61
|
+
if (t.startsWith('#'))
|
|
62
|
+
return false;
|
|
63
|
+
const cols = t.split(/\s+/);
|
|
64
|
+
return cols[0] === ip && cols.slice(1).includes(host);
|
|
65
|
+
});
|
|
66
|
+
const missing = [];
|
|
67
|
+
for (const h of hosts) {
|
|
68
|
+
if (!hasEntry('127.0.0.1', h))
|
|
69
|
+
missing.push(`127.0.0.1 ${h}`);
|
|
70
|
+
if (!hasEntry('::1', h))
|
|
71
|
+
missing.push(`::1 ${h}`);
|
|
72
|
+
}
|
|
73
|
+
if (missing.length === 0) {
|
|
74
|
+
console.log('[trust] /etc/hosts already complete (both families for every hostname).');
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
console.log(`[trust] appending to /etc/hosts (sudo):\n ${missing.join('\n ')}`);
|
|
78
|
+
const script = `printf '%s\\n' ${missing.map((l) => `'${l}'`).join(' ')} >> /etc/hosts`;
|
|
79
|
+
const r = (0, node_child_process_1.spawnSync)('sudo', ['sh', '-c', script], { stdio: 'inherit' });
|
|
80
|
+
if (r.status !== 0) {
|
|
81
|
+
console.error('[trust] /etc/hosts update failed.');
|
|
82
|
+
return { success: false };
|
|
83
|
+
}
|
|
84
|
+
// --- 3) flush DNS so the new entries take effect immediately ----------
|
|
85
|
+
(0, node_child_process_1.spawnSync)('sudo', ['sh', '-c', 'dscacheutil -flushcache; killall -HUP mDNSResponder'], { stdio: 'inherit' });
|
|
86
|
+
}
|
|
87
|
+
// --- 4) verify ------------------------------------------------------------
|
|
88
|
+
const verify = (0, node_child_process_1.spawnSync)('security', ['verify-cert', '-c', caPath, '-p', 'basic'], { stdio: 'ignore' });
|
|
89
|
+
console.log(`[trust] CA trust check: ${verify.status === 0 ? 'OK' : 'NOT TRUSTED YET (browser restart may be needed)'}`);
|
|
90
|
+
for (const h of hosts) {
|
|
91
|
+
console.log(`[trust] ${h} → https ready (hosts + cert SAN ride the gateway config)`);
|
|
92
|
+
}
|
|
93
|
+
return { success: true };
|
|
94
|
+
}
|
|
95
|
+
function collectHosts(options, context) {
|
|
96
|
+
const found = [];
|
|
97
|
+
// 1) This project's embedded gateway routes (single-service setups).
|
|
98
|
+
const project = context.projectName
|
|
99
|
+
? context.projectsConfigurations?.projects[context.projectName]
|
|
100
|
+
: undefined;
|
|
101
|
+
const serveTarget = options.serveTarget ?? 'serve-hmr';
|
|
102
|
+
const routes = project?.targets?.[serveTarget]?.options?.gateway?.routes ?? [];
|
|
103
|
+
for (const r of routes) {
|
|
104
|
+
if (r.host && !r.host.includes('*'))
|
|
105
|
+
found.push(r.host);
|
|
106
|
+
}
|
|
107
|
+
// 2) Every project's `davnx` declaration — the workspace gateway picture.
|
|
108
|
+
for (const p of Object.values(context.projectsConfigurations?.projects ?? {})) {
|
|
109
|
+
try {
|
|
110
|
+
const raw = JSON.parse(fs.readFileSync(path.join(context.root, p.root, 'project.json'), 'utf8'));
|
|
111
|
+
const decl = raw.cluster ?? raw.davnx;
|
|
112
|
+
const h = decl?.host;
|
|
113
|
+
if (h && !h.includes('*')) {
|
|
114
|
+
found.push(h);
|
|
115
|
+
// socket-pool services also get internal.<host> (east-west, no middleware)
|
|
116
|
+
if (decl?.service && decl.internalHost !== false) {
|
|
117
|
+
found.push(typeof decl.internalHost === 'string' ? decl.internalHost : `internal.${h}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
/* projects without a project.json (package.json-inferred) — skip */
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return [...new Set([...found, ...(options.hosts ?? [])])];
|
|
126
|
+
}
|
package/executors.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executors": {
|
|
3
|
+
"build": {
|
|
4
|
+
"implementation": "./src/executors/build/build.impl",
|
|
5
|
+
"schema": "./src/executors/build/schema.json",
|
|
6
|
+
"description": "Production webpack build for a NestJS application."
|
|
7
|
+
},
|
|
8
|
+
"serve": {
|
|
9
|
+
"implementation": "./src/executors/serve/serve.impl",
|
|
10
|
+
"schema": "./src/executors/serve/schema.json",
|
|
11
|
+
"description": "Webpack watch mode with integrated devserver for a NestJS application."
|
|
12
|
+
},
|
|
13
|
+
"trust": {
|
|
14
|
+
"implementation": "./src/executors/trust/trust.impl",
|
|
15
|
+
"schema": "./src/executors/trust/schema.json",
|
|
16
|
+
"description": "One-time HTTPS dev setup: trust the davnx local CA + write /etc/hosts entries for gateway hostnames (idempotent, sudo prompts inline)."
|
|
17
|
+
},
|
|
18
|
+
"gateway": {
|
|
19
|
+
"implementation": "./src/executors/gateway/gateway.impl",
|
|
20
|
+
"schema": "./src/executors/gateway/schema.json",
|
|
21
|
+
"description": "Workspace https front door: reads every project davnx declaration (host/port/prefix), routes by hostname, serves the local-CA cert with all SANs."
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type NodeExternalsConfig, type ScopePatterns, buildScopePatterns } from './build-scope-patterns';
|
|
2
|
+
export { createDevWebpackConfig, type DevWebpackOptions } from './create-webpack-dev';
|
|
3
|
+
export { createProdWebpackConfig, type ProdWebpackOptions } from './create-webpack-prod';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../libs/cluster/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1G,OAAO,EAAE,sBAAsB,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProdWebpackConfig = exports.createDevWebpackConfig = exports.buildScopePatterns = void 0;
|
|
4
|
+
var build_scope_patterns_1 = require("./build-scope-patterns");
|
|
5
|
+
Object.defineProperty(exports, "buildScopePatterns", { enumerable: true, get: function () { return build_scope_patterns_1.buildScopePatterns; } });
|
|
6
|
+
var create_webpack_dev_1 = require("./create-webpack-dev");
|
|
7
|
+
Object.defineProperty(exports, "createDevWebpackConfig", { enumerable: true, get: function () { return create_webpack_dev_1.createDevWebpackConfig; } });
|
|
8
|
+
var create_webpack_prod_1 = require("./create-webpack-prod");
|
|
9
|
+
Object.defineProperty(exports, "createProdWebpackConfig", { enumerable: true, get: function () { return create_webpack_prod_1.createProdWebpackConfig; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface GatewayRoute {
|
|
2
|
+
/** Hostname to match — exact (`api.tetros.localhost`) or wildcard (`*.tetros.localhost`). */
|
|
3
|
+
host?: string;
|
|
4
|
+
/** URL prefix to match (e.g. `/api`). */
|
|
5
|
+
prefix?: string;
|
|
6
|
+
/** Proxy destination (e.g. `http://localhost:5173`). Omit → this service's children. */
|
|
7
|
+
target?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Prepend this to the forwarded URL. The prod-parity case: the app mounts
|
|
10
|
+
* at `/api` but the dev domain `api.tetros.ai.local` should serve it at
|
|
11
|
+
* the ROOT (like prod `api.tetros.ai`) — `prependPrefix: '/api'` rewrites
|
|
12
|
+
* `/tenants/...` → `/api/tenants/...` on the way to the children.
|
|
13
|
+
*/
|
|
14
|
+
prependPrefix?: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=main.devserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.devserver.d.ts","sourceRoot":"","sources":["../../../libs/cluster/src/main.devserver.ts"],"names":[],"mappings":"AA8EA,MAAM,WAAW,YAAY;IAC3B,6FAA6F;IAC7F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|