@celljs/cli 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/bin/cell +2 -0
- package/lib/build/build-manager.d.ts +9 -0
- package/lib/build/build-manager.d.ts.map +1 -0
- package/lib/build/build-manager.js +41 -0
- package/lib/build/build-manager.js.map +1 -0
- package/lib/build/build.d.ts +6 -0
- package/lib/build/build.d.ts.map +1 -0
- package/lib/build/build.js +16 -0
- package/lib/build/build.js.map +1 -0
- package/lib/cell-main.d.ts +2 -0
- package/lib/cell-main.d.ts.map +1 -0
- package/lib/cell-main.js +110 -0
- package/lib/cell-main.js.map +1 -0
- package/lib/cell.d.ts +2 -0
- package/lib/cell.d.ts.map +1 -0
- package/lib/cell.js +190 -0
- package/lib/cell.js.map +1 -0
- package/lib/config/config.d.ts +12 -0
- package/lib/config/config.d.ts.map +1 -0
- package/lib/config/config.js +48 -0
- package/lib/config/config.js.map +1 -0
- package/lib/deploy/deploy.d.ts +7 -0
- package/lib/deploy/deploy.d.ts.map +1 -0
- package/lib/deploy/deploy.js +27 -0
- package/lib/deploy/deploy.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/info/info.d.ts +6 -0
- package/lib/info/info.d.ts.map +1 -0
- package/lib/info/info.js +21 -0
- package/lib/info/info.js.map +1 -0
- package/lib/init/init-manager.d.ts +33 -0
- package/lib/init/init-manager.d.ts.map +1 -0
- package/lib/init/init-manager.js +138 -0
- package/lib/init/init-manager.js.map +1 -0
- package/lib/init/init.d.ts +4 -0
- package/lib/init/init.d.ts.map +1 -0
- package/lib/init/init.js +17 -0
- package/lib/init/init.js.map +1 -0
- package/lib/init/templates.d.ts +2 -0
- package/lib/init/templates.d.ts.map +1 -0
- package/lib/init/templates.js +25 -0
- package/lib/init/templates.js.map +1 -0
- package/lib/malagu-main.d.ts +2 -0
- package/lib/malagu-main.d.ts.map +1 -0
- package/lib/malagu-main.js +110 -0
- package/lib/malagu-main.js.map +1 -0
- package/lib/malagu.d.ts +2 -0
- package/lib/malagu.d.ts.map +1 -0
- package/lib/malagu.js +190 -0
- package/lib/malagu.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/lib/props/props.d.ts +9 -0
- package/lib/props/props.d.ts.map +1 -0
- package/lib/props/props.js +46 -0
- package/lib/props/props.js.map +1 -0
- package/lib/serve/serve-manager.d.ts +8 -0
- package/lib/serve/serve-manager.d.ts.map +1 -0
- package/lib/serve/serve-manager.js +44 -0
- package/lib/serve/serve-manager.js.map +1 -0
- package/lib/serve/serve.d.ts +7 -0
- package/lib/serve/serve.d.ts.map +1 -0
- package/lib/serve/serve.js +16 -0
- package/lib/serve/serve.js.map +1 -0
- package/lib/update/update.d.ts +9 -0
- package/lib/update/update.d.ts.map +1 -0
- package/lib/update/update.js +56 -0
- package/lib/update/update.js.map +1 -0
- package/lib/utils/banner-util.d.ts +6 -0
- package/lib/utils/banner-util.d.ts.map +1 -0
- package/lib/utils/banner-util.js +44 -0
- package/lib/utils/banner-util.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +18 -0
- package/lib/utils/index.js.map +1 -0
- package/package.json +63 -0
- package/src/build/build-manager.ts +50 -0
- package/src/build/build.ts +17 -0
- package/src/cell-main.ts +125 -0
- package/src/cell.ts +214 -0
- package/src/config/config.ts +56 -0
- package/src/deploy/deploy.ts +31 -0
- package/src/index.ts +0 -0
- package/src/info/info.ts +23 -0
- package/src/init/init-manager.ts +163 -0
- package/src/init/init.ts +15 -0
- package/src/init/templates.ts +21 -0
- package/src/package.spec.ts +4 -0
- package/src/props/props.ts +48 -0
- package/src/serve/serve-manager.ts +51 -0
- package/src/serve/serve.ts +19 -0
- package/src/update/update.ts +61 -0
- package/src/utils/banner-util.ts +41 -0
- package/src/utils/index.ts +1 -0
- package/templates/accounts/README.md +92 -0
- package/templates/accounts/cell-database.yml +17 -0
- package/templates/accounts/cell-locale.yml +17 -0
- package/templates/accounts/cell-oauth2.0.yml +8 -0
- package/templates/accounts/cell-theme.yml +9 -0
- package/templates/accounts/cell.yml +10 -0
- package/templates/accounts/favicon.ico +0 -0
- package/templates/accounts/package.json +48 -0
- package/templates/accounts/src/browser/home.view.tsx +86 -0
- package/templates/accounts/src/browser/index.ts +3 -0
- package/templates/accounts/src/browser/login.view.tsx +78 -0
- package/templates/accounts/src/browser/module.ts +3 -0
- package/templates/accounts/src/common/entity-protocol.ts +7 -0
- package/templates/accounts/src/common/index.ts +1 -0
- package/templates/accounts/src/node/authentication/authentication-success-handler.ts +69 -0
- package/templates/accounts/src/node/authentication/index.ts +1 -0
- package/templates/accounts/src/node/entity/base-entity.ts +13 -0
- package/templates/accounts/src/node/entity/connection.ts +52 -0
- package/templates/accounts/src/node/entity/index.ts +1 -0
- package/templates/accounts/src/node/entity/user.ts +73 -0
- package/templates/accounts/src/node/error/error.ts +14 -0
- package/templates/accounts/src/node/error/index.ts +1 -0
- package/templates/accounts/src/node/index.ts +2 -0
- package/templates/accounts/src/node/module.ts +9 -0
- package/templates/accounts/src/node/user/index.ts +4 -0
- package/templates/accounts/src/node/user/user-protocol.ts +19 -0
- package/templates/accounts/src/node/user/user-repository.ts +72 -0
- package/templates/accounts/src/node/user/user-service.ts +36 -0
- package/templates/accounts/tsconfig.json +29 -0
- package/templates/admin-app/.github/workflows/deploy.yml +25 -0
- package/templates/admin-app/.vscode/launch.json +23 -0
- package/templates/admin-app/README.md +92 -0
- package/templates/admin-app/cell-database.yml +7 -0
- package/templates/admin-app/cell.yml +93 -0
- package/templates/admin-app/package.json +37 -0
- package/templates/admin-app/src/browser/module.ts +3 -0
- package/templates/admin-app/src/browser/user.view.tsx +40 -0
- package/templates/admin-app/src/common/index.ts +1 -0
- package/templates/admin-app/src/common/user-protocol.ts +23 -0
- package/templates/admin-app/src/node/entity/index.ts +1 -0
- package/templates/admin-app/src/node/entity/user.ts +15 -0
- package/templates/admin-app/src/node/module.ts +8 -0
- package/templates/admin-app/src/node/user-service.ts +41 -0
- package/templates/admin-app/tsconfig.json +29 -0
- package/templates/backend-app/.github/workflows/deploy.yml +25 -0
- package/templates/backend-app/.vscode/launch.json +23 -0
- package/templates/backend-app/README.md +92 -0
- package/templates/backend-app/cell.yml +0 -0
- package/templates/backend-app/package.json +33 -0
- package/templates/backend-app/src/home-controller.ts +11 -0
- package/templates/backend-app/src/module.ts +4 -0
- package/templates/backend-app/src/user-controller.ts +48 -0
- package/templates/backend-app/test/home-controller.spec.ts +16 -0
- package/templates/backend-app/tsconfig.json +29 -0
- package/templates/cell-component/.eslintrc.js +10 -0
- package/templates/cell-component/README.md +36 -0
- package/templates/cell-component/cell.yml +0 -0
- package/templates/cell-component/package.json +29 -0
- package/templates/cell-component/src/echo-service.ts +16 -0
- package/templates/cell-component/src/index.ts +1 -0
- package/templates/cell-component/src/module.ts +4 -0
- package/templates/cell-component/src/package.spec.ts +4 -0
- package/templates/cell-component/tsconfig.json +11 -0
- package/templates/database-app/.github/workflows/deploy.yml +25 -0
- package/templates/database-app/.vscode/launch.json +23 -0
- package/templates/database-app/README.md +92 -0
- package/templates/database-app/cell.yml +17 -0
- package/templates/database-app/package.json +31 -0
- package/templates/database-app/src/entity/index.ts +1 -0
- package/templates/database-app/src/entity/user.ts +13 -0
- package/templates/database-app/src/home-controller.ts +11 -0
- package/templates/database-app/src/module.ts +8 -0
- package/templates/database-app/src/user-controller.ts +43 -0
- package/templates/database-app/tsconfig.json +29 -0
- package/templates/docker-app/.github/workflows/deploy.yml +25 -0
- package/templates/docker-app/.vscode/launch.json +23 -0
- package/templates/docker-app/Dockerfile +27 -0
- package/templates/docker-app/README.md +93 -0
- package/templates/docker-app/cell.yml +0 -0
- package/templates/docker-app/package.json +31 -0
- package/templates/docker-app/src/browser/assets/logo.png +0 -0
- package/templates/docker-app/src/browser/css-shims.d.ts +30 -0
- package/templates/docker-app/src/browser/hello.view.tsx +31 -0
- package/templates/docker-app/src/browser/module.ts +3 -0
- package/templates/docker-app/src/browser/style/hello.module.scss +4 -0
- package/templates/docker-app/src/common/welcome-protocol.ts +5 -0
- package/templates/docker-app/src/node/module.ts +3 -0
- package/templates/docker-app/src/node/welcome-server.ts +9 -0
- package/templates/docker-app/tsconfig.json +30 -0
- package/templates/file-service/.github/workflows/deploy.yml +25 -0
- package/templates/file-service/.vscode/launch.json +23 -0
- package/templates/file-service/README.md +92 -0
- package/templates/file-service/cell.yml +12 -0
- package/templates/file-service/package.json +34 -0
- package/templates/file-service/src/file-controller.ts +47 -0
- package/templates/file-service/src/home-controller.ts +11 -0
- package/templates/file-service/src/module.ts +5 -0
- package/templates/file-service/tsconfig.json +29 -0
- package/templates/jwt-app/.github/workflows/deploy.yml +25 -0
- package/templates/jwt-app/.vscode/launch.json +23 -0
- package/templates/jwt-app/README.md +92 -0
- package/templates/jwt-app/cell.yml +4 -0
- package/templates/jwt-app/package.json +36 -0
- package/templates/jwt-app/src/context.ts +16 -0
- package/templates/jwt-app/src/error-handler.ts +30 -0
- package/templates/jwt-app/src/error.ts +4 -0
- package/templates/jwt-app/src/home-controller.ts +23 -0
- package/templates/jwt-app/src/index.ts +5 -0
- package/templates/jwt-app/src/jwt-middleware.ts +36 -0
- package/templates/jwt-app/src/module.ts +3 -0
- package/templates/jwt-app/test/home-controller.spec.ts +16 -0
- package/templates/jwt-app/tsconfig.json +29 -0
- package/templates/koa-app/app.js +8 -0
- package/templates/koa-app/package.json +9 -0
- package/templates/microservice/.github/workflows/deploy.yml +28 -0
- package/templates/microservice/.vscode/launch.json +24 -0
- package/templates/microservice/README.md +92 -0
- package/templates/microservice/examples/backend-app/README.md +92 -0
- package/templates/microservice/examples/backend-app/cell-remote.yml +4 -0
- package/templates/microservice/examples/backend-app/cell.yml +3 -0
- package/templates/microservice/examples/backend-app/package.json +32 -0
- package/templates/microservice/examples/backend-app/src/api-controller.ts +31 -0
- package/templates/microservice/examples/backend-app/src/module.ts +3 -0
- package/templates/microservice/examples/backend-app/tsconfig.json +29 -0
- package/templates/microservice/lerna.json +19 -0
- package/templates/microservice/package.json +23 -0
- package/templates/microservice/packages/api/README.md +92 -0
- package/templates/microservice/packages/api/cell.yml +0 -0
- package/templates/microservice/packages/api/package.json +25 -0
- package/templates/microservice/packages/api/src/common/api-protocol.ts +10 -0
- package/templates/microservice/packages/api/src/common/index.ts +1 -0
- package/templates/microservice/packages/api/tsconfig.json +27 -0
- package/templates/microservice/packages/serviceA/.vscode/launch.json +23 -0
- package/templates/microservice/packages/serviceA/README.md +92 -0
- package/templates/microservice/packages/serviceA/cell.yml +6 -0
- package/templates/microservice/packages/serviceA/package.json +29 -0
- package/templates/microservice/packages/serviceA/src/node/module.ts +3 -0
- package/templates/microservice/packages/serviceA/src/node/service-a.ts +9 -0
- package/templates/microservice/packages/serviceA/tsconfig.json +27 -0
- package/templates/microservice/packages/serviceB/README.md +92 -0
- package/templates/microservice/packages/serviceB/cell.yml +5 -0
- package/templates/microservice/packages/serviceB/package.json +29 -0
- package/templates/microservice/packages/serviceB/src/node/module.ts +3 -0
- package/templates/microservice/packages/serviceB/src/node/service-b.ts +9 -0
- package/templates/microservice/packages/serviceB/tsconfig.json +27 -0
- package/templates/microservice/tsconfig.json +29 -0
- package/templates/monorepo/.editorconfig +12 -0
- package/templates/monorepo/.eslintrc.js +18 -0
- package/templates/monorepo/.yarnrc +1 -0
- package/templates/monorepo/CHANGELOG.md +5 -0
- package/templates/monorepo/README.md +0 -0
- package/templates/monorepo/apps/sample-app/cell.yml +0 -0
- package/templates/monorepo/apps/sample-app/package.json +33 -0
- package/templates/monorepo/apps/sample-app/src/browser/assets/logo.png +0 -0
- package/templates/monorepo/apps/sample-app/src/browser/css-shims.d.ts +30 -0
- package/templates/monorepo/apps/sample-app/src/browser/hello.view.tsx +31 -0
- package/templates/monorepo/apps/sample-app/src/browser/module.ts +3 -0
- package/templates/monorepo/apps/sample-app/src/browser/style/hello.module.scss +4 -0
- package/templates/monorepo/apps/sample-app/src/common/welcome-protocol.ts +5 -0
- package/templates/monorepo/apps/sample-app/src/node/module.ts +3 -0
- package/templates/monorepo/apps/sample-app/src/node/welcome-server.ts +9 -0
- package/templates/monorepo/apps/sample-app/tsconfig.json +30 -0
- package/templates/monorepo/configs/root-compilation.tsconfig.json +14 -0
- package/templates/monorepo/configs/typedoc-tsconfig.json +6 -0
- package/templates/monorepo/configs/typedoc.json +23 -0
- package/templates/monorepo/lerna.json +17 -0
- package/templates/monorepo/package.json +46 -0
- package/templates/monorepo/packages/core/.eslintrc.js +10 -0
- package/templates/monorepo/packages/core/README.md +1 -0
- package/templates/monorepo/packages/core/cell.yml +0 -0
- package/templates/monorepo/packages/core/compile.tsconfig.json +13 -0
- package/templates/monorepo/packages/core/package.json +40 -0
- package/templates/monorepo/packages/core/src/browser/index.ts +0 -0
- package/templates/monorepo/packages/core/src/browser/module.ts +4 -0
- package/templates/monorepo/packages/core/src/common/index.ts +0 -0
- package/templates/monorepo/packages/core/src/common/module.ts +4 -0
- package/templates/monorepo/packages/core/src/node/index.ts +0 -0
- package/templates/monorepo/packages/core/src/node/module.ts +4 -0
- package/templates/monorepo/packages/core/src/package.spec.ts +4 -0
- package/templates/monorepo/scripts/check-publish.js +40 -0
- package/templates/monorepo/scripts/compile-references.js +286 -0
- package/templates/monorepo/tsconfig.json +20 -0
- package/templates/monorepo/tsfmt.json +3 -0
- package/templates/mycli/.vscode/launch.json +33 -0
- package/templates/mycli/bin/mycli +2 -0
- package/templates/mycli/bin/mycli-deploy +2 -0
- package/templates/mycli/bin/mycli-init +2 -0
- package/templates/mycli/package.json +33 -0
- package/templates/mycli/src/bootstrap.ts +7 -0
- package/templates/mycli/src/constants.ts +1 -0
- package/templates/mycli/src/deploy/deploy-manager.ts +12 -0
- package/templates/mycli/src/deploy/deploy.ts +16 -0
- package/templates/mycli/src/deploy/index.ts +1 -0
- package/templates/mycli/src/index.ts +2 -0
- package/templates/mycli/src/init/index.ts +1 -0
- package/templates/mycli/src/init/init-manager.ts +85 -0
- package/templates/mycli/src/init/init.ts +25 -0
- package/templates/mycli/src/init/templates.ts +3 -0
- package/templates/mycli/src/module.ts +3 -0
- package/templates/mycli/src/mycli.ts +13 -0
- package/templates/mycli/templates/application-template/README.md +0 -0
- package/templates/mycli/tsconfig.json +29 -0
- package/templates/nest-app/.eslintrc.js +25 -0
- package/templates/nest-app/.prettierrc +4 -0
- package/templates/nest-app/README.md +73 -0
- package/templates/nest-app/nest-cli.json +8 -0
- package/templates/nest-app/package.json +69 -0
- package/templates/nest-app/src/app.controller.spec.ts +22 -0
- package/templates/nest-app/src/app.controller.ts +12 -0
- package/templates/nest-app/src/app.module.ts +10 -0
- package/templates/nest-app/src/app.service.ts +8 -0
- package/templates/nest-app/src/main.ts +8 -0
- package/templates/nest-app/test/app.e2e-spec.ts +24 -0
- package/templates/nest-app/test/jest-e2e.json +9 -0
- package/templates/nest-app/tsconfig.build.json +4 -0
- package/templates/nest-app/tsconfig.json +21 -0
- package/templates/nextjs-app/.eslintrc.json +3 -0
- package/templates/nextjs-app/README.md +34 -0
- package/templates/nextjs-app/next.config.js +6 -0
- package/templates/nextjs-app/package.json +20 -0
- package/templates/nextjs-app/pages/_app.js +7 -0
- package/templates/nextjs-app/pages/api/hello.js +5 -0
- package/templates/nextjs-app/pages/index.js +69 -0
- package/templates/nextjs-app/public/favicon.ico +0 -0
- package/templates/nextjs-app/public/vercel.svg +4 -0
- package/templates/nextjs-app/styles/Home.module.css +116 -0
- package/templates/nextjs-app/styles/globals.css +16 -0
- package/templates/puppeteer/.github/workflows/deploy.yml +25 -0
- package/templates/puppeteer/.vscode/launch.json +23 -0
- package/templates/puppeteer/README.md +92 -0
- package/templates/puppeteer/cell.yml +11 -0
- package/templates/puppeteer/package.json +31 -0
- package/templates/puppeteer/src/home-controller.ts +11 -0
- package/templates/puppeteer/src/module.ts +5 -0
- package/templates/puppeteer/src/puppeteer-controller.ts +26 -0
- package/templates/puppeteer/tsconfig.json +29 -0
- package/templates/sample-app/.github/workflows/deploy.yml +25 -0
- package/templates/sample-app/.vscode/launch.json +23 -0
- package/templates/sample-app/README.md +92 -0
- package/templates/sample-app/cell.yml +0 -0
- package/templates/sample-app/package.json +31 -0
- package/templates/sample-app/src/browser/assets/logo.png +0 -0
- package/templates/sample-app/src/browser/css-shims.d.ts +30 -0
- package/templates/sample-app/src/browser/hello.view.tsx +31 -0
- package/templates/sample-app/src/browser/module.ts +3 -0
- package/templates/sample-app/src/browser/style/hello.module.scss +4 -0
- package/templates/sample-app/src/common/welcome-protocol.ts +5 -0
- package/templates/sample-app/src/node/module.ts +3 -0
- package/templates/sample-app/src/node/welcome-server.ts +9 -0
- package/templates/sample-app/tsconfig.json +29 -0
- package/templates/schedule/.github/workflows/deploy.yml +25 -0
- package/templates/schedule/.vscode/launch.json +23 -0
- package/templates/schedule/README.md +92 -0
- package/templates/schedule/cell.yml +1 -0
- package/templates/schedule/package.json +29 -0
- package/templates/schedule/src/module.ts +3 -0
- package/templates/schedule/src/scheduler.ts +10 -0
- package/templates/schedule/tsconfig.json +29 -0
- package/templates/standalone-app/package.json +17 -0
- package/templates/standalone-app/src/app.service.ts +10 -0
- package/templates/standalone-app/src/main.ts +14 -0
- package/templates/standalone-app/src/module.ts +3 -0
- package/templates/standalone-app/tsconfig.json +27 -0
- package/templates/vue-app/.github/workflows/deploy.yml +25 -0
- package/templates/vue-app/.vscode/launch.json +23 -0
- package/templates/vue-app/README.md +92 -0
- package/templates/vue-app/cell.yml +0 -0
- package/templates/vue-app/package.json +32 -0
- package/templates/vue-app/src/browser/App.vue +32 -0
- package/templates/vue-app/src/browser/app.ts +7 -0
- package/templates/vue-app/src/browser/components/HelloWorld.vue +42 -0
- package/templates/vue-app/src/browser/declare.d.ts +7 -0
- package/templates/vue-app/src/browser/images/logo.png +0 -0
- package/templates/vue-app/src/browser/module.ts +3 -0
- package/templates/vue-app/src/browser/router.ts +13 -0
- package/templates/vue-app/src/browser/shims-vue.d.ts +5 -0
- package/templates/vue-app/src/browser/views/About.vue +5 -0
- package/templates/vue-app/src/browser/views/Root.vue +37 -0
- package/templates/vue-app/src/common/welcome-protocol.ts +5 -0
- package/templates/vue-app/src/node/module.ts +3 -0
- package/templates/vue-app/src/node/welcome-server.ts +9 -0
- package/templates/vue-app/tsconfig.json +30 -0
package/src/cell.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
const leven = require('leven');
|
|
2
|
+
import * as ora from 'ora';
|
|
3
|
+
import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
|
|
4
|
+
import { CommandUtil } from '@celljs/cli-common/lib/utils/command-util';
|
|
5
|
+
import { program, Command } from '@celljs/cli-common/lib/command/command-protocol';
|
|
6
|
+
import { BannerUtil } from './utils/banner-util';
|
|
7
|
+
import build from './build/build';
|
|
8
|
+
import serve from './serve/serve';
|
|
9
|
+
import deploy from './deploy/deploy';
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
const updateNotifier = require('update-notifier');
|
|
12
|
+
const pkg = require('../package.json');
|
|
13
|
+
|
|
14
|
+
const version = pkg.version;
|
|
15
|
+
updateNotifier({ pkg }).notify();
|
|
16
|
+
|
|
17
|
+
const spinner = ora({ text: chalk.italic.gray('loading command line context...\n'), discardStdin: false });
|
|
18
|
+
|
|
19
|
+
(async () => {
|
|
20
|
+
const { runtime, framework, settings } = JSON.parse(process.env.MALAGU_RFS!);
|
|
21
|
+
BannerUtil.print(version, settings, runtime, framework);
|
|
22
|
+
|
|
23
|
+
spinner.start();
|
|
24
|
+
const context = await CommandUtil.loadContext(settings, framework, runtime, undefined, spinner);
|
|
25
|
+
await new HookExecutor().executeHooks(context, 'cliHooks', HookStage.before);
|
|
26
|
+
const { componentPackages, configHookModules, webpackHookModules, serveHookModules, buildHookModules, deployHookModules, infoHookModules, propsHookModules } = context.pkg;
|
|
27
|
+
|
|
28
|
+
if (CommandUtil.includesCommand(context.args, settings.compileCommands)) {
|
|
29
|
+
process.send!({
|
|
30
|
+
type: 'cliContext',
|
|
31
|
+
data: {
|
|
32
|
+
components: componentPackages.map(c => c.cellComponent),
|
|
33
|
+
configHookModules,
|
|
34
|
+
webpackHookModules,
|
|
35
|
+
serveHookModules,
|
|
36
|
+
buildHookModules,
|
|
37
|
+
deployHookModules,
|
|
38
|
+
infoHookModules,
|
|
39
|
+
propsHookModules
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
program
|
|
45
|
+
.version(version, '-V, --version', 'version for cell')
|
|
46
|
+
.option('-t, --targets [targets]', 'targets for cell', value => value ? value.split(',') : [])
|
|
47
|
+
.option('-m, --mode [mode]', 'mode for cell', value => value ? value.split(',') : [])
|
|
48
|
+
.option('--props-dir [propsDir]', 'props directory for cell')
|
|
49
|
+
.option('--props-file [propsFile]', 'props file for cell')
|
|
50
|
+
.option('--skip-auto-install [skipAutoInstall]', 'skip automatic installation of components for cell')
|
|
51
|
+
.usage('<command> [options]');
|
|
52
|
+
|
|
53
|
+
program
|
|
54
|
+
.command('init [template]')
|
|
55
|
+
.option('-o, --output-dir [path]', 'output directory')
|
|
56
|
+
.option('-p --packager [packager]', 'package manager(pnpm, yarn, npm)')
|
|
57
|
+
.description('init a application')
|
|
58
|
+
.action((template, options) => {
|
|
59
|
+
require('./init/init').default({ template, ...options });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
program
|
|
63
|
+
.command('serve')
|
|
64
|
+
.option('-p, --port [port]', 'port used by the server')
|
|
65
|
+
.description('serve a applicaton')
|
|
66
|
+
.action((entry, options) => {
|
|
67
|
+
serve(context, { entry, ...options });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
program
|
|
71
|
+
.command('build')
|
|
72
|
+
.description('build a application')
|
|
73
|
+
.action((entry, options) => {
|
|
74
|
+
build(context, { entry, ...options });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
program
|
|
78
|
+
.command('deploy')
|
|
79
|
+
.option('-s, --skip-build [skipBuild]', 'skip the build process')
|
|
80
|
+
.description('deploy a applicaton')
|
|
81
|
+
.action((entry, options) => {
|
|
82
|
+
deploy(context, { entry, ...options });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
program
|
|
86
|
+
.command('props')
|
|
87
|
+
.description('display properties about application')
|
|
88
|
+
.option('-n, --name [name]', 'get the property value of the specified name')
|
|
89
|
+
.option('-f, --frontend [frontend]', 'frontend properties')
|
|
90
|
+
.option('-b, --backend [backend]', 'backend properties')
|
|
91
|
+
.action(options => {
|
|
92
|
+
require('./props/props').default(context, { ...options });
|
|
93
|
+
});
|
|
94
|
+
program
|
|
95
|
+
.command('info')
|
|
96
|
+
.description('display information about application')
|
|
97
|
+
.action(options => {
|
|
98
|
+
require('./info/info').default(context, { ...options });
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
program
|
|
102
|
+
.command('config')
|
|
103
|
+
.option('--default-runtime [defaultRuntime]', 'default runtime')
|
|
104
|
+
.option('--default-mode [defaultMode]', 'default mode', value => value ? value.split(',') : [])
|
|
105
|
+
.option('--frameworks-url [frameworksUrl]', 'frameworks url')
|
|
106
|
+
.option('--frameworks-upstream-url [frameworksUpStreamUrl]', 'frameworks upstream url')
|
|
107
|
+
.option('--config-file-alias [configFileAlias]', 'config file alias')
|
|
108
|
+
.option('--show [show]', 'show properties for the application')
|
|
109
|
+
.description('configure properties for the application')
|
|
110
|
+
.action(options => {
|
|
111
|
+
require('./config/config').default(context, { ...options });
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
program
|
|
115
|
+
.command('update')
|
|
116
|
+
.option('-v, --version [version]', 'version for cell')
|
|
117
|
+
.option('-d, --dist-tag [distTag]', 'Which dist-tag to use to find the latest version')
|
|
118
|
+
.option('-s, --skip-installing-component [skipIntallingComponent]', 'skip installing components')
|
|
119
|
+
.description('update cell cli and current project\'s cell components')
|
|
120
|
+
.action(options => {
|
|
121
|
+
require('./update/update').default(context, { ...options });
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const runtimeCmd = program
|
|
125
|
+
.command('runtime [command]')
|
|
126
|
+
.alias('r')
|
|
127
|
+
.description('management runtime');
|
|
128
|
+
runtimeCmd
|
|
129
|
+
.command('install [runtime] [alias]')
|
|
130
|
+
.alias('i')
|
|
131
|
+
.description('install a runtime')
|
|
132
|
+
.option('-f, --force-installing-component [forceInstallingComponent]', 'force installing component')
|
|
133
|
+
.option('-o, --overwrite [overwrite]', 'overwrite existing runtime')
|
|
134
|
+
.option('-v, --version [version]', 'specify runtime version', 'latest')
|
|
135
|
+
.action((r, alias, options) => {
|
|
136
|
+
require('@celljs/cli-runtime/lib/install/install').default({ runtime: r, alias, ...options });
|
|
137
|
+
});
|
|
138
|
+
runtimeCmd
|
|
139
|
+
.command('use [runtime]')
|
|
140
|
+
.description('use a runtime')
|
|
141
|
+
.action(r => {
|
|
142
|
+
require('@celljs/cli-runtime/lib/use/use').default({ runtime: r });
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
runtimeCmd
|
|
146
|
+
.command('list')
|
|
147
|
+
.alias('ls')
|
|
148
|
+
.description('list all runtimes')
|
|
149
|
+
.action(() => {
|
|
150
|
+
require('@celljs/cli-runtime/lib/list/list').default({});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
runtimeCmd
|
|
154
|
+
.command('uninstall [runtime]')
|
|
155
|
+
.alias('u')
|
|
156
|
+
.description('uninstall a runtime')
|
|
157
|
+
.action(r => {
|
|
158
|
+
require('@celljs/cli-runtime/lib/uninstall/uninstall').default({ runtime: r });
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await new HookExecutor().executeHooks(context, 'cliHooks');
|
|
162
|
+
spinner.stop();
|
|
163
|
+
|
|
164
|
+
program
|
|
165
|
+
.arguments('[command]')
|
|
166
|
+
.action(cmd => {
|
|
167
|
+
program.outputHelp();
|
|
168
|
+
if (cmd) {
|
|
169
|
+
console.log();
|
|
170
|
+
console.log(chalk.red(`Unknown command ${chalk.yellow(cmd)}.`));
|
|
171
|
+
console.log();
|
|
172
|
+
suggestCommands(cmd, program);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
runtimeCmd
|
|
178
|
+
.arguments('[command]')
|
|
179
|
+
.action(cmd => {
|
|
180
|
+
runtimeCmd.outputHelp();
|
|
181
|
+
if (cmd) {
|
|
182
|
+
console.log();
|
|
183
|
+
console.log(chalk.red(`Unknown command ${chalk.yellow(cmd)}.`));
|
|
184
|
+
console.log();
|
|
185
|
+
suggestCommands(cmd, runtimeCmd);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
});
|
|
189
|
+
program.addHelpText('after', '\nUse "cell [command] --help" for more information about a command.');
|
|
190
|
+
program.parse(process.argv);
|
|
191
|
+
|
|
192
|
+
})().catch(error => {
|
|
193
|
+
spinner.stop();
|
|
194
|
+
console.error(error);
|
|
195
|
+
process.exit(-1);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
function suggestCommands(unknownCommand: string, main: Command) {
|
|
199
|
+
const availableCommands = main.commands.map((cmd: Command) => cmd.name());
|
|
200
|
+
|
|
201
|
+
let suggestion: string = '';
|
|
202
|
+
|
|
203
|
+
availableCommands.forEach((cmd: string) => {
|
|
204
|
+
const isBestMatch = leven(cmd, unknownCommand) < leven(suggestion, unknownCommand);
|
|
205
|
+
if (leven(cmd, unknownCommand) <= 3 && isBestMatch) {
|
|
206
|
+
suggestion = cmd;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (suggestion) {
|
|
211
|
+
console.log(` ${chalk.yellow(`Did you mean ${chalk.green(suggestion)}?`)}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
|
|
3
|
+
import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
|
|
4
|
+
import { SettingsUtil } from '@celljs/cli-common/lib/settings/settings-util';
|
|
5
|
+
|
|
6
|
+
import { dump } from 'js-yaml';
|
|
7
|
+
|
|
8
|
+
export interface ConfigOptions {
|
|
9
|
+
frameworksUrl?: string;
|
|
10
|
+
frameworksUpstreamUrl?: boolean;
|
|
11
|
+
configFileAlias?: string;
|
|
12
|
+
defaultMode?: string[];
|
|
13
|
+
defaultRuntime?: string[];
|
|
14
|
+
show?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default async (ctx: CliContext, options: ConfigOptions) => {
|
|
18
|
+
try {
|
|
19
|
+
ctx.options = options;
|
|
20
|
+
const hookExecutor = new HookExecutor();
|
|
21
|
+
await hookExecutor.executeConfigHooks(ctx, HookStage.before);
|
|
22
|
+
if (options.defaultMode?.length) {
|
|
23
|
+
SettingsUtil.updateSettings({
|
|
24
|
+
defaultMode: options.defaultMode
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (options.defaultRuntime) {
|
|
28
|
+
SettingsUtil.updateSettings({
|
|
29
|
+
defaultRuntime: options.defaultRuntime
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (options.frameworksUpstreamUrl || options.frameworksUrl) {
|
|
33
|
+
SettingsUtil.updateSettings({
|
|
34
|
+
frameworks: {
|
|
35
|
+
url: options.frameworksUrl,
|
|
36
|
+
upstreamUrl: options.frameworksUpstreamUrl
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (options.configFileAlias) {
|
|
41
|
+
SettingsUtil.updateSettings({
|
|
42
|
+
configFileAlias: options.configFileAlias
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (options.show) {
|
|
46
|
+
ctx.output.settings = SettingsUtil.getSettings();
|
|
47
|
+
}
|
|
48
|
+
await hookExecutor.executeConfigHooks(ctx);
|
|
49
|
+
if (options.show) {
|
|
50
|
+
console.log(dump(ctx.output));
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(error);
|
|
54
|
+
process.exit(-1);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import build from '../build/build';
|
|
3
|
+
import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
|
|
4
|
+
import { CliContext, ContextUtils } from '@celljs/cli-common/lib/context/context-protocol';
|
|
5
|
+
import { CommandUtil, CommandType, CommandStage } from '@celljs/cli-common/lib/utils/command-util';
|
|
6
|
+
|
|
7
|
+
export interface DeplyOptions {
|
|
8
|
+
skipBuild?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default async (ctx: CliContext, options: DeplyOptions) => {
|
|
12
|
+
try {
|
|
13
|
+
ctx.options = options;
|
|
14
|
+
ctx = ContextUtils.mergeContext(ctx, options);
|
|
15
|
+
const hookExecutor = new HookExecutor();
|
|
16
|
+
await CommandUtil.executeCommand(ctx, CommandType.DeployCommand, CommandStage.before);
|
|
17
|
+
await hookExecutor.executeDeployHooks(ctx, HookStage.before);
|
|
18
|
+
if (!options.skipBuild) {
|
|
19
|
+
await build(ctx, options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
await CommandUtil.executeCommand(ctx, CommandType.DeployCommand);
|
|
23
|
+
|
|
24
|
+
await hookExecutor.executeDeployHooks(ctx);
|
|
25
|
+
await hookExecutor.executeDeployHooks(ctx, HookStage.after);
|
|
26
|
+
await CommandUtil.executeCommand(ctx, CommandType.DeployCommand, CommandStage.after);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error);
|
|
29
|
+
process.exit(-1);
|
|
30
|
+
}
|
|
31
|
+
};
|
package/src/index.ts
ADDED
|
File without changes
|
package/src/info/info.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
|
|
2
|
+
import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
|
|
3
|
+
import { LoggerUtil } from '@celljs/cli-common/lib/utils/logger-util';
|
|
4
|
+
|
|
5
|
+
export interface InfoOptions {}
|
|
6
|
+
|
|
7
|
+
export default async (ctx: CliContext, options: InfoOptions) => {
|
|
8
|
+
try {
|
|
9
|
+
ctx.options = options;
|
|
10
|
+
const hookExecutor = new HookExecutor();
|
|
11
|
+
await hookExecutor.executeInfoHooks(ctx, HookStage.before);
|
|
12
|
+
|
|
13
|
+
LoggerUtil.printStage(ctx);
|
|
14
|
+
LoggerUtil.printMode(ctx);
|
|
15
|
+
LoggerUtil.printTargets(ctx);
|
|
16
|
+
LoggerUtil.printComponents(ctx);
|
|
17
|
+
|
|
18
|
+
await hookExecutor.executeInfoHooks(ctx);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(error);
|
|
21
|
+
process.exit(-1);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { resolve, basename, relative, join } from 'path';
|
|
2
|
+
import { existsSync, copy, readFile, writeJSON } from 'fs-extra';
|
|
3
|
+
import { templates } from './templates';
|
|
4
|
+
import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
|
|
5
|
+
import { getPackager, spawnProcess } from '@celljs/cli-common/lib/packager/utils';
|
|
6
|
+
import { HookExecutor } from '@celljs/cli-common/lib/hook/hook-executor';
|
|
7
|
+
import { CommandUtil } from '@celljs/cli-common/lib/utils/command-util';
|
|
8
|
+
import { prompts } from 'prompts';
|
|
9
|
+
import * as ora from 'ora';
|
|
10
|
+
const rimraf = require('rimraf');
|
|
11
|
+
const chalk = require('chalk');
|
|
12
|
+
import { ok } from 'assert';
|
|
13
|
+
import { RuntimeUtil } from '@celljs/cli-runtime';
|
|
14
|
+
const version = require('../../package.json').version;
|
|
15
|
+
|
|
16
|
+
const PLACEHOLD = '{{ templatePath }}';
|
|
17
|
+
|
|
18
|
+
const remoteTemplateRegex = /^(https?:|git@)/i;
|
|
19
|
+
|
|
20
|
+
export interface Template {
|
|
21
|
+
name: string;
|
|
22
|
+
location: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface InitOptions {
|
|
26
|
+
template?: string;
|
|
27
|
+
packager?: 'pnpm' | 'yarn' | 'npm';
|
|
28
|
+
outputDir: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class InitManager {
|
|
32
|
+
|
|
33
|
+
protected source: any[];
|
|
34
|
+
protected templateName: string;
|
|
35
|
+
protected location: string;
|
|
36
|
+
protected cliContext: CliContext;
|
|
37
|
+
constructor(protected readonly opts: InitOptions) {
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async output(): Promise<void> {
|
|
42
|
+
await this.selectTemplate();
|
|
43
|
+
await this.checkOutputDir();
|
|
44
|
+
await this.doOutput();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async render(): Promise<void> {
|
|
48
|
+
const packageJsonPath = resolve(this.outputDir, 'package.json');
|
|
49
|
+
if (existsSync(packageJsonPath)) {
|
|
50
|
+
let packageJsonStr = await readFile(packageJsonPath, { encoding: 'utf8' });
|
|
51
|
+
packageJsonStr = packageJsonStr.replace(/{{\s*version\s*}}/g, version);
|
|
52
|
+
const packageJson = JSON.parse(packageJsonStr);
|
|
53
|
+
packageJson.name = basename(this.outputDir);
|
|
54
|
+
await writeJSON(packageJsonPath, packageJson, { encoding: 'utf8', spaces: 2 });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async install(): Promise<void> {
|
|
59
|
+
const pkg = CommandUtil.getPkg(undefined, this.outputDir);
|
|
60
|
+
const packager = this.opts.packager || pkg.rootComponentPackage.cellComponent?.packager;
|
|
61
|
+
|
|
62
|
+
await getPackager(packager, this.outputDir).install({}, this.outputDir);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async executeHooks(): Promise<void> {
|
|
66
|
+
const outputDir = this.outputDir;
|
|
67
|
+
const initContext = await this.getCliContext();
|
|
68
|
+
await new HookExecutor().executeHooks(initContext, 'initHooks');
|
|
69
|
+
console.log(chalk`{bold.green Success!} Initialized "${ this.templateName }" example in {bold.blue ${outputDir}}.`);
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected async getCliContext(): Promise<CliContext> {
|
|
74
|
+
if (!this.cliContext) {
|
|
75
|
+
this.cliContext = await RuntimeUtil.initRuntimeAndLoadContext(this.outputDir);
|
|
76
|
+
this.cliContext.location = this.realLocation;
|
|
77
|
+
this.cliContext.outputDir = this.outputDir;
|
|
78
|
+
}
|
|
79
|
+
return this.cliContext;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected get outputDir(): string {
|
|
83
|
+
return resolve(process.cwd(), this.opts.outputDir ? this.opts.outputDir : this.location.split('/').pop()!.replace('.git', ''));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
protected async checkOutputDir(): Promise<void> {
|
|
87
|
+
if (existsSync(this.outputDir)) {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
89
|
+
await prompts.confirm({
|
|
90
|
+
name: 'remove',
|
|
91
|
+
type: 'confirm',
|
|
92
|
+
message: `App already exists, remove the app (dir: ${join(relative(process.cwd(), this.outputDir))})`,
|
|
93
|
+
onState: ({ value }) => {
|
|
94
|
+
if (value === true) {
|
|
95
|
+
rimraf.sync(this.outputDir);
|
|
96
|
+
} else {
|
|
97
|
+
process.exit(0);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
protected toOfficialTemplate(name: string, location: string): any {
|
|
105
|
+
return { title: `${name} ${chalk.italic.gray('Official')}`, value: { location, name} };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
protected toThirdPartyTemplate(item: any): any {
|
|
109
|
+
return { title: `${item.name} ${chalk.italic.gray(item.stargazers_count + '⭑')}`, value: { location: item.clone_url, name: item.name }};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
protected async selectTemplate(): Promise<void> {
|
|
113
|
+
const { template } = this.opts;
|
|
114
|
+
if (template) {
|
|
115
|
+
this.templateName = template;
|
|
116
|
+
if (remoteTemplateRegex.test(template)) {
|
|
117
|
+
this.location = template;
|
|
118
|
+
} else {
|
|
119
|
+
Object.keys(templates).forEach(key => {
|
|
120
|
+
if (key === template) {
|
|
121
|
+
this.location = templates[key];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
ok(this.location, `"${template}" template not found`);
|
|
125
|
+
}
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const spinner = ora({ text: 'loading...', discardStdin: false }).start();
|
|
129
|
+
const officialTemplates = Object.keys(templates).map(key => this.toOfficialTemplate(key, templates[key]));
|
|
130
|
+
const choices = officialTemplates;
|
|
131
|
+
spinner.stop();
|
|
132
|
+
const answer = await prompts.autocomplete({
|
|
133
|
+
type: 'autocomplete',
|
|
134
|
+
name: 'template',
|
|
135
|
+
limit: 12,
|
|
136
|
+
message: 'Select a template to init',
|
|
137
|
+
choices,
|
|
138
|
+
suggest: async input => choices.filter(item => !input || item.title.toLowerCase().includes(input.toLowerCase()))
|
|
139
|
+
});
|
|
140
|
+
this.templateName = answer.name;
|
|
141
|
+
this.location = answer.location;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
protected get realLocation() {
|
|
145
|
+
return this.location.replace(PLACEHOLD, resolve(__dirname, '..', '..', 'templates'));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
protected async doOutput(): Promise<void> {
|
|
149
|
+
if (remoteTemplateRegex.test(this.location)) {
|
|
150
|
+
await this.outputRemoteTempate();
|
|
151
|
+
} else {
|
|
152
|
+
await this.outputLocalTemplate();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
protected async outputLocalTemplate(): Promise<void> {
|
|
156
|
+
await copy(this.realLocation, this.outputDir);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
protected outputRemoteTempate(): Promise<any> {
|
|
160
|
+
const dir = this.opts.outputDir ? [ this.opts.outputDir ] : [];
|
|
161
|
+
return spawnProcess('git', [ 'clone', '--depth=1', this.location, ...dir ], { stdio: 'inherit' });
|
|
162
|
+
}
|
|
163
|
+
}
|
package/src/init/init.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InitManager, InitOptions } from './init-manager';
|
|
2
|
+
|
|
3
|
+
export default async (options: InitOptions) => {
|
|
4
|
+
try {
|
|
5
|
+
const initManager = new InitManager(options);
|
|
6
|
+
await initManager.output();
|
|
7
|
+
await initManager.render();
|
|
8
|
+
await initManager.install();
|
|
9
|
+
await initManager.executeHooks();
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error(error);
|
|
12
|
+
process.exit(-1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const templates: any = {
|
|
2
|
+
'backend-app': '{{ templatePath }}/backend-app',
|
|
3
|
+
'sample-app': '{{ templatePath }}/sample-app',
|
|
4
|
+
'cell-component': '{{ templatePath }}/cell-component',
|
|
5
|
+
'docker-app': '{{ templatePath }}/docker-app',
|
|
6
|
+
'monorepo': '{{ templatePath }}/monorepo',
|
|
7
|
+
'nest-app': '{{ templatePath }}/nest-app',
|
|
8
|
+
'nextjs-app': '{{ templatePath }}/nextjs-app',
|
|
9
|
+
'koa-app': '{{ templatePath }}/koa-app',
|
|
10
|
+
'vue-app': '{{ templatePath }}/vue-app',
|
|
11
|
+
'database-app': '{{ templatePath }}/database-app',
|
|
12
|
+
'jwt-app': '{{ templatePath }}/jwt-app',
|
|
13
|
+
'accounts': '{{ templatePath }}/accounts',
|
|
14
|
+
'schedule': '{{ templatePath }}/schedule',
|
|
15
|
+
'admin-app': '{{ templatePath }}/admin-app',
|
|
16
|
+
'microservice': '{{ templatePath }}/microservice',
|
|
17
|
+
'standalone-app': '{{ templatePath }}/standalone-app',
|
|
18
|
+
'file-service': '{{ templatePath }}/file-service',
|
|
19
|
+
'puppeteer': '{{ templatePath }}/puppeteer',
|
|
20
|
+
'mycli': '{{ templatePath }}/mycli'
|
|
21
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
|
|
2
|
+
import { ConfigUtil } from '@celljs/cli-common/lib/utils/config-util';
|
|
3
|
+
import { dump } from 'js-yaml';
|
|
4
|
+
import * as traverse from 'traverse';
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
|
|
7
|
+
export interface PropsOptions {
|
|
8
|
+
backend?: boolean;
|
|
9
|
+
frontend?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default async (ctx: CliContext, options: PropsOptions) => {
|
|
14
|
+
try {
|
|
15
|
+
ctx.options = options;
|
|
16
|
+
let backendProps: any;
|
|
17
|
+
let frontendProps: any;
|
|
18
|
+
|
|
19
|
+
if (options.frontend) {
|
|
20
|
+
frontendProps = ConfigUtil.getFrontendConfig(ctx.cfg);
|
|
21
|
+
} else if (options.backend) {
|
|
22
|
+
backendProps = ConfigUtil.getBackendConfig(ctx.cfg);
|
|
23
|
+
} else {
|
|
24
|
+
frontendProps = ConfigUtil.getFrontendConfig(ctx.cfg);
|
|
25
|
+
backendProps = ConfigUtil.getBackendConfig(ctx.cfg);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (frontendProps) {
|
|
29
|
+
console.log(chalk`{bold.magenta - Frontend: }`);
|
|
30
|
+
if (options.name) {
|
|
31
|
+
console.log(`${options.name}: ${traverse(frontendProps).get(options.name.split('.'))}`);
|
|
32
|
+
} else {
|
|
33
|
+
console.log(dump(ConfigUtil.getFrontendConfig(ctx.cfg), { skipInvalid: true }));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (backendProps) {
|
|
37
|
+
console.log(chalk`{bold.magenta - Backend: }`);
|
|
38
|
+
if (options.name) {
|
|
39
|
+
console.log(`${options.name}: ${traverse(backendProps).get(options.name.split('.'))}`);
|
|
40
|
+
} else {
|
|
41
|
+
console.log(dump(ConfigUtil.getBackendConfig(ctx.cfg), { skipInvalid: true }));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error(error);
|
|
46
|
+
process.exit(-1);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { LoggerUtil } from '@celljs/cli-common/lib/utils/logger-util';
|
|
2
|
+
import { CommandUtil, CommandType, CommandStage } from '@celljs/cli-common/lib/utils/command-util';
|
|
3
|
+
import { CliContext } from '@celljs/cli-common/lib/context/context-protocol';
|
|
4
|
+
import { HookExecutor, HookStage } from '@celljs/cli-common/lib/hook/hook-executor';
|
|
5
|
+
import { ConfigUtil } from '@celljs/cli-common/lib/utils';
|
|
6
|
+
|
|
7
|
+
export class ServeManager {
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
protected readonly context: CliContext) {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
protected log() {
|
|
14
|
+
LoggerUtil.printStage(this.context);
|
|
15
|
+
LoggerUtil.printMode(this.context);
|
|
16
|
+
LoggerUtil.printTargets(this.context);
|
|
17
|
+
LoggerUtil.printComponents(this.context);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async start() {
|
|
21
|
+
|
|
22
|
+
this.log();
|
|
23
|
+
|
|
24
|
+
const commandRender = async (command: string, target: string) => {
|
|
25
|
+
const { cfg, port } = this.context;
|
|
26
|
+
const realPort = ConfigUtil.getPort(cfg, target, port);
|
|
27
|
+
return command
|
|
28
|
+
.replace(/\$PATH/g, ConfigUtil.getCellConfig(cfg, target).server?.path)
|
|
29
|
+
.replace(/\$PORT/g, realPort);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const hookExecutor = new HookExecutor();
|
|
33
|
+
await CommandUtil.executeCommand(this.context, CommandType.CompileCommand, CommandStage.before);
|
|
34
|
+
await hookExecutor.executeCompileHooks(this.context, HookStage.before);
|
|
35
|
+
|
|
36
|
+
await CommandUtil.executeCommand(this.context, CommandType.CompileCommand);
|
|
37
|
+
await hookExecutor.executeCompileHooks(this.context);
|
|
38
|
+
|
|
39
|
+
await hookExecutor.executeCompileHooks(this.context, HookStage.after);
|
|
40
|
+
await CommandUtil.executeCommand(this.context, CommandType.CompileCommand, CommandStage.after);
|
|
41
|
+
|
|
42
|
+
await CommandUtil.executeCommand(this.context, CommandType.ServeCommand, CommandStage.before, commandRender);
|
|
43
|
+
await hookExecutor.executeServeHooks(this.context, HookStage.before);
|
|
44
|
+
|
|
45
|
+
await CommandUtil.executeCommand(this.context, CommandType.ServeCommand, CommandStage.on, commandRender);
|
|
46
|
+
await hookExecutor.executeServeHooks(this.context);
|
|
47
|
+
|
|
48
|
+
await hookExecutor.executeServeHooks(this.context, HookStage.after);
|
|
49
|
+
await CommandUtil.executeCommand(this.context, CommandType.ServeCommand, CommandStage.after, commandRender);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { ServeManager } from './serve-manager';
|
|
3
|
+
import { CliContext, ContextUtils } from '@celljs/cli-common/lib/context/context-protocol';
|
|
4
|
+
|
|
5
|
+
export interface ServeOptions {
|
|
6
|
+
port?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default async (ctx: CliContext, options: ServeOptions) => {
|
|
10
|
+
try {
|
|
11
|
+
ctx.options = options;
|
|
12
|
+
ctx = ContextUtils.mergeContext(ctx, { dev: true, ...options });
|
|
13
|
+
await new ServeManager(ctx).start();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error(error);
|
|
16
|
+
process.exit(-1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
};
|