@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/db-backup.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const { t } = require('./i18n');
|
|
6
|
-
const { mysqldumpFromDbContainer } = require('./docker');
|
|
7
|
-
|
|
8
|
-
function isLocalDbHost(host) {
|
|
9
|
-
const h = String(host || '').toLowerCase();
|
|
10
|
-
return h === '127.0.0.1' || h === 'localhost' || h === '::1' || h === '';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function isMysqldumpNotFoundError(err) {
|
|
14
|
-
const msg = `${err && err.message ? err.message : ''}\n${err && err.stderr ? err.stderr : ''}`;
|
|
15
|
-
if (err && err.status === 127) return true;
|
|
16
|
-
return /command not found|not recognized as an internal or external command/i.test(msg);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function parseEnv(projectRoot) {
|
|
20
|
-
const envPath = path.join(projectRoot, '.env');
|
|
21
|
-
const out = {};
|
|
22
|
-
try {
|
|
23
|
-
const content = fs.readFileSync(envPath, 'utf8');
|
|
24
|
-
for (const line of content.split('\n')) {
|
|
25
|
-
const m = line.match(/^([A-Z_]+)=(.*)$/);
|
|
26
|
-
if (m) out[m[1]] = m[2].trim().replace(/^['"]|['"]$/g, '');
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
// ignore
|
|
30
|
-
}
|
|
31
|
-
return out;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function runDbBackup(projectRoot, outputPath) {
|
|
35
|
-
const env = parseEnv(projectRoot);
|
|
36
|
-
const host = env.DB_HOST || '127.0.0.1';
|
|
37
|
-
const port = env.DB_PORT || '3306';
|
|
38
|
-
const user = env.DB_USER || 'root';
|
|
39
|
-
const password = env.DB_PASSWD || env.DB_PASSWORD || 'root';
|
|
40
|
-
const database = env.DB_DATABASE || 'reactpress';
|
|
41
|
-
const out =
|
|
42
|
-
outputPath ||
|
|
43
|
-
path.join(projectRoot, `reactpress-backup-${new Date().toISOString().replace(/[:.]/g, '-')}.sql`);
|
|
44
|
-
|
|
45
|
-
const cmd = `mysqldump -h ${host} -P ${port} -u ${user} -p${password} ${database}`;
|
|
46
|
-
console.log(chalk.cyan('[reactpress]'), t('db.backup.to', { path: out }));
|
|
47
|
-
try {
|
|
48
|
-
const dump = execSync(cmd, { encoding: 'utf8', maxBuffer: 50 * 1024 * 1024 });
|
|
49
|
-
fs.writeFileSync(out, dump, 'utf8');
|
|
50
|
-
console.log(chalk.green('[reactpress]'), t('db.backup.done'));
|
|
51
|
-
return out;
|
|
52
|
-
} catch (err) {
|
|
53
|
-
if (isMysqldumpNotFoundError(err) && isLocalDbHost(host)) {
|
|
54
|
-
const via = mysqldumpFromDbContainer(projectRoot, { user, password, database });
|
|
55
|
-
if (via.ok) {
|
|
56
|
-
console.log(chalk.cyan('[reactpress]'), t('db.backup.viaDocker'));
|
|
57
|
-
fs.writeFileSync(out, via.stdout, 'utf8');
|
|
58
|
-
console.log(chalk.green('[reactpress]'), t('db.backup.done'));
|
|
59
|
-
return out;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
console.error(chalk.red('[reactpress]'), t('db.backup.fail'));
|
|
63
|
-
throw err;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = { runDbBackup };
|
package/lib/dev-banner.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
brand,
|
|
3
|
-
icon,
|
|
4
|
-
ok,
|
|
5
|
-
divider,
|
|
6
|
-
padRight,
|
|
7
|
-
terminalWidth,
|
|
8
|
-
gradientText,
|
|
9
|
-
palette,
|
|
10
|
-
pulseBar,
|
|
11
|
-
statusLights,
|
|
12
|
-
} = require('../ui/theme');
|
|
13
|
-
const {
|
|
14
|
-
loadClientSiteUrl,
|
|
15
|
-
loadServerSiteUrl,
|
|
16
|
-
getApiPrefix,
|
|
17
|
-
getHealthUrl,
|
|
18
|
-
} = require('./http');
|
|
19
|
-
const { t } = require('./i18n');
|
|
20
|
-
|
|
21
|
-
function getDevUrls(projectRoot) {
|
|
22
|
-
const client = loadClientSiteUrl(projectRoot).replace(/\/$/, '');
|
|
23
|
-
const server = loadServerSiteUrl(projectRoot).replace(/\/$/, '');
|
|
24
|
-
const prefix = getApiPrefix(projectRoot).replace(/\/$/, '') || '/api';
|
|
25
|
-
return {
|
|
26
|
-
site: client,
|
|
27
|
-
admin: `${client}/admin`,
|
|
28
|
-
api: `${server}${prefix}`,
|
|
29
|
-
swagger: `${server}${prefix}`,
|
|
30
|
-
health: getHealthUrl(projectRoot),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function urlLine(key, url, { underline = true } = {}) {
|
|
35
|
-
const keyCol = brand.muted(padRight(key, 10));
|
|
36
|
-
const value = underline ? brand.accent.underline(url) : brand.dim(url);
|
|
37
|
-
return ` ${brand.accent('▸ ')}${keyCol} ${value}`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function printDevReadyBanner(projectRoot, { apiOnly = false } = {}) {
|
|
41
|
-
const urls = getDevUrls(projectRoot);
|
|
42
|
-
const w = Math.min(terminalWidth() - 4, 56);
|
|
43
|
-
|
|
44
|
-
console.log('');
|
|
45
|
-
console.log(
|
|
46
|
-
` ${icon.ok} ${gradientText(t('devBanner.ready'), [palette.green, palette.accent], { bold: true })} ${statusLights('online')}`
|
|
47
|
-
);
|
|
48
|
-
console.log(` ${brand.primary('╔' + '═'.repeat(w) + '╗')}`);
|
|
49
|
-
|
|
50
|
-
if (!apiOnly) {
|
|
51
|
-
console.log(urlLine(t('devBanner.site'), urls.site));
|
|
52
|
-
console.log(urlLine(t('devBanner.admin'), urls.admin));
|
|
53
|
-
}
|
|
54
|
-
console.log(urlLine(t('devBanner.api'), urls.api));
|
|
55
|
-
console.log(urlLine(t('devBanner.swagger'), urls.swagger));
|
|
56
|
-
console.log(urlLine(t('devBanner.health'), urls.health, { underline: false }));
|
|
57
|
-
|
|
58
|
-
const pulseWidth = Math.min(20, w - 4);
|
|
59
|
-
if (pulseWidth > 6) {
|
|
60
|
-
console.log(
|
|
61
|
-
` ${brand.muted(' ')}${pulseBar(pulseWidth, pulseWidth)} ${brand.success(t('devBanner.allSystemsGo'))}`
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
console.log(` ${brand.primary('╚' + '═'.repeat(w) + '╝')}`);
|
|
66
|
-
console.log(
|
|
67
|
-
` ${brand.dim(t('devBanner.hint'))} ${brand.muted('·')} ${brand.dim(t('devBanner.shortcuts'))}`
|
|
68
|
-
);
|
|
69
|
-
console.log('');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
module.exports = { getDevUrls, printDevReadyBanner };
|
package/lib/dev.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
const { spawn } = require('child_process');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const ora = require('ora');
|
|
4
|
-
const { runBuild } = require('./build');
|
|
5
|
-
const { ensureProjectEnvironment } = require('./bootstrap');
|
|
6
|
-
const { loadServerSiteUrl, loadClientSiteUrl, waitForHttp } = require('./http');
|
|
7
|
-
const { printDevReadyBanner } = require('./dev-banner');
|
|
8
|
-
const { ensureOriginalCwd } = require('./root');
|
|
9
|
-
const { detectProjectType, hasClient, hasToolkit } = require('./project-type');
|
|
10
|
-
const { t } = require('./i18n');
|
|
11
|
-
|
|
12
|
-
const CLIENT_READY_TIMEOUT_MS = 120_000;
|
|
13
|
-
const API_READY_TIMEOUT_MS = 180_000;
|
|
14
|
-
|
|
15
|
-
function formatDevFailureHint() {
|
|
16
|
-
return [
|
|
17
|
-
t('dev.nextSteps'),
|
|
18
|
-
t('dev.nextDoctor'),
|
|
19
|
-
t('dev.nextDocker'),
|
|
20
|
-
t('dev.nextEnv'),
|
|
21
|
-
].join('\n');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let apiChild;
|
|
25
|
-
let webChild;
|
|
26
|
-
let shuttingDown = false;
|
|
27
|
-
|
|
28
|
-
function shutdown(signal = 'SIGINT') {
|
|
29
|
-
if (shuttingDown) return;
|
|
30
|
-
shuttingDown = true;
|
|
31
|
-
if (webChild && !webChild.killed) webChild.kill(signal);
|
|
32
|
-
if (apiChild && !apiChild.killed) apiChild.kill(signal);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function buildToolkit(projectRoot) {
|
|
36
|
-
if (!hasToolkit(projectRoot)) return;
|
|
37
|
-
await runBuild('toolkit', projectRoot);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function spawnApi(projectRoot) {
|
|
41
|
-
const apiDevRunner = path.join(__dirname, 'api-dev-runner.js');
|
|
42
|
-
console.log(t('dev.startingApi'));
|
|
43
|
-
apiChild = spawn(process.execPath, [apiDevRunner], {
|
|
44
|
-
stdio: 'inherit',
|
|
45
|
-
cwd: projectRoot,
|
|
46
|
-
env: {
|
|
47
|
-
...process.env,
|
|
48
|
-
REACTPRESS_ORIGINAL_CWD: projectRoot,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
apiChild.on('close', (code) => {
|
|
53
|
-
if (shuttingDown) {
|
|
54
|
-
process.exit(code ?? 0);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (webChild && !webChild.killed) webChild.kill('SIGINT');
|
|
58
|
-
process.exit(code ?? 1);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function waitForApiReady(projectRoot) {
|
|
63
|
-
const serverUrl = loadServerSiteUrl(projectRoot);
|
|
64
|
-
const spinner = ora({
|
|
65
|
-
text: t('dev.waitingApi', { url: serverUrl }),
|
|
66
|
-
color: 'magenta',
|
|
67
|
-
spinner: 'dots',
|
|
68
|
-
}).start();
|
|
69
|
-
const ready = await waitForHttp(serverUrl, API_READY_TIMEOUT_MS);
|
|
70
|
-
if (!ready) {
|
|
71
|
-
spinner.fail(t('dev.apiTimeout', { seconds: API_READY_TIMEOUT_MS / 1000 }));
|
|
72
|
-
shutdown('SIGINT');
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
spinner.succeed(t('dev.apiReady'));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function spawnClient(projectRoot) {
|
|
79
|
-
webChild = spawn('pnpm', ['run', '--dir', './client', 'dev'], {
|
|
80
|
-
stdio: 'inherit',
|
|
81
|
-
shell: true,
|
|
82
|
-
cwd: projectRoot,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const clientUrl = loadClientSiteUrl(projectRoot);
|
|
86
|
-
waitForHttp(clientUrl, CLIENT_READY_TIMEOUT_MS).then((clientReady) => {
|
|
87
|
-
if (clientReady) {
|
|
88
|
-
printDevReadyBanner(projectRoot);
|
|
89
|
-
} else {
|
|
90
|
-
console.warn(
|
|
91
|
-
t('dev.clientSlow', {
|
|
92
|
-
seconds: CLIENT_READY_TIMEOUT_MS / 1000,
|
|
93
|
-
url: clientUrl,
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
webChild.on('close', (code) => {
|
|
100
|
-
if (!shuttingDown) shutdown('SIGINT');
|
|
101
|
-
process.exit(code ?? 0);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function startDevStack(projectRoot) {
|
|
106
|
-
const includeClient = hasClient(projectRoot);
|
|
107
|
-
|
|
108
|
-
spawnApi(projectRoot);
|
|
109
|
-
await waitForApiReady(projectRoot);
|
|
110
|
-
printDevReadyBanner(projectRoot, { apiOnly: !includeClient });
|
|
111
|
-
|
|
112
|
-
if (!includeClient) {
|
|
113
|
-
console.log(t('dev.standaloneHint'));
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
spawnClient(projectRoot);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function runDev(projectRoot = ensureOriginalCwd()) {
|
|
120
|
-
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
121
|
-
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
const result = await ensureProjectEnvironment(projectRoot);
|
|
125
|
-
if (result.message) console.log(`[reactpress] ${result.message}`);
|
|
126
|
-
} catch (err) {
|
|
127
|
-
console.error(t('dev.envFailed'), err.message || err);
|
|
128
|
-
console.error(formatDevFailureHint());
|
|
129
|
-
process.exit(1);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
await buildToolkit(projectRoot);
|
|
133
|
-
await startDevStack(projectRoot);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
module.exports = {
|
|
137
|
-
runDev,
|
|
138
|
-
buildToolkit,
|
|
139
|
-
startDevStack,
|
|
140
|
-
detectProjectType,
|
|
141
|
-
};
|
package/lib/docker.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { spawn, execSync, spawnSync } = require('child_process');
|
|
4
|
-
const ora = require('ora');
|
|
5
|
-
const { ensureOriginalCwd } = require('./root');
|
|
6
|
-
const { detectProjectType, hasClient } = require('./project-type');
|
|
7
|
-
const { t } = require('./i18n');
|
|
8
|
-
|
|
9
|
-
function isDockerRunning() {
|
|
10
|
-
try {
|
|
11
|
-
execSync('docker info', { stdio: 'ignore' });
|
|
12
|
-
return true;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function pickDockerComposeCommand() {
|
|
19
|
-
const v2 = spawnSync('docker', ['compose', 'version'], { stdio: 'ignore' });
|
|
20
|
-
if (v2.status === 0) return { command: 'docker', baseArgs: ['compose'] };
|
|
21
|
-
|
|
22
|
-
const v1 = spawnSync('docker-compose', ['version'], { stdio: 'ignore' });
|
|
23
|
-
if (v1.status === 0) return { command: 'docker-compose', baseArgs: [] };
|
|
24
|
-
|
|
25
|
-
return { command: 'docker', baseArgs: ['compose'] };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Resolve which docker-compose file to use for the current project.
|
|
30
|
-
*
|
|
31
|
-
* - Monorepo checkouts use `docker-compose.dev.yml` at the repo root.
|
|
32
|
-
* - Standalone projects use `.reactpress/docker-compose.yml` (managed by init).
|
|
33
|
-
*
|
|
34
|
-
* @returns {{ composeFile: string, cwd: string, type: 'monorepo' | 'standalone' }}
|
|
35
|
-
*/
|
|
36
|
-
function resolveComposeContext(projectRoot) {
|
|
37
|
-
const type = detectProjectType(projectRoot);
|
|
38
|
-
if (type === 'monorepo') {
|
|
39
|
-
const composeFile = path.join(projectRoot, 'docker-compose.dev.yml');
|
|
40
|
-
if (fs.existsSync(composeFile)) {
|
|
41
|
-
return { composeFile, cwd: projectRoot, type };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const standaloneCompose = path.join(projectRoot, '.reactpress', 'docker-compose.yml');
|
|
45
|
-
if (fs.existsSync(standaloneCompose)) {
|
|
46
|
-
return { composeFile: standaloneCompose, cwd: path.dirname(standaloneCompose), type: 'standalone' };
|
|
47
|
-
}
|
|
48
|
-
const fallback = path.join(projectRoot, 'docker-compose.dev.yml');
|
|
49
|
-
return { composeFile: fallback, cwd: projectRoot, type };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function runCompose(args, ctx, options = {}) {
|
|
53
|
-
const { command, baseArgs } = pickDockerComposeCommand();
|
|
54
|
-
return spawnSync(
|
|
55
|
-
command,
|
|
56
|
-
[...baseArgs, '-f', ctx.composeFile, ...args],
|
|
57
|
-
{ stdio: options.stdio ?? 'inherit', cwd: ctx.cwd, ...options }
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function stopDockerServices(projectRoot) {
|
|
62
|
-
console.log(t('docker.stopping'));
|
|
63
|
-
const ctx = resolveComposeContext(projectRoot);
|
|
64
|
-
const result = runCompose(['down'], ctx);
|
|
65
|
-
if (result.status !== 0) {
|
|
66
|
-
console.error(t('docker.stopFailed'));
|
|
67
|
-
throw new Error(t('docker.stopFailed'));
|
|
68
|
-
}
|
|
69
|
-
console.log(t('docker.stopped'));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function startDockerServices(projectRoot) {
|
|
73
|
-
console.log(t('docker.starting'));
|
|
74
|
-
if (!isDockerRunning()) {
|
|
75
|
-
throw new Error(t('docker.notRunning'));
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
const { ensureNginxConfig } = require('./nginx');
|
|
79
|
-
const { configPath, created } = ensureNginxConfig(projectRoot, { mode: 'dev' });
|
|
80
|
-
if (created) {
|
|
81
|
-
console.log(t('nginx.configCreated', { path: configPath }));
|
|
82
|
-
}
|
|
83
|
-
} catch (err) {
|
|
84
|
-
console.warn(t('nginx.ensureWarn', { message: err.message || err }));
|
|
85
|
-
}
|
|
86
|
-
const ctx = resolveComposeContext(projectRoot);
|
|
87
|
-
const result = runCompose(['up', '-d'], ctx);
|
|
88
|
-
if (result.status !== 0) {
|
|
89
|
-
throw new Error(t('docker.notRunning'));
|
|
90
|
-
}
|
|
91
|
-
console.log(t('docker.started'));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function resolveDbContainerName(ctx, projectRoot) {
|
|
95
|
-
if (ctx.type === 'standalone') return 'reactpress_cli_db';
|
|
96
|
-
return 'reactpress_db';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function resolveDbCredentialsFromEnv(projectRoot) {
|
|
100
|
-
const envPath = path.join(projectRoot, '.env');
|
|
101
|
-
let user = 'reactpress';
|
|
102
|
-
let password = 'reactpress';
|
|
103
|
-
try {
|
|
104
|
-
const content = fs.readFileSync(envPath, 'utf8');
|
|
105
|
-
const u = content.match(/^DB_USER=(.+)$/m);
|
|
106
|
-
const p = content.match(/^(DB_PASSWD|DB_PASSWORD)=(.+)$/m);
|
|
107
|
-
if (u) user = u[1].trim().replace(/^['"]|['"]$/g, '');
|
|
108
|
-
if (p) password = p[2].trim().replace(/^['"]|['"]$/g, '');
|
|
109
|
-
} catch {
|
|
110
|
-
// ignore
|
|
111
|
-
}
|
|
112
|
-
return { user, password };
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function waitForMysql(projectRoot, maxAttempts = 30) {
|
|
116
|
-
const ctx = resolveComposeContext(projectRoot);
|
|
117
|
-
const container = resolveDbContainerName(ctx, projectRoot);
|
|
118
|
-
const { user, password } = resolveDbCredentialsFromEnv(projectRoot);
|
|
119
|
-
|
|
120
|
-
const spinner = ora({
|
|
121
|
-
text: t('docker.waitingMysql'),
|
|
122
|
-
color: 'magenta',
|
|
123
|
-
spinner: 'dots',
|
|
124
|
-
}).start();
|
|
125
|
-
|
|
126
|
-
let attempts = 0;
|
|
127
|
-
while (attempts < maxAttempts) {
|
|
128
|
-
const probe = spawnSync(
|
|
129
|
-
'docker',
|
|
130
|
-
['exec', container, 'mysql', `-u${user}`, `-p${password}`, '-e', 'SELECT 1'],
|
|
131
|
-
{ stdio: 'ignore' }
|
|
132
|
-
);
|
|
133
|
-
if (probe.status === 0) {
|
|
134
|
-
spinner.succeed(t('docker.mysqlReady'));
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
attempts += 1;
|
|
138
|
-
spinner.text = t('docker.waitingMysqlProgress', { attempts, max: maxAttempts });
|
|
139
|
-
await new Promise((r) => setTimeout(r, 1000));
|
|
140
|
-
}
|
|
141
|
-
spinner.fail(t('docker.mysqlTimeout'));
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async function dockerStartWithDev(projectRoot) {
|
|
146
|
-
startDockerServices(projectRoot);
|
|
147
|
-
const ready = await waitForMysql(projectRoot);
|
|
148
|
-
if (!ready) {
|
|
149
|
-
throw new Error(t('docker.mysqlNotReady'));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (!hasClient(projectRoot)) {
|
|
153
|
-
console.log(t('dev.standaloneHint'));
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const { buildToolkit } = require('./dev');
|
|
158
|
-
await buildToolkit(projectRoot);
|
|
159
|
-
|
|
160
|
-
const apiRunner = path.join(__dirname, 'api-dev-runner.js');
|
|
161
|
-
console.log(t('docker.startDevStack'));
|
|
162
|
-
console.log(t('docker.visitUrls'));
|
|
163
|
-
|
|
164
|
-
return new Promise((resolve, reject) => {
|
|
165
|
-
const child = spawn(
|
|
166
|
-
'npx',
|
|
167
|
-
[
|
|
168
|
-
'concurrently',
|
|
169
|
-
'-n',
|
|
170
|
-
'api,web',
|
|
171
|
-
'-c',
|
|
172
|
-
'blue,green',
|
|
173
|
-
`node "${apiRunner}"`,
|
|
174
|
-
'pnpm run --dir ./client dev',
|
|
175
|
-
],
|
|
176
|
-
{
|
|
177
|
-
stdio: 'inherit',
|
|
178
|
-
shell: true,
|
|
179
|
-
cwd: projectRoot,
|
|
180
|
-
env: {
|
|
181
|
-
...process.env,
|
|
182
|
-
REACTPRESS_ORIGINAL_CWD: projectRoot,
|
|
183
|
-
},
|
|
184
|
-
}
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
child.on('error', reject);
|
|
188
|
-
child.on('close', (code) => {
|
|
189
|
-
if (code !== 0) {
|
|
190
|
-
reject(Object.assign(new Error(t('docker.devProcessExit', { code })), { exitCode: code }));
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
resolve();
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Run mysqldump inside the compose `db` container (MySQL image ships mysqldump).
|
|
200
|
-
* Used when the host has no `mysqldump` binary but Docker DB is running.
|
|
201
|
-
*
|
|
202
|
-
* @returns {{ ok: true, stdout: string } | { ok: false, stderr: string }}
|
|
203
|
-
*/
|
|
204
|
-
function mysqldumpFromDbContainer(projectRoot, { user, password, database }) {
|
|
205
|
-
const ctx = resolveComposeContext(projectRoot);
|
|
206
|
-
if (!fs.existsSync(ctx.composeFile)) {
|
|
207
|
-
return { ok: false, stderr: 'compose file missing' };
|
|
208
|
-
}
|
|
209
|
-
if (!isDockerRunning()) {
|
|
210
|
-
return { ok: false, stderr: 'docker not running' };
|
|
211
|
-
}
|
|
212
|
-
const container = resolveDbContainerName(ctx, projectRoot);
|
|
213
|
-
const res = spawnSync(
|
|
214
|
-
'docker',
|
|
215
|
-
['exec', container, 'mysqldump', `-u${user}`, `-p${password}`, database],
|
|
216
|
-
{ encoding: 'utf8', maxBuffer: 50 * 1024 * 1024 }
|
|
217
|
-
);
|
|
218
|
-
if (res.error) {
|
|
219
|
-
return { ok: false, stderr: res.error.message };
|
|
220
|
-
}
|
|
221
|
-
if (res.status !== 0) {
|
|
222
|
-
return { ok: false, stderr: res.stderr || res.stdout || `exit ${res.status}` };
|
|
223
|
-
}
|
|
224
|
-
return { ok: true, stdout: res.stdout };
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
async function runDockerCommand(command, projectRoot = ensureOriginalCwd(), extraArgs = []) {
|
|
228
|
-
const ctx = resolveComposeContext(projectRoot);
|
|
229
|
-
switch (command) {
|
|
230
|
-
case 'up':
|
|
231
|
-
startDockerServices(projectRoot);
|
|
232
|
-
await waitForMysql(projectRoot);
|
|
233
|
-
return;
|
|
234
|
-
case 'down':
|
|
235
|
-
case 'stop':
|
|
236
|
-
stopDockerServices(projectRoot);
|
|
237
|
-
return;
|
|
238
|
-
case 'start':
|
|
239
|
-
await dockerStartWithDev(projectRoot);
|
|
240
|
-
return;
|
|
241
|
-
case 'restart':
|
|
242
|
-
stopDockerServices(projectRoot);
|
|
243
|
-
await new Promise((r) => setTimeout(r, 2000));
|
|
244
|
-
startDockerServices(projectRoot);
|
|
245
|
-
await waitForMysql(projectRoot);
|
|
246
|
-
return;
|
|
247
|
-
case 'status': {
|
|
248
|
-
const res = runCompose(['ps'], ctx);
|
|
249
|
-
if (res.status !== 0) {
|
|
250
|
-
throw new Error(t('docker.unknownCommand', { command: 'ps' }));
|
|
251
|
-
}
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
case 'logs': {
|
|
255
|
-
const service = extraArgs[0];
|
|
256
|
-
const args = ['logs', '-f'];
|
|
257
|
-
if (service) args.push(service);
|
|
258
|
-
runCompose(args, ctx);
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
default:
|
|
262
|
-
throw new Error(t('docker.unknownCommand', { command }));
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
module.exports = {
|
|
267
|
-
runDockerCommand,
|
|
268
|
-
startDockerServices,
|
|
269
|
-
stopDockerServices,
|
|
270
|
-
waitForMysql,
|
|
271
|
-
isDockerRunning,
|
|
272
|
-
resolveComposeContext,
|
|
273
|
-
pickDockerComposeCommand,
|
|
274
|
-
mysqldumpFromDbContainer,
|
|
275
|
-
};
|