@lunora/config 1.0.0-alpha.11 → 1.0.0-alpha.13
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/index.d.mts
CHANGED
|
@@ -668,6 +668,8 @@ interface RemoteEnableInputs {
|
|
|
668
668
|
* is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
|
|
669
669
|
*/
|
|
670
670
|
declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
671
|
+
/** Core (always-scaffolded) secrets followed by the package-specific ones for the detected capabilities. */
|
|
672
|
+
declare const requiredSecrets: (packageNames: ReadonlyArray<string>) => SecretEntry[];
|
|
671
673
|
/**
|
|
672
674
|
* Whether an (already-unquoted) value looks like a fill-me-in placeholder —
|
|
673
675
|
* empty, angle-bracketed, or containing a known marker — rather than a real
|
|
@@ -676,6 +678,15 @@ declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
|
676
678
|
*/
|
|
677
679
|
declare const isPlaceholderValue: (value: string) => boolean;
|
|
678
680
|
/**
|
|
681
|
+
* True for a secret-looking key whose value Lunora can mint locally (a random
|
|
682
|
+
* 32-byte hex, like `openssl rand -hex 32`) — e.g. `AUTH_SECRET`,
|
|
683
|
+
* `LUNORA_ADMIN_TOKEN`, `STORAGE_SIGNING_SECRET`. False for provider-issued keys
|
|
684
|
+
* ({@link PROVIDER_SECRET_KEYS}) and any non-secret key.
|
|
685
|
+
*/
|
|
686
|
+
declare const isMintableSecretKey: (key: string) => boolean;
|
|
687
|
+
/** Mint a fresh strong secret value — 64 hex chars (32 bytes), like `openssl rand -hex 32`. */
|
|
688
|
+
declare const generateSecretValue: (randomHex?: (bytes: number) => string) => string;
|
|
689
|
+
/**
|
|
679
690
|
* The outcome of planning a scaffold — a discriminated union so the orchestrator
|
|
680
691
|
* never has to re-derive whether `content` is present.
|
|
681
692
|
*
|
|
@@ -777,6 +788,58 @@ declare const buildPackageSecretsBlock: (packageNames: ReadonlyArray<string>, ex
|
|
|
777
788
|
* **Safety invariant:** only placeholder values are written — no real secrets.
|
|
778
789
|
*/
|
|
779
790
|
declare const ensureDevVariablesExample: (cwd: string, packageNames: ReadonlyArray<string>) => string[];
|
|
791
|
+
interface DevSecretsFillPlan {
|
|
792
|
+
/** {@link CORE_SECRETS} keys appended because they were absent (each generated). */
|
|
793
|
+
addedKeys: string[];
|
|
794
|
+
/** The full new file content to write. */
|
|
795
|
+
content: string;
|
|
796
|
+
/** Existing empty/placeholder secret-keyed entries filled with fresh values. */
|
|
797
|
+
filledKeys: string[];
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Plan the in-place generation of dev secrets for a `.dev.vars`. First, every
|
|
801
|
+
* line whose KEY looks like a secret (`*_SECRET`, `*_TOKEN`, `*_KEY`,
|
|
802
|
+
* `*_PASSWORD`) and whose value is empty or a placeholder gets a freshly
|
|
803
|
+
* generated value — so a `lunora add`-scaffolded `.dev.vars` (which writes each
|
|
804
|
+
* secret blank) becomes usable on `lunora dev` / `vite dev` without the user
|
|
805
|
+
* running `openssl` by hand. Second, any {@link CORE_SECRETS} key absent from
|
|
806
|
+
* the file is appended (generated) — notably `LUNORA_ADMIN_TOKEN`, which the
|
|
807
|
+
* local Studio needs to call the worker's admin gate in dev (without it the
|
|
808
|
+
* Studio shows its login gate).
|
|
809
|
+
*
|
|
810
|
+
* Pure (given `randomHex`): real (non-placeholder) values are never touched, and
|
|
811
|
+
* comments + non-secret entries are preserved verbatim.
|
|
812
|
+
*/
|
|
813
|
+
declare const planDevSecretsFill: (input: {
|
|
814
|
+
existingContent: string;
|
|
815
|
+
randomHex?: (bytes: number) => string;
|
|
816
|
+
}) => DevSecretsFillPlan;
|
|
817
|
+
interface FillDevSecretsResult {
|
|
818
|
+
/** Core secret keys appended (generated) because they were missing. */
|
|
819
|
+
addedKeys: string[];
|
|
820
|
+
/** Existing empty/placeholder secrets filled with generated values. */
|
|
821
|
+
filledKeys: string[];
|
|
822
|
+
/** `created` = no `.dev.vars` existed; `filled` = topped up an existing one; `unchanged` = nothing to do. */
|
|
823
|
+
status: "created" | "filled" | "unchanged";
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Generate any missing/empty dev secrets in the project's `.dev.vars`, in place.
|
|
827
|
+
*
|
|
828
|
+
* Complements {@link ensureDevVariables} (which scaffolds `.dev.vars` from
|
|
829
|
+
* `.dev.vars.example`). A `lunora add`-scaffolded project writes secrets blank
|
|
830
|
+
* straight into `.dev.vars` (no example) and never includes `LUNORA_ADMIN_TOKEN`
|
|
831
|
+
* — so the worker boots with empty secrets and the Studio shows its login gate.
|
|
832
|
+
* This fills those gaps at dev startup, so both `lunora dev` and the
|
|
833
|
+
* `@lunora/vite` dev server give a working project with zero manual `openssl`.
|
|
834
|
+
*
|
|
835
|
+
* Never overwrites a real (non-placeholder) value. The write is atomic + owner-
|
|
836
|
+
* only (temp + rename, `mode: 0o600`), matching the other `.dev.vars` writers.
|
|
837
|
+
*/
|
|
838
|
+
declare const fillDevSecrets: (deps: {
|
|
839
|
+
cwd: string;
|
|
840
|
+
info?: (message: string) => void;
|
|
841
|
+
randomHex?: (bytes: number) => string;
|
|
842
|
+
}) => FillDevSecretsResult;
|
|
780
843
|
/** Add a new table to `defineSchema({ ... })`. */
|
|
781
844
|
interface AddTableEdit {
|
|
782
845
|
readonly kind: "addTable";
|
|
@@ -1137,4 +1200,4 @@ interface WranglerProjectValidationResult {
|
|
|
1137
1200
|
* `{ problems, wranglerPath }` shape plus the structured `report`.
|
|
1138
1201
|
*/
|
|
1139
1202
|
declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
|
|
1140
|
-
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, findWranglerFile, formatLunoraEvent, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
|
1203
|
+
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, requiredSecrets, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
package/dist/index.d.ts
CHANGED
|
@@ -668,6 +668,8 @@ interface RemoteEnableInputs {
|
|
|
668
668
|
* is still overridable per-run by `--remote` or `LUNORA_REMOTE=1`.
|
|
669
669
|
*/
|
|
670
670
|
declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
671
|
+
/** Core (always-scaffolded) secrets followed by the package-specific ones for the detected capabilities. */
|
|
672
|
+
declare const requiredSecrets: (packageNames: ReadonlyArray<string>) => SecretEntry[];
|
|
671
673
|
/**
|
|
672
674
|
* Whether an (already-unquoted) value looks like a fill-me-in placeholder —
|
|
673
675
|
* empty, angle-bracketed, or containing a known marker — rather than a real
|
|
@@ -676,6 +678,15 @@ declare const resolveRemoteEnabled: (inputs: RemoteEnableInputs) => boolean;
|
|
|
676
678
|
*/
|
|
677
679
|
declare const isPlaceholderValue: (value: string) => boolean;
|
|
678
680
|
/**
|
|
681
|
+
* True for a secret-looking key whose value Lunora can mint locally (a random
|
|
682
|
+
* 32-byte hex, like `openssl rand -hex 32`) — e.g. `AUTH_SECRET`,
|
|
683
|
+
* `LUNORA_ADMIN_TOKEN`, `STORAGE_SIGNING_SECRET`. False for provider-issued keys
|
|
684
|
+
* ({@link PROVIDER_SECRET_KEYS}) and any non-secret key.
|
|
685
|
+
*/
|
|
686
|
+
declare const isMintableSecretKey: (key: string) => boolean;
|
|
687
|
+
/** Mint a fresh strong secret value — 64 hex chars (32 bytes), like `openssl rand -hex 32`. */
|
|
688
|
+
declare const generateSecretValue: (randomHex?: (bytes: number) => string) => string;
|
|
689
|
+
/**
|
|
679
690
|
* The outcome of planning a scaffold — a discriminated union so the orchestrator
|
|
680
691
|
* never has to re-derive whether `content` is present.
|
|
681
692
|
*
|
|
@@ -777,6 +788,58 @@ declare const buildPackageSecretsBlock: (packageNames: ReadonlyArray<string>, ex
|
|
|
777
788
|
* **Safety invariant:** only placeholder values are written — no real secrets.
|
|
778
789
|
*/
|
|
779
790
|
declare const ensureDevVariablesExample: (cwd: string, packageNames: ReadonlyArray<string>) => string[];
|
|
791
|
+
interface DevSecretsFillPlan {
|
|
792
|
+
/** {@link CORE_SECRETS} keys appended because they were absent (each generated). */
|
|
793
|
+
addedKeys: string[];
|
|
794
|
+
/** The full new file content to write. */
|
|
795
|
+
content: string;
|
|
796
|
+
/** Existing empty/placeholder secret-keyed entries filled with fresh values. */
|
|
797
|
+
filledKeys: string[];
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Plan the in-place generation of dev secrets for a `.dev.vars`. First, every
|
|
801
|
+
* line whose KEY looks like a secret (`*_SECRET`, `*_TOKEN`, `*_KEY`,
|
|
802
|
+
* `*_PASSWORD`) and whose value is empty or a placeholder gets a freshly
|
|
803
|
+
* generated value — so a `lunora add`-scaffolded `.dev.vars` (which writes each
|
|
804
|
+
* secret blank) becomes usable on `lunora dev` / `vite dev` without the user
|
|
805
|
+
* running `openssl` by hand. Second, any {@link CORE_SECRETS} key absent from
|
|
806
|
+
* the file is appended (generated) — notably `LUNORA_ADMIN_TOKEN`, which the
|
|
807
|
+
* local Studio needs to call the worker's admin gate in dev (without it the
|
|
808
|
+
* Studio shows its login gate).
|
|
809
|
+
*
|
|
810
|
+
* Pure (given `randomHex`): real (non-placeholder) values are never touched, and
|
|
811
|
+
* comments + non-secret entries are preserved verbatim.
|
|
812
|
+
*/
|
|
813
|
+
declare const planDevSecretsFill: (input: {
|
|
814
|
+
existingContent: string;
|
|
815
|
+
randomHex?: (bytes: number) => string;
|
|
816
|
+
}) => DevSecretsFillPlan;
|
|
817
|
+
interface FillDevSecretsResult {
|
|
818
|
+
/** Core secret keys appended (generated) because they were missing. */
|
|
819
|
+
addedKeys: string[];
|
|
820
|
+
/** Existing empty/placeholder secrets filled with generated values. */
|
|
821
|
+
filledKeys: string[];
|
|
822
|
+
/** `created` = no `.dev.vars` existed; `filled` = topped up an existing one; `unchanged` = nothing to do. */
|
|
823
|
+
status: "created" | "filled" | "unchanged";
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Generate any missing/empty dev secrets in the project's `.dev.vars`, in place.
|
|
827
|
+
*
|
|
828
|
+
* Complements {@link ensureDevVariables} (which scaffolds `.dev.vars` from
|
|
829
|
+
* `.dev.vars.example`). A `lunora add`-scaffolded project writes secrets blank
|
|
830
|
+
* straight into `.dev.vars` (no example) and never includes `LUNORA_ADMIN_TOKEN`
|
|
831
|
+
* — so the worker boots with empty secrets and the Studio shows its login gate.
|
|
832
|
+
* This fills those gaps at dev startup, so both `lunora dev` and the
|
|
833
|
+
* `@lunora/vite` dev server give a working project with zero manual `openssl`.
|
|
834
|
+
*
|
|
835
|
+
* Never overwrites a real (non-placeholder) value. The write is atomic + owner-
|
|
836
|
+
* only (temp + rename, `mode: 0o600`), matching the other `.dev.vars` writers.
|
|
837
|
+
*/
|
|
838
|
+
declare const fillDevSecrets: (deps: {
|
|
839
|
+
cwd: string;
|
|
840
|
+
info?: (message: string) => void;
|
|
841
|
+
randomHex?: (bytes: number) => string;
|
|
842
|
+
}) => FillDevSecretsResult;
|
|
780
843
|
/** Add a new table to `defineSchema({ ... })`. */
|
|
781
844
|
interface AddTableEdit {
|
|
782
845
|
readonly kind: "addTable";
|
|
@@ -1137,4 +1200,4 @@ interface WranglerProjectValidationResult {
|
|
|
1137
1200
|
* `{ problems, wranglerPath }` shape plus the structured `report`.
|
|
1138
1201
|
*/
|
|
1139
1202
|
declare const validateWranglerProject: (options: WranglerProjectValidationOptions) => WranglerProjectValidationResult;
|
|
1140
|
-
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, findWranglerFile, formatLunoraEvent, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
|
1203
|
+
export { ACCENT, AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, type AddIndexEdit, type AddOptionalColumnEdit, type AddTableEdit, type AdditiveEdit, type AgentRulesStatus, type ApplyEditResult, type ApplyFailureReason, type AugmentPlan, BADGES, BADGE_COLUMN_WIDTH, type BadgeName, type BadgeSpec, DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, type DestructiveEdit, type DetectedFramework, type DevSecretsFillPlan, type DiscoverContainerInfoResult, type DiscoverSchemaInfoResult, type DiscoverWorkflowInfoResult, type EnsureDevVariablesDeps, type EnsureDevVariablesResult, type EnsureDevVariablesStatus, type ExportGap, type FillDevSecretsResult, type FrameworkClass, type FrameworkDetection, type InferOptions, type InferredBindings, type InferredContainer, type InferredWorkflow, LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, LUNORA_CONFIG_FILE, LUNORA_EVENT_SOURCE, LUNORA_SKILL_NAMES, type LevelBadgeName, type LinkedProject, type LunoraFormattedLine, type LunoraLineLevel, type LunoraProjectConfig, LunoraReporter, type MaterializeOptions, type MaterializeResult, type MultiSelectOption, PACKAGE_SECRETS_REGISTRY, type ParseSchemaResult, REMOTE_ELIGIBLE_KEYS, REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, ROOT_SKILL_NAME, type ReadWranglerResult, type ReconcileBindingsResult, type RemoteBindingPlan, type RemoteEnableInputs, type RemotePreference, type RemoteWranglerShape, STEP_BADGE_NAMES, type ScaffoldPlan, type SchemaColumn, type SchemaEdit, type SchemaIndex, type SchemaInfo, type SchemaTable, type SecretEntry, type SelectOption, type StepBadgeName, type TailConsumer, WRANGLER_FILES, type WranglerConfig, type WranglerContainerEntry, type WranglerProjectValidationOptions, type WranglerProjectValidationResult, type WranglerValidationReport, type WranglerWorkflowEntry, applyAdditiveEdit, badgeLead, badgeWidth, buildPackageSecretsBlock, claimAgentRulesHint, classifyEdit, createConfirm, detectAgentRules, detectFramework, discoverContainerInfo, discoverSchemaInfo, discoverWorkflowInfo, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, findWranglerFile, formatLunoraEvent, generateSecretValue, inferLunoraBindings, injectRemoteFlags, interpretRemote, isInteractive, isMintableSecretKey, isPlaceholderValue, isRemoteEnvEnabled, materializeRemoteWranglerConfig, packageNamesFromBindings, padBadge, paintAnswer, paintBadge, parseDevVariableEntries, parseSchema, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, planRemoteBindings, promptMultiSelect, promptSelect, promptYesNo, readLinkedProject, readProjectRemotePreference, readWranglerJsonc, reconcileWranglerBindings, requiredSecrets, resolveRemoteEnabled, secretsForPackages, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer, writeLinkedProject };
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ export { LUNORA_CONFIG_FILE, interpretRemote, readProjectRemotePreference } from
|
|
|
11
11
|
export { createConfirm, isInteractive, promptMultiSelect, promptSelect, promptYesNo } from './packem_shared/createConfirm-fvpdgJ9s.mjs';
|
|
12
12
|
export { reconcileWranglerBindings } from './packem_shared/reconcileWranglerBindings-DTHmqTbL.mjs';
|
|
13
13
|
export { REMOTE_ELIGIBLE_KEYS, injectRemoteFlags, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, resolveRemoteEnabled } from './packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs';
|
|
14
|
-
export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVarsExample, isPlaceholderValue, planDevVariablesAugment, planDevVariablesScaffold } from './packem_shared/buildPackageSecretsBlock-
|
|
14
|
+
export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVarsExample, fillDevSecrets, generateSecretValue, isMintableSecretKey, isPlaceholderValue, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, requiredSecrets } from './packem_shared/buildPackageSecretsBlock-DWDKHViT.mjs';
|
|
15
15
|
export { applyAdditiveEdit, classifyEdit } from './packem_shared/applyAdditiveEdit-C-snTFEV.mjs';
|
|
16
16
|
export { parseSchema } from './packem_shared/parseSchema-DSeyktvG.mjs';
|
|
17
17
|
export { classifyPolicyEdit, scaffoldPolicyFile, wireRlsIntoProcedure } from './packem_shared/classifyPolicyEdit-BHeAqF8P.mjs';
|
|
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync, renameSync, rmSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { DEV_VARS_FILE, DEV_VARS_EXAMPLE_FILE, parseDevVariableEntries, DEV_VARS_NEWLINE, splitDevVariableLine, unquoteDevVariable } from './DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs';
|
|
5
|
-
import { CORE_SECRETS, secretsForPackages } from './PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs';
|
|
5
|
+
import { CORE_SECRETS, PACKAGE_SECRETS_REGISTRY, secretsForPackages } from './PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs';
|
|
6
6
|
|
|
7
7
|
const requiredSecrets = (packageNames) => [...CORE_SECRETS, ...secretsForPackages(packageNames)];
|
|
8
8
|
const SECRET_BYTES = 32;
|
|
@@ -46,6 +46,11 @@ const isPlaceholderValue = (value) => {
|
|
|
46
46
|
const isPlaceholder = (rawValue) => isPlaceholderValue(unquoteDevVariable(rawValue.trim()));
|
|
47
47
|
const defaultRandomHex = (bytes) => randomBytes(bytes).toString("hex");
|
|
48
48
|
const generatedSecretFor = (key, rawValue, randomHex) => SECRET_KEY.test(key) && isPlaceholder(rawValue) ? randomHex(SECRET_BYTES) : void 0;
|
|
49
|
+
const PROVIDER_SECRET_KEYS = new Set(
|
|
50
|
+
[...CORE_SECRETS, ...Object.values(PACKAGE_SECRETS_REGISTRY).flat()].filter((entry) => SECRET_KEY.test(entry.key) && entry.placeholderValue.startsWith("<")).map((entry) => entry.key)
|
|
51
|
+
);
|
|
52
|
+
const isMintableSecretKey = (key) => SECRET_KEY.test(key) && !PROVIDER_SECRET_KEYS.has(key);
|
|
53
|
+
const generateSecretValue = (randomHex = defaultRandomHex) => randomHex(SECRET_BYTES);
|
|
49
54
|
const planDevVariablesScaffold = (input) => {
|
|
50
55
|
if (input.devVarsExists) {
|
|
51
56
|
return { status: "exists" };
|
|
@@ -184,5 +189,55 @@ ${block}
|
|
|
184
189
|
}
|
|
185
190
|
return requiredSecrets(packageNames).filter((entry) => !existingKeys.has(entry.key)).map((entry) => entry.key);
|
|
186
191
|
};
|
|
192
|
+
const planDevSecretsFill = (input) => {
|
|
193
|
+
const randomHex = input.randomHex ?? defaultRandomHex;
|
|
194
|
+
const filledKeys = [];
|
|
195
|
+
const lines = input.existingContent.split(DEV_VARS_NEWLINE).map((line) => {
|
|
196
|
+
const parsed = splitDevVariableLine(line);
|
|
197
|
+
const secret = parsed ? generatedSecretFor(parsed.key, parsed.value, randomHex) : void 0;
|
|
198
|
+
if (!parsed || secret === void 0) {
|
|
199
|
+
return line;
|
|
200
|
+
}
|
|
201
|
+
filledKeys.push(parsed.key);
|
|
202
|
+
return `${parsed.key}="${secret}"`;
|
|
203
|
+
});
|
|
204
|
+
const present = new Set(parseDevVariableEntries(input.existingContent).map((entry) => entry.key));
|
|
205
|
+
const addedKeys = [];
|
|
206
|
+
const additions = [];
|
|
207
|
+
for (const entry of CORE_SECRETS) {
|
|
208
|
+
if (present.has(entry.key)) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
addedKeys.push(entry.key);
|
|
212
|
+
additions.push(`# ${entry.description}`, `${entry.key}="${randomHex(SECRET_BYTES)}"`);
|
|
213
|
+
}
|
|
214
|
+
const body = lines.join("\n");
|
|
215
|
+
if (additions.length === 0) {
|
|
216
|
+
return { addedKeys, content: body, filledKeys };
|
|
217
|
+
}
|
|
218
|
+
const separator = body === "" || body.endsWith("\n") ? "" : "\n";
|
|
219
|
+
return { addedKeys, content: `${body}${separator}${additions.join("\n")}
|
|
220
|
+
`, filledKeys };
|
|
221
|
+
};
|
|
222
|
+
const fillDevSecrets = (deps) => {
|
|
223
|
+
const devVariablesPath = join(deps.cwd, DEV_VARS_FILE);
|
|
224
|
+
const exists = existsSync(devVariablesPath);
|
|
225
|
+
const existingContent = exists ? readFileSync(devVariablesPath, "utf8") : "";
|
|
226
|
+
const plan = planDevSecretsFill({ existingContent, randomHex: deps.randomHex });
|
|
227
|
+
if (plan.filledKeys.length === 0 && plan.addedKeys.length === 0) {
|
|
228
|
+
return { addedKeys: [], filledKeys: [], status: "unchanged" };
|
|
229
|
+
}
|
|
230
|
+
const temporaryPath = `${devVariablesPath}.tmp-${String(process.pid)}`;
|
|
231
|
+
try {
|
|
232
|
+
writeFileSync(temporaryPath, plan.content, { encoding: "utf8", mode: 384 });
|
|
233
|
+
renameSync(temporaryPath, devVariablesPath);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
rmSync(temporaryPath, { force: true });
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
const generated = [...plan.filledKeys, ...plan.addedKeys];
|
|
239
|
+
deps.info?.(`Generated ${String(generated.length)} dev secret(s) in ${DEV_VARS_FILE}: ${generated.join(", ")}`);
|
|
240
|
+
return { addedKeys: plan.addedKeys, filledKeys: plan.filledKeys, status: exists ? "filled" : "created" };
|
|
241
|
+
};
|
|
187
242
|
|
|
188
|
-
export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, isPlaceholderValue, planDevVariablesAugment, planDevVariablesScaffold };
|
|
243
|
+
export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVariablesExample as ensureDevVarsExample, fillDevSecrets, generateSecretValue, isMintableSecretKey, isPlaceholderValue, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, requiredSecrets };
|
package/package.json
CHANGED