silgi 0.43.28 ā 0.50.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/README.md +103 -1
- package/dist/_virtual/_rolldown/runtime.mjs +5 -0
- package/dist/adapters/_fetch-adapter.d.mts +18 -0
- package/dist/adapters/_fetch-adapter.mjs +53 -0
- package/dist/adapters/astro.d.mts +15 -0
- package/dist/adapters/astro.mjs +31 -0
- package/dist/adapters/aws-lambda.d.mts +42 -0
- package/dist/adapters/aws-lambda.mjs +92 -0
- package/dist/adapters/express.d.mts +16 -0
- package/dist/adapters/express.mjs +110 -0
- package/dist/adapters/message-port.d.mts +42 -0
- package/dist/adapters/message-port.mjs +132 -0
- package/dist/adapters/nestjs.d.mts +25 -0
- package/dist/adapters/nestjs.mjs +83 -0
- package/dist/adapters/nextjs.d.mts +14 -0
- package/dist/adapters/nextjs.mjs +29 -0
- package/dist/adapters/peer.d.mts +27 -0
- package/dist/adapters/peer.mjs +36 -0
- package/dist/adapters/remix.d.mts +15 -0
- package/dist/adapters/remix.mjs +30 -0
- package/dist/adapters/solidstart.d.mts +12 -0
- package/dist/adapters/solidstart.mjs +29 -0
- package/dist/adapters/sveltekit.d.mts +14 -0
- package/dist/adapters/sveltekit.mjs +30 -0
- package/dist/broker/index.d.mts +62 -0
- package/dist/broker/index.mjs +153 -0
- package/dist/broker/nats.d.mts +33 -0
- package/dist/broker/nats.mjs +31 -0
- package/dist/broker/redis.d.mts +51 -0
- package/dist/broker/redis.mjs +92 -0
- package/dist/builder.d.mts +55 -0
- package/dist/builder.mjs +70 -0
- package/dist/callable.d.mts +19 -0
- package/dist/callable.mjs +42 -0
- package/dist/caller.mjs +90 -0
- package/dist/client/adapters/fetch/index.d.mts +15 -0
- package/dist/client/adapters/fetch/index.mjs +57 -0
- package/dist/client/adapters/ofetch/index.d.mts +55 -0
- package/dist/client/adapters/ofetch/index.mjs +91 -0
- package/dist/client/adapters/websocket/index.d.mts +20 -0
- package/dist/client/adapters/websocket/index.mjs +101 -0
- package/dist/client/client.d.mts +37 -0
- package/dist/client/client.mjs +80 -0
- package/dist/client/consume.d.mts +50 -0
- package/dist/client/consume.mjs +66 -0
- package/dist/client/dynamic-link.d.mts +16 -0
- package/dist/client/dynamic-link.mjs +19 -0
- package/dist/client/index.d.mts +6 -0
- package/dist/client/index.mjs +5 -0
- package/dist/client/interceptor.d.mts +31 -0
- package/dist/client/interceptor.mjs +34 -0
- package/dist/client/openapi.d.mts +29 -0
- package/dist/client/openapi.mjs +89 -0
- package/dist/client/plugins/batch.d.mts +26 -0
- package/dist/client/plugins/batch.mjs +64 -0
- package/dist/client/plugins/circuit-breaker.d.mts +24 -0
- package/dist/client/plugins/circuit-breaker.mjs +60 -0
- package/dist/client/plugins/csrf.d.mts +13 -0
- package/dist/client/plugins/csrf.mjs +20 -0
- package/dist/client/plugins/dedupe.d.mts +10 -0
- package/dist/client/plugins/dedupe.mjs +28 -0
- package/dist/client/plugins/index.d.mts +8 -0
- package/dist/client/plugins/index.mjs +8 -0
- package/dist/client/plugins/otel.d.mts +12 -0
- package/dist/client/plugins/otel.mjs +27 -0
- package/dist/client/plugins/retry.d.mts +34 -0
- package/dist/client/plugins/retry.mjs +79 -0
- package/dist/client/plugins/timeout.d.mts +10 -0
- package/dist/client/plugins/timeout.mjs +14 -0
- package/dist/client/server.d.mts +16 -0
- package/dist/client/server.mjs +59 -0
- package/dist/client/types.d.mts +29 -0
- package/dist/codec/devalue.d.mts +21 -0
- package/dist/codec/devalue.mjs +33 -0
- package/dist/codec/msgpack.d.mts +18 -0
- package/dist/codec/msgpack.mjs +45 -0
- package/dist/codec/sanitize.mjs +38 -0
- package/dist/codegen/emitters.d.mts +51 -0
- package/dist/codegen/emitters.mjs +143 -0
- package/dist/codegen/generate.d.mts +25 -0
- package/dist/codegen/generate.mjs +224 -0
- package/dist/codegen/index.d.mts +44 -0
- package/dist/codegen/index.mjs +103 -0
- package/dist/codegen/parse.d.mts +124 -0
- package/dist/codegen/parse.mjs +135 -0
- package/dist/codegen/preserve.d.mts +21 -0
- package/dist/codegen/preserve.mjs +62 -0
- package/dist/codegen/schema-to-code.d.mts +57 -0
- package/dist/codegen/schema-to-code.mjs +167 -0
- package/dist/compile.d.mts +46 -0
- package/dist/compile.mjs +332 -0
- package/dist/core/codec.mjs +67 -0
- package/dist/core/context-bridge.mjs +11 -0
- package/dist/core/dispatch.mjs +62 -0
- package/dist/core/error.d.mts +99 -60
- package/dist/core/error.mjs +125 -92
- package/dist/core/handler.d.mts +6 -0
- package/dist/core/handler.mjs +153 -0
- package/dist/core/input.mjs +49 -0
- package/dist/core/iterator.d.mts +17 -0
- package/dist/core/iterator.mjs +79 -0
- package/dist/core/router-utils.mjs +22 -0
- package/dist/core/schema.d.mts +20 -0
- package/dist/core/schema.mjs +33 -0
- package/dist/core/serve.d.mts +51 -0
- package/dist/core/serve.mjs +76 -0
- package/dist/core/sse.d.mts +18 -0
- package/dist/core/sse.mjs +110 -0
- package/dist/core/storage.d.mts +17 -4
- package/dist/core/storage.mjs +60 -13
- package/dist/core/task.d.mts +62 -0
- package/dist/core/task.mjs +165 -0
- package/dist/core/trace-map.d.mts +13 -0
- package/dist/core/trace-map.mjs +13 -0
- package/dist/core/url.mjs +28 -0
- package/dist/core/utils.mjs +24 -0
- package/dist/index.d.mts +17 -21
- package/dist/index.mjs +14 -22
- package/dist/integrations/ai/index.d.mts +25 -0
- package/dist/integrations/ai/index.mjs +117 -0
- package/dist/integrations/better-auth/index.d.mts +41 -0
- package/dist/integrations/better-auth/index.mjs +331 -0
- package/dist/integrations/drizzle/index.d.mts +27 -0
- package/dist/integrations/drizzle/index.mjs +285 -0
- package/dist/integrations/hey-api/index.d.mts +2 -0
- package/dist/integrations/hey-api/index.mjs +2 -0
- package/dist/integrations/hey-api/to-client.d.mts +20 -0
- package/dist/integrations/hey-api/to-client.mjs +39 -0
- package/dist/integrations/pinia-colada/general-utils.d.mts +13 -0
- package/dist/integrations/pinia-colada/general-utils.mjs +9 -0
- package/dist/integrations/pinia-colada/index.d.mts +6 -0
- package/dist/integrations/pinia-colada/index.mjs +5 -0
- package/dist/integrations/pinia-colada/key.d.mts +11 -0
- package/dist/integrations/pinia-colada/key.mjs +11 -0
- package/dist/integrations/pinia-colada/procedure-utils.d.mts +25 -0
- package/dist/integrations/pinia-colada/procedure-utils.mjs +33 -0
- package/dist/integrations/pinia-colada/router-utils.d.mts +17 -0
- package/dist/integrations/pinia-colada/router-utils.mjs +30 -0
- package/dist/integrations/pinia-colada/types.d.mts +25 -0
- package/dist/integrations/react/index.d.mts +83 -0
- package/dist/integrations/react/index.mjs +196 -0
- package/dist/integrations/tanstack-query/index.d.mts +120 -0
- package/dist/integrations/tanstack-query/index.mjs +100 -0
- package/dist/integrations/tanstack-query/ssr.d.mts +60 -0
- package/dist/integrations/tanstack-query/ssr.mjs +102 -0
- package/dist/integrations/zod/converter.d.mts +75 -0
- package/dist/integrations/zod/converter.mjs +345 -0
- package/dist/integrations/zod/index.d.mts +2 -0
- package/dist/integrations/zod/index.mjs +2 -0
- package/dist/lazy.d.mts +22 -0
- package/dist/lazy.mjs +34 -0
- package/dist/lifecycle.d.mts +36 -0
- package/dist/lifecycle.mjs +46 -0
- package/dist/map-input.d.mts +17 -0
- package/dist/map-input.mjs +47 -0
- package/dist/plugins/analytics/accumulator.d.mts +24 -0
- package/dist/plugins/analytics/accumulator.mjs +91 -0
- package/dist/plugins/analytics/alerts.d.mts +59 -0
- package/dist/plugins/analytics/alerts.mjs +140 -0
- package/dist/plugins/analytics/collector.d.mts +38 -0
- package/dist/plugins/analytics/collector.mjs +275 -0
- package/dist/plugins/analytics/cost.d.mts +61 -0
- package/dist/plugins/analytics/cost.mjs +97 -0
- package/dist/plugins/analytics/export.d.mts +7 -0
- package/dist/plugins/analytics/export.mjs +86 -0
- package/dist/plugins/analytics/normalize.mjs +144 -0
- package/dist/plugins/analytics/query.mjs +164 -0
- package/dist/plugins/analytics/request-id.mjs +34 -0
- package/dist/plugins/analytics/routes.d.mts +11 -0
- package/dist/plugins/analytics/routes.mjs +211 -0
- package/dist/plugins/analytics/sse.d.mts +31 -0
- package/dist/plugins/analytics/sse.mjs +74 -0
- package/dist/plugins/analytics/store.mjs +103 -0
- package/dist/plugins/analytics/timeseries.d.mts +50 -0
- package/dist/plugins/analytics/timeseries.mjs +169 -0
- package/dist/plugins/analytics/trace.d.mts +48 -0
- package/dist/plugins/analytics/trace.mjs +83 -0
- package/dist/plugins/analytics/types.d.mts +145 -0
- package/dist/plugins/analytics/types.mjs +40 -0
- package/dist/plugins/analytics/utils.d.mts +4 -0
- package/dist/plugins/analytics/utils.mjs +56 -0
- package/dist/plugins/analytics.d.mts +18 -0
- package/dist/plugins/analytics.mjs +188 -0
- package/dist/plugins/batch-server.d.mts +20 -0
- package/dist/plugins/batch-server.mjs +91 -0
- package/dist/plugins/body-limit.d.mts +19 -0
- package/dist/plugins/body-limit.mjs +49 -0
- package/dist/plugins/cache.d.mts +170 -0
- package/dist/plugins/cache.mjs +212 -0
- package/dist/plugins/coerce.d.mts +24 -0
- package/dist/plugins/coerce.mjs +70 -0
- package/dist/plugins/cookies.d.mts +14 -0
- package/dist/plugins/cookies.mjs +48 -0
- package/dist/plugins/cors.d.mts +43 -0
- package/dist/plugins/cors.mjs +62 -0
- package/dist/plugins/file-upload.d.mts +38 -0
- package/dist/plugins/file-upload.mjs +102 -0
- package/dist/plugins/index.d.mts +18 -0
- package/dist/plugins/index.mjs +17 -0
- package/dist/plugins/otel.d.mts +35 -0
- package/dist/plugins/otel.mjs +40 -0
- package/dist/plugins/pino.d.mts +60 -0
- package/dist/plugins/pino.mjs +42 -0
- package/dist/plugins/pubsub.d.mts +50 -0
- package/dist/plugins/pubsub.mjs +53 -0
- package/dist/plugins/ratelimit.d.mts +53 -0
- package/dist/plugins/ratelimit.mjs +92 -0
- package/dist/plugins/signing.d.mts +41 -0
- package/dist/plugins/signing.mjs +118 -0
- package/dist/plugins/strict-get.d.mts +10 -0
- package/dist/plugins/strict-get.mjs +33 -0
- package/dist/scalar.d.mts +49 -0
- package/dist/scalar.mjs +311 -0
- package/dist/silgi.d.mts +144 -0
- package/dist/silgi.mjs +164 -0
- package/dist/trpc-interop.d.mts +22 -0
- package/dist/trpc-interop.mjs +68 -0
- package/dist/types.d.mts +108 -0
- package/dist/ws.d.mts +88 -0
- package/dist/ws.mjs +205 -0
- package/lib/dashboard/index.html +120 -0
- package/lib/ocache.d.mts +1 -0
- package/lib/ocache.mjs +1 -0
- package/lib/ofetch.d.mts +1 -0
- package/lib/ofetch.mjs +1 -0
- package/lib/srvx.d.mts +1 -0
- package/lib/srvx.mjs +1 -0
- package/lib/unstorage.d.mts +1 -0
- package/lib/unstorage.mjs +1 -0
- package/package.json +314 -150
- package/dist/build.d.mts +0 -3
- package/dist/build.mjs +0 -4
- package/dist/cli/build/build.mjs +0 -15
- package/dist/cli/build/dev.d.mts +0 -10
- package/dist/cli/build/dev.mjs +0 -91
- package/dist/cli/build/prepare.d.mts +0 -6
- package/dist/cli/build/prepare.mjs +0 -15
- package/dist/cli/commands/commands.mjs +0 -90
- package/dist/cli/commands/env.mjs +0 -53
- package/dist/cli/commands/init.mjs +0 -84
- package/dist/cli/commands/install.mjs +0 -52
- package/dist/cli/commands/prepare.mjs +0 -65
- package/dist/cli/commands/reset.mjs +0 -46
- package/dist/cli/commands/run.mjs +0 -31
- package/dist/cli/commands/watch.mjs +0 -153
- package/dist/cli/config/defaults.mjs +0 -117
- package/dist/cli/config/index.d.mts +0 -3
- package/dist/cli/config/index.mjs +0 -4
- package/dist/cli/config/loader.d.mts +0 -6
- package/dist/cli/config/loader.mjs +0 -71
- package/dist/cli/config/resolvers/compatibility.mjs +0 -71
- package/dist/cli/config/resolvers/imports.mjs +0 -35
- package/dist/cli/config/resolvers/paths.mjs +0 -98
- package/dist/cli/config/resolvers/storage.mjs +0 -23
- package/dist/cli/config/resolvers/url.mjs +0 -9
- package/dist/cli/config/types.d.mts +0 -14
- package/dist/cli/config/types.mjs +0 -147
- package/dist/cli/core/apiful.mjs +0 -36
- package/dist/cli/core/devServer.mjs +0 -10
- package/dist/cli/core/env.mjs +0 -68
- package/dist/cli/core/installPackage.mjs +0 -60
- package/dist/cli/core/runtimeConfig.mjs +0 -70
- package/dist/cli/core/scan.mjs +0 -35
- package/dist/cli/core/silgi.mjs +0 -111
- package/dist/cli/framework/emptyFramework.mjs +0 -7
- package/dist/cli/framework/h3.mjs +0 -55
- package/dist/cli/framework/index.mjs +0 -15
- package/dist/cli/framework/nitro.mjs +0 -24
- package/dist/cli/framework/nuxt.mjs +0 -10
- package/dist/cli/index.d.mts +0 -1
- package/dist/cli/index.mjs +0 -29
- package/dist/cli/module/exportScan.mjs +0 -180
- package/dist/cli/module/install.mjs +0 -49
- package/dist/cli/module/scan.mjs +0 -193
- package/dist/cli/scan/prepareCommands.mjs +0 -40
- package/dist/cli/scan/prepareConfigs.mjs +0 -33
- package/dist/cli/scan/prepareCoreFile.mjs +0 -118
- package/dist/cli/scan/prepareScanFile.mjs +0 -59
- package/dist/cli/scan/prepareSchema.mjs +0 -128
- package/dist/cli/scan/scanExportFile.mjs +0 -288
- package/dist/cli/scan/writeCoreFile.mjs +0 -22
- package/dist/cli/scan/writeTypesAndFiles.mjs +0 -72
- package/dist/cli/utils/cancel.mjs +0 -14
- package/dist/cli/utils/common.mjs +0 -15
- package/dist/cli/utils/compatibility.mjs +0 -33
- package/dist/cli/utils/debug.mjs +0 -11
- package/dist/cli/utils/ignore.mjs +0 -56
- package/dist/cli/utils/processManager.mjs +0 -170
- package/dist/cli/utils/readScanFile.mjs +0 -58
- package/dist/cli/utils/storage.mjs +0 -23
- package/dist/core/context.d.mts +0 -30
- package/dist/core/context.mjs +0 -32
- package/dist/core/createSilgi.d.mts +0 -6
- package/dist/core/createSilgi.mjs +0 -153
- package/dist/core/event.d.mts +0 -26
- package/dist/core/event.mjs +0 -44
- package/dist/core/index.d.mts +0 -25
- package/dist/core/index.mjs +0 -30
- package/dist/core/orchestrate.mjs +0 -115
- package/dist/core/response.d.mts +0 -20
- package/dist/core/response.mjs +0 -105
- package/dist/core/silgi.d.mts +0 -19
- package/dist/core/silgi.mjs +0 -141
- package/dist/core/silgiApp.d.mts +0 -9
- package/dist/core/silgiApp.mjs +0 -23
- package/dist/core/unctx.d.mts +0 -21
- package/dist/core/unctx.mjs +0 -35
- package/dist/core/utils/event-stream.d.mts +0 -53
- package/dist/core/utils/event-stream.mjs +0 -38
- package/dist/core/utils/event.d.mts +0 -8
- package/dist/core/utils/event.mjs +0 -12
- package/dist/core/utils/internal/event-stream.d.mts +0 -45
- package/dist/core/utils/internal/event-stream.mjs +0 -137
- package/dist/core/utils/internal/obj.mjs +0 -9
- package/dist/core/utils/internal/object.mjs +0 -29
- package/dist/core/utils/internal/query.mjs +0 -73
- package/dist/core/utils/internal/req.mjs +0 -35
- package/dist/core/utils/merge.d.mts +0 -14
- package/dist/core/utils/merge.mjs +0 -27
- package/dist/core/utils/middleware.d.mts +0 -14
- package/dist/core/utils/middleware.mjs +0 -12
- package/dist/core/utils/request.mjs +0 -35
- package/dist/core/utils/resolver.d.mts +0 -7
- package/dist/core/utils/resolver.mjs +0 -29
- package/dist/core/utils/runtime.d.mts +0 -7
- package/dist/core/utils/runtime.mjs +0 -20
- package/dist/core/utils/sanitize.mjs +0 -22
- package/dist/core/utils/schema.d.mts +0 -34
- package/dist/core/utils/schema.mjs +0 -33
- package/dist/core/utils/service.d.mts +0 -13
- package/dist/core/utils/service.mjs +0 -19
- package/dist/core/utils/shared.d.mts +0 -6
- package/dist/core/utils/shared.mjs +0 -7
- package/dist/core/utils/storage.d.mts +0 -24
- package/dist/core/utils/storage.mjs +0 -54
- package/dist/kit/add/add-commands.d.mts +0 -6
- package/dist/kit/add/add-commands.mjs +0 -12
- package/dist/kit/add/add-core-file.d.mts +0 -9
- package/dist/kit/add/add-core-file.mjs +0 -11
- package/dist/kit/add/add-imports.d.mts +0 -14
- package/dist/kit/add/add-imports.mjs +0 -56
- package/dist/kit/add/add-npm.d.mts +0 -14
- package/dist/kit/add/add-npm.mjs +0 -23
- package/dist/kit/define.d.mts +0 -28
- package/dist/kit/define.mjs +0 -25
- package/dist/kit/errors.d.mts +0 -6
- package/dist/kit/errors.mjs +0 -11
- package/dist/kit/esm.d.mts +0 -11
- package/dist/kit/esm.mjs +0 -21
- package/dist/kit/fs.d.mts +0 -4
- package/dist/kit/fs.mjs +0 -13
- package/dist/kit/function-utils.d.mts +0 -27
- package/dist/kit/function-utils.mjs +0 -75
- package/dist/kit/gen.d.mts +0 -5
- package/dist/kit/gen.mjs +0 -26
- package/dist/kit/hash.d.mts +0 -4
- package/dist/kit/hash.mjs +0 -10
- package/dist/kit/index.d.mts +0 -22
- package/dist/kit/index.mjs +0 -23
- package/dist/kit/isFramework.d.mts +0 -6
- package/dist/kit/isFramework.mjs +0 -21
- package/dist/kit/logger.d.mts +0 -6
- package/dist/kit/logger.mjs +0 -10
- package/dist/kit/migration.d.mts +0 -113
- package/dist/kit/migration.mjs +0 -301
- package/dist/kit/module.d.mts +0 -14
- package/dist/kit/module.mjs +0 -53
- package/dist/kit/path.d.mts +0 -7
- package/dist/kit/path.mjs +0 -26
- package/dist/kit/preset.d.mts +0 -8
- package/dist/kit/preset.mjs +0 -11
- package/dist/kit/resolve.d.mts +0 -37
- package/dist/kit/resolve.mjs +0 -82
- package/dist/kit/template.d.mts +0 -19
- package/dist/kit/template.mjs +0 -91
- package/dist/kit/useRequest.d.mts +0 -19
- package/dist/kit/useRequest.mjs +0 -63
- package/dist/kit/utils.d.mts +0 -34
- package/dist/kit/utils.mjs +0 -91
- package/dist/package.mjs +0 -176
- package/dist/presets/_all.gen.d.mts +0 -6
- package/dist/presets/_all.gen.mjs +0 -18
- package/dist/presets/_resolve.d.mts +0 -12
- package/dist/presets/_resolve.mjs +0 -57
- package/dist/presets/_types.gen.d.mts +0 -8
- package/dist/presets/_types.gen.mjs +0 -5
- package/dist/presets/h3/preset.d.mts +0 -6
- package/dist/presets/h3/preset.mjs +0 -35
- package/dist/presets/hono/preset.d.mts +0 -6
- package/dist/presets/hono/preset.mjs +0 -30
- package/dist/presets/index.d.mts +0 -3
- package/dist/presets/index.mjs +0 -3
- package/dist/presets/nitro/preset.d.mts +0 -6
- package/dist/presets/nitro/preset.mjs +0 -37
- package/dist/presets/npmpackage/preset.d.mts +0 -6
- package/dist/presets/npmpackage/preset.mjs +0 -29
- package/dist/presets/nuxt/preset.d.mts +0 -6
- package/dist/presets/nuxt/preset.mjs +0 -41
- package/dist/runtime/index.d.mts +0 -4
- package/dist/runtime/index.mjs +0 -5
- package/dist/runtime/internal/config.d.mts +0 -11
- package/dist/runtime/internal/config.mjs +0 -97
- package/dist/runtime/internal/debug.d.mts +0 -6
- package/dist/runtime/internal/debug.mjs +0 -11
- package/dist/runtime/internal/defu.d.mts +0 -4
- package/dist/runtime/internal/defu.mjs +0 -9
- package/dist/runtime/internal/index.d.mts +0 -7
- package/dist/runtime/internal/index.mjs +0 -8
- package/dist/runtime/internal/nitro.d.mts +0 -6
- package/dist/runtime/internal/nitro.mjs +0 -36
- package/dist/runtime/internal/nuxt.d.mts +0 -12
- package/dist/runtime/internal/nuxt.mjs +0 -16
- package/dist/runtime/internal/ofetch.d.mts +0 -8
- package/dist/runtime/internal/ofetch.mjs +0 -39
- package/dist/runtime/internal/plugin.d.mts +0 -7
- package/dist/runtime/internal/plugin.mjs +0 -8
- package/dist/types/cliConfig.d.mts +0 -288
- package/dist/types/cliConfig.mjs +0 -0
- package/dist/types/cliHooks.d.mts +0 -142
- package/dist/types/cliHooks.mjs +0 -0
- package/dist/types/compatibility.d.mts +0 -13
- package/dist/types/compatibility.mjs +0 -0
- package/dist/types/config.d.mts +0 -46
- package/dist/types/config.mjs +0 -0
- package/dist/types/dotenv.d.mts +0 -29
- package/dist/types/dotenv.mjs +0 -0
- package/dist/types/event.d.mts +0 -63
- package/dist/types/event.mjs +0 -0
- package/dist/types/global.d.mts +0 -24
- package/dist/types/global.mjs +0 -0
- package/dist/types/helper.d.mts +0 -25
- package/dist/types/helper.mjs +0 -0
- package/dist/types/hooks.d.mts +0 -37
- package/dist/types/hooks.mjs +0 -0
- package/dist/types/index.d.mts +0 -26
- package/dist/types/index.mjs +0 -0
- package/dist/types/kits.d.mts +0 -32
- package/dist/types/kits.mjs +0 -0
- package/dist/types/middleware.d.mts +0 -31
- package/dist/types/middleware.mjs +0 -0
- package/dist/types/module.d.mts +0 -102
- package/dist/types/module.mjs +0 -0
- package/dist/types/preset.d.mts +0 -20
- package/dist/types/preset.mjs +0 -0
- package/dist/types/route.d.mts +0 -59
- package/dist/types/route.mjs +0 -0
- package/dist/types/runtime/index.d.mts +0 -5
- package/dist/types/runtime/index.mjs +0 -0
- package/dist/types/runtime/nuxt.d.mts +0 -13
- package/dist/types/runtime/nuxt.mjs +0 -0
- package/dist/types/runtime/ofetch.d.mts +0 -14
- package/dist/types/runtime/ofetch.mjs +0 -0
- package/dist/types/runtime/plugin.d.mts +0 -8
- package/dist/types/runtime/plugin.mjs +0 -0
- package/dist/types/runtime/silgi.d.mts +0 -11
- package/dist/types/runtime/silgi.mjs +0 -0
- package/dist/types/schema.d.mts +0 -86
- package/dist/types/schema.mjs +0 -0
- package/dist/types/service.d.mts +0 -102
- package/dist/types/service.mjs +0 -0
- package/dist/types/shared.d.mts +0 -19
- package/dist/types/shared.mjs +0 -0
- package/dist/types/silgi.d.mts +0 -71
- package/dist/types/silgi.mjs +0 -0
- package/dist/types/silgiCLI.d.mts +0 -118
- package/dist/types/silgiCLI.mjs +0 -0
- package/dist/types/standard-schema.d.mts +0 -61
- package/dist/types/standard-schema.mjs +0 -0
- package/dist/types/storage.d.mts +0 -30
- package/dist/types/storage.mjs +0 -0
- package/dist/types/tree-kill.d.mts +0 -18
- package/dist/types/tree-kill.mjs +0 -0
- package/lib/config.d.mts +0 -7
- package/lib/config.mjs +0 -5
- package/lib/meta.d.mts +0 -4
- package/lib/meta.mjs +0 -6
- package/lib/runtime-meta.d.mts +0 -4
- package/lib/runtime-meta.mjs +0 -32
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createSilgiCLI } from "../core/silgi.mjs";
|
|
2
|
-
import { build } from "./build.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/cli/build/prepare.ts
|
|
5
|
-
async function prepareBuild(config) {
|
|
6
|
-
const silgi = await createSilgiCLI({
|
|
7
|
-
commandType: config?.commandType || "prepare",
|
|
8
|
-
...config
|
|
9
|
-
});
|
|
10
|
-
await build(silgi);
|
|
11
|
-
return silgi;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { prepareBuild };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { silgiCLIIClose } from "../../core/silgiApp.mjs";
|
|
2
|
-
import { prepareEnv } from "./env.mjs";
|
|
3
|
-
import { loadOptions } from "../config/loader.mjs";
|
|
4
|
-
import { cancelOnCancel } from "../utils/cancel.mjs";
|
|
5
|
-
import { commonArgs } from "../utils/common.mjs";
|
|
6
|
-
import prepare_default from "./prepare.mjs";
|
|
7
|
-
import { consola as consola$1 } from "consola";
|
|
8
|
-
import { useSilgiCLI } from "silgi";
|
|
9
|
-
import * as p from "@clack/prompts";
|
|
10
|
-
import { createJiti } from "dev-jiti";
|
|
11
|
-
import { version } from "silgi/meta";
|
|
12
|
-
import { defineCommand, runCommand } from "citty";
|
|
13
|
-
import { execSync } from "node:child_process";
|
|
14
|
-
|
|
15
|
-
//#region src/cli/commands/commands.ts
|
|
16
|
-
const command = defineCommand({
|
|
17
|
-
meta: {
|
|
18
|
-
name: "run",
|
|
19
|
-
description: "Run a command from the CLI",
|
|
20
|
-
version
|
|
21
|
-
},
|
|
22
|
-
args: {
|
|
23
|
-
...commonArgs,
|
|
24
|
-
preset: {
|
|
25
|
-
type: "string",
|
|
26
|
-
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
27
|
-
},
|
|
28
|
-
tag: { type: "string" },
|
|
29
|
-
prepare: {
|
|
30
|
-
type: "boolean",
|
|
31
|
-
description: "Run in silgi development mode",
|
|
32
|
-
default: true
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
async run({ args }) {
|
|
36
|
-
if (args.prepare) await runCommand(prepare_default, { rawArgs: ["--commandType", "commands"] });
|
|
37
|
-
const silgi = useSilgiCLI();
|
|
38
|
-
if (!silgi) throw new Error("Silgi is not initialized");
|
|
39
|
-
const commands = silgi.options.commands;
|
|
40
|
-
const tags = args.tag?.split(",").map((t) => t.trim());
|
|
41
|
-
const silgiConfig = await loadOptions({});
|
|
42
|
-
await prepareEnv(silgiConfig);
|
|
43
|
-
let selectedCommands = [];
|
|
44
|
-
if (tags?.length) selectedCommands = commands.filter((cmd) => cmd.tags?.some((tag) => tags.includes(tag))).filter((cmd) => cmd.when !== false);
|
|
45
|
-
else selectedCommands = commands.filter((cmd) => cmd.when !== false);
|
|
46
|
-
if (!selectedCommands.length) return;
|
|
47
|
-
const multiSelect = await p.groupMultiselect({
|
|
48
|
-
message: "Select commands to run",
|
|
49
|
-
required: true,
|
|
50
|
-
options: { ...selectedCommands.sort((a, b) => (a.order || Infinity) - (b.order || Infinity)).reduce((acc, cmd) => {
|
|
51
|
-
const groupKey = cmd.group || "";
|
|
52
|
-
if (!acc[groupKey]) acc[groupKey] = [];
|
|
53
|
-
acc[groupKey].push({
|
|
54
|
-
label: cmd.name,
|
|
55
|
-
value: cmd,
|
|
56
|
-
hint: cmd.description
|
|
57
|
-
});
|
|
58
|
-
return acc;
|
|
59
|
-
}, {}) }
|
|
60
|
-
});
|
|
61
|
-
cancelOnCancel({ value: multiSelect });
|
|
62
|
-
selectedCommands = multiSelect;
|
|
63
|
-
const spinner = p.spinner({ indicator: "dots" });
|
|
64
|
-
for (const cmd of selectedCommands) {
|
|
65
|
-
const data = cmd.getContents({ app: silgi });
|
|
66
|
-
spinner.start(`[${cmd.group}] ${cmd.name}...`);
|
|
67
|
-
if (cmd.type === "command") execSync(data, { stdio: "inherit" });
|
|
68
|
-
if (cmd.type === "function") {
|
|
69
|
-
const jiti = createJiti(import.meta.url, { alias: silgiConfig.alias });
|
|
70
|
-
let cleanHandler = cmd.getContents({ app: silgi }).replace(/\n/g, "");
|
|
71
|
-
cleanHandler = `import { silgiCLICtx } from 'silgi'
|
|
72
|
-
${cleanHandler}
|
|
73
|
-
`;
|
|
74
|
-
await jiti.evalModule(cleanHandler, {
|
|
75
|
-
filename: import.meta.url,
|
|
76
|
-
async: true,
|
|
77
|
-
conditions: silgiConfig.conditions,
|
|
78
|
-
forceTranspile: true
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
spinner.stop();
|
|
82
|
-
consola$1.success(`[${cmd.group}] ${cmd.name} done`);
|
|
83
|
-
}
|
|
84
|
-
await silgiCLIIClose();
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
var commands_default = command;
|
|
88
|
-
|
|
89
|
-
//#endregion
|
|
90
|
-
export { commands_default as default };
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { setupDotenv } from "../core/env.mjs";
|
|
2
|
-
import * as p from "@clack/prompts";
|
|
3
|
-
|
|
4
|
-
//#region src/cli/commands/env.ts
|
|
5
|
-
let initialized = false;
|
|
6
|
-
async function prepareEnv(silgiConfig) {
|
|
7
|
-
if (initialized) return;
|
|
8
|
-
initialized = true;
|
|
9
|
-
const customEnvironments = silgiConfig.environments;
|
|
10
|
-
const environment = silgiConfig.activeEnvironment ? silgiConfig.activeEnvironment : await p.select({
|
|
11
|
-
message: "Select an environment",
|
|
12
|
-
options: customEnvironments?.length > 0 ? customEnvironments.map((env) => ({
|
|
13
|
-
label: env.fileName,
|
|
14
|
-
value: env.fileName
|
|
15
|
-
})) : [
|
|
16
|
-
{
|
|
17
|
-
label: "Development (.env)",
|
|
18
|
-
value: ".env"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
label: "Docker (.env.docker)",
|
|
22
|
-
value: "docker"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
label: "Staging (.env.staging)",
|
|
26
|
-
value: "staging"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: "Testing (.env.testing)",
|
|
30
|
-
value: "testing"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
label: "Production (.env.prod)",
|
|
34
|
-
value: "prod"
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
});
|
|
38
|
-
const findEnv = customEnvironments?.find((env) => env.fileName === environment);
|
|
39
|
-
if (findEnv) await setupDotenv({
|
|
40
|
-
cwd: findEnv.cwd || silgiConfig.rootDir,
|
|
41
|
-
interpolate: findEnv.interpolate,
|
|
42
|
-
fileName: findEnv.fileName,
|
|
43
|
-
env: findEnv.env
|
|
44
|
-
});
|
|
45
|
-
else await setupDotenv({
|
|
46
|
-
cwd: silgiConfig.rootDir,
|
|
47
|
-
interpolate: true,
|
|
48
|
-
fileName: environment === ".env" ? ".env" : `.env.${environment}`
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
export { prepareEnv };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { cancelOnCancel } from "../utils/cancel.mjs";
|
|
2
|
-
import prepare_default from "./prepare.mjs";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import { dirname } from "pathe";
|
|
5
|
-
import * as p from "@clack/prompts";
|
|
6
|
-
import { writeFileSync } from "node:fs";
|
|
7
|
-
import fsp from "node:fs/promises";
|
|
8
|
-
import { defineCommand, runCommand } from "citty";
|
|
9
|
-
|
|
10
|
-
//#region src/cli/commands/init.ts
|
|
11
|
-
const command = defineCommand({
|
|
12
|
-
meta: {
|
|
13
|
-
name: "Silgi Init",
|
|
14
|
-
description: "Initialize silgi config",
|
|
15
|
-
version: "0.1.0"
|
|
16
|
-
},
|
|
17
|
-
args: {},
|
|
18
|
-
async run() {
|
|
19
|
-
p.intro("Initializing silgi config");
|
|
20
|
-
const framework = await p.select({
|
|
21
|
-
message: "Choose a framework",
|
|
22
|
-
options: [
|
|
23
|
-
{
|
|
24
|
-
label: "Nitro",
|
|
25
|
-
value: "nitro"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
label: "Nuxt",
|
|
29
|
-
value: "nuxt"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
label: "H3",
|
|
33
|
-
value: "h3"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
label: "NPM Package",
|
|
37
|
-
value: "npm-package"
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
initialValue: "h3"
|
|
41
|
-
});
|
|
42
|
-
cancelOnCancel({ value: framework });
|
|
43
|
-
const context = [
|
|
44
|
-
`import { defineSilgiConfig } from 'silgi/config'`,
|
|
45
|
-
"",
|
|
46
|
-
"export default defineSilgiConfig({",
|
|
47
|
-
` preset: '${framework}',`,
|
|
48
|
-
` compatibilityDate: '${new Date().toISOString().split("T")[0]}',`,
|
|
49
|
-
"",
|
|
50
|
-
"})",
|
|
51
|
-
""
|
|
52
|
-
];
|
|
53
|
-
if (framework === "nitro" || framework === "nuxt") {
|
|
54
|
-
const plugin = [
|
|
55
|
-
`import { buildSilgi } from '../silgi/core'`,
|
|
56
|
-
"",
|
|
57
|
-
"export default defineNitroPlugin(async (nitro) => {",
|
|
58
|
-
"",
|
|
59
|
-
" await buildSilgi({",
|
|
60
|
-
" framework: {",
|
|
61
|
-
" nitro,",
|
|
62
|
-
" },",
|
|
63
|
-
" options: {",
|
|
64
|
-
" putStorage: useStorage(),",
|
|
65
|
-
" runtimeConfig: useRuntimeConfig(),",
|
|
66
|
-
" },",
|
|
67
|
-
" })",
|
|
68
|
-
"})",
|
|
69
|
-
""
|
|
70
|
-
];
|
|
71
|
-
const file = "server/plugins/silgi.ts";
|
|
72
|
-
await fsp.mkdir(dirname(file), { recursive: true });
|
|
73
|
-
writeFileSync(file, plugin.join("\n"));
|
|
74
|
-
consola.success("Silgi plugin created, see server/plugins/silgi.ts");
|
|
75
|
-
runCommand(prepare_default, { rawArgs: ["--env", ".env"] });
|
|
76
|
-
}
|
|
77
|
-
writeFileSync("silgi.config.ts", context.join("\n"));
|
|
78
|
-
consola.success("Silgi config created, see silgi.config.ts");
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
var init_default = command;
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
export { init_default as default };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { commonArgs } from "../utils/common.mjs";
|
|
2
|
-
import prepare_default from "./prepare.mjs";
|
|
3
|
-
import { installPackages } from "../core/installPackage.mjs";
|
|
4
|
-
import { consola as consola$1 } from "consola";
|
|
5
|
-
import { version } from "silgi/meta";
|
|
6
|
-
import { defineCommand, runCommand } from "citty";
|
|
7
|
-
import { execSync } from "node:child_process";
|
|
8
|
-
|
|
9
|
-
//#region src/cli/commands/install.ts
|
|
10
|
-
const command = defineCommand({
|
|
11
|
-
meta: {
|
|
12
|
-
name: "install",
|
|
13
|
-
description: "Install dependencies from the install.json file.",
|
|
14
|
-
version
|
|
15
|
-
},
|
|
16
|
-
args: {
|
|
17
|
-
...commonArgs,
|
|
18
|
-
preset: {
|
|
19
|
-
type: "string",
|
|
20
|
-
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
async run() {
|
|
24
|
-
await runCommand(prepare_default, { rawArgs: ["--commandType", "install"] }).catch(() => {});
|
|
25
|
-
const packages = await installPackages();
|
|
26
|
-
const commandArgs = process.argv.slice(process.argv.indexOf("install") + 1);
|
|
27
|
-
const extraArgs = commandArgs.length ? ` ${commandArgs.join(" ")}` : "";
|
|
28
|
-
if (Object.keys(packages).length === 0) {
|
|
29
|
-
consola$1.info("Empty command list, maybe forgot pnpm silgi prepare?");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const cleanPackageName = (name, version$1) => {
|
|
33
|
-
const cleanVersion = version$1.replace(/^(>=|<=|>|<)/, "^");
|
|
34
|
-
return `${name}@${cleanVersion}`;
|
|
35
|
-
};
|
|
36
|
-
const deps = Object.entries(packages.dependencies || {}).map(([name, version$1]) => cleanPackageName(name, version$1)).join(" ");
|
|
37
|
-
const devDeps = Object.entries(packages.devDependencies || {}).map(([name, version$1]) => cleanPackageName(name, version$1)).join(" ");
|
|
38
|
-
if (deps) {
|
|
39
|
-
consola$1.info("Installing dependencies...");
|
|
40
|
-
execSync(`ni ${deps}${extraArgs}`, { stdio: "inherit" });
|
|
41
|
-
}
|
|
42
|
-
if (devDeps) {
|
|
43
|
-
consola$1.info("Installing dev dependencies...");
|
|
44
|
-
execSync(`ni ${devDeps}${extraArgs} -D`, { stdio: "inherit" });
|
|
45
|
-
}
|
|
46
|
-
consola$1.success("All dependencies installed successfully.");
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
var install_default = command;
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { install_default as default };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { createSilgiCLI } from "../core/silgi.mjs";
|
|
2
|
-
import { build } from "../build/build.mjs";
|
|
3
|
-
import { commonArgs } from "../utils/common.mjs";
|
|
4
|
-
import commands_default from "./commands.mjs";
|
|
5
|
-
import { resolve } from "pathe";
|
|
6
|
-
import { readPackageJSON } from "pkg-types";
|
|
7
|
-
import { version } from "silgi/meta";
|
|
8
|
-
import { defineCommand, runCommand } from "citty";
|
|
9
|
-
|
|
10
|
-
//#region src/cli/commands/prepare.ts
|
|
11
|
-
const command = defineCommand({
|
|
12
|
-
meta: {
|
|
13
|
-
name: "prepare",
|
|
14
|
-
description: "Generate types for the project",
|
|
15
|
-
version
|
|
16
|
-
},
|
|
17
|
-
args: {
|
|
18
|
-
...commonArgs,
|
|
19
|
-
preset: {
|
|
20
|
-
type: "string",
|
|
21
|
-
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
22
|
-
},
|
|
23
|
-
stub: {
|
|
24
|
-
type: "boolean",
|
|
25
|
-
description: "Run in silgi development mode"
|
|
26
|
-
},
|
|
27
|
-
dev: {
|
|
28
|
-
type: "boolean",
|
|
29
|
-
description: "Run in silgi development mode"
|
|
30
|
-
},
|
|
31
|
-
env: {
|
|
32
|
-
type: "string",
|
|
33
|
-
description: "The environment to use"
|
|
34
|
-
},
|
|
35
|
-
commandType: {
|
|
36
|
-
type: "string",
|
|
37
|
-
description: "The command type to run"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
async run({ args }) {
|
|
41
|
-
const rootDir = resolve(args.dir || args._dir || ".");
|
|
42
|
-
const packageJson = await readPackageJSON(rootDir);
|
|
43
|
-
const packageName = packageJson.name || "";
|
|
44
|
-
const silgi = await createSilgiCLI({
|
|
45
|
-
rootDir,
|
|
46
|
-
dev: args.dev || args.stub,
|
|
47
|
-
stub: args.stub,
|
|
48
|
-
preset: args.preset,
|
|
49
|
-
commandType: args.commandType || "prepare",
|
|
50
|
-
activeEnvironment: args.env,
|
|
51
|
-
package: { name: packageName }
|
|
52
|
-
});
|
|
53
|
-
await build(silgi);
|
|
54
|
-
if (args.commandType !== "commands") await runCommand(commands_default, { rawArgs: [
|
|
55
|
-
"--tag",
|
|
56
|
-
"init",
|
|
57
|
-
"--prepare",
|
|
58
|
-
"false"
|
|
59
|
-
] });
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
var prepare_default = command;
|
|
63
|
-
|
|
64
|
-
//#endregion
|
|
65
|
-
export { prepare_default as default };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { loadOptions } from "../config/loader.mjs";
|
|
2
|
-
import { commonArgs } from "../utils/common.mjs";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import { join, resolve } from "pathe";
|
|
5
|
-
import { version } from "silgi/meta";
|
|
6
|
-
import fsp from "node:fs/promises";
|
|
7
|
-
import { defineCommand } from "citty";
|
|
8
|
-
|
|
9
|
-
//#region src/cli/commands/reset.ts
|
|
10
|
-
const command = defineCommand({
|
|
11
|
-
meta: {
|
|
12
|
-
name: "prepare",
|
|
13
|
-
description: "Generate types for the project",
|
|
14
|
-
version
|
|
15
|
-
},
|
|
16
|
-
args: { ...commonArgs },
|
|
17
|
-
async run({ args }) {
|
|
18
|
-
const rootDir = resolve(args.dir || args._dir || ".");
|
|
19
|
-
const options = await loadOptions({ rootDir }, {});
|
|
20
|
-
const serverDir = options.silgi.serverDir;
|
|
21
|
-
const vfs = join(serverDir, "vfs");
|
|
22
|
-
const configs = join(serverDir, "configs.ts");
|
|
23
|
-
const core = join(serverDir, "core.ts");
|
|
24
|
-
const scan = join(serverDir, "scan.ts");
|
|
25
|
-
const meta = join(serverDir, "meta.ts");
|
|
26
|
-
const silgiDir = options.build.dir;
|
|
27
|
-
for (const file of [
|
|
28
|
-
vfs,
|
|
29
|
-
configs,
|
|
30
|
-
core,
|
|
31
|
-
scan,
|
|
32
|
-
silgiDir,
|
|
33
|
-
meta
|
|
34
|
-
]) try {
|
|
35
|
-
await fsp.rm(file, {
|
|
36
|
-
force: true,
|
|
37
|
-
recursive: true
|
|
38
|
-
});
|
|
39
|
-
consola.success(`Removed ${file.replace(rootDir, "")}`);
|
|
40
|
-
} catch {}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
var reset_default = command;
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { reset_default as default };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import watch_default from "./watch.mjs";
|
|
2
|
-
import consola from "consola";
|
|
3
|
-
import { version } from "silgi/meta";
|
|
4
|
-
import { runCommand } from "citty";
|
|
5
|
-
|
|
6
|
-
//#region src/cli/commands/run.ts
|
|
7
|
-
const command = {
|
|
8
|
-
meta: {
|
|
9
|
-
name: "run",
|
|
10
|
-
description: "Run a command with silgi watch (shortcut for \"silgi watch npm run <command>\")",
|
|
11
|
-
version
|
|
12
|
-
},
|
|
13
|
-
args: { command: {
|
|
14
|
-
type: "string",
|
|
15
|
-
description: "your application start command",
|
|
16
|
-
required: false
|
|
17
|
-
} },
|
|
18
|
-
async run({ args, rawArgs }) {
|
|
19
|
-
const command$1 = args.command || rawArgs[0];
|
|
20
|
-
if (command$1 && !command$1.includes(" ")) {
|
|
21
|
-
const fullCommand = `npm run ${command$1}`;
|
|
22
|
-
consola.info(`Running: ${fullCommand}`);
|
|
23
|
-
return runCommand(watch_default, { rawArgs: [fullCommand] });
|
|
24
|
-
}
|
|
25
|
-
return runCommand(watch_default, { rawArgs });
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var run_default = command;
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { run_default as default };
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { watchDev } from "../build/dev.mjs";
|
|
2
|
-
import { commonArgs } from "../utils/common.mjs";
|
|
3
|
-
import prepare_default from "./prepare.mjs";
|
|
4
|
-
import { aggressiveCleanup, killPortProcesses, killProcessTree } from "../utils/processManager.mjs";
|
|
5
|
-
import consola from "consola";
|
|
6
|
-
import { version } from "silgi/meta";
|
|
7
|
-
import { defineCommand, runCommand } from "citty";
|
|
8
|
-
import { spawn } from "node:child_process";
|
|
9
|
-
|
|
10
|
-
//#region src/cli/commands/watch.ts
|
|
11
|
-
const runningProcesses = new Map();
|
|
12
|
-
const openPorts = new Set();
|
|
13
|
-
let watchHandle = null;
|
|
14
|
-
let isShuttingDown = false;
|
|
15
|
-
const isWindows = process.platform === "win32";
|
|
16
|
-
function detectPort(data) {
|
|
17
|
-
const patterns = [
|
|
18
|
-
/localhost:(\d+)/i,
|
|
19
|
-
/127\.0\.0\.1:(\d+)/,
|
|
20
|
-
/0\.0\.0\.0:(\d+)/,
|
|
21
|
-
/\[::1\]:(\d+)/,
|
|
22
|
-
/Local:\s*http:\/\/[^:]+:(\d+)/i,
|
|
23
|
-
/ā\s+Local:\s+http:\/\/[^:]+:(\d+)/i
|
|
24
|
-
];
|
|
25
|
-
for (const pattern of patterns) {
|
|
26
|
-
const match = data.match(pattern);
|
|
27
|
-
if (match && match[1]) return Number.parseInt(match[1], 10);
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
async function shutdown() {
|
|
32
|
-
if (isShuttingDown) return;
|
|
33
|
-
isShuttingDown = true;
|
|
34
|
-
consola.info("\nš Shutting down...");
|
|
35
|
-
for (const [pid, proc] of runningProcesses) if (!proc.killed) {
|
|
36
|
-
consola.info(`Terminating process ${pid}...`);
|
|
37
|
-
await killProcessTree(pid);
|
|
38
|
-
}
|
|
39
|
-
runningProcesses.clear();
|
|
40
|
-
for (const port of openPorts) await killPortProcesses(port);
|
|
41
|
-
openPorts.clear();
|
|
42
|
-
if (openPorts.size > 0 || runningProcesses.size > 0) {
|
|
43
|
-
consola.warn("Some processes may still be running, performing aggressive cleanup...");
|
|
44
|
-
await aggressiveCleanup();
|
|
45
|
-
}
|
|
46
|
-
if (watchHandle?.close) await watchHandle.close();
|
|
47
|
-
consola.success("ā
Shutdown complete\n");
|
|
48
|
-
process.exit(0);
|
|
49
|
-
}
|
|
50
|
-
const command = defineCommand({
|
|
51
|
-
meta: {
|
|
52
|
-
name: "dev",
|
|
53
|
-
description: "Start the development server for the project",
|
|
54
|
-
version
|
|
55
|
-
},
|
|
56
|
-
args: {
|
|
57
|
-
...commonArgs,
|
|
58
|
-
preset: {
|
|
59
|
-
type: "string",
|
|
60
|
-
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
61
|
-
},
|
|
62
|
-
stub: {
|
|
63
|
-
type: "boolean",
|
|
64
|
-
description: "Run in silgi development mode"
|
|
65
|
-
},
|
|
66
|
-
command: {
|
|
67
|
-
type: "string",
|
|
68
|
-
description: "Optional command to run alongside watch (e.g., \"npm run dev\")",
|
|
69
|
-
required: false
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
async run({ args, rawArgs }) {
|
|
73
|
-
await runCommand(prepare_default, { rawArgs: [
|
|
74
|
-
"--commandType",
|
|
75
|
-
"dev",
|
|
76
|
-
"--dev",
|
|
77
|
-
"true"
|
|
78
|
-
] });
|
|
79
|
-
watchHandle = await watchDev();
|
|
80
|
-
const userCommand = args.command || rawArgs[0];
|
|
81
|
-
if (userCommand) {
|
|
82
|
-
consola.withTag("silgi").info(`Starting: ${userCommand}`);
|
|
83
|
-
const [cmd, ...cmdArgs] = userCommand.split(" ");
|
|
84
|
-
if (!cmd) {
|
|
85
|
-
consola.error("Invalid command provided");
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
const childProcess = spawn(cmd, cmdArgs, {
|
|
89
|
-
stdio: [
|
|
90
|
-
"inherit",
|
|
91
|
-
"pipe",
|
|
92
|
-
"pipe"
|
|
93
|
-
],
|
|
94
|
-
cwd: process.cwd(),
|
|
95
|
-
shell: isWindows,
|
|
96
|
-
detached: !isWindows,
|
|
97
|
-
env: { ...process.env }
|
|
98
|
-
});
|
|
99
|
-
if (childProcess.pid) {
|
|
100
|
-
runningProcesses.set(childProcess.pid, childProcess);
|
|
101
|
-
consola.debug(`Started process ${childProcess.pid}`);
|
|
102
|
-
}
|
|
103
|
-
childProcess.stdout?.on("data", (data) => {
|
|
104
|
-
const output = data.toString();
|
|
105
|
-
process.stdout.write(output);
|
|
106
|
-
const port = detectPort(output);
|
|
107
|
-
if (port && !openPorts.has(port)) {
|
|
108
|
-
openPorts.add(port);
|
|
109
|
-
consola.info(`Detected server on port ${port}`);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
childProcess.stderr?.on("data", (data) => {
|
|
113
|
-
process.stderr.write(data);
|
|
114
|
-
});
|
|
115
|
-
childProcess.on("exit", (code, signal) => {
|
|
116
|
-
if (childProcess.pid) runningProcesses.delete(childProcess.pid);
|
|
117
|
-
if (!isShuttingDown) {
|
|
118
|
-
if (code !== null && code !== 0) consola.error(`Process exited with code ${code}`);
|
|
119
|
-
else if (signal) consola.error(`Process killed by signal ${signal}`);
|
|
120
|
-
process.exit(code ?? 1);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
childProcess.on("error", (err) => {
|
|
124
|
-
consola.error("Child process error:", err);
|
|
125
|
-
if (!isShuttingDown) process.exit(1);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
consola.withTag("silgi").success("Prepare completed");
|
|
129
|
-
consola.withTag("silgi").info("Process is still running. Press Ctrl+C to exit.");
|
|
130
|
-
await new Promise(() => {});
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
process.on("SIGINT", shutdown);
|
|
134
|
-
process.on("SIGTERM", shutdown);
|
|
135
|
-
process.on("SIGHUP", shutdown);
|
|
136
|
-
process.on("SIGQUIT", shutdown);
|
|
137
|
-
process.on("exit", () => {
|
|
138
|
-
if (!isShuttingDown) for (const [pid] of runningProcesses) try {
|
|
139
|
-
process.kill(pid, "SIGKILL");
|
|
140
|
-
} catch {}
|
|
141
|
-
});
|
|
142
|
-
process.on("uncaughtException", (err) => {
|
|
143
|
-
consola.error("Uncaught exception:", err);
|
|
144
|
-
shutdown();
|
|
145
|
-
});
|
|
146
|
-
process.on("unhandledRejection", (err) => {
|
|
147
|
-
consola.error("Unhandled rejection:", err);
|
|
148
|
-
shutdown();
|
|
149
|
-
});
|
|
150
|
-
var watch_default = command;
|
|
151
|
-
|
|
152
|
-
//#endregion
|
|
153
|
-
export { watch_default as default };
|