mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-04 21:19:27 +08:00
chore: auto-update package.json on upgrade (#6747)
* fix: update package.json * fix: deps
This commit is contained in:
parent
a494dacdaf
commit
174693e219
@ -13,11 +13,13 @@
|
||||
"@umijs/utils": "3.5.20",
|
||||
"chalk": "^4.1.1",
|
||||
"commander": "^9.2.0",
|
||||
"deepmerge": "^4.3.1",
|
||||
"dotenv": "^16.0.0",
|
||||
"execa": "^5.1.1",
|
||||
"fast-glob": "^3.3.1",
|
||||
"fs-extra": "^11.1.1",
|
||||
"p-all": "3.0.0",
|
||||
"pm2": "^6.0.5",
|
||||
"portfinder": "^1.0.28",
|
||||
"tar": "^7.4.3",
|
||||
"tree-kill": "^1.2.2",
|
||||
|
@ -12,6 +12,17 @@ const { Command } = require('commander');
|
||||
const { resolve } = require('path');
|
||||
const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode, checkDBDialect } = require('../util');
|
||||
const { existsSync, rmSync } = require('fs');
|
||||
const { readJSON, writeJSON } = require('fs-extra');
|
||||
const deepmerge = require('deepmerge');
|
||||
|
||||
async function updatePackage() {
|
||||
const sourcePath = resolve(__dirname, '../../templates/create-app-package.json');
|
||||
const descPath = resolve(process.cwd(), 'package.json');
|
||||
const sourceJson = await readJSON(sourcePath, 'utf8');
|
||||
const descJson = await readJSON(descPath, 'utf8');
|
||||
const json = deepmerge(descJson, sourceJson);
|
||||
await writeJSON(descPath, json, { spaces: 2, encoding: 'utf8' });
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@ -70,6 +81,7 @@ module.exports = (cli) => {
|
||||
return;
|
||||
}
|
||||
await run('yarn', ['add', `@nocobase/cli@${distTag}`, `@nocobase/devtools@${distTag}`, '-W']);
|
||||
await updatePackage();
|
||||
await run('yarn', ['install']);
|
||||
await downloadPro();
|
||||
await runAppCommand('upgrade');
|
||||
|
39
packages/core/cli/templates/create-app-package.json
Normal file
39
packages/core/cli/templates/create-app-package.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"private": true,
|
||||
"workspaces": ["packages/*/*", "packages/*/*/*"],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"nocobase": "nocobase",
|
||||
"pm": "nocobase pm",
|
||||
"pm2": "nocobase pm2",
|
||||
"dev": "nocobase dev",
|
||||
"start": "nocobase start",
|
||||
"clean": "nocobase clean",
|
||||
"build": "nocobase build",
|
||||
"test": "nocobase test",
|
||||
"e2e": "nocobase e2e",
|
||||
"tar": "nocobase tar",
|
||||
"postinstall": "nocobase postinstall",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"resolutions": {
|
||||
"cytoscape": "3.28.0",
|
||||
"@types/react": "18.3.18",
|
||||
"@types/react-dom": "^18.0.0",
|
||||
"react-router-dom": "6.28.1",
|
||||
"react-router": "6.28.1",
|
||||
"async": "^3.2.6",
|
||||
"antd": "5.12.8",
|
||||
"rollup": "4.24.0",
|
||||
"semver": "^7.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"pm2": "^6.0.5",
|
||||
"mysql2": "^3.14.0",
|
||||
"mariadb": "^3.4.1",
|
||||
"pg": "^8.14.1",
|
||||
"pg-hstore": "^2.3.4"
|
||||
}
|
||||
}
|
@ -165,21 +165,27 @@ class AppGenerator extends Generator {
|
||||
console.log(`Creating a new NocoBase application at ${chalk.green(name)}`);
|
||||
console.log('Creating files');
|
||||
|
||||
const context = this.getContext();
|
||||
|
||||
this.copyDirectory({
|
||||
context: this.getContext(),
|
||||
context,
|
||||
path: join(__dirname, '../templates/app'),
|
||||
target: this.cwd,
|
||||
});
|
||||
|
||||
this.checkDbEnv();
|
||||
const json = {
|
||||
name: context.name,
|
||||
...(await fs.readJSON(join(this.cwd, 'package.json'), 'utf8')),
|
||||
};
|
||||
|
||||
const skipDevDependencies = this.args.skipDevDependencies;
|
||||
if (skipDevDependencies) {
|
||||
const json = await fs.readJSON(join(this.cwd, 'package.json'), 'utf8');
|
||||
delete json['devDependencies'];
|
||||
await fs.writeJSON(join(this.cwd, 'package.json'), json, { encoding: 'utf8', spaces: 2 });
|
||||
json['dependencies']['@nocobase/cli'] = context.version;
|
||||
|
||||
if (!this.args.skipDevDependencies) {
|
||||
json['devDependencies'] = json['devDependencies'] || {};
|
||||
json['devDependencies']['@nocobase/devtools'] = context.version;
|
||||
}
|
||||
|
||||
await fs.writeJSON(join(this.cwd, 'package.json'), json, { encoding: 'utf8', spaces: 2 });
|
||||
console.log('');
|
||||
console.log(chalk.green(`$ cd ${name}`));
|
||||
console.log(chalk.green(`$ yarn install`));
|
||||
|
@ -1,5 +1,4 @@
|
||||
{
|
||||
"name": "{{{name}}}",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"packages/*/*",
|
||||
@ -34,11 +33,10 @@
|
||||
"semver": "^7.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nocobase/cli": "{{{version}}}",
|
||||
"pm2": "^6.0.5",
|
||||
{{{dependencies}}}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nocobase/devtools": "{{{version}}}"
|
||||
"mysql2": "^3.14.0",
|
||||
"mariadb": "^3.4.1",
|
||||
"pg": "^8.14.1",
|
||||
"pg-hstore": "^2.3.4"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user