@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/ui/interactive.js
DELETED
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const inquirer = require('inquirer');
|
|
4
|
-
const ora = require('ora');
|
|
5
|
-
const open = require('open');
|
|
6
|
-
const { printBanner } = require('./banner');
|
|
7
|
-
const {
|
|
8
|
-
brand,
|
|
9
|
-
icon,
|
|
10
|
-
label,
|
|
11
|
-
ok,
|
|
12
|
-
fail,
|
|
13
|
-
sectionHeader,
|
|
14
|
-
statusPill,
|
|
15
|
-
padRight,
|
|
16
|
-
} = require('./theme');
|
|
17
|
-
const { ensureOriginalCwd } = require('../lib/root');
|
|
18
|
-
const { describeProject, hasClient } = require('../lib/project-type');
|
|
19
|
-
const { ensureProjectEnvironment } = require('../lib/bootstrap');
|
|
20
|
-
const { runDev } = require('../lib/dev');
|
|
21
|
-
const { runApiDev } = require('../lib/api-dev');
|
|
22
|
-
const { runLifecycleCommand } = require('../lib/lifecycle');
|
|
23
|
-
const { runDockerCommand } = require('../lib/docker');
|
|
24
|
-
const { runNginxCommand } = require('../lib/nginx');
|
|
25
|
-
const { printUnifiedStatus } = require('../lib/status');
|
|
26
|
-
const { runDoctor } = require('../lib/doctor');
|
|
27
|
-
const { runBuild, TARGETS } = require('../lib/build');
|
|
28
|
-
const { runNodeScript } = require('../lib/spawn');
|
|
29
|
-
const { getClientBin } = require('../lib/paths');
|
|
30
|
-
const { loadClientSiteUrl, loadServerSiteUrl, isHttpResponding } = require('../lib/http');
|
|
31
|
-
const { isDockerRunning } = require('../lib/docker');
|
|
32
|
-
const { t } = require('../lib/i18n');
|
|
33
|
-
|
|
34
|
-
function menuSection(title) {
|
|
35
|
-
return new inquirer.Separator(sectionHeader(title));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function formatChoice(key, text, hint) {
|
|
39
|
-
const keyCol = key ? brand.primary(padRight(key, 2)) : ' ';
|
|
40
|
-
const hintPart = hint ? brand.dim(` ${hint}`) : '';
|
|
41
|
-
return `${keyCol} ${text}${hintPart}`;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function assignShortcuts(items) {
|
|
45
|
-
let n = 0;
|
|
46
|
-
return items.map((item) => {
|
|
47
|
-
if (item instanceof inquirer.Separator || item.type === 'separator') {
|
|
48
|
-
return item;
|
|
49
|
-
}
|
|
50
|
-
n += 1;
|
|
51
|
-
const key = n <= 9 ? String(n) : '';
|
|
52
|
-
return {
|
|
53
|
-
...item,
|
|
54
|
-
name: formatChoice(key, item._label || item.name, item._hint),
|
|
55
|
-
short: item.value,
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function choice(labelKey, value, hintKey) {
|
|
61
|
-
return {
|
|
62
|
-
_label: t(labelKey),
|
|
63
|
-
_hint: hintKey ? t(hintKey) : '',
|
|
64
|
-
value,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function getMenuActions(project) {
|
|
69
|
-
const standalone = project.type === 'standalone';
|
|
70
|
-
const monorepo = project.type === 'monorepo';
|
|
71
|
-
const showClient = hasClient(project.root);
|
|
72
|
-
|
|
73
|
-
const items = [
|
|
74
|
-
menuSection(t('menu.section.run')),
|
|
75
|
-
choice('menu.dev', 'dev', 'menu.hint.dev'),
|
|
76
|
-
choice('menu.init', 'init', 'menu.hint.init'),
|
|
77
|
-
choice('menu.status', 'status', 'menu.hint.status'),
|
|
78
|
-
choice('menu.doctor', 'doctor', 'menu.hint.doctor'),
|
|
79
|
-
menuSection(t('menu.section.lifecycle')),
|
|
80
|
-
choice('menu.devApi', 'dev:api', 'menu.hint.devApi'),
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
if (showClient) {
|
|
84
|
-
items.push(choice('menu.devClient', 'dev:client', 'menu.hint.devClient'));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
items.push(
|
|
88
|
-
choice('menu.serverStart', 'server:start', 'menu.hint.serverStart'),
|
|
89
|
-
choice('menu.serverStop', 'server:stop', 'menu.hint.serverStop'),
|
|
90
|
-
choice('menu.serverRestart', 'server:restart', 'menu.hint.serverRestart'),
|
|
91
|
-
menuSection(t('menu.section.build')),
|
|
92
|
-
choice('menu.build', 'build', 'menu.hint.build')
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
if (monorepo) {
|
|
96
|
-
items.push(
|
|
97
|
-
choice('menu.dockerStart', 'docker:start', 'menu.hint.dockerStart'),
|
|
98
|
-
choice('menu.dockerUp', 'docker:up', 'menu.hint.dockerUp'),
|
|
99
|
-
choice('menu.dockerStop', 'docker:stop', 'menu.hint.dockerStop')
|
|
100
|
-
);
|
|
101
|
-
} else if (standalone) {
|
|
102
|
-
items.push(
|
|
103
|
-
choice('menu.dockerUp', 'docker:up', 'menu.hint.dockerUp'),
|
|
104
|
-
choice('menu.dockerStop', 'docker:stop', 'menu.hint.dockerStop')
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
items.push(
|
|
109
|
-
menuSection(t('menu.section.tools')),
|
|
110
|
-
choice('menu.nginxUp', 'nginx:up', 'menu.hint.nginxUp'),
|
|
111
|
-
choice('menu.nginxOpen', 'nginx:open', 'menu.hint.nginxOpen'),
|
|
112
|
-
choice('menu.nginxReload', 'nginx:reload', 'menu.hint.nginxReload'),
|
|
113
|
-
choice('menu.openAdmin', 'open:admin', 'menu.hint.openAdmin')
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
if (monorepo) {
|
|
117
|
-
items.push(choice('menu.publish', 'publish', 'menu.hint.publish'));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
items.push(
|
|
121
|
-
new inquirer.Separator(),
|
|
122
|
-
choice('menu.exit', 'exit', 'menu.hint.exit')
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
return assignShortcuts(items);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function parseEnvFile(projectRoot) {
|
|
129
|
-
const envPath = path.join(projectRoot, '.env');
|
|
130
|
-
const env = {};
|
|
131
|
-
try {
|
|
132
|
-
if (!fs.existsSync(envPath)) return env;
|
|
133
|
-
for (const line of fs.readFileSync(envPath, 'utf8').split('\n')) {
|
|
134
|
-
const m = line.match(/^([A-Z_]+)=(.*)$/);
|
|
135
|
-
if (m) env[m[1]] = m[2].trim().replace(/^['"]|['"]$/g, '');
|
|
136
|
-
}
|
|
137
|
-
} catch {
|
|
138
|
-
// ignore
|
|
139
|
-
}
|
|
140
|
-
return env;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async function probeDatabase(projectRoot) {
|
|
144
|
-
try {
|
|
145
|
-
const mysql = require('mysql2/promise');
|
|
146
|
-
const env = parseEnvFile(projectRoot);
|
|
147
|
-
const conn = await mysql.createConnection({
|
|
148
|
-
host: env.DB_HOST || '127.0.0.1',
|
|
149
|
-
port: Number(env.DB_PORT || 3306),
|
|
150
|
-
user: env.DB_USER || 'reactpress',
|
|
151
|
-
password: env.DB_PASSWD || env.DB_PASSWORD || 'reactpress',
|
|
152
|
-
database: env.DB_DATABASE || 'reactpress',
|
|
153
|
-
connectTimeout: 2000,
|
|
154
|
-
});
|
|
155
|
-
await conn.ping();
|
|
156
|
-
await conn.end();
|
|
157
|
-
return true;
|
|
158
|
-
} catch {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async function fetchContextStatus(projectRoot) {
|
|
164
|
-
const apiUrl = loadServerSiteUrl(projectRoot);
|
|
165
|
-
const [apiOk, dockerOk, dbOk] = await Promise.all([
|
|
166
|
-
isHttpResponding(apiUrl, 1500),
|
|
167
|
-
Promise.resolve(isDockerRunning()),
|
|
168
|
-
probeDatabase(projectRoot),
|
|
169
|
-
]);
|
|
170
|
-
return { apiOk, dbOk, dockerOk };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function printStatusPanel(status) {
|
|
174
|
-
const on = { on: t('menu.statusOn'), off: t('menu.statusOff') };
|
|
175
|
-
const db = {
|
|
176
|
-
on: t('menu.statusReady'),
|
|
177
|
-
off: t('menu.statusNotReady'),
|
|
178
|
-
pending: t('menu.statusChecking'),
|
|
179
|
-
};
|
|
180
|
-
const docker = { on: t('menu.statusYes'), off: t('menu.statusNo') };
|
|
181
|
-
|
|
182
|
-
console.log(sectionHeader(t('menu.statusHeader')));
|
|
183
|
-
const rows = [
|
|
184
|
-
[t('menu.statusLabelApi'), statusPill(status.apiOk, on)],
|
|
185
|
-
[t('menu.statusLabelDb'), statusPill(status.dbOk, db)],
|
|
186
|
-
[t('menu.statusLabelDocker'), statusPill(status.dockerOk, docker)],
|
|
187
|
-
];
|
|
188
|
-
for (const [name, pill] of rows) {
|
|
189
|
-
console.log(` ${brand.muted(padRight(name, 10))} ${pill}`);
|
|
190
|
-
}
|
|
191
|
-
console.log('');
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
async function printContextStatus(projectRoot) {
|
|
195
|
-
const spinner = ora({
|
|
196
|
-
text: brand.dim(t('menu.statusChecking')),
|
|
197
|
-
color: 'magenta',
|
|
198
|
-
spinner: 'dots',
|
|
199
|
-
}).start();
|
|
200
|
-
const status = await fetchContextStatus(projectRoot);
|
|
201
|
-
spinner.stop();
|
|
202
|
-
printStatusPanel(status);
|
|
203
|
-
return status;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async function withSpinner(text, fn) {
|
|
207
|
-
const spinner = ora({ text, color: 'magenta', spinner: 'dots' }).start();
|
|
208
|
-
try {
|
|
209
|
-
const result = await fn();
|
|
210
|
-
spinner.succeed();
|
|
211
|
-
return result;
|
|
212
|
-
} catch (err) {
|
|
213
|
-
spinner.fail();
|
|
214
|
-
throw err;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
async function runMenuAction(action, projectRoot, project) {
|
|
219
|
-
switch (action) {
|
|
220
|
-
case 'dev':
|
|
221
|
-
console.log(label(t('menu.startingDev')));
|
|
222
|
-
await runDev(projectRoot);
|
|
223
|
-
return false;
|
|
224
|
-
case 'init': {
|
|
225
|
-
const result = await withSpinner(t('menu.initProject'), () =>
|
|
226
|
-
ensureProjectEnvironment(projectRoot)
|
|
227
|
-
);
|
|
228
|
-
console.log(ok(result.message || t('menu.done')));
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
case 'status':
|
|
232
|
-
await printUnifiedStatus(projectRoot);
|
|
233
|
-
return true;
|
|
234
|
-
case 'doctor': {
|
|
235
|
-
const code = await runDoctor(projectRoot);
|
|
236
|
-
if (code !== 0) process.exit(code);
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
case 'dev:api':
|
|
240
|
-
await runApiDev(projectRoot);
|
|
241
|
-
return false;
|
|
242
|
-
case 'dev:client':
|
|
243
|
-
await runNodeScript(getClientBin(), [], { cwd: projectRoot });
|
|
244
|
-
return false;
|
|
245
|
-
case 'server:start': {
|
|
246
|
-
const code = await withSpinner(t('menu.startingApi'), () =>
|
|
247
|
-
runLifecycleCommand('start', projectRoot)
|
|
248
|
-
);
|
|
249
|
-
if (code !== 0) process.exit(code);
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
case 'server:stop':
|
|
253
|
-
await withSpinner(t('menu.stoppingApi'), async () => {
|
|
254
|
-
await runLifecycleCommand('stop', projectRoot);
|
|
255
|
-
});
|
|
256
|
-
return true;
|
|
257
|
-
case 'server:restart': {
|
|
258
|
-
const code = await withSpinner(t('menu.restartingApi'), () =>
|
|
259
|
-
runLifecycleCommand('restart', projectRoot)
|
|
260
|
-
);
|
|
261
|
-
if (code !== 0) process.exit(code);
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
case 'build': {
|
|
265
|
-
const buildChoices = TARGETS.map((target) => ({
|
|
266
|
-
name:
|
|
267
|
-
target === 'all'
|
|
268
|
-
? t('menu.buildAll')
|
|
269
|
-
: t(`build.label.${target}`),
|
|
270
|
-
value: target,
|
|
271
|
-
}));
|
|
272
|
-
const { target } = await inquirer.prompt([
|
|
273
|
-
{
|
|
274
|
-
type: 'list',
|
|
275
|
-
name: 'target',
|
|
276
|
-
message: t('menu.buildTarget'),
|
|
277
|
-
pageSize: 12,
|
|
278
|
-
choices: buildChoices,
|
|
279
|
-
},
|
|
280
|
-
]);
|
|
281
|
-
await runBuild(target, projectRoot);
|
|
282
|
-
return true;
|
|
283
|
-
}
|
|
284
|
-
case 'docker:start':
|
|
285
|
-
await runDockerCommand('start', projectRoot);
|
|
286
|
-
return false;
|
|
287
|
-
case 'docker:up':
|
|
288
|
-
await withSpinner(t('docker.starting'), () => runDockerCommand('up', projectRoot));
|
|
289
|
-
return true;
|
|
290
|
-
case 'docker:stop':
|
|
291
|
-
await withSpinner(t('docker.stopping'), async () => {
|
|
292
|
-
await runDockerCommand('down', projectRoot);
|
|
293
|
-
});
|
|
294
|
-
return true;
|
|
295
|
-
case 'nginx:up':
|
|
296
|
-
await withSpinner(t('cli.nginx.up'), async () => {
|
|
297
|
-
await runNginxCommand('up', projectRoot);
|
|
298
|
-
});
|
|
299
|
-
return true;
|
|
300
|
-
case 'nginx:open':
|
|
301
|
-
await runNginxCommand('open', projectRoot);
|
|
302
|
-
return true;
|
|
303
|
-
case 'nginx:reload':
|
|
304
|
-
await runNginxCommand('reload', projectRoot);
|
|
305
|
-
return true;
|
|
306
|
-
case 'open:admin': {
|
|
307
|
-
const url = loadClientSiteUrl(projectRoot);
|
|
308
|
-
console.log(label(t('menu.opening', { url })));
|
|
309
|
-
await open(url);
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
case 'publish': {
|
|
313
|
-
const prev = process.argv.slice();
|
|
314
|
-
process.argv = [process.argv[0], process.argv[1], '--publish'];
|
|
315
|
-
await require('../lib/publish').main();
|
|
316
|
-
process.argv = prev;
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
case 'exit':
|
|
320
|
-
return false;
|
|
321
|
-
default:
|
|
322
|
-
return true;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
async function runInteractiveLoop() {
|
|
327
|
-
const projectRoot = ensureOriginalCwd();
|
|
328
|
-
const project = describeProject(projectRoot);
|
|
329
|
-
|
|
330
|
-
printBanner({ projectRoot, project });
|
|
331
|
-
await printContextStatus(projectRoot);
|
|
332
|
-
console.log(` ${brand.dim(t('menu.shortcuts'))}`);
|
|
333
|
-
console.log('');
|
|
334
|
-
|
|
335
|
-
let loop = true;
|
|
336
|
-
while (loop) {
|
|
337
|
-
const { action } = await inquirer.prompt([
|
|
338
|
-
{
|
|
339
|
-
type: 'list',
|
|
340
|
-
name: 'action',
|
|
341
|
-
message: `${brand.primary(t('menu.actionPrefix'))} ${brand.dim('›')}`,
|
|
342
|
-
pageSize: 20,
|
|
343
|
-
loop: false,
|
|
344
|
-
choices: getMenuActions(project),
|
|
345
|
-
},
|
|
346
|
-
]);
|
|
347
|
-
|
|
348
|
-
if (action === 'exit') {
|
|
349
|
-
console.log(brand.muted(t('menu.goodbye')));
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
try {
|
|
354
|
-
const stay = await runMenuAction(action, projectRoot, project);
|
|
355
|
-
if (!stay) break;
|
|
356
|
-
|
|
357
|
-
if (action !== 'status' && action !== 'doctor') {
|
|
358
|
-
console.log('');
|
|
359
|
-
await printContextStatus(projectRoot);
|
|
360
|
-
}
|
|
361
|
-
} catch (err) {
|
|
362
|
-
console.error(fail(err.message || err));
|
|
363
|
-
const { retry } = await inquirer.prompt([
|
|
364
|
-
{
|
|
365
|
-
type: 'confirm',
|
|
366
|
-
name: 'retry',
|
|
367
|
-
message: t('menu.retry'),
|
|
368
|
-
default: true,
|
|
369
|
-
},
|
|
370
|
-
]);
|
|
371
|
-
loop = retry;
|
|
372
|
-
if (loop) {
|
|
373
|
-
console.log('');
|
|
374
|
-
await printContextStatus(projectRoot);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
module.exports = { runInteractiveLoop, runMenuAction, getMenuActions };
|
package/ui/theme.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ReactPress CLI visual identity — a single source of truth so banners,
|
|
5
|
-
* menus, status, doctor, build output all share the same colours and glyphs.
|
|
6
|
-
*/
|
|
7
|
-
const palette = {
|
|
8
|
-
primary: '#7C5CFF',
|
|
9
|
-
accent: '#22D3EE',
|
|
10
|
-
pink: '#F472B6',
|
|
11
|
-
green: '#22C55E',
|
|
12
|
-
amber: '#F59E0B',
|
|
13
|
-
red: '#EF4444',
|
|
14
|
-
gray: '#6B7280',
|
|
15
|
-
dim: '#9CA3AF',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const brand = {
|
|
19
|
-
primary: chalk.hex(palette.primary),
|
|
20
|
-
accent: chalk.hex(palette.accent),
|
|
21
|
-
pink: chalk.hex(palette.pink),
|
|
22
|
-
success: chalk.hex(palette.green),
|
|
23
|
-
warn: chalk.hex(palette.amber),
|
|
24
|
-
error: chalk.hex(palette.red),
|
|
25
|
-
muted: chalk.hex(palette.gray),
|
|
26
|
-
dim: chalk.hex(palette.dim),
|
|
27
|
-
bold: chalk.bold,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const icon = {
|
|
31
|
-
ok: brand.success('✓'),
|
|
32
|
-
fail: brand.error('✗'),
|
|
33
|
-
warn: brand.warn('⚠'),
|
|
34
|
-
info: brand.accent('ℹ'),
|
|
35
|
-
arrow: brand.primary('›'),
|
|
36
|
-
pointer: brand.primary('▸'),
|
|
37
|
-
bullet: brand.muted('·'),
|
|
38
|
-
dotOn: brand.success('●'),
|
|
39
|
-
dotOff: brand.muted('○'),
|
|
40
|
-
dotPending: brand.warn('◐'),
|
|
41
|
-
dotInfo: brand.accent('●'),
|
|
42
|
-
spark: brand.primary('✱'),
|
|
43
|
-
link: brand.muted('↗'),
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Whether a Unicode code point should occupy two terminal cells.
|
|
48
|
-
*
|
|
49
|
-
* Covers the common "East Asian Wide / Full-width" ranges that show up in
|
|
50
|
-
* Chinese / Japanese / Korean text plus full-width punctuation. We
|
|
51
|
-
* deliberately do not pull in a heavy dependency like `string-width` to keep
|
|
52
|
-
* the CLI's startup cheap.
|
|
53
|
-
*/
|
|
54
|
-
function isWideCodePoint(cp) {
|
|
55
|
-
return (
|
|
56
|
-
(cp >= 0x1100 && cp <= 0x115f) ||
|
|
57
|
-
(cp >= 0x2e80 && cp <= 0x303e) ||
|
|
58
|
-
(cp >= 0x3041 && cp <= 0x33ff) ||
|
|
59
|
-
(cp >= 0x3400 && cp <= 0x4dbf) ||
|
|
60
|
-
(cp >= 0x4e00 && cp <= 0x9fff) ||
|
|
61
|
-
(cp >= 0xa000 && cp <= 0xa4cf) ||
|
|
62
|
-
(cp >= 0xac00 && cp <= 0xd7a3) ||
|
|
63
|
-
(cp >= 0xf900 && cp <= 0xfaff) ||
|
|
64
|
-
(cp >= 0xfe30 && cp <= 0xfe4f) ||
|
|
65
|
-
(cp >= 0xff00 && cp <= 0xff60) ||
|
|
66
|
-
(cp >= 0xffe0 && cp <= 0xffe6) ||
|
|
67
|
-
(cp >= 0x1f300 && cp <= 0x1f64f) ||
|
|
68
|
-
(cp >= 0x1f900 && cp <= 0x1f9ff) ||
|
|
69
|
-
(cp >= 0x20000 && cp <= 0x2fffd) ||
|
|
70
|
-
(cp >= 0x30000 && cp <= 0x3fffd)
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Visible terminal-cell width of a string, after stripping ANSI colour codes
|
|
76
|
-
* and accounting for East Asian wide characters (which occupy 2 cells).
|
|
77
|
-
*/
|
|
78
|
-
function visibleLength(text) {
|
|
79
|
-
const stripped = String(text)
|
|
80
|
-
.replace(/\u001b\[[0-9;]*m/g, '')
|
|
81
|
-
.replace(/\u001b\]8;[^\u0007\u001b]*(?:\u0007|\u001b\\)/g, '');
|
|
82
|
-
let width = 0;
|
|
83
|
-
for (const ch of stripped) {
|
|
84
|
-
const cp = ch.codePointAt(0);
|
|
85
|
-
if (cp === undefined) continue;
|
|
86
|
-
if (cp < 0x20 || (cp >= 0x7f && cp < 0xa0)) continue;
|
|
87
|
-
width += isWideCodePoint(cp) ? 2 : 1;
|
|
88
|
-
}
|
|
89
|
-
return width;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function padRight(text, width) {
|
|
93
|
-
const len = visibleLength(text);
|
|
94
|
-
if (len >= width) return text;
|
|
95
|
-
return text + ' '.repeat(width - len);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function padLeft(text, width) {
|
|
99
|
-
const len = visibleLength(text);
|
|
100
|
-
if (len >= width) return text;
|
|
101
|
-
return ' '.repeat(width - len) + text;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function terminalWidth(fallback = 80) {
|
|
105
|
-
const cols = Number(process.stdout.columns) || fallback;
|
|
106
|
-
return Math.max(48, Math.min(120, cols));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function divider(width = 44, char = '─', colorize = brand.muted) {
|
|
110
|
-
return colorize(char.repeat(width));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Cyberpunk-flavoured progress-bar style decoration.
|
|
115
|
-
* `filled` segments use the primary colour, the trailing track stays muted.
|
|
116
|
-
*/
|
|
117
|
-
function pulseBar(width = 24, filled = Math.ceil(width * 0.7)) {
|
|
118
|
-
const f = Math.max(0, Math.min(width, filled));
|
|
119
|
-
const head = brand.primary('▰'.repeat(f));
|
|
120
|
-
const tail = brand.muted('▱'.repeat(Math.max(0, width - f)));
|
|
121
|
-
return `${head}${tail}`;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Three-light status indicator used in the top-right of the banner.
|
|
126
|
-
* Mimics the running-light cluster you'd see on a server rack.
|
|
127
|
-
*/
|
|
128
|
-
function statusLights(state = 'online') {
|
|
129
|
-
if (state === 'offline') {
|
|
130
|
-
return `${brand.muted('●')} ${brand.muted('●')} ${brand.muted('●')}`;
|
|
131
|
-
}
|
|
132
|
-
if (state === 'pending') {
|
|
133
|
-
return `${brand.warn('●')} ${brand.warn('●')} ${brand.muted('○')}`;
|
|
134
|
-
}
|
|
135
|
-
return `${brand.success('●')} ${brand.warn('●')} ${brand.muted('○')}`;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function hex2rgb(h) {
|
|
139
|
-
const s = h.replace('#', '');
|
|
140
|
-
return {
|
|
141
|
-
r: parseInt(s.substring(0, 2), 16),
|
|
142
|
-
g: parseInt(s.substring(2, 4), 16),
|
|
143
|
-
b: parseInt(s.substring(4, 6), 16),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function rgb2hex(r, g, b) {
|
|
148
|
-
const pad = (n) => n.toString(16).padStart(2, '0');
|
|
149
|
-
return `#${pad(r)}${pad(g)}${pad(b)}`;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function mixHex(a, b, t) {
|
|
153
|
-
const pa = hex2rgb(a);
|
|
154
|
-
const pb = hex2rgb(b);
|
|
155
|
-
const r = Math.round(pa.r + (pb.r - pa.r) * t);
|
|
156
|
-
const g = Math.round(pa.g + (pb.g - pa.g) * t);
|
|
157
|
-
const bl = Math.round(pa.b + (pb.b - pa.b) * t);
|
|
158
|
-
return rgb2hex(r, g, bl);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Paint a string with a left→right linear gradient across `colors` (hex).
|
|
163
|
-
* Falls back to plain text when stdout does not support truecolor.
|
|
164
|
-
*/
|
|
165
|
-
function gradientText(text, colors = [palette.primary, palette.accent], { bold = false } = {}) {
|
|
166
|
-
if (!text) return '';
|
|
167
|
-
const supports = chalk.supportsColor && chalk.supportsColor.has16m;
|
|
168
|
-
if (!supports || colors.length < 2) {
|
|
169
|
-
const c = chalk.hex(colors[0] || palette.primary);
|
|
170
|
-
return bold ? c.bold(text) : c(text);
|
|
171
|
-
}
|
|
172
|
-
const chars = [...String(text)];
|
|
173
|
-
const n = Math.max(chars.length - 1, 1);
|
|
174
|
-
return chars
|
|
175
|
-
.map((ch, i) => {
|
|
176
|
-
const ratio = i / n;
|
|
177
|
-
const idx = ratio * (colors.length - 1);
|
|
178
|
-
const lo = Math.floor(idx);
|
|
179
|
-
const hi = Math.min(colors.length - 1, lo + 1);
|
|
180
|
-
const local = idx - lo;
|
|
181
|
-
const c = chalk.hex(mixHex(colors[lo], colors[hi], local));
|
|
182
|
-
return bold ? c.bold(ch) : c(ch);
|
|
183
|
-
})
|
|
184
|
-
.join('');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function label(text) {
|
|
188
|
-
return `${icon.arrow} ${brand.primary(text)}`;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function ok(text) {
|
|
192
|
-
return `${icon.ok} ${brand.success(text)}`;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function fail(text) {
|
|
196
|
-
return `${icon.fail} ${brand.error(text)}`;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function warn(text) {
|
|
200
|
-
return `${icon.warn} ${brand.warn(text)}`;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function info(text) {
|
|
204
|
-
return `${icon.info} ${brand.accent(text)}`;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function chip(text, color = brand.primary) {
|
|
208
|
-
return color(`[ ${text} ]`);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function kv(key, value, { keyWidth = 10, valueColor = (s) => s } = {}) {
|
|
212
|
-
return `${brand.muted(padRight(key, keyWidth))} ${valueColor(value)}`;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Render a 3-state status pill, e.g. `● online` / `○ offline` / `◐ pending`.
|
|
217
|
-
*
|
|
218
|
-
* @param {boolean | 'pending'} state
|
|
219
|
-
* @param {{ on?: string, off?: string, pending?: string }} labels
|
|
220
|
-
*/
|
|
221
|
-
function statusPill(state, labels = {}) {
|
|
222
|
-
if (state === 'pending') {
|
|
223
|
-
return `${icon.dotPending} ${brand.warn(labels.pending || 'pending')}`;
|
|
224
|
-
}
|
|
225
|
-
if (state === true) {
|
|
226
|
-
return `${icon.dotOn} ${brand.success(labels.on || 'online')}`;
|
|
227
|
-
}
|
|
228
|
-
return `${icon.dotOff} ${brand.dim(labels.off || 'offline')}`;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Render a single-line section header: ` ── Title ────────────`.
|
|
233
|
-
*/
|
|
234
|
-
function sectionHeader(title, { width } = {}) {
|
|
235
|
-
const w = width ?? terminalWidth();
|
|
236
|
-
const prefix = brand.muted('── ');
|
|
237
|
-
const t = brand.bold(brand.primary(title));
|
|
238
|
-
const usedLen = visibleLength(prefix) + visibleLength(t) + 2;
|
|
239
|
-
const fillLen = Math.max(3, w - usedLen - 2);
|
|
240
|
-
const fill = brand.muted('─'.repeat(fillLen));
|
|
241
|
-
return ` ${prefix}${t} ${fill}`;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
module.exports = {
|
|
245
|
-
palette,
|
|
246
|
-
brand,
|
|
247
|
-
icon,
|
|
248
|
-
label,
|
|
249
|
-
ok,
|
|
250
|
-
fail,
|
|
251
|
-
warn,
|
|
252
|
-
info,
|
|
253
|
-
chip,
|
|
254
|
-
kv,
|
|
255
|
-
statusPill,
|
|
256
|
-
sectionHeader,
|
|
257
|
-
visibleLength,
|
|
258
|
-
padRight,
|
|
259
|
-
padLeft,
|
|
260
|
-
terminalWidth,
|
|
261
|
-
divider,
|
|
262
|
-
gradientText,
|
|
263
|
-
pulseBar,
|
|
264
|
-
statusLights,
|
|
265
|
-
};
|