@geekmidas/cli 0.49.0 → 0.51.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/dist/deploy/sniffer-envkit-patch.cjs +27 -0
- package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -0
- package/dist/deploy/sniffer-envkit-patch.d.cts +46 -0
- package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -0
- package/dist/deploy/sniffer-envkit-patch.d.mts +46 -0
- package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -0
- package/dist/deploy/sniffer-envkit-patch.mjs +20 -0
- package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -0
- package/dist/deploy/sniffer-hooks.cjs +25 -0
- package/dist/deploy/sniffer-hooks.cjs.map +1 -0
- package/dist/deploy/sniffer-hooks.d.cts +27 -0
- package/dist/deploy/sniffer-hooks.d.cts.map +1 -0
- package/dist/deploy/sniffer-hooks.d.mts +27 -0
- package/dist/deploy/sniffer-hooks.d.mts.map +1 -0
- package/dist/deploy/sniffer-hooks.mjs +24 -0
- package/dist/deploy/sniffer-hooks.mjs.map +1 -0
- package/dist/deploy/sniffer-loader.cjs +16 -0
- package/dist/deploy/sniffer-loader.cjs.map +1 -0
- package/dist/deploy/sniffer-loader.d.cts +1 -0
- package/dist/deploy/sniffer-loader.d.mts +1 -0
- package/dist/deploy/sniffer-loader.mjs +15 -0
- package/dist/deploy/sniffer-loader.mjs.map +1 -0
- package/dist/deploy/sniffer-worker.cjs +42 -0
- package/dist/deploy/sniffer-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-worker.d.cts +9 -0
- package/dist/deploy/sniffer-worker.d.cts.map +1 -0
- package/dist/deploy/sniffer-worker.d.mts +9 -0
- package/dist/deploy/sniffer-worker.d.mts.map +1 -0
- package/dist/deploy/sniffer-worker.mjs +41 -0
- package/dist/deploy/sniffer-worker.mjs.map +1 -0
- package/dist/index.cjs +26 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +26 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/deploy/index.ts +5 -3
- package/src/deploy/sniffer-envkit-patch.ts +19 -3
- package/src/deploy/sniffer-hooks.ts +6 -1
- package/src/deploy/sniffer-loader.ts +7 -2
- package/src/deploy/sniffer.ts +36 -2
- package/tsdown.config.ts +5 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
2
|
+
const __geekmidas_envkit_sniffer = require_chunk.__toESM(require("@geekmidas/envkit/sniffer"));
|
|
3
|
+
|
|
4
|
+
//#region src/deploy/sniffer-envkit-patch.ts
|
|
5
|
+
if (!globalThis.__envSniffer) globalThis.__envSniffer = new __geekmidas_envkit_sniffer.SnifferEnvironmentParser();
|
|
6
|
+
/**
|
|
7
|
+
* Patched EnvironmentParser that uses the global sniffer instance.
|
|
8
|
+
*
|
|
9
|
+
* This class wraps the global sniffer to maintain API compatibility
|
|
10
|
+
* with the real EnvironmentParser. The constructor accepts an env
|
|
11
|
+
* parameter for API compatibility but ignores it since we're sniffing.
|
|
12
|
+
*/
|
|
13
|
+
var PatchedEnvironmentParser = class {
|
|
14
|
+
create(builder) {
|
|
15
|
+
return globalThis.__envSniffer.create(builder);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.EnvironmentParser = PatchedEnvironmentParser;
|
|
21
|
+
Object.defineProperty(exports, 'SnifferEnvironmentParser', {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return __geekmidas_envkit_sniffer.SnifferEnvironmentParser;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=sniffer-envkit-patch.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-envkit-patch.cjs","names":["SnifferEnvironmentParser","builder: (get: EnvFetcher) => TReturn"],"sources":["../../src/deploy/sniffer-envkit-patch.ts"],"sourcesContent":["/**\n * Patched @geekmidas/envkit module for entry app sniffing.\n *\n * This module re-exports the SnifferEnvironmentParser as EnvironmentParser,\n * allowing entry apps to be imported while capturing their env var usage.\n *\n * The actual sniffer instance is stored in globalThis.__envSniffer\n * so the worker script can retrieve the captured variables.\n */\n\nimport { SnifferEnvironmentParser } from '@geekmidas/envkit/sniffer';\n\n// Extend globalThis type for the sniffer instance\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __envSniffer: SnifferEnvironmentParser | undefined;\n}\n\n// Create a shared sniffer instance that will be used by all imports\n// This is stored globally so the worker script can access it\nif (!globalThis.__envSniffer) {\n\tglobalThis.__envSniffer = new SnifferEnvironmentParser();\n}\n\n// Type for the config parser returned by create()\ninterface ConfigParser<T> {\n\tparse(): T;\n\tsafeParse(): { success: true; data: T } | { success: false; error: Error };\n}\n\n// Type for the env fetcher function\ntype EnvFetcher = (name: string) => {\n\tstring(): { parse(): string; safeParse(): unknown };\n\tnumber(): { parse(): number; safeParse(): unknown };\n\tboolean(): { parse(): boolean; safeParse(): unknown };\n\toptional(): EnvFetcher;\n\tdefault(value: unknown): EnvFetcher;\n};\n\n/**\n * Patched EnvironmentParser that uses the global sniffer instance.\n *\n * This class wraps the global sniffer to maintain API compatibility\n * with the real EnvironmentParser. The constructor accepts an env\n * parameter for API compatibility but ignores it since we're sniffing.\n */\nclass PatchedEnvironmentParser {\n\tcreate<TReturn extends Record<string, unknown>>(\n\t\tbuilder: (get: EnvFetcher) => TReturn,\n\t): ConfigParser<TReturn> {\n\t\treturn globalThis.__envSniffer!.create(builder) as ConfigParser<TReturn>;\n\t}\n}\n\n// Export the patched parser as EnvironmentParser\nexport { PatchedEnvironmentParser as EnvironmentParser };\n\n// Re-export other envkit exports that entry apps might use\nexport { SnifferEnvironmentParser } from '@geekmidas/envkit/sniffer';\n"],"mappings":";;;;AAoBA,KAAK,WAAW,aACf,YAAW,eAAe,IAAIA;;;;;;;;AAyB/B,IAAM,2BAAN,MAA+B;CAC9B,OACCC,SACwB;AACxB,SAAO,WAAW,aAAc,OAAO,QAAQ;CAC/C;AACD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SnifferEnvironmentParser, SnifferEnvironmentParser as SnifferEnvironmentParser$1 } from "@geekmidas/envkit/sniffer";
|
|
2
|
+
|
|
3
|
+
//#region src/deploy/sniffer-envkit-patch.d.ts
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
var __envSniffer: SnifferEnvironmentParser$1 | undefined;
|
|
7
|
+
}
|
|
8
|
+
interface ConfigParser<T> {
|
|
9
|
+
parse(): T;
|
|
10
|
+
safeParse(): {
|
|
11
|
+
success: true;
|
|
12
|
+
data: T;
|
|
13
|
+
} | {
|
|
14
|
+
success: false;
|
|
15
|
+
error: Error;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
type EnvFetcher = (name: string) => {
|
|
19
|
+
string(): {
|
|
20
|
+
parse(): string;
|
|
21
|
+
safeParse(): unknown;
|
|
22
|
+
};
|
|
23
|
+
number(): {
|
|
24
|
+
parse(): number;
|
|
25
|
+
safeParse(): unknown;
|
|
26
|
+
};
|
|
27
|
+
boolean(): {
|
|
28
|
+
parse(): boolean;
|
|
29
|
+
safeParse(): unknown;
|
|
30
|
+
};
|
|
31
|
+
optional(): EnvFetcher;
|
|
32
|
+
default(value: unknown): EnvFetcher;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Patched EnvironmentParser that uses the global sniffer instance.
|
|
36
|
+
*
|
|
37
|
+
* This class wraps the global sniffer to maintain API compatibility
|
|
38
|
+
* with the real EnvironmentParser. The constructor accepts an env
|
|
39
|
+
* parameter for API compatibility but ignores it since we're sniffing.
|
|
40
|
+
*/
|
|
41
|
+
declare class PatchedEnvironmentParser {
|
|
42
|
+
create<TReturn extends Record<string, unknown>>(builder: (get: EnvFetcher) => TReturn): ConfigParser<TReturn>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { PatchedEnvironmentParser as EnvironmentParser, SnifferEnvironmentParser };
|
|
46
|
+
//# sourceMappingURL=sniffer-envkit-patch.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-envkit-patch.d.cts","names":[],"sources":["../../src/deploy/sniffer-envkit-patch.ts"],"sourcesContent":[],"mappings":";;;;QA0BU,MAAA,CAAA;EAAC,IAC0B,YAAA,EAZlB,0BAYkB,GAAA,SAAA;;AAAoC,UAF/D,YAE+D,CAAA,CAAA,CAAA,CAAA;EAIpE,KAAA,EAAA,EALK,CAKL;EAAU,SAAA,EAAA,EAAA;IAIF,OAAA,EAAA,IAAA;IACa,IAAA,EATW,CASX;EAAU,CAAA,GAAA;IAU9B,OAAA,EAAA,KAAA;IAAwB,KAAA,EAnBsC,KAmBtC;EAAA,CAAA;;KAfzB,UAAA,GAiB2B,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA;EAAO,MACtB,EAAA,EAAA;IAAb,KAAA,EAAA,EAAA,MAAA;IAAY,SAAA,EAAA,EAAA,OAAA;;;;;;;;;;cAdH;2BACa;;;;;;;;;cAUpB,wBAAA;yBACkB,wCACP,eAAe,UAC5B,aAAa"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SnifferEnvironmentParser, SnifferEnvironmentParser as SnifferEnvironmentParser$1 } from "@geekmidas/envkit/sniffer";
|
|
2
|
+
|
|
3
|
+
//#region src/deploy/sniffer-envkit-patch.d.ts
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
var __envSniffer: SnifferEnvironmentParser$1 | undefined;
|
|
7
|
+
}
|
|
8
|
+
interface ConfigParser<T> {
|
|
9
|
+
parse(): T;
|
|
10
|
+
safeParse(): {
|
|
11
|
+
success: true;
|
|
12
|
+
data: T;
|
|
13
|
+
} | {
|
|
14
|
+
success: false;
|
|
15
|
+
error: Error;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
type EnvFetcher = (name: string) => {
|
|
19
|
+
string(): {
|
|
20
|
+
parse(): string;
|
|
21
|
+
safeParse(): unknown;
|
|
22
|
+
};
|
|
23
|
+
number(): {
|
|
24
|
+
parse(): number;
|
|
25
|
+
safeParse(): unknown;
|
|
26
|
+
};
|
|
27
|
+
boolean(): {
|
|
28
|
+
parse(): boolean;
|
|
29
|
+
safeParse(): unknown;
|
|
30
|
+
};
|
|
31
|
+
optional(): EnvFetcher;
|
|
32
|
+
default(value: unknown): EnvFetcher;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Patched EnvironmentParser that uses the global sniffer instance.
|
|
36
|
+
*
|
|
37
|
+
* This class wraps the global sniffer to maintain API compatibility
|
|
38
|
+
* with the real EnvironmentParser. The constructor accepts an env
|
|
39
|
+
* parameter for API compatibility but ignores it since we're sniffing.
|
|
40
|
+
*/
|
|
41
|
+
declare class PatchedEnvironmentParser {
|
|
42
|
+
create<TReturn extends Record<string, unknown>>(builder: (get: EnvFetcher) => TReturn): ConfigParser<TReturn>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { PatchedEnvironmentParser as EnvironmentParser, SnifferEnvironmentParser };
|
|
46
|
+
//# sourceMappingURL=sniffer-envkit-patch.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-envkit-patch.d.mts","names":[],"sources":["../../src/deploy/sniffer-envkit-patch.ts"],"sourcesContent":[],"mappings":";;;;QA0BU,MAAA,CAAA;EAAC,IAC0B,YAAA,EAZlB,0BAYkB,GAAA,SAAA;;AAAoC,UAF/D,YAE+D,CAAA,CAAA,CAAA,CAAA;EAIpE,KAAA,EAAA,EALK,CAKL;EAAU,SAAA,EAAA,EAAA;IAIF,OAAA,EAAA,IAAA;IACa,IAAA,EATW,CASX;EAAU,CAAA,GAAA;IAU9B,OAAA,EAAA,KAAA;IAAwB,KAAA,EAnBsC,KAmBtC;EAAA,CAAA;;KAfzB,UAAA,GAiB2B,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA;EAAO,MACtB,EAAA,EAAA;IAAb,KAAA,EAAA,EAAA,MAAA;IAAY,SAAA,EAAA,EAAA,OAAA;;;;;;;;;;cAdH;2BACa;;;;;;;;;cAUpB,wBAAA;yBACkB,wCACP,eAAe,UAC5B,aAAa"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SnifferEnvironmentParser, SnifferEnvironmentParser as SnifferEnvironmentParser$1 } from "@geekmidas/envkit/sniffer";
|
|
2
|
+
|
|
3
|
+
//#region src/deploy/sniffer-envkit-patch.ts
|
|
4
|
+
if (!globalThis.__envSniffer) globalThis.__envSniffer = new SnifferEnvironmentParser$1();
|
|
5
|
+
/**
|
|
6
|
+
* Patched EnvironmentParser that uses the global sniffer instance.
|
|
7
|
+
*
|
|
8
|
+
* This class wraps the global sniffer to maintain API compatibility
|
|
9
|
+
* with the real EnvironmentParser. The constructor accepts an env
|
|
10
|
+
* parameter for API compatibility but ignores it since we're sniffing.
|
|
11
|
+
*/
|
|
12
|
+
var PatchedEnvironmentParser = class {
|
|
13
|
+
create(builder) {
|
|
14
|
+
return globalThis.__envSniffer.create(builder);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { PatchedEnvironmentParser as EnvironmentParser, SnifferEnvironmentParser };
|
|
20
|
+
//# sourceMappingURL=sniffer-envkit-patch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-envkit-patch.mjs","names":["SnifferEnvironmentParser","builder: (get: EnvFetcher) => TReturn"],"sources":["../../src/deploy/sniffer-envkit-patch.ts"],"sourcesContent":["/**\n * Patched @geekmidas/envkit module for entry app sniffing.\n *\n * This module re-exports the SnifferEnvironmentParser as EnvironmentParser,\n * allowing entry apps to be imported while capturing their env var usage.\n *\n * The actual sniffer instance is stored in globalThis.__envSniffer\n * so the worker script can retrieve the captured variables.\n */\n\nimport { SnifferEnvironmentParser } from '@geekmidas/envkit/sniffer';\n\n// Extend globalThis type for the sniffer instance\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __envSniffer: SnifferEnvironmentParser | undefined;\n}\n\n// Create a shared sniffer instance that will be used by all imports\n// This is stored globally so the worker script can access it\nif (!globalThis.__envSniffer) {\n\tglobalThis.__envSniffer = new SnifferEnvironmentParser();\n}\n\n// Type for the config parser returned by create()\ninterface ConfigParser<T> {\n\tparse(): T;\n\tsafeParse(): { success: true; data: T } | { success: false; error: Error };\n}\n\n// Type for the env fetcher function\ntype EnvFetcher = (name: string) => {\n\tstring(): { parse(): string; safeParse(): unknown };\n\tnumber(): { parse(): number; safeParse(): unknown };\n\tboolean(): { parse(): boolean; safeParse(): unknown };\n\toptional(): EnvFetcher;\n\tdefault(value: unknown): EnvFetcher;\n};\n\n/**\n * Patched EnvironmentParser that uses the global sniffer instance.\n *\n * This class wraps the global sniffer to maintain API compatibility\n * with the real EnvironmentParser. The constructor accepts an env\n * parameter for API compatibility but ignores it since we're sniffing.\n */\nclass PatchedEnvironmentParser {\n\tcreate<TReturn extends Record<string, unknown>>(\n\t\tbuilder: (get: EnvFetcher) => TReturn,\n\t): ConfigParser<TReturn> {\n\t\treturn globalThis.__envSniffer!.create(builder) as ConfigParser<TReturn>;\n\t}\n}\n\n// Export the patched parser as EnvironmentParser\nexport { PatchedEnvironmentParser as EnvironmentParser };\n\n// Re-export other envkit exports that entry apps might use\nexport { SnifferEnvironmentParser } from '@geekmidas/envkit/sniffer';\n"],"mappings":";;;AAoBA,KAAK,WAAW,aACf,YAAW,eAAe,IAAIA;;;;;;;;AAyB/B,IAAM,2BAAN,MAA+B;CAC9B,OACCC,SACwB;AACxB,SAAO,WAAW,aAAc,OAAO,QAAQ;CAC/C;AACD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
2
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
3
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
|
+
const node_url = require_chunk.__toESM(require("node:url"));
|
|
5
|
+
|
|
6
|
+
//#region src/deploy/sniffer-hooks.ts
|
|
7
|
+
const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
8
|
+
const __dirname$1 = (0, node_path.dirname)(__filename$1);
|
|
9
|
+
const mjsPath = (0, node_path.join)(__dirname$1, "sniffer-envkit-patch.mjs");
|
|
10
|
+
const tsPath = (0, node_path.join)(__dirname$1, "sniffer-envkit-patch.ts");
|
|
11
|
+
const patchedEnvkitPath = (0, node_fs.existsSync)(mjsPath) ? mjsPath : tsPath;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve hook - intercepts module resolution for @geekmidas/envkit
|
|
14
|
+
*/
|
|
15
|
+
async function resolve(specifier, context, nextResolve) {
|
|
16
|
+
if (specifier === "@geekmidas/envkit") return {
|
|
17
|
+
url: `file://${patchedEnvkitPath}`,
|
|
18
|
+
shortCircuit: true
|
|
19
|
+
};
|
|
20
|
+
return nextResolve(specifier, context);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.resolve = resolve;
|
|
25
|
+
//# sourceMappingURL=sniffer-hooks.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-hooks.cjs","names":["__filename","__dirname","specifier: string","context: ResolveContext","nextResolve: NextResolve"],"sources":["../../src/deploy/sniffer-hooks.ts"],"sourcesContent":["/**\n * Module loader hooks for entry app sniffing.\n *\n * This module provides the resolve hook that intercepts '@geekmidas/envkit'\n * imports and redirects them to the patched sniffer version.\n *\n * This file is registered via module.register() from sniffer-loader.ts.\n */\n\nimport { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Resolve path to the patched envkit module\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Try .mjs first (production dist), then .ts (development)\nconst mjsPath = join(__dirname, 'sniffer-envkit-patch.mjs');\nconst tsPath = join(__dirname, 'sniffer-envkit-patch.ts');\nconst patchedEnvkitPath = existsSync(mjsPath) ? mjsPath : tsPath;\n\ntype ResolveContext = {\n\tconditions: string[];\n\timportAttributes: Record<string, string>;\n\tparentURL?: string;\n};\n\ntype ResolveResult = {\n\turl: string;\n\tshortCircuit?: boolean;\n\tformat?: string;\n};\n\ntype NextResolve = (\n\tspecifier: string,\n\tcontext: ResolveContext,\n) => Promise<ResolveResult>;\n\n/**\n * Resolve hook - intercepts module resolution for @geekmidas/envkit\n */\nexport async function resolve(\n\tspecifier: string,\n\tcontext: ResolveContext,\n\tnextResolve: NextResolve,\n): Promise<ResolveResult> {\n\t// Intercept @geekmidas/envkit imports\n\tif (specifier === '@geekmidas/envkit') {\n\t\treturn {\n\t\t\turl: `file://${patchedEnvkitPath}`,\n\t\t\tshortCircuit: true,\n\t\t};\n\t}\n\n\treturn nextResolve(specifier, context);\n}\n"],"mappings":";;;;;;AAcA,MAAMA,eAAa,0EAA8B;AACjD,MAAMC,cAAY,uBAAQD,aAAW;AAGrC,MAAM,UAAU,oBAAKC,aAAW,2BAA2B;AAC3D,MAAM,SAAS,oBAAKA,aAAW,0BAA0B;AACzD,MAAM,oBAAoB,wBAAW,QAAQ,GAAG,UAAU;;;;AAsB1D,eAAsB,QACrBC,WACAC,SACAC,aACyB;AAEzB,KAAI,cAAc,oBACjB,QAAO;EACN,MAAM,SAAS,kBAAkB;EACjC,cAAc;CACd;AAGF,QAAO,YAAY,WAAW,QAAQ;AACtC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/deploy/sniffer-hooks.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Module loader hooks for entry app sniffing.
|
|
4
|
+
*
|
|
5
|
+
* This module provides the resolve hook that intercepts '@geekmidas/envkit'
|
|
6
|
+
* imports and redirects them to the patched sniffer version.
|
|
7
|
+
*
|
|
8
|
+
* This file is registered via module.register() from sniffer-loader.ts.
|
|
9
|
+
*/
|
|
10
|
+
type ResolveContext = {
|
|
11
|
+
conditions: string[];
|
|
12
|
+
importAttributes: Record<string, string>;
|
|
13
|
+
parentURL?: string;
|
|
14
|
+
};
|
|
15
|
+
type ResolveResult = {
|
|
16
|
+
url: string;
|
|
17
|
+
shortCircuit?: boolean;
|
|
18
|
+
format?: string;
|
|
19
|
+
};
|
|
20
|
+
type NextResolve = (specifier: string, context: ResolveContext) => Promise<ResolveResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve hook - intercepts module resolution for @geekmidas/envkit
|
|
23
|
+
*/
|
|
24
|
+
declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { resolve };
|
|
27
|
+
//# sourceMappingURL=sniffer-hooks.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-hooks.d.cts","names":[],"sources":["../../src/deploy/sniffer-hooks.ts"],"sourcesContent":[],"mappings":";;;AAwByB;AAIP;;;;;AASN,KAfP,cAAA,GAeO;EAKU,UAAO,EAAA,MAAA,EAAA;EAAA,gBAAA,EAlBV,MAkBU,CAAA,MAAA,EAAA,MAAA,CAAA;EAAA,SAEnB,CAAA,EAAA,MAAA;CAAc;KAhBnB,aAAA,GAkBM;EAAa,GAArB,EAAA,MAAA;EAAO,YAAA,CAAA,EAAA,OAAA;;;KAZL,WAAA,gCAEK,mBACL,QAAQ;;;;iBAKS,OAAA,6BAEZ,6BACI,cACX,QAAQ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/deploy/sniffer-hooks.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Module loader hooks for entry app sniffing.
|
|
4
|
+
*
|
|
5
|
+
* This module provides the resolve hook that intercepts '@geekmidas/envkit'
|
|
6
|
+
* imports and redirects them to the patched sniffer version.
|
|
7
|
+
*
|
|
8
|
+
* This file is registered via module.register() from sniffer-loader.ts.
|
|
9
|
+
*/
|
|
10
|
+
type ResolveContext = {
|
|
11
|
+
conditions: string[];
|
|
12
|
+
importAttributes: Record<string, string>;
|
|
13
|
+
parentURL?: string;
|
|
14
|
+
};
|
|
15
|
+
type ResolveResult = {
|
|
16
|
+
url: string;
|
|
17
|
+
shortCircuit?: boolean;
|
|
18
|
+
format?: string;
|
|
19
|
+
};
|
|
20
|
+
type NextResolve = (specifier: string, context: ResolveContext) => Promise<ResolveResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve hook - intercepts module resolution for @geekmidas/envkit
|
|
23
|
+
*/
|
|
24
|
+
declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { resolve };
|
|
27
|
+
//# sourceMappingURL=sniffer-hooks.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-hooks.d.mts","names":[],"sources":["../../src/deploy/sniffer-hooks.ts"],"sourcesContent":[],"mappings":";;;AAwByB;AAIP;;;;;AASN,KAfP,cAAA,GAeO;EAKU,UAAO,EAAA,MAAA,EAAA;EAAA,gBAAA,EAlBV,MAkBU,CAAA,MAAA,EAAA,MAAA,CAAA;EAAA,SAEnB,CAAA,EAAA,MAAA;CAAc;KAhBnB,aAAA,GAkBM;EAAa,GAArB,EAAA,MAAA;EAAO,YAAA,CAAA,EAAA,OAAA;;;KAZL,WAAA,gCAEK,mBACL,QAAQ;;;;iBAKS,OAAA,6BAEZ,6BACI,cACX,QAAQ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
//#region src/deploy/sniffer-hooks.ts
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
const mjsPath = join(__dirname, "sniffer-envkit-patch.mjs");
|
|
9
|
+
const tsPath = join(__dirname, "sniffer-envkit-patch.ts");
|
|
10
|
+
const patchedEnvkitPath = existsSync(mjsPath) ? mjsPath : tsPath;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve hook - intercepts module resolution for @geekmidas/envkit
|
|
13
|
+
*/
|
|
14
|
+
async function resolve(specifier, context, nextResolve) {
|
|
15
|
+
if (specifier === "@geekmidas/envkit") return {
|
|
16
|
+
url: `file://${patchedEnvkitPath}`,
|
|
17
|
+
shortCircuit: true
|
|
18
|
+
};
|
|
19
|
+
return nextResolve(specifier, context);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { resolve };
|
|
24
|
+
//# sourceMappingURL=sniffer-hooks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-hooks.mjs","names":["specifier: string","context: ResolveContext","nextResolve: NextResolve"],"sources":["../../src/deploy/sniffer-hooks.ts"],"sourcesContent":["/**\n * Module loader hooks for entry app sniffing.\n *\n * This module provides the resolve hook that intercepts '@geekmidas/envkit'\n * imports and redirects them to the patched sniffer version.\n *\n * This file is registered via module.register() from sniffer-loader.ts.\n */\n\nimport { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Resolve path to the patched envkit module\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Try .mjs first (production dist), then .ts (development)\nconst mjsPath = join(__dirname, 'sniffer-envkit-patch.mjs');\nconst tsPath = join(__dirname, 'sniffer-envkit-patch.ts');\nconst patchedEnvkitPath = existsSync(mjsPath) ? mjsPath : tsPath;\n\ntype ResolveContext = {\n\tconditions: string[];\n\timportAttributes: Record<string, string>;\n\tparentURL?: string;\n};\n\ntype ResolveResult = {\n\turl: string;\n\tshortCircuit?: boolean;\n\tformat?: string;\n};\n\ntype NextResolve = (\n\tspecifier: string,\n\tcontext: ResolveContext,\n) => Promise<ResolveResult>;\n\n/**\n * Resolve hook - intercepts module resolution for @geekmidas/envkit\n */\nexport async function resolve(\n\tspecifier: string,\n\tcontext: ResolveContext,\n\tnextResolve: NextResolve,\n): Promise<ResolveResult> {\n\t// Intercept @geekmidas/envkit imports\n\tif (specifier === '@geekmidas/envkit') {\n\t\treturn {\n\t\t\turl: `file://${patchedEnvkitPath}`,\n\t\t\tshortCircuit: true,\n\t\t};\n\t}\n\n\treturn nextResolve(specifier, context);\n}\n"],"mappings":";;;;;AAcA,MAAM,aAAa,cAAc,OAAO,KAAK,IAAI;AACjD,MAAM,YAAY,QAAQ,WAAW;AAGrC,MAAM,UAAU,KAAK,WAAW,2BAA2B;AAC3D,MAAM,SAAS,KAAK,WAAW,0BAA0B;AACzD,MAAM,oBAAoB,WAAW,QAAQ,GAAG,UAAU;;;;AAsB1D,eAAsB,QACrBA,WACAC,SACAC,aACyB;AAEzB,KAAI,cAAc,oBACjB,QAAO;EACN,MAAM,SAAS,kBAAkB;EACjC,cAAc;CACd;AAGF,QAAO,YAAY,WAAW,QAAQ;AACtC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
2
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
3
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
|
+
const node_url = require_chunk.__toESM(require("node:url"));
|
|
5
|
+
const node_module = require_chunk.__toESM(require("node:module"));
|
|
6
|
+
|
|
7
|
+
//#region src/deploy/sniffer-loader.ts
|
|
8
|
+
const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
9
|
+
const __dirname$1 = (0, node_path.dirname)(__filename$1);
|
|
10
|
+
const mjsPath = (0, node_path.join)(__dirname$1, "sniffer-hooks.mjs");
|
|
11
|
+
const tsPath = (0, node_path.join)(__dirname$1, "sniffer-hooks.ts");
|
|
12
|
+
const hooksPath = (0, node_fs.existsSync)(mjsPath) ? mjsPath : tsPath;
|
|
13
|
+
(0, node_module.register)((0, node_url.pathToFileURL)(hooksPath).href, require("url").pathToFileURL(__filename).href);
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//# sourceMappingURL=sniffer-loader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-loader.cjs","names":["__filename","__dirname"],"sources":["../../src/deploy/sniffer-loader.ts"],"sourcesContent":["/**\n * Node.js module loader registration for entry app sniffing.\n *\n * This module registers a custom loader hook that intercepts imports of\n * '@geekmidas/envkit' and replaces the EnvironmentParser with\n * SnifferEnvironmentParser, allowing us to capture which environment\n * variables an entry app accesses.\n *\n * Usage:\n * node --import tsx --import ./sniffer-loader.mjs ./sniffer-worker.mjs /path/to/entry.ts\n */\n\nimport { existsSync } from 'node:fs';\nimport { register } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\n// Resolve path to the loader hooks module\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Try .mjs first (production dist), then .ts (development)\nconst mjsPath = join(__dirname, 'sniffer-hooks.mjs');\nconst tsPath = join(__dirname, 'sniffer-hooks.ts');\nconst hooksPath = existsSync(mjsPath) ? mjsPath : tsPath;\n\n// Register the loader hooks\nregister(pathToFileURL(hooksPath).href, import.meta.url);\n"],"mappings":";;;;;;;AAkBA,MAAMA,eAAa,0EAA8B;AACjD,MAAMC,cAAY,uBAAQD,aAAW;AAGrC,MAAM,UAAU,oBAAKC,aAAW,oBAAoB;AACpD,MAAM,SAAS,oBAAKA,aAAW,mBAAmB;AAClD,MAAM,YAAY,wBAAW,QAAQ,GAAG,UAAU;AAGlD,0BAAS,4BAAc,UAAU,CAAC,oDAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { register } from "node:module";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
|
+
|
|
6
|
+
//#region src/deploy/sniffer-loader.ts
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
const mjsPath = join(__dirname, "sniffer-hooks.mjs");
|
|
10
|
+
const tsPath = join(__dirname, "sniffer-hooks.ts");
|
|
11
|
+
const hooksPath = existsSync(mjsPath) ? mjsPath : tsPath;
|
|
12
|
+
register(pathToFileURL(hooksPath).href, import.meta.url);
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//# sourceMappingURL=sniffer-loader.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-loader.mjs","names":[],"sources":["../../src/deploy/sniffer-loader.ts"],"sourcesContent":["/**\n * Node.js module loader registration for entry app sniffing.\n *\n * This module registers a custom loader hook that intercepts imports of\n * '@geekmidas/envkit' and replaces the EnvironmentParser with\n * SnifferEnvironmentParser, allowing us to capture which environment\n * variables an entry app accesses.\n *\n * Usage:\n * node --import tsx --import ./sniffer-loader.mjs ./sniffer-worker.mjs /path/to/entry.ts\n */\n\nimport { existsSync } from 'node:fs';\nimport { register } from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\n// Resolve path to the loader hooks module\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n// Try .mjs first (production dist), then .ts (development)\nconst mjsPath = join(__dirname, 'sniffer-hooks.mjs');\nconst tsPath = join(__dirname, 'sniffer-hooks.ts');\nconst hooksPath = existsSync(mjsPath) ? mjsPath : tsPath;\n\n// Register the loader hooks\nregister(pathToFileURL(hooksPath).href, import.meta.url);\n"],"mappings":";;;;;;AAkBA,MAAM,aAAa,cAAc,OAAO,KAAK,IAAI;AACjD,MAAM,YAAY,QAAQ,WAAW;AAGrC,MAAM,UAAU,KAAK,WAAW,oBAAoB;AACpD,MAAM,SAAS,KAAK,WAAW,mBAAmB;AAClD,MAAM,YAAY,WAAW,QAAQ,GAAG,UAAU;AAGlD,SAAS,cAAc,UAAU,CAAC,MAAM,OAAO,KAAK,IAAI"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const require_chunk = require('../chunk-CUT6urMc.cjs');
|
|
2
|
+
const node_url = require_chunk.__toESM(require("node:url"));
|
|
3
|
+
|
|
4
|
+
//#region src/deploy/sniffer-worker.ts
|
|
5
|
+
const entryPath = process.argv[2];
|
|
6
|
+
if (!entryPath) {
|
|
7
|
+
console.log(JSON.stringify({
|
|
8
|
+
envVars: [],
|
|
9
|
+
error: "No entry file path provided"
|
|
10
|
+
}));
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
const validEntryPath = entryPath;
|
|
14
|
+
/**
|
|
15
|
+
* Main sniffing function
|
|
16
|
+
*/
|
|
17
|
+
async function sniff() {
|
|
18
|
+
let error = null;
|
|
19
|
+
try {
|
|
20
|
+
const entryUrl = (0, node_url.pathToFileURL)(validEntryPath).href;
|
|
21
|
+
await import(entryUrl);
|
|
22
|
+
} catch (e) {
|
|
23
|
+
error = e instanceof Error ? e.message : String(e);
|
|
24
|
+
}
|
|
25
|
+
const sniffer = globalThis.__envSniffer;
|
|
26
|
+
const envVars = sniffer ? sniffer.getEnvironmentVariables() : [];
|
|
27
|
+
console.log(JSON.stringify({
|
|
28
|
+
envVars,
|
|
29
|
+
error
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
process.on("unhandledRejection", () => {});
|
|
33
|
+
sniff().catch((e) => {
|
|
34
|
+
console.log(JSON.stringify({
|
|
35
|
+
envVars: [],
|
|
36
|
+
error: e.message || String(e)
|
|
37
|
+
}));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//# sourceMappingURL=sniffer-worker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-worker.cjs","names":["validEntryPath: string","error: string | null"],"sources":["../../src/deploy/sniffer-worker.ts"],"sourcesContent":["/**\n * Subprocess worker for entry app sniffing.\n *\n * This script is executed in a subprocess with the sniffer-loader.ts\n * registered, which intercepts @geekmidas/envkit imports.\n *\n * Usage:\n * node --import tsx --import ./sniffer-loader.ts ./sniffer-worker.ts /path/to/entry.ts\n *\n * Output (JSON to stdout):\n * { \"envVars\": [\"PORT\", \"DATABASE_URL\", ...], \"error\": null }\n */\n\nimport { pathToFileURL } from 'node:url';\nimport type { SnifferEnvironmentParser } from '@geekmidas/envkit/sniffer';\n\n// Extend globalThis type for the sniffer instance\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __envSniffer: SnifferEnvironmentParser | undefined;\n}\n\n// Get the entry file path from command line args\nconst entryPath = process.argv[2] as string | undefined;\n\nif (!entryPath) {\n\tconsole.log(\n\t\tJSON.stringify({ envVars: [], error: 'No entry file path provided' }),\n\t);\n\tprocess.exit(1);\n}\n\n// entryPath is guaranteed to be defined after the check above\nconst validEntryPath: string = entryPath;\n\n/**\n * Main sniffing function\n */\nasync function sniff(): Promise<void> {\n\tlet error: string | null = null;\n\n\ttry {\n\t\t// Import the entry file - this triggers:\n\t\t// 1. Entry imports config module\n\t\t// 2. Config module imports @geekmidas/envkit (intercepted by loader)\n\t\t// 3. Config creates EnvironmentParser (actually SnifferEnvironmentParser)\n\t\t// 4. Config calls .create() and .parse()\n\t\t// 5. Sniffer captures all accessed env var names\n\t\tconst entryUrl = pathToFileURL(validEntryPath).href;\n\t\tawait import(entryUrl);\n\t} catch (e) {\n\t\t// Entry may fail due to missing env vars or other runtime issues.\n\t\t// This is expected - we still capture the env vars that were accessed.\n\t\terror = e instanceof Error ? e.message : String(e);\n\t}\n\n\t// Retrieve captured env vars from the global sniffer\n\tconst sniffer = globalThis.__envSniffer;\n\tconst envVars = sniffer ? sniffer.getEnvironmentVariables() : [];\n\n\t// Output result as JSON\n\tconsole.log(JSON.stringify({ envVars, error }));\n}\n\n// Handle unhandled rejections (fire-and-forget promises)\nprocess.on('unhandledRejection', () => {\n\t// Silently ignore - we only care about env var capture\n});\n\n// Run the sniffer\nsniff().catch((e) => {\n\tconsole.log(JSON.stringify({ envVars: [], error: e.message || String(e) }));\n\tprocess.exit(1);\n});\n"],"mappings":";;;;AAuBA,MAAM,YAAY,QAAQ,KAAK;AAE/B,KAAK,WAAW;AACf,SAAQ,IACP,KAAK,UAAU;EAAE,SAAS,CAAE;EAAE,OAAO;CAA+B,EAAC,CACrE;AACD,SAAQ,KAAK,EAAE;AACf;AAGD,MAAMA,iBAAyB;;;;AAK/B,eAAe,QAAuB;CACrC,IAAIC,QAAuB;AAE3B,KAAI;EAOH,MAAM,WAAW,4BAAc,eAAe,CAAC;AAC/C,QAAM,OAAO;CACb,SAAQ,GAAG;AAGX,UAAQ,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;CAClD;CAGD,MAAM,UAAU,WAAW;CAC3B,MAAM,UAAU,UAAU,QAAQ,yBAAyB,GAAG,CAAE;AAGhE,SAAQ,IAAI,KAAK,UAAU;EAAE;EAAS;CAAO,EAAC,CAAC;AAC/C;AAGD,QAAQ,GAAG,sBAAsB,MAAM,CAEtC,EAAC;AAGF,OAAO,CAAC,MAAM,CAAC,MAAM;AACpB,SAAQ,IAAI,KAAK,UAAU;EAAE,SAAS,CAAE;EAAE,OAAO,EAAE,WAAW,OAAO,EAAE;CAAE,EAAC,CAAC;AAC3E,SAAQ,KAAK,EAAE;AACf,EAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SnifferEnvironmentParser } from "@geekmidas/envkit/sniffer";
|
|
2
|
+
|
|
3
|
+
//#region src/deploy/sniffer-worker.d.ts
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
var __envSniffer: SnifferEnvironmentParser | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=sniffer-worker.d.ts.map
|
|
9
|
+
//# sourceMappingURL=sniffer-worker.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-worker.d.cts","names":[],"sources":["../../src/deploy/sniffer-worker.ts"],"sourcesContent":[],"mappings":";;;;;oBAmBmB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SnifferEnvironmentParser } from "@geekmidas/envkit/sniffer";
|
|
2
|
+
|
|
3
|
+
//#region src/deploy/sniffer-worker.d.ts
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
var __envSniffer: SnifferEnvironmentParser | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=sniffer-worker.d.ts.map
|
|
9
|
+
//# sourceMappingURL=sniffer-worker.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-worker.d.mts","names":[],"sources":["../../src/deploy/sniffer-worker.ts"],"sourcesContent":[],"mappings":";;;;;oBAmBmB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
|
|
3
|
+
//#region src/deploy/sniffer-worker.ts
|
|
4
|
+
const entryPath = process.argv[2];
|
|
5
|
+
if (!entryPath) {
|
|
6
|
+
console.log(JSON.stringify({
|
|
7
|
+
envVars: [],
|
|
8
|
+
error: "No entry file path provided"
|
|
9
|
+
}));
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
const validEntryPath = entryPath;
|
|
13
|
+
/**
|
|
14
|
+
* Main sniffing function
|
|
15
|
+
*/
|
|
16
|
+
async function sniff() {
|
|
17
|
+
let error = null;
|
|
18
|
+
try {
|
|
19
|
+
const entryUrl = pathToFileURL(validEntryPath).href;
|
|
20
|
+
await import(entryUrl);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
error = e instanceof Error ? e.message : String(e);
|
|
23
|
+
}
|
|
24
|
+
const sniffer = globalThis.__envSniffer;
|
|
25
|
+
const envVars = sniffer ? sniffer.getEnvironmentVariables() : [];
|
|
26
|
+
console.log(JSON.stringify({
|
|
27
|
+
envVars,
|
|
28
|
+
error
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
process.on("unhandledRejection", () => {});
|
|
32
|
+
sniff().catch((e) => {
|
|
33
|
+
console.log(JSON.stringify({
|
|
34
|
+
envVars: [],
|
|
35
|
+
error: e.message || String(e)
|
|
36
|
+
}));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//# sourceMappingURL=sniffer-worker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniffer-worker.mjs","names":["validEntryPath: string","error: string | null"],"sources":["../../src/deploy/sniffer-worker.ts"],"sourcesContent":["/**\n * Subprocess worker for entry app sniffing.\n *\n * This script is executed in a subprocess with the sniffer-loader.ts\n * registered, which intercepts @geekmidas/envkit imports.\n *\n * Usage:\n * node --import tsx --import ./sniffer-loader.ts ./sniffer-worker.ts /path/to/entry.ts\n *\n * Output (JSON to stdout):\n * { \"envVars\": [\"PORT\", \"DATABASE_URL\", ...], \"error\": null }\n */\n\nimport { pathToFileURL } from 'node:url';\nimport type { SnifferEnvironmentParser } from '@geekmidas/envkit/sniffer';\n\n// Extend globalThis type for the sniffer instance\ndeclare global {\n\t// eslint-disable-next-line no-var\n\tvar __envSniffer: SnifferEnvironmentParser | undefined;\n}\n\n// Get the entry file path from command line args\nconst entryPath = process.argv[2] as string | undefined;\n\nif (!entryPath) {\n\tconsole.log(\n\t\tJSON.stringify({ envVars: [], error: 'No entry file path provided' }),\n\t);\n\tprocess.exit(1);\n}\n\n// entryPath is guaranteed to be defined after the check above\nconst validEntryPath: string = entryPath;\n\n/**\n * Main sniffing function\n */\nasync function sniff(): Promise<void> {\n\tlet error: string | null = null;\n\n\ttry {\n\t\t// Import the entry file - this triggers:\n\t\t// 1. Entry imports config module\n\t\t// 2. Config module imports @geekmidas/envkit (intercepted by loader)\n\t\t// 3. Config creates EnvironmentParser (actually SnifferEnvironmentParser)\n\t\t// 4. Config calls .create() and .parse()\n\t\t// 5. Sniffer captures all accessed env var names\n\t\tconst entryUrl = pathToFileURL(validEntryPath).href;\n\t\tawait import(entryUrl);\n\t} catch (e) {\n\t\t// Entry may fail due to missing env vars or other runtime issues.\n\t\t// This is expected - we still capture the env vars that were accessed.\n\t\terror = e instanceof Error ? e.message : String(e);\n\t}\n\n\t// Retrieve captured env vars from the global sniffer\n\tconst sniffer = globalThis.__envSniffer;\n\tconst envVars = sniffer ? sniffer.getEnvironmentVariables() : [];\n\n\t// Output result as JSON\n\tconsole.log(JSON.stringify({ envVars, error }));\n}\n\n// Handle unhandled rejections (fire-and-forget promises)\nprocess.on('unhandledRejection', () => {\n\t// Silently ignore - we only care about env var capture\n});\n\n// Run the sniffer\nsniff().catch((e) => {\n\tconsole.log(JSON.stringify({ envVars: [], error: e.message || String(e) }));\n\tprocess.exit(1);\n});\n"],"mappings":";;;AAuBA,MAAM,YAAY,QAAQ,KAAK;AAE/B,KAAK,WAAW;AACf,SAAQ,IACP,KAAK,UAAU;EAAE,SAAS,CAAE;EAAE,OAAO;CAA+B,EAAC,CACrE;AACD,SAAQ,KAAK,EAAE;AACf;AAGD,MAAMA,iBAAyB;;;;AAK/B,eAAe,QAAuB;CACrC,IAAIC,QAAuB;AAE3B,KAAI;EAOH,MAAM,WAAW,cAAc,eAAe,CAAC;AAC/C,QAAM,OAAO;CACb,SAAQ,GAAG;AAGX,UAAQ,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;CAClD;CAGD,MAAM,UAAU,WAAW;CAC3B,MAAM,UAAU,UAAU,QAAQ,yBAAyB,GAAG,CAAE;AAGhE,SAAQ,IAAI,KAAK,UAAU;EAAE;EAAS;CAAO,EAAC,CAAC;AAC/C;AAGD,QAAQ,GAAG,sBAAsB,MAAM,CAEtC,EAAC;AAGF,OAAO,CAAC,MAAM,CAAC,MAAM;AACpB,SAAQ,IAAI,KAAK,UAAU;EAAE,SAAS,CAAE;EAAE,OAAO,EAAE,WAAW,OAAO,EAAE;CAAE,EAAC,CAAC;AAC3E,SAAQ,KAAK,EAAE;AACf,EAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ const node_module = require_chunk.__toESM(require("node:module"));
|
|
|
31
31
|
|
|
32
32
|
//#region package.json
|
|
33
33
|
var name = "@geekmidas/cli";
|
|
34
|
-
var version = "0.
|
|
34
|
+
var version = "0.51.0";
|
|
35
35
|
var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
|
|
36
36
|
var private$1 = false;
|
|
37
37
|
var type = "module";
|
|
@@ -4869,6 +4869,24 @@ function generateSecretsReport(encryptedApps, sniffedApps) {
|
|
|
4869
4869
|
const __filename$1 = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
4870
4870
|
const __dirname$1 = (0, node_path.dirname)(__filename$1);
|
|
4871
4871
|
/**
|
|
4872
|
+
* Resolve the path to a sniffer helper file.
|
|
4873
|
+
* Handles both dev (.ts with tsx) and production (.mjs from dist).
|
|
4874
|
+
*
|
|
4875
|
+
* In production: sniffer.ts is bundled into dist/index.mjs, but sniffer helper
|
|
4876
|
+
* files are output to dist/deploy/ as standalone modules for subprocess loading.
|
|
4877
|
+
*
|
|
4878
|
+
* In development: All files are in src/deploy/ and loaded via tsx.
|
|
4879
|
+
*/
|
|
4880
|
+
function resolveSnifferFile(baseName) {
|
|
4881
|
+
const deployMjsPath = (0, node_path.resolve)(__dirname$1, "deploy", `${baseName}.mjs`);
|
|
4882
|
+
if ((0, node_fs.existsSync)(deployMjsPath)) return deployMjsPath;
|
|
4883
|
+
const mjsPath = (0, node_path.resolve)(__dirname$1, `${baseName}.mjs`);
|
|
4884
|
+
if ((0, node_fs.existsSync)(mjsPath)) return mjsPath;
|
|
4885
|
+
const tsPath = (0, node_path.resolve)(__dirname$1, `${baseName}.ts`);
|
|
4886
|
+
if ((0, node_fs.existsSync)(tsPath)) return tsPath;
|
|
4887
|
+
return tsPath;
|
|
4888
|
+
}
|
|
4889
|
+
/**
|
|
4872
4890
|
* Get required environment variables for an app.
|
|
4873
4891
|
*
|
|
4874
4892
|
* Detection strategy (in order):
|
|
@@ -4942,8 +4960,8 @@ async function sniffAppEnvironment(app, appName, workspacePath, options = {}) {
|
|
|
4942
4960
|
*/
|
|
4943
4961
|
async function sniffEntryFile(entryPath, appPath, workspacePath) {
|
|
4944
4962
|
const fullEntryPath = (0, node_path.resolve)(workspacePath, appPath, entryPath);
|
|
4945
|
-
const loaderPath = (
|
|
4946
|
-
const workerPath = (
|
|
4963
|
+
const loaderPath = resolveSnifferFile("sniffer-loader");
|
|
4964
|
+
const workerPath = resolveSnifferFile("sniffer-worker");
|
|
4947
4965
|
return new Promise((resolvePromise) => {
|
|
4948
4966
|
const child = (0, node_child_process.spawn)("node", [
|
|
4949
4967
|
"--import",
|
|
@@ -5190,9 +5208,11 @@ async function initializePostgresUsers(api, postgres, serverHostname, users) {
|
|
|
5190
5208
|
logger$1.log(` Creating user "${user.name}" with schema "${schemaName}"...`);
|
|
5191
5209
|
await client.query(`
|
|
5192
5210
|
DO $$ BEGIN
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5211
|
+
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '${user.name}') THEN
|
|
5212
|
+
CREATE USER "${user.name}" WITH PASSWORD '${user.password}';
|
|
5213
|
+
ELSE
|
|
5214
|
+
ALTER USER "${user.name}" WITH PASSWORD '${user.password}';
|
|
5215
|
+
END IF;
|
|
5196
5216
|
END $$;
|
|
5197
5217
|
`);
|
|
5198
5218
|
if (user.usePublicSchema) await client.query(`
|