@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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const cp = require('child_process');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
checkPublish().catch(error => {
|
|
9
|
+
console.error(error);
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
async function checkPublish() {
|
|
14
|
+
const workspaces = JSON.parse(cp.execSync('yarn --silent workspaces info').toString());
|
|
15
|
+
await Promise.all(Object.values(workspaces).map(async workspace => {
|
|
16
|
+
const packagePath = path.resolve(workspace.location, 'package.json');
|
|
17
|
+
const pck = JSON.parse(await fs.promises.readFile(packagePath, 'utf8'));
|
|
18
|
+
if (!pck.private) {
|
|
19
|
+
const pckName = `${pck.name}@${pck.version}`;
|
|
20
|
+
const npmViewOutput = await new Promise(
|
|
21
|
+
resolve => cp.exec(`npm view ${pckName} version --json`,
|
|
22
|
+
(error, stdout, stderr) => {
|
|
23
|
+
if (error) {
|
|
24
|
+
console.error(error);
|
|
25
|
+
resolve('');
|
|
26
|
+
} else {
|
|
27
|
+
resolve(stdout.trim());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
if (npmViewOutput) {
|
|
33
|
+
console.info(`${pckName}: published`);
|
|
34
|
+
} else {
|
|
35
|
+
console.error(`(${chalk.red('ERR')}) ${pckName}: ${chalk.red('NOT')} published`);
|
|
36
|
+
process.exitCode = 1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
'use-strict';
|
|
3
|
+
|
|
4
|
+
const cp = require('child_process');
|
|
5
|
+
const path = require('path').posix;
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
const ROOT = path.join(__dirname, '..');
|
|
9
|
+
|
|
10
|
+
const DRY_RUN = popFlag(process.argv, '--dry-run');
|
|
11
|
+
|
|
12
|
+
const FORCE_REWRITE = popFlag(process.argv, '--force-rewrite') && !DRY_RUN;
|
|
13
|
+
|
|
14
|
+
/** @type {{ [packageName: string]: YarnWorkspace }} */
|
|
15
|
+
const YARN_WORKSPACES = JSON.parse(cp.execSync('yarn --silent workspaces info').toString());
|
|
16
|
+
|
|
17
|
+
// Add the package name inside each package object.
|
|
18
|
+
for (const [packageName, yarnWorkspace] of Object.entries(YARN_WORKSPACES)) {
|
|
19
|
+
yarnWorkspace.name = packageName;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** @type {YarnWorkspace} */
|
|
23
|
+
const MONOREPO = {
|
|
24
|
+
name: 'monorepo',
|
|
25
|
+
workspaceDependencies: Object.keys(YARN_WORKSPACES),
|
|
26
|
+
location: ROOT,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
let rewriteRequired = false;
|
|
31
|
+
let result = false;
|
|
32
|
+
|
|
33
|
+
// Configure all `compile.tsconfig.json` files of this monorepo
|
|
34
|
+
for (const packageName of Object.keys(YARN_WORKSPACES)) {
|
|
35
|
+
const workspacePackage = YARN_WORKSPACES[packageName];
|
|
36
|
+
const tsconfigCompilePath = path.join(ROOT, workspacePackage.location, 'compile.tsconfig.json');
|
|
37
|
+
const references = getTypescriptReferences(workspacePackage);
|
|
38
|
+
result = configureTypeScriptCompilation(workspacePackage, tsconfigCompilePath, references);
|
|
39
|
+
rewriteRequired = rewriteRequired || result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Configure our root compilation configuration, living inside `configs/root-compilation.tsconfig.json`.
|
|
43
|
+
const configsFolder = path.join(ROOT, 'configs');
|
|
44
|
+
const tsconfigCompilePath = path.join(configsFolder, 'root-compilation.tsconfig.json');
|
|
45
|
+
const references = getTypescriptReferences(MONOREPO, configsFolder);
|
|
46
|
+
result = configureTypeScriptCompilation(MONOREPO, tsconfigCompilePath, references);
|
|
47
|
+
rewriteRequired = rewriteRequired || result;
|
|
48
|
+
|
|
49
|
+
// Configure the root `tsconfig.json` for code navigation using `tsserver`.
|
|
50
|
+
const tsconfigNavPath = path.join(ROOT, 'tsconfig.json');
|
|
51
|
+
result = configureTypeScriptNavigation(MONOREPO, tsconfigNavPath);
|
|
52
|
+
rewriteRequired = rewriteRequired || result;
|
|
53
|
+
|
|
54
|
+
// CI will be able to tell if references got changed by looking at the exit code.
|
|
55
|
+
if (rewriteRequired) {
|
|
56
|
+
if (DRY_RUN) {
|
|
57
|
+
// Running a dry run usually only happens when a developer or CI runs the tests, so we only print the help then.
|
|
58
|
+
console.error('TypeScript references seem to be out of sync, run "yarn prepare:references" to fix.');
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
} else {
|
|
61
|
+
console.warn('TypeScript references were out of sync and got updated.');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error(error);
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @param {YarnWorkspace} requestedPackage
|
|
72
|
+
* @param {string} [overrideLocation] affects how relative paths are computed.
|
|
73
|
+
* @returns {string[]} project references for `requestedPackage`.
|
|
74
|
+
*/
|
|
75
|
+
function getTypescriptReferences(requestedPackage, overrideLocation) {
|
|
76
|
+
const references = [];
|
|
77
|
+
for (const dependency of requestedPackage.workspaceDependencies || []) {
|
|
78
|
+
const depWorkspace = YARN_WORKSPACES[dependency];
|
|
79
|
+
const depConfig = path.join(depWorkspace.location, 'compile.tsconfig.json');
|
|
80
|
+
if (!fs.existsSync(depConfig)) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const relativePath = path.relative(overrideLocation || requestedPackage.location, depWorkspace.location);
|
|
84
|
+
references.push(relativePath);
|
|
85
|
+
}
|
|
86
|
+
return references;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Wires a given compilation tsconfig file according to the provided references.
|
|
91
|
+
* This allows TypeScript to operate in build mode.
|
|
92
|
+
*
|
|
93
|
+
* @param {YarnWorkspace} targetPackage for debug purpose.
|
|
94
|
+
* @param {string} tsconfigPath path to the tsconfig file to edit.
|
|
95
|
+
* @param {string[]} references list of paths to the related project roots.
|
|
96
|
+
* @returns {boolean} rewrite was needed.
|
|
97
|
+
*/
|
|
98
|
+
function configureTypeScriptCompilation(targetPackage, tsconfigPath, references) {
|
|
99
|
+
if (!fs.existsSync(tsconfigPath)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const tsconfigJson = readJsonFile(tsconfigPath);
|
|
103
|
+
|
|
104
|
+
let needRewrite = FORCE_REWRITE;
|
|
105
|
+
|
|
106
|
+
if (!tsconfigJson.compilerOptions) {
|
|
107
|
+
// Somehow no `compilerOptions` literal is defined.
|
|
108
|
+
tsconfigJson.compilerOptions = {
|
|
109
|
+
composite: true,
|
|
110
|
+
rootDir: 'src',
|
|
111
|
+
outDir: 'lib',
|
|
112
|
+
};
|
|
113
|
+
needRewrite = true;
|
|
114
|
+
|
|
115
|
+
} else if (!tsconfigJson.compilerOptions.composite) {
|
|
116
|
+
// `compilerOptions` is missing the `composite` literal.
|
|
117
|
+
tsconfigJson.compilerOptions = {
|
|
118
|
+
composite: true,
|
|
119
|
+
...tsconfigJson.compilerOptions,
|
|
120
|
+
};
|
|
121
|
+
needRewrite = true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** @type {string[]} */
|
|
125
|
+
const tsconfigReferences = references
|
|
126
|
+
.map(reference => path.join(reference, 'compile.tsconfig.json'));
|
|
127
|
+
|
|
128
|
+
/** @type {string[]} */
|
|
129
|
+
const currentReferences = (tsconfigJson['references'] || [])
|
|
130
|
+
// We will work on a set of paths, easier to handle than objects.
|
|
131
|
+
.map(reference => reference.path)
|
|
132
|
+
// Remove any invalid reference (maybe outdated).
|
|
133
|
+
.filter((referenceRelativePath, index, self) => {
|
|
134
|
+
if (!tsconfigReferences.includes(referenceRelativePath)) {
|
|
135
|
+
// Found a reference that wasn't automatically computed, will remove.
|
|
136
|
+
console.warn(`error: ${targetPackage.name} untracked reference: ${referenceRelativePath}`);
|
|
137
|
+
needRewrite = true;
|
|
138
|
+
return false; // remove
|
|
139
|
+
}
|
|
140
|
+
if (self.indexOf(referenceRelativePath) !== index) {
|
|
141
|
+
// Remove duplicates.
|
|
142
|
+
console.error(`error: ${targetPackage.name} duplicate reference: ${referenceRelativePath}`);
|
|
143
|
+
needRewrite = true;
|
|
144
|
+
return false; // remove
|
|
145
|
+
}
|
|
146
|
+
const referencePath = path.join(path.dirname(tsconfigPath), referenceRelativePath);
|
|
147
|
+
try {
|
|
148
|
+
const referenceStat = fs.statSync(referencePath);
|
|
149
|
+
if (referenceStat.isDirectory() && fs.statSync(path.join(referencePath, 'tsconfig.json')).isFile()) {
|
|
150
|
+
return true; // keep
|
|
151
|
+
} else if (referenceStat.isFile()) { // still could be something else than a tsconfig, but good enough.
|
|
152
|
+
return true; // keep
|
|
153
|
+
}
|
|
154
|
+
} catch {
|
|
155
|
+
// passthrough
|
|
156
|
+
}
|
|
157
|
+
console.error(`error: ${targetPackage.name} invalid reference: ${referenceRelativePath}`);
|
|
158
|
+
needRewrite = true;
|
|
159
|
+
return false; // remove
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
for (const tsconfigReference of tsconfigReferences) {
|
|
163
|
+
if (!currentReferences.includes(tsconfigReference)) {
|
|
164
|
+
console.error(`error: ${targetPackage.name} missing reference: ${tsconfigReference}`);
|
|
165
|
+
currentReferences.push(tsconfigReference);
|
|
166
|
+
needRewrite = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!DRY_RUN && needRewrite) {
|
|
170
|
+
tsconfigJson.references = currentReferences.map(path => ({ path }));
|
|
171
|
+
const content = JSON.stringify(tsconfigJson, undefined, 2);
|
|
172
|
+
fs.writeFileSync(tsconfigPath, content + '\n');
|
|
173
|
+
console.warn(`info: ${tsconfigPath} updated.`);
|
|
174
|
+
}
|
|
175
|
+
return needRewrite;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Wire the root `tsconfig.json` to map scoped import to real location in the monorepo.
|
|
180
|
+
* This setup is a shim for the TypeScript language server to provide cross-package navigation.
|
|
181
|
+
* Compilation is done via `compile.tsconfig.json` files.
|
|
182
|
+
*
|
|
183
|
+
* @param {YarnWorkspace} targetPackage for debug purpose.
|
|
184
|
+
* @param {string} tsconfigPath
|
|
185
|
+
* @returns {boolean} rewrite was needed.
|
|
186
|
+
*/
|
|
187
|
+
function configureTypeScriptNavigation(targetPackage, tsconfigPath) {
|
|
188
|
+
const tsconfigJson = readJsonFile(tsconfigPath);
|
|
189
|
+
|
|
190
|
+
let needRewrite = FORCE_REWRITE;
|
|
191
|
+
|
|
192
|
+
if (typeof tsconfigJson.compilerOptions === 'undefined') {
|
|
193
|
+
// Somehow no `compilerOptions` literal is defined.
|
|
194
|
+
tsconfigJson.compilerOptions = {
|
|
195
|
+
baseUrl: '.',
|
|
196
|
+
paths: {},
|
|
197
|
+
};
|
|
198
|
+
needRewrite = true;
|
|
199
|
+
|
|
200
|
+
} else if (typeof tsconfigJson.compilerOptions.paths === 'undefined') {
|
|
201
|
+
// `compilerOptions` is missing the `paths` literal.
|
|
202
|
+
tsconfigJson.compilerOptions = {
|
|
203
|
+
...tsconfigJson.compilerOptions,
|
|
204
|
+
paths: {},
|
|
205
|
+
};
|
|
206
|
+
needRewrite = true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** @type {{ [prefix: string]: string[] }} */
|
|
210
|
+
const currentPaths = tsconfigJson.compilerOptions.paths;
|
|
211
|
+
|
|
212
|
+
for (const packageName of MONOREPO.workspaceDependencies) {
|
|
213
|
+
const depWorkspace = YARN_WORKSPACES[packageName];
|
|
214
|
+
|
|
215
|
+
/** @type {string} */
|
|
216
|
+
let originalImportPath;
|
|
217
|
+
/** @type {string} */
|
|
218
|
+
let mappedFsPath;
|
|
219
|
+
|
|
220
|
+
const depSrcPath = path.join(depWorkspace.location, 'src');
|
|
221
|
+
const depConfigPath = path.join(depWorkspace.location, 'compile.tsconfig.json');
|
|
222
|
+
|
|
223
|
+
if (fs.existsSync(depConfigPath) && fs.existsSync(depSrcPath)) {
|
|
224
|
+
// If it is a TypeScript dependency, map `lib` imports to our local sources in `src`.
|
|
225
|
+
const depConfigJson = readJsonFile(depConfigPath);
|
|
226
|
+
originalImportPath = `${packageName}/${depConfigJson.compilerOptions.outDir}/*`;
|
|
227
|
+
mappedFsPath = path.relative(MONOREPO.location, path.join(depSrcPath, '*'));
|
|
228
|
+
|
|
229
|
+
} else {
|
|
230
|
+
// I don't really know what to do here, simply point to our local package root.
|
|
231
|
+
originalImportPath = `${packageName}/*`;
|
|
232
|
+
mappedFsPath = path.relative(MONOREPO.location, path.join(depWorkspace.location, '*'));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** @type {string[] | undefined} */
|
|
236
|
+
const currentFsPaths = currentPaths[originalImportPath];
|
|
237
|
+
|
|
238
|
+
if (typeof currentFsPaths === 'undefined' || currentFsPaths.length !== 1 || currentFsPaths[0] !== mappedFsPath) {
|
|
239
|
+
console.error(`error: ${targetPackage.name} invalid mapped path: {"${originalImportPath}": "${currentFsPaths}"}`);
|
|
240
|
+
currentPaths[originalImportPath] = [mappedFsPath];
|
|
241
|
+
needRewrite = true;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!DRY_RUN && needRewrite) {
|
|
245
|
+
const content = JSON.stringify(tsconfigJson, undefined, 2);
|
|
246
|
+
fs.writeFileSync(tsconfigPath, content + '\n');
|
|
247
|
+
console.warn(`info: ${tsconfigPath} updated.`);
|
|
248
|
+
}
|
|
249
|
+
return needRewrite;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
*
|
|
254
|
+
* @param {string[]} argv
|
|
255
|
+
* @param {string} flag
|
|
256
|
+
* @returns {boolean}
|
|
257
|
+
*/
|
|
258
|
+
function popFlag(argv, flag) {
|
|
259
|
+
const flagIndex = argv.indexOf(flag)
|
|
260
|
+
if (flagIndex !== -1) {
|
|
261
|
+
argv.splice(flagIndex, 1);
|
|
262
|
+
return true;
|
|
263
|
+
} else {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @param {string} filePath
|
|
270
|
+
* @returns {any}
|
|
271
|
+
*/
|
|
272
|
+
function readJsonFile(filePath) {
|
|
273
|
+
try {
|
|
274
|
+
return JSON.parse(fs.readFileSync(filePath).toString());
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error('ParseError in file:', filePath);
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @typedef YarnWorkspace
|
|
283
|
+
* @property {string} name
|
|
284
|
+
* @property {string} location
|
|
285
|
+
* @property {string[]} workspaceDependencies
|
|
286
|
+
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@celljs/component/configs/base.tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"noEmit": true,
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@app/core/lib/*": [
|
|
9
|
+
"packages/core/src/*"
|
|
10
|
+
],
|
|
11
|
+
"@app/app-sample-app/*": [
|
|
12
|
+
"apps/sample-app/*"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": [
|
|
17
|
+
"packages/*/src",
|
|
18
|
+
"apps/*/test"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "pwa-node",
|
|
6
|
+
"request": "launch",
|
|
7
|
+
"name": "mycli init",
|
|
8
|
+
"program": "${workspaceRoot}/bin/mycli-init",
|
|
9
|
+
"cwd": "${workspaceFolder}",
|
|
10
|
+
"sourceMaps": true,
|
|
11
|
+
"env": {
|
|
12
|
+
"NODE_ENV": "development"
|
|
13
|
+
},
|
|
14
|
+
"smartStep": true,
|
|
15
|
+
"internalConsoleOptions": "openOnSessionStart",
|
|
16
|
+
"outputCapture": "std"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "pwa-node",
|
|
20
|
+
"request": "launch",
|
|
21
|
+
"name": "mycli deploy",
|
|
22
|
+
"program": "${workspaceRoot}/bin/mycli-deploy",
|
|
23
|
+
"cwd": "${workspaceFolder}",
|
|
24
|
+
"sourceMaps": true,
|
|
25
|
+
"env": {
|
|
26
|
+
"NODE_ENV": "development"
|
|
27
|
+
},
|
|
28
|
+
"smartStep": true,
|
|
29
|
+
"internalConsoleOptions": "openOnSessionStart",
|
|
30
|
+
"outputCapture": "std"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mycli",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"files": [
|
|
6
|
+
"lib",
|
|
7
|
+
"bin",
|
|
8
|
+
"src",
|
|
9
|
+
"templates"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"mycli": "./bin/mycli"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@celljs/core": "{{ version }}",
|
|
16
|
+
"chalk": "^4.1.0",
|
|
17
|
+
"commander": "^4.0.1",
|
|
18
|
+
"fs-extra": "^11.1.1",
|
|
19
|
+
"prompts": "^2.4.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@celljs/cli": "{{ version }}",
|
|
23
|
+
"@types/fs-extra": "^11.0.1",
|
|
24
|
+
"rimraf": "^5.0.2",
|
|
25
|
+
"typescript": "~4.5.5"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepare": "yarn run clean & yarn run build",
|
|
29
|
+
"clean": "rimraf lib",
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"watch": "tsc -w"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ApplicationFactory } from '@celljs/core/lib/common/application/application-factory';
|
|
2
|
+
import { MycliModule } from './module';
|
|
3
|
+
|
|
4
|
+
export async function bootstrap() {
|
|
5
|
+
const app = await ApplicationFactory.create({}, MycliModule); // 根据应用属性配置和相关的应用模块创建应用
|
|
6
|
+
await app.start(); // 启动应用
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CONTEXT = 'CONTEXT';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import { bootstrap } from '../bootstrap';
|
|
3
|
+
import { ContainerUtil } from '@celljs/core';
|
|
4
|
+
import * as program from 'commander';
|
|
5
|
+
import { DeployManager } from './deploy-manager';
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.name('cell deploy')
|
|
9
|
+
.description('init a application')
|
|
10
|
+
.parse(process.argv);
|
|
11
|
+
|
|
12
|
+
(async () => {
|
|
13
|
+
await bootstrap();
|
|
14
|
+
const deployManager = ContainerUtil.get<DeployManager>(DeployManager);
|
|
15
|
+
await deployManager.deploy();
|
|
16
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './deploy-manager';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './init-manager';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { existsSync, copy } from 'fs-extra';
|
|
3
|
+
import { prompts } from 'prompts';
|
|
4
|
+
import { templates } from './templates';
|
|
5
|
+
import { Component, Autowired } from '@celljs/core';
|
|
6
|
+
import { CONTEXT } from '../constants';
|
|
7
|
+
import * as chalk from 'chalk';
|
|
8
|
+
|
|
9
|
+
const PLACEHOLD = '{{ templatePath }}';
|
|
10
|
+
|
|
11
|
+
export interface Template {
|
|
12
|
+
name: string;
|
|
13
|
+
location: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Component()
|
|
17
|
+
export class InitManager {
|
|
18
|
+
|
|
19
|
+
protected name: string;
|
|
20
|
+
protected location: string;
|
|
21
|
+
|
|
22
|
+
@Autowired(CONTEXT)
|
|
23
|
+
protected context: any;
|
|
24
|
+
|
|
25
|
+
async output(): Promise<void> {
|
|
26
|
+
await this.selectTemplate();
|
|
27
|
+
await this.checkOutputDir();
|
|
28
|
+
await this.doOutput();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected get outputDir(): string {
|
|
32
|
+
return resolve(process.cwd(), this.context.outputDir, this.context.name);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async checkOutputDir() {
|
|
36
|
+
if (existsSync(this.outputDir)) {
|
|
37
|
+
await prompts.confirm({
|
|
38
|
+
name: 'overwrite',
|
|
39
|
+
type: 'confirm',
|
|
40
|
+
message: 'Project already exists, overwrite the project',
|
|
41
|
+
onState: ({ value }) => {
|
|
42
|
+
if (value !== true) {
|
|
43
|
+
process.exit(-1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected toTemplateMap(name: string, location: string) {
|
|
52
|
+
return { title: name, value: { location, name} };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected async selectTemplate(): Promise<void> {
|
|
56
|
+
const templateMap = Object.keys(templates).map(key => this.toTemplateMap(key, templates[key]));
|
|
57
|
+
let answers;
|
|
58
|
+
if (templateMap.length == 1) {
|
|
59
|
+
answers = { item: templateMap[0].value };
|
|
60
|
+
} else {
|
|
61
|
+
answers = await prompts.autocomplete({
|
|
62
|
+
name: 'item',
|
|
63
|
+
type: 'autocomplete',
|
|
64
|
+
message: 'Select a template to init',
|
|
65
|
+
choices: templateMap,
|
|
66
|
+
suggest: async input => {
|
|
67
|
+
return templateMap.filter(item => !input || item.title.toLowerCase().includes(input.toLowerCase()));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.name = answers.name;
|
|
73
|
+
this.context.name = this.context.name || answers.name;
|
|
74
|
+
this.location = answers.location;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected get realLocation() {
|
|
78
|
+
return this.location.replace(PLACEHOLD, resolve(__dirname, '..', '..', 'templates'));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
protected async doOutput() {
|
|
82
|
+
await copy(this.realLocation, this.outputDir);
|
|
83
|
+
console.log(chalk`{bold.green Success!}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { bootstrap } from '../bootstrap';
|
|
2
|
+
import * as program from 'commander';
|
|
3
|
+
import { InitManager } from './init-manager';
|
|
4
|
+
import { CONTEXT } from '../constants';
|
|
5
|
+
import { ContainerProvider } from '@celljs/core';
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.name('cell init')
|
|
9
|
+
.usage('[options] [name]')
|
|
10
|
+
.option('-o, --output-dir [path]', 'output directory', '.')
|
|
11
|
+
.description('init a application')
|
|
12
|
+
.parse(process.argv);
|
|
13
|
+
|
|
14
|
+
(async () => {
|
|
15
|
+
await bootstrap();
|
|
16
|
+
let name = undefined;
|
|
17
|
+
if (program.args.length > 0) {
|
|
18
|
+
name = program.args[0];
|
|
19
|
+
}
|
|
20
|
+
const outputDir = program.outputDir;
|
|
21
|
+
const container = await ContainerProvider.asyncProvide();
|
|
22
|
+
container.bind(CONTEXT).toConstantValue({ name, outputDir, program })
|
|
23
|
+
const initManager = container.get(InitManager);
|
|
24
|
+
await initManager.output();
|
|
25
|
+
})();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as program from 'commander';
|
|
2
|
+
import { bootstrap } from './bootstrap';
|
|
3
|
+
const pkg = require('../package.json');
|
|
4
|
+
|
|
5
|
+
(async () => {
|
|
6
|
+
await bootstrap();
|
|
7
|
+
program
|
|
8
|
+
.version(pkg.version)
|
|
9
|
+
.command('init [name]', 'init a fc application')
|
|
10
|
+
.command('deploy [options]', 'deply a fc application')
|
|
11
|
+
.parse(process.argv);
|
|
12
|
+
|
|
13
|
+
})();
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"skipLibCheck": true,
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"noImplicitAny": true,
|
|
7
|
+
"noEmitOnError": false,
|
|
8
|
+
"noImplicitThis": true,
|
|
9
|
+
"noUnusedLocals": true,
|
|
10
|
+
"strictNullChecks": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"emitDecoratorMetadata": true,
|
|
13
|
+
"downlevelIteration": true,
|
|
14
|
+
"module": "commonjs",
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"jsx": "react",
|
|
17
|
+
"target": "ES2017",
|
|
18
|
+
"lib": [
|
|
19
|
+
"ES2017",
|
|
20
|
+
"dom"
|
|
21
|
+
],
|
|
22
|
+
"sourceMap": true,
|
|
23
|
+
"rootDir": "src",
|
|
24
|
+
"outDir": "lib"
|
|
25
|
+
},
|
|
26
|
+
"include": [
|
|
27
|
+
"src"
|
|
28
|
+
]
|
|
29
|
+
}
|