From b65184ca377e0e0994e71224329fa8db468f1400 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 7 Apr 2021 19:36:09 +0800 Subject: [PATCH] fix: skip postinstall when umi does not exist --- packages/api/.env.example | 47 +++++++++++++++++++++++++++++++++++++++ packages/app/package.json | 2 +- packages/app/umi.js | 22 ++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 packages/api/.env.example create mode 100644 packages/app/umi.js diff --git a/packages/api/.env.example b/packages/api/.env.example new file mode 100644 index 000000000..3479d5cc4 --- /dev/null +++ b/packages/api/.env.example @@ -0,0 +1,47 @@ +########## DOCKER COMPOSE ENV ########## + +DB_MYSQL_PORT=3306 +DB_POSTGRES_PORT=5432 +API_PORT=23000 +VERDACCIO_PORT=4873 + +########## NOCOBASE ENV ########## + +# DATABASE + +DB_DIALECT=postgres +DB_HOST=localhost +DB_PORT=5432 +DB_DATABASE=nocobase +DB_USER=nocobase +DB_PASSWORD=nocobase +# set to 'on' to enable log +DB_LOG_SQL= + +# API & APP + +NOCOBASE_ENV= +API_PORT=23000 +APP_USE_STATIC_SERVER=true +APP_DIST=packages/app/dist + +# ADMIN USER (Initialization only) + +ADMIN_EMAIL=admin@nocobase.com +ADMIN_PASSWORD=admin + +# STORAGE (Initialization only) + +# local or ali-oss +STORAGE_TYPE=local + +# LOCAL STORAGE +LOCAL_STORAGE_USE_STATIC_SERVER=true +LOCAL_STORAGE_BASE_URL=http://localhost:23000 + +# ALI OSS STORAGE +ALI_OSS_STORAGE_BASE_URL= +ALI_OSS_REGION=oss-cn-beijing +ALI_OSS_ACCESS_KEY_ID= +ALI_OSS_ACCESS_KEY_SECRET= +ALI_OSS_BUCKET= diff --git a/packages/app/package.json b/packages/app/package.json index 3d60343c7..a39c28abe 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -5,7 +5,7 @@ "start": "concurrently \"cd ../../ && nodemon\" \"umi dev\"", "dev": "umi dev", "build": "umi build", - "postinstall": "umi generate tmp", + "postinstall": "node ./umi.js generate tmp", "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'", "test": "umi-test", "test:coverage": "umi-test --coverage" diff --git a/packages/app/umi.js b/packages/app/umi.js new file mode 100644 index 000000000..8a37a191b --- /dev/null +++ b/packages/app/umi.js @@ -0,0 +1,22 @@ +#!/usr/bin/env node + +try { + require.resolve('umi'); + + require('v8-compile-cache'); + + const resolveCwd = require('@umijs/deps/compiled/resolve-cwd'); + + const { name, bin } = require('umi/package.json'); + const localCLI = resolveCwd.silent(`${name}/${bin['umi']}`); + if (!process.env.USE_GLOBAL_UMI && localCLI && localCLI !== __filename) { + const debug = require('@umijs/utils').createDebug('umi:cli'); + debug('Using local install of umi'); + require(localCLI); + } else { + require('umi/lib/cli'); + } + +} catch (error) { + console.log('done') +}