chore(deps): upgrade dependencies (#6708)

* chore: upgrade jsonwebtoken to version 9.0.2

* chore: update

* fix: deps

* fix: semver

* chore: dicer

* chore: upgrade multer

* fix: dicer

* fix: remove sqlite

* chore: check db dialect

* chore: remove sqlite3

* fix: yarn add sqlite3 --no-save -W

* fix: test

* fix: test

* fix: ci

* fix: test

* fix: deps
This commit is contained in:
chenos 2025-04-21 18:52:26 +08:00 committed by GitHub
parent 73956a834d
commit 120aa3420c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 83 additions and 72 deletions

View File

@ -61,7 +61,9 @@ jobs:
node-version: ${{ matrix.node_version }}
cache: 'yarn'
- name: Install project dependencies
run: yarn install
run: |
yarn install
yarn add sqlite3 --no-save -W
- name: Test with Sqlite
run: yarn test --server --single-thread=false
env:

View File

@ -63,7 +63,9 @@ jobs:
${{ runner.os }}-yarn-
- name: Install project dependencies
run: yarn --prefer-offline
run: |
yarn --prefer-offline
yarn add sqlite3 --no-save -W
- name: Test with Sqlite
run: yarn test --server --single-thread=false

View File

@ -8,7 +8,11 @@ RUN cd /app \
&& yarn config set network-timeout 600000 -g \
&& npx -y create-nocobase-app@${CNA_VERSION} my-nocobase-app --skip-dev-dependencies -a -e APP_ENV=production \
&& cd /app/my-nocobase-app \
&& yarn install --production
&& yarn install --production \
&& rm -rf yarn.lock \
&& find node_modules -type f -name "yarn.lock" -delete \
&& find node_modules -type f -name "bower.json" -delete \
&& find node_modules -type f -name "composer.json" -delete
RUN cd /app \
&& rm -rf nocobase.tar.gz \

View File

@ -11,8 +11,8 @@
"@nocobase/database": "1.6.21",
"@nocobase/resourcer": "1.6.21",
"@nocobase/utils": "1.6.21",
"@types/jsonwebtoken": "^8.5.8",
"jsonwebtoken": "^8.5.1"
"@types/jsonwebtoken": "^9.0.9",
"jsonwebtoken": "^9.0.2"
},
"repository": {
"type": "git",

View File

@ -8,7 +8,7 @@
*/
const _ = require('lodash');
const { Command } = require('commander');
const { generatePlugins, run, postCheck, nodeCheck, promptForTs, isPortReachable } = require('../util');
const { generatePlugins, run, postCheck, nodeCheck, promptForTs, isPortReachable, checkDBDialect } = require('../util');
const { getPortPromise } = require('portfinder');
const chokidar = require('chokidar');
const { uid } = require('@formily/shared');
@ -36,6 +36,7 @@ module.exports = (cli) => {
.option('-i, --inspect [port]')
.allowUnknownOption()
.action(async (opts) => {
checkDBDialect();
let subprocess;
const runDevClient = () => {
console.log('starting client', 1 * clientPort);

View File

@ -8,7 +8,7 @@
*/
const { Command } = require('commander');
const { run, isPortReachable } = require('../util');
const { run, isPortReachable, checkDBDialect } = require('../util');
const { execSync } = require('node:child_process');
const axios = require('axios');
const { pTest } = require('./p-test');
@ -165,6 +165,7 @@ const filterArgv = () => {
*/
module.exports = (cli) => {
const e2e = cli.command('e2e').hook('preAction', () => {
checkDBDialect();
if (process.env.APP_BASE_URL) {
process.env.APP_BASE_URL = process.env.APP_BASE_URL.replace('localhost', '127.0.0.1');
console.log('APP_BASE_URL:', process.env.APP_BASE_URL);

View File

@ -8,7 +8,7 @@
*/
const { Command } = require('commander');
const { run, isDev, isProd, promptForTs, downloadPro } = require('../util');
const { run, isDev, isProd, promptForTs, downloadPro, checkDBDialect } = require('../util');
/**
*
@ -21,6 +21,7 @@ module.exports = (cli) => {
.option('-h, --help')
.option('--ts-node-dev')
.action(async (options) => {
checkDBDialect();
const cmd = process.argv.slice(2)?.[0];
if (cmd === 'install') {
await downloadPro();

View File

@ -8,7 +8,7 @@
*/
const _ = require('lodash');
const { Command } = require('commander');
const { run, postCheck, downloadPro, promptForTs } = require('../util');
const { run, postCheck, downloadPro, promptForTs, checkDBDialect } = require('../util');
const { existsSync, rmSync } = require('fs');
const { resolve, isAbsolute } = require('path');
const chalk = require('chalk');
@ -50,6 +50,7 @@ module.exports = (cli) => {
.option('--quickstart')
.allowUnknownOption()
.action(async (opts) => {
checkDBDialect();
if (opts.quickstart) {
await downloadPro();
}

View File

@ -7,7 +7,7 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
const { run } = require('../util');
const { run, checkDBDialect } = require('../util');
const fg = require('fast-glob');
const coreClientPackages = ['packages/core/client', 'packages/core/sdk'];
@ -30,6 +30,7 @@ const getPackagesDir = (isClient) => {
module.exports = (cli) => {
cli.command('test-coverage:server').action(async () => {
checkDBDialect();
const packageRoots = getPackagesDir(false);
for (const dir of packageRoots) {
try {
@ -41,6 +42,7 @@ module.exports = (cli) => {
});
cli.command('test-coverage:client').action(async () => {
checkDBDialect();
const packageRoots = getPackagesDir(true);
for (const dir of packageRoots) {
try {

View File

@ -8,7 +8,7 @@
*/
const { Command } = require('commander');
const { run } = require('../util');
const { run, checkDBDialect } = require('../util');
const path = require('path');
/**
@ -29,6 +29,7 @@ function addTestCommand(name, cli) {
.arguments('[paths...]')
.allowUnknownOption()
.action(async (paths, opts) => {
checkDBDialect();
if (name === 'test:server') {
process.env.TEST_ENV = 'server-side';
} else if (name === 'test:client') {

View File

@ -10,7 +10,7 @@
const chalk = require('chalk');
const { Command } = require('commander');
const { resolve } = require('path');
const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode } = require('../util');
const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode, checkDBDialect } = require('../util');
const { existsSync, rmSync } = require('fs');
/**
@ -26,6 +26,7 @@ module.exports = (cli) => {
.option('--next')
.option('-S|--skip-code-update')
.action(async (options) => {
checkDBDialect();
if (hasTsNode()) promptForTs();
if (hasCorePackages()) {
// await run('yarn', ['install']);

View File

@ -360,7 +360,7 @@ exports.initEnv = function initEnv() {
API_BASE_PATH: '/api/',
API_CLIENT_STORAGE_PREFIX: 'NOCOBASE_',
API_CLIENT_STORAGE_TYPE: 'localStorage',
DB_DIALECT: 'sqlite',
// DB_DIALECT: 'sqlite',
DB_STORAGE: 'storage/db/nocobase.sqlite',
// DB_TIMEZONE: '+00:00',
DB_UNDERSCORED: parseEnv('DB_UNDERSCORED'),
@ -472,6 +472,12 @@ exports.initEnv = function initEnv() {
}
};
exports.checkDBDialect = function () {
if (!process.env.DB_DIALECT) {
throw new Error('DB_DIALECT is required.');
}
};
exports.generatePlugins = function () {
try {
require.resolve('@nocobase/devtools/umiConfig');

View File

@ -21,7 +21,7 @@ cli
.option('--quickstart', 'quickstart app creation')
.option('--skip-dev-dependencies')
.option('-a, --all-db-dialect', 'install all database dialect dependencies')
.option('-d, --db-dialect <dbDialect>', 'database dialect, current support sqlite/mysql/postgres', 'sqlite')
.option('-d, --db-dialect <dbDialect>', 'database dialect, current support mysql/postgres', 'postgres')
.option('-e, --env <env>', 'environment variables write into .env file', concat, [])
.description('create a new application')
.action(async (name, options) => {

View File

@ -61,7 +61,7 @@ class AppGenerator extends Generator {
checkDialect() {
const dialect = this.args.dbDialect;
const supportDialects = ['mysql', 'mariadb', 'sqlite', 'postgres'];
const supportDialects = ['mysql', 'mariadb', 'postgres'];
if (!supportDialects.includes(dialect)) {
console.log(
`dialect ${chalk.red(dialect)} is not supported, currently supported dialects are ${chalk.green(
@ -76,27 +76,15 @@ class AppGenerator extends Generator {
const env = this.env;
const envs = [];
const dependencies = [];
const { dbDialect, allDbDialect } = this.args;
const { dbDialect } = this.args;
if (allDbDialect) {
dependencies.push(`"mysql2": "^3.11.0"`);
dependencies.push(`"mariadb": "^2.5.6"`);
dependencies.push(`"pg": "^8.7.3"`);
dependencies.push(`"mysql2": "^3.14.0"`);
dependencies.push(`"mariadb": "^3.4.1"`);
dependencies.push(`"pg": "^8.14.1"`);
dependencies.push(`"pg-hstore": "^2.3.4"`);
dependencies.push(`"sqlite3": "^5.0.8"`);
}
switch (dbDialect) {
case 'sqlite':
if (!allDbDialect) {
dependencies.push(`"sqlite3": "^5.0.8"`);
}
envs.push(`DB_STORAGE=${env.DB_STORAGE || 'storage/db/nocobase.sqlite'}`);
break;
case 'mysql':
if (!allDbDialect) {
dependencies.push(`"mysql2": "^3.11.0"`);
}
envs.push(`DB_HOST=${env.DB_HOST || 'localhost'}`);
envs.push(`DB_PORT=${env.DB_PORT || 3306}`);
envs.push(`DB_DATABASE=${env.DB_DATABASE || ''}`);
@ -104,9 +92,6 @@ class AppGenerator extends Generator {
envs.push(`DB_PASSWORD=${env.DB_PASSWORD || ''}`);
break;
case 'mariadb':
if (!allDbDialect) {
dependencies.push(`"mariadb": "^2.5.6"`);
}
envs.push(`DB_HOST=${env.DB_HOST || 'localhost'}`);
envs.push(`DB_PORT=${env.DB_PORT || 3306}`);
envs.push(`DB_DATABASE=${env.DB_DATABASE || ''}`);
@ -115,10 +100,6 @@ class AppGenerator extends Generator {
break;
case 'kingbase':
case 'postgres':
if (!allDbDialect) {
dependencies.push(`"pg": "^8.7.3"`);
dependencies.push(`"pg-hstore": "^2.3.4"`);
}
envs.push(`DB_HOST=${env.DB_HOST || 'localhost'}`);
envs.push(`DB_PORT=${env.DB_PORT || 5432}`);
envs.push(`DB_DATABASE=${env.DB_DATABASE || ''}`);

View File

@ -28,9 +28,10 @@
"@types/react-dom": "^18.0.0",
"react-router-dom": "6.28.1",
"react-router": "6.28.1",
"async": "3.2.6",
"async": "^3.2.6",
"antd": "5.12.8",
"rollup": "4.24.0"
"rollup": "4.24.0",
"semver": "^7.7.1"
},
"dependencies": {
"@nocobase/cli": "{{{version}}}",

View File

@ -11,8 +11,8 @@
"@nocobase/database": "1.6.21",
"@nocobase/resourcer": "1.6.21",
"@nocobase/utils": "1.6.21",
"@types/jsonwebtoken": "^8.5.8",
"jsonwebtoken": "^8.5.1"
"@types/jsonwebtoken": "^9.0.9",
"jsonwebtoken": "^9.0.2"
},
"repository": {
"type": "git",

View File

@ -10,7 +10,7 @@
"deepmerge": "^4.2.2",
"koa-compose": "^4.1.0",
"lodash": "^4.17.21",
"path-to-regexp": "6.2.2",
"path-to-regexp": "^6.3.0",
"qs": "^6.9.4"
},
"repository": {

View File

@ -367,7 +367,7 @@ export class ResourceManager {
: params.resourceName;
ctx.action.params.filterByTk = params.resourceIndex;
const query = parseQuery(ctx.request.querystring);
if (pathToRegexp('/resourcer/{:associatedName.}?:resourceName{\\::actionName}').test(ctx.request.path)) {
if (pathToRegexp('/resourcer/:rest(.*)').test(ctx.request.path)) {
ctx.action.mergeParams({
...query,
...params,

View File

@ -67,17 +67,25 @@ export function parseRequest(request: ParseRequest, options: ParseOptions = {}):
...(options.accessors || {}),
};
const keys = [];
const regexp = pathToRegexp('/resourcer/{:associatedName.}?:resourceName{\\::actionName}', keys);
const regexp = pathToRegexp('/resourcer/:rest(.*)', keys);
const reqPath = decodeURI(request.path);
const matches = regexp.exec(reqPath);
if (matches) {
const params = {};
keys.forEach((obj, index) => {
if (matches[index + 1] === undefined) {
return;
const [resource, action] = matches[1].split(':');
const [res1, res2] = resource.split('.');
if (res1) {
if (res2) {
params['associatedName'] = res1;
params['resourceName'] = res2;
} else {
params['resourceName'] = res1;
}
}
if (action) {
params['actionName'] = action;
}
params[obj.name] = matches[index + 1];
});
return params;
}
const defaults = {

View File

@ -8,8 +8,8 @@
"@formily/json-schema": "2.x",
"@hapi/topo": "^6.0.0",
"@koa/cors": "^5.0.0",
"@koa/multer": "^3.0.2",
"@koa/router": "^9.4.0",
"@koa/multer": "^3.1.0",
"@koa/router": "^13.1.0",
"@nocobase/acl": "1.6.21",
"@nocobase/actions": "1.6.21",
"@nocobase/auth": "1.6.21",
@ -26,7 +26,7 @@
"@types/decompress": "4.2.7",
"@types/ini": "^1.3.31",
"@types/koa-send": "^4.1.3",
"@types/multer": "^1.4.5",
"@types/multer": "^1.4.12",
"async-mutex": "^0.5.0",
"axios": "^1.7.0",
"chalk": "^4.1.1",
@ -45,7 +45,7 @@
"koa-send": "^5.0.1",
"koa-static": "^5.0.0",
"lodash": "^4.17.21",
"multer": "^1.4.2",
"multer": "^1.4.5-lts.2",
"nanoid": "^3.3.11",
"semver": "^7.7.1",
"serve-handler": "^6.1.6",

View File

@ -15,7 +15,7 @@ const deps: Record<string, string> = {
'@formily': '2.x',
'@formily/antd-v5': '1.x',
jsonwebtoken: '8.x',
jsonwebtoken: '9.x',
'cache-manager': '5.x',
sequelize: '6.x',
umzug: '3.x',
@ -26,7 +26,7 @@ const deps: Record<string, string> = {
'winston-daily-rotate-file': '4.x',
koa: '2.x',
'@koa/cors': '5.x',
'@koa/router': '9.x',
'@koa/router': '13.x',
multer: '1.x',
'@koa/multer': '3.x',
'koa-bodyparser': '4.x',

View File

@ -69,7 +69,6 @@
"mysql2": "^3.11.0",
"pg": "^8.7.3",
"pg-hstore": "^2.3.4",
"sqlite3": "^5.0.8",
"supertest": "^6.1.6",
"vite": "^5.0.0",
"vitest": "^1.5.0",

View File

@ -7,13 +7,13 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import http from 'http';
import url from 'url';
import pg from 'pg';
import dotenv from 'dotenv';
import path from 'path';
import mysql from 'mysql2/promise';
import http from 'http';
import mariadb from 'mariadb';
import mysql from 'mysql2/promise';
import path from 'path';
import pg from 'pg';
import url from 'url';
dotenv.config({ path: path.resolve(process.cwd(), '.env.test') });

View File

@ -13,7 +13,7 @@
"flat-to-nested": "^1.1.1",
"graphlib": "^2.1.8",
"handlebars": "^4.7.8",
"multer": "^1.4.5-lts.1",
"multer": "^1.4.5-lts.2",
"object-path": "^0.11.8"
},
"gitHead": "d0b4efe4be55f8c79a98a331d99d9f8cf99021a1"

View File

@ -13,8 +13,8 @@
"Users & permissions"
],
"devDependencies": {
"@types/jsonwebtoken": "^8.5.8",
"jsonwebtoken": "^8.5.1",
"@types/jsonwebtoken": "^9.0.9",
"jsonwebtoken": "^9.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},

View File

@ -15,7 +15,7 @@
"@formily/core": "2.x",
"@formily/react": "2.x",
"@formily/shared": "2.x",
"@koa/multer": "^3.0.2",
"@koa/multer": "^3.1.0",
"@types/node-xlsx": "^0.15.1",
"antd": "5.x",
"async-mutex": "^0.5.0",

View File

@ -15,15 +15,15 @@
"@formily/core": "2.x",
"@formily/react": "2.x",
"@formily/shared": "2.x",
"@koa/multer": "^3.0.0",
"@types/koa-multer": "^1.0.1",
"@koa/multer": "^3.1.0",
"@types/koa-multer": "^1.0.4",
"@types/multer": "^1.4.5",
"antd": "5.x",
"cos-nodejs-sdk-v5": "^2.11.14",
"koa-static": "^5.0.0",
"mime-match": "^1.0.2",
"mkdirp": "~0.5.4",
"multer": "^1.4.2",
"multer": "^1.4.5-lts.2",
"multer-aliyun-oss": "2.1.3",
"multer-cos": "^1.0.3",
"multer-s3": "^3.0.1",

View File

@ -10,8 +10,8 @@
"homepage": "https://docs.nocobase.com/handbook/users",
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/users",
"devDependencies": {
"@types/jsonwebtoken": "^8.5.8",
"jsonwebtoken": "^8.5.1"
"@types/jsonwebtoken": "^9.0.9",
"jsonwebtoken": "^9.0.2"
},
"peerDependencies": {
"@nocobase/actions": "1.x",