everything-dev 1.7.2 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +1 -1
- package/dist/app.cjs +82 -51
- package/dist/app.cjs.map +1 -1
- package/dist/app.mjs +82 -51
- package/dist/app.mjs.map +1 -1
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/components/dev-view.cjs +6 -3
- package/dist/components/dev-view.cjs.map +1 -1
- package/dist/components/dev-view.mjs +6 -3
- package/dist/components/dev-view.mjs.map +1 -1
- package/dist/components/streaming-view.cjs +5 -2
- package/dist/components/streaming-view.cjs.map +1 -1
- package/dist/components/streaming-view.mjs +5 -2
- package/dist/components/streaming-view.mjs.map +1 -1
- package/dist/config.cjs +28 -5
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +28 -5
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +1 -0
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +14 -6
- package/dist/contract.d.cts.map +1 -1
- package/dist/contract.d.mts +14 -6
- package/dist/contract.d.mts.map +1 -1
- package/dist/contract.mjs +1 -0
- package/dist/contract.mjs.map +1 -1
- package/dist/dev-logs.cjs +6 -2
- package/dist/dev-logs.cjs.map +1 -1
- package/dist/dev-logs.mjs +7 -2
- package/dist/dev-logs.mjs.map +1 -1
- package/dist/dev-session.cjs +27 -23
- package/dist/dev-session.cjs.map +1 -1
- package/dist/dev-session.mjs +27 -24
- package/dist/dev-session.mjs.map +1 -1
- package/dist/federation.server.cjs +1 -1
- package/dist/federation.server.mjs +1 -1
- package/dist/host.cjs +4 -3
- package/dist/host.cjs.map +1 -1
- package/dist/host.d.cts.map +1 -1
- package/dist/host.d.mts.map +1 -1
- package/dist/host.mjs +4 -3
- package/dist/host.mjs.map +1 -1
- package/dist/integrity.cjs +68 -2
- package/dist/integrity.cjs.map +1 -1
- package/dist/integrity.d.cts +14 -1
- package/dist/integrity.d.cts.map +1 -1
- package/dist/integrity.d.mts +14 -1
- package/dist/integrity.d.mts.map +1 -1
- package/dist/integrity.mjs +66 -3
- package/dist/integrity.mjs.map +1 -1
- package/dist/mf.cjs +32 -0
- package/dist/mf.cjs.map +1 -1
- package/dist/mf.d.cts +3 -1
- package/dist/mf.d.cts.map +1 -1
- package/dist/mf.d.mts +3 -1
- package/dist/mf.d.mts.map +1 -1
- package/dist/mf.mjs +32 -1
- package/dist/mf.mjs.map +1 -1
- package/dist/orchestrator.cjs +167 -317
- package/dist/orchestrator.cjs.map +1 -1
- package/dist/orchestrator.d.cts +24 -21
- package/dist/orchestrator.d.cts.map +1 -1
- package/dist/orchestrator.d.mts +24 -21
- package/dist/orchestrator.d.mts.map +1 -1
- package/dist/orchestrator.mjs +168 -316
- package/dist/orchestrator.mjs.map +1 -1
- package/dist/plugin.cjs +38 -107
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +19 -5
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +19 -5
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +39 -108
- package/dist/plugin.mjs.map +1 -1
- package/dist/service-descriptor.cjs +188 -0
- package/dist/service-descriptor.cjs.map +1 -0
- package/dist/service-descriptor.d.cts +107 -0
- package/dist/service-descriptor.d.cts.map +1 -0
- package/dist/service-descriptor.d.mts +107 -0
- package/dist/service-descriptor.d.mts.map +1 -0
- package/dist/service-descriptor.mjs +182 -0
- package/dist/service-descriptor.mjs.map +1 -0
- package/dist/types.cjs +8 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +18 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +18 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +8 -1
- package/dist/types.mjs.map +1 -1
- package/dist/ui/index.cjs +1 -0
- package/dist/ui/index.d.cts +2 -2
- package/dist/ui/index.d.mts +2 -2
- package/dist/ui/index.mjs +2 -2
- package/dist/ui/runtime.cjs +4 -0
- package/dist/ui/runtime.cjs.map +1 -1
- package/dist/ui/runtime.d.cts +2 -1
- package/dist/ui/runtime.d.cts.map +1 -1
- package/dist/ui/runtime.d.mts +2 -1
- package/dist/ui/runtime.d.mts.map +1 -1
- package/dist/ui/runtime.mjs +4 -1
- package/dist/ui/runtime.mjs.map +1 -1
- package/package.json +12 -4
- package/skills/dev-workflow/SKILL.md +105 -0
- package/skills/publish-sync/SKILL.md +130 -0
- package/src/app.ts +98 -204
- package/src/cli/upgrade.ts +20 -4
- package/src/components/dev-view.tsx +8 -3
- package/src/components/streaming-view.ts +7 -2
- package/src/config.ts +40 -8
- package/src/contract.ts +1 -0
- package/src/dev-logs.ts +8 -1
- package/src/dev-session.ts +56 -79
- package/src/host.ts +4 -3
- package/src/integrity.ts +96 -10
- package/src/mf.ts +42 -0
- package/src/orchestrator.ts +232 -411
- package/src/plugin.ts +48 -136
- package/src/service-descriptor.ts +258 -0
- package/src/types.ts +8 -1
- package/src/ui/runtime.ts +5 -0
- package/dist/process-registry.cjs +0 -120
- package/dist/process-registry.cjs.map +0 -1
- package/dist/process-registry.d.cts +0 -25
- package/dist/process-registry.d.cts.map +0 -1
- package/dist/process-registry.d.mts +0 -25
- package/dist/process-registry.d.mts.map +0 -1
- package/dist/process-registry.mjs +0 -119
- package/dist/process-registry.mjs.map +0 -1
- package/src/process-registry.ts +0 -154
package/dist/contract.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.mjs","names":[],"sources":["../src/contract.ts"],"sourcesContent":["import { oc, z } from \"./sdk\";\nimport { BosConfigSchema, SourceModeSchema } from \"./types\";\n\nexport const DevOptionsSchema = z.object({\n host: SourceModeSchema.default(\"local\"),\n ui: SourceModeSchema.default(\"local\"),\n api: SourceModeSchema.default(\"local\"),\n proxy: z.boolean().default(false),\n ssr: z.boolean().default(false),\n port: z.number().optional(),\n interactive: z.boolean().optional(),\n});\n\nexport const DevResultSchema = z.object({\n status: z.enum([\"started\", \"error\"]),\n description: z.string(),\n processes: z.array(z.string()),\n});\n\nexport const StartOptionsSchema = z.object({\n port: z.number().optional(),\n interactive: z.boolean().optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n env: z.enum([\"production\", \"staging\"]).default(\"production\"),\n});\n\nexport const StartResultSchema = z.object({\n status: z.enum([\"running\", \"error\"]),\n url: z.string(),\n});\n\nexport const BuildOptionsSchema = z.object({\n packages: z.string().default(\"all\"),\n force: z.boolean().default(false),\n deploy: z.boolean().default(false),\n});\n\nexport const BuildResultSchema = z.object({\n status: z.enum([\"success\", \"error\"]),\n built: z.array(z.string()),\n skipped: z.array(z.string()).optional(),\n deployed: z.boolean().optional(),\n});\n\nexport const ConfigResultSchema = z.object({\n config: BosConfigSchema.nullable(),\n packages: z.array(z.string()),\n remotes: z.array(z.string()),\n});\n\nexport const PluginAddOptionsSchema = z.object({\n source: z.string(),\n as: z.string().optional(),\n production: z.string().optional(),\n});\n\nexport const PluginAddResultSchema = z.object({\n status: z.enum([\"added\", \"error\"]),\n key: z.string(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n version: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const PluginRemoveOptionsSchema = z.object({\n key: z.string(),\n});\n\nexport const PluginRemoveResultSchema = z.object({\n status: z.enum([\"removed\", \"error\"]),\n key: z.string(),\n error: z.string().optional(),\n});\n\nexport const PluginListResultSchema = z.object({\n status: z.enum([\"listed\", \"error\"]),\n plugins: z.array(\n z.object({\n key: z.string(),\n development: z.string().optional(),\n production: z.string().optional(),\n localPath: z.string().optional(),\n source: z.enum([\"local\", \"remote\"]),\n integrity: z.string().optional(),\n version: z.string().optional(),\n name: z.string().optional(),\n }),\n ),\n error: z.string().optional(),\n});\n\nexport const PluginPublishOptionsSchema = z.object({\n key: z.string(),\n});\n\nexport const PluginPublishResultSchema = z.object({\n status: z.enum([\"published\", \"error\"]),\n key: z.string(),\n path: z.string().optional(),\n script: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n version: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const PublishOptionsSchema = z.object({\n deploy: z.boolean().default(false),\n dryRun: z.boolean().default(false),\n packages: z.string().default(\"all\"),\n network: z.enum([\"mainnet\", \"testnet\"]).optional(),\n privateKey: z.string().optional(),\n});\n\nexport const PublishResultSchema = z.object({\n status: z.enum([\"published\", \"error\", \"dry-run\"]),\n registryUrl: z.string(),\n txHash: z.string().optional(),\n error: z.string().optional(),\n built: z.array(z.string()).optional(),\n skipped: z.array(z.string()).optional(),\n});\n\nexport const KeyPublishOptionsSchema = z.object({\n allowance: z.string().default(\"0.25NEAR\"),\n});\n\nexport const KeyPublishResultSchema = z.object({\n status: z.enum([\"published\", \"error\"]),\n account: z.string(),\n network: z.enum([\"mainnet\", \"testnet\"]),\n contract: z.string(),\n allowance: z.string(),\n functionNames: z.array(z.string()),\n publicKey: z.string().optional(),\n privateKey: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const InitOptionsSchema = z.object({\n extends: z.string().optional(),\n extendsAccount: z.string().optional(),\n extendsGateway: z.string().optional(),\n directory: z.string().optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n source: z.string().optional(),\n plugins: z.array(z.string()).optional(),\n withHost: z.boolean().default(false),\n noInteractive: z.boolean().default(false),\n noInstall: z.boolean().default(false),\n});\n\nexport const InitResultSchema = z.object({\n status: z.enum([\"initialized\", \"error\"]),\n directory: z.string(),\n extendsAccount: z.string(),\n extendsGateway: z.string(),\n account: z.string().optional(),\n domain: z.string().optional(),\n extends: z.string(),\n plugins: z.array(z.string()).optional(),\n filesCopied: z.number(),\n error: z.string().optional(),\n});\n\nexport const SyncOptionsSchema = z.object({\n dryRun: z.boolean().default(false),\n force: z.boolean().default(false),\n noInstall: z.boolean().default(false),\n});\n\nexport const SyncResultSchema = z.object({\n status: z.enum([\"synced\", \"dry-run\", \"error\"]),\n updated: z.array(z.string()),\n skipped: z.array(z.string()),\n added: z.array(z.string()),\n error: z.string().optional(),\n});\n\nexport const UpgradeOptionsSchema = z.object({\n dryRun: z.boolean().default(false),\n force: z.boolean().default(false),\n noInstall: z.boolean().default(false),\n noSync: z.boolean().default(false),\n});\n\nexport const UpgradeResultSchema = z.object({\n status: z.enum([\"upgraded\", \"dry-run\", \"error\"]),\n packages: z.array(\n z.object({\n name: z.string(),\n from: z.string().optional(),\n to: z.string(),\n }),\n ),\n sync: SyncResultSchema.optional(),\n changelogUrl: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const StatusResultSchema = z.object({\n status: z.enum([\"ok\", \"error\"]),\n extends: z.string().optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n packages: z.array(\n z.object({\n name: z.string(),\n installed: z.string().optional(),\n latest: z.string().optional(),\n }),\n ),\n lastSync: z.string().optional(),\n envFile: z.enum([\"found\", \"missing\", \"example-only\"]),\n parentReachable: z.boolean().optional(),\n error: z.string().optional(),\n});\n\nexport const bosContract = oc.router({\n dev: oc.route({ method: \"POST\", path: \"/dev\" }).input(DevOptionsSchema).output(DevResultSchema),\n start: oc\n .route({ method: \"POST\", path: \"/start\" })\n .input(StartOptionsSchema)\n .output(StartResultSchema),\n build: oc\n .route({ method: \"POST\", path: \"/build\" })\n .input(BuildOptionsSchema)\n .output(BuildResultSchema),\n config: oc.route({ method: \"GET\", path: \"/config\" }).output(ConfigResultSchema),\n pluginAdd: oc\n .route({ method: \"POST\", path: \"/plugin/add\" })\n .input(PluginAddOptionsSchema)\n .output(PluginAddResultSchema),\n pluginRemove: oc\n .route({ method: \"POST\", path: \"/plugin/remove\" })\n .input(PluginRemoveOptionsSchema)\n .output(PluginRemoveResultSchema),\n pluginList: oc.route({ method: \"GET\", path: \"/plugin/list\" }).output(PluginListResultSchema),\n pluginPublish: oc\n .route({ method: \"POST\", path: \"/plugin/publish\" })\n .input(PluginPublishOptionsSchema)\n .output(PluginPublishResultSchema),\n publish: oc\n .route({ method: \"POST\", path: \"/publish\" })\n .input(PublishOptionsSchema)\n .output(PublishResultSchema),\n keyPublish: oc\n .route({ method: \"POST\", path: \"/key/publish\" })\n .input(KeyPublishOptionsSchema)\n .output(KeyPublishResultSchema),\n init: oc\n .route({ method: \"POST\", path: \"/init\" })\n .input(InitOptionsSchema)\n .output(InitResultSchema),\n sync: oc\n .route({ method: \"POST\", path: \"/sync\" })\n .input(SyncOptionsSchema)\n .output(SyncResultSchema),\n upgrade: oc\n .route({ method: \"POST\", path: \"/upgrade\" })\n .input(UpgradeOptionsSchema)\n .output(UpgradeResultSchema),\n status: oc.route({ method: \"GET\", path: \"/status\" }).output(StatusResultSchema),\n});\n\nexport type DevOptions = z.infer<typeof DevOptionsSchema>;\nexport type StartOptions = z.infer<typeof StartOptionsSchema>;\nexport type BuildOptions = z.infer<typeof BuildOptionsSchema>;\nexport type BosConfigResult = z.infer<typeof ConfigResultSchema>;\nexport type PluginAddOptions = z.infer<typeof PluginAddOptionsSchema>;\nexport type PluginAddResult = z.infer<typeof PluginAddResultSchema>;\nexport type PluginRemoveOptions = z.infer<typeof PluginRemoveOptionsSchema>;\nexport type PluginRemoveResult = z.infer<typeof PluginRemoveResultSchema>;\nexport type PluginListResult = z.infer<typeof PluginListResultSchema>;\nexport type PluginPublishOptions = z.infer<typeof PluginPublishOptionsSchema>;\nexport type PluginPublishResult = z.infer<typeof PluginPublishResultSchema>;\nexport type PublishOptions = z.infer<typeof PublishOptionsSchema>;\nexport type KeyPublishOptions = z.infer<typeof KeyPublishOptionsSchema>;\nexport type KeyPublishResult = z.infer<typeof KeyPublishResultSchema>;\nexport type InitOptions = z.infer<typeof InitOptionsSchema>;\nexport type InitResult = z.infer<typeof InitResultSchema>;\nexport type SyncOptions = z.infer<typeof SyncOptionsSchema>;\nexport type SyncResult = z.infer<typeof SyncResultSchema>;\nexport type UpgradeOptions = z.infer<typeof UpgradeOptionsSchema>;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EAAmB,CAAC,CAClD,MAAM,2BAA2B,CACjC,OAAO,0BAA0B;CACpC,SAAS,GACN,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAY,CAAC,CAC3C,MAAM,qBAAqB,CAC3B,OAAO,oBAAoB;CAC9B,YAAY,GACT,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAgB,CAAC,CAC/C,MAAM,wBAAwB,CAC9B,OAAO,uBAAuB;CACjC,MAAM,GACH,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAS,CAAC,CACxC,MAAM,kBAAkB,CACxB,OAAO,iBAAiB;CAC3B,MAAM,GACH,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAS,CAAC,CACxC,MAAM,kBAAkB,CACxB,OAAO,iBAAiB;CAC3B,SAAS,GACN,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAY,CAAC,CAC3C,MAAM,qBAAqB,CAC3B,OAAO,oBAAoB;CAC9B,QAAQ,GAAG,MAAM;EAAE,QAAQ;EAAO,MAAM;EAAW,CAAC,CAAC,OAAO,mBAAmB;CAChF,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.mjs","names":[],"sources":["../src/contract.ts"],"sourcesContent":["import { oc, z } from \"./sdk\";\nimport { BosConfigSchema, SourceModeSchema } from \"./types\";\n\nexport const DevOptionsSchema = z.object({\n host: SourceModeSchema.default(\"local\"),\n ui: SourceModeSchema.default(\"local\"),\n api: SourceModeSchema.default(\"local\"),\n auth: SourceModeSchema.default(\"local\"),\n proxy: z.boolean().default(false),\n ssr: z.boolean().default(false),\n port: z.number().optional(),\n interactive: z.boolean().optional(),\n});\n\nexport const DevResultSchema = z.object({\n status: z.enum([\"started\", \"error\"]),\n description: z.string(),\n processes: z.array(z.string()),\n});\n\nexport const StartOptionsSchema = z.object({\n port: z.number().optional(),\n interactive: z.boolean().optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n env: z.enum([\"production\", \"staging\"]).default(\"production\"),\n});\n\nexport const StartResultSchema = z.object({\n status: z.enum([\"running\", \"error\"]),\n url: z.string(),\n});\n\nexport const BuildOptionsSchema = z.object({\n packages: z.string().default(\"all\"),\n force: z.boolean().default(false),\n deploy: z.boolean().default(false),\n});\n\nexport const BuildResultSchema = z.object({\n status: z.enum([\"success\", \"error\"]),\n built: z.array(z.string()),\n skipped: z.array(z.string()).optional(),\n deployed: z.boolean().optional(),\n});\n\nexport const ConfigResultSchema = z.object({\n config: BosConfigSchema.nullable(),\n packages: z.array(z.string()),\n remotes: z.array(z.string()),\n});\n\nexport const PluginAddOptionsSchema = z.object({\n source: z.string(),\n as: z.string().optional(),\n production: z.string().optional(),\n});\n\nexport const PluginAddResultSchema = z.object({\n status: z.enum([\"added\", \"error\"]),\n key: z.string(),\n development: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n version: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const PluginRemoveOptionsSchema = z.object({\n key: z.string(),\n});\n\nexport const PluginRemoveResultSchema = z.object({\n status: z.enum([\"removed\", \"error\"]),\n key: z.string(),\n error: z.string().optional(),\n});\n\nexport const PluginListResultSchema = z.object({\n status: z.enum([\"listed\", \"error\"]),\n plugins: z.array(\n z.object({\n key: z.string(),\n development: z.string().optional(),\n production: z.string().optional(),\n localPath: z.string().optional(),\n source: z.enum([\"local\", \"remote\"]),\n integrity: z.string().optional(),\n version: z.string().optional(),\n name: z.string().optional(),\n }),\n ),\n error: z.string().optional(),\n});\n\nexport const PluginPublishOptionsSchema = z.object({\n key: z.string(),\n});\n\nexport const PluginPublishResultSchema = z.object({\n status: z.enum([\"published\", \"error\"]),\n key: z.string(),\n path: z.string().optional(),\n script: z.string().optional(),\n production: z.string().optional(),\n integrity: z.string().optional(),\n version: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const PublishOptionsSchema = z.object({\n deploy: z.boolean().default(false),\n dryRun: z.boolean().default(false),\n packages: z.string().default(\"all\"),\n network: z.enum([\"mainnet\", \"testnet\"]).optional(),\n privateKey: z.string().optional(),\n});\n\nexport const PublishResultSchema = z.object({\n status: z.enum([\"published\", \"error\", \"dry-run\"]),\n registryUrl: z.string(),\n txHash: z.string().optional(),\n error: z.string().optional(),\n built: z.array(z.string()).optional(),\n skipped: z.array(z.string()).optional(),\n});\n\nexport const KeyPublishOptionsSchema = z.object({\n allowance: z.string().default(\"0.25NEAR\"),\n});\n\nexport const KeyPublishResultSchema = z.object({\n status: z.enum([\"published\", \"error\"]),\n account: z.string(),\n network: z.enum([\"mainnet\", \"testnet\"]),\n contract: z.string(),\n allowance: z.string(),\n functionNames: z.array(z.string()),\n publicKey: z.string().optional(),\n privateKey: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const InitOptionsSchema = z.object({\n extends: z.string().optional(),\n extendsAccount: z.string().optional(),\n extendsGateway: z.string().optional(),\n directory: z.string().optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n source: z.string().optional(),\n plugins: z.array(z.string()).optional(),\n withHost: z.boolean().default(false),\n noInteractive: z.boolean().default(false),\n noInstall: z.boolean().default(false),\n});\n\nexport const InitResultSchema = z.object({\n status: z.enum([\"initialized\", \"error\"]),\n directory: z.string(),\n extendsAccount: z.string(),\n extendsGateway: z.string(),\n account: z.string().optional(),\n domain: z.string().optional(),\n extends: z.string(),\n plugins: z.array(z.string()).optional(),\n filesCopied: z.number(),\n error: z.string().optional(),\n});\n\nexport const SyncOptionsSchema = z.object({\n dryRun: z.boolean().default(false),\n force: z.boolean().default(false),\n noInstall: z.boolean().default(false),\n});\n\nexport const SyncResultSchema = z.object({\n status: z.enum([\"synced\", \"dry-run\", \"error\"]),\n updated: z.array(z.string()),\n skipped: z.array(z.string()),\n added: z.array(z.string()),\n error: z.string().optional(),\n});\n\nexport const UpgradeOptionsSchema = z.object({\n dryRun: z.boolean().default(false),\n force: z.boolean().default(false),\n noInstall: z.boolean().default(false),\n noSync: z.boolean().default(false),\n});\n\nexport const UpgradeResultSchema = z.object({\n status: z.enum([\"upgraded\", \"dry-run\", \"error\"]),\n packages: z.array(\n z.object({\n name: z.string(),\n from: z.string().optional(),\n to: z.string(),\n }),\n ),\n sync: SyncResultSchema.optional(),\n changelogUrl: z.string().optional(),\n error: z.string().optional(),\n});\n\nexport const StatusResultSchema = z.object({\n status: z.enum([\"ok\", \"error\"]),\n extends: z.string().optional(),\n account: z.string().optional(),\n domain: z.string().optional(),\n packages: z.array(\n z.object({\n name: z.string(),\n installed: z.string().optional(),\n latest: z.string().optional(),\n }),\n ),\n lastSync: z.string().optional(),\n envFile: z.enum([\"found\", \"missing\", \"example-only\"]),\n parentReachable: z.boolean().optional(),\n error: z.string().optional(),\n});\n\nexport const bosContract = oc.router({\n dev: oc.route({ method: \"POST\", path: \"/dev\" }).input(DevOptionsSchema).output(DevResultSchema),\n start: oc\n .route({ method: \"POST\", path: \"/start\" })\n .input(StartOptionsSchema)\n .output(StartResultSchema),\n build: oc\n .route({ method: \"POST\", path: \"/build\" })\n .input(BuildOptionsSchema)\n .output(BuildResultSchema),\n config: oc.route({ method: \"GET\", path: \"/config\" }).output(ConfigResultSchema),\n pluginAdd: oc\n .route({ method: \"POST\", path: \"/plugin/add\" })\n .input(PluginAddOptionsSchema)\n .output(PluginAddResultSchema),\n pluginRemove: oc\n .route({ method: \"POST\", path: \"/plugin/remove\" })\n .input(PluginRemoveOptionsSchema)\n .output(PluginRemoveResultSchema),\n pluginList: oc.route({ method: \"GET\", path: \"/plugin/list\" }).output(PluginListResultSchema),\n pluginPublish: oc\n .route({ method: \"POST\", path: \"/plugin/publish\" })\n .input(PluginPublishOptionsSchema)\n .output(PluginPublishResultSchema),\n publish: oc\n .route({ method: \"POST\", path: \"/publish\" })\n .input(PublishOptionsSchema)\n .output(PublishResultSchema),\n keyPublish: oc\n .route({ method: \"POST\", path: \"/key/publish\" })\n .input(KeyPublishOptionsSchema)\n .output(KeyPublishResultSchema),\n init: oc\n .route({ method: \"POST\", path: \"/init\" })\n .input(InitOptionsSchema)\n .output(InitResultSchema),\n sync: oc\n .route({ method: \"POST\", path: \"/sync\" })\n .input(SyncOptionsSchema)\n .output(SyncResultSchema),\n upgrade: oc\n .route({ method: \"POST\", path: \"/upgrade\" })\n .input(UpgradeOptionsSchema)\n .output(UpgradeResultSchema),\n status: oc.route({ method: \"GET\", path: \"/status\" }).output(StatusResultSchema),\n});\n\nexport type DevOptions = z.infer<typeof DevOptionsSchema>;\nexport type StartOptions = z.infer<typeof StartOptionsSchema>;\nexport type BuildOptions = z.infer<typeof BuildOptionsSchema>;\nexport type BosConfigResult = z.infer<typeof ConfigResultSchema>;\nexport type PluginAddOptions = z.infer<typeof PluginAddOptionsSchema>;\nexport type PluginAddResult = z.infer<typeof PluginAddResultSchema>;\nexport type PluginRemoveOptions = z.infer<typeof PluginRemoveOptionsSchema>;\nexport type PluginRemoveResult = z.infer<typeof PluginRemoveResultSchema>;\nexport type PluginListResult = z.infer<typeof PluginListResultSchema>;\nexport type PluginPublishOptions = z.infer<typeof PluginPublishOptionsSchema>;\nexport type PluginPublishResult = z.infer<typeof PluginPublishResultSchema>;\nexport type PublishOptions = z.infer<typeof PublishOptionsSchema>;\nexport type KeyPublishOptions = z.infer<typeof KeyPublishOptionsSchema>;\nexport type KeyPublishResult = z.infer<typeof KeyPublishResultSchema>;\nexport type InitOptions = z.infer<typeof InitOptionsSchema>;\nexport type InitResult = z.infer<typeof InitResultSchema>;\nexport type SyncOptions = z.infer<typeof SyncOptionsSchema>;\nexport type SyncResult = z.infer<typeof SyncResultSchema>;\nexport type UpgradeOptions = z.infer<typeof UpgradeOptionsSchema>;\nexport type UpgradeResult = z.infer<typeof UpgradeResultSchema>;\nexport type StatusResult = z.infer<typeof StatusResultSchema>;\n"],"mappings":";;;;AAGA,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,iBAAiB,QAAQ,QAAQ;CACvC,IAAI,iBAAiB,QAAQ,QAAQ;CACrC,KAAK,iBAAiB,QAAQ,QAAQ;CACtC,MAAM,iBAAiB,QAAQ,QAAQ;CACvC,OAAO,EAAE,SA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9B,OAAO,uBAAuB;CACjC,MAAM,GACH,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAS,CAAC,CACxC,MAAM,kBAAkB,CACxB,OAAO,iBAAiB;CAC3B,MAAM,GACH,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAS,CAAC,CACxC,MAAM,kBAAkB,CACxB,OAAO,iBAAiB;CAC3B,SAAS,GACN,MAAM;EAAE,QAAQ;EAAQ,MAAM;EAAY,CAAC,CAC3C,MAAM,qBAAqB,CAC3B,OAAO,oBAAoB;CAC9B,QAAQ,GAAG,MAAM;EAAE,QAAQ;EAAO,MAAM;EAAW,CAAC,CAAC,OAAO,mBAAmB;CAChF,CAAC"}
|
package/dist/dev-logs.cjs
CHANGED
|
@@ -4,6 +4,10 @@ let node_path = require("node:path");
|
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
|
|
6
6
|
//#region src/dev-logs.ts
|
|
7
|
+
const ESC = "\x1B";
|
|
8
|
+
const BEL = "\x07";
|
|
9
|
+
const ANSI_RE = new RegExp(`${ESC}\\[[0-?]*[ -/]*[@-~]|${ESC}\\][^${BEL}]*${BEL}`, "g");
|
|
10
|
+
const stripAnsi = (input) => input.replace(ANSI_RE, "");
|
|
7
11
|
function getBosDir(configDir) {
|
|
8
12
|
return (0, node_path.join)(configDir, ".bos");
|
|
9
13
|
}
|
|
@@ -13,7 +17,8 @@ function getLogsDir(configDir) {
|
|
|
13
17
|
function formatLogLine(entry) {
|
|
14
18
|
const ts = new Date(entry.timestamp).toISOString();
|
|
15
19
|
const prefix = entry.isError ? "ERR" : "OUT";
|
|
16
|
-
|
|
20
|
+
const clean = stripAnsi(entry.line);
|
|
21
|
+
return `[${ts}] [${entry.source}] [${prefix}] ${clean}`;
|
|
17
22
|
}
|
|
18
23
|
async function createDevLogger(configDir, description) {
|
|
19
24
|
const dir = getLogsDir(configDir);
|
|
@@ -49,5 +54,4 @@ async function createDevLogger(configDir, description) {
|
|
|
49
54
|
|
|
50
55
|
//#endregion
|
|
51
56
|
exports.createDevLogger = createDevLogger;
|
|
52
|
-
exports.getBosDir = getBosDir;
|
|
53
57
|
//# sourceMappingURL=dev-logs.cjs.map
|
package/dist/dev-logs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-logs.cjs","names":[],"sources":["../src/dev-logs.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { appendFile, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport interface LogEntry {\n timestamp: number;\n source: string;\n line: string;\n isError?: boolean;\n}\n\nexport interface DevLogger {\n logFile: string;\n latestFile: string;\n write: (entry: LogEntry) => Promise<void>;\n readLatest: (opts?: { tail?: number }) => Promise<string>;\n}\n\nexport function getBosDir(configDir: string): string {\n return join(configDir, \".bos\");\n}\n\nexport function getLogsDir(configDir: string): string {\n return join(getBosDir(configDir), \"logs\");\n}\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n return `[${ts}] [${entry.source}] [${prefix}] ${
|
|
1
|
+
{"version":3,"file":"dev-logs.cjs","names":[],"sources":["../src/dev-logs.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { appendFile, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nconst ESC = \"\\x1b\";\nconst BEL = \"\\x07\";\nconst ANSI_RE = new RegExp(`${ESC}\\\\[[0-?]*[ -/]*[@-~]|${ESC}\\\\][^${BEL}]*${BEL}`, \"g\");\n\nconst stripAnsi = (input: string): string => input.replace(ANSI_RE, \"\");\n\nexport interface LogEntry {\n timestamp: number;\n source: string;\n line: string;\n isError?: boolean;\n}\n\nexport interface DevLogger {\n logFile: string;\n latestFile: string;\n write: (entry: LogEntry) => Promise<void>;\n readLatest: (opts?: { tail?: number }) => Promise<string>;\n}\n\nexport function getBosDir(configDir: string): string {\n return join(configDir, \".bos\");\n}\n\nexport function getLogsDir(configDir: string): string {\n return join(getBosDir(configDir), \"logs\");\n}\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n const clean = stripAnsi(entry.line);\n return `[${ts}] [${entry.source}] [${prefix}] ${clean}`;\n}\n\nexport async function createDevLogger(configDir: string, description: string): Promise<DevLogger> {\n const dir = getLogsDir(configDir);\n if (!existsSync(dir)) {\n await mkdir(dir, { recursive: true });\n }\n\n const now = new Date();\n const ts = now.toISOString().replace(/[:.]/g, \"-\").slice(0, 19);\n const logFile = join(dir, `dev-${ts}.log`);\n const latestFile = join(dir, \"dev-latest.log\");\n\n const header =\n `# everything-dev dev session: ${description}\\n` + `# Started: ${now.toISOString()}\\n\\n`;\n // Overwrite each run so dev-latest.log is always actionable.\n await writeFile(logFile, header, \"utf8\");\n await writeFile(latestFile, header, \"utf8\");\n\n let chain = Promise.resolve();\n const enqueue = (fn: () => Promise<void>) => {\n chain = chain.then(fn, fn);\n return chain;\n };\n\n return {\n logFile,\n latestFile,\n write: (entry) =>\n enqueue(async () => {\n const line = `${formatLogLine(entry)}\\n`;\n await appendFile(logFile, line);\n await appendFile(latestFile, line);\n }),\n readLatest: async (opts) => {\n const text = await readFile(latestFile, \"utf8\").catch(() => \"\");\n const tail = opts?.tail;\n if (!tail || tail <= 0) return text;\n const lines = text.split(\"\\n\");\n return lines.slice(Math.max(0, lines.length - tail)).join(\"\\n\");\n },\n };\n}\n\nexport async function readDevLatestLog(\n configDir: string,\n opts?: { tail?: number },\n): Promise<string> {\n const latestFile = join(getLogsDir(configDir), \"dev-latest.log\");\n const text = await readFile(latestFile, \"utf8\").catch(() => \"\");\n const tail = opts?.tail;\n if (!tail || tail <= 0) return text;\n const lines = text.split(\"\\n\");\n return lines.slice(Math.max(0, lines.length - tail)).join(\"\\n\");\n}\n"],"mappings":";;;;;;AAIA,MAAM,MAAM;AACZ,MAAM,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CAAe,YAAY,OAAO,CAAC,YAAY,GAAG;GAC/D,MAAM,OAAO,MAAM;AACnB,OAAI,CAAC,QAAQ,QAAQ,EAAG,QAAO;GAC/B,MAAM,QAAQ,KAAK,MAAM,KAAK;AAC9B,UAAO,MAAM,MAAM,KAAK,IAAI,GAAG,MAAM,SAAS,KAAK,CAAC,CAAC,KAAK,KAAK;;EAElE"}
|
package/dist/dev-logs.mjs
CHANGED
|
@@ -3,6 +3,10 @@ import { join } from "node:path";
|
|
|
3
3
|
import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
|
|
5
5
|
//#region src/dev-logs.ts
|
|
6
|
+
const ESC = "\x1B";
|
|
7
|
+
const BEL = "\x07";
|
|
8
|
+
const ANSI_RE = new RegExp(`${ESC}\\[[0-?]*[ -/]*[@-~]|${ESC}\\][^${BEL}]*${BEL}`, "g");
|
|
9
|
+
const stripAnsi = (input) => input.replace(ANSI_RE, "");
|
|
6
10
|
function getBosDir(configDir) {
|
|
7
11
|
return join(configDir, ".bos");
|
|
8
12
|
}
|
|
@@ -12,7 +16,8 @@ function getLogsDir(configDir) {
|
|
|
12
16
|
function formatLogLine(entry) {
|
|
13
17
|
const ts = new Date(entry.timestamp).toISOString();
|
|
14
18
|
const prefix = entry.isError ? "ERR" : "OUT";
|
|
15
|
-
|
|
19
|
+
const clean = stripAnsi(entry.line);
|
|
20
|
+
return `[${ts}] [${entry.source}] [${prefix}] ${clean}`;
|
|
16
21
|
}
|
|
17
22
|
async function createDevLogger(configDir, description) {
|
|
18
23
|
const dir = getLogsDir(configDir);
|
|
@@ -47,5 +52,5 @@ async function createDevLogger(configDir, description) {
|
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
//#endregion
|
|
50
|
-
export { createDevLogger
|
|
55
|
+
export { createDevLogger };
|
|
51
56
|
//# sourceMappingURL=dev-logs.mjs.map
|
package/dist/dev-logs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-logs.mjs","names":[],"sources":["../src/dev-logs.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { appendFile, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nexport interface LogEntry {\n timestamp: number;\n source: string;\n line: string;\n isError?: boolean;\n}\n\nexport interface DevLogger {\n logFile: string;\n latestFile: string;\n write: (entry: LogEntry) => Promise<void>;\n readLatest: (opts?: { tail?: number }) => Promise<string>;\n}\n\nexport function getBosDir(configDir: string): string {\n return join(configDir, \".bos\");\n}\n\nexport function getLogsDir(configDir: string): string {\n return join(getBosDir(configDir), \"logs\");\n}\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n return `[${ts}] [${entry.source}] [${prefix}] ${
|
|
1
|
+
{"version":3,"file":"dev-logs.mjs","names":[],"sources":["../src/dev-logs.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { appendFile, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nconst ESC = \"\\x1b\";\nconst BEL = \"\\x07\";\nconst ANSI_RE = new RegExp(`${ESC}\\\\[[0-?]*[ -/]*[@-~]|${ESC}\\\\][^${BEL}]*${BEL}`, \"g\");\n\nconst stripAnsi = (input: string): string => input.replace(ANSI_RE, \"\");\n\nexport interface LogEntry {\n timestamp: number;\n source: string;\n line: string;\n isError?: boolean;\n}\n\nexport interface DevLogger {\n logFile: string;\n latestFile: string;\n write: (entry: LogEntry) => Promise<void>;\n readLatest: (opts?: { tail?: number }) => Promise<string>;\n}\n\nexport function getBosDir(configDir: string): string {\n return join(configDir, \".bos\");\n}\n\nexport function getLogsDir(configDir: string): string {\n return join(getBosDir(configDir), \"logs\");\n}\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n const clean = stripAnsi(entry.line);\n return `[${ts}] [${entry.source}] [${prefix}] ${clean}`;\n}\n\nexport async function createDevLogger(configDir: string, description: string): Promise<DevLogger> {\n const dir = getLogsDir(configDir);\n if (!existsSync(dir)) {\n await mkdir(dir, { recursive: true });\n }\n\n const now = new Date();\n const ts = now.toISOString().replace(/[:.]/g, \"-\").slice(0, 19);\n const logFile = join(dir, `dev-${ts}.log`);\n const latestFile = join(dir, \"dev-latest.log\");\n\n const header =\n `# everything-dev dev session: ${description}\\n` + `# Started: ${now.toISOString()}\\n\\n`;\n // Overwrite each run so dev-latest.log is always actionable.\n await writeFile(logFile, header, \"utf8\");\n await writeFile(latestFile, header, \"utf8\");\n\n let chain = Promise.resolve();\n const enqueue = (fn: () => Promise<void>) => {\n chain = chain.then(fn, fn);\n return chain;\n };\n\n return {\n logFile,\n latestFile,\n write: (entry) =>\n enqueue(async () => {\n const line = `${formatLogLine(entry)}\\n`;\n await appendFile(logFile, line);\n await appendFile(latestFile, line);\n }),\n readLatest: async (opts) => {\n const text = await readFile(latestFile, \"utf8\").catch(() => \"\");\n const tail = opts?.tail;\n if (!tail || tail <= 0) return text;\n const lines = text.split(\"\\n\");\n return lines.slice(Math.max(0, lines.length - tail)).join(\"\\n\");\n },\n };\n}\n\nexport async function readDevLatestLog(\n configDir: string,\n opts?: { tail?: number },\n): Promise<string> {\n const latestFile = join(getLogsDir(configDir), \"dev-latest.log\");\n const text = await readFile(latestFile, \"utf8\").catch(() => \"\");\n const tail = opts?.tail;\n if (!tail || tail <= 0) return text;\n const lines = text.split(\"\\n\");\n return lines.slice(Math.max(0, lines.length - tail)).join(\"\\n\");\n}\n"],"mappings":";;;;;AAIA,MAAM,MAAM;AACZ,MAAM,MAAM;AACZ,MAAM,UAAU,IAAI,OAAO,GAAG,IAAI,uBAAuB,IAAI,OAAO,IAAI,IAAI,OAAO,IAAI;AAEvF,MAAM,aAAa,UAA0B,MAAM,QAAQ,SAAS,GAAG;AAgBvE,SAAgB,UAAU,WAA2B;AACnD,QAAO,KAAK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;AAC9B,UAAO,MAAM,MAAM,KAAK,IAAI,GAAG,MAAM,SAAS,KAAK,CAAC,CAAC,KAAK,KAAK;;EAElE"}
|
package/dist/dev-session.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
2
|
const require_config = require('./config.cjs');
|
|
3
|
-
const require_orchestrator = require('./orchestrator.cjs');
|
|
4
3
|
const require_dev_view = require('./components/dev-view.cjs');
|
|
5
4
|
const require_streaming_view = require('./components/streaming-view.cjs');
|
|
6
5
|
const require_dev_logs = require('./dev-logs.cjs');
|
|
7
|
-
const
|
|
6
|
+
const require_service_descriptor = require('./service-descriptor.cjs');
|
|
7
|
+
const require_orchestrator = require('./orchestrator.cjs');
|
|
8
8
|
let effect = require("effect");
|
|
9
|
+
let _effect_platform_node = require("@effect/platform-node");
|
|
9
10
|
|
|
10
11
|
//#region src/dev-session.ts
|
|
11
12
|
const LOG_NOISE_PATTERNS = [
|
|
@@ -34,6 +35,7 @@ const isInteractiveSupported = () => {
|
|
|
34
35
|
const STARTUP_ORDER = [
|
|
35
36
|
"ui-ssr",
|
|
36
37
|
"ui",
|
|
38
|
+
"auth",
|
|
37
39
|
"api",
|
|
38
40
|
"plugin",
|
|
39
41
|
"host-build",
|
|
@@ -54,22 +56,11 @@ function formatLogLine(entry) {
|
|
|
54
56
|
const prefix = entry.isError ? "ERR" : "OUT";
|
|
55
57
|
return `[${ts}] [${entry.source}] [${prefix}] ${entry.line}`;
|
|
56
58
|
}
|
|
57
|
-
const scopedProcess = (pkg, env, callbacks, portOverride, bosConfig, runtimeConfig, registry) => effect.Effect.acquireRelease(require_orchestrator.makeDevProcess(pkg, env, callbacks, portOverride, bosConfig, runtimeConfig, registry), (handle) => handle.kill.pipe(effect.Effect.ignore));
|
|
58
59
|
const runDevSession = (orchestrator, onShutdownReady) => effect.Effect.gen(function* () {
|
|
59
60
|
const configDir = require_config.getProjectRoot();
|
|
61
|
+
const services = yield* require_service_descriptor.ServiceDescriptorMap;
|
|
60
62
|
const orderedPackages = sortByOrder(orchestrator.packages);
|
|
61
|
-
const initialProcesses =
|
|
62
|
-
const config = require_orchestrator.getProcessConfig(pkg, void 0, pkg === "host" ? orchestrator.port : void 0, orchestrator.bosConfig, orchestrator.runtimeConfig);
|
|
63
|
-
const source = pkg === "host" ? orchestrator.appConfig.host : pkg === "ui" ? orchestrator.appConfig.ui : pkg === "api" ? orchestrator.appConfig.api : void 0;
|
|
64
|
-
return {
|
|
65
|
-
name: pkg,
|
|
66
|
-
status: "pending",
|
|
67
|
-
port: config?.port ?? 0,
|
|
68
|
-
source
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
const registry = yield* require_process_registry.makeProcessRegistry(configDir);
|
|
72
|
-
yield* registry.killAll().pipe(effect.Effect.ignore);
|
|
63
|
+
const initialProcesses = require_orchestrator.getProcessStates(orderedPackages, services, orchestrator.port);
|
|
73
64
|
const logger = yield* effect.Effect.promise(() => require_dev_logs.createDevLogger(configDir, orchestrator.description));
|
|
74
65
|
const shutdown = yield* effect.Deferred.make();
|
|
75
66
|
onShutdownReady?.(() => {
|
|
@@ -101,8 +92,16 @@ const runDevSession = (orchestrator, onShutdownReady) => effect.Effect.gen(funct
|
|
|
101
92
|
}
|
|
102
93
|
};
|
|
103
94
|
const startProcess = (pkg) => {
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
return require_orchestrator.makeDevProcess(pkg, callbacks, pkg === "host" ? orchestrator.port : void 0).pipe(effect.Effect.tapError((err) => effect.Effect.sync(() => {
|
|
96
|
+
callbacks.onLog(pkg, `Failed to start: ${err}`, true);
|
|
97
|
+
callbacks.onStatus(pkg, "error");
|
|
98
|
+
})), effect.Effect.catchAll(() => effect.Effect.succeed({
|
|
99
|
+
name: pkg,
|
|
100
|
+
pid: void 0,
|
|
101
|
+
kill: effect.Effect.void,
|
|
102
|
+
waitForReady: effect.Effect.void,
|
|
103
|
+
waitForExit: effect.Effect.never
|
|
104
|
+
})));
|
|
106
105
|
};
|
|
107
106
|
const startGroup = (packages) => effect.Effect.forEach(packages, startProcess, { concurrency: "unbounded" });
|
|
108
107
|
const awaitReady = (pkg, handle) => effect.Effect.race(handle.waitForReady, effect.Effect.sleep("30 seconds").pipe(effect.Effect.andThen(effect.Effect.sync(() => {
|
|
@@ -120,7 +119,10 @@ const runDevSession = (orchestrator, onShutdownReady) => effect.Effect.gen(funct
|
|
|
120
119
|
handle,
|
|
121
120
|
pkg: hostPackages[index] ?? handle.name
|
|
122
121
|
})), ({ handle, pkg }) => awaitReady(pkg, handle), { concurrency: "unbounded" });
|
|
122
|
+
const allHandles = [...nonHostHandles, ...hostHandles];
|
|
123
123
|
yield* effect.Effect.addFinalizer(() => effect.Effect.gen(function* () {
|
|
124
|
+
yield* effect.Effect.forEach(allHandles, (h) => h.kill.pipe(effect.Effect.ignore), { concurrency: "unbounded" });
|
|
125
|
+
yield* effect.Effect.sleep("200 millis");
|
|
124
126
|
view?.unmount();
|
|
125
127
|
if (shouldExportLogs) {
|
|
126
128
|
console.log("\n");
|
|
@@ -137,11 +139,10 @@ const runDevSession = (orchestrator, onShutdownReady) => effect.Effect.gen(funct
|
|
|
137
139
|
console.log("═".repeat(70));
|
|
138
140
|
console.log("");
|
|
139
141
|
}
|
|
140
|
-
yield* registry.killAll(true).pipe(effect.Effect.ignore);
|
|
141
142
|
}));
|
|
142
143
|
yield* effect.Deferred.await(shutdown);
|
|
143
144
|
});
|
|
144
|
-
const
|
|
145
|
+
const runApp = (orchestrator, services, runtimeConfig) => {
|
|
145
146
|
let requestShutdown = null;
|
|
146
147
|
let signalCount = 0;
|
|
147
148
|
let forceExitTimer = null;
|
|
@@ -153,10 +154,10 @@ const startApp = (orchestrator) => {
|
|
|
153
154
|
requestShutdown = shutdown;
|
|
154
155
|
})).pipe(effect.Effect.catchAll((e) => effect.Effect.sync(() => {
|
|
155
156
|
if (e instanceof Error) {
|
|
156
|
-
console.error("App
|
|
157
|
+
console.error("App error:", e.message);
|
|
157
158
|
if (e.stack) console.error(e.stack);
|
|
158
|
-
} else console.error("App
|
|
159
|
-
})));
|
|
159
|
+
} else console.error("App error:", e);
|
|
160
|
+
})), effect.Effect.provide(require_service_descriptor.ServiceDescriptorMapLive(services)), effect.Effect.provide(require_service_descriptor.DevRuntimeConfigLive(runtimeConfig)), effect.Effect.provide(_effect_platform_node.NodeContext.layer));
|
|
160
161
|
const handleSignal = () => {
|
|
161
162
|
signalCount++;
|
|
162
163
|
if (signalCount > 1) {
|
|
@@ -164,7 +165,7 @@ const startApp = (orchestrator) => {
|
|
|
164
165
|
return;
|
|
165
166
|
}
|
|
166
167
|
console.log("\n[Dev] Shutting down...");
|
|
167
|
-
forceExitTimer = setTimeout(forceExit,
|
|
168
|
+
forceExitTimer = setTimeout(forceExit, 5e3);
|
|
168
169
|
requestShutdown?.();
|
|
169
170
|
};
|
|
170
171
|
process.on("SIGINT", handleSignal);
|
|
@@ -174,7 +175,10 @@ const startApp = (orchestrator) => {
|
|
|
174
175
|
process.exit(effect.Exit.isSuccess(exit) ? 0 : 0);
|
|
175
176
|
});
|
|
176
177
|
};
|
|
178
|
+
const devApp = runApp;
|
|
179
|
+
const startApp = runApp;
|
|
177
180
|
|
|
178
181
|
//#endregion
|
|
182
|
+
exports.devApp = devApp;
|
|
179
183
|
exports.startApp = startApp;
|
|
180
184
|
//# sourceMappingURL=dev-session.cjs.map
|
package/dist/dev-session.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-session.cjs","names":["Effect","makeDevProcess","getProjectRoot","getProcessConfig","makeProcessRegistry","createDevLogger","Deferred","renderDevView","renderStreamingView","Exit"],"sources":["../src/dev-session.ts"],"sourcesContent":["import { Deferred, Effect, Exit } from \"effect\";\nimport {\n type DevViewHandle,\n type LogEntry,\n type ProcessState,\n renderDevView,\n} from \"./components/dev-view\";\nimport { renderStreamingView } from \"./components/streaming-view\";\nimport { getProjectRoot } from \"./config\";\nimport { createDevLogger } from \"./dev-logs\";\nimport {\n getProcessConfig,\n makeDevProcess,\n type ProcessCallbacks,\n type ProcessHandle,\n} from \"./orchestrator\";\nimport { makeProcessRegistry, type ProcessRegistry } from \"./process-registry\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\n\nexport interface AppConfig {\n host: SourceMode;\n ui: SourceMode;\n api: SourceMode;\n proxy?: boolean;\n ssr?: boolean;\n}\n\nexport interface AppOrchestrator {\n packages: string[];\n env: Record<string, string>;\n description: string;\n appConfig: AppConfig;\n bosConfig: BosConfig;\n runtimeConfig: RuntimeConfig;\n port?: number;\n interactive?: boolean;\n noLogs?: boolean;\n}\n\nconst LOG_NOISE_PATTERNS = [\n /\\[ Federation Runtime \\] Version .* from (host|ui) of shared singleton module/,\n /Executing an Effect versioned \\d+\\.\\d+\\.\\d+ with a Runtime of version/,\n /you may want to dedupe the effect dependencies/,\n];\n\nconst SSR_LOG_ALLOWLIST = [\n /\\bready\\s+built in\\b/i,\n /\\bcompiled\\b.*successfully/i,\n /\\berror\\b/i,\n /\\bfailed\\b/i,\n /\\bexception\\b/i,\n];\n\nconst shouldDisplayLog = (source: string, line: string, isError?: boolean): boolean => {\n if (process.env.DEBUG === \"true\" || process.env.DEBUG === \"1\") return true;\n if (source === \"ui-ssr\") {\n if (isError) return true;\n return SSR_LOG_ALLOWLIST.some((pattern) => pattern.test(line));\n }\n return !LOG_NOISE_PATTERNS.some((pattern) => pattern.test(line));\n};\n\nconst isInteractiveSupported = (): boolean => {\n return process.stdin.isTTY === true && process.stdout.isTTY === true;\n};\n\nconst STARTUP_ORDER = [\"ui-ssr\", \"ui\", \"api\", \"plugin\", \"host-build\", \"host\"];\n\nconst sortByOrder = (packages: string[]): string[] => {\n return [...packages].sort((a, b) => {\n const aIdx = a.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(a);\n const bIdx = b.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(b);\n if (aIdx === -1 && bIdx === -1) return 0;\n if (aIdx === -1) return 1;\n if (bIdx === -1) return -1;\n return aIdx - bIdx;\n });\n};\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n return `[${ts}] [${entry.source}] [${prefix}] ${entry.line}`;\n}\n\nconst scopedProcess = (\n pkg: string,\n env: Record<string, string> | undefined,\n callbacks: ProcessCallbacks,\n portOverride: number | undefined,\n bosConfig: BosConfig | undefined,\n runtimeConfig: RuntimeConfig | undefined,\n registry: ProcessRegistry | undefined,\n) =>\n Effect.acquireRelease(\n makeDevProcess(pkg, env, callbacks, portOverride, bosConfig, runtimeConfig, registry),\n (handle) => handle.kill.pipe(Effect.ignore),\n );\n\nexport const runDevSession = (\n orchestrator: AppOrchestrator,\n onShutdownReady?: (requestShutdown: () => void) => void,\n) =>\n Effect.gen(function* () {\n const configDir = getProjectRoot();\n const orderedPackages = sortByOrder(orchestrator.packages);\n const initialProcesses: ProcessState[] = orderedPackages.map((pkg) => {\n const portOverride = pkg === \"host\" ? orchestrator.port : undefined;\n const config = getProcessConfig(\n pkg,\n undefined,\n portOverride,\n orchestrator.bosConfig,\n orchestrator.runtimeConfig,\n );\n const source =\n pkg === \"host\"\n ? orchestrator.appConfig.host\n : pkg === \"ui\"\n ? orchestrator.appConfig.ui\n : pkg === \"api\"\n ? orchestrator.appConfig.api\n : undefined;\n return {\n name: pkg,\n status: \"pending\" as const,\n port: config?.port ?? 0,\n source,\n };\n });\n\n const registry = yield* makeProcessRegistry(configDir);\n yield* registry.killAll().pipe(Effect.ignore);\n\n const logger = yield* Effect.promise(() =>\n createDevLogger(configDir, orchestrator.description),\n );\n\n const shutdown = yield* Deferred.make<void>();\n\n onShutdownReady?.(() => {\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n });\n\n const allLogs: LogEntry[] = [];\n let view: DevViewHandle | null = null;\n let shouldExportLogs = false;\n\n const requestShutdownAndExport = () => {\n shouldExportLogs = true;\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n };\n\n const useInteractive = orchestrator.interactive ?? isInteractiveSupported();\n view = useInteractive\n ? renderDevView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n requestShutdownAndExport,\n )\n : renderStreamingView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n );\n\n const callbacks: ProcessCallbacks = {\n onStatus: (name, status, message) => {\n view?.updateProcess(name, status, message);\n },\n onLog: (name, line, isError) => {\n const entry: LogEntry = {\n id: `${Date.now()}-${allLogs.length + 1}`,\n source: name,\n line,\n timestamp: Date.now(),\n isError,\n };\n allLogs.push(entry);\n if (shouldDisplayLog(name, line, isError)) {\n view?.addLog(name, line, isError);\n }\n if (!orchestrator.noLogs) {\n void logger.write(entry);\n }\n },\n };\n\n const startProcess = (pkg: string) => {\n const portOverride = pkg === \"host\" ? orchestrator.port : undefined;\n return scopedProcess(\n pkg,\n orchestrator.env,\n callbacks,\n portOverride,\n orchestrator.bosConfig,\n orchestrator.runtimeConfig,\n registry,\n );\n };\n\n const startGroup = (packages: string[]) =>\n Effect.forEach(packages, startProcess, { concurrency: \"unbounded\" });\n\n const awaitReady = (pkg: string, handle: ProcessHandle) =>\n Effect.race(\n handle.waitForReady,\n Effect.sleep(\"30 seconds\").pipe(\n Effect.andThen(\n Effect.sync(() => {\n callbacks.onLog(pkg, \"Timeout waiting for ready, continuing...\", true);\n }),\n ),\n ),\n );\n\n const nonHostPackages = orderedPackages.filter((pkg) => pkg !== \"host\");\n const hostPackages = orderedPackages.filter((pkg) => pkg === \"host\");\n\n const nonHostHandles = yield* startGroup(nonHostPackages);\n\n yield* Effect.forEach(\n nonHostHandles.map((handle, index) => ({\n handle,\n pkg: nonHostPackages[index] ?? handle.name,\n })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n const hostHandles = yield* startGroup(hostPackages);\n\n yield* Effect.forEach(\n hostHandles.map((handle, index) => ({ handle, pkg: hostPackages[index] ?? handle.name })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n yield* Effect.addFinalizer(() =>\n Effect.gen(function* () {\n view?.unmount();\n\n if (shouldExportLogs) {\n console.log(\"\\n\");\n console.log(\"═\".repeat(70));\n console.log(` SESSION LOGS: ${orchestrator.description}`);\n console.log(` Started: ${new Date(allLogs[0]?.timestamp || Date.now()).toISOString()}`);\n console.log(` Total entries: ${allLogs.length}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n for (const entry of allLogs) {\n console.log(formatLogLine(entry));\n }\n console.log(\"\");\n console.log(\"═\".repeat(70));\n console.log(` Full logs saved to: ${logger.logFile}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n }\n\n yield* registry.killAll(true).pipe(Effect.ignore);\n }),\n );\n\n yield* Deferred.await(shutdown);\n });\n\nexport const startApp = (orchestrator: AppOrchestrator) => {\n let requestShutdown: (() => void) | null = null;\n let signalCount = 0;\n let forceExitTimer: ReturnType<typeof setTimeout> | null = null;\n\n const forceExit = () => {\n console.log(\"\\n[Dev] Force exit\");\n process.exit(0);\n };\n\n const program = Effect.scoped(\n runDevSession(orchestrator, (shutdown) => {\n requestShutdown = shutdown;\n }),\n ).pipe(\n Effect.catchAll((e) =>\n Effect.sync(() => {\n if (e instanceof Error) {\n console.error(\"App server error:\", e.message);\n if (e.stack) console.error(e.stack);\n } else {\n console.error(\"App server error:\", e);\n }\n }),\n ),\n );\n\n const handleSignal = () => {\n signalCount++;\n if (signalCount > 1) {\n forceExit();\n return;\n }\n console.log(\"\\n[Dev] Shutting down...\");\n forceExitTimer = setTimeout(forceExit, 8000);\n requestShutdown?.();\n };\n\n process.on(\"SIGINT\", handleSignal);\n process.on(\"SIGTERM\", handleSignal);\n\n Effect.runPromiseExit(program).then((exit) => {\n if (forceExitTimer) clearTimeout(forceExitTimer);\n process.exit(Exit.isSuccess(exit) ? 0 : 0);\n });\n};\n"],"mappings":";;;;;;;;;;AAuCA,MAAM,qBAAqB;CACzB;CACA;CACA;CACD;AAED,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,oBAAoB,QAAgB,MAAc,YAA+B;AACrF,KAAI,QAAQ,IAAI,UAAU,UAAU,QAAQ,IAAI,UAAU,IAAK,QAAO;AACtE,KAAI,WAAW,UAAU;AACvB,MAAI,QAAS,QAAO;AACpB,SAAO,kBAAkB,MAAM,YAAY,QAAQ,KAAK,KAAK,CAAC;;AAEhE,QAAO,CAAC,mBAAmB,MAAM,YAAY,QAAQ,KAAK,KAAK,CAAC;;AAGlE,MAAM,+BAAwC;AAC5C,QAAO,QAAQ,MAAM,UAAU,QAAQ,QAAQ,OAAO,UAAU;;AAGlE,MAAM,gBAAgB;CAAC;CAAU;CAAM;CAAO;CAAU;CAAc;CAAO;AAE7E,MAAM,eAAe,aAAiC;AACpD,QAAO,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM;EAClC,MAAM,OAAO,EAAE,WAAW,UAAU,GAChC,cAAc,QAAQ,SAAS,GAC/B,cAAc,QAAQ,EAAE;EAC5B,MAAM,OAAO,EAAE,WAAW,UAAU,GAChC,cAAc,QAAQ,SAAS,GAC/B,cAAc,QAAQ,EAAE;AAC5B,MAAI,SAAS,MAAM,SAAS,GAAI,QAAO;AACvC,MAAI,SAAS,GAAI,QAAO;AACxB,MAAI,SAAS,GAAI,QAAO;AACxB,SAAO,OAAO;GACd;;AAGJ,SAAS,cAAc,OAAyB;CAC9C,MAAM,KAAK,IAAI,KAAK,MAAM,UAAU,CAAC,aAAa;CAClD,MAAM,SAAS,MAAM,UAAU,QAAQ;AACvC,QAAO,IAAI,GAAG,KAAK,MAAM,OAAO,KAAK,OAAO,IAAI,MAAM;;AAGx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qB,EAAE,QAAQ;AAC7C,OAAI,EAAE,MAAO,SAAQ,MAAM,EAAE,MAAM;QAEnC,SAAQ,MAAM,qBAAqB,EAAE;GAEvC,CACH,CACF;CAED,MAAM,qBAAqB;AACzB;AACA,MAAI,cAAc,GAAG;AACnB,cAAW;AACX;;AAEF,UAAQ,IAAI,2BAA2B;AACvC,mBAAiB,WAAW,WAAW,IAAK;AAC5C,qBAAmB;;AAGrB,SAAQ,GAAG,UAAU,aAAa;AAClC,SAAQ,GAAG,WAAW,aAAa;AAEnC,eAAO,eAAe,QAAQ,CAAC,MAAM,SAAS;AAC5C,MAAI,eAAgB,cAAa,eAAe;AAChD,UAAQ,KAAKS,YAAK,UAAU,KAAK,GAAG,IAAI,EAAE;GAC1C"}
|
|
1
|
+
{"version":3,"file":"dev-session.cjs","names":["Effect","getProjectRoot","ServiceDescriptorMap","getProcessStates","createDevLogger","Deferred","renderDevView","renderStreamingView","makeDevProcess","ServiceDescriptorMapLive","DevRuntimeConfigLive","NodeContext","Exit"],"sources":["../src/dev-session.ts"],"sourcesContent":["import { NodeContext } from \"@effect/platform-node\";\nimport { Deferred, Effect, Exit } from \"effect\";\nimport {\n type DevViewHandle,\n type LogEntry,\n type ProcessState,\n renderDevView,\n} from \"./components/dev-view\";\nimport { renderStreamingView } from \"./components/streaming-view\";\nimport { getProjectRoot } from \"./config\";\nimport { createDevLogger } from \"./dev-logs\";\nimport {\n getProcessStates,\n makeDevProcess,\n type ProcessCallbacks,\n type ProcessHandle,\n} from \"./orchestrator\";\nimport {\n type AppOrchestrator,\n DevRuntimeConfigLive,\n type ServiceDescriptor,\n ServiceDescriptorMap,\n ServiceDescriptorMapLive,\n} from \"./service-descriptor\";\nimport type { RuntimeConfig } from \"./types\";\n\nconst LOG_NOISE_PATTERNS = [\n /\\[ Federation Runtime \\] Version .* from (host|ui) of shared singleton module/,\n /Executing an Effect versioned \\d+\\.\\d+\\.\\d+ with a Runtime of version/,\n /you may want to dedupe the effect dependencies/,\n];\n\nconst SSR_LOG_ALLOWLIST = [\n /\\bready\\s+built in\\b/i,\n /\\bcompiled\\b.*successfully/i,\n /\\berror\\b/i,\n /\\bfailed\\b/i,\n /\\bexception\\b/i,\n];\n\nconst shouldDisplayLog = (source: string, line: string, isError?: boolean): boolean => {\n if (process.env.DEBUG === \"true\" || process.env.DEBUG === \"1\") return true;\n if (source === \"ui-ssr\") {\n if (isError) return true;\n return SSR_LOG_ALLOWLIST.some((pattern) => pattern.test(line));\n }\n return !LOG_NOISE_PATTERNS.some((pattern) => pattern.test(line));\n};\n\nconst isInteractiveSupported = (): boolean => {\n return process.stdin.isTTY === true && process.stdout.isTTY === true;\n};\n\nconst STARTUP_ORDER = [\"ui-ssr\", \"ui\", \"auth\", \"api\", \"plugin\", \"host-build\", \"host\"];\n\nconst sortByOrder = (packages: string[]): string[] => {\n return [...packages].sort((a, b) => {\n const aIdx = a.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(a);\n const bIdx = b.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(b);\n if (aIdx === -1 && bIdx === -1) return 0;\n if (aIdx === -1) return 1;\n if (bIdx === -1) return -1;\n return aIdx - bIdx;\n });\n};\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n return `[${ts}] [${entry.source}] [${prefix}] ${entry.line}`;\n}\n\nexport const runDevSession = (\n orchestrator: AppOrchestrator,\n onShutdownReady?: (requestShutdown: () => void) => void,\n) =>\n Effect.gen(function* () {\n const configDir = getProjectRoot();\n const services = yield* ServiceDescriptorMap;\n const orderedPackages = sortByOrder(orchestrator.packages);\n const initialProcesses: ProcessState[] = getProcessStates(\n orderedPackages,\n services,\n orchestrator.port,\n );\n\n const logger = yield* Effect.promise(() =>\n createDevLogger(configDir, orchestrator.description),\n );\n\n const shutdown = yield* Deferred.make<void>();\n\n onShutdownReady?.(() => {\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n });\n\n const allLogs: LogEntry[] = [];\n let view: DevViewHandle | null = null;\n let shouldExportLogs = false;\n\n const requestShutdownAndExport = () => {\n shouldExportLogs = true;\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n };\n\n const useInteractive = orchestrator.interactive ?? isInteractiveSupported();\n view = useInteractive\n ? renderDevView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n requestShutdownAndExport,\n )\n : renderStreamingView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n );\n\n const callbacks: ProcessCallbacks = {\n onStatus: (name, status, message) => {\n view?.updateProcess(name, status, message);\n },\n onLog: (name, line, isError) => {\n const entry: LogEntry = {\n id: `${Date.now()}-${allLogs.length + 1}`,\n source: name,\n line,\n timestamp: Date.now(),\n isError,\n };\n allLogs.push(entry);\n if (shouldDisplayLog(name, line, isError)) {\n view?.addLog(name, line, isError);\n }\n if (!orchestrator.noLogs) {\n void logger.write(entry);\n }\n },\n };\n\n const startProcess = (pkg: string) => {\n const portOverride = pkg === \"host\" ? orchestrator.port : undefined;\n return makeDevProcess(pkg, callbacks, portOverride).pipe(\n Effect.tapError((err) =>\n Effect.sync(() => {\n callbacks.onLog(pkg, `Failed to start: ${err}`, true);\n callbacks.onStatus(pkg, \"error\");\n }),\n ),\n Effect.catchAll(() =>\n Effect.succeed({\n name: pkg,\n pid: undefined,\n kill: Effect.void,\n waitForReady: Effect.void,\n waitForExit: Effect.never,\n } satisfies ProcessHandle),\n ),\n );\n };\n\n const startGroup = (packages: string[]) =>\n Effect.forEach(packages, startProcess, { concurrency: \"unbounded\" });\n\n const awaitReady = (pkg: string, handle: ProcessHandle) =>\n Effect.race(\n handle.waitForReady,\n Effect.sleep(\"30 seconds\").pipe(\n Effect.andThen(\n Effect.sync(() => {\n callbacks.onLog(pkg, \"Timeout waiting for ready, continuing...\", true);\n }),\n ),\n ),\n );\n\n const nonHostPackages = orderedPackages.filter((pkg) => pkg !== \"host\");\n const hostPackages = orderedPackages.filter((pkg) => pkg === \"host\");\n\n const nonHostHandles = yield* startGroup(nonHostPackages);\n\n yield* Effect.forEach(\n nonHostHandles.map((handle, index) => ({\n handle,\n pkg: nonHostPackages[index] ?? handle.name,\n })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n const hostHandles = yield* startGroup(hostPackages);\n\n yield* Effect.forEach(\n hostHandles.map((handle, index) => ({ handle, pkg: hostPackages[index] ?? handle.name })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n const allHandles = [...nonHostHandles, ...hostHandles];\n\n yield* Effect.addFinalizer(() =>\n Effect.gen(function* () {\n yield* Effect.forEach(allHandles, (h) => h.kill.pipe(Effect.ignore), {\n concurrency: \"unbounded\",\n });\n\n yield* Effect.sleep(\"200 millis\");\n\n view?.unmount();\n\n if (shouldExportLogs) {\n console.log(\"\\n\");\n console.log(\"═\".repeat(70));\n console.log(` SESSION LOGS: ${orchestrator.description}`);\n console.log(` Started: ${new Date(allLogs[0]?.timestamp || Date.now()).toISOString()}`);\n console.log(` Total entries: ${allLogs.length}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n for (const entry of allLogs) {\n console.log(formatLogLine(entry));\n }\n console.log(\"\");\n console.log(\"═\".repeat(70));\n console.log(` Full logs saved to: ${logger.logFile}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n }\n }),\n );\n\n yield* Deferred.await(shutdown);\n });\n\nconst runApp = (\n orchestrator: AppOrchestrator,\n services: Map<string, ServiceDescriptor>,\n runtimeConfig: RuntimeConfig,\n) => {\n let requestShutdown: (() => void) | null = null;\n let signalCount = 0;\n let forceExitTimer: ReturnType<typeof setTimeout> | null = null;\n\n const forceExit = () => {\n console.log(\"\\n[Dev] Force exit\");\n process.exit(0);\n };\n\n const program = Effect.scoped(\n runDevSession(orchestrator, (shutdown) => {\n requestShutdown = shutdown;\n }),\n ).pipe(\n Effect.catchAll((e) =>\n Effect.sync(() => {\n if (e instanceof Error) {\n console.error(\"App error:\", e.message);\n if (e.stack) console.error(e.stack);\n } else {\n console.error(\"App error:\", e);\n }\n }),\n ),\n Effect.provide(ServiceDescriptorMapLive(services)),\n Effect.provide(DevRuntimeConfigLive(runtimeConfig)),\n Effect.provide(NodeContext.layer),\n );\n\n const handleSignal = () => {\n signalCount++;\n if (signalCount > 1) {\n forceExit();\n return;\n }\n console.log(\"\\n[Dev] Shutting down...\");\n forceExitTimer = setTimeout(forceExit, 5000);\n requestShutdown?.();\n };\n\n process.on(\"SIGINT\", handleSignal);\n process.on(\"SIGTERM\", handleSignal);\n\n Effect.runPromiseExit(program).then((exit) => {\n if (forceExitTimer) clearTimeout(forceExitTimer);\n process.exit(Exit.isSuccess(exit) ? 0 : 0);\n });\n};\n\nexport const devApp = runApp;\n\nexport const startApp = runApp;\n"],"mappings":";;;;;;;;;;;AA0BA,MAAM,qBAAqB;CACzB;CACA;CACA;CACD;AAED,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,oBAAoB,QAAgB,MAAc,YAA+B;AACrF,KAAI,QAAQ,IAAI,UAAU,UAAU,QAAQ,IAAI,UAAU,IAAK,QAAO;AACtE,KAAI,WAAW,UAAU;AACvB,MAAI,QAAS,QAAO;AACpB,SAAO,kBAAkB,MAAM,YAAY,QAAQ,KAAK,KAAK,CAAC;;AAEhE,QAAO,CAAC,mBAAmB,MAAM,YAAY,QAAQ,KAAK,KAAK,CAAC;;AAGlE,MAAM,+BAAwC;AAC5C,QAAO,QAAQ,MAAM,UAAU,QAAQ,QAAQ,OAAO,UAAU;;AAGlE,MAAM,gBAAgB;CAAC;CAAU;CAAM;CAAQ;CAAO;CAAU;CAAc;CAAO;AAErF,MAAM,eAAe,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,IAAI,GAAG;;GAEjB,CACH;AAED,QAAOK,gBAAS,MAAM,SAAS;EAC/B;AAEJ,MAAM,UACJ,cACA,UACA,kBACG;CACH,IAAI,kBAAuC;CAC3C,IAAI,cAAc;CAClB,IAAI,iBAAuD;CAE3D,MAAM,kBAAkB;AACtB,UAAQ,IAAI,qBAAqB;AACjC,UAAQ,KAAK,EAAE;;CAGjB,MAAM,UAAUL,cAAO,OACrB,cAAc,eAAe,aAAa;AACxC,oBAAkB;GAClB,CACH,CAAC,KACAA,cAAO,UAAU,MACfA,cAAO,WAAW;AAChB,MAAI,aAAa,OAAO;AACtB,WAAQ,MAAM,cAAc,EAAE,QAAQ;AACtC,OAAI,EAAE,MAAO,SAAQ,MAAM,EAAE,MAAM;QAEnC,SAAQ,MAAM,cAAc,EAAE;GAEhC,CACH,EACDA,cAAO,QAAQS,oDAAyB,SAAS,CAAC,EAClDT,cAAO,QAAQU,gDAAqB,cAAc,CAAC,EACnDV,cAAO,QAAQW,kCAAY,MAAM,CAClC;CAED,MAAM,qBAAqB;AACzB;AACA,MAAI,cAAc,GAAG;AACnB,cAAW;AACX;;AAEF,UAAQ,IAAI,2BAA2B;AACvC,mBAAiB,WAAW,WAAW,IAAK;AAC5C,qBAAmB;;AAGrB,SAAQ,GAAG,UAAU,aAAa;AAClC,SAAQ,GAAG,WAAW,aAAa;AAEnC,eAAO,eAAe,QAAQ,CAAC,MAAM,SAAS;AAC5C,MAAI,eAAgB,cAAa,eAAe;AAChD,UAAQ,KAAKC,YAAK,UAAU,KAAK,GAAG,IAAI,EAAE;GAC1C;;AAGJ,MAAa,SAAS;AAEtB,MAAa,WAAW"}
|
package/dist/dev-session.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getProjectRoot } from "./config.mjs";
|
|
2
|
-
import { getProcessConfig, makeDevProcess } from "./orchestrator.mjs";
|
|
3
2
|
import { renderDevView } from "./components/dev-view.mjs";
|
|
4
3
|
import { renderStreamingView } from "./components/streaming-view.mjs";
|
|
5
4
|
import { createDevLogger } from "./dev-logs.mjs";
|
|
6
|
-
import {
|
|
5
|
+
import { DevRuntimeConfigLive, ServiceDescriptorMap, ServiceDescriptorMapLive } from "./service-descriptor.mjs";
|
|
6
|
+
import { getProcessStates, makeDevProcess } from "./orchestrator.mjs";
|
|
7
7
|
import { Deferred, Effect, Exit } from "effect";
|
|
8
|
+
import { NodeContext } from "@effect/platform-node";
|
|
8
9
|
|
|
9
10
|
//#region src/dev-session.ts
|
|
10
11
|
const LOG_NOISE_PATTERNS = [
|
|
@@ -33,6 +34,7 @@ const isInteractiveSupported = () => {
|
|
|
33
34
|
const STARTUP_ORDER = [
|
|
34
35
|
"ui-ssr",
|
|
35
36
|
"ui",
|
|
37
|
+
"auth",
|
|
36
38
|
"api",
|
|
37
39
|
"plugin",
|
|
38
40
|
"host-build",
|
|
@@ -53,22 +55,11 @@ function formatLogLine(entry) {
|
|
|
53
55
|
const prefix = entry.isError ? "ERR" : "OUT";
|
|
54
56
|
return `[${ts}] [${entry.source}] [${prefix}] ${entry.line}`;
|
|
55
57
|
}
|
|
56
|
-
const scopedProcess = (pkg, env, callbacks, portOverride, bosConfig, runtimeConfig, registry) => Effect.acquireRelease(makeDevProcess(pkg, env, callbacks, portOverride, bosConfig, runtimeConfig, registry), (handle) => handle.kill.pipe(Effect.ignore));
|
|
57
58
|
const runDevSession = (orchestrator, onShutdownReady) => Effect.gen(function* () {
|
|
58
59
|
const configDir = getProjectRoot();
|
|
60
|
+
const services = yield* ServiceDescriptorMap;
|
|
59
61
|
const orderedPackages = sortByOrder(orchestrator.packages);
|
|
60
|
-
const initialProcesses = orderedPackages.
|
|
61
|
-
const config = getProcessConfig(pkg, void 0, pkg === "host" ? orchestrator.port : void 0, orchestrator.bosConfig, orchestrator.runtimeConfig);
|
|
62
|
-
const source = pkg === "host" ? orchestrator.appConfig.host : pkg === "ui" ? orchestrator.appConfig.ui : pkg === "api" ? orchestrator.appConfig.api : void 0;
|
|
63
|
-
return {
|
|
64
|
-
name: pkg,
|
|
65
|
-
status: "pending",
|
|
66
|
-
port: config?.port ?? 0,
|
|
67
|
-
source
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
const registry = yield* makeProcessRegistry(configDir);
|
|
71
|
-
yield* registry.killAll().pipe(Effect.ignore);
|
|
62
|
+
const initialProcesses = getProcessStates(orderedPackages, services, orchestrator.port);
|
|
72
63
|
const logger = yield* Effect.promise(() => createDevLogger(configDir, orchestrator.description));
|
|
73
64
|
const shutdown = yield* Deferred.make();
|
|
74
65
|
onShutdownReady?.(() => {
|
|
@@ -100,8 +91,16 @@ const runDevSession = (orchestrator, onShutdownReady) => Effect.gen(function* ()
|
|
|
100
91
|
}
|
|
101
92
|
};
|
|
102
93
|
const startProcess = (pkg) => {
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
return makeDevProcess(pkg, callbacks, pkg === "host" ? orchestrator.port : void 0).pipe(Effect.tapError((err) => Effect.sync(() => {
|
|
95
|
+
callbacks.onLog(pkg, `Failed to start: ${err}`, true);
|
|
96
|
+
callbacks.onStatus(pkg, "error");
|
|
97
|
+
})), Effect.catchAll(() => Effect.succeed({
|
|
98
|
+
name: pkg,
|
|
99
|
+
pid: void 0,
|
|
100
|
+
kill: Effect.void,
|
|
101
|
+
waitForReady: Effect.void,
|
|
102
|
+
waitForExit: Effect.never
|
|
103
|
+
})));
|
|
105
104
|
};
|
|
106
105
|
const startGroup = (packages) => Effect.forEach(packages, startProcess, { concurrency: "unbounded" });
|
|
107
106
|
const awaitReady = (pkg, handle) => Effect.race(handle.waitForReady, Effect.sleep("30 seconds").pipe(Effect.andThen(Effect.sync(() => {
|
|
@@ -119,7 +118,10 @@ const runDevSession = (orchestrator, onShutdownReady) => Effect.gen(function* ()
|
|
|
119
118
|
handle,
|
|
120
119
|
pkg: hostPackages[index] ?? handle.name
|
|
121
120
|
})), ({ handle, pkg }) => awaitReady(pkg, handle), { concurrency: "unbounded" });
|
|
121
|
+
const allHandles = [...nonHostHandles, ...hostHandles];
|
|
122
122
|
yield* Effect.addFinalizer(() => Effect.gen(function* () {
|
|
123
|
+
yield* Effect.forEach(allHandles, (h) => h.kill.pipe(Effect.ignore), { concurrency: "unbounded" });
|
|
124
|
+
yield* Effect.sleep("200 millis");
|
|
123
125
|
view?.unmount();
|
|
124
126
|
if (shouldExportLogs) {
|
|
125
127
|
console.log("\n");
|
|
@@ -136,11 +138,10 @@ const runDevSession = (orchestrator, onShutdownReady) => Effect.gen(function* ()
|
|
|
136
138
|
console.log("═".repeat(70));
|
|
137
139
|
console.log("");
|
|
138
140
|
}
|
|
139
|
-
yield* registry.killAll(true).pipe(Effect.ignore);
|
|
140
141
|
}));
|
|
141
142
|
yield* Deferred.await(shutdown);
|
|
142
143
|
});
|
|
143
|
-
const
|
|
144
|
+
const runApp = (orchestrator, services, runtimeConfig) => {
|
|
144
145
|
let requestShutdown = null;
|
|
145
146
|
let signalCount = 0;
|
|
146
147
|
let forceExitTimer = null;
|
|
@@ -152,10 +153,10 @@ const startApp = (orchestrator) => {
|
|
|
152
153
|
requestShutdown = shutdown;
|
|
153
154
|
})).pipe(Effect.catchAll((e) => Effect.sync(() => {
|
|
154
155
|
if (e instanceof Error) {
|
|
155
|
-
console.error("App
|
|
156
|
+
console.error("App error:", e.message);
|
|
156
157
|
if (e.stack) console.error(e.stack);
|
|
157
|
-
} else console.error("App
|
|
158
|
-
})));
|
|
158
|
+
} else console.error("App error:", e);
|
|
159
|
+
})), Effect.provide(ServiceDescriptorMapLive(services)), Effect.provide(DevRuntimeConfigLive(runtimeConfig)), Effect.provide(NodeContext.layer));
|
|
159
160
|
const handleSignal = () => {
|
|
160
161
|
signalCount++;
|
|
161
162
|
if (signalCount > 1) {
|
|
@@ -163,7 +164,7 @@ const startApp = (orchestrator) => {
|
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
166
|
console.log("\n[Dev] Shutting down...");
|
|
166
|
-
forceExitTimer = setTimeout(forceExit,
|
|
167
|
+
forceExitTimer = setTimeout(forceExit, 5e3);
|
|
167
168
|
requestShutdown?.();
|
|
168
169
|
};
|
|
169
170
|
process.on("SIGINT", handleSignal);
|
|
@@ -173,7 +174,9 @@ const startApp = (orchestrator) => {
|
|
|
173
174
|
process.exit(Exit.isSuccess(exit) ? 0 : 0);
|
|
174
175
|
});
|
|
175
176
|
};
|
|
177
|
+
const devApp = runApp;
|
|
178
|
+
const startApp = runApp;
|
|
176
179
|
|
|
177
180
|
//#endregion
|
|
178
|
-
export { startApp };
|
|
181
|
+
export { devApp, startApp };
|
|
179
182
|
//# sourceMappingURL=dev-session.mjs.map
|
package/dist/dev-session.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-session.mjs","names":[],"sources":["../src/dev-session.ts"],"sourcesContent":["import { Deferred, Effect, Exit } from \"effect\";\nimport {\n type DevViewHandle,\n type LogEntry,\n type ProcessState,\n renderDevView,\n} from \"./components/dev-view\";\nimport { renderStreamingView } from \"./components/streaming-view\";\nimport { getProjectRoot } from \"./config\";\nimport { createDevLogger } from \"./dev-logs\";\nimport {\n getProcessConfig,\n makeDevProcess,\n type ProcessCallbacks,\n type ProcessHandle,\n} from \"./orchestrator\";\nimport { makeProcessRegistry, type ProcessRegistry } from \"./process-registry\";\nimport type { BosConfig, RuntimeConfig, SourceMode } from \"./types\";\n\nexport interface AppConfig {\n host: SourceMode;\n ui: SourceMode;\n api: SourceMode;\n proxy?: boolean;\n ssr?: boolean;\n}\n\nexport interface AppOrchestrator {\n packages: string[];\n env: Record<string, string>;\n description: string;\n appConfig: AppConfig;\n bosConfig: BosConfig;\n runtimeConfig: RuntimeConfig;\n port?: number;\n interactive?: boolean;\n noLogs?: boolean;\n}\n\nconst LOG_NOISE_PATTERNS = [\n /\\[ Federation Runtime \\] Version .* from (host|ui) of shared singleton module/,\n /Executing an Effect versioned \\d+\\.\\d+\\.\\d+ with a Runtime of version/,\n /you may want to dedupe the effect dependencies/,\n];\n\nconst SSR_LOG_ALLOWLIST = [\n /\\bready\\s+built in\\b/i,\n /\\bcompiled\\b.*successfully/i,\n /\\berror\\b/i,\n /\\bfailed\\b/i,\n /\\bexception\\b/i,\n];\n\nconst shouldDisplayLog = (source: string, line: string, isError?: boolean): boolean => {\n if (process.env.DEBUG === \"true\" || process.env.DEBUG === \"1\") return true;\n if (source === \"ui-ssr\") {\n if (isError) return true;\n return SSR_LOG_ALLOWLIST.some((pattern) => pattern.test(line));\n }\n return !LOG_NOISE_PATTERNS.some((pattern) => pattern.test(line));\n};\n\nconst isInteractiveSupported = (): boolean => {\n return process.stdin.isTTY === true && process.stdout.isTTY === true;\n};\n\nconst STARTUP_ORDER = [\"ui-ssr\", \"ui\", \"api\", \"plugin\", \"host-build\", \"host\"];\n\nconst sortByOrder = (packages: string[]): string[] => {\n return [...packages].sort((a, b) => {\n const aIdx = a.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(a);\n const bIdx = b.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(b);\n if (aIdx === -1 && bIdx === -1) return 0;\n if (aIdx === -1) return 1;\n if (bIdx === -1) return -1;\n return aIdx - bIdx;\n });\n};\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n return `[${ts}] [${entry.source}] [${prefix}] ${entry.line}`;\n}\n\nconst scopedProcess = (\n pkg: string,\n env: Record<string, string> | undefined,\n callbacks: ProcessCallbacks,\n portOverride: number | undefined,\n bosConfig: BosConfig | undefined,\n runtimeConfig: RuntimeConfig | undefined,\n registry: ProcessRegistry | undefined,\n) =>\n Effect.acquireRelease(\n makeDevProcess(pkg, env, callbacks, portOverride, bosConfig, runtimeConfig, registry),\n (handle) => handle.kill.pipe(Effect.ignore),\n );\n\nexport const runDevSession = (\n orchestrator: AppOrchestrator,\n onShutdownReady?: (requestShutdown: () => void) => void,\n) =>\n Effect.gen(function* () {\n const configDir = getProjectRoot();\n const orderedPackages = sortByOrder(orchestrator.packages);\n const initialProcesses: ProcessState[] = orderedPackages.map((pkg) => {\n const portOverride = pkg === \"host\" ? orchestrator.port : undefined;\n const config = getProcessConfig(\n pkg,\n undefined,\n portOverride,\n orchestrator.bosConfig,\n orchestrator.runtimeConfig,\n );\n const source =\n pkg === \"host\"\n ? orchestrator.appConfig.host\n : pkg === \"ui\"\n ? orchestrator.appConfig.ui\n : pkg === \"api\"\n ? orchestrator.appConfig.api\n : undefined;\n return {\n name: pkg,\n status: \"pending\" as const,\n port: config?.port ?? 0,\n source,\n };\n });\n\n const registry = yield* makeProcessRegistry(configDir);\n yield* registry.killAll().pipe(Effect.ignore);\n\n const logger = yield* Effect.promise(() =>\n createDevLogger(configDir, orchestrator.description),\n );\n\n const shutdown = yield* Deferred.make<void>();\n\n onShutdownReady?.(() => {\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n });\n\n const allLogs: LogEntry[] = [];\n let view: DevViewHandle | null = null;\n let shouldExportLogs = false;\n\n const requestShutdownAndExport = () => {\n shouldExportLogs = true;\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n };\n\n const useInteractive = orchestrator.interactive ?? isInteractiveSupported();\n view = useInteractive\n ? renderDevView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n requestShutdownAndExport,\n )\n : renderStreamingView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n );\n\n const callbacks: ProcessCallbacks = {\n onStatus: (name, status, message) => {\n view?.updateProcess(name, status, message);\n },\n onLog: (name, line, isError) => {\n const entry: LogEntry = {\n id: `${Date.now()}-${allLogs.length + 1}`,\n source: name,\n line,\n timestamp: Date.now(),\n isError,\n };\n allLogs.push(entry);\n if (shouldDisplayLog(name, line, isError)) {\n view?.addLog(name, line, isError);\n }\n if (!orchestrator.noLogs) {\n void logger.write(entry);\n }\n },\n };\n\n const startProcess = (pkg: string) => {\n const portOverride = pkg === \"host\" ? orchestrator.port : undefined;\n return scopedProcess(\n pkg,\n orchestrator.env,\n callbacks,\n portOverride,\n orchestrator.bosConfig,\n orchestrator.runtimeConfig,\n registry,\n );\n };\n\n const startGroup = (packages: string[]) =>\n Effect.forEach(packages, startProcess, { concurrency: \"unbounded\" });\n\n const awaitReady = (pkg: string, handle: ProcessHandle) =>\n Effect.race(\n handle.waitForReady,\n Effect.sleep(\"30 seconds\").pipe(\n Effect.andThen(\n Effect.sync(() => {\n callbacks.onLog(pkg, \"Timeout waiting for ready, continuing...\", true);\n }),\n ),\n ),\n );\n\n const nonHostPackages = orderedPackages.filter((pkg) => pkg !== \"host\");\n const hostPackages = orderedPackages.filter((pkg) => pkg === \"host\");\n\n const nonHostHandles = yield* startGroup(nonHostPackages);\n\n yield* Effect.forEach(\n nonHostHandles.map((handle, index) => ({\n handle,\n pkg: nonHostPackages[index] ?? handle.name,\n })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n const hostHandles = yield* startGroup(hostPackages);\n\n yield* Effect.forEach(\n hostHandles.map((handle, index) => ({ handle, pkg: hostPackages[index] ?? handle.name })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n yield* Effect.addFinalizer(() =>\n Effect.gen(function* () {\n view?.unmount();\n\n if (shouldExportLogs) {\n console.log(\"\\n\");\n console.log(\"═\".repeat(70));\n console.log(` SESSION LOGS: ${orchestrator.description}`);\n console.log(` Started: ${new Date(allLogs[0]?.timestamp || Date.now()).toISOString()}`);\n console.log(` Total entries: ${allLogs.length}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n for (const entry of allLogs) {\n console.log(formatLogLine(entry));\n }\n console.log(\"\");\n console.log(\"═\".repeat(70));\n console.log(` Full logs saved to: ${logger.logFile}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n }\n\n yield* registry.killAll(true).pipe(Effect.ignore);\n }),\n );\n\n yield* Deferred.await(shutdown);\n });\n\nexport const startApp = (orchestrator: AppOrchestrator) => {\n let requestShutdown: (() => void) | null = null;\n let signalCount = 0;\n let forceExitTimer: ReturnType<typeof setTimeout> | null = null;\n\n const forceExit = () => {\n console.log(\"\\n[Dev] Force exit\");\n process.exit(0);\n };\n\n const program = Effect.scoped(\n runDevSession(orchestrator, (shutdown) => {\n requestShutdown = shutdown;\n }),\n ).pipe(\n Effect.catchAll((e) =>\n Effect.sync(() => {\n if (e instanceof Error) {\n console.error(\"App server error:\", e.message);\n if (e.stack) console.error(e.stack);\n } else {\n console.error(\"App server error:\", e);\n }\n }),\n ),\n );\n\n const handleSignal = () => {\n signalCount++;\n if (signalCount > 1) {\n forceExit();\n return;\n }\n console.log(\"\\n[Dev] Shutting down...\");\n forceExitTimer = setTimeout(forceExit, 8000);\n requestShutdown?.();\n };\n\n process.on(\"SIGINT\", handleSignal);\n process.on(\"SIGTERM\", handleSignal);\n\n Effect.runPromiseExit(program).then((exit) => {\n if (forceExitTimer) clearTimeout(forceExitTimer);\n process.exit(Exit.isSuccess(exit) ? 0 : 0);\n });\n};\n"],"mappings":";;;;;;;;;AAuCA,MAAM,qBAAqB;CACzB;CACA;CACA;CACD;AAED,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,oBAAoB,QAAgB,MAAc,YAA+B;AACrF,KAAI,QAAQ,IAAI,UAAU,UAAU,QAAQ,IAAI,UAAU,IAAK,QAAO;AACtE,KAAI,WAAW,UAAU;AACvB,MAAI,QAAS,QAAO;AACpB,SAAO,kBAAkB,MAAM,YAAY,QAAQ,KAAK,KAAK,CAAC;;AAEhE,QAAO,CAAC,mBAAmB,MAAM,YAAY,QAAQ,KAAK,KAAK,CAAC;;AAGlE,MAAM,+BAAwC;AAC5C,QAAO,QAAQ,MAAM,UAAU,QAAQ,QAAQ,OA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AQ,IAAI,GAAG;AACf,WAAQ,IAAI,IAAI,OAAO,GAAG,CAAC;AAC3B,WAAQ,IAAI,yBAAyB,OAAO,UAAU;AACtD,WAAQ,IAAI,IAAI,OAAO,GAAG,CAAC;AAC3B,WAAQ,IAAI,GAAG;;AAGjB,SAAO,SAAS,QAAQ,KAAK,CAAC,KAAK,OAAO,OAAO;GACjD,CACH;AAED,QAAO,SAAS,MAAM,SAAS;EAC/B;AAEJ,MAAa,YAAY,iBAAkC;CACzD,IAAI,kBAAuC;CAC3C,IAAI,cAAc;CAClB,IAAI,iBAAuD;CAE3D,MAAM,kBAAkB;AACtB,UAAQ,IAAI,qBAAqB;AACjC,UAAQ,KAAK,EAAE;;CAGjB,MAAM,UAAU,OAAO,OACrB,cAAc,eAAe,aAAa;AACxC,oBAAkB;GAClB,CACH,CAAC,KACA,OAAO,UAAU,MACf,OAAO,WAAW;AAChB,MAAI,aAAa,OAAO;AACtB,WAAQ,MAAM,qBAAqB,EAAE,QAAQ;AAC7C,OAAI,EAAE,MAAO,SAAQ,MAAM,EAAE,MAAM;QAEnC,SAAQ,MAAM,qBAAqB,EAAE;GAEvC,CACH,CACF;CAED,MAAM,qBAAqB;AACzB;AACA,MAAI,cAAc,GAAG;AACnB,cAAW;AACX;;AAEF,UAAQ,IAAI,2BAA2B;AACvC,mBAAiB,WAAW,WAAW,IAAK;AAC5C,qBAAmB;;AAGrB,SAAQ,GAAG,UAAU,aAAa;AAClC,SAAQ,GAAG,WAAW,aAAa;AAEnC,QAAO,eAAe,QAAQ,CAAC,MAAM,SAAS;AAC5C,MAAI,eAAgB,cAAa,eAAe;AAChD,UAAQ,KAAK,KAAK,UAAU,KAAK,GAAG,IAAI,EAAE;GAC1C"}
|
|
1
|
+
{"version":3,"file":"dev-session.mjs","names":[],"sources":["../src/dev-session.ts"],"sourcesContent":["import { NodeContext } from \"@effect/platform-node\";\nimport { Deferred, Effect, Exit } from \"effect\";\nimport {\n type DevViewHandle,\n type LogEntry,\n type ProcessState,\n renderDevView,\n} from \"./components/dev-view\";\nimport { renderStreamingView } from \"./components/streaming-view\";\nimport { getProjectRoot } from \"./config\";\nimport { createDevLogger } from \"./dev-logs\";\nimport {\n getProcessStates,\n makeDevProcess,\n type ProcessCallbacks,\n type ProcessHandle,\n} from \"./orchestrator\";\nimport {\n type AppOrchestrator,\n DevRuntimeConfigLive,\n type ServiceDescriptor,\n ServiceDescriptorMap,\n ServiceDescriptorMapLive,\n} from \"./service-descriptor\";\nimport type { RuntimeConfig } from \"./types\";\n\nconst LOG_NOISE_PATTERNS = [\n /\\[ Federation Runtime \\] Version .* from (host|ui) of shared singleton module/,\n /Executing an Effect versioned \\d+\\.\\d+\\.\\d+ with a Runtime of version/,\n /you may want to dedupe the effect dependencies/,\n];\n\nconst SSR_LOG_ALLOWLIST = [\n /\\bready\\s+built in\\b/i,\n /\\bcompiled\\b.*successfully/i,\n /\\berror\\b/i,\n /\\bfailed\\b/i,\n /\\bexception\\b/i,\n];\n\nconst shouldDisplayLog = (source: string, line: string, isError?: boolean): boolean => {\n if (process.env.DEBUG === \"true\" || process.env.DEBUG === \"1\") return true;\n if (source === \"ui-ssr\") {\n if (isError) return true;\n return SSR_LOG_ALLOWLIST.some((pattern) => pattern.test(line));\n }\n return !LOG_NOISE_PATTERNS.some((pattern) => pattern.test(line));\n};\n\nconst isInteractiveSupported = (): boolean => {\n return process.stdin.isTTY === true && process.stdout.isTTY === true;\n};\n\nconst STARTUP_ORDER = [\"ui-ssr\", \"ui\", \"auth\", \"api\", \"plugin\", \"host-build\", \"host\"];\n\nconst sortByOrder = (packages: string[]): string[] => {\n return [...packages].sort((a, b) => {\n const aIdx = a.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(a);\n const bIdx = b.startsWith(\"plugin:\")\n ? STARTUP_ORDER.indexOf(\"plugin\")\n : STARTUP_ORDER.indexOf(b);\n if (aIdx === -1 && bIdx === -1) return 0;\n if (aIdx === -1) return 1;\n if (bIdx === -1) return -1;\n return aIdx - bIdx;\n });\n};\n\nfunction formatLogLine(entry: LogEntry): string {\n const ts = new Date(entry.timestamp).toISOString();\n const prefix = entry.isError ? \"ERR\" : \"OUT\";\n return `[${ts}] [${entry.source}] [${prefix}] ${entry.line}`;\n}\n\nexport const runDevSession = (\n orchestrator: AppOrchestrator,\n onShutdownReady?: (requestShutdown: () => void) => void,\n) =>\n Effect.gen(function* () {\n const configDir = getProjectRoot();\n const services = yield* ServiceDescriptorMap;\n const orderedPackages = sortByOrder(orchestrator.packages);\n const initialProcesses: ProcessState[] = getProcessStates(\n orderedPackages,\n services,\n orchestrator.port,\n );\n\n const logger = yield* Effect.promise(() =>\n createDevLogger(configDir, orchestrator.description),\n );\n\n const shutdown = yield* Deferred.make<void>();\n\n onShutdownReady?.(() => {\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n });\n\n const allLogs: LogEntry[] = [];\n let view: DevViewHandle | null = null;\n let shouldExportLogs = false;\n\n const requestShutdownAndExport = () => {\n shouldExportLogs = true;\n void Effect.runPromise(Deferred.succeed(shutdown, undefined));\n };\n\n const useInteractive = orchestrator.interactive ?? isInteractiveSupported();\n view = useInteractive\n ? renderDevView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n requestShutdownAndExport,\n )\n : renderStreamingView(\n initialProcesses,\n orchestrator.description,\n orchestrator.env,\n () => void Effect.runPromise(Deferred.succeed(shutdown, undefined)),\n );\n\n const callbacks: ProcessCallbacks = {\n onStatus: (name, status, message) => {\n view?.updateProcess(name, status, message);\n },\n onLog: (name, line, isError) => {\n const entry: LogEntry = {\n id: `${Date.now()}-${allLogs.length + 1}`,\n source: name,\n line,\n timestamp: Date.now(),\n isError,\n };\n allLogs.push(entry);\n if (shouldDisplayLog(name, line, isError)) {\n view?.addLog(name, line, isError);\n }\n if (!orchestrator.noLogs) {\n void logger.write(entry);\n }\n },\n };\n\n const startProcess = (pkg: string) => {\n const portOverride = pkg === \"host\" ? orchestrator.port : undefined;\n return makeDevProcess(pkg, callbacks, portOverride).pipe(\n Effect.tapError((err) =>\n Effect.sync(() => {\n callbacks.onLog(pkg, `Failed to start: ${err}`, true);\n callbacks.onStatus(pkg, \"error\");\n }),\n ),\n Effect.catchAll(() =>\n Effect.succeed({\n name: pkg,\n pid: undefined,\n kill: Effect.void,\n waitForReady: Effect.void,\n waitForExit: Effect.never,\n } satisfies ProcessHandle),\n ),\n );\n };\n\n const startGroup = (packages: string[]) =>\n Effect.forEach(packages, startProcess, { concurrency: \"unbounded\" });\n\n const awaitReady = (pkg: string, handle: ProcessHandle) =>\n Effect.race(\n handle.waitForReady,\n Effect.sleep(\"30 seconds\").pipe(\n Effect.andThen(\n Effect.sync(() => {\n callbacks.onLog(pkg, \"Timeout waiting for ready, continuing...\", true);\n }),\n ),\n ),\n );\n\n const nonHostPackages = orderedPackages.filter((pkg) => pkg !== \"host\");\n const hostPackages = orderedPackages.filter((pkg) => pkg === \"host\");\n\n const nonHostHandles = yield* startGroup(nonHostPackages);\n\n yield* Effect.forEach(\n nonHostHandles.map((handle, index) => ({\n handle,\n pkg: nonHostPackages[index] ?? handle.name,\n })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n const hostHandles = yield* startGroup(hostPackages);\n\n yield* Effect.forEach(\n hostHandles.map((handle, index) => ({ handle, pkg: hostPackages[index] ?? handle.name })),\n ({ handle, pkg }) => awaitReady(pkg, handle),\n { concurrency: \"unbounded\" },\n );\n\n const allHandles = [...nonHostHandles, ...hostHandles];\n\n yield* Effect.addFinalizer(() =>\n Effect.gen(function* () {\n yield* Effect.forEach(allHandles, (h) => h.kill.pipe(Effect.ignore), {\n concurrency: \"unbounded\",\n });\n\n yield* Effect.sleep(\"200 millis\");\n\n view?.unmount();\n\n if (shouldExportLogs) {\n console.log(\"\\n\");\n console.log(\"═\".repeat(70));\n console.log(` SESSION LOGS: ${orchestrator.description}`);\n console.log(` Started: ${new Date(allLogs[0]?.timestamp || Date.now()).toISOString()}`);\n console.log(` Total entries: ${allLogs.length}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n for (const entry of allLogs) {\n console.log(formatLogLine(entry));\n }\n console.log(\"\");\n console.log(\"═\".repeat(70));\n console.log(` Full logs saved to: ${logger.logFile}`);\n console.log(\"═\".repeat(70));\n console.log(\"\");\n }\n }),\n );\n\n yield* Deferred.await(shutdown);\n });\n\nconst runApp = (\n orchestrator: AppOrchestrator,\n services: Map<string, ServiceDescriptor>,\n runtimeConfig: RuntimeConfig,\n) => {\n let requestShutdown: (() => void) | null = null;\n let signalCount = 0;\n let forceExitTimer: ReturnType<typeof setTimeout> | null = null;\n\n const forceExit = () => {\n console.log(\"\\n[Dev] Force exit\");\n process.exit(0);\n };\n\n const program = Effect.scoped(\n runDevSession(orchestrator, (shutdown) => {\n requestShutdown = shutdown;\n }),\n ).pipe(\n Effect.catchAll((e) =>\n Effect.sync(() => {\n if (e instanceof Error) {\n console.error(\"App error:\", e.message);\n if (e.stack) console.error(e.stack);\n } else {\n console.error(\"App error:\", e);\n }\n }),\n ),\n Effect.provide(ServiceDescriptorMapLive(services)),\n Effect.provide(DevRuntimeConfigLive(runtimeConfig)),\n Effect.provide(NodeContext.layer),\n );\n\n const handleSignal = () => {\n signalCount++;\n if (signalCount > 1) {\n forceExit();\n return;\n }\n console.log(\"\\n[Dev] Shutting down...\");\n forceExitTimer = setTimeout(forceExit, 5000);\n requestShutdown?.();\n };\n\n process.on(\"SIGINT\", handleSignal);\n process.on(\"SIGTERM\", handleSignal);\n\n Effect.runPromiseExit(program).then((exit) => {\n if (forceExitTimer) clearTimeout(forceExitTimer);\n process.exit(Exit.isSuccess(exit) ? 0 : 0);\n });\n};\n\nexport const devApp = runApp;\n\nexport const startApp = runApp;\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,qBAAqB;CACzB;CACA;CACA;CACD;AAED,MAAM,oBAAoB;CACxB;C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GAAG,WAAW,aAAa;AAEnC,QAAO,eAAe,QAAQ,CAAC,MAAM,SAAS;AAC5C,MAAI,eAAgB,cAAa,eAAe;AAChD,UAAQ,KAAK,KAAK,UAAU,KAAK,GAAG,IAAI,EAAE;GAC1C;;AAGJ,MAAa,SAAS;AAEtB,MAAa,WAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ensureNodeRuntimePlugin, loadRemoteModule, registerRemote } from "./mf.mjs";
|
|
2
1
|
import { verifySriForUrl } from "./integrity.mjs";
|
|
2
|
+
import { ensureNodeRuntimePlugin, loadRemoteModule, registerRemote } from "./mf.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/federation.server.ts
|
|
5
5
|
async function loadRouterModule(config) {
|
package/dist/host.cjs
CHANGED
|
@@ -18,10 +18,11 @@ function buildClientRuntimeConfig(runtimeConfig) {
|
|
|
18
18
|
env: runtimeConfig.env,
|
|
19
19
|
account: runtimeConfig.account,
|
|
20
20
|
networkId: runtimeConfig.networkId,
|
|
21
|
-
hostUrl: runtimeConfig.
|
|
21
|
+
hostUrl: runtimeConfig.host.url,
|
|
22
22
|
assetsUrl: runtimeConfig.ui.url,
|
|
23
23
|
apiBase: "/api",
|
|
24
24
|
rpcBase: "/api/rpc",
|
|
25
|
+
authAvailable: !!runtimeConfig.auth,
|
|
25
26
|
ui: runtimeConfig.ui ? {
|
|
26
27
|
name: runtimeConfig.ui.name,
|
|
27
28
|
url: runtimeConfig.ui.url,
|
|
@@ -161,7 +162,7 @@ async function runHostServer(opts) {
|
|
|
161
162
|
ensureApiPluginLoaded();
|
|
162
163
|
ensureRouterModuleLoaded();
|
|
163
164
|
const app = new hono.Hono();
|
|
164
|
-
const corsOrigins = process.env.CORS_ORIGIN?.split(",").map((o) => o.trim()) ?? [runtimeConfig.
|
|
165
|
+
const corsOrigins = process.env.CORS_ORIGIN?.split(",").map((o) => o.trim()) ?? [runtimeConfig.host.url, ...runtimeConfig.ui?.url ? [runtimeConfig.ui.url] : []];
|
|
165
166
|
if (!process.env.CORS_ORIGIN && runtimeConfig.env === "production") console.warn("[Security] CORS_ORIGIN is not set in production. Using host and UI URLs as allowed origins.");
|
|
166
167
|
app.use("/*", (0, hono_cors.cors)({
|
|
167
168
|
origin: corsOrigins,
|
|
@@ -249,7 +250,7 @@ async function runHostServer(opts) {
|
|
|
249
250
|
return c.json({
|
|
250
251
|
status: allRequiredOk ? "ready" : "not_ready",
|
|
251
252
|
host: {
|
|
252
|
-
url: runtimeConfig.
|
|
253
|
+
url: runtimeConfig.host.url,
|
|
253
254
|
env: runtimeConfig.env
|
|
254
255
|
},
|
|
255
256
|
checks,
|