@fecommunity/reactpress 3.7.0 → 4.0.0-beta.1
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/bin/reactpress-cli-shim.js +2 -6
- package/bin/reactpress-theme-client.js +2 -0
- package/bin/reactpress.js +1 -380
- package/out/.source-fingerprint-cli +1 -0
- package/out/bin/reactpress-cli-shim.d.ts +3 -0
- package/out/bin/reactpress-cli-shim.d.ts.map +1 -0
- package/out/bin/reactpress-cli-shim.js +28 -0
- package/out/bin/reactpress-cli-shim.js.map +1 -0
- package/out/bin/reactpress-theme-client.d.ts +3 -0
- package/out/bin/reactpress-theme-client.d.ts.map +1 -0
- package/out/bin/reactpress-theme-client.js +113 -0
- package/out/bin/reactpress-theme-client.js.map +1 -0
- package/out/bin/reactpress.d.ts +3 -0
- package/out/bin/reactpress.d.ts.map +1 -0
- package/out/bin/reactpress.js +566 -0
- package/out/bin/reactpress.js.map +1 -0
- package/out/core/services/config.d.ts +12 -0
- package/out/core/services/config.d.ts.map +1 -0
- package/out/core/services/config.js +137 -0
- package/out/core/services/config.js.map +1 -0
- package/out/core/services/database/index.d.ts +17 -0
- package/out/core/services/database/index.d.ts.map +1 -0
- package/out/core/services/database/index.js +242 -0
- package/out/core/services/database/index.js.map +1 -0
- package/out/core/services/database/mysql.d.ts +14 -0
- package/out/core/services/database/mysql.d.ts.map +1 -0
- package/out/core/services/database/mysql.js +82 -0
- package/out/core/services/database/mysql.js.map +1 -0
- package/out/core/services/database/profile.d.ts +6 -0
- package/out/core/services/database/profile.d.ts.map +1 -0
- package/out/core/services/database/profile.js +60 -0
- package/out/core/services/database/profile.js.map +1 -0
- package/out/core/services/database/sqlite.d.ts +10 -0
- package/out/core/services/database/sqlite.d.ts.map +1 -0
- package/out/core/services/database/sqlite.js +73 -0
- package/out/core/services/database/sqlite.js.map +1 -0
- package/out/core/services/exec.d.ts +21 -0
- package/out/core/services/exec.d.ts.map +1 -0
- package/out/core/services/exec.js +56 -0
- package/out/core/services/exec.js.map +1 -0
- package/out/core/services/init.d.ts +11 -0
- package/out/core/services/init.d.ts.map +1 -0
- package/out/core/services/init.js +60 -0
- package/out/core/services/init.js.map +1 -0
- package/out/core/services/local-site.d.ts +24 -0
- package/out/core/services/local-site.d.ts.map +1 -0
- package/out/core/services/local-site.js +144 -0
- package/out/core/services/local-site.js.map +1 -0
- package/out/core/utils/cli-context.d.ts +3 -0
- package/out/core/utils/cli-context.d.ts.map +1 -0
- package/out/core/utils/cli-context.js +12 -0
- package/out/core/utils/cli-context.js.map +1 -0
- package/out/core/utils/paths.d.ts +20 -0
- package/out/core/utils/paths.d.ts.map +1 -0
- package/out/core/utils/paths.js +34 -0
- package/out/core/utils/paths.js.map +1 -0
- package/out/core/utils/platform.d.ts +7 -0
- package/out/core/utils/platform.d.ts.map +1 -0
- package/out/core/utils/platform.js +28 -0
- package/out/core/utils/platform.js.map +1 -0
- package/out/core/utils/port.d.ts +4 -0
- package/out/core/utils/port.d.ts.map +1 -0
- package/out/core/utils/port.js +32 -0
- package/out/core/utils/port.js.map +1 -0
- package/out/lib/api-dev-runner.d.ts +3 -0
- package/out/lib/api-dev-runner.d.ts.map +1 -0
- package/{lib → out/lib}/api-dev-runner.js +4 -1
- package/out/lib/api-dev-runner.js.map +1 -0
- package/out/lib/api-dev.d.ts +2 -0
- package/out/lib/api-dev.d.ts.map +1 -0
- package/out/lib/api-dev.js +101 -0
- package/out/lib/api-dev.js.map +1 -0
- package/out/lib/bootstrap.d.ts +18 -0
- package/out/lib/bootstrap.d.ts.map +1 -0
- package/out/lib/bootstrap.js +93 -0
- package/out/lib/bootstrap.js.map +1 -0
- package/out/lib/build.d.ts +2 -0
- package/out/lib/build.d.ts.map +1 -0
- package/out/lib/build.js +191 -0
- package/out/lib/build.js.map +1 -0
- package/out/lib/db-backup.d.ts +2 -0
- package/out/lib/db-backup.d.ts.map +1 -0
- package/out/lib/db-backup.js +68 -0
- package/out/lib/db-backup.js.map +1 -0
- package/out/lib/dev-banner.d.ts +2 -0
- package/out/lib/dev-banner.d.ts.map +1 -0
- package/out/lib/dev-banner.js +102 -0
- package/out/lib/dev-banner.js.map +1 -0
- package/out/lib/dev-child-io.d.ts +2 -0
- package/out/lib/dev-child-io.d.ts.map +1 -0
- package/out/lib/dev-child-io.js +80 -0
- package/out/lib/dev-child-io.js.map +1 -0
- package/out/lib/dev-log.d.ts +2 -0
- package/out/lib/dev-log.d.ts.map +1 -0
- package/out/lib/dev-log.js +64 -0
- package/out/lib/dev-log.js.map +1 -0
- package/out/lib/dev-session.d.ts +2 -0
- package/out/lib/dev-session.d.ts.map +1 -0
- package/out/lib/dev-session.js +95 -0
- package/out/lib/dev-session.js.map +1 -0
- package/out/lib/dev.d.ts +2 -0
- package/out/lib/dev.d.ts.map +1 -0
- package/out/lib/dev.js +914 -0
- package/out/lib/dev.js.map +1 -0
- package/out/lib/docker.d.ts +2 -0
- package/out/lib/docker.d.ts.map +1 -0
- package/out/lib/docker.js +398 -0
- package/out/lib/docker.js.map +1 -0
- package/out/lib/doctor.d.ts +2 -0
- package/out/lib/doctor.d.ts.map +1 -0
- package/out/lib/doctor.js +260 -0
- package/out/lib/doctor.js.map +1 -0
- package/out/lib/health-parse.d.ts +5 -0
- package/out/lib/health-parse.d.ts.map +1 -0
- package/out/lib/health-parse.js +36 -0
- package/out/lib/health-parse.js.map +1 -0
- package/out/lib/health-parse.test.d.ts +2 -0
- package/out/lib/health-parse.test.d.ts.map +1 -0
- package/out/lib/health-parse.test.js +19 -0
- package/out/lib/health-parse.test.js.map +1 -0
- package/out/lib/http.d.ts +2 -0
- package/out/lib/http.d.ts.map +1 -0
- package/out/lib/http.js +234 -0
- package/out/lib/http.js.map +1 -0
- package/out/lib/i18n/index.d.ts +2 -0
- package/out/lib/i18n/index.d.ts.map +1 -0
- package/out/lib/i18n/index.js +29 -0
- package/out/lib/i18n/index.js.map +1 -0
- package/out/lib/i18n/strings.d.ts +2 -0
- package/out/lib/i18n/strings.d.ts.map +1 -0
- package/out/lib/i18n/strings.js +1192 -0
- package/out/lib/i18n/strings.js.map +1 -0
- package/out/lib/lifecycle.d.ts +2 -0
- package/out/lib/lifecycle.d.ts.map +1 -0
- package/out/lib/lifecycle.js +169 -0
- package/out/lib/lifecycle.js.map +1 -0
- package/out/lib/nginx.d.ts +2 -0
- package/out/lib/nginx.d.ts.map +1 -0
- package/out/lib/nginx.js +618 -0
- package/out/lib/nginx.js.map +1 -0
- package/out/lib/paths.d.ts +2 -0
- package/out/lib/paths.d.ts.map +1 -0
- package/out/lib/paths.js +106 -0
- package/out/lib/paths.js.map +1 -0
- package/out/lib/plugin-build.d.ts +2 -0
- package/out/lib/plugin-build.d.ts.map +1 -0
- package/out/lib/plugin-build.js +104 -0
- package/out/lib/plugin-build.js.map +1 -0
- package/out/lib/plugin-cli.d.ts +2 -0
- package/out/lib/plugin-cli.d.ts.map +1 -0
- package/out/lib/plugin-cli.js +142 -0
- package/out/lib/plugin-cli.js.map +1 -0
- package/out/lib/pm2.d.ts +2 -0
- package/out/lib/pm2.d.ts.map +1 -0
- package/out/lib/pm2.js +32 -0
- package/out/lib/pm2.js.map +1 -0
- package/out/lib/ports.d.ts +2 -0
- package/out/lib/ports.d.ts.map +1 -0
- package/out/lib/ports.js +394 -0
- package/out/lib/ports.js.map +1 -0
- package/out/lib/process.d.ts +2 -0
- package/out/lib/process.d.ts.map +1 -0
- package/out/lib/process.js +47 -0
- package/out/lib/process.js.map +1 -0
- package/out/lib/prod-memory.d.ts +6 -0
- package/out/lib/prod-memory.d.ts.map +1 -0
- package/out/lib/prod-memory.js +57 -0
- package/out/lib/prod-memory.js.map +1 -0
- package/out/lib/project-type.d.ts +2 -0
- package/out/lib/project-type.d.ts.map +1 -0
- package/out/lib/project-type.js +95 -0
- package/out/lib/project-type.js.map +1 -0
- package/out/lib/publish.d.ts +3 -0
- package/out/lib/publish.d.ts.map +1 -0
- package/out/lib/publish.js +388 -0
- package/out/lib/publish.js.map +1 -0
- package/out/lib/remote-dev.d.ts +2 -0
- package/out/lib/remote-dev.d.ts.map +1 -0
- package/out/lib/remote-dev.js +158 -0
- package/out/lib/remote-dev.js.map +1 -0
- package/out/lib/root.d.ts +2 -0
- package/out/lib/root.d.ts.map +1 -0
- package/out/lib/root.js +85 -0
- package/out/lib/root.js.map +1 -0
- package/out/lib/spawn.d.ts +2 -0
- package/out/lib/spawn.d.ts.map +1 -0
- package/out/lib/spawn.js +96 -0
- package/out/lib/spawn.js.map +1 -0
- package/out/lib/status.d.ts +2 -0
- package/out/lib/status.d.ts.map +1 -0
- package/out/lib/status.js +78 -0
- package/out/lib/status.js.map +1 -0
- package/out/lib/theme-catalog.d.ts +2 -0
- package/out/lib/theme-catalog.d.ts.map +1 -0
- package/out/lib/theme-catalog.js +6 -0
- package/out/lib/theme-catalog.js.map +1 -0
- package/out/lib/theme-cli.d.ts +2 -0
- package/out/lib/theme-cli.d.ts.map +1 -0
- package/out/lib/theme-cli.js +50 -0
- package/out/lib/theme-cli.js.map +1 -0
- package/out/lib/theme-dev.d.ts +2 -0
- package/out/lib/theme-dev.d.ts.map +1 -0
- package/out/lib/theme-dev.js +759 -0
- package/out/lib/theme-dev.js.map +1 -0
- package/out/lib/theme-env.d.ts +2 -0
- package/out/lib/theme-env.d.ts.map +1 -0
- package/out/lib/theme-env.js +101 -0
- package/out/lib/theme-env.js.map +1 -0
- package/out/lib/theme-install.d.ts +2 -0
- package/out/lib/theme-install.d.ts.map +1 -0
- package/out/lib/theme-install.js +363 -0
- package/out/lib/theme-install.js.map +1 -0
- package/out/lib/theme-lock.d.ts +2 -0
- package/out/lib/theme-lock.d.ts.map +1 -0
- package/out/lib/theme-lock.js +70 -0
- package/out/lib/theme-lock.js.map +1 -0
- package/out/lib/theme-paths.d.ts +2 -0
- package/out/lib/theme-paths.d.ts.map +1 -0
- package/out/lib/theme-paths.js +73 -0
- package/out/lib/theme-paths.js.map +1 -0
- package/out/lib/theme-placeholder-cover.d.ts +13 -0
- package/out/lib/theme-placeholder-cover.d.ts.map +1 -0
- package/out/lib/theme-placeholder-cover.js +95 -0
- package/out/lib/theme-placeholder-cover.js.map +1 -0
- package/out/lib/theme-preview-frame.d.ts +2 -0
- package/out/lib/theme-preview-frame.d.ts.map +1 -0
- package/out/lib/theme-preview-frame.js +107 -0
- package/out/lib/theme-preview-frame.js.map +1 -0
- package/out/lib/theme-preview-pool.d.ts +2 -0
- package/out/lib/theme-preview-pool.d.ts.map +1 -0
- package/out/lib/theme-preview-pool.js +484 -0
- package/out/lib/theme-preview-pool.js.map +1 -0
- package/out/lib/theme-preview-proxy.d.ts +2 -0
- package/out/lib/theme-preview-proxy.d.ts.map +1 -0
- package/out/lib/theme-preview-proxy.js +101 -0
- package/out/lib/theme-preview-proxy.js.map +1 -0
- package/out/lib/theme-prod.d.ts +2 -0
- package/out/lib/theme-prod.d.ts.map +1 -0
- package/out/lib/theme-prod.js +400 -0
- package/out/lib/theme-prod.js.map +1 -0
- package/out/lib/theme-registry.d.ts +2 -0
- package/out/lib/theme-registry.d.ts.map +1 -0
- package/out/lib/theme-registry.js +135 -0
- package/out/lib/theme-registry.js.map +1 -0
- package/out/lib/theme-runtime.d.ts +2 -0
- package/out/lib/theme-runtime.d.ts.map +1 -0
- package/out/lib/theme-runtime.js +344 -0
- package/out/lib/theme-runtime.js.map +1 -0
- package/out/lib/theme-sources.d.ts +2 -0
- package/out/lib/theme-sources.d.ts.map +1 -0
- package/out/lib/theme-sources.js +347 -0
- package/out/lib/theme-sources.js.map +1 -0
- package/out/lib/theme-warmup.d.ts +2 -0
- package/out/lib/theme-warmup.d.ts.map +1 -0
- package/out/lib/theme-warmup.js +167 -0
- package/out/lib/theme-warmup.js.map +1 -0
- package/out/lib/toolkit-build.d.ts +2 -0
- package/out/lib/toolkit-build.d.ts.map +1 -0
- package/out/lib/toolkit-build.js +57 -0
- package/out/lib/toolkit-build.js.map +1 -0
- package/out/types/config.d.ts +57 -0
- package/out/types/config.d.ts.map +1 -0
- package/out/types/config.js +3 -0
- package/out/types/config.js.map +1 -0
- package/out/ui/banner.d.ts +2 -0
- package/out/ui/banner.d.ts.map +1 -0
- package/out/ui/banner.js +358 -0
- package/out/ui/banner.js.map +1 -0
- package/out/ui/interactive.d.ts +2 -0
- package/out/ui/interactive.d.ts.map +1 -0
- package/out/ui/interactive.js +378 -0
- package/out/ui/interactive.js.map +1 -0
- package/out/ui/prompts.d.ts +2 -0
- package/out/ui/prompts.d.ts.map +1 -0
- package/out/ui/prompts.js +91 -0
- package/out/ui/prompts.js.map +1 -0
- package/out/ui/theme.d.ts +2 -0
- package/out/ui/theme.d.ts.map +1 -0
- package/out/ui/theme.js +250 -0
- package/out/ui/theme.js.map +1 -0
- package/package.json +13 -7
- package/server/dist/common/api-messages.d.ts +9 -0
- package/server/dist/common/api-messages.js +9 -0
- package/server/dist/common/api-messages.js.map +1 -1
- package/server/dist/database/typeorm-options.d.ts +3 -0
- package/server/dist/database/typeorm-options.js +60 -0
- package/server/dist/database/typeorm-options.js.map +1 -0
- package/server/dist/modules/api-key/api-key.controller.js.map +1 -1
- package/server/dist/modules/api-key/api-key.entity.js.map +1 -1
- package/server/dist/modules/api-key/api-key.guard.js +2 -3
- package/server/dist/modules/api-key/api-key.guard.js.map +1 -1
- package/server/dist/modules/api-key/api-key.module.js.map +1 -1
- package/server/dist/modules/api-key/api-key.service.js +1 -1
- package/server/dist/modules/api-key/api-key.service.js.map +1 -1
- package/server/dist/modules/article/article-revision.entity.js +3 -3
- package/server/dist/modules/article/article-revision.entity.js.map +1 -1
- package/server/dist/modules/article/article-slug.util.d.ts +2 -0
- package/server/dist/modules/article/article-slug.util.js +19 -0
- package/server/dist/modules/article/article-slug.util.js.map +1 -0
- package/server/dist/modules/article/scheduled-publish.service.js.map +1 -1
- package/server/dist/modules/bootstrap/bootstrap.constants.d.ts +20 -0
- package/server/dist/modules/bootstrap/bootstrap.constants.js +171 -0
- package/server/dist/modules/bootstrap/bootstrap.constants.js.map +1 -0
- package/server/dist/modules/bootstrap/bootstrap.service.d.ts +22 -0
- package/server/dist/modules/bootstrap/bootstrap.service.js +183 -0
- package/server/dist/modules/bootstrap/bootstrap.service.js.map +1 -0
- package/server/dist/modules/bootstrap/install-locale.d.ts +2 -0
- package/server/dist/modules/bootstrap/install-locale.js +11 -0
- package/server/dist/modules/bootstrap/install-locale.js.map +1 -0
- package/server/dist/modules/extension/extension.module.d.ts +9 -0
- package/server/dist/modules/extension/extension.module.js +50 -0
- package/server/dist/modules/extension/extension.module.js.map +1 -0
- package/server/dist/modules/extension/plugin-loader.service.d.ts +12 -0
- package/server/dist/modules/extension/plugin-loader.service.js +96 -0
- package/server/dist/modules/extension/plugin-loader.service.js.map +1 -0
- package/server/dist/modules/extension/plugin-registry.bridge.d.ts +3 -0
- package/server/dist/modules/extension/plugin-registry.bridge.js +44 -0
- package/server/dist/modules/extension/plugin-registry.bridge.js.map +1 -0
- package/server/dist/modules/extension/plugin.controller.d.ts +22 -0
- package/server/dist/modules/extension/plugin.controller.js +155 -0
- package/server/dist/modules/extension/plugin.controller.js.map +1 -0
- package/server/dist/modules/extension/plugin.service.d.ts +52 -0
- package/server/dist/modules/extension/plugin.service.js +391 -0
- package/server/dist/modules/extension/plugin.service.js.map +1 -0
- package/server/dist/modules/extension/preview-draft.store.d.ts +13 -0
- package/server/dist/modules/extension/preview-draft.store.js +41 -0
- package/server/dist/modules/extension/preview-draft.store.js.map +1 -0
- package/server/dist/modules/extension/theme-registry.bridge.d.ts +56 -0
- package/server/dist/modules/extension/theme-registry.bridge.js +46 -0
- package/server/dist/modules/extension/theme-registry.bridge.js.map +1 -0
- package/server/dist/modules/extension/theme.controller.d.ts +66 -0
- package/server/dist/modules/extension/theme.controller.js +301 -0
- package/server/dist/modules/extension/theme.controller.js.map +1 -0
- package/server/dist/modules/extension/theme.service.d.ts +140 -0
- package/server/dist/modules/extension/theme.service.js +1039 -0
- package/server/dist/modules/extension/theme.service.js.map +1 -0
- package/server/dist/modules/file/file-optimization.controller.d.ts +12 -0
- package/server/dist/modules/file/file-optimization.controller.js +79 -0
- package/server/dist/modules/file/file-optimization.controller.js.map +1 -0
- package/server/dist/modules/file/file-optimization.service.d.ts +36 -0
- package/server/dist/modules/file/file-optimization.service.js +385 -0
- package/server/dist/modules/file/file-optimization.service.js.map +1 -0
- package/server/dist/modules/file/file-optimization.types.d.ts +66 -0
- package/server/dist/modules/file/file-optimization.types.js +5 -0
- package/server/dist/modules/file/file-optimization.types.js.map +1 -0
- package/server/dist/modules/file/image-optimizer-plugin.guard.d.ts +7 -0
- package/server/dist/modules/file/image-optimizer-plugin.guard.js +33 -0
- package/server/dist/modules/file/image-optimizer-plugin.guard.js.map +1 -0
- package/server/dist/modules/health/health.controller.js +2 -4
- package/server/dist/modules/health/health.controller.js.map +1 -1
- package/server/dist/modules/health/health.module.js.map +1 -1
- package/server/dist/modules/hook/hook.module.d.ts +2 -0
- package/server/dist/modules/hook/hook.module.js +22 -0
- package/server/dist/modules/hook/hook.module.js.map +1 -0
- package/server/dist/modules/hook/hook.service.d.ts +26 -0
- package/server/dist/modules/hook/hook.service.js +105 -0
- package/server/dist/modules/hook/hook.service.js.map +1 -0
- package/server/dist/modules/webhook/webhook.controller.js.map +1 -1
- package/server/dist/modules/webhook/webhook.entity.js.map +1 -1
- package/server/dist/modules/webhook/webhook.module.js.map +1 -1
- package/server/dist/modules/webhook/webhook.service.d.ts +1 -1
- package/server/dist/modules/webhook/webhook.service.js +5 -2
- package/server/dist/modules/webhook/webhook.service.js.map +1 -1
- package/server/dist/node-polyfills.d.ts +18 -0
- package/server/dist/node-polyfills.js +24 -0
- package/server/dist/node-polyfills.js.map +1 -0
- package/server/dist/public/uploads/2026-05-30/QR3X4UZQ93ZTUPGXCFA9II..png +0 -0
- package/server/dist/public/uploads/2026-05-31/BXQV3NX9ZVWHGNOSX9AXD8.webp +0 -0
- package/server/dist/public/uploads/2026-05-31/BXQV3NX9ZVWHGNOSX9AXD8_medium.webp +0 -0
- package/server/dist/public/uploads/2026-05-31/BXQV3NX9ZVWHGNOSX9AXD8_thumb.webp +0 -0
- package/server/dist/public/uploads/2026-05-31/I2SZC0ONA7CF31UM46MN56..jpg +0 -0
- package/server/dist/tsconfig.tsbuildinfo +1 -0
- package/server/dist/utils/image-processor.util.d.ts +23 -0
- package/server/dist/utils/image-processor.util.js +88 -0
- package/server/dist/utils/image-processor.util.js.map +1 -0
- package/server/dist/utils/local-api-quiet.util.d.ts +1 -0
- package/server/dist/utils/local-api-quiet.util.js +8 -0
- package/server/dist/utils/local-api-quiet.util.js.map +1 -0
- package/server/dist/utils/project-root.util.d.ts +2 -0
- package/server/dist/utils/project-root.util.js +42 -0
- package/server/dist/utils/project-root.util.js.map +1 -0
- package/server/public/uploads/2026-05-30/QR3X4UZQ93ZTUPGXCFA9II..png +0 -0
- package/server/public/uploads/2026-05-31/BXQV3NX9ZVWHGNOSX9AXD8.webp +0 -0
- package/server/public/uploads/2026-05-31/BXQV3NX9ZVWHGNOSX9AXD8_medium.webp +0 -0
- package/server/public/uploads/2026-05-31/BXQV3NX9ZVWHGNOSX9AXD8_thumb.webp +0 -0
- package/server/public/uploads/2026-05-31/I2SZC0ONA7CF31UM46MN56..jpg +0 -0
- package/templates/config.local.json +13 -0
- package/templates/env.local.default +10 -0
- package/templates/theme-catalog.json +27 -0
- package/lib/api-dev.js +0 -89
- package/lib/bootstrap.js +0 -114
- package/lib/build.js +0 -162
- package/lib/db-backup.js +0 -67
- package/lib/dev-banner.js +0 -72
- package/lib/dev.js +0 -141
- package/lib/docker.js +0 -275
- package/lib/doctor.js +0 -266
- package/lib/http.js +0 -182
- package/lib/i18n/index.js +0 -32
- package/lib/i18n/strings.js +0 -846
- package/lib/lifecycle.js +0 -190
- package/lib/nginx.js +0 -342
- package/lib/paths.js +0 -108
- package/lib/pm2.js +0 -32
- package/lib/process.js +0 -45
- package/lib/project-type.js +0 -72
- package/lib/publish.js +0 -968
- package/lib/root.js +0 -88
- package/lib/spawn.js +0 -92
- package/lib/status.js +0 -132
- package/ui/banner.js +0 -441
- package/ui/interactive.js +0 -380
- package/ui/theme.js +0 -265
package/lib/lifecycle.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const ora = require('ora');
|
|
3
|
-
const { ensureProjectEnvironment } = require('./bootstrap');
|
|
4
|
-
const { loadServerSiteUrl, waitForHttp } = require('./http');
|
|
5
|
-
const {
|
|
6
|
-
getServerBin,
|
|
7
|
-
getServerDir,
|
|
8
|
-
isUsingMonorepoServer,
|
|
9
|
-
canStartLocalApi,
|
|
10
|
-
getPidFile,
|
|
11
|
-
} = require('./paths');
|
|
12
|
-
const net = require('net');
|
|
13
|
-
const { readPid, isProcessRunning, clearPidFile, writePid } = require('./process');
|
|
14
|
-
const { ensureOriginalCwd } = require('./root');
|
|
15
|
-
const { t } = require('./i18n');
|
|
16
|
-
|
|
17
|
-
function parseServerPort(projectRoot) {
|
|
18
|
-
try {
|
|
19
|
-
const url = new URL(loadServerSiteUrl(projectRoot));
|
|
20
|
-
return Number(url.port) || 3002;
|
|
21
|
-
} catch {
|
|
22
|
-
return 3002;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function isPortBusy(port, host = '127.0.0.1') {
|
|
27
|
-
return new Promise((resolve) => {
|
|
28
|
-
const socket = net.createConnection({ port, host }, () => {
|
|
29
|
-
socket.destroy();
|
|
30
|
-
resolve(true);
|
|
31
|
-
});
|
|
32
|
-
socket.on('error', () => resolve(false));
|
|
33
|
-
socket.setTimeout(800, () => {
|
|
34
|
-
socket.destroy();
|
|
35
|
-
resolve(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function waitForPortFree(port, timeoutMs = 8000) {
|
|
41
|
-
const deadline = Date.now() + timeoutMs;
|
|
42
|
-
while (Date.now() < deadline) {
|
|
43
|
-
if (!(await isPortBusy(port))) return true;
|
|
44
|
-
await new Promise((r) => setTimeout(r, 200));
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function ensureConfig(projectRoot) {
|
|
50
|
-
try {
|
|
51
|
-
await ensureProjectEnvironment(projectRoot);
|
|
52
|
-
return true;
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.error(t('dev.envFailed'), err.message || err);
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function stopApi(projectRoot) {
|
|
60
|
-
const pid = readPid(projectRoot);
|
|
61
|
-
if (pid && isProcessRunning(pid)) {
|
|
62
|
-
try {
|
|
63
|
-
process.kill(pid, 'SIGTERM');
|
|
64
|
-
console.log(t('lifecycle.apiStopped', { pid }));
|
|
65
|
-
} catch (err) {
|
|
66
|
-
console.warn(t('lifecycle.stopPidFailed', { pid }), err.message);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
clearPidFile(projectRoot);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function startApi(projectRoot, { wait = true } = {}) {
|
|
73
|
-
if (!(await ensureConfig(projectRoot))) {
|
|
74
|
-
return 1;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const existing = readPid(projectRoot);
|
|
78
|
-
if (existing && isProcessRunning(existing)) {
|
|
79
|
-
console.log(t('lifecycle.apiAlreadyRunning', { pid: existing }));
|
|
80
|
-
return 0;
|
|
81
|
-
}
|
|
82
|
-
clearPidFile(projectRoot);
|
|
83
|
-
|
|
84
|
-
if (!canStartLocalApi(projectRoot)) {
|
|
85
|
-
console.error(t('lifecycle.noServerAvailable'));
|
|
86
|
-
return 1;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (isUsingMonorepoServer(projectRoot)) {
|
|
90
|
-
console.log(t('lifecycle.startingLocalApi'));
|
|
91
|
-
} else {
|
|
92
|
-
console.log(t('lifecycle.startingBundledApi'));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const child = spawn(process.execPath, [getServerBin(projectRoot)], {
|
|
96
|
-
cwd: getServerDir(projectRoot),
|
|
97
|
-
detached: true,
|
|
98
|
-
stdio: 'ignore',
|
|
99
|
-
env: {
|
|
100
|
-
...process.env,
|
|
101
|
-
REACTPRESS_ORIGINAL_CWD: projectRoot,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
child.unref();
|
|
106
|
-
writePid(projectRoot, child.pid);
|
|
107
|
-
console.log(t('lifecycle.apiStartedBg', { pid: child.pid }));
|
|
108
|
-
|
|
109
|
-
if (!wait) {
|
|
110
|
-
return 0;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const serverUrl = loadServerSiteUrl(projectRoot);
|
|
114
|
-
const spinner = ora({
|
|
115
|
-
text: t('dev.waitingApi', { url: serverUrl }),
|
|
116
|
-
color: 'magenta',
|
|
117
|
-
spinner: 'dots',
|
|
118
|
-
}).start();
|
|
119
|
-
const ready = await waitForHttp(serverUrl);
|
|
120
|
-
if (!ready) {
|
|
121
|
-
spinner.fail(t('lifecycle.apiTimeout120', { url: serverUrl }));
|
|
122
|
-
return 1;
|
|
123
|
-
}
|
|
124
|
-
spinner.succeed(t('lifecycle.apiReady', { url: serverUrl }));
|
|
125
|
-
return 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
async function statusApi(projectRoot) {
|
|
129
|
-
const pid = readPid(projectRoot);
|
|
130
|
-
const serverUrl = loadServerSiteUrl(projectRoot);
|
|
131
|
-
const { isHttpResponding } = require('./http');
|
|
132
|
-
const httpOk = await isHttpResponding(serverUrl);
|
|
133
|
-
|
|
134
|
-
const source = isUsingMonorepoServer(projectRoot)
|
|
135
|
-
? t('lifecycle.source.monorepo')
|
|
136
|
-
: t('lifecycle.source.bundle');
|
|
137
|
-
|
|
138
|
-
console.log(t('lifecycle.apiStatusTitle'));
|
|
139
|
-
console.log(t('lifecycle.source', { source }));
|
|
140
|
-
console.log(t('lifecycle.pidFile', { path: getPidFile(projectRoot) }));
|
|
141
|
-
console.log(
|
|
142
|
-
t('lifecycle.recordedPid', {
|
|
143
|
-
pid: pid ?? t('common.none'),
|
|
144
|
-
})
|
|
145
|
-
);
|
|
146
|
-
console.log(
|
|
147
|
-
t('lifecycle.processAlive', {
|
|
148
|
-
alive: pid
|
|
149
|
-
? isProcessRunning(pid)
|
|
150
|
-
? t('common.yes')
|
|
151
|
-
: t('common.no')
|
|
152
|
-
: '—',
|
|
153
|
-
})
|
|
154
|
-
);
|
|
155
|
-
console.log(
|
|
156
|
-
t('lifecycle.httpStatus', {
|
|
157
|
-
url: serverUrl,
|
|
158
|
-
status: httpOk ? t('lifecycle.httpReachable') : t('lifecycle.httpUnreachable'),
|
|
159
|
-
})
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async function runLifecycleCommand(command, projectRoot = ensureOriginalCwd()) {
|
|
164
|
-
switch (command) {
|
|
165
|
-
case 'start':
|
|
166
|
-
return startApi(projectRoot, { wait: true });
|
|
167
|
-
case 'start:bg':
|
|
168
|
-
return startApi(projectRoot, { wait: false });
|
|
169
|
-
case 'stop':
|
|
170
|
-
stopApi(projectRoot);
|
|
171
|
-
return 0;
|
|
172
|
-
case 'restart':
|
|
173
|
-
stopApi(projectRoot);
|
|
174
|
-
await waitForPortFree(parseServerPort(projectRoot));
|
|
175
|
-
await new Promise((r) => setTimeout(r, 400));
|
|
176
|
-
return startApi(projectRoot, { wait: true });
|
|
177
|
-
case 'status':
|
|
178
|
-
await statusApi(projectRoot);
|
|
179
|
-
return 0;
|
|
180
|
-
default:
|
|
181
|
-
throw new Error(t('lifecycle.unknownCommand', { command }));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
module.exports = {
|
|
186
|
-
startApi,
|
|
187
|
-
stopApi,
|
|
188
|
-
statusApi,
|
|
189
|
-
runLifecycleCommand,
|
|
190
|
-
};
|
package/lib/nginx.js
DELETED
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const http = require('http');
|
|
4
|
-
const { spawnSync } = require('child_process');
|
|
5
|
-
const open = require('open');
|
|
6
|
-
const { detectProjectType } = require('./project-type');
|
|
7
|
-
const { isDockerRunning, pickDockerComposeCommand } = require('./docker');
|
|
8
|
-
const { t } = require('./i18n');
|
|
9
|
-
|
|
10
|
-
const NGINX_CONTAINER = 'reactpress_nginx';
|
|
11
|
-
const DEFAULT_NGINX_PORT = 80;
|
|
12
|
-
|
|
13
|
-
function resolveNginxMode(options = {}) {
|
|
14
|
-
return options.prod ? 'prod' : 'dev';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function resolveNginxConfigBasename(mode) {
|
|
18
|
-
return mode === 'prod' ? 'nginx.conf' : 'nginx.dev.conf';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function resolveNginxConfigPath(projectRoot, mode = 'dev') {
|
|
22
|
-
const basename = resolveNginxConfigBasename(mode);
|
|
23
|
-
const type = detectProjectType(projectRoot);
|
|
24
|
-
if (type === 'monorepo') {
|
|
25
|
-
return path.join(projectRoot, basename);
|
|
26
|
-
}
|
|
27
|
-
return path.join(projectRoot, '.reactpress', basename);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function bundledTemplatePath(mode) {
|
|
31
|
-
const file = mode === 'prod' ? 'nginx.prod.conf' : 'nginx.dev.conf';
|
|
32
|
-
return path.join(__dirname, '..', 'templates', file);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function resolveNginxPort(projectRoot) {
|
|
36
|
-
const envPath = path.join(projectRoot, '.env');
|
|
37
|
-
try {
|
|
38
|
-
const content = fs.readFileSync(envPath, 'utf8');
|
|
39
|
-
const m = content.match(/^NGINX_PORT=(.+)$/m);
|
|
40
|
-
if (m) {
|
|
41
|
-
const port = parseInt(m[1].trim().replace(/^['"]|['"]$/g, ''), 10);
|
|
42
|
-
if (port > 0) return port;
|
|
43
|
-
}
|
|
44
|
-
} catch {
|
|
45
|
-
// ignore
|
|
46
|
-
}
|
|
47
|
-
return DEFAULT_NGINX_PORT;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function nginxEntryUrl(projectRoot) {
|
|
51
|
-
const port = resolveNginxPort(projectRoot);
|
|
52
|
-
return port === 80 ? 'http://localhost' : `http://localhost:${port}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Write default nginx config from CLI templates when missing (or when force).
|
|
57
|
-
*
|
|
58
|
-
* @returns {{ configPath: string, created: boolean, mode: 'dev' | 'prod' }}
|
|
59
|
-
*/
|
|
60
|
-
function ensureNginxConfig(projectRoot, options = {}) {
|
|
61
|
-
const mode = resolveNginxMode(options);
|
|
62
|
-
const configPath = resolveNginxConfigPath(projectRoot, mode);
|
|
63
|
-
const templatePath = bundledTemplatePath(mode);
|
|
64
|
-
if (!fs.existsSync(templatePath)) {
|
|
65
|
-
throw new Error(t('nginx.templateMissing', { path: templatePath }));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const exists = fs.existsSync(configPath);
|
|
69
|
-
if (exists && !options.force) {
|
|
70
|
-
return { configPath, created: false, mode };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
74
|
-
fs.copyFileSync(templatePath, configPath);
|
|
75
|
-
return { configPath, created: !exists || !!options.force, mode };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function resolveNginxComposeContext(projectRoot, mode = 'dev') {
|
|
79
|
-
const type = detectProjectType(projectRoot);
|
|
80
|
-
if (mode === 'prod' && type === 'monorepo') {
|
|
81
|
-
return {
|
|
82
|
-
composeFile: path.join(projectRoot, 'docker-compose.prod.yml'),
|
|
83
|
-
cwd: projectRoot,
|
|
84
|
-
service: 'nginx',
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
if (type === 'monorepo') {
|
|
88
|
-
return {
|
|
89
|
-
composeFile: path.join(projectRoot, 'docker-compose.dev.yml'),
|
|
90
|
-
cwd: projectRoot,
|
|
91
|
-
service: 'nginx',
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
composeFile: path.join(projectRoot, '.reactpress', 'docker-compose.yml'),
|
|
96
|
-
cwd: path.join(projectRoot, '.reactpress'),
|
|
97
|
-
service: 'nginx',
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function composeDefinesNginxService(composeFile) {
|
|
102
|
-
try {
|
|
103
|
-
const content = fs.readFileSync(composeFile, 'utf8');
|
|
104
|
-
return /^\s*nginx:\s*$/m.test(content);
|
|
105
|
-
} catch {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function runComposeOnContext(ctx, args, options = {}) {
|
|
111
|
-
const { command, baseArgs } = pickDockerComposeCommand();
|
|
112
|
-
return spawnSync(command, [...baseArgs, '-f', ctx.composeFile, ...args], {
|
|
113
|
-
stdio: options.stdio ?? 'inherit',
|
|
114
|
-
cwd: ctx.cwd,
|
|
115
|
-
...options,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function isNginxContainerRunning() {
|
|
120
|
-
const res = spawnSync(
|
|
121
|
-
'docker',
|
|
122
|
-
['inspect', '-f', '{{.State.Running}}', NGINX_CONTAINER],
|
|
123
|
-
{ encoding: 'utf8' }
|
|
124
|
-
);
|
|
125
|
-
return res.status === 0 && res.stdout.trim() === 'true';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function startNginxContainer(configPath, port) {
|
|
129
|
-
spawnSync('docker', ['rm', '-f', NGINX_CONTAINER], { stdio: 'ignore' });
|
|
130
|
-
const absConfig = path.resolve(configPath);
|
|
131
|
-
const res = spawnSync(
|
|
132
|
-
'docker',
|
|
133
|
-
[
|
|
134
|
-
'run',
|
|
135
|
-
'-d',
|
|
136
|
-
'--name',
|
|
137
|
-
NGINX_CONTAINER,
|
|
138
|
-
'-p',
|
|
139
|
-
`${port}:80`,
|
|
140
|
-
'-v',
|
|
141
|
-
`${absConfig}:/etc/nginx/conf.d/default.conf:ro`,
|
|
142
|
-
'--add-host',
|
|
143
|
-
'host.docker.internal:host-gateway',
|
|
144
|
-
'nginx:alpine',
|
|
145
|
-
],
|
|
146
|
-
{ encoding: 'utf8' }
|
|
147
|
-
);
|
|
148
|
-
if (res.status !== 0) {
|
|
149
|
-
throw new Error(res.stderr?.trim() || t('nginx.startFailed'));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function stopNginxContainer() {
|
|
154
|
-
spawnSync('docker', ['rm', '-sf', NGINX_CONTAINER], { stdio: 'ignore' });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function nginxUp(projectRoot, options = {}) {
|
|
158
|
-
if (!isDockerRunning()) {
|
|
159
|
-
throw new Error(t('docker.notRunning'));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const mode = resolveNginxMode(options);
|
|
163
|
-
const type = detectProjectType(projectRoot);
|
|
164
|
-
|
|
165
|
-
if (mode === 'prod' && type !== 'monorepo') {
|
|
166
|
-
throw new Error(t('nginx.prodMonorepoOnly'));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const { configPath } = ensureNginxConfig(projectRoot, { mode, force: options.force });
|
|
170
|
-
const port = resolveNginxPort(projectRoot);
|
|
171
|
-
const ctx = resolveNginxComposeContext(projectRoot, mode);
|
|
172
|
-
|
|
173
|
-
if (fs.existsSync(ctx.composeFile) && composeDefinesNginxService(ctx.composeFile)) {
|
|
174
|
-
const result = runComposeOnContext(ctx, ['up', '-d', ctx.service]);
|
|
175
|
-
if (result.status !== 0) {
|
|
176
|
-
throw new Error(t('nginx.startFailed'));
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
startNginxContainer(configPath, port);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
console.log(t('nginx.started', { url: nginxEntryUrl(projectRoot) }));
|
|
183
|
-
console.log(t('nginx.configPath', { path: configPath }));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function nginxDown(projectRoot, options = {}) {
|
|
187
|
-
const mode = resolveNginxMode(options);
|
|
188
|
-
const ctx = resolveNginxComposeContext(projectRoot, mode);
|
|
189
|
-
if (fs.existsSync(ctx.composeFile) && composeDefinesNginxService(ctx.composeFile)) {
|
|
190
|
-
runComposeOnContext(ctx, ['stop', ctx.service], { stdio: 'ignore' });
|
|
191
|
-
}
|
|
192
|
-
stopNginxContainer();
|
|
193
|
-
console.log(t('nginx.stopped'));
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function nginxRestart(projectRoot, options = {}) {
|
|
197
|
-
nginxDown(projectRoot, options);
|
|
198
|
-
nginxUp(projectRoot, options);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function nginxStatus(projectRoot, options = {}) {
|
|
202
|
-
const mode = resolveNginxMode(options);
|
|
203
|
-
const configPath = resolveNginxConfigPath(projectRoot, mode);
|
|
204
|
-
const port = resolveNginxPort(projectRoot);
|
|
205
|
-
const running = isNginxContainerRunning();
|
|
206
|
-
const configExists = fs.existsSync(configPath);
|
|
207
|
-
|
|
208
|
-
console.log(t('nginx.statusTitle'));
|
|
209
|
-
console.log(t('nginx.statusContainer', { name: NGINX_CONTAINER, running: running ? t('common.yes') : t('common.no') }));
|
|
210
|
-
console.log(t('nginx.statusConfig', { path: configPath, exists: configExists ? t('common.yes') : t('common.no') }));
|
|
211
|
-
console.log(t('nginx.statusUrl', { url: nginxEntryUrl(projectRoot), port }));
|
|
212
|
-
console.log(t('nginx.statusMode', { mode }));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function nginxLogs(extraArgs = []) {
|
|
216
|
-
const args = ['logs', '-f', NGINX_CONTAINER, ...extraArgs];
|
|
217
|
-
spawnSync('docker', args, { stdio: 'inherit' });
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function dockerExecNginx(args) {
|
|
221
|
-
return spawnSync('docker', ['exec', NGINX_CONTAINER, 'nginx', ...args], {
|
|
222
|
-
encoding: 'utf8',
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function nginxTest() {
|
|
227
|
-
if (!isNginxContainerRunning()) {
|
|
228
|
-
throw new Error(t('nginx.notRunning'));
|
|
229
|
-
}
|
|
230
|
-
const res = dockerExecNginx(['-t']);
|
|
231
|
-
process.stdout.write(res.stdout || '');
|
|
232
|
-
process.stderr.write(res.stderr || '');
|
|
233
|
-
if (res.status !== 0) {
|
|
234
|
-
throw new Error(t('nginx.testFailed'));
|
|
235
|
-
}
|
|
236
|
-
console.log(t('nginx.testOk'));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function nginxReload() {
|
|
240
|
-
nginxTest();
|
|
241
|
-
const res = dockerExecNginx(['-s', 'reload']);
|
|
242
|
-
if (res.status !== 0) {
|
|
243
|
-
throw new Error(res.stderr?.trim() || t('nginx.reloadFailed'));
|
|
244
|
-
}
|
|
245
|
-
console.log(t('nginx.reloadOk'));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function nginxOpen(projectRoot) {
|
|
249
|
-
const url = nginxEntryUrl(projectRoot);
|
|
250
|
-
console.log(t('nginx.opening', { url }));
|
|
251
|
-
await open(url);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function probeNginxHealth(projectRoot, timeoutMs = 2000) {
|
|
255
|
-
const url = new URL('/health', nginxEntryUrl(projectRoot));
|
|
256
|
-
return new Promise((resolve) => {
|
|
257
|
-
const req = http.get(url, { timeout: timeoutMs }, (res) => {
|
|
258
|
-
res.resume();
|
|
259
|
-
resolve(res.statusCode === 200);
|
|
260
|
-
});
|
|
261
|
-
req.on('error', () => resolve(false));
|
|
262
|
-
req.on('timeout', () => {
|
|
263
|
-
req.destroy();
|
|
264
|
-
resolve(false);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
async function checkNginx(projectRoot) {
|
|
270
|
-
if (!isDockerRunning()) {
|
|
271
|
-
return { ok: true, message: t('nginx.doctorSkippedDocker') };
|
|
272
|
-
}
|
|
273
|
-
if (!isNginxContainerRunning()) {
|
|
274
|
-
return { ok: true, message: t('nginx.doctorSkippedNotRunning') };
|
|
275
|
-
}
|
|
276
|
-
const healthy = await probeNginxHealth(projectRoot);
|
|
277
|
-
if (healthy) {
|
|
278
|
-
return {
|
|
279
|
-
ok: true,
|
|
280
|
-
message: t('nginx.doctorOk', { url: nginxEntryUrl(projectRoot) }),
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
return {
|
|
284
|
-
ok: false,
|
|
285
|
-
message: t('nginx.doctorUnhealthy', { url: nginxEntryUrl(projectRoot) }),
|
|
286
|
-
fix: t('nginx.doctorUnhealthyFix'),
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
async function runNginxCommand(command, projectRoot, extraArgs = [], options = {}) {
|
|
291
|
-
switch (command) {
|
|
292
|
-
case 'ensure': {
|
|
293
|
-
const { configPath, created } = ensureNginxConfig(projectRoot, options);
|
|
294
|
-
console.log(
|
|
295
|
-
created ? t('nginx.configCreated', { path: configPath }) : t('nginx.configExists', { path: configPath })
|
|
296
|
-
);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
case 'up':
|
|
300
|
-
nginxUp(projectRoot, options);
|
|
301
|
-
return;
|
|
302
|
-
case 'down':
|
|
303
|
-
case 'stop':
|
|
304
|
-
nginxDown(projectRoot, options);
|
|
305
|
-
return;
|
|
306
|
-
case 'restart':
|
|
307
|
-
nginxRestart(projectRoot, options);
|
|
308
|
-
return;
|
|
309
|
-
case 'status':
|
|
310
|
-
nginxStatus(projectRoot, options);
|
|
311
|
-
return;
|
|
312
|
-
case 'logs':
|
|
313
|
-
nginxLogs(extraArgs);
|
|
314
|
-
return;
|
|
315
|
-
case 'test':
|
|
316
|
-
nginxTest();
|
|
317
|
-
return;
|
|
318
|
-
case 'reload':
|
|
319
|
-
nginxReload();
|
|
320
|
-
return;
|
|
321
|
-
case 'open':
|
|
322
|
-
await nginxOpen(projectRoot);
|
|
323
|
-
return;
|
|
324
|
-
default:
|
|
325
|
-
throw new Error(t('nginx.unknownCommand', { command }));
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
module.exports = {
|
|
330
|
-
NGINX_CONTAINER,
|
|
331
|
-
DEFAULT_NGINX_PORT,
|
|
332
|
-
resolveNginxMode,
|
|
333
|
-
resolveNginxConfigPath,
|
|
334
|
-
resolveNginxComposeContext,
|
|
335
|
-
ensureNginxConfig,
|
|
336
|
-
nginxEntryUrl,
|
|
337
|
-
resolveNginxPort,
|
|
338
|
-
isNginxContainerRunning,
|
|
339
|
-
probeNginxHealth,
|
|
340
|
-
checkNginx,
|
|
341
|
-
runNginxCommand,
|
|
342
|
-
};
|
package/lib/paths.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { ensureOriginalCwd, getMonorepoRoot } = require('./root');
|
|
4
|
-
|
|
5
|
-
function resolveProjectRoot(projectRoot) {
|
|
6
|
-
return path.resolve(projectRoot || ensureOriginalCwd());
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function getMonorepoServerDir(projectRoot) {
|
|
10
|
-
return path.join(resolveProjectRoot(projectRoot), 'server');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function hasMonorepoServerSource(projectRoot) {
|
|
14
|
-
return fs.existsSync(
|
|
15
|
-
path.join(getMonorepoServerDir(projectRoot), 'src', 'main.ts')
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getCliPackageRoot() {
|
|
20
|
-
const ownRoot = path.join(__dirname, '..');
|
|
21
|
-
if (fs.existsSync(path.join(ownRoot, 'dist', 'index.js'))) {
|
|
22
|
-
return ownRoot;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
return path.dirname(
|
|
26
|
-
require.resolve('@fecommunity/reactpress-cli-core/package.json')
|
|
27
|
-
);
|
|
28
|
-
} catch {
|
|
29
|
-
return path.dirname(require.resolve('@fecommunity/reactpress-cli/package.json'));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getBundledServerDir() {
|
|
34
|
-
return path.join(getCliPackageRoot(), 'server');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function hasBundledServerBuild() {
|
|
38
|
-
return fs.existsSync(path.join(getBundledServerDir(), 'dist', 'main.js'));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function getServerDir(projectRoot) {
|
|
42
|
-
if (hasMonorepoServerSource(projectRoot)) {
|
|
43
|
-
return getMonorepoServerDir(projectRoot);
|
|
44
|
-
}
|
|
45
|
-
return getBundledServerDir();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getServerBin(projectRoot) {
|
|
49
|
-
return path.join(getServerDir(projectRoot), 'bin', 'reactpress-server.js');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getSwaggerPath(projectRoot) {
|
|
53
|
-
return path.join(getServerDir(projectRoot), 'public', 'swagger.json');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function getServerMain(projectRoot) {
|
|
57
|
-
return path.join(getServerDir(projectRoot), 'dist', 'main.js');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function isUsingMonorepoServer(projectRoot) {
|
|
61
|
-
return hasMonorepoServerSource(projectRoot);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function canStartLocalApi(projectRoot) {
|
|
65
|
-
return (
|
|
66
|
-
isUsingMonorepoServer(projectRoot) ||
|
|
67
|
-
hasBundledServerBuild()
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function getClientBin(projectRoot) {
|
|
72
|
-
const binPath = path.join(
|
|
73
|
-
resolveProjectRoot(projectRoot),
|
|
74
|
-
'client',
|
|
75
|
-
'bin',
|
|
76
|
-
'reactpress-client.js'
|
|
77
|
-
);
|
|
78
|
-
if (!fs.existsSync(binPath)) {
|
|
79
|
-
const err = new Error(
|
|
80
|
-
`Client entry not found: ${binPath}. Run from a ReactPress monorepo root or use reactpress dev --client-only with a remote API.`
|
|
81
|
-
);
|
|
82
|
-
err.code = 'REACTPRESS_CLIENT_NOT_FOUND';
|
|
83
|
-
throw err;
|
|
84
|
-
}
|
|
85
|
-
return binPath;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function getPidFile(projectRoot) {
|
|
89
|
-
return path.join(resolveProjectRoot(projectRoot), '.reactpress', 'server.pid');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
module.exports = {
|
|
93
|
-
getMonorepoRoot,
|
|
94
|
-
resolveProjectRoot,
|
|
95
|
-
getMonorepoServerDir,
|
|
96
|
-
hasMonorepoServerSource,
|
|
97
|
-
hasBundledServerBuild,
|
|
98
|
-
isUsingMonorepoServer,
|
|
99
|
-
canStartLocalApi,
|
|
100
|
-
getCliPackageRoot,
|
|
101
|
-
getBundledServerDir,
|
|
102
|
-
getServerDir,
|
|
103
|
-
getServerBin,
|
|
104
|
-
getSwaggerPath,
|
|
105
|
-
getServerMain,
|
|
106
|
-
getClientBin,
|
|
107
|
-
getPidFile,
|
|
108
|
-
};
|
package/lib/pm2.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const { getServerBin, getServerDir } = require('./paths');
|
|
3
|
-
const { ensureOriginalCwd } = require('./root');
|
|
4
|
-
const { t } = require('./i18n');
|
|
5
|
-
|
|
6
|
-
function startApiWithPm2(projectRoot = ensureOriginalCwd()) {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
const child = spawn(process.execPath, [getServerBin(projectRoot), '--pm2'], {
|
|
9
|
-
stdio: 'inherit',
|
|
10
|
-
cwd: getServerDir(projectRoot),
|
|
11
|
-
env: {
|
|
12
|
-
...process.env,
|
|
13
|
-
REACTPRESS_ORIGINAL_CWD: projectRoot,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
child.on('error', (error) => {
|
|
18
|
-
console.error(t('pm2.startFailed'), error);
|
|
19
|
-
reject(error);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
child.on('close', (code) => {
|
|
23
|
-
if (code !== 0) {
|
|
24
|
-
reject(Object.assign(new Error(t('pm2.exitCode', { code })), { exitCode: code }));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
resolve();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = { startApiWithPm2 };
|
package/lib/process.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { getPidFile } = require('./paths');
|
|
4
|
-
|
|
5
|
-
function readPid(projectRoot) {
|
|
6
|
-
const pidFile = getPidFile(projectRoot);
|
|
7
|
-
try {
|
|
8
|
-
const raw = fs.readFileSync(pidFile, 'utf8').trim();
|
|
9
|
-
const pid = Number.parseInt(raw, 10);
|
|
10
|
-
return Number.isFinite(pid) ? pid : null;
|
|
11
|
-
} catch {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function isProcessRunning(pid) {
|
|
17
|
-
if (!pid) return false;
|
|
18
|
-
try {
|
|
19
|
-
process.kill(pid, 0);
|
|
20
|
-
return true;
|
|
21
|
-
} catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function clearPidFile(projectRoot) {
|
|
27
|
-
const pidFile = getPidFile(projectRoot);
|
|
28
|
-
if (fs.existsSync(pidFile)) {
|
|
29
|
-
fs.unlinkSync(pidFile);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function writePid(projectRoot, pid) {
|
|
34
|
-
const pidFile = getPidFile(projectRoot);
|
|
35
|
-
fs.mkdirSync(path.dirname(pidFile), { recursive: true });
|
|
36
|
-
fs.writeFileSync(pidFile, String(pid));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = {
|
|
40
|
-
readPid,
|
|
41
|
-
isProcessRunning,
|
|
42
|
-
clearPidFile,
|
|
43
|
-
writePid,
|
|
44
|
-
getPidFile,
|
|
45
|
-
};
|