@lunora/config 1.0.0-alpha.13 → 1.0.0-alpha.131
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.md +6 -0
- package/README.md +2 -2
- package/__assets__/package-og.svg +1 -1
- package/dist/cloudflare/index.d.mts +790 -0
- package/dist/cloudflare/index.d.ts +790 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +702 -855
- package/dist/index.d.ts +702 -855
- package/dist/index.mjs +1 -22
- package/dist/packem_shared/ACCENT-CLeV5v0K.mjs +7 -0
- package/dist/packem_shared/AGENT_MODE_ENV-B54hVQ_w.mjs +1 -0
- package/dist/packem_shared/AGENT_RULES_DIR-hP9TiDNx.mjs +1 -0
- package/dist/packem_shared/ALLOW_FORWARDED_ENV-DGdbCDre.mjs +1 -0
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-DOlqQgYt.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_DRIVER-B_MaIVFz.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-cfA_ogWA.mjs +1 -0
- package/dist/packem_shared/DEV_DAEMON_ENV-D9Z83rlU.mjs +4 -0
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-BL0hrPx3.mjs +6 -0
- package/dist/packem_shared/LINKED_PROJECT_DIR-CMzUvj-1.mjs +2 -0
- package/dist/packem_shared/LUNORA_CONFIG_FILE-11ax8L-y.mjs +1 -0
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-ZclWASXS.mjs +1 -0
- package/dist/packem_shared/LUNORA_IGNORED_PATHS-DIdyP0js.mjs +19 -0
- package/dist/packem_shared/LunoraReporter-BnXUqh8t.mjs +6 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs +1 -0
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CUYWD0Mh.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-ws6iE0y-.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-BN97lRmC.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-BNB1ogaj.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-BaYShU8q.mjs +1 -0
- package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-B1h_wNDN.mjs +1 -0
- package/dist/packem_shared/WRANGLER_FILES-Bi_18Pj6.mjs +1 -0
- package/dist/packem_shared/applyAdditiveEdit-Cff30cSa.mjs +6 -0
- package/dist/packem_shared/assetContentType-DNZyUOuF.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-D2oDEMcf.mjs +18 -0
- package/dist/packem_shared/classifyPolicyEdit-BzC_MfYK.mjs +24 -0
- package/dist/packem_shared/cloudflare-driver-BHtz6vmK.mjs +1 -0
- package/dist/packem_shared/collectExportGaps-ajyIOfom.mjs +1 -0
- package/dist/packem_shared/collectWranglerSecretVariables-DZE0RIsW.mjs +1 -0
- package/dist/packem_shared/createConfirm-C5G4-dT6.mjs +7 -0
- package/dist/packem_shared/detectFramework-VTQfCNXy.mjs +1 -0
- package/dist/packem_shared/discover-info-DRQ0Ote0.mjs +1 -0
- package/dist/packem_shared/discoverAgentInfo-C8LTinx8.mjs +1 -0
- package/dist/packem_shared/discoverContainerInfo-C1zY2O8F.mjs +1 -0
- package/dist/packem_shared/discoverSchemaInfo-C8X9mo-i.mjs +1 -0
- package/dist/packem_shared/discoverWorkflowInfo-DHzCyLRj.mjs +1 -0
- package/dist/packem_shared/inferLunoraBindings-_ESCdL9P.mjs +1 -0
- package/dist/packem_shared/jsonc-edit-BZVpxVA0.mjs +1 -0
- package/dist/packem_shared/parseDevVariable-B193_28t.mjs +1 -0
- package/dist/packem_shared/parseSchema-BQjgz6bk.mjs +1 -0
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.mts → policy-scaffold.d-fV3db0S_.d.mts} +23 -23
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.ts → policy-scaffold.d-fV3db0S_.d.ts} +23 -23
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-BXNiEQ7p.mjs +1 -0
- package/dist/packem_shared/reconcileWranglerCrons-BmQa_kGL.mjs +1 -0
- package/dist/packem_shared/renderStudioHtml-B2AkxcW1.mjs +15 -0
- package/dist/packem_shared/schema-info.d-DS0bUsWE.d.mts +375 -0
- package/dist/packem_shared/schema-info.d-DS0bUsWE.d.ts +375 -0
- package/dist/packem_shared/serveJsonHandler-DQ-Yqa4J.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-BPYBNrWS.mjs +2 -0
- package/dist/packem_shared/wranglerToAlchemy-BXagFk92.mjs +6 -0
- package/dist/packem_shared/write-atomic-Cdr2oQb-.mjs +1 -0
- package/dist/studio-host/index.d.mts +166 -92
- package/dist/studio-host/index.d.ts +166 -92
- package/dist/studio-host/index.mjs +1 -7
- package/package.json +15 -8
- package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
- package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
- package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
- package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
- package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-DRSNSOOp.mjs +0 -476
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
- package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
- package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
- package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
- package/dist/packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs +0 -243
- package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
- package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
- package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
- package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
- package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
- package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
- package/dist/packem_shared/inferLunoraBindings-DIku9mTN.mjs +0 -302
- package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
- package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
- package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
- package/dist/packem_shared/reconcileWranglerBindings-DTHmqTbL.mjs +0 -277
- package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
- package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-
|
|
1
|
+
import { D as DestructivePolicyEdit, S as ScaffoldPolicyEdit, W as WireRlsEdit } from "../packem_shared/policy-scaffold.d-fV3db0S_.js";
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Parse a single `KEY=value` (optionally quoted) out of a `.dev.vars` body,
|
|
5
|
+
* returning `undefined` when the key is absent or its value is empty. A thin
|
|
6
|
+
* wrapper over {@link parseDevVariableEntries} — the single owner of the
|
|
7
|
+
* `.dev.vars` line grammar — so the key-validation, comment-skip, and quote-strip
|
|
8
|
+
* rules can't drift from every other reader/writer of the file.
|
|
9
|
+
*/
|
|
4
10
|
declare const parseDevVariable: (contents: string, key: string) => string | undefined;
|
|
5
11
|
/**
|
|
6
|
-
* Resolve the worker's admin token so the studio can auto-authenticate in
|
|
7
|
-
* dev. Prefers the `LUNORA_ADMIN_TOKEN` env var, then the project's `.dev.vars`
|
|
8
|
-
* — the same file `@cloudflare/vite-plugin` / `wrangler dev` feed the worker, so
|
|
9
|
-
* the token the studio sends matches the one the worker's admin gate
|
|
10
|
-
* verifies. Returns `undefined` when neither is set (the studio then prompts).
|
|
11
|
-
*/
|
|
12
|
+
* Resolve the worker's admin token so the studio can auto-authenticate in
|
|
13
|
+
* dev. Prefers the `LUNORA_ADMIN_TOKEN` env var, then the project's `.dev.vars`
|
|
14
|
+
* — the same file `@cloudflare/vite-plugin` / `wrangler dev` feed the worker, so
|
|
15
|
+
* the token the studio sends matches the one the worker's admin gate
|
|
16
|
+
* verifies. Returns `undefined` when neither is set (the studio then prompts).
|
|
17
|
+
*/
|
|
12
18
|
declare const resolveAdminToken: (root: string) => string | undefined;
|
|
13
19
|
/** Config injected into the studio document before the bundle loads. */
|
|
14
20
|
interface StudioHtmlConfig {
|
|
@@ -17,34 +23,34 @@ interface StudioHtmlConfig {
|
|
|
17
23
|
/** Router basepath the studio mounts under (e.g. `/__lunora`, or `/` for a root server). */
|
|
18
24
|
readonly basePath: string;
|
|
19
25
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
* Make the data browser editable (insert/edit/delete rows). Injected as
|
|
27
|
+
* `window.__LUNORA_DATA_EDITABLE__` for the bundle to read. The loopback-only
|
|
28
|
+
* dev hosts (the Vite `/__lunora` route, the CLI studio server) set this so a
|
|
29
|
+
* developer can edit; a static deploy leaves it off (read-only) by default.
|
|
30
|
+
*/
|
|
25
31
|
readonly dataEditable?: boolean;
|
|
26
32
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
* Whether the project's Lunora agent skills ("rules") are installed. Injected
|
|
34
|
+
* as `window.__LUNORA_RULES_INSTALLED__` **only when `false`**, so the studio
|
|
35
|
+
* shows a "rules not installed" banner on the loopback dev hosts (which detect
|
|
36
|
+
* it) and stays quiet on a static deploy (which leaves it unset).
|
|
37
|
+
*/
|
|
32
38
|
readonly rulesInstalled?: boolean;
|
|
33
39
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
* Enable the function runner's "Run as identity" tool (execute a function as a
|
|
41
|
+
* chosen user to test auth/RLS). Injected as `window.__LUNORA_RUN_AS_IDENTITY__`.
|
|
42
|
+
* Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts set
|
|
43
|
+
* this — forging an identity is a developer-only affordance; a static deploy
|
|
44
|
+
* leaves it off so the control never renders.
|
|
45
|
+
*/
|
|
40
46
|
readonly runAsIdentity?: boolean;
|
|
41
47
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
* Enable the visual schema editor (add table / column / index, written back to
|
|
49
|
+
* `lunora/schema.ts` + codegen). Injected as `window.__LUNORA_SCHEMA_EDITABLE__`.
|
|
50
|
+
* Like {@link StudioHtmlConfig.dataEditable}, only the loopback-only dev hosts
|
|
51
|
+
* set this — editing source + running codegen needs the project's filesystem and
|
|
52
|
+
* toolchain, so a static deploy leaves it off and the diagram stays read-only.
|
|
53
|
+
*/
|
|
48
54
|
readonly schemaEditable?: boolean;
|
|
49
55
|
/** URL the studio bundle is served from (absolute, host-relative). */
|
|
50
56
|
readonly scriptSrc: string;
|
|
@@ -61,30 +67,62 @@ interface StudioAssets {
|
|
|
61
67
|
readonly styles: Buffer;
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
64
|
-
* Read the prebuilt static studio files shipped by `@lunora/studio`
|
|
65
|
-
* (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
|
|
66
|
-
* with a one-time warning — when the optional package isn't installed or hasn't
|
|
67
|
-
* been built, so a missing studio never breaks the dev server.
|
|
68
|
-
*
|
|
69
|
-
* `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
|
|
70
|
-
* to this module's own location, which is correct once this code is inlined into
|
|
71
|
-
* a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
|
|
72
|
-
* installed — node walks up from the host's `dist` to find it.
|
|
73
|
-
*/
|
|
70
|
+
* Read the prebuilt static studio files shipped by `@lunora/studio`
|
|
71
|
+
* (`dist/standalone/studio.js` + `dist/styles.css`). Returns `undefined` —
|
|
72
|
+
* with a one-time warning — when the optional package isn't installed or hasn't
|
|
73
|
+
* been built, so a missing studio never breaks the dev server.
|
|
74
|
+
*
|
|
75
|
+
* `resolveFrom` controls where `@lunora/studio` is resolved from. It defaults
|
|
76
|
+
* to this module's own location, which is correct once this code is inlined into
|
|
77
|
+
* a host package (`@lunora/vite` / `@lunora/cli`) that has `@lunora/studio`
|
|
78
|
+
* installed — node walks up from the host's `dist` to find it.
|
|
79
|
+
*/
|
|
74
80
|
declare const loadStudioAssets: (logger?: WarnLogger, resolveFrom?: string) => StudioAssets | undefined;
|
|
75
81
|
/**
|
|
76
|
-
* A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
|
|
77
|
-
* `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
|
|
78
|
-
* cache {@link loadStudioAssets} for the dev session but compare this stamp per
|
|
79
|
-
* request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
|
|
80
|
-
* server restart needed.
|
|
81
|
-
*/
|
|
82
|
+
* A freshness stamp for the studio assets: the latest mtime (ms) of the resolved
|
|
83
|
+
* `studio.js` / `styles.css`, or `undefined` when they can't be resolved. Hosts
|
|
84
|
+
* cache {@link loadStudioAssets} for the dev session but compare this stamp per
|
|
85
|
+
* request, so a `@lunora/studio` rebuild mid-session is picked up live — no dev
|
|
86
|
+
* server restart needed.
|
|
87
|
+
*/
|
|
82
88
|
declare const studioAssetsStamp: (resolveFrom?: string) => number | undefined;
|
|
83
89
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
|
|
90
|
+
* Absolute path of the built standalone directory — `@lunora/studio`'s
|
|
91
|
+
* `dist/standalone`, where the `studio.js` entry and its code-split `chunk-*.js`
|
|
92
|
+
* siblings live — or `undefined` when the studio isn't installed/built. The
|
|
93
|
+
* standalone bundle is emitted with esbuild `splitting`, so the hosts must serve
|
|
94
|
+
* the whole directory (not two fixed paths); this resolves its root.
|
|
95
|
+
*/
|
|
96
|
+
declare const resolveStandaloneDirectory: (resolveFrom?: string) => string | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Read a single file from the standalone directory by its plain filename (the
|
|
99
|
+
* `studio.js` entry, a `chunk-*.js`, or a `.map`). **Path-traversal-safe** via
|
|
100
|
+
* {@link resolveContainedFile}: only a lone filename resolving to a direct child
|
|
101
|
+
* of the standalone directory is served — any separator, `..`, NUL, or absolute
|
|
102
|
+
* path is rejected — so a request like `../../etc/passwd` can never escape it.
|
|
103
|
+
* Returns the bytes, or `undefined` when the studio isn't built or the name
|
|
104
|
+
* doesn't resolve to a file inside the directory (the host answers that 404).
|
|
105
|
+
*/
|
|
106
|
+
declare const readStandaloneAsset: (fileName: string, resolveFrom?: string) => Buffer | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* True when `pathname` addresses a standalone JS module — the `studio.js` entry
|
|
109
|
+
* or one of its code-split `chunk-*.js` siblings (and their `.map`s). Shared by
|
|
110
|
+
* the CLI and Vite hosts so both route the same request shapes to the directory
|
|
111
|
+
* server; the stylesheet is matched separately at each host's own style path.
|
|
112
|
+
*/
|
|
113
|
+
declare const isStandaloneModulePath: (pathname: string) => boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Content-Type for a served standalone asset, by extension: `.css` → CSS,
|
|
116
|
+
* `.map` → JSON (a source map), everything else (the `.js` entry + chunks) →
|
|
117
|
+
* JavaScript. Shared by the CLI and Vite hosts so the MIME decision lives in one
|
|
118
|
+
* place.
|
|
119
|
+
*/
|
|
120
|
+
declare const assetContentType: (fileName: string) => string;
|
|
121
|
+
/**
|
|
122
|
+
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
123
|
+
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
124
|
+
* CLI's `/_lunora/*` worker proxy (single underscore).
|
|
125
|
+
*/
|
|
88
126
|
declare const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
|
|
89
127
|
/** A `wireRls` request additionally carries the procedure's source-file path. */
|
|
90
128
|
interface WirePolicyEdit extends WireRlsEdit {
|
|
@@ -110,26 +148,26 @@ interface PolicyScaffoldResponse {
|
|
|
110
148
|
readonly status: number;
|
|
111
149
|
}
|
|
112
150
|
/**
|
|
113
|
-
* Handle a policy-scaffold request. Pure over its inputs apart from the file
|
|
114
|
-
* I/O + codegen it performs on an applied edit; safe to unit-test against a
|
|
115
|
-
* temp project directory.
|
|
116
|
-
*/
|
|
151
|
+
* Handle a policy-scaffold request. Pure over its inputs apart from the file
|
|
152
|
+
* I/O + codegen it performs on an applied edit; safe to unit-test against a
|
|
153
|
+
* temp project directory.
|
|
154
|
+
*/
|
|
117
155
|
declare const handlePolicyScaffoldRequest: (request: PolicyScaffoldRequest) => PolicyScaffoldResponse;
|
|
118
156
|
/**
|
|
119
|
-
* Render the single-page document that boots the studio. Emitted verbatim —
|
|
120
|
-
* never through a bundler/transform — so the studio stays a static tool,
|
|
121
|
-
* decoupled from the host project's build. A small inline script publishes the
|
|
122
|
-
* per-server config on `globalThis` before the bundle loads: the mount basepath
|
|
123
|
-
* (so the router stays under its mount), the admin token when present (so the
|
|
124
|
-
* studio auto-authenticates instead of prompting), and an editable flag when the
|
|
125
|
-
* host is a loopback dev server (so the data browser allows edits).
|
|
126
|
-
*/
|
|
157
|
+
* Render the single-page document that boots the studio. Emitted verbatim —
|
|
158
|
+
* never through a bundler/transform — so the studio stays a static tool,
|
|
159
|
+
* decoupled from the host project's build. A small inline script publishes the
|
|
160
|
+
* per-server config on `globalThis` before the bundle loads: the mount basepath
|
|
161
|
+
* (so the router stays under its mount), the admin token when present (so the
|
|
162
|
+
* studio auto-authenticates instead of prompting), and an editable flag when the
|
|
163
|
+
* host is a loopback dev server (so the data browser allows edits).
|
|
164
|
+
*/
|
|
127
165
|
declare const renderStudioHtml: (config: StudioHtmlConfig) => string;
|
|
128
166
|
/**
|
|
129
|
-
* Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
|
|
130
|
-
* `/_lunora/*` worker proxy (single underscore), so a schema edit is never
|
|
131
|
-
* forwarded to the worker.
|
|
132
|
-
*/
|
|
167
|
+
* Endpoint path both dev hosts mount the handler at. Distinct from the CLI's
|
|
168
|
+
* `/_lunora/*` worker proxy (single underscore), so a schema edit is never
|
|
169
|
+
* forwarded to the worker.
|
|
170
|
+
*/
|
|
133
171
|
declare const SCHEMA_EDIT_ENDPOINT = "/__lunora/schema-edit";
|
|
134
172
|
/** A request adapted from the host transport. */
|
|
135
173
|
interface SchemaEditRequest {
|
|
@@ -148,28 +186,28 @@ interface SchemaEditResponse {
|
|
|
148
186
|
readonly status: number;
|
|
149
187
|
}
|
|
150
188
|
/**
|
|
151
|
-
* Handle a schema-edit request. Pure over its inputs apart from the file I/O +
|
|
152
|
-
* codegen it performs on a `POST` additive edit; safe to unit-test against a
|
|
153
|
-
* temp project directory.
|
|
154
|
-
*/
|
|
189
|
+
* Handle a schema-edit request. Pure over its inputs apart from the file I/O +
|
|
190
|
+
* codegen it performs on a `POST` additive edit; safe to unit-test against a
|
|
191
|
+
* temp project directory.
|
|
192
|
+
*/
|
|
155
193
|
declare const handleSchemaEditRequest: (request: SchemaEditRequest) => SchemaEditResponse;
|
|
156
194
|
/**
|
|
157
|
-
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
158
|
-
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
159
|
-
* CLI's `/_lunora/*` worker proxy (single underscore).
|
|
160
|
-
*/
|
|
195
|
+
* Endpoint path both dev hosts mount the handler at. A sibling of the schema
|
|
196
|
+
* editor's `/__lunora/schema-edit`; the double underscore keeps it clear of the
|
|
197
|
+
* CLI's `/_lunora/*` worker proxy (single underscore).
|
|
198
|
+
*/
|
|
161
199
|
declare const SEED_ENDPOINT = "/__lunora/seed";
|
|
162
200
|
/** Body the host transport adapts from a `POST` — one generate-rows request. */
|
|
163
201
|
interface SeedRequestBody {
|
|
164
202
|
/** How many rows to generate (clamped to `[1, MAX_SEED_ROWS]`). */
|
|
165
203
|
readonly count?: number;
|
|
166
204
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
205
|
+
* Ids of rows that already exist in the live DB, keyed by referenced table.
|
|
206
|
+
* Foreign keys resolve against these, and every referenced parent table
|
|
207
|
+
* present here is treated as covered — so the generator links to existing
|
|
208
|
+
* rows instead of fabricating new parent rows. The studio samples these from
|
|
209
|
+
* the target table's FK columns before calling.
|
|
210
|
+
*/
|
|
173
211
|
readonly existingIds?: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
174
212
|
/** Deterministic mapping selector — same value yields identical rows. */
|
|
175
213
|
readonly seed?: number;
|
|
@@ -193,10 +231,10 @@ interface SeedResponse {
|
|
|
193
231
|
readonly status: number;
|
|
194
232
|
}
|
|
195
233
|
/**
|
|
196
|
-
* Handle a generate-rows request: statically lift the schema, generate `count`
|
|
197
|
-
* rows for `table` (linking foreign keys to the supplied existing ids rather
|
|
198
|
-
* than fabricating parents), and return them JSON-safe for the client to insert.
|
|
199
|
-
*/
|
|
234
|
+
* Handle a generate-rows request: statically lift the schema, generate `count`
|
|
235
|
+
* rows for `table` (linking foreign keys to the supplied existing ids rather
|
|
236
|
+
* than fabricating parents), and return them JSON-safe for the client to insert.
|
|
237
|
+
*/
|
|
200
238
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
201
239
|
/** A request adapted from a host transport, passed to a local-dev handler. */
|
|
202
240
|
interface LocalEndpointRequest {
|
|
@@ -217,11 +255,47 @@ interface LocalEndpointResponse {
|
|
|
217
255
|
/** A transport-agnostic local-dev handler (schema edit, policy scaffold). */
|
|
218
256
|
type LocalEndpointHandler = (request: LocalEndpointRequest) => LocalEndpointResponse;
|
|
219
257
|
/**
|
|
220
|
-
* Adapt a `node:http` request/response pair to a transport-agnostic local-dev
|
|
221
|
-
* handler. `GET` carries no body (the schema editor uses it to read the parsed
|
|
222
|
-
* schema); every other method has its body read + JSON-parsed first. The
|
|
223
|
-
* handler's `{ status, body }` is serialised back as JSON. A malformed body is a
|
|
224
|
-
* `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
258
|
+
* Adapt a `node:http` request/response pair to a transport-agnostic local-dev
|
|
259
|
+
* handler. `GET` carries no body (the schema editor uses it to read the parsed
|
|
260
|
+
* schema); every other method has its body read + JSON-parsed first. The
|
|
261
|
+
* handler's `{ status, body }` is serialised back as JSON. A malformed body is a
|
|
262
|
+
* `400`; an unexpected throw (e.g. the body-size guard) is a `500`.
|
|
263
|
+
*
|
|
264
|
+
* `schemaDirectory` (when the host configures a custom `schemaDir`) is forwarded
|
|
265
|
+
* to the handler so the schema/seed/policy endpoints target the right directory
|
|
266
|
+
* instead of always defaulting to `"lunora"`.
|
|
267
|
+
*/
|
|
268
|
+
declare const serveJsonHandler: (request: IncomingMessage, response: ServerResponse, handle: LocalEndpointHandler, projectRoot: string, schemaDirectory?: string) => void;
|
|
269
|
+
/** A single header value, lower-cased and trimmed; `undefined` when absent or array-valued. */
|
|
270
|
+
declare const headerValue: (raw: string | string[] | undefined) => string | undefined;
|
|
271
|
+
/**
|
|
272
|
+
* True for an IPv4/IPv6 loopback peer (`127.0.0.0/8`, `::1`, and the
|
|
273
|
+
* IPv4-mapped `::ffff:127.x`). A missing address means we cannot read the
|
|
274
|
+
* transport (e.g. a mocked request in tests) — treated as loopback so the
|
|
275
|
+
* config-derived gate stays the source of truth there; on a real Vite/Node
|
|
276
|
+
* server `remoteAddress` is always populated.
|
|
277
|
+
*/
|
|
278
|
+
declare const isLoopbackAddress: (remoteAddress: string | undefined) => boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Explicit opt-out for the forwarding-header refusal below — set to `"1"` to
|
|
281
|
+
* allow a proxied request through once you've confirmed the forwarding is
|
|
282
|
+
* your own trusted dev tunnel (Codespaces, devcontainers, Gitpod, Cloud
|
|
283
|
+
* Workstations, ngrok, a Docker reverse proxy, …), not an attacker's relay.
|
|
284
|
+
* Does not relax the socket-peer or `Host` checks — only this one.
|
|
285
|
+
*/
|
|
286
|
+
declare const ALLOW_FORWARDED_ENV = "LUNORA_STUDIO_ALLOW_FORWARDED";
|
|
287
|
+
/**
|
|
288
|
+
* Per-request transport gate, independent of a host's config-derived bind
|
|
289
|
+
* intent (e.g. Vite's `isNonLoopbackBind`, the CLI's `isLoopback`). In Vite
|
|
290
|
+
* middleware mode the real bind belongs to the embedding server (so the
|
|
291
|
+
* config check measures the wrong thing); here we read the actual socket peer
|
|
292
|
+
* and the `Host` header. Returns a refusal reason, or `undefined` when the
|
|
293
|
+
* connection is loopback-local.
|
|
294
|
+
*
|
|
295
|
+
* `logger`, when supplied, gets a `warnOnce` line for a forwarding-header
|
|
296
|
+
* refusal — naming the specific header seen and the {@link ALLOW_FORWARDED_ENV}
|
|
297
|
+
* escape hatch — so the failure points at its cause in the terminal running
|
|
298
|
+
* the dev server, not just as an opaque 403 in the browser.
|
|
299
|
+
*/
|
|
300
|
+
declare const transportRejectionReason: (request: IncomingMessage, logger?: WarnLogger) => string | undefined;
|
|
301
|
+
export { ALLOW_FORWARDED_ENV, type LocalEndpointHandler, type LocalEndpointRequest, type LocalEndpointResponse, POLICY_SCAFFOLD_ENDPOINT, type PolicyScaffoldBody, type PolicyScaffoldRequest, type PolicyScaffoldResponse, SCHEMA_EDIT_ENDPOINT, SEED_ENDPOINT, type SchemaEditRequest, type SchemaEditResponse, type SeedRequest, type SeedRequestBody, type SeedResponse, type StudioAssets, type StudioHtmlConfig, type WarnLogger, type WirePolicyEdit, assetContentType, handlePolicyScaffoldRequest, handleSchemaEditRequest, handleSeedRequest, headerValue, isLoopbackAddress, isStandaloneModulePath, loadStudioAssets, parseDevVariable, readStandaloneAsset, renderStudioHtml, resolveAdminToken, resolveStandaloneDirectory, serveJsonHandler, studioAssetsStamp, transportRejectionReason };
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as loadStudioAssets, studioAssetsStamp } from '../packem_shared/loadStudioAssets-Csk5RS4E.mjs';
|
|
3
|
-
export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest } from '../packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs';
|
|
4
|
-
export { default as renderStudioHtml } from '../packem_shared/renderStudioHtml-449Ysn75.mjs';
|
|
5
|
-
export { SCHEMA_EDIT_ENDPOINT, handleSchemaEditRequest } from '../packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs';
|
|
6
|
-
export { SEED_ENDPOINT, handleSeedRequest } from '../packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs';
|
|
7
|
-
export { serveJsonHandler } from '../packem_shared/serveJsonHandler-B4OLTGLS.mjs';
|
|
1
|
+
import{parseDevVariable as t,resolveAdminToken as r}from"../packem_shared/parseDevVariable-B193_28t.mjs";import{assetContentType as s,isStandaloneModulePath as d,loadStudioAssets as n,readStandaloneAsset as l,resolveStandaloneDirectory as p,studioAssetsStamp as m}from"../packem_shared/assetContentType-DNZyUOuF.mjs";import{POLICY_SCAFFOLD_ENDPOINT as f,handlePolicyScaffoldRequest as i}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-CUYWD0Mh.mjs";import{default as E}from"../packem_shared/renderStudioHtml-B2AkxcW1.mjs";import{SCHEMA_EDIT_ENDPOINT as A,handleSchemaEditRequest as x}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-BNB1ogaj.mjs";import{SEED_ENDPOINT as O,handleSeedRequest as R}from"../packem_shared/SEED_ENDPOINT-BaYShU8q.mjs";import{serveJsonHandler as c}from"../packem_shared/serveJsonHandler-DQ-Yqa4J.mjs";import{ALLOW_FORWARDED_ENV as P,headerValue as T,isLoopbackAddress as I,transportRejectionReason as L}from"../packem_shared/ALLOW_FORWARDED_ENV-DGdbCDre.mjs";export{P as ALLOW_FORWARDED_ENV,f as POLICY_SCAFFOLD_ENDPOINT,A as SCHEMA_EDIT_ENDPOINT,O as SEED_ENDPOINT,s as assetContentType,i as handlePolicyScaffoldRequest,x as handleSchemaEditRequest,R as handleSeedRequest,T as headerValue,I as isLoopbackAddress,d as isStandaloneModulePath,n as loadStudioAssets,t as parseDevVariable,l as readStandaloneAsset,E as renderStudioHtml,r as resolveAdminToken,p as resolveStandaloneDirectory,c as serveJsonHandler,m as studioAssetsStamp,L as transportRejectionReason};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.131",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"directory": "packages/config"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist",
|
|
28
|
+
"./dist",
|
|
29
29
|
"__assets__",
|
|
30
30
|
"README.md",
|
|
31
31
|
"LICENSE.md"
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"types": "./dist/index.d.ts",
|
|
41
41
|
"import": "./dist/index.mjs"
|
|
42
42
|
},
|
|
43
|
+
"./cloudflare": {
|
|
44
|
+
"types": "./dist/cloudflare/index.d.ts",
|
|
45
|
+
"import": "./dist/cloudflare/index.mjs"
|
|
46
|
+
},
|
|
43
47
|
"./studio-host": {
|
|
44
48
|
"types": "./dist/studio-host/index.d.ts",
|
|
45
49
|
"import": "./dist/studio-host/index.mjs"
|
|
@@ -50,16 +54,19 @@
|
|
|
50
54
|
"access": "public"
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
54
|
-
"@lunora/container": "1.0.0-alpha.
|
|
55
|
-
"@lunora/
|
|
56
|
-
"@
|
|
57
|
-
"
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.102",
|
|
58
|
+
"@lunora/container": "1.0.0-alpha.29",
|
|
59
|
+
"@lunora/errors": "1.0.0-alpha.20",
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.69",
|
|
61
|
+
"@visulima/colorize": "2.0.0",
|
|
62
|
+
"@visulima/find-ai-runner": "1.0.0",
|
|
63
|
+
"dockerode": "^5.0.1",
|
|
64
|
+
"es-module-lexer": "^2.3.1",
|
|
58
65
|
"jsonc-parser": "^3.3.1",
|
|
59
66
|
"ts-morph": "^28.0.0"
|
|
60
67
|
},
|
|
61
68
|
"peerDependencies": {
|
|
62
|
-
"@lunora/studio": "1.0.0-alpha.
|
|
69
|
+
"@lunora/studio": ">=1.0.0-alpha.50 <2.0.0-0"
|
|
63
70
|
},
|
|
64
71
|
"peerDependenciesMeta": {
|
|
65
72
|
"@lunora/studio": {
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import colorize from '@visulima/colorize';
|
|
2
|
-
|
|
3
|
-
const ACCENT = "#a855f7";
|
|
4
|
-
const INK = "#0b0b0b";
|
|
5
|
-
const STEP_BADGE_NAMES = ["lunora", "dir", "tmpl", "add", "deps", "git", "next"];
|
|
6
|
-
const BADGES = {
|
|
7
|
-
add: { bg: ACCENT, fg: INK, text: "add" },
|
|
8
|
-
debug: { bg: "#6b7280", fg: "#f3f4f6", text: "debug" },
|
|
9
|
-
deps: { bg: ACCENT, fg: INK, text: "deps" },
|
|
10
|
-
dir: { bg: ACCENT, fg: INK, text: "dir" },
|
|
11
|
-
error: { bg: "#ef4444", fg: INK, text: "error" },
|
|
12
|
-
git: { bg: "#f59e0b", fg: INK, text: "git" },
|
|
13
|
-
info: { bg: "#3b82f6", fg: INK, text: "info" },
|
|
14
|
-
lunora: { bg: "#22c55e", fg: INK, text: "lunora" },
|
|
15
|
-
next: { bg: "#06b6d4", fg: INK, text: "next" },
|
|
16
|
-
success: { bg: "#22c55e", fg: INK, text: "ok" },
|
|
17
|
-
tmpl: { bg: ACCENT, fg: INK, text: "tmpl" },
|
|
18
|
-
warn: { bg: "#f59e0b", fg: INK, text: "warn" }
|
|
19
|
-
};
|
|
20
|
-
const LUNA_NAME = "Luna";
|
|
21
|
-
const LUNA_SIGNOFF = "Safe travels, voyager.";
|
|
22
|
-
const LUNA_BUNNY = String.raw`
|
|
23
|
-
.-"""""-.
|
|
24
|
-
/ (\(\ \
|
|
25
|
-
| ( -.-) |
|
|
26
|
-
\ o(")(") /
|
|
27
|
-
'-._____.-'`;
|
|
28
|
-
const LUNA_ART = LUNA_BUNNY.startsWith("\n") ? LUNA_BUNNY.slice(1) : LUNA_BUNNY;
|
|
29
|
-
const BADGE_GUTTER = 6;
|
|
30
|
-
const padBadge = (text) => ` ${text} `;
|
|
31
|
-
const badgeLead = (text) => " ".repeat(Math.max(0, BADGE_GUTTER - text.length));
|
|
32
|
-
const BADGE_COLUMN_WIDTH = BADGE_GUTTER + 2;
|
|
33
|
-
const badgeWidth = (_spec) => BADGE_COLUMN_WIDTH;
|
|
34
|
-
const paintBadge = (spec) => (
|
|
35
|
-
// eslint-disable-next-line import/no-named-as-default-member -- see file header.
|
|
36
|
-
badgeLead(spec.text) + colorize.bgHex(spec.bg).hex(spec.fg).bold(padBadge(spec.text))
|
|
37
|
-
);
|
|
38
|
-
const paintAnswer = (text) => colorize.dim(text);
|
|
39
|
-
|
|
40
|
-
export { ACCENT, BADGES, BADGE_COLUMN_WIDTH, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, STEP_BADGE_NAMES, badgeLead, badgeWidth, padBadge, paintAnswer, paintBadge };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
const AGENT_RULES_DIR = ".agents/skills";
|
|
5
|
-
const AGENT_RULES_HINT_ENV = "LUNORA_RULES_HINT_SHOWN";
|
|
6
|
-
const LUNORA_SKILL_NAMES = [
|
|
7
|
-
"lunora",
|
|
8
|
-
"lunora-quickstart",
|
|
9
|
-
"lunora-functions",
|
|
10
|
-
"lunora-realtime",
|
|
11
|
-
"lunora-setup-auth",
|
|
12
|
-
"lunora-create-package",
|
|
13
|
-
"lunora-migration-helper",
|
|
14
|
-
"lunora-deploy",
|
|
15
|
-
"lunora-performance-audit"
|
|
16
|
-
];
|
|
17
|
-
const ROOT_SKILL_NAME = "lunora";
|
|
18
|
-
const AGENT_RULES_HINT = "Lunora AI rules not installed — run `lunora rules install` so your coding agent knows how to use Lunora.";
|
|
19
|
-
const claimAgentRulesHint = () => {
|
|
20
|
-
if (process.env[AGENT_RULES_HINT_ENV] === "1") {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
process.env[AGENT_RULES_HINT_ENV] = "1";
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
const skillFile = (projectRoot, name) => join(projectRoot, AGENT_RULES_DIR, name, "SKILL.md");
|
|
27
|
-
const detectAgentRules = (projectRoot) => {
|
|
28
|
-
const present = [];
|
|
29
|
-
const missing = [];
|
|
30
|
-
for (const name of LUNORA_SKILL_NAMES) {
|
|
31
|
-
if (existsSync(skillFile(projectRoot, name))) {
|
|
32
|
-
present.push(name);
|
|
33
|
-
} else {
|
|
34
|
-
missing.push(name);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return { installed: existsSync(skillFile(projectRoot, ROOT_SKILL_NAME)), missing, present };
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, LUNORA_SKILL_NAMES, ROOT_SKILL_NAME, claimAgentRulesHint, detectAgentRules };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const DEV_VARS_FILE = ".dev.vars";
|
|
2
|
-
const DEV_VARS_EXAMPLE_FILE = ".dev.vars.example";
|
|
3
|
-
const DEV_VARS_KEY_PATTERN = /^[A-Za-z_]\w*$/u;
|
|
4
|
-
const DEV_VARS_NEWLINE = /\r?\n/u;
|
|
5
|
-
const unquoteDevVariable = (value) => {
|
|
6
|
-
if (value.length >= 2 && (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'"))) {
|
|
7
|
-
return value.slice(1, -1);
|
|
8
|
-
}
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
|
-
const splitDevVariableLine = (line) => {
|
|
12
|
-
const trimmed = line.trim();
|
|
13
|
-
if (trimmed === "" || trimmed.startsWith("#")) {
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
const equals = trimmed.indexOf("=");
|
|
17
|
-
if (equals <= 0) {
|
|
18
|
-
return void 0;
|
|
19
|
-
}
|
|
20
|
-
const key = trimmed.slice(0, equals).trim();
|
|
21
|
-
if (!DEV_VARS_KEY_PATTERN.test(key)) {
|
|
22
|
-
return void 0;
|
|
23
|
-
}
|
|
24
|
-
return { key, value: trimmed.slice(equals + 1).trim() };
|
|
25
|
-
};
|
|
26
|
-
const parseDevVariableEntries = (content) => {
|
|
27
|
-
const entries = [];
|
|
28
|
-
for (const line of content.split(DEV_VARS_NEWLINE)) {
|
|
29
|
-
const parsed = splitDevVariableLine(line);
|
|
30
|
-
if (parsed) {
|
|
31
|
-
entries.push({ key: parsed.key, value: unquoteDevVariable(parsed.value) });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return entries;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, DEV_VARS_NEWLINE, parseDevVariableEntries, splitDevVariableLine, unquoteDevVariable };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { parse } from 'jsonc-parser';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
|
|
5
|
-
const LINKED_PROJECT_DIR = ".lunora";
|
|
6
|
-
const LINKED_PROJECT_FILE = join(LINKED_PROJECT_DIR, "project.json");
|
|
7
|
-
const isObject = (value) => value !== null && typeof value === "object";
|
|
8
|
-
const stringField = (record, key) => {
|
|
9
|
-
const value = record[key];
|
|
10
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
11
|
-
};
|
|
12
|
-
const readLinkedProject = (projectRoot) => {
|
|
13
|
-
const path = join(projectRoot, LINKED_PROJECT_FILE);
|
|
14
|
-
if (!existsSync(path)) {
|
|
15
|
-
return void 0;
|
|
16
|
-
}
|
|
17
|
-
let text;
|
|
18
|
-
try {
|
|
19
|
-
text = readFileSync(path, "utf8");
|
|
20
|
-
} catch {
|
|
21
|
-
return void 0;
|
|
22
|
-
}
|
|
23
|
-
const parseErrors = [];
|
|
24
|
-
const parsed = parse(text, parseErrors, { allowTrailingComma: true });
|
|
25
|
-
if (parseErrors.length > 0 || !isObject(parsed)) {
|
|
26
|
-
return void 0;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
account: stringField(parsed, "account"),
|
|
30
|
-
env: stringField(parsed, "env"),
|
|
31
|
-
linkedAt: stringField(parsed, "linkedAt"),
|
|
32
|
-
workerName: stringField(parsed, "workerName"),
|
|
33
|
-
workerUrl: stringField(parsed, "workerUrl")
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const writeLinkedProject = (projectRoot, link) => {
|
|
37
|
-
const directory = join(projectRoot, LINKED_PROJECT_DIR);
|
|
38
|
-
mkdirSync(directory, { recursive: true });
|
|
39
|
-
const record = {};
|
|
40
|
-
for (const key of ["account", "env", "linkedAt", "workerName", "workerUrl"]) {
|
|
41
|
-
const value = link[key];
|
|
42
|
-
if (value !== void 0 && value !== "") {
|
|
43
|
-
record[key] = value;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const path = join(projectRoot, LINKED_PROJECT_FILE);
|
|
47
|
-
writeFileSync(path, `${JSON.stringify(record, void 0, 2)}
|
|
48
|
-
`, "utf8");
|
|
49
|
-
return path;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export { LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, readLinkedProject, writeLinkedProject };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { parse } from 'jsonc-parser';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
|
|
5
|
-
const LUNORA_CONFIG_FILE = "lunora.json";
|
|
6
|
-
const interpretRemote = (value) => {
|
|
7
|
-
if (typeof value === "boolean") {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
if (value !== null && typeof value === "object") {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return void 0;
|
|
14
|
-
};
|
|
15
|
-
const readProjectRemotePreference = (projectRoot) => {
|
|
16
|
-
const configPath = join(projectRoot, LUNORA_CONFIG_FILE);
|
|
17
|
-
if (!existsSync(configPath)) {
|
|
18
|
-
return void 0;
|
|
19
|
-
}
|
|
20
|
-
let text;
|
|
21
|
-
try {
|
|
22
|
-
text = readFileSync(configPath, "utf8");
|
|
23
|
-
} catch {
|
|
24
|
-
return void 0;
|
|
25
|
-
}
|
|
26
|
-
const parseErrors = [];
|
|
27
|
-
const parsed = parse(text, parseErrors, { allowTrailingComma: true });
|
|
28
|
-
if (parseErrors.length > 0 || parsed === null || typeof parsed !== "object") {
|
|
29
|
-
return void 0;
|
|
30
|
-
}
|
|
31
|
-
return interpretRemote(parsed.remote);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { LUNORA_CONFIG_FILE, interpretRemote, readProjectRemotePreference };
|