@lunora/config 1.0.0-alpha.152 → 1.0.0-alpha.154
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/cloudflare/index.mjs +1 -1
- package/dist/index.d.mts +34 -22
- package/dist/index.d.ts +34 -22
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/CLOUDFLARE_DRIVER-BC-PjyIb.mjs +1 -0
- package/dist/packem_shared/{DEFAULT_DEPLOY_TARGET-RDWcFKBe.mjs → DEFAULT_DEPLOY_TARGET-dS2wApDX.mjs} +1 -1
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
- package/dist/packem_shared/{LUNORA_CONFIG_FILE-CBV3C1Hl.mjs → LUNORA_CONFIG_FILE-GOH3iIA4.mjs} +1 -1
- package/dist/packem_shared/{REQUIRED_COMPATIBILITY_DATE-l78q5ZIV.mjs → REQUIRED_COMPATIBILITY_DATE-BM4qXyjS.mjs} +1 -1
- package/dist/packem_shared/buildPackageSecretsBlock-J7bP1P-6.mjs +19 -0
- package/dist/packem_shared/{cloudflare-driver-CvMyH1Ih.mjs → cloudflare-driver-DkF7wRh1.mjs} +1 -1
- package/dist/packem_shared/{collectExportGaps-B5eIg8p8.mjs → collectExportGaps-DHLZ7ulq.mjs} +1 -1
- package/dist/packem_shared/{collectWranglerSecretVariables-Df_H6ytT.mjs → collectWranglerSecretVariables-WNirpc4n.mjs} +1 -1
- package/dist/packem_shared/{inferLunoraBindings-CEE39hXz.mjs → inferLunoraBindings-KST9XCEe.mjs} +1 -1
- package/dist/packem_shared/{parseDevVariable-C0QlCXhO.mjs → parseDevVariable-cacbGJkN.mjs} +1 -1
- package/dist/studio-host/index.mjs +1 -1
- package/package.json +4 -3
- package/dist/packem_shared/CLOUDFLARE_DRIVER-6bjm6hSn.mjs +0 -1
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-DxtfY0DW.mjs +0 -6
- package/dist/packem_shared/buildPackageSecretsBlock-DX6SFs-J.mjs +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-Cd00jVOf.mjs";import{C as n}from"../packem_shared/cloudflare-driver-
|
|
1
|
+
import{BINDING_MANIFEST_VERSION as o,buildBindingManifest as a}from"../packem_shared/BINDING_MANIFEST_VERSION-Cd00jVOf.mjs";import{C as n}from"../packem_shared/cloudflare-driver-DkF7wRh1.mjs";import{collectExportGaps as i,reconcileWranglerBindings as E}from"../packem_shared/collectExportGaps-DHLZ7ulq.mjs";import{reconcileWranglerCompatibilityDate as c}from"../packem_shared/reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as R}from"../packem_shared/reconcileWranglerCrons-COMb6ICf.mjs";import{REMOTE_ELIGIBLE_KEYS as f,injectRemoteFlags as p,isRemoteEnvEnabled as I,materializeRemoteWranglerConfig as W,planRemoteBindings as d,resolveRemoteEnabled as x}from"../packem_shared/REMOTE_ELIGIBLE_KEYS-DKlqkz1w.mjs";import{WORKERS_CACHE_MIN_DATE as C,isCacheEnabled as A}from"../packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{WRANGLER_FILES as L,findWranglerFile as T,readWranglerJsonc as b}from"../packem_shared/WRANGLER_FILES-UNW-xY5u.mjs";import{collectWranglerSecretVariables as S,scanWranglerVariablesForSecrets as B}from"../packem_shared/collectWranglerSecretVariables-WNirpc4n.mjs";import{wranglerToAlchemy as v}from"../packem_shared/wranglerToAlchemy-CX9nCwtu.mjs";import{REQUIRED_COMPATIBILITY_DATE as M,REQUIRED_FLAG as O,validateWrangler as V,validateWranglerConfig as h,validateWranglerProject as U,withTailConsumer as j}from"../packem_shared/REQUIRED_COMPATIBILITY_DATE-BM4qXyjS.mjs";export{o as BINDING_MANIFEST_VERSION,n as CLOUDFLARE_DRIVER,f as REMOTE_ELIGIBLE_KEYS,M as REQUIRED_COMPATIBILITY_DATE,O as REQUIRED_FLAG,C as WORKERS_CACHE_MIN_DATE,L as WRANGLER_FILES,a as buildBindingManifest,i as collectExportGaps,S as collectWranglerSecretVariables,T as findWranglerFile,p as injectRemoteFlags,A as isCacheEnabled,I as isRemoteEnvEnabled,W as materializeRemoteWranglerConfig,d as planRemoteBindings,b as readWranglerJsonc,E as reconcileWranglerBindings,c as reconcileWranglerCompatibilityDate,R as reconcileWranglerCrons,x as resolveRemoteEnabled,B as scanWranglerVariablesForSecrets,V as validateWrangler,h as validateWranglerConfig,U as validateWranglerProject,j as withTailConsumer,v as wranglerToAlchemy};
|
package/dist/index.d.mts
CHANGED
|
@@ -323,25 +323,35 @@ interface ClaimDevServerStateResult {
|
|
|
323
323
|
declare const claimDevServerState: (projectRoot: string, state: DevServerState, options?: {
|
|
324
324
|
supersedePid?: number;
|
|
325
325
|
}) => ClaimDevServerStateResult;
|
|
326
|
-
/**
|
|
327
|
-
* The `.dev.vars` line grammar — one owner, shared by every reader/writer of the
|
|
328
|
-
* file so the format can't drift between packages. `@lunora/cli`'s `env`
|
|
329
|
-
* command (parse/serialize) and `@lunora/config`'s scaffolder (comment-
|
|
330
|
-
* preserving rewrite) do different *transforms*, but they agree on these
|
|
331
|
-
* primitives: the filename, what a `KEY` looks like, how lines split, and how
|
|
332
|
-
* quotes strip.
|
|
333
|
-
*/
|
|
334
326
|
/** The conventional filename for local Cloudflare dev secrets (gitignored). */
|
|
335
327
|
declare const DEV_VARS_FILE: string;
|
|
336
328
|
/** Its committed, secret-free counterpart that scaffolding reads from. */
|
|
337
329
|
declare const DEV_VARS_EXAMPLE_FILE: string;
|
|
338
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* A bare `KEY` identifier accepted on the **write** path — `lunora env set`,
|
|
332
|
+
* `env unset`, `env generate`, and {@link upsertDevVariableLine}'s line
|
|
333
|
+
* targeting. Deliberately stricter than what the reader accepts: dotenv keys
|
|
334
|
+
* are `[\w.-]+`, but a key we *write* stays a conventional env-var name so it
|
|
335
|
+
* needs no quoting and round-trips through every consumer. Never use this to
|
|
336
|
+
* decide whether a line in an existing file counts — that is the reader's job.
|
|
337
|
+
*/
|
|
339
338
|
declare const DEV_VARS_KEY_PATTERN: RegExp;
|
|
340
339
|
/**
|
|
341
|
-
* Parse `.dev.vars` content into its `{ key, value }` entries, in file order
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
340
|
+
* Parse `.dev.vars` content into its `{ key, value }` entries, in file order.
|
|
341
|
+
*
|
|
342
|
+
* Delegates to dotenv's own `parse()` — the literal function `wrangler dev` /
|
|
343
|
+
* `@cloudflare/vite-plugin` run over this file before handing the variables to
|
|
344
|
+
* the worker. Using the library rather than a compatible reimplementation is
|
|
345
|
+
* the point: every line the worker sees, Lunora reads identically, including
|
|
346
|
+
* `export `-prefixed lines, dotted/dashed keys, `KEY: value` separators,
|
|
347
|
+
* quote stripping (single/double/backtick), `\n`/`\r` expansion inside double
|
|
348
|
+
* quotes, `#` comments ending unquoted values, and multi-line quoted values.
|
|
349
|
+
* Duplicate keys resolve last-wins, at the key's first position — dotenv
|
|
350
|
+
* returns an object, so a repeated key overwrites in place.
|
|
351
|
+
*
|
|
352
|
+
* The canonical read of the whole file: every reader of `.dev.vars` (and of
|
|
353
|
+
* `.dev.vars.example`) goes through here or through {@link
|
|
354
|
+
* parseDevVariableLine} below, so the format cannot drift between packages.
|
|
345
355
|
*/
|
|
346
356
|
declare const parseDevVariableEntries: (content: string) => {
|
|
347
357
|
key: string;
|
|
@@ -368,16 +378,18 @@ declare const escapeRegExp: (value: string) => string;
|
|
|
368
378
|
* `deploy`'s minted-secret disclosure) reject newline/`"`/`\` up front so the
|
|
369
379
|
* verbatim quote is safe.
|
|
370
380
|
*
|
|
371
|
-
* Duplicate
|
|
372
|
-
* path
|
|
373
|
-
*
|
|
374
|
-
* read time.
|
|
375
|
-
* `.replace()` does) left that later, untouched duplicate still winning at read
|
|
376
|
-
* time — a `set` that silently didn't take effect. The first matching line is
|
|
377
|
-
* replaced in place (preserving its position in the file); every later
|
|
378
|
-
* duplicate is dropped entirely (including its own trailing newline).
|
|
381
|
+
* Duplicate lines for the key are collapsed down to exactly one. The shared
|
|
382
|
+
* read path is last-wins — dotenv overwrites the key as it walks the file — so
|
|
383
|
+
* replacing only the first match would leave a later, untouched duplicate
|
|
384
|
+
* still winning at read time, i.e. a `set` that silently didn't take effect.
|
|
379
385
|
*/
|
|
380
386
|
declare const upsertDevVariableLine: (content: string, key: string, value: string) => string;
|
|
387
|
+
/**
|
|
388
|
+
* Surgically remove every `.dev.vars` line defining `key` (and its own line
|
|
389
|
+
* terminator), preserving all other lines, comments, and blanks verbatim.
|
|
390
|
+
* Backs `lunora env unset`.
|
|
391
|
+
*/
|
|
392
|
+
declare const removeDevVariableLine: (content: string, key: string) => string;
|
|
381
393
|
/** The default deploy target — today's behavior for every project. */
|
|
382
394
|
declare const DEFAULT_DEPLOY_TARGET = "cloudflare";
|
|
383
395
|
/** The ids a caller may select, for error messages and `--target` help text. */
|
|
@@ -1046,4 +1058,4 @@ declare const badgeWidth: (_spec: BadgeSpec) => number;
|
|
|
1046
1058
|
declare const paintBadge: (spec: BadgeSpec) => string;
|
|
1047
1059
|
/** Dim continuation text (a step's chosen answer, shown under the question). */
|
|
1048
1060
|
declare const paintAnswer: (text: string) => string;
|
|
1049
|
-
export { ACCENT, AGENT_MODE_ENV, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectLintTools, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, escapeRegExp, fillDevSecrets, formatLunoraEvent, generateSecretValue, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, secretsForPackages, streamContainerLogs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
|
1061
|
+
export { ACCENT, AGENT_MODE_ENV, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectLintTools, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, escapeRegExp, fillDevSecrets, formatLunoraEvent, generateSecretValue, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, secretsForPackages, streamContainerLogs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
package/dist/index.d.ts
CHANGED
|
@@ -323,25 +323,35 @@ interface ClaimDevServerStateResult {
|
|
|
323
323
|
declare const claimDevServerState: (projectRoot: string, state: DevServerState, options?: {
|
|
324
324
|
supersedePid?: number;
|
|
325
325
|
}) => ClaimDevServerStateResult;
|
|
326
|
-
/**
|
|
327
|
-
* The `.dev.vars` line grammar — one owner, shared by every reader/writer of the
|
|
328
|
-
* file so the format can't drift between packages. `@lunora/cli`'s `env`
|
|
329
|
-
* command (parse/serialize) and `@lunora/config`'s scaffolder (comment-
|
|
330
|
-
* preserving rewrite) do different *transforms*, but they agree on these
|
|
331
|
-
* primitives: the filename, what a `KEY` looks like, how lines split, and how
|
|
332
|
-
* quotes strip.
|
|
333
|
-
*/
|
|
334
326
|
/** The conventional filename for local Cloudflare dev secrets (gitignored). */
|
|
335
327
|
declare const DEV_VARS_FILE: string;
|
|
336
328
|
/** Its committed, secret-free counterpart that scaffolding reads from. */
|
|
337
329
|
declare const DEV_VARS_EXAMPLE_FILE: string;
|
|
338
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* A bare `KEY` identifier accepted on the **write** path — `lunora env set`,
|
|
332
|
+
* `env unset`, `env generate`, and {@link upsertDevVariableLine}'s line
|
|
333
|
+
* targeting. Deliberately stricter than what the reader accepts: dotenv keys
|
|
334
|
+
* are `[\w.-]+`, but a key we *write* stays a conventional env-var name so it
|
|
335
|
+
* needs no quoting and round-trips through every consumer. Never use this to
|
|
336
|
+
* decide whether a line in an existing file counts — that is the reader's job.
|
|
337
|
+
*/
|
|
339
338
|
declare const DEV_VARS_KEY_PATTERN: RegExp;
|
|
340
339
|
/**
|
|
341
|
-
* Parse `.dev.vars` content into its `{ key, value }` entries, in file order
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
340
|
+
* Parse `.dev.vars` content into its `{ key, value }` entries, in file order.
|
|
341
|
+
*
|
|
342
|
+
* Delegates to dotenv's own `parse()` — the literal function `wrangler dev` /
|
|
343
|
+
* `@cloudflare/vite-plugin` run over this file before handing the variables to
|
|
344
|
+
* the worker. Using the library rather than a compatible reimplementation is
|
|
345
|
+
* the point: every line the worker sees, Lunora reads identically, including
|
|
346
|
+
* `export `-prefixed lines, dotted/dashed keys, `KEY: value` separators,
|
|
347
|
+
* quote stripping (single/double/backtick), `\n`/`\r` expansion inside double
|
|
348
|
+
* quotes, `#` comments ending unquoted values, and multi-line quoted values.
|
|
349
|
+
* Duplicate keys resolve last-wins, at the key's first position — dotenv
|
|
350
|
+
* returns an object, so a repeated key overwrites in place.
|
|
351
|
+
*
|
|
352
|
+
* The canonical read of the whole file: every reader of `.dev.vars` (and of
|
|
353
|
+
* `.dev.vars.example`) goes through here or through {@link
|
|
354
|
+
* parseDevVariableLine} below, so the format cannot drift between packages.
|
|
345
355
|
*/
|
|
346
356
|
declare const parseDevVariableEntries: (content: string) => {
|
|
347
357
|
key: string;
|
|
@@ -368,16 +378,18 @@ declare const escapeRegExp: (value: string) => string;
|
|
|
368
378
|
* `deploy`'s minted-secret disclosure) reject newline/`"`/`\` up front so the
|
|
369
379
|
* verbatim quote is safe.
|
|
370
380
|
*
|
|
371
|
-
* Duplicate
|
|
372
|
-
* path
|
|
373
|
-
*
|
|
374
|
-
* read time.
|
|
375
|
-
* `.replace()` does) left that later, untouched duplicate still winning at read
|
|
376
|
-
* time — a `set` that silently didn't take effect. The first matching line is
|
|
377
|
-
* replaced in place (preserving its position in the file); every later
|
|
378
|
-
* duplicate is dropped entirely (including its own trailing newline).
|
|
381
|
+
* Duplicate lines for the key are collapsed down to exactly one. The shared
|
|
382
|
+
* read path is last-wins — dotenv overwrites the key as it walks the file — so
|
|
383
|
+
* replacing only the first match would leave a later, untouched duplicate
|
|
384
|
+
* still winning at read time, i.e. a `set` that silently didn't take effect.
|
|
379
385
|
*/
|
|
380
386
|
declare const upsertDevVariableLine: (content: string, key: string, value: string) => string;
|
|
387
|
+
/**
|
|
388
|
+
* Surgically remove every `.dev.vars` line defining `key` (and its own line
|
|
389
|
+
* terminator), preserving all other lines, comments, and blanks verbatim.
|
|
390
|
+
* Backs `lunora env unset`.
|
|
391
|
+
*/
|
|
392
|
+
declare const removeDevVariableLine: (content: string, key: string) => string;
|
|
381
393
|
/** The default deploy target — today's behavior for every project. */
|
|
382
394
|
declare const DEFAULT_DEPLOY_TARGET = "cloudflare";
|
|
383
395
|
/** The ids a caller may select, for error messages and `--target` help text. */
|
|
@@ -1046,4 +1058,4 @@ declare const badgeWidth: (_spec: BadgeSpec) => number;
|
|
|
1046
1058
|
declare const paintBadge: (spec: BadgeSpec) => string;
|
|
1047
1059
|
/** Dim continuation text (a step's chosen answer, shown under the question). */
|
|
1048
1060
|
declare const paintAnswer: (text: string) => string;
|
|
1049
|
-
export { ACCENT, AGENT_MODE_ENV, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectLintTools, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, escapeRegExp, fillDevSecrets, formatLunoraEvent, generateSecretValue, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, secretsForPackages, streamContainerLogs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
|
1061
|
+
export { ACCENT, AGENT_MODE_ENV, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentDetection, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, type ClaimDevServerStateResult, type ContainerLogLevel, type ContainerLogLine, type ContainerLogSource, type ContainerLogStreamHandle, type ContainerLogStreamOptions, DEFAULT_DEPLOY_TARGET, DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DeployDriver, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DevServerMode, type DevServerState, type DiscoverAgentInfoResult, type DiscoverContainerInfoResult, type DiscoverWorkflowInfoResult, type DockerLike, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_IGNORED_PATHS, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LintIgnoreOutcome, type LintIgnoreStatus, type LintTool, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, ROOT_SKILL_NAME, type RemotePreference, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, applyAdditiveEdit, applyLintIgnores, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, claimDevServerState, classifyEdit, clearDevServerState, createConfirm, deployTargetIds, detectAgentRules, detectAiAgent, detectFramework, detectLintTools, discoverAgentInfo, discoverContainerInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, escapeRegExp, fillDevSecrets, formatLunoraEvent, generateSecretValue, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isProcessAlive, isRecordedProcessCurrent, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, promptMultiSelect, promptSelect, promptText, promptYesNo, readDevServerState, readLinkedProject, readLiveDevServerState, readProjectDependencyNames, readProjectRemotePreference, readProjectTarget, removeDevVariableLine, requiredSecrets, resolveDeployDriver, resolveProjectTarget, resolveTargetOrThrow, secretsForPackages, streamContainerLogs, updateDevServerState, upsertDevVariableLine, writeDevServerState, writeDevVariablesFileAtomically, writeLinkedProject };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AGENT_MODE_ENV as t,detectAiAgent as o}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-CTdCSfYM.mjs";import{AGENT_RULES_DIR as _,AGENT_RULES_HINT as p,AGENT_RULES_HINT_ENV as s,LUNORA_SKILL_NAMES as l,ROOT_SKILL_NAME as c,claimAgentRulesHint as n,detectAgentRules as
|
|
1
|
+
import{AGENT_MODE_ENV as t,detectAiAgent as o}from"./packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs";import{discoverAgentInfo as E}from"./packem_shared/discoverAgentInfo-CTdCSfYM.mjs";import{AGENT_RULES_DIR as _,AGENT_RULES_HINT as p,AGENT_RULES_HINT_ENV as s,LUNORA_SKILL_NAMES as l,ROOT_SKILL_NAME as c,claimAgentRulesHint as n,detectAgentRules as m}from"./packem_shared/AGENT_RULES_DIR-3-Sx1gHU.mjs";import{discoverContainerInfo as d}from"./packem_shared/discoverContainerInfo-EhZtEBQs.mjs";import{streamContainerLogs as S}from"./packem_shared/streamContainerLogs-0nko1qpv.mjs";import{detectFramework as f,readProjectDependencyNames as N}from"./packem_shared/detectFramework-DOn4PtpP.mjs";import{DEV_DAEMON_ENV as T,DEV_HANDOFF_ENV as R,DEV_LOG_FILE as I,DEV_LOG_FILE_ENV as V,DEV_STATE_DIR as x,DEV_STATE_FILE as P,claimDevServerState as g,clearDevServerState as O,isProcessAlive as F,isRecordedProcessCurrent as u,readDevServerState as G,readLiveDevServerState as U,updateDevServerState as C,writeDevServerState as b}from"./packem_shared/DEV_DAEMON_ENV-e1mJUd1-.mjs";import{DEV_VARS_EXAMPLE_FILE as M,DEV_VARS_FILE as B,DEV_VARS_KEY_PATTERN as k,escapeRegExp as w,parseDevVariableEntries as K,removeDevVariableLine as j,upsertDevVariableLine as H}from"./packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{DEFAULT_DEPLOY_TARGET as Y,deployTargetIds as W,resolveDeployDriver as J}from"./packem_shared/DEFAULT_DEPLOY_TARGET-dS2wApDX.mjs";import{inferLunoraBindings as X,packageNamesFromBindings as z}from"./packem_shared/inferLunoraBindings-KST9XCEe.mjs";import{LINKED_PROJECT_DIR as Z,LINKED_PROJECT_FILE as $,readLinkedProject as ee,writeLinkedProject as re}from"./packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs";import{LUNORA_IGNORED_PATHS as oe,applyLintIgnores as ae,detectLintTools as Ee}from"./packem_shared/LUNORA_IGNORED_PATHS-BGbVUqw_.mjs";import{LUNORA_EVENT_SOURCE as _e,formatLunoraEvent as pe}from"./packem_shared/LUNORA_EVENT_SOURCE-DYdcDU9G.mjs";import{default as le}from"./packem_shared/LunoraReporter-f277GLNT.mjs";import{PACKAGE_SECRETS_REGISTRY as ne,secretsForPackages as me}from"./packem_shared/PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";import{LUNORA_CONFIG_FILE as de,interpretRemote as De,readProjectRemotePreference as Se,readProjectTarget as Le,resolveProjectTarget as fe,resolveTargetOrThrow as Ne}from"./packem_shared/LUNORA_CONFIG_FILE-GOH3iIA4.mjs";import{createConfirm as Te,isInteractive as Re,promptMultiSelect as Ie,promptSelect as Ve,promptText as xe,promptYesNo as Pe}from"./packem_shared/createConfirm-D5mKTMHj.mjs";import{buildPackageSecretsBlock as Oe,ensureDevVariables as Fe,ensureDevVarsExample as ue,fillDevSecrets as Ge,generateSecretValue as Ue,isMintableSecretKey as Ce,isPlaceholderValue as be,planDevSecretsFill as ye,planDevVariablesAugment as Me,planDevVariablesScaffold as Be,requiredSecrets as ke,writeDevVariablesFileAtomically as we}from"./packem_shared/buildPackageSecretsBlock-J7bP1P-6.mjs";import{applyAdditiveEdit as je,classifyEdit as He}from"./packem_shared/applyAdditiveEdit-DPhNZsf2.mjs";import{parseSchema as Ye}from"./packem_shared/parseSchema-B4nFDPzZ.mjs";import{classifyPolicyEdit as Je,scaffoldPolicyFile as qe,wireRlsIntoProcedure as Xe}from"./packem_shared/classifyPolicyEdit-BfSiVpv-.mjs";import{discoverSchemaInfo as Qe}from"./packem_shared/discoverSchemaInfo-Bg2CUZXG.mjs";import{ACCENT as $e,BADGES as er,BADGE_COLUMN_WIDTH as rr,LUNA_ART as tr,LUNA_BUNNY as or,LUNA_NAME as ar,LUNA_SIGNOFF as Er,STEP_BADGE_NAMES as ir,badgeLead as _r,badgeWidth as pr,padBadge as sr,paintAnswer as lr,paintBadge as cr}from"./packem_shared/ACCENT-CotPTfv7.mjs";import{discoverWorkflowInfo as mr}from"./packem_shared/discoverWorkflowInfo-BsPvlo6O.mjs";export{$e as ACCENT,t as AGENT_MODE_ENV,_ as AGENT_RULES_DIR,p as AGENT_RULES_HINT,s as AGENT_RULES_HINT_ENV,er as BADGES,rr as BADGE_COLUMN_WIDTH,Y as DEFAULT_DEPLOY_TARGET,T as DEV_DAEMON_ENV,R as DEV_HANDOFF_ENV,I as DEV_LOG_FILE,V as DEV_LOG_FILE_ENV,x as DEV_STATE_DIR,P as DEV_STATE_FILE,M as DEV_VARS_EXAMPLE_FILE,B as DEV_VARS_FILE,k as DEV_VARS_KEY_PATTERN,Z as LINKED_PROJECT_DIR,$ as LINKED_PROJECT_FILE,tr as LUNA_ART,or as LUNA_BUNNY,ar as LUNA_NAME,Er as LUNA_SIGNOFF,de as LUNORA_CONFIG_FILE,_e as LUNORA_EVENT_SOURCE,oe as LUNORA_IGNORED_PATHS,l as LUNORA_SKILL_NAMES,le as LunoraReporter,ne as PACKAGE_SECRETS_REGISTRY,c as ROOT_SKILL_NAME,ir as STEP_BADGE_NAMES,je as applyAdditiveEdit,ae as applyLintIgnores,_r as badgeLead,pr as badgeWidth,Oe as buildPackageSecretsBlock,n as claimAgentRulesHint,g as claimDevServerState,He as classifyEdit,Je as classifyPolicyEdit,O as clearDevServerState,Te as createConfirm,W as deployTargetIds,m as detectAgentRules,o as detectAiAgent,f as detectFramework,Ee as detectLintTools,E as discoverAgentInfo,d as discoverContainerInfo,Qe as discoverSchemaInfo,mr as discoverWorkflowInfo,Fe as ensureDevVariables,ue as ensureDevVarsExample,w as escapeRegExp,Ge as fillDevSecrets,pe as formatLunoraEvent,Ue as generateSecretValue,X as inferLunoraBindings,De as interpretRemote,Re as isInteractive,Ce as isMintableSecretKey,be as isPlaceholderValue,F as isProcessAlive,u as isRecordedProcessCurrent,z as packageNamesFromBindings,sr as padBadge,lr as paintAnswer,cr as paintBadge,K as parseDevVariableEntries,Ye as parseSchema,ye as planDevSecretsFill,Me as planDevVariablesAugment,Be as planDevVariablesScaffold,Ie as promptMultiSelect,Ve as promptSelect,xe as promptText,Pe as promptYesNo,G as readDevServerState,ee as readLinkedProject,U as readLiveDevServerState,N as readProjectDependencyNames,Se as readProjectRemotePreference,Le as readProjectTarget,j as removeDevVariableLine,ke as requiredSecrets,J as resolveDeployDriver,fe as resolveProjectTarget,Ne as resolveTargetOrThrow,qe as scaffoldPolicyFile,me as secretsForPackages,S as streamContainerLogs,C as updateDevServerState,H as upsertDevVariableLine,Xe as wireRlsIntoProcedure,b as writeDevServerState,we as writeDevVariablesFileAtomically,re as writeLinkedProject};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./inferLunoraBindings-KST9XCEe.mjs";import{C as a}from"./cloudflare-driver-DkF7wRh1.mjs";import"./collectExportGaps-DHLZ7ulq.mjs";import"./reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import"./reconcileWranglerCrons-COMb6ICf.mjs";export{a as default};
|
package/dist/packem_shared/{DEFAULT_DEPLOY_TARGET-RDWcFKBe.mjs → DEFAULT_DEPLOY_TARGET-dS2wApDX.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,C as c}from"./cloudflare-driver-
|
|
1
|
+
import{t,C as c}from"./cloudflare-driver-DkF7wRh1.mjs";import{inferLunoraBindings as a}from"./inferLunoraBindings-KST9XCEe.mjs";const l=[{detect:e=>e.containers.length>0,warning:"containers have no Node equivalent in @lunora/platform-node — ctx.containers will be unavailable"}],d={id:"node",infer:async e=>t(await a({projectRoot:e.projectRoot}),e.crons??[]),name:"Node",provision:async e=>{let r;try{r=t(await a({projectRoot:e.projectRoot}),e.crons??[])}catch(n){const s=n instanceof Error?n.message:String(n);return{added:[],changed:!1,warnings:[`requirement inference skipped: ${s}`]}}const o=l.filter(n=>n.detect(r)).map(n=>n.warning);return r.crons.length>0&&o.push(`${String(r.crons.length)} cron expression(s) will be registered at runtime via SchedulerHost.cron rather than written to a config file`),{added:[],changed:!1,warnings:o}}},p="cloudflare",i={cloudflare:c,node:d},g=()=>Object.keys(i).toSorted((e,r)=>e.localeCompare(r)),h=(e=p)=>{const r=i[e];if(r===void 0)throw new Error(`unknown deploy target "${e}" — available targets: ${g().join(", ")}`);return r};export{p as DEFAULT_DEPLOY_TARGET,g as deployTargetIds,h as resolveDeployDriver};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{parse as p}from"dotenv";const A=".dev.vars",D=".dev.vars.example",$=/^[A-Za-z_]\w*$/u,d=/\r?\n/u,u=e=>Object.entries(p(e)).map(([t,n])=>({key:t,value:n})),V=e=>u(e)[0],L=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`),_=/(\r?\n)/u,E=(e,t,n)=>{const r=e.split(_),s=[];let a=!1;for(let i=0;i<r.length;i+=2){const o=r[i]??"",c=r[i+1]??"";if(V(o)?.key!==t){s.push(o,c);continue}const l=!a;a=!0,n!==void 0&&l&&s.push(n,c)}return{content:s.join(""),matched:a}},m=(e,t,n)=>{const r=`${t}="${n}"`,s=E(e,t,r);return s.matched?s.content:e===""?`${r}
|
|
2
|
+
`:e.endsWith(`
|
|
3
|
+
`)?`${e}${r}
|
|
4
|
+
`:`${e}
|
|
5
|
+
${r}
|
|
6
|
+
`},R=(e,t)=>E(e,t,void 0).content;export{D as DEV_VARS_EXAMPLE_FILE,A as DEV_VARS_FILE,$ as DEV_VARS_KEY_PATTERN,d as DEV_VARS_NEWLINE,L as escapeRegExp,u as parseDevVariableEntries,V as parseDevVariableLine,R as removeDevVariableLine,m as upsertDevVariableLine};
|
package/dist/packem_shared/{LUNORA_CONFIG_FILE-CBV3C1Hl.mjs → LUNORA_CONFIG_FILE-GOH3iIA4.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as c,readFileSync as i}from"node:fs";import{readProjectTarget as s}from"@lunora/codegen";import{parse as a}from"jsonc-parser";import{DEFAULT_DEPLOY_TARGET as f,resolveDeployDriver as m}from"./DEFAULT_DEPLOY_TARGET-
|
|
1
|
+
import{existsSync as c,readFileSync as i}from"node:fs";import{readProjectTarget as s}from"@lunora/codegen";import{parse as a}from"jsonc-parser";import{DEFAULT_DEPLOY_TARGET as f,resolveDeployDriver as m}from"./DEFAULT_DEPLOY_TARGET-dS2wApDX.mjs";import{join as p}from"node:path";const l="lunora.json",d=r=>{if(typeof r=="boolean")return r;if(r!==null&&typeof r=="object")return!0},u=r=>{const e=p(r,l);if(!c(e))return;let t;try{t=i(e,"utf8")}catch{return}const n=[],o=a(t,n,{allowTrailingComma:!0});if(!(n.length>0||o===null||typeof o!="object"))return o},h=r=>d(u(r)?.remote),g=r=>s(r),j=(r,e)=>e??g(r)??f,D=(r,e)=>{const t=j(r,e);return m(t),t};export{l as LUNORA_CONFIG_FILE,d as interpretRemote,h as readProjectRemotePreference,g as readProjectTarget,j as resolveProjectTarget,D as resolveTargetOrThrow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as f,readFileSync as M}from"node:fs";import{dirname as A,join as p}from"node:path";import{WORKER_ENTRY_FALLBACKS as O}from"./inferLunoraBindings-CEE39hXz.mjs";import{discoverSchemaInfo as D}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{isCacheEnabled as x,WORKERS_CACHE_MIN_DATE as _}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as N,readWranglerJsonc as I}from"./WRANGLER_FILES-UNW-xY5u.mjs";const v="2026-04-07",Ie="web_socket_auto_reply_to_close",$=/^\d{4}-\d{2}-\d{2}$/,E=["d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],S=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],R=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const t=e.env?.[s];if(t===void 0){const c=Object.keys(e.env??{}).toSorted((r,l)=>r.localeCompare(l)),d=c.length>0?` (declared: ${c.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${d}`,merged:e,unverifiedKeys:[]}}const n={...e},a=Object.keys(t).filter(c=>c!=="env");for(const c of a)S.includes(c)&&(n[c]=t[c]);for(const c of E)n[c]=t[c];const i=new Set([...E,...S]),o=a.filter(c=>!i.has(c)).map(String);return{merged:n,unverifiedKeys:o}},C=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],a=new Set(n.filter(Boolean).map(i=>i?.index_name));for(const i of s)a.has(i)||t.push(`schema declares vector index "${i}"; wrangler "vectorize" must include a binding with index_name "${i}"`)},L=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),T={disk_mb:2e4,memory_mib:12288,vcpu:4},B=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){L.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[c,d]of Object.entries(T)){const r=n[c];r!==void 0&&(typeof r!="number"||r<=0||r>d)&&t.push(`${s} custom instance_type ${c} must be a positive number ≤ ${String(d)} (got ${String(r)})`)}const{disk_mb:a,memory_mib:i,vcpu:o}=n;if(typeof o=="number"&&typeof i=="number"&&i<o*3072&&t.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(i)} MiB for ${String(o)} vCPU)`),typeof i=="number"&&typeof a=="number"){const c=Math.floor(i/1024*2e3);a>c&&t.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(c)} MB for ${String(i)} MiB memory; got ${String(a)} MB)`)}},W=(e,s,t)=>{const{boundClasses:n,errors:a,nonSqliteClasses:i,sqliteClasses:o,warnings:c}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&a.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||a.push(`${s} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),o.has(e.class_name)||a.push(i.has(e.class_name)?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),B(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&c.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},m=e=>typeof e=="string"&&e.length>0,b=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],h=e=>Array.isArray(e)?e.filter(s=>m(s)):[],q=e=>{const s=new Set;for(const t of b(e)){for(const n of h(t.new_classes))s.add(n);for(const n of h(t.new_sqlite_classes))s.add(n);for(const n of b(t.renamed_classes))m(n.from)&&m(n.to)&&(s.delete(n.from),s.add(n.to));for(const n of h(t.deleted_classes))s.delete(n)}return s},U=(e,s)=>{const t=q(e.migrations);for(const n of b(e.durable_objects?.bindings))n.script_name===void 0&&m(n.class_name)&&!t.has(n.class_name)&&s.push(`durable_objects.bindings declares class "${n.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${n.class_name}"] (or "new_classes" for a non-SQLite-backed class), or run \`lunora dev\` to auto-reconcile wrangler.jsonc`)},F=(e,s,t)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const a=new Set(b(e.durable_objects?.bindings).map(d=>d.class_name)),i=e.migrations??[],o=new Set(i.flatMap(d=>[...d?.new_sqlite_classes??[]])),c=new Set(i.flatMap(d=>[...d?.new_classes??[]]));for(const[d,r]of n.entries())W(r,`containers[${String(d)}]`,{boundClasses:a,errors:s,nonSqliteClasses:c,sqliteClasses:o,warnings:t});e.observability?.enabled!==!0&&t.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},y=e=>e,g=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[a,i]of y(e).entries()){const o=`${s}[${String(a)}]`;if(!i||typeof i!="object"){n.push(t.objectMessage(o));continue}for(const c of t.fields)m(i[c.field])||n.push(c.message(o))}}},P={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},K={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},G={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},Y=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}g(e.queues.producers,"queues.producers",K,s),g(e.queues.consumers,"queues.consumers",G,s)}},H={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:s=>`${s} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},Q=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],V=(e,s,t,n)=>{const a=e[s.key];if(a!==void 0){if(!Array.isArray(a)){t.push(s.arrayMessage);return}for(const[i,o]of y(a).entries()){const c=`${s.key}[${String(i)}]`;if(!o||typeof o!="object"||!m(o.binding)){t.push(s.bindingMessage(c));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(r=>m(o[r]))||n.push(s.hintMessage(c,o.binding))}}},z=[{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'}],X=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||Array.isArray(n)||!m(n.binding))&&t.push(s.message)},J=[{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`}],Z=(e,s)=>{const{d1_databases:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,a]of y(t).entries()){const i=`d1_databases[${String(n)}]`;if(!a||typeof a!="object"){s.push(`${i} must be a { binding, database_id | database_name } object`);continue}m(a.binding)||s.push(`${i} must have a non-empty "binding" naming the D1 binding`),!m(a.database_id)&&!m(a.database_name)&&s.push(`${i} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},ee=(e,s,t)=>{const n=e.send_email;if(n===void 0)return;if(!Array.isArray(n)){s.push("send_email must be an array of { name, destination_address? } entries");return}const a=n;for(const[i,o]of a.entries())(!o||typeof o!="object"||typeof o.name!="string"||o.name.length===0)&&t.push(`send_email[${String(i)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},se=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},ne=(e,s)=>{const{placement:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}t.mode!==void 0&&t.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},te=(e,s)=>{const{observability:t}=e;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n=(a,i)=>{a!==void 0&&(typeof a!="number"||Number.isNaN(a)||a<0||a>1)&&s.push(`${i} must be a number in [0, 1] (the fraction of requests sampled)`)};n(t.head_sampling_rate,"observability.head_sampling_rate"),t.logs!==void 0&&(typeof t.logs!="object"||Array.isArray(t.logs)?s.push("observability.logs must be an object"):n(t.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},ae=(e,s)=>{const{cache:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push('cache must be an object (e.g. { "enabled": true })');return}t.enabled!==void 0&&typeof t.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},ie=(e,s)=>{const{exports:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push("exports must be an object keyed by entrypoint name");return}for(const[n,a]of Object.entries(t)){if(typeof a!="object"||a===null){s.push(`exports["${n}"] must be an object`);continue}a.type!==void 0&&typeof a.type!="string"&&s.push(`exports["${n}"].type must be a string`),a.cache!==void 0&&(typeof a.cache!="object"||a.cache===null||Array.isArray(a.cache)?s.push(`exports["${n}"].cache must be an object`):a.cache.enabled!==void 0&&typeof a.cache.enabled!="boolean"&&s.push(`exports["${n}"].cache.enabled must be a boolean`))}}},oe=(e,s)=>{const{assets:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),t.html_handling!==void 0&&typeof t.html_handling!="string"&&s.push("assets.html_handling must be a string"),t.not_found_handling!==void 0&&typeof t.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},re=(e,s)=>{const t=e.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const n=t;for(const[a,i]of n.entries())(!i||typeof i!="object"||typeof i.service!="string"||i.service.length===0)&&s.push(`tail_consumers[${String(a)}] must have a non-empty "service" naming the consumer Worker`)},Ce=(e,s)=>{const t=e.tail_consumers??[];return t.some(a=>!!a&&a?.service===s.service&&a?.environment===s.environment)?e:{...e,tail_consumers:[...t,s]}},ce=new Set(["1","enabled","on","true","yes"]),de=(e,s)=>{const{vars:t}=e;if(!t||typeof t!="object")return;const n=t.LUNORA_ALLOWED_ORIGINS,a=t.LUNORA_CORS_ALLOW_CREDENTIALS,i=typeof n=="string"&&n.split(",").some(c=>c.trim()==="*"),o=typeof a=="string"&&ce.has(a.trim().toLowerCase());i&&o&&s.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},le=(e,s,t)=>{const{error:n,merged:a,unverifiedKeys:i}=R(e,s);return n!==void 0?{error:n,wrangler:a}:(i.length>0&&t.push(`env.${String(s)} overrides ${i.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${i.length===1?"it":"them"} by hand for "${String(s)}".`),{wrangler:a})},k=(e,s,t)=>{const n=[],a=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:a};const{error:i,wrangler:o}=le(e,t,a);if(i!==void 0)return n.push(i),{errors:n,valid:!1,warnings:a};b(o.durable_objects?.bindings).find(l=>l.name==="SHARD"&&l.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually'),U(o,n);const r=o.compatibility_date??"";r&&!$.test(r)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${r}")`):r<v&&n.push(`compatibility_date must be >= "${v}" (got "${r||"<missing>"}")`),x(o)&&$.test(r)&&r<_&&n.push(`cache.enabled requires compatibility_date >= "${_}" (got "${r||"<missing>"}")`),s?.hasGlobalTable&&(b(o.d1_databases).find(w=>w.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),Z(o,n),C(o,s?.vectorIndexNames??[],n),re(o,n),F(o,n,a),g(o.workflows,"workflows",P,n),Y(o,n),g(o.secrets_store_secrets,"secrets_store_secrets",H,n);for(const l of Q)V(o,l,n,a);for(const l of J)g(o[l.key],l.key,l,n);for(const l of z)X(o,l,n);return ee(o,n,a),se(o,n),ne(o,n),te(o,n),oe(o,n),ae(o,n),ie(o,n),de(o,n),{errors:n,valid:n.length===0,warnings:a}},Le=k,me=(e,s,t)=>{const n=[];for(const a of e){const i=a?.image;typeof i!="string"||!(i.startsWith("./")||i.startsWith("../")||i.startsWith("/")||i.includes("Dockerfile"))||f(i.startsWith("/")?i:p(s,i))||n.push(`containers image "${i}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`)}return n},ue=(e,s,t)=>{if(typeof e=="string"&&e.length>0){const n=p(A(t),e);return f(n)?n:void 0}return O.map(n=>p(s,n)).find(n=>f(n))},be=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,ge=e=>e.replaceAll(be,s=>s.replaceAll(/[^\n]/gu," ")),fe=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,pe=/\bexport\b/gu,he=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,ye=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,_e=/^\s*(?:const|let|var)\s*\{/u,ve=/^[$A-Z_a-z][\w$]*/u,$e=/^type\b/u,Ee=/\s+/u,Se=e=>{const s=[];for(const t of e.split(",")){const n=t.trim().split(Ee).filter(Boolean),a=n.at(-1);a!==void 0&&n[0]!=="type"&&s.push(a)}return s},je=e=>{const s=[];for(const t of e.split(",")){const n=t.includes(":")?t.slice(t.indexOf(":")+1):t,a=ve.exec(n.trim());a&&s.push(a[0])}return s},j=e=>{const s=e.indexOf("{"),t=e.indexOf("}",s);return s===-1||t===-1?void 0:e.slice(s+1,t)},Ae=e=>{const s=e.trimStart();if($e.test(s))return[];if(s.startsWith("{")){const n=j(s);return n===void 0?[]:Se(n)}if(_e.test(e)){const n=j(e);return n===void 0?[]:je(n)}const t=ye.exec(e.replace(he,""));return t?.groups?.name===void 0?[]:[t.groups.name]},Re=e=>{const s=new Set;for(const t of e.matchAll(pe))for(const n of Ae(e.slice(t.index+6)))s.add(n);return s},ke=(e,s,t)=>{const n=ue(e.main,s,t);if(n===void 0)return[];let a;try{a=M(n,"utf8")}catch{return[]}const i=ge(a);if(fe.test(i))return[];const o=[];for(const r of b(e.durable_objects?.bindings))typeof r.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"durable_objects.bindings"});for(const r of e.workflows??[])typeof r?.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"workflows"});const c=Re(i);return o.filter(r=>!c.has(r.className)).map(r=>`${r.label} declares class "${r.className}" but the worker entry (${n}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${r.className} } from "…";\` to the entry.`)},Te=e=>{const s=e.schemaDir??"lunora",t=N(e.projectRoot);if(!t){const u=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:n}=I(t);if(n===void 0){const u=`failed to parse ${t} as JSONC.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:t}}const{error:a,merged:i}=R(n,e.environment);if(a!==void 0)return{problems:[a],report:{errors:[a],valid:!1,warnings:[]},wranglerPath:t};const{error:o,info:c}=D(e.projectRoot,s),d=k(n,c,e.environment);o!==void 0&&d.warnings.push(`schema parse failed in ${s}/schema.ts: ${o}`);const r=A(t);d.errors.push(...me(i.containers??[],r,t)),d.warnings.push(...ke(i,e.projectRoot,t));const l=i.assets?.directory;if(typeof l=="string"&&l.length>0){const u=l.startsWith("/")?l:p(r,l);f(u)||d.warnings.push(`assets.directory "${l}" does not exist yet — it is created by the client build; run the build before deploy`)}return d.valid=d.errors.length===0,{problems:d.errors,report:d,wranglerPath:t}};export{v as REQUIRED_COMPATIBILITY_DATE,Ie as REQUIRED_FLAG,Le as validateWrangler,k as validateWranglerConfig,Te as validateWranglerProject,Ce as withTailConsumer};
|
|
1
|
+
import{existsSync as f,readFileSync as M}from"node:fs";import{dirname as A,join as p}from"node:path";import{WORKER_ENTRY_FALLBACKS as O}from"./inferLunoraBindings-KST9XCEe.mjs";import{discoverSchemaInfo as D}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{isCacheEnabled as x,WORKERS_CACHE_MIN_DATE as _}from"./WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs";import{findWranglerFile as N,readWranglerJsonc as I}from"./WRANGLER_FILES-UNW-xY5u.mjs";const v="2026-04-07",Ie="web_socket_auto_reply_to_close",$=/^\d{4}-\d{2}-\d{2}$/,E=["d1_databases","durable_objects","kv_namespaces","queues","r2_buckets","secrets_store_secrets","services","tail_consumers","vars","vectorize","workflows"],S=["assets","compatibility_date","exports","logpush","main","migrations","observability","placement"],R=(e,s)=>{if(s===void 0)return{merged:e,unverifiedKeys:[]};const t=e.env?.[s];if(t===void 0){const c=Object.keys(e.env??{}).toSorted((r,l)=>r.localeCompare(l)),d=c.length>0?` (declared: ${c.join(", ")}).`:" (no environments are declared).";return{error:`--env "${s}" names no environment declared in wrangler.jsonc's "env" block${d}`,merged:e,unverifiedKeys:[]}}const n={...e},a=Object.keys(t).filter(c=>c!=="env");for(const c of a)S.includes(c)&&(n[c]=t[c]);for(const c of E)n[c]=t[c];const i=new Set([...E,...S]),o=a.filter(c=>!i.has(c)).map(String);return{merged:n,unverifiedKeys:o}},C=(e,s,t)=>{if(s.length===0)return;const n=e.vectorize??[],a=new Set(n.filter(Boolean).map(i=>i?.index_name));for(const i of s)a.has(i)||t.push(`schema declares vector index "${i}"; wrangler "vectorize" must include a binding with index_name "${i}"`)},L=new Set(["basic","dev","lite","standard","standard-1","standard-2","standard-3","standard-4"]),T={disk_mb:2e4,memory_mib:12288,vcpu:4},B=(e,s,t)=>{const n=e.instance_type;if(n===void 0)return;if(typeof n=="string"){L.has(n)||t.push(`${s} has unknown instance_type "${n}" — expected lite, basic, standard-1..4, or a custom { vcpu, memory_mib, disk_mb } object`);return}for(const[c,d]of Object.entries(T)){const r=n[c];r!==void 0&&(typeof r!="number"||r<=0||r>d)&&t.push(`${s} custom instance_type ${c} must be a positive number ≤ ${String(d)} (got ${String(r)})`)}const{disk_mb:a,memory_mib:i,vcpu:o}=n;if(typeof o=="number"&&typeof i=="number"&&i<o*3072&&t.push(`${s} custom instance_type needs ≥ 3 GiB (3072 MiB) memory per vCPU (got ${String(i)} MiB for ${String(o)} vCPU)`),typeof i=="number"&&typeof a=="number"){const c=Math.floor(i/1024*2e3);a>c&&t.push(`${s} custom instance_type allows ≤ 2 GB disk per GiB memory (≤ ${String(c)} MB for ${String(i)} MiB memory; got ${String(a)} MB)`)}},W=(e,s,t)=>{const{boundClasses:n,errors:a,nonSqliteClasses:i,sqliteClasses:o,warnings:c}=t;if(!e||typeof e!="object"||typeof e.class_name!="string"||e.class_name.length===0){a.push(`${s} must have a non-empty "class_name" naming its container-enabled Durable Object class`);return}(typeof e.image!="string"||e.image.length===0)&&a.push(`${s} ("${e.class_name}") must have an "image" — a Dockerfile path or a registry reference`),n.has(e.class_name)||a.push(`${s} class "${e.class_name}" has no matching durable_objects binding — run \`lunora dev\` to auto-reconcile wrangler.jsonc, or add { "name": "...", "class_name": "${e.class_name}" }`),o.has(e.class_name)||a.push(i.has(e.class_name)?`${s} class "${e.class_name}" is registered via "new_classes" but containers require SQLite-backed DOs — move it to "new_sqlite_classes"`:`${s} class "${e.class_name}" is missing from migrations — add a migration entry with "new_sqlite_classes": ["${e.class_name}"]`),B(e,`${s} ("${e.class_name}")`,a),e.max_instances===void 0&&c.push(`${s} ("${e.class_name}") declares no max_instances — set a cap so a traffic spike can't fan out unbounded container spend`)},m=e=>typeof e=="string"&&e.length>0,b=e=>Array.isArray(e)?e.filter(s=>s!==null&&typeof s=="object"):[],h=e=>Array.isArray(e)?e.filter(s=>m(s)):[],q=e=>{const s=new Set;for(const t of b(e)){for(const n of h(t.new_classes))s.add(n);for(const n of h(t.new_sqlite_classes))s.add(n);for(const n of b(t.renamed_classes))m(n.from)&&m(n.to)&&(s.delete(n.from),s.add(n.to));for(const n of h(t.deleted_classes))s.delete(n)}return s},U=(e,s)=>{const t=q(e.migrations);for(const n of b(e.durable_objects?.bindings))n.script_name===void 0&&m(n.class_name)&&!t.has(n.class_name)&&s.push(`durable_objects.bindings declares class "${n.class_name}" but it is missing from migrations — add a migration entry with "new_sqlite_classes": ["${n.class_name}"] (or "new_classes" for a non-SQLite-backed class), or run \`lunora dev\` to auto-reconcile wrangler.jsonc`)},F=(e,s,t)=>{if(e.containers===void 0)return;if(!Array.isArray(e.containers)){s.push("containers must be an array of { class_name, image, ... } entries");return}const n=e.containers;if(n.length===0)return;const a=new Set(b(e.durable_objects?.bindings).map(d=>d.class_name)),i=e.migrations??[],o=new Set(i.flatMap(d=>[...d?.new_sqlite_classes??[]])),c=new Set(i.flatMap(d=>[...d?.new_classes??[]]));for(const[d,r]of n.entries())W(r,`containers[${String(d)}]`,{boundClasses:a,errors:s,nonSqliteClasses:c,sqliteClasses:o,warnings:t});e.observability?.enabled!==!0&&t.push('containers are configured but observability is not enabled — container logs will not be captured (add { "observability": { "enabled": true } })')},y=e=>e,g=(e,s,t,n)=>{if(e!==void 0){if(!Array.isArray(e)){n.push(t.arrayMessage);return}for(const[a,i]of y(e).entries()){const o=`${s}[${String(a)}]`;if(!i||typeof i!="object"){n.push(t.objectMessage(o));continue}for(const c of t.fields)m(i[c.field])||n.push(c.message(o))}}},P={arrayMessage:"workflows must be an array of { name, binding, class_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Workflow binding (e.g. WORKFLOW_ORDER_PIPELINE)`},{field:"class_name",message:e=>`${e} must have a non-empty "class_name" naming the exported WorkflowEntrypoint class`},{field:"name",message:e=>`${e} must have a non-empty "name" naming the deployed workflow`}],objectMessage:e=>`${e} must be a { name, binding, class_name } object`},K={arrayMessage:"queues.producers must be an array of { binding, queue } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the Queue producer (e.g. QUEUE_EMAIL)`},{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the deployed queue`}],objectMessage:e=>`${e} must be a { binding, queue } object`},G={arrayMessage:"queues.consumers must be an array of { queue } entries",fields:[{field:"queue",message:e=>`${e} must have a non-empty "queue" naming the consumed queue`}],objectMessage:e=>`${e} must be a { queue } object`},Y=(e,s)=>{if(e.queues!==void 0){if(typeof e.queues!="object"||Array.isArray(e.queues)){s.push("queues must be a { producers, consumers } object");return}g(e.queues.producers,"queues.producers",K,s),g(e.queues.consumers,"queues.consumers",G,s)}},H={arrayMessage:"secrets_store_secrets must be an array of { binding, store_id, secret_name } entries",fields:["binding","store_id","secret_name"].map(e=>({field:e,message:s=>`${s} must have a non-empty "${e}"`})),objectMessage:e=>`${e} must be a { binding, store_id, secret_name } object`},Q=[{arrayMessage:"kv_namespaces must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the KV namespace binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler kv namespace create\` and set the namespace id, or the binding can't resolve`,key:"kv_namespaces"},{arrayMessage:"flagship must be an array of { binding, app_id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Flagship binding`,hintField:"app_id",hintMessage:(e,s)=>`${e} ("${s}") has no "app_id" — create a Flagship app and set its id, or the binding can't resolve`,key:"flagship"},{arrayMessage:"hyperdrive must be an array of { binding, id } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Hyperdrive binding`,hintField:"id",hintMessage:(e,s)=>`${e} ("${s}") has no "id" — run \`wrangler hyperdrive create\` and set the id, or the binding can't connect`,key:"hyperdrive"},{arrayMessage:"pipelines must be an array of { binding, stream } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Pipelines binding`,hintField:["stream","pipeline"],hintMessage:(e,s)=>`${e} ("${s}") has no "stream" — run \`wrangler pipelines create <name>\` and set the stream name, or the binding can't resolve`,key:"pipelines"},{arrayMessage:"analytics_engine_datasets must be an array of { binding, dataset } entries",bindingMessage:e=>`${e} must have a non-empty "binding" naming the Analytics Engine binding`,hintField:"dataset",hintMessage:(e,s)=>`${e} ("${s}") has no "dataset" — it defaults to the binding name; set it explicitly to avoid drift`,key:"analytics_engine_datasets"}],V=(e,s,t,n)=>{const a=e[s.key];if(a!==void 0){if(!Array.isArray(a)){t.push(s.arrayMessage);return}for(const[i,o]of y(a).entries()){const c=`${s.key}[${String(i)}]`;if(!o||typeof o!="object"||!m(o.binding)){t.push(s.bindingMessage(c));continue}(typeof s.hintField=="string"?[s.hintField]:s.hintField).some(r=>m(o[r]))||n.push(s.hintMessage(c,o.binding))}}},z=[{key:"browser",message:'browser must be an object with a non-empty "binding" (e.g. { "binding": "BROWSER" })'},{key:"images",message:'images must be an object with a non-empty "binding" (e.g. { "binding": "IMAGES" })'}],X=(e,s,t)=>{const n=e[s.key];n!==void 0&&(typeof n!="object"||Array.isArray(n)||!m(n.binding))&&t.push(s.message)},J=[{arrayMessage:"services must be an array of { binding, service, entrypoint? } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the service binding`},{field:"service",message:e=>`${e} must have a non-empty "service" naming the target Worker`}],key:"services",objectMessage:e=>`${e} must be a { binding, service, entrypoint? } object`},{arrayMessage:"dispatch_namespaces must be an array of { binding, namespace } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"namespace",message:e=>`${e} must have a non-empty "namespace" naming the dispatch namespace`}],key:"dispatch_namespaces",objectMessage:e=>`${e} must be a { binding, namespace } object`},{arrayMessage:"mtls_certificates must be an array of { binding, certificate_id } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding"`},{field:"certificate_id",message:e=>`${e} must have a non-empty "certificate_id" (upload via \`wrangler mtls-certificate upload\`)`}],key:"mtls_certificates",objectMessage:e=>`${e} must be a { binding, certificate_id } object`},{arrayMessage:"r2_buckets must be an array of { binding, bucket_name } entries",fields:[{field:"binding",message:e=>`${e} must have a non-empty "binding" naming the R2 bucket binding`},{field:"bucket_name",message:e=>`${e} must have a non-empty "bucket_name" naming the deployed bucket`}],key:"r2_buckets",objectMessage:e=>`${e} must be a { binding, bucket_name } object`}],Z=(e,s)=>{const{d1_databases:t}=e;if(t!==void 0){if(!Array.isArray(t)){s.push("d1_databases must be an array of { binding, database_id | database_name } entries");return}for(const[n,a]of y(t).entries()){const i=`d1_databases[${String(n)}]`;if(!a||typeof a!="object"){s.push(`${i} must be a { binding, database_id | database_name } object`);continue}m(a.binding)||s.push(`${i} must have a non-empty "binding" naming the D1 binding`),!m(a.database_id)&&!m(a.database_name)&&s.push(`${i} must have a "database_id" or a "database_name" — run \`wrangler d1 create\` and set one, or the binding can't resolve`)}}},ee=(e,s,t)=>{const n=e.send_email;if(n===void 0)return;if(!Array.isArray(n)){s.push("send_email must be an array of { name, destination_address? } entries");return}const a=n;for(const[i,o]of a.entries())(!o||typeof o!="object"||typeof o.name!="string"||o.name.length===0)&&t.push(`send_email[${String(i)}] has no non-empty "name" naming the send-email binding — set one before deploying`)},se=(e,s)=>{e.logpush!==void 0&&typeof e.logpush!="boolean"&&s.push('logpush must be a boolean (set "logpush": true to enable Cloudflare Logpush)')},ne=(e,s)=>{const{placement:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('placement must be an object (e.g. { "mode": "smart" })');return}t.mode!==void 0&&t.mode!=="smart"&&s.push('placement.mode must be "smart" (the only supported Smart Placement mode)')}},te=(e,s)=>{const{observability:t}=e;if(t===void 0)return;if(typeof t!="object"||Array.isArray(t)){s.push('observability must be an object (e.g. { "enabled": true, "head_sampling_rate": 1 })');return}const n=(a,i)=>{a!==void 0&&(typeof a!="number"||Number.isNaN(a)||a<0||a>1)&&s.push(`${i} must be a number in [0, 1] (the fraction of requests sampled)`)};n(t.head_sampling_rate,"observability.head_sampling_rate"),t.logs!==void 0&&(typeof t.logs!="object"||Array.isArray(t.logs)?s.push("observability.logs must be an object"):n(t.logs.head_sampling_rate,"observability.logs.head_sampling_rate"))},ae=(e,s)=>{const{cache:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push('cache must be an object (e.g. { "enabled": true })');return}t.enabled!==void 0&&typeof t.enabled!="boolean"&&s.push("cache.enabled must be a boolean (true or false)")}},ie=(e,s)=>{const{exports:t}=e;if(t!==void 0){if(typeof t!="object"||t===null||Array.isArray(t)){s.push("exports must be an object keyed by entrypoint name");return}for(const[n,a]of Object.entries(t)){if(typeof a!="object"||a===null){s.push(`exports["${n}"] must be an object`);continue}a.type!==void 0&&typeof a.type!="string"&&s.push(`exports["${n}"].type must be a string`),a.cache!==void 0&&(typeof a.cache!="object"||a.cache===null||Array.isArray(a.cache)?s.push(`exports["${n}"].cache must be an object`):a.cache.enabled!==void 0&&typeof a.cache.enabled!="boolean"&&s.push(`exports["${n}"].cache.enabled must be a boolean`))}}},oe=(e,s)=>{const{assets:t}=e;if(t!==void 0){if(typeof t!="object"||Array.isArray(t)){s.push('assets must be an object (e.g. { "directory": "./dist/client", "binding": "ASSETS" })');return}(typeof t.directory!="string"||t.directory.length===0)&&s.push('assets must declare a non-empty "directory" pointing at the built client output (e.g. "./dist/client")'),t.binding!==void 0&&(typeof t.binding!="string"||t.binding.length===0)&&s.push('assets.binding must be a non-empty string (e.g. "ASSETS")'),t.html_handling!==void 0&&typeof t.html_handling!="string"&&s.push("assets.html_handling must be a string"),t.not_found_handling!==void 0&&typeof t.not_found_handling!="string"&&s.push("assets.not_found_handling must be a string")}},re=(e,s)=>{const t=e.tail_consumers;if(t===void 0)return;if(!Array.isArray(t)){s.push("tail_consumers must be an array of { service, environment? } entries");return}const n=t;for(const[a,i]of n.entries())(!i||typeof i!="object"||typeof i.service!="string"||i.service.length===0)&&s.push(`tail_consumers[${String(a)}] must have a non-empty "service" naming the consumer Worker`)},Ce=(e,s)=>{const t=e.tail_consumers??[];return t.some(a=>!!a&&a?.service===s.service&&a?.environment===s.environment)?e:{...e,tail_consumers:[...t,s]}},ce=new Set(["1","enabled","on","true","yes"]),de=(e,s)=>{const{vars:t}=e;if(!t||typeof t!="object")return;const n=t.LUNORA_ALLOWED_ORIGINS,a=t.LUNORA_CORS_ALLOW_CREDENTIALS,i=typeof n=="string"&&n.split(",").some(c=>c.trim()==="*"),o=typeof a=="string"&&ce.has(a.trim().toLowerCase());i&&o&&s.push('vars.LUNORA_ALLOWED_ORIGINS includes a "*" wildcard while vars.LUNORA_CORS_ALLOW_CREDENTIALS is on — browsers reject this combination and it defeats the allowlist; name explicit origins or drop credentials')},le=(e,s,t)=>{const{error:n,merged:a,unverifiedKeys:i}=R(e,s);return n!==void 0?{error:n,wrangler:a}:(i.length>0&&t.push(`env.${String(s)} overrides ${i.join(", ")}, which this validator doesn't have a verified inheritance rule for — validated against the TOP-LEVEL value only. Double-check ${i.length===1?"it":"them"} by hand for "${String(s)}".`),{wrangler:a})},k=(e,s,t)=>{const n=[],a=[];if(!e||typeof e!="object")return n.push("wrangler config is not a valid object"),{errors:n,valid:!1,warnings:a};const{error:i,wrangler:o}=le(e,t,a);if(i!==void 0)return n.push(i),{errors:n,valid:!1,warnings:a};b(o.durable_objects?.bindings).find(l=>l.name==="SHARD"&&l.class_name==="ShardDO")||n.push('durable_objects.bindings must include { "name": "SHARD", "class_name": "ShardDO" } — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually'),U(o,n);const r=o.compatibility_date??"";r&&!$.test(r)?n.push(`compatibility_date must be in YYYY-MM-DD format (got "${r}")`):r<v&&n.push(`compatibility_date must be >= "${v}" (got "${r||"<missing>"}")`),x(o)&&$.test(r)&&r<_&&n.push(`cache.enabled requires compatibility_date >= "${_}" (got "${r||"<missing>"}")`),s?.hasGlobalTable&&(b(o.d1_databases).find(w=>w.binding==="DB")||n.push('schema declares .global() tables; d1_databases must include a binding named "DB" — run `lunora dev` to auto-reconcile wrangler.jsonc, or add the binding manually')),Z(o,n),C(o,s?.vectorIndexNames??[],n),re(o,n),F(o,n,a),g(o.workflows,"workflows",P,n),Y(o,n),g(o.secrets_store_secrets,"secrets_store_secrets",H,n);for(const l of Q)V(o,l,n,a);for(const l of J)g(o[l.key],l.key,l,n);for(const l of z)X(o,l,n);return ee(o,n,a),se(o,n),ne(o,n),te(o,n),oe(o,n),ae(o,n),ie(o,n),de(o,n),{errors:n,valid:n.length===0,warnings:a}},Le=k,me=(e,s,t)=>{const n=[];for(const a of e){const i=a?.image;typeof i!="string"||!(i.startsWith("./")||i.startsWith("../")||i.startsWith("/")||i.includes("Dockerfile"))||f(i.startsWith("/")?i:p(s,i))||n.push(`containers image "${i}" does not exist (resolved relative to ${t}); create the Dockerfile or point image at a registry reference`)}return n},ue=(e,s,t)=>{if(typeof e=="string"&&e.length>0){const n=p(A(t),e);return f(n)?n:void 0}return O.map(n=>p(s,n)).find(n=>f(n))},be=/\/\/[^\n]*|\/\*.*?\*\/|"[^"\n]*"|'[^'\n]*'|`[^`]*`/gsu,ge=e=>e.replaceAll(be,s=>s.replaceAll(/[^\n]/gu," ")),fe=/\bexport\s*\*\s*(?:as\s+\w+\s*)?from\b/u,pe=/\bexport\b/gu,he=/^\s*(?:(?:abstract|async|declare|default)\s+)*/u,ye=/^(?:class|const|function|let|var)\s+(?<name>[$A-Z_a-z][\w$]*)/u,_e=/^\s*(?:const|let|var)\s*\{/u,ve=/^[$A-Z_a-z][\w$]*/u,$e=/^type\b/u,Ee=/\s+/u,Se=e=>{const s=[];for(const t of e.split(",")){const n=t.trim().split(Ee).filter(Boolean),a=n.at(-1);a!==void 0&&n[0]!=="type"&&s.push(a)}return s},je=e=>{const s=[];for(const t of e.split(",")){const n=t.includes(":")?t.slice(t.indexOf(":")+1):t,a=ve.exec(n.trim());a&&s.push(a[0])}return s},j=e=>{const s=e.indexOf("{"),t=e.indexOf("}",s);return s===-1||t===-1?void 0:e.slice(s+1,t)},Ae=e=>{const s=e.trimStart();if($e.test(s))return[];if(s.startsWith("{")){const n=j(s);return n===void 0?[]:Se(n)}if(_e.test(e)){const n=j(e);return n===void 0?[]:je(n)}const t=ye.exec(e.replace(he,""));return t?.groups?.name===void 0?[]:[t.groups.name]},Re=e=>{const s=new Set;for(const t of e.matchAll(pe))for(const n of Ae(e.slice(t.index+6)))s.add(n);return s},ke=(e,s,t)=>{const n=ue(e.main,s,t);if(n===void 0)return[];let a;try{a=M(n,"utf8")}catch{return[]}const i=ge(a);if(fe.test(i))return[];const o=[];for(const r of b(e.durable_objects?.bindings))typeof r.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"durable_objects.bindings"});for(const r of e.workflows??[])typeof r?.class_name=="string"&&r.class_name.length>0&&r.script_name===void 0&&o.push({className:r.class_name,label:"workflows"});const c=Re(i);return o.filter(r=>!c.has(r.className)).map(r=>`${r.label} declares class "${r.className}" but the worker entry (${n}) does not export it — wrangler refuses to bundle a Worker whose Durable Object classes are not exported. Add \`export { ${r.className} } from "…";\` to the entry.`)},Te=e=>{const s=e.schemaDir??"lunora",t=N(e.projectRoot);if(!t){const u=`wrangler.jsonc not found in ${e.projectRoot}; create one declaring at least the SHARD durable object binding.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:void 0}}const{parsed:n}=I(t);if(n===void 0){const u=`failed to parse ${t} as JSONC.`;return{problems:[u],report:{errors:[u],valid:!1,warnings:[]},wranglerPath:t}}const{error:a,merged:i}=R(n,e.environment);if(a!==void 0)return{problems:[a],report:{errors:[a],valid:!1,warnings:[]},wranglerPath:t};const{error:o,info:c}=D(e.projectRoot,s),d=k(n,c,e.environment);o!==void 0&&d.warnings.push(`schema parse failed in ${s}/schema.ts: ${o}`);const r=A(t);d.errors.push(...me(i.containers??[],r,t)),d.warnings.push(...ke(i,e.projectRoot,t));const l=i.assets?.directory;if(typeof l=="string"&&l.length>0){const u=l.startsWith("/")?l:p(r,l);f(u)||d.warnings.push(`assets.directory "${l}" does not exist yet — it is created by the client build; run the build before deploy`)}return d.valid=d.errors.length===0,{problems:d.errors,report:d,wranglerPath:t}};export{v as REQUIRED_COMPATIBILITY_DATE,Ie as REQUIRED_FLAG,Le as validateWrangler,k as validateWranglerConfig,Te as validateWranglerProject,Ce as withTailConsumer};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{randomBytes as R}from"node:crypto";import{existsSync as y,readFileSync as f,writeFileSync as V,renameSync as A,rmSync as h,statSync as F}from"node:fs";import{join as g}from"node:path";import{LunoraError as L}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as m,parseDevVariableLine as x,parseDevVariableEntries as S,DEV_VARS_NEWLINE as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{CORE_SECRETS as K,PACKAGE_SECRETS_REGISTRY as T,secretsForPackages as j}from"./PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";const M=/(?:key|password|secret|token)$/iu,D=e=>M.test(e),P=e=>[...K,...j(e)],E=32,I=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],z=/[.*+?^${}()|[\]\\]/gu,N=/[a-z0-9]$/u,W=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:I.some(r=>{const s=r.replaceAll(z,String.raw`\$&`),o=N.test(r)?`(^|[^a-z0-9])${s}([^a-z0-9]|$)`:`(^|[^a-z0-9])${s}`;return new RegExp(o,"u").test(t)})},p=e=>R(e).toString("hex"),B=new Set([...K,...Object.values(T).flat()].filter(e=>D(e.key)&&e.placeholderValue.startsWith("<")).map(e=>e.key)),G=e=>D(e)&&!B.has(e),H=(e,t,r)=>G(e)&&W(t)?r(E):void 0,ie=(e=p)=>e(E),b=(e,t,r)=>e.split(C).map(s=>{const n=x(s),o=n?H(n.key,n.value,t):void 0;return!n||o===void 0?s:(r.push(n.key),`${n.key}="${o}"`)}),O=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:b(e.exampleContent,e.randomHex??p,t).join(`
|
|
2
|
+
`),generatedKeys:t,status:"generate"}},U=e=>e.includes('"')||e.includes("\\")?"":e.replaceAll("\r",String.raw`\r`).replaceAll(`
|
|
3
|
+
`,String.raw`\n`),k=e=>{const t=e.randomHex??p,r=new Set(S(e.existingContent).map(d=>d.key)),s=[],n=[],o=[];for(const d of e.exampleContent.split(C)){const i=x(d);if(!i||r.has(i.key))continue;const a=H(i.key,i.value,t);o.push(i.key),a===void 0?s.push(`${i.key}="${U(i.value)}"`):(n.push(i.key),s.push(`${i.key}="${a}"`))}return{additions:s,generatedKeys:n,missingKeys:o}},w=e=>e.length>0?` (generated ${e.join(", ")})`:"",$=(e,t,r={})=>{const s=`${e}.tmp-${String(process.pid)}`;try{V(s,t,{encoding:"utf8",...r}),A(s,e)}catch(n){throw h(s,{force:!0}),n}},ae=(e,t)=>{$(e,t,{mode:384})},v=5,_=e=>{try{const t=F(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},X=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,Y=(e,t)=>{for(let r=0;r<v;r+=1){const s=_(e),n=f(e,"utf8"),o=t(n);if(o.length===0)return[];const d=n.length>0&&!n.endsWith(`
|
|
4
|
+
`)?`
|
|
5
|
+
`:"",i=`${n}${d}${o.join(`
|
|
6
|
+
`)}
|
|
7
|
+
`,a=`${e}.tmp-${String(process.pid)}-${R(6).toString("hex")}`;try{V(a,i,{encoding:"utf8",mode:384});const c=_(e);if(!X(s,c)){h(a,{force:!0});continue}return A(a,e),o}catch(c){throw h(a,{force:!0}),c}}throw new L("INTERNAL",`Failed to append to ${e} after ${String(v)} attempts — a concurrent writer kept winning the race.`)},ce=async e=>{const t=g(e.cwd,u),r=g(e.cwd,m);if(!y(r))return{addedKeys:[],generatedKeys:[],status:"no-example"};const s=f(r,"utf8");if(!y(t)){const l=O({devVarsExists:!1,exampleContent:s,randomHex:e.randomHex});return l.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${u} found. Generate it from ${m} (secrets auto-filled)?`)?y(t)?{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:($(t,l.content,{flag:"wx",mode:384}),e.info(`Created ${u}${w(l.generatedKeys)}.`),{addedKeys:[],generatedKeys:l.generatedKeys,status:"generated"}):(e.info(`Skipped — copy ${m} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const n=k({existingContent:f(t,"utf8"),exampleContent:s,randomHex:e.randomHex});if(n.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const o=n.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${u} is missing ${String(n.missingKeys.length)} key(s) from ${m} (${o}). Add them?`)))return e.info(`Skipped — add ${o} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const a=Y(t,l=>k({existingContent:l,exampleContent:s,randomHex:e.randomHex}).additions).map(l=>x(l)?.key).filter(l=>l!==void 0);if(a.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const c=n.generatedKeys.filter(l=>a.includes(l));return e.info(`Updated ${u} — added ${a.join(", ")}${w(c)}.`),{addedKeys:a,generatedKeys:c,status:"augmented"}},q=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
|
|
8
|
+
`),J=(e,t)=>{const r=P(e).filter(s=>!t.has(s.key));return r.length===0?"":r.map(s=>q(s)).join(`
|
|
9
|
+
|
|
10
|
+
`)},de=(e,t)=>{const r=g(e,m),s=y(r)?f(r,"utf8"):"",n=new Set(S(s).map(i=>i.key)),o=J(t,n);if(o==="")return[];const d=s.length>0&&!s.endsWith(`
|
|
11
|
+
`)?`
|
|
12
|
+
`:"";return $(r,`${s}${d}
|
|
13
|
+
${o}
|
|
14
|
+
`),P(t).filter(i=>!n.has(i.key)).map(i=>i.key)},Q=e=>{const t=e.randomHex??p,r=[],s=b(e.existingContent,t,r),n=new Set(S(e.existingContent).map(c=>c.key)),o=[],d=[];for(const c of K)n.has(c.key)||(o.push(c.key),d.push(`# ${c.description}`,`${c.key}="${t(E)}"`));const i=s.join(`
|
|
15
|
+
`);if(d.length===0)return{addedKeys:o,content:i,filledKeys:r};const a=i===""||i.endsWith(`
|
|
16
|
+
`)?"":`
|
|
17
|
+
`;return{addedKeys:o,content:`${i}${a}${d.join(`
|
|
18
|
+
`)}
|
|
19
|
+
`,filledKeys:r}},le=e=>{const t=g(e.cwd,u),r=y(t),s=r?f(t,"utf8"):"",n=Q({existingContent:s,randomHex:e.randomHex});if(n.filledKeys.length===0&&n.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};$(t,n.content,{mode:384});const o=[...n.filledKeys,...n.addedKeys];return e.info?.(`Generated ${String(o.length)} dev secret(s) in ${u}: ${o.join(", ")}`),{addedKeys:n.addedKeys,filledKeys:n.filledKeys,status:r?"filled":"created"}};export{J as buildPackageSecretsBlock,ce as ensureDevVariables,de as ensureDevVarsExample,le as fillDevSecrets,ie as generateSecretValue,G as isMintableSecretKey,W as isPlaceholderValue,Q as planDevSecretsFill,k as planDevVariablesAugment,O as planDevVariablesScaffold,P as requiredSecrets,ae as writeDevVariablesFileAtomically};
|
package/dist/packem_shared/{cloudflare-driver-CvMyH1Ih.mjs → cloudflare-driver-DkF7wRh1.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{inferLunoraBindings as c}from"./inferLunoraBindings-
|
|
1
|
+
import{inferLunoraBindings as c}from"./inferLunoraBindings-KST9XCEe.mjs";import{reconcileWranglerBindings as p}from"./collectExportGaps-DHLZ7ulq.mjs";import{reconcileWranglerCompatibilityDate as g}from"./reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import{reconcileWranglerCrons as m}from"./reconcileWranglerCrons-COMb6ICf.mjs";const l=(n,r)=>{const e=n.durableObjects.map(o=>({className:o.className,exported:!0,name:o.binding})),a=n.queues.map(o=>({name:o.name})),i=n.workflows.map(o=>({exported:o.exported,name:o.exportName}));return{containers:n.containers.map(o=>({exported:o.exported,name:o.exportName})),crons:[...r],globalDatabase:n.needsD1,keyValueStore:n.usesKv,objectStorage:n.usesStorage,queues:a,shardNamespaces:e,signals:[...n.signals],workflows:i}},s=(n,r)=>{try{const e=r();return{added:e.added??[],changed:e.changed,configPath:e.wranglerPath,warnings:e.warnings??[]}}catch(e){const a=e instanceof Error?e.message:String(e);return{added:[],changed:!1,warnings:[`${n} skipped: ${a}`]}}},f={deploy:n=>{const r=n.preview===!0?["versions","upload"]:["deploy"];return n.entry!==void 0&&r.push(n.entry),n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),n.dryRun===!0&&r.push("--dry-run"),n.outDir!==void 0&&r.push("--outdir",n.outDir,"--metafile"),{args:r,tool:"wrangler"}},dev:n=>{const r=["dev"];return n.configPath!==void 0&&r.push("--config",n.configPath),n.environment!==void 0&&r.push("--env",n.environment),r.push(...n.extraArgs??[]),{args:r,tool:"wrangler"}},secretList:n=>{const r=["secret","list","--format","json"];return n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},secretPut:n=>{const r=["secret","put",n.key??""];return n.environment!==void 0&&r.push("--env",n.environment),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}},tail:n=>{const r=["tail"];return n.worker!==void 0&&r.push(n.worker),n.environment!==void 0&&r.push("--env",n.environment),n.format!==void 0&&r.push("--format",n.format),n.status!==void 0&&r.push("--status",n.status),n.search!==void 0&&r.push("--search",n.search),n.temporary===!0&&r.push("--temporary"),{args:r,tool:"wrangler"}}},w={id:"cloudflare",infer:async n=>{const r=await c({projectRoot:n.projectRoot});return l(r,n.crons??[])},name:"Cloudflare",provision:async n=>{const r=n.crons??[],e=await(async()=>{try{const o=await c({projectRoot:n.projectRoot});return s("binding inference",()=>p(n.projectRoot,o))}catch(o){const d=o instanceof Error?o.message:String(o);return{added:[],changed:!1,warnings:[`binding inference skipped: ${d}`]}}})(),a=s("compatibility date sync",()=>g(n.projectRoot)),i=s("cron trigger sync",()=>m(n.projectRoot,r)),t=[e,{...a,added:a.changed?["compatibility_date"]:[]},{...i,added:i.changed?[`${String(r.length)} cron trigger(s)`]:[]}];return{added:t.flatMap(o=>o.added),changed:t.some(o=>o.changed),configPath:t.find(o=>o.configPath!==void 0)?.configPath,warnings:t.flatMap(o=>o.warnings)}},toolchain:f};export{w as C,l as t};
|
package/dist/packem_shared/{collectExportGaps-B5eIg8p8.mjs → collectExportGaps-DHLZ7ulq.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeFileSync as k,readFileSync as N}from"node:fs";import{join as D}from"node:path";import{containerBuildTag as B}from"@lunora/container";import{DEV_VARS_FILE as A,parseDevVariableEntries as C}from"./DEV_VARS_EXAMPLE_FILE-DxtfY0DW.mjs";import{a as b}from"./jsonc-edit-BZgQIdAH.mjs";import{findWranglerFile as O,readWranglerJsonc as P}from"./WRANGLER_FILES-UNW-xY5u.mjs";const S="<replace-with-d1-create-id>",R=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,a,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:c})=>({className:i,exportName:c,kind:s,module:a}))),$=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[e.usesPipelines&&(n?.pipelines?.length??0)===0,"ctx.pipelines is used but no pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned."],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([o])=>o).map(([,o])=>o)},I=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),_=(e,n,s)=>s.filter(a=>!a.exported).map(a=>`${e} "${a.exportName}" is declared but ${a.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),E=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],T=()=>E.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),M=e=>{let n;try{n=N(D(e,A),"utf8")}catch{return!1}const s=new Map(C(n).map(a=>[a.key,a.value]));return E.some(({keys:a})=>a.every(o=>(s.get(o)??"")!==""))},f=(e,n,s)=>{const a=new Set(e.durableObjects.map(d=>d.className)),o=[],i=(s?.r2_buckets?.length??0)>0,c=(s?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!i&&o.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!a.has("SessionDO")&&!c&&o.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!a.has("SchedulerDO")&&o.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),o.push(..._("container","containers",e.containers),..._("workflow","workflows",e.workflows),..._("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&o.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!M(n)&&o.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${T()}.`),o.push(...I(e),...$(e,s)),o},W=e=>{const n=new Set(e.map(a=>a.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},K=(e,n,s)=>{const a=n.durable_objects?.bindings??[],o=new Set(a.map(u=>u.name)),i=s.filter(u=>!o.has(u.binding));let c=e;const d=[];if(i.length>0){const u=[...a,...i.map(p=>({class_name:p.className,name:p.binding}))];c=b(c,["durable_objects","bindings"],u),d.push(...i.map(p=>`${p.binding}/${p.className}`))}const g=n.migrations??[],l=new Set(g.flatMap(u=>[...u.new_sqlite_classes??[],...u.new_classes??[]])),h=s.map(u=>u.className).filter(u=>!l.has(u));if(h.length>0){const u=[...g,{new_sqlite_classes:h,tag:W(g)}];c=b(c,["migrations"],u)}return{added:d,text:c}},L=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const a=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:S,database_name:a}];return{added:["DB (D1)"],text:b(e,["d1_databases"],o)}},x=(e,n,s,a,o)=>{const i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:b(e,[s],{binding:a})}},Y=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},H=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},F=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:B(e.exportName),j=e=>{const n={class_name:e.className,image:F(e)};return e.image.kind==="dockerfile"&&(n.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(n.image_vars=e.buildArgs),e.instanceType!==void 0&&(n.instance_type=H(e.instanceType)),e.maxInstances!==void 0&&(n.max_instances=e.maxInstances),e.name!==void 0&&(n.name=e.name),e.rollout?.stepPercentage!==void 0&&(n.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(n.rollout_active_grace_period=e.rollout.gracePeriodSeconds),n},G=(e,n,s)=>{const a=n.containers??[],o=new Set(a.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));if(i.length===0)return{added:[],text:e};const c=b(e,["containers"],[...a,...i.map(d=>j(d))]);return{added:i.map(d=>`containers/${d.className}`),text:c}},U=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},w=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),V=(e,n,s,a=[])=>{const o=n.workflows??[],i=new Set(o.map(l=>l.class_name)),c=s.filter(l=>!i.has(l.className)),d=a.filter(l=>!i.has(l.className));if(c.length===0&&d.length===0)return{added:[],text:e};const g=b(e,["workflows"],[...o,...c.map(l=>w(l)),...d.map(l=>w(l))]);return{added:[...c.map(l=>`workflows/${l.className}`),...d.map(l=>`workflows/${l.className}`)],text:g}},z=(e,n,s)=>{const a=n.queues??{},o=a.producers??[],i=a.consumers??[],c=new Set(o.map(r=>r.binding)),d=new Set(i.map(r=>r.queue)),g=s.filter(r=>!c.has(r.bindingName)),l=s.filter(r=>!d.has(r.name));if(g.length===0&&l.length===0)return{added:[],text:e};const h=[...o,...g.map(r=>({binding:r.bindingName,queue:r.name}))],u=[...i,...l.map(r=>{const m={queue:r.name};return r.mode==="pull"&&(m.type="http_pull"),r.tuning.maxBatchSize!==void 0&&(m.max_batch_size=r.tuning.maxBatchSize),r.tuning.maxBatchTimeout!==void 0&&(m.max_batch_timeout=r.tuning.maxBatchTimeout),r.tuning.maxRetries!==void 0&&(m.max_retries=r.tuning.maxRetries),r.tuning.deadLetterQueue!==void 0&&(m.dead_letter_queue=r.tuning.deadLetterQueue),r.tuning.retryDelay!==void 0&&(m.retry_delay=r.tuning.retryDelay),m})],p=b(e,["queues"],{consumers:u,producers:h});return{added:[...g.map(r=>`queues.producers/${r.bindingName}`),...l.map(r=>`queues.consumers/${r.name}`)],text:p}},ne=(e,n,s)=>{const a=O(e),o=R(n);if(!a)return{added:[],changed:!1,exportGaps:o,reason:"wrangler.jsonc not found",warnings:f(n,e)};const{parsed:i,text:c}=P(a);if(i===void 0)return{added:[],changed:!1,exportGaps:o,reason:`failed to parse ${a} as JSONC`,warnings:f(n,e),wranglerPath:a};const d=f(n,e,i);if(s!==void 0){const t=i.env?.[s]!==void 0;d.push(t?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const g=n.containers.filter(t=>t.exported),l=n.agents.filter(t=>t.exported&&t.voice===!0&&t.voiceBindingName!==void 0&&t.voiceClassName!==void 0),h=[...n.durableObjects,...g.map(t=>({binding:t.bindingName,className:t.className})),...l.map(t=>({binding:t.voiceBindingName,className:t.voiceClassName}))],u=n.workflows.filter(t=>t.exported),p=n.agents.filter(t=>t.exported),r=[{enabled:!0,run:t=>K(t,i,h)},{enabled:n.needsD1,run:t=>L(t,i)},{enabled:n.usesAi,run:t=>x(t,i,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:t=>x(t,i,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:t=>x(t,i,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:t=>Y(t,i)},{enabled:!0,run:t=>U(t,i)},{enabled:g.length>0,run:t=>G(t,i,g)},{enabled:u.length>0||p.length>0,run:t=>V(t,i,u,p)},{enabled:n.queues.length>0,run:t=>z(t,i,n.queues)}];let m=c;const v=[];for(const t of r){if(!t.enabled)continue;const y=t.run(m);m=y.text,v.push(...y.added)}return v.includes("DB (D1)")&&d.push(`wrote a DB binding with a placeholder database_id ("${S}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),m===c?{added:[],changed:!1,exportGaps:o,reason:"bindings already in sync",warnings:d,wranglerPath:a}:(k(a,m,"utf8"),{added:v,changed:!0,exportGaps:o,warnings:d,wranglerPath:a})};export{R as collectExportGaps,ne as reconcileWranglerBindings};
|
|
1
|
+
import{writeFileSync as k,readFileSync as N}from"node:fs";import{join as D}from"node:path";import{containerBuildTag as B}from"@lunora/container";import{DEV_VARS_FILE as A,parseDevVariableEntries as C}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{a as b}from"./jsonc-edit-BZgQIdAH.mjs";import{findWranglerFile as O,readWranglerJsonc as P}from"./WRANGLER_FILES-UNW-xY5u.mjs";const S="<replace-with-d1-create-id>",R=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,a,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:c})=>({className:i,exportName:c,kind:s,module:a}))),$=(e,n)=>{const s=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(o=>o.binding===e.flagshipBinding);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0,"@lunora/bindings/kv is used but no kv_namespaces binding exists; add a kv_namespaces entry ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned."],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0,"@lunora/hyperdrive is used but no hyperdrive binding exists; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned."],[e.usesPipelines&&(n?.pipelines?.length??0)===0,"ctx.pipelines is used but no pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned."],[s,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([o])=>o).map(([,o])=>o)},I=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402Pay,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),_=(e,n,s)=>s.filter(a=>!a.exported).map(a=>`${e} "${a.exportName}" is declared but ${a.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),E=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],T=()=>E.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),M=e=>{let n;try{n=N(D(e,A),"utf8")}catch{return!1}const s=new Map(C(n).map(a=>[a.key,a.value]));return E.some(({keys:a})=>a.every(o=>(s.get(o)??"")!==""))},f=(e,n,s)=>{const a=new Set(e.durableObjects.map(d=>d.className)),o=[],i=(s?.r2_buckets?.length??0)>0,c=(s?.d1_databases?.some(d=>d.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!i&&o.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!a.has("SessionDO")&&!c&&o.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!a.has("SchedulerDO")&&o.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),o.push(..._("container","containers",e.containers),..._("workflow","workflows",e.workflows),..._("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&o.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayment&&!M(n)&&o.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${T()}.`),o.push(...I(e),...$(e,s)),o},W=e=>{const n=new Set(e.map(a=>a.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},K=(e,n,s)=>{const a=n.durable_objects?.bindings??[],o=new Set(a.map(u=>u.name)),i=s.filter(u=>!o.has(u.binding));let c=e;const d=[];if(i.length>0){const u=[...a,...i.map(p=>({class_name:p.className,name:p.binding}))];c=b(c,["durable_objects","bindings"],u),d.push(...i.map(p=>`${p.binding}/${p.className}`))}const g=n.migrations??[],l=new Set(g.flatMap(u=>[...u.new_sqlite_classes??[],...u.new_classes??[]])),h=s.map(u=>u.className).filter(u=>!l.has(u));if(h.length>0){const u=[...g,{new_sqlite_classes:h,tag:W(g)}];c=b(c,["migrations"],u)}return{added:d,text:c}},L=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const a=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:S,database_name:a}];return{added:["DB (D1)"],text:b(e,["d1_databases"],o)}},x=(e,n,s,a,o)=>{const i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:b(e,[s],{binding:a})}},Y=(e,n)=>(n.analytics_engine_datasets?.length??0)>0?{added:[],text:e}:{added:["ANALYTICS (Analytics Engine)"],text:b(e,["analytics_engine_datasets"],[{binding:"ANALYTICS",dataset:"ANALYTICS"}])},H=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},F=e=>e.image.kind==="dockerfile"?e.image.dockerfilePath:e.image.kind==="registry"?e.image.reference:B(e.exportName),j=e=>{const n={class_name:e.className,image:F(e)};return e.image.kind==="dockerfile"&&(n.image_build_context=e.image.buildContext),e.buildArgs!==void 0&&e.image.kind!=="registry"&&(n.image_vars=e.buildArgs),e.instanceType!==void 0&&(n.instance_type=H(e.instanceType)),e.maxInstances!==void 0&&(n.max_instances=e.maxInstances),e.name!==void 0&&(n.name=e.name),e.rollout?.stepPercentage!==void 0&&(n.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(n.rollout_active_grace_period=e.rollout.gracePeriodSeconds),n},G=(e,n,s)=>{const a=n.containers??[],o=new Set(a.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));if(i.length===0)return{added:[],text:e};const c=b(e,["containers"],[...a,...i.map(d=>j(d))]);return{added:i.map(d=>`containers/${d.className}`),text:c}},U=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=b(e,["observability"],{enabled:!0,head_sampling_rate:1});return{added:["observability"],text:s}},w=e=>({binding:e.bindingName,class_name:e.className,name:e.name}),V=(e,n,s,a=[])=>{const o=n.workflows??[],i=new Set(o.map(l=>l.class_name)),c=s.filter(l=>!i.has(l.className)),d=a.filter(l=>!i.has(l.className));if(c.length===0&&d.length===0)return{added:[],text:e};const g=b(e,["workflows"],[...o,...c.map(l=>w(l)),...d.map(l=>w(l))]);return{added:[...c.map(l=>`workflows/${l.className}`),...d.map(l=>`workflows/${l.className}`)],text:g}},z=(e,n,s)=>{const a=n.queues??{},o=a.producers??[],i=a.consumers??[],c=new Set(o.map(r=>r.binding)),d=new Set(i.map(r=>r.queue)),g=s.filter(r=>!c.has(r.bindingName)),l=s.filter(r=>!d.has(r.name));if(g.length===0&&l.length===0)return{added:[],text:e};const h=[...o,...g.map(r=>({binding:r.bindingName,queue:r.name}))],u=[...i,...l.map(r=>{const m={queue:r.name};return r.mode==="pull"&&(m.type="http_pull"),r.tuning.maxBatchSize!==void 0&&(m.max_batch_size=r.tuning.maxBatchSize),r.tuning.maxBatchTimeout!==void 0&&(m.max_batch_timeout=r.tuning.maxBatchTimeout),r.tuning.maxRetries!==void 0&&(m.max_retries=r.tuning.maxRetries),r.tuning.deadLetterQueue!==void 0&&(m.dead_letter_queue=r.tuning.deadLetterQueue),r.tuning.retryDelay!==void 0&&(m.retry_delay=r.tuning.retryDelay),m})],p=b(e,["queues"],{consumers:u,producers:h});return{added:[...g.map(r=>`queues.producers/${r.bindingName}`),...l.map(r=>`queues.consumers/${r.name}`)],text:p}},ne=(e,n,s)=>{const a=O(e),o=R(n);if(!a)return{added:[],changed:!1,exportGaps:o,reason:"wrangler.jsonc not found",warnings:f(n,e)};const{parsed:i,text:c}=P(a);if(i===void 0)return{added:[],changed:!1,exportGaps:o,reason:`failed to parse ${a} as JSONC`,warnings:f(n,e),wranglerPath:a};const d=f(n,e,i);if(s!==void 0){const t=i.env?.[s]!==void 0;d.push(t?`auto-provisioned bindings are written to the top level of wrangler.jsonc only — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const g=n.containers.filter(t=>t.exported),l=n.agents.filter(t=>t.exported&&t.voice===!0&&t.voiceBindingName!==void 0&&t.voiceClassName!==void 0),h=[...n.durableObjects,...g.map(t=>({binding:t.bindingName,className:t.className})),...l.map(t=>({binding:t.voiceBindingName,className:t.voiceClassName}))],u=n.workflows.filter(t=>t.exported),p=n.agents.filter(t=>t.exported),r=[{enabled:!0,run:t=>K(t,i,h)},{enabled:n.needsD1,run:t=>L(t,i)},{enabled:n.usesAi,run:t=>x(t,i,"ai","AI","AI (Workers AI)")},{enabled:n.usesBrowser,run:t=>x(t,i,"browser","BROWSER","BROWSER (Browser Rendering)")},{enabled:n.usesImages,run:t=>x(t,i,"images","IMAGES","IMAGES (Cloudflare Images)")},{enabled:n.usesAnalytics,run:t=>Y(t,i)},{enabled:!0,run:t=>U(t,i)},{enabled:g.length>0,run:t=>G(t,i,g)},{enabled:u.length>0||p.length>0,run:t=>V(t,i,u,p)},{enabled:n.queues.length>0,run:t=>z(t,i,n.queues)}];let m=c;const v=[];for(const t of r){if(!t.enabled)continue;const y=t.run(m);m=y.text,v.push(...y.added)}return v.includes("DB (D1)")&&d.push(`wrote a DB binding with a placeholder database_id ("${S}") — run \`wrangler d1 create <name>\` and replace it before deploying.`),m===c?{added:[],changed:!1,exportGaps:o,reason:"bindings already in sync",warnings:d,wranglerPath:a}:(k(a,m,"utf8"),{added:v,changed:!0,exportGaps:o,warnings:d,wranglerPath:a})};export{R as collectExportGaps,ne as reconcileWranglerBindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{relative as c}from"node:path";import{secretKindOf as E,redact as a}from"@lunora/codegen";import{isPlaceholderValue as S}from"./buildPackageSecretsBlock-
|
|
1
|
+
import{relative as c}from"node:path";import{secretKindOf as E,redact as a}from"@lunora/codegen";import{isPlaceholderValue as S}from"./buildPackageSecretsBlock-J7bP1P-6.mjs";import{findWranglerFile as _,readWranglerJsonc as l}from"./WRANGLER_FILES-UNW-xY5u.mjs";const d=8,f=new Set(["CREDENTIAL","CREDENTIALS","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),p=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],u=new Set(["PUBLIC","PUBLISHABLE"]),K=/[_-]/u,i=e=>e.toUpperCase().split(K),m=e=>{const r=e.toUpperCase().replaceAll("-","_");return i(e).some(n=>f.has(n))?!0:p.some(n=>r===n||r.endsWith(`_${n}`))},A=e=>i(e).some(r=>u.has(r)),N=(e,r)=>{if(e===void 0)return[];const n=[];for(const[o,t]of Object.entries(e)){if(typeof t!="string"||S(t)||A(o))continue;const s=E(t)??(m(o)&&t.length>=d?"secret_named_var":void 0);s!==void 0&&n.push({file:r,key:o,kind:s,preview:a(t)})}return n},h=e=>{const r=_(e);if(r===void 0)return[];const{parsed:n}=l(r);return n===void 0?[]:N(n.vars,c(e,r))};export{h as collectWranglerSecretVariables,N as scanWranglerVariablesForSecrets};
|
package/dist/packem_shared/{inferLunoraBindings-CEE39hXz.mjs → inferLunoraBindings-KST9XCEe.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as l,statSync as v,readFileSync as b,readdirSync as B}from"node:fs";import{init as k,parse as f}from"es-module-lexer";import{discoverAgentInfo as $}from"./discoverAgentInfo-CTdCSfYM.mjs";import{WRANGLER_FILES as F,readWranglerJsonc as j}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{discoverContainerInfo as Y}from"./discoverContainerInfo-EhZtEBQs.mjs";import{escapeRegExp as A}from"./DEV_VARS_EXAMPLE_FILE-
|
|
1
|
+
import{existsSync as l,statSync as v,readFileSync as b,readdirSync as B}from"node:fs";import{init as k,parse as f}from"es-module-lexer";import{discoverAgentInfo as $}from"./discoverAgentInfo-CTdCSfYM.mjs";import{WRANGLER_FILES as F,readWranglerJsonc as j}from"./WRANGLER_FILES-UNW-xY5u.mjs";import{discoverContainerInfo as Y}from"./discoverContainerInfo-EhZtEBQs.mjs";import{escapeRegExp as A}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{discoverFlags as K,FLAGS_FILENAME as U,discoverQueues as W,QUEUES_FILENAME as M}from"@lunora/codegen";import{d as w}from"./discover-info-Vj9d4qYt.mjs";import{discoverSchemaInfo as X}from"./discoverSchemaInfo-Bg2CUZXG.mjs";import{discoverWorkflowInfo as G}from"./discoverWorkflowInfo-BsPvlo6O.mjs";import{join as c}from"node:path";const H=(e,s)=>{const{error:t,value:r}=w(e,s,U,K);return t===void 0?{flags:r}:{error:t}},q=(e,s)=>{const{error:t,value:r}=w(e,s,M,W);return t===void 0?{queues:r??[]}:{error:t,queues:[]}},Q=new Set([".cjs",".cts",".js",".jsx",".mjs",".mts",".ts",".tsx"]),V=new Set([".git",".lunora-cache",".wrangler","_generated","dist","node_modules"]),J=["lunora","src"],z=["src/server/index.ts","src/server/index.tsx","src/index.ts","src/worker.ts"],T={SchedulerDO:"SCHEDULER",SessionDO:"SESSION",ShardDO:"SHARD"},N=Object.keys(T),Z={SchedulerDO:/\btype\s+SchedulerDO\b/,SessionDO:/\btype\s+SessionDO\b/,ShardDO:/\btype\s+ShardDO\b/},ee=/\benv\s*\.\s*DB\b/,se=/\benv\s*\.\s*AI\b/,D=/\bctx\s*\.\s*pipelines\b/,P=/^\s*import\s+type\b/,re=new Set(["@lunora/agent","@lunora/agent/sandbox"]),te=e=>{const s=e.indexOf("{");if(s===-1)return"";const t=e.indexOf("}",s+1);return t===-1?e.slice(s+1):e.slice(s+1,t)},ne=/\btype\s+browserTool\b/,oe=/\bbrowserTool\b/,ae=/import\s+\{[^}]*\bbrowserTool\b[^}]*\}\s+from\s+["']@lunora\/agent(?:\/sandbox)?["']/,ie=e=>{if(P.test(e))return!1;const s=te(e);return oe.test(s)&&!ne.test(s)},ce=e=>{try{const[s]=f(e);return s.some(t=>t.n!==void 0&&re.has(t.n)&&ie(e.slice(t.ss,t.se)))}catch{return ae.test(e)}},g={usesAi:{pattern:/\bfrom\s+["']@lunora\/ai["']/,source:"@lunora/ai"},usesAnalytics:{pattern:/\bfrom\s+["']@lunora\/bindings\/analytics["']/,source:"@lunora/bindings/analytics"},usesAuth:{pattern:/\bfrom\s+["']@lunora\/auth["']/,source:"@lunora/auth"},usesBrowser:{pattern:/\bfrom\s+["']@lunora\/browser["']/,source:"@lunora/browser"},usesHyperdrive:{pattern:/\bfrom\s+["']@lunora\/hyperdrive["']/,source:"@lunora/hyperdrive"},usesImages:{pattern:/\bfrom\s+["']@lunora\/bindings\/images["']/,source:"@lunora/bindings/images"},usesKv:{pattern:/\bfrom\s+["']@lunora\/bindings\/kv["']/,source:"@lunora/bindings/kv"},usesMail:{pattern:/\bfrom\s+["']@lunora\/mail["']/,source:"@lunora/mail"},usesPayment:{pattern:/\bfrom\s+["']@lunora\/payment["']/,source:"@lunora/payment"},usesPipelines:{pattern:D,source:"@lunora/bindings/pipelines"},usesScheduler:{pattern:/\bfrom\s+["']@lunora\/scheduler["']/,source:"@lunora/scheduler"},usesStorage:{pattern:/\bfrom\s+["']@lunora\/storage["']/,source:"@lunora/storage"},usesX402Charge:{pattern:/\bfrom\s+["']@lunora\/x402\/charge["']/,source:"@lunora/x402/charge"},usesX402Pay:{pattern:/\bfrom\s+["']@lunora\/x402\/pay["']/,source:"@lunora/x402/pay"}},p=Object.keys(g),ue="STRIPE_SECRET_KEY + STRIPE_WEBHOOK_SECRET (Stripe) or POLAR_ACCESS_TOKEN + POLAR_WEBHOOK_SECRET (Polar)",C=[...p,"needsD1"],de=()=>{const e={};for(const s of C)e[s]=!1;return e},d=Object.freeze(de()),S=(e,s)=>{const t={};for(const r of C)t[r]=e[r]||s[r];return t},le=e=>{for(const s of p)if(g[s].source===e)return{...d,[s]:!0};return d},pe=e=>{const[s]=f(e);let t=d;for(const r of s){const n=r.n;!n||P.test(e.slice(r.ss,r.se))||(t=S(t,le(n)))}return t},me=e=>{const s={...d};for(const t of p)s[t]=g[t].pattern.test(e);return s},be=e=>{let s;try{s=pe(e)}catch{s=me(e)}return S(s,{...d,needsD1:ee.test(e),usesAi:se.test(e),usesPipelines:D.test(e)})},y=(e,s)=>{let t;try{t=B(e,{withFileTypes:!0})}catch{return}for(const r of t){if(r.isDirectory()){V.has(r.name)||y(c(e,r.name),s);continue}const n=r.name.lastIndexOf(".");n!==-1&&Q.has(r.name.slice(n))&&s.push(c(e,r.name))}},fe=e=>{for(const s of F){const t=c(e,s);if(!l(t))continue;const{parsed:r}=j(t),n=r?.main;if(typeof n=="string"&&l(c(e,n)))return c(e,n);break}for(const s of z){const t=c(e,s);if(l(t))return t}},ge=e=>{const s=b(e,"utf8");let t;try{const[,r]=f(s);t=new Set(r.map(n=>n.n))}catch{t=new Set(N.filter(r=>new RegExp(String.raw`\bexport\b[^\n;]*\b${r}\b`).test(s)))}return N.filter(r=>t.has(r)&&!Z[r].test(s)).map(r=>({binding:T[r],className:r}))},he=/(?:^|[\s,{])type$/u,Ee=(e,s)=>{const t=s.ls>=0?s.ls:s.s;return he.test(e.slice(0,t).trimEnd())},Se=(e,s)=>{const t=A(s);return new RegExp(String.raw`\bexport\s+type\s+${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+type\s*\{[^}]*\b${t}\b`,"u").test(e)||new RegExp(String.raw`\bexport\s+\{[^}]*\btype\s+${t}\b`,"u").test(e)},E=(e,s,t)=>{if(s.length===0)return[];if(e===void 0)return s.map(o=>({...o,exported:!1}));const r=b(e,"utf8"),n=new RegExp(String.raw`\bexport\s*\*\s*from\s*["'][^"']*_generated\/${t}(?:\.js)?["']`).test(r);let a;try{const[,o]=f(r);a=new Set(o.filter(i=>!Ee(r,i)).map(i=>i.n))}catch{a=new Set(s.map(o=>o.className).filter(o=>new RegExp(String.raw`\bexport\b[^\n;]*\b${A(o)}\b`,"u").test(r)&&!Se(r,o)))}return s.map(o=>{const i=n||a.has(o.className);return{...o,exported:i}})},ye=(e,s)=>X(e,s).info?.hasGlobalTable??!1,xe=(e,s)=>{let t=d;for(const r of s){const n=c(e,r);if(!l(n)||!v(n).isDirectory())continue;const a=[];y(n,a);for(const o of a)t=S(t,be(b(o,"utf8")))}return t},_e=(e,s)=>{const t=c(e,s);if(!l(t)||!v(t).isDirectory())return!1;const r=[];return y(t,r),r.some(n=>ce(b(n,"utf8")))},Re=(e,s,t)=>[...e.map(r=>r.exported?`${r.bindingName}/${r.className} (container "${r.exportName}" declared and exported)`:`hint: container "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/containers"\``),...s.map(r=>r.exported?`${r.bindingName}/${r.className} (workflow "${r.exportName}" declared and exported)`:`hint: workflow "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/workflows"\``),...t.map(r=>r.exported?`${r.bindingName}/${r.className} (agent "${r.exportName}" declared and exported)`:`hint: agent "${r.exportName}" is declared but ${r.className} is not exported by the worker entry — add \`export * from "./lunora/_generated/agents"\``)],Ie=(e,s)=>[[e.usesAi,"AI (@lunora/ai imported or env.AI used)"],[e.usesAuth&&!s.has("SessionDO"),"hint: @lunora/auth is imported; its tables are D1-backed by default. For DO-backed auth (what @better-auth/scim needs), pass `namespace` to .auth() and export the generated auth DO class"],[e.usesScheduler&&!s.has("SchedulerDO"),"hint: @lunora/scheduler is imported but no SchedulerDO is exported by the worker entry"],[e.usesStorage,"hint: @lunora/storage is imported; add an r2_buckets binding (bucket binding names are user-defined)"],[e.usesMail,"hint: @lunora/mail is imported; set RESEND_API_KEY in .dev.vars (obtain at https://resend.com/api-keys)"],[e.usesPayment,`hint: @lunora/payment is imported; set the provider secrets in .dev.vars — ${ue}`],[e.usesBrowser,"browser (@lunora/browser imported) — self-describing { binding: BROWSER }"],[e.usesImages,"images (@lunora/bindings/images imported) — self-describing { binding: IMAGES }"],[e.usesAnalytics,"analytics_engine_datasets (@lunora/bindings/analytics imported) — self-describing { binding: ANALYTICS, dataset }"],[e.usesKv,"hint: @lunora/bindings/kv is imported; add a kv_namespaces binding ({ binding, id }) and pass env.<BINDING> to createKv() — the namespace id can't be auto-provisioned"],[e.usesHyperdrive,"hint: @lunora/hyperdrive is imported; run 'wrangler hyperdrive create' and add a 'hyperdrive' binding ({ binding, id }) — the id can't be auto-provisioned"],[e.usesPipelines,"hint: ctx.pipelines is used; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding, pipeline }) — the pipeline resource can't be auto-provisioned"],[e.usesX402Charge,"hint: @lunora/x402/charge is imported; set the recipient wallet address as a [vars] entry (the var name is yours to choose) and pass it to the charge config — the x402 facilitator settles USDC to that address"],[e.usesX402Pay,"hint: @lunora/x402/pay is imported (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding for the agent wallet key (name it to match signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars, so the key can't be auto-provisioned"]].filter(([r])=>r).map(([,r])=>r),Oe=(e,s,t,r=[],n=[],a=[])=>{const o=new Set(e.map(u=>u.className)),i=e.map(u=>`${u.binding}/${u.className} (exported by worker entry)`);return s&&i.push("DB (.global() table declared)"),i.push(...Re(r,n,a),...Ie(t,o)),i},$e=async e=>{await k;const s=e.schemaDir??"lunora",t=e.scanDirs??J,r=xe(e.projectRoot,t),n={...r,usesBrowser:r.usesBrowser||_e(e.projectRoot,s)},a=fe(e.projectRoot),o=a?ge(a):[],i=n.needsD1||ye(e.projectRoot,s),u=E(a,Y(e.projectRoot,s).containers,"containers"),x=E(a,G(e.projectRoot,s).workflows,"workflows"),_=E(a,$(e.projectRoot,s).agents,"agents"),L=[...q(e.projectRoot,s).queues],{flags:m}=H(e.projectRoot,s),h=m?.provider==="flagship"&&m.mode==="binding"?m.bindingName:void 0,R={};for(const O of p)R[O]=n[O];const I=Oe(o,i,n,u,x,_);return h!==void 0&&I.push(`hint: lunora/flags.ts uses Flagship in binding mode; add a flagship binding ({ binding: "${h}", app_id }) — the app_id can't be auto-provisioned`),{agents:_,containers:u,durableObjects:o,flagshipBinding:h,needsD1:i,queues:L,signals:I,usesFlags:m!==void 0,workflows:x,...R}},Fe=e=>{const s=[];for(const t of p)e[t]&&s.push(g[t].source);return s};export{z as WORKER_ENTRY_FALLBACKS,$e as inferLunoraBindings,Ee as isTypeOnlyExportEntry,Fe as packageNamesFromBindings,fe as resolveWorkerEntry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as n}from"node:fs";import{join as i}from"node:path";import{parseDevVariableEntries as s}from"./DEV_VARS_EXAMPLE_FILE-
|
|
1
|
+
import{readFileSync as n}from"node:fs";import{join as i}from"node:path";import{parseDevVariableEntries as s}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const v=(e,r)=>{const o=s(e).find(t=>t.key===r);return o===void 0||o.value===""?void 0:o.value},m=e=>{const r=process.env.LUNORA_ADMIN_TOKEN;if(typeof r=="string"&&r!=="")return r;try{return v(n(i(e,".dev.vars"),"utf8"),"LUNORA_ADMIN_TOKEN")}catch{return}};export{v as parseDevVariable,m as resolveAdminToken};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseDevVariable as t,resolveAdminToken as r}from"../packem_shared/parseDevVariable-
|
|
1
|
+
import{parseDevVariable as t,resolveAdminToken as r}from"../packem_shared/parseDevVariable-cacbGJkN.mjs";import{applyStudioAssetCache as s,sendStudioDocument as d}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as l,isStandaloneModulePath as p,loadStudioAssets as m,readStandaloneAsset as S,resolveStandaloneDirectory as i,studioAssetsStamp as f}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{POLICY_SCAFFOLD_ENDPOINT as D,handlePolicyScaffoldRequest as A}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-C1gb9ykA.mjs";import{default as x}from"../packem_shared/renderStudioHtml-ByowDtMl.mjs";import{SCHEMA_EDIT_ENDPOINT as h,handleSchemaEditRequest as N}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-CknH7oga.mjs";import{SEED_ENDPOINT as R,handleSeedRequest as _}from"../packem_shared/SEED_ENDPOINT-DVzCYp6l.mjs";import{serveJsonHandler as T}from"../packem_shared/serveJsonHandler-CB85A2S9.mjs";import{ALLOW_FORWARDED_ENV as I,headerValue as L,isLoopbackAddress as v,transportRejectionReason as y}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{I as ALLOW_FORWARDED_ENV,D as POLICY_SCAFFOLD_ENDPOINT,h as SCHEMA_EDIT_ENDPOINT,R as SEED_ENDPOINT,s as applyStudioAssetCache,l as assetContentType,A as handlePolicyScaffoldRequest,N as handleSchemaEditRequest,_ as handleSeedRequest,L as headerValue,v as isLoopbackAddress,p as isStandaloneModulePath,m as loadStudioAssets,t as parseDevVariable,S as readStandaloneAsset,x as renderStudioHtml,r as resolveAdminToken,i as resolveStandaloneDirectory,d as sendStudioDocument,T as serveJsonHandler,f as studioAssetsStamp,y 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.154",
|
|
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",
|
|
@@ -54,13 +54,14 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.123",
|
|
58
58
|
"@lunora/container": "1.0.0-alpha.33",
|
|
59
59
|
"@lunora/errors": "1.0.0-alpha.22",
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.81",
|
|
61
61
|
"@visulima/colorize": "2.1.1",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.1",
|
|
63
63
|
"dockerode": "^5.0.1",
|
|
64
|
+
"dotenv": "16.6.1",
|
|
64
65
|
"es-module-lexer": "^2.3.1",
|
|
65
66
|
"jsonc-parser": "^3.3.1",
|
|
66
67
|
"ts-morph": "^28.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./inferLunoraBindings-CEE39hXz.mjs";import{C as a}from"./cloudflare-driver-CvMyH1Ih.mjs";import"./collectExportGaps-B5eIg8p8.mjs";import"./reconcileWranglerCompatibilityDate-7OO_xaKR.mjs";import"./reconcileWranglerCrons-COMb6ICf.mjs";export{a as default};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const p=".dev.vars",$=".dev.vars.example",u=/^[A-Za-z_]\w*$/u,c=/\r?\n/u,l=e=>e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))?e.slice(1,-1):e,o=e=>{const r=e.trim();if(r===""||r.startsWith("#"))return;const s=r.indexOf("=");if(s<=0)return;const t=r.slice(0,s).trim();if(u.test(t))return{key:t,value:r.slice(s+1).trim()}},f=e=>{const r=[];for(const s of e.split(c)){const t=o(s);t&&r.push({key:t.key,value:l(t.value)})}return r},d=e=>e.replaceAll(/[.*+?^${}()|[\]\\]/gu,String.raw`\$&`),n=(e,r)=>new RegExp(String.raw`^[ \t]*${d(e)}[ \t]*=.*(\r?\n|$)`,r?"gmu":"mu"),V=(e,r,s)=>{const t=`${r}="${s}"`;if(!n(r,!1).test(e))return e===""?`${t}
|
|
2
|
-
`:e.endsWith(`
|
|
3
|
-
`)?`${e}${t}
|
|
4
|
-
`:`${e}
|
|
5
|
-
${t}
|
|
6
|
-
`;let i=!1;return e.replace(n(r,!0),(E,a)=>i?"":(i=!0,`${t}${a}`))};export{$ as DEV_VARS_EXAMPLE_FILE,p as DEV_VARS_FILE,u as DEV_VARS_KEY_PATTERN,c as DEV_VARS_NEWLINE,d as escapeRegExp,f as parseDevVariableEntries,o as splitDevVariableLine,l as unquoteDevVariable,V as upsertDevVariableLine};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{randomBytes as _}from"node:crypto";import{existsSync as f,readFileSync as y,writeFileSync as V,renameSync as C,rmSync as $,statSync as L}from"node:fs";import{join as g}from"node:path";import{LunoraError as j}from"@lunora/errors";import{DEV_VARS_FILE as u,DEV_VARS_EXAMPLE_FILE as m,splitDevVariableLine as x,parseDevVariableEntries as S,DEV_VARS_NEWLINE as A,unquoteDevVariable as D}from"./DEV_VARS_EXAMPLE_FILE-DxtfY0DW.mjs";import{CORE_SECRETS as E,PACKAGE_SECRETS_REGISTRY as F,secretsForPackages as M}from"./PACKAGE_SECRETS_REGISTRY-BgmvEPA-.mjs";const P=e=>[...E,...M(e)],K=32,H=/(?:KEY|PASSWORD|SECRET|TOKEN)$/u,W=["replace","openssl","changeme","change-me","change_me","change-this","change_this","your-","your_","example","placeholder","todo","fill-me","fill_me","fill-in","fill_in","xxx"],z=/[.*+?^${}()|[\]\\]/gu,I=/[a-z0-9]$/u,N=e=>{const t=e.trim().toLowerCase();return t===""||t.startsWith("<")&&t.endsWith(">")?!0:W.some(r=>{const s=r.replaceAll(z,String.raw`\$&`),o=I.test(r)?`(^|[^a-z0-9])${s}([^a-z0-9]|$)`:`(^|[^a-z0-9])${s}`;return new RegExp(o,"u").test(t)})},O=e=>N(D(e.trim())),p=e=>_(e).toString("hex"),B=new Set([...E,...Object.values(F).flat()].filter(e=>H.test(e.key)&&e.placeholderValue.startsWith("<")).map(e=>e.key)),G=e=>H.test(e)&&!B.has(e),b=(e,t,r)=>G(e)&&O(t)?r(K):void 0,ie=(e=p)=>e(K),T=(e,t,r)=>e.split(A).map(s=>{const n=x(s),o=n?b(n.key,n.value,t):void 0;return!n||o===void 0?s:(r.push(n.key),`${n.key}="${o}"`)}),Y=e=>{if(e.devVarsExists)return{status:"exists"};if(e.exampleContent===void 0)return{status:"no-example"};const t=[];return{content:T(e.exampleContent,e.randomHex??p,t).join(`
|
|
2
|
-
`),generatedKeys:t,status:"generate"}},v=e=>{const t=e.randomHex??p,r=new Set(S(e.existingContent).map(d=>d.key)),s=[],n=[],o=[];for(const d of e.exampleContent.split(A)){const i=x(d);if(!i||r.has(i.key))continue;const a=b(i.key,i.value,t);o.push(i.key),a===void 0?s.push(`${i.key}="${D(i.value)}"`):(n.push(i.key),s.push(`${i.key}="${a}"`))}return{additions:s,generatedKeys:n,missingKeys:o}},k=e=>e.length>0?` (generated ${e.join(", ")})`:"",h=(e,t,r={})=>{const s=`${e}.tmp-${String(process.pid)}`;try{V(s,t,{encoding:"utf8",...r}),C(s,e)}catch(n){throw $(s,{force:!0}),n}},ae=(e,t)=>{h(e,t,{mode:384})},w=5,R=e=>{try{const t=L(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}},U=(e,t)=>e===void 0||t===void 0?!1:e.mtimeMs===t.mtimeMs&&e.size===t.size,X=(e,t)=>{for(let r=0;r<w;r+=1){const s=R(e),n=y(e,"utf8"),o=t(n);if(o.length===0)return[];const d=n.length>0&&!n.endsWith(`
|
|
3
|
-
`)?`
|
|
4
|
-
`:"",i=`${n}${d}${o.join(`
|
|
5
|
-
`)}
|
|
6
|
-
`,a=`${e}.tmp-${String(process.pid)}-${_(6).toString("hex")}`;try{V(a,i,{encoding:"utf8",mode:384});const c=R(e);if(!U(s,c)){$(a,{force:!0});continue}return C(a,e),o}catch(c){throw $(a,{force:!0}),c}}throw new j("INTERNAL",`Failed to append to ${e} after ${String(w)} attempts — a concurrent writer kept winning the race.`)},ce=async e=>{const t=g(e.cwd,u),r=g(e.cwd,m);if(!f(r))return{addedKeys:[],generatedKeys:[],status:"no-example"};const s=y(r,"utf8");if(!f(t)){const l=Y({devVarsExists:!1,exampleContent:s,randomHex:e.randomHex});return l.status!=="generate"?{addedKeys:[],generatedKeys:[],status:"no-example"}:e.yes===!0||await e.confirm(`No ${u} found. Generate it from ${m} (secrets auto-filled)?`)?f(t)?{addedKeys:[],generatedKeys:[],status:"skipped-exists"}:(h(t,l.content,{flag:"wx",mode:384}),e.info(`Created ${u}${k(l.generatedKeys)}.`),{addedKeys:[],generatedKeys:l.generatedKeys,status:"generated"}):(e.info(`Skipped — copy ${m} to ${u} and fill it in when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"})}const n=v({existingContent:y(t,"utf8"),exampleContent:s,randomHex:e.randomHex});if(n.missingKeys.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const o=n.missingKeys.join(", ");if(!(e.yes===!0||await e.confirm(`${u} is missing ${String(n.missingKeys.length)} key(s) from ${m} (${o}). Add them?`)))return e.info(`Skipped — add ${o} to ${u} when you're ready.`),{addedKeys:[],generatedKeys:[],status:"declined"};const a=X(t,l=>v({existingContent:l,exampleContent:s,randomHex:e.randomHex}).additions).map(l=>x(l)?.key).filter(l=>l!==void 0);if(a.length===0)return{addedKeys:[],generatedKeys:[],status:"exists"};const c=n.generatedKeys.filter(l=>a.includes(l));return e.info(`Updated ${u} — added ${a.join(", ")}${k(c)}.`),{addedKeys:a,generatedKeys:c,status:"augmented"}},q=e=>[`# ${e.description}`,`# Docs: ${e.docsUrl}`,`${e.key}="${e.placeholderValue}"`].join(`
|
|
7
|
-
`),J=(e,t)=>{const r=P(e).filter(s=>!t.has(s.key));return r.length===0?"":r.map(s=>q(s)).join(`
|
|
8
|
-
|
|
9
|
-
`)},de=(e,t)=>{const r=g(e,m),s=f(r)?y(r,"utf8"):"",n=new Set(S(s).map(i=>i.key)),o=J(t,n);if(o==="")return[];const d=s.length>0&&!s.endsWith(`
|
|
10
|
-
`)?`
|
|
11
|
-
`:"";return h(r,`${s}${d}
|
|
12
|
-
${o}
|
|
13
|
-
`),P(t).filter(i=>!n.has(i.key)).map(i=>i.key)},Q=e=>{const t=e.randomHex??p,r=[],s=T(e.existingContent,t,r),n=new Set(S(e.existingContent).map(c=>c.key)),o=[],d=[];for(const c of E)n.has(c.key)||(o.push(c.key),d.push(`# ${c.description}`,`${c.key}="${t(K)}"`));const i=s.join(`
|
|
14
|
-
`);if(d.length===0)return{addedKeys:o,content:i,filledKeys:r};const a=i===""||i.endsWith(`
|
|
15
|
-
`)?"":`
|
|
16
|
-
`;return{addedKeys:o,content:`${i}${a}${d.join(`
|
|
17
|
-
`)}
|
|
18
|
-
`,filledKeys:r}},le=e=>{const t=g(e.cwd,u),r=f(t),s=r?y(t,"utf8"):"",n=Q({existingContent:s,randomHex:e.randomHex});if(n.filledKeys.length===0&&n.addedKeys.length===0)return{addedKeys:[],filledKeys:[],status:"unchanged"};h(t,n.content,{mode:384});const o=[...n.filledKeys,...n.addedKeys];return e.info?.(`Generated ${String(o.length)} dev secret(s) in ${u}: ${o.join(", ")}`),{addedKeys:n.addedKeys,filledKeys:n.filledKeys,status:r?"filled":"created"}};export{J as buildPackageSecretsBlock,ce as ensureDevVariables,de as ensureDevVarsExample,le as fillDevSecrets,ie as generateSecretValue,G as isMintableSecretKey,N as isPlaceholderValue,Q as planDevSecretsFill,v as planDevVariablesAugment,Y as planDevVariablesScaffold,P as requiredSecrets,ae as writeDevVariablesFileAtomically};
|