From 219dbee467d00fae9c298569606ee40a84fe7cf3 Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Mon, 25 Apr 2022 22:05:05 +0800 Subject: [PATCH] fix: create-nocobase-app client package version (#321) * fix: create-nocobase-app client package version * chore: create-nocobase-app package name * feat: nocobase-prod script * chore: npm registry Co-authored-by: chenos --- README.zh-CN.md | 4 ++-- docker/nocobase/Dockerfile | 4 ++-- .../core/create-nocobase-app/src/create-app.js | 12 ++++++++++++ .../src/resources/files/tsconfig.jest.json | 4 +--- .../src/resources/files/tsconfig.json | 4 +--- .../resources/templates/client.package.json.js | 16 ++++++++++++++++ .../src/resources/templates/package.json.js | 1 + .../resources/templates/server.package.json.js | 2 +- 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 packages/core/create-nocobase-app/src/resources/templates/client.package.json.js diff --git a/README.zh-CN.md b/README.zh-CN.md index 65708f4484..b069f1e377 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -98,8 +98,8 @@ yarn create nocobase-app my-nocobase-app -d postgres \ # 2. 切换目录 cd my-nocobase-app -# 3. 安装依赖 -yarn install +# 3. 安装依赖(使用阿里云镜像) +yarn install --registry=https://registry.npmmirror.com # 4. 安装 NocoBase yarn nocobase install --lang=zh-CN diff --git a/docker/nocobase/Dockerfile b/docker/nocobase/Dockerfile index 40434394fb..05631f5431 100644 --- a/docker/nocobase/Dockerfile +++ b/docker/nocobase/Dockerfile @@ -4,8 +4,8 @@ WORKDIR /app # COPY . /app RUN ls -a -RUN npm config set registry https://registry.npm.taobao.org -RUN yarn config set registry https://registry.npm.taobao.org +RUN npm config set registry https://registry.npmmirror.com +RUN yarn config set registry https://registry.npmmirror.com # RUN npm install # RUN npm run bootstrap diff --git a/packages/core/create-nocobase-app/src/create-app.js b/packages/core/create-nocobase-app/src/create-app.js index 06160d9a5b..9bdfd36069 100644 --- a/packages/core/create-nocobase-app/src/create-app.js +++ b/packages/core/create-nocobase-app/src/create-app.js @@ -9,6 +9,7 @@ const { join, resolve } = require('path'); const createEnvFile = require('./resources/templates/env'); const createPackageJson = require('./resources/templates/package.json.js'); const createServerPackageJson = require('./resources/templates/server.package.json.js'); +const createClientPackageJson = require('./resources/templates/client.package.json.js'); const loadSrcFromNpm = require('./resources/templates/load-src-from-npm'); let envs = undefined; @@ -135,6 +136,17 @@ async function createApp(directory, options) { }, ); + // write client package.json + await fse.writeJson( + join(projectPath, 'packages/app/client/package.json'), + createClientPackageJson({ + projectPath, + }), + { + spaces: 2, + }, + ); + // run install command console.log('finished'); } diff --git a/packages/core/create-nocobase-app/src/resources/files/tsconfig.jest.json b/packages/core/create-nocobase-app/src/resources/files/tsconfig.jest.json index 99237bad7b..2c3d7497ed 100644 --- a/packages/core/create-nocobase-app/src/resources/files/tsconfig.jest.json +++ b/packages/core/create-nocobase-app/src/resources/files/tsconfig.jest.json @@ -8,9 +8,7 @@ "allowJs": true, "module": "commonjs", "target": "es6", - "paths": { - "@nocobase/*": ["./packages/*/src"] - } + "paths": {} }, "exclude": ["./packages/*/esm", "./packages/*/lib"] } \ No newline at end of file diff --git a/packages/core/create-nocobase-app/src/resources/files/tsconfig.json b/packages/core/create-nocobase-app/src/resources/files/tsconfig.json index ba93156204..2efe562740 100644 --- a/packages/core/create-nocobase-app/src/resources/files/tsconfig.json +++ b/packages/core/create-nocobase-app/src/resources/files/tsconfig.json @@ -16,8 +16,6 @@ "experimentalDecorators": true, "downlevelIteration": true, "baseUrl": ".", - "paths": { - "@nocobase/*": ["packages/*/src"] - } + "paths": {} } } \ No newline at end of file diff --git a/packages/core/create-nocobase-app/src/resources/templates/client.package.json.js b/packages/core/create-nocobase-app/src/resources/templates/client.package.json.js new file mode 100644 index 0000000000..4df9323fc9 --- /dev/null +++ b/packages/core/create-nocobase-app/src/resources/templates/client.package.json.js @@ -0,0 +1,16 @@ +const path = require('path'); + +module.exports = (opts) => { + const { projectPath } = opts; + const templateJsonPath = path.join(projectPath, 'packages/app/client/package.json'); + const templateJson = require(templateJsonPath); + + return { + ...templateJson, + name: 'app-client', + version: '0.1.0', + dependencies: { + ...templateJson.dependencies, + }, + }; +}; diff --git a/packages/core/create-nocobase-app/src/resources/templates/package.json.js b/packages/core/create-nocobase-app/src/resources/templates/package.json.js index dd49288d62..5f55cbb9fc 100644 --- a/packages/core/create-nocobase-app/src/resources/templates/package.json.js +++ b/packages/core/create-nocobase-app/src/resources/templates/package.json.js @@ -12,6 +12,7 @@ module.exports = (opts) => { clean: 'rimraf -rf packages/{app,plugins}/*/{lib,esm,dist} && lerna clean', nocobase: 'cross-env DOTENV_CONFIG_PATH=.env ts-node-dev -r dotenv/config -r tsconfig-paths/register ./packages/app/server/src/index.ts', + 'nocobase-prod': 'cross-env DOTENV_CONFIG_PATH=.env node -r dotenv/config packages/app/server/lib/index.js', 'start-client': 'cd packages/app/client && npm run start', 'start-server': 'npm run nocobase start', build: 'lerna run build', diff --git a/packages/core/create-nocobase-app/src/resources/templates/server.package.json.js b/packages/core/create-nocobase-app/src/resources/templates/server.package.json.js index bec66f0e9c..8255b286b2 100644 --- a/packages/core/create-nocobase-app/src/resources/templates/server.package.json.js +++ b/packages/core/create-nocobase-app/src/resources/templates/server.package.json.js @@ -27,7 +27,7 @@ module.exports = (opts) => { return { ...templateJson, - name: 'server', + name: 'app-server', version: '0.1.0', main: 'index.js', dependencies: {