mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
chore: support running multiple application processes simultaneously in development mode
This commit is contained in:
parent
2f1a9100a0
commit
f92717e1cd
@ -37,6 +37,7 @@ export default defineConfig({
|
|||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
cacheDirectoryPath: process.env.APP_CLIENT_CACHE_DIR || `node_modules/.cache`,
|
||||||
outputPath: path.resolve(__dirname, '../dist/client'),
|
outputPath: path.resolve(__dirname, '../dist/client'),
|
||||||
hash: true,
|
hash: true,
|
||||||
alias: {
|
alias: {
|
||||||
|
@ -38,16 +38,16 @@ module.exports = (cli) => {
|
|||||||
depth: 1, // 只监听第一层目录
|
depth: 1, // 只监听第一层目录
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await fs.promises.mkdir(path.dirname(process.env.WATCH_FILE), { recursive: true });
|
||||||
|
|
||||||
watcher
|
watcher
|
||||||
.on('addDir', async (pathname) => {
|
.on('addDir', async (pathname) => {
|
||||||
generatePlugins();
|
generatePlugins();
|
||||||
const file = path.resolve(process.cwd(), 'storage/app.watch.ts');
|
await fs.promises.writeFile(process.env.WATCH_FILE, `export const watchId = '${uid()}';`, 'utf-8');
|
||||||
await fs.promises.writeFile(file, `export const watchId = '${uid()}';`, 'utf-8');
|
|
||||||
})
|
})
|
||||||
.on('unlinkDir', async (pathname) => {
|
.on('unlinkDir', async (pathname) => {
|
||||||
generatePlugins();
|
generatePlugins();
|
||||||
const file = path.resolve(process.cwd(), 'storage/app.watch.ts');
|
await fs.promises.writeFile(process.env.WATCH_FILE, `export const watchId = '${uid()}';`, 'utf-8');
|
||||||
await fs.promises.writeFile(file, `export const watchId = '${uid()}';`, 'utf-8');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
promptForTs();
|
promptForTs();
|
||||||
|
@ -350,6 +350,7 @@ exports.initEnv = function initEnv() {
|
|||||||
LOGGER_BASE_PATH: 'storage/logs',
|
LOGGER_BASE_PATH: 'storage/logs',
|
||||||
APP_SERVER_BASE_URL: '',
|
APP_SERVER_BASE_URL: '',
|
||||||
APP_PUBLIC_PATH: '/',
|
APP_PUBLIC_PATH: '/',
|
||||||
|
WATCH_FILE: resolve(process.cwd(), 'storage/app.watch.ts'),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -1023,5 +1023,6 @@
|
|||||||
"When the Label exceeds the width": "字段标题超出宽度时",
|
"When the Label exceeds the width": "字段标题超出宽度时",
|
||||||
"Line break": "换行",
|
"Line break": "换行",
|
||||||
"Ellipsis": "省略",
|
"Ellipsis": "省略",
|
||||||
"Set block layout": "设置区块布局"
|
"Set block layout": "设置区块布局",
|
||||||
|
"Add & Update": "添加 & 更新"
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ export const PluginAddModal: FC<IPluginFormProps> = ({ onClose, isShow }) => {
|
|||||||
const [type, setType] = useState<'npm' | 'upload' | 'url'>('npm');
|
const [type, setType] = useState<'npm' | 'upload' | 'url'>('npm');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal onCancel={() => onClose()} footer={null} destroyOnClose title={t('Add & update')} width={580} open={isShow}>
|
<Modal onCancel={() => onClose()} footer={null} destroyOnClose title={t('Add & Update')} width={580} open={isShow}>
|
||||||
{/* <label style={{ fontWeight: 'bold' }}>{t('Source')}:</label> */}
|
{/* <label style={{ fontWeight: 'bold' }}>{t('Source')}:</label> */}
|
||||||
<div style={{ marginTop: theme.marginLG, marginBottom: theme.marginLG }}>
|
<div style={{ marginTop: theme.marginLG, marginBottom: theme.marginLG }}>
|
||||||
<Radio.Group optionType="button" defaultValue={type} onChange={(e) => setType(e.target.value)}>
|
<Radio.Group optionType="button" defaultValue={type} onChange={(e) => setType(e.target.value)}>
|
||||||
|
@ -311,7 +311,7 @@ export class Gateway extends EventEmitter {
|
|||||||
if (!process.env.IS_DEV_CMD) {
|
if (!process.env.IS_DEV_CMD) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const file = resolve(process.cwd(), 'storage/app.watch.ts');
|
const file = process.env.WATCH_FILE;
|
||||||
if (!fs.existsSync(file)) {
|
if (!fs.existsSync(file)) {
|
||||||
await fs.promises.writeFile(file, `export const watchId = '${uid()}';`, 'utf-8');
|
await fs.promises.writeFile(file, `export const watchId = '${uid()}';`, 'utf-8');
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import { randomUUID } from 'crypto';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
import bodyParser from 'koa-bodyparser';
|
import bodyParser from 'koa-bodyparser';
|
||||||
import { resolve } from 'path';
|
|
||||||
import { createHistogram, RecordableHistogram } from 'perf_hooks';
|
import { createHistogram, RecordableHistogram } from 'perf_hooks';
|
||||||
import Application, { ApplicationOptions } from './application';
|
import Application, { ApplicationOptions } from './application';
|
||||||
import { dataWrapping } from './middlewares/data-wrapping';
|
import { dataWrapping } from './middlewares/data-wrapping';
|
||||||
@ -124,8 +123,7 @@ export const getCommandFullName = (command: Command) => {
|
|||||||
|
|
||||||
/* istanbul ignore next -- @preserve */
|
/* istanbul ignore next -- @preserve */
|
||||||
export const tsxRerunning = async () => {
|
export const tsxRerunning = async () => {
|
||||||
const file = resolve(process.cwd(), 'storage/app.watch.ts');
|
await fs.promises.writeFile(process.env.WATCH_FILE, `export const watchId = '${uid()}';`, 'utf-8');
|
||||||
await fs.promises.writeFile(file, `export const watchId = '${uid()}';`, 'utf-8');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* istanbul ignore next -- @preserve */
|
/* istanbul ignore next -- @preserve */
|
||||||
|
@ -32,6 +32,19 @@ async function trim(packageNames: string[]) {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const excludes = [
|
||||||
|
'@nocobase/plugin-audit-logs',
|
||||||
|
'@nocobase/plugin-backup-restore',
|
||||||
|
'@nocobase/plugin-charts',
|
||||||
|
'@nocobase/plugin-disable-pm-add',
|
||||||
|
'@nocobase/plugin-mobile-client',
|
||||||
|
'@nocobase/plugin-mock-collections',
|
||||||
|
'@nocobase/plugin-multi-app-share-collection',
|
||||||
|
'@nocobase/plugin-notifications',
|
||||||
|
'@nocobase/plugin-snapshot-field',
|
||||||
|
'@nocobase/plugin-workflow-test',
|
||||||
|
];
|
||||||
|
|
||||||
export async function findPackageNames() {
|
export async function findPackageNames() {
|
||||||
const patterns = [
|
const patterns = [
|
||||||
'./packages/plugins/*/package.json',
|
'./packages/plugins/*/package.json',
|
||||||
@ -52,23 +65,11 @@ export async function findPackageNames() {
|
|||||||
return packageJson.name;
|
return packageJson.name;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const excludes = [
|
|
||||||
'@nocobase/plugin-audit-logs',
|
|
||||||
'@nocobase/plugin-backup-restore',
|
|
||||||
'@nocobase/plugin-charts',
|
|
||||||
'@nocobase/plugin-disable-pm-add',
|
|
||||||
'@nocobase/plugin-mobile-client',
|
|
||||||
'@nocobase/plugin-mock-collections',
|
|
||||||
'@nocobase/plugin-multi-app-share-collection',
|
|
||||||
'@nocobase/plugin-notifications',
|
|
||||||
'@nocobase/plugin-snapshot-field',
|
|
||||||
'@nocobase/plugin-workflow-test',
|
|
||||||
];
|
|
||||||
const nocobasePlugins = await findNocobasePlugins();
|
const nocobasePlugins = await findNocobasePlugins();
|
||||||
const { APPEND_PRESET_BUILT_IN_PLUGINS = '', APPEND_PRESET_LOCAL_PLUGINS = '' } = process.env;
|
const { APPEND_PRESET_BUILT_IN_PLUGINS = '', APPEND_PRESET_LOCAL_PLUGINS = '' } = process.env;
|
||||||
return trim(
|
return trim(
|
||||||
_.difference(packageNames, excludes)
|
packageNames
|
||||||
.filter(Boolean)
|
.filter((pkg) => pkg && !excludes.includes(pkg))
|
||||||
.concat(nocobasePlugins)
|
.concat(nocobasePlugins)
|
||||||
.concat(splitNames(APPEND_PRESET_BUILT_IN_PLUGINS))
|
.concat(splitNames(APPEND_PRESET_BUILT_IN_PLUGINS))
|
||||||
.concat(splitNames(APPEND_PRESET_LOCAL_PLUGINS)),
|
.concat(splitNames(APPEND_PRESET_LOCAL_PLUGINS)),
|
||||||
@ -89,7 +90,7 @@ async function findNocobasePlugins() {
|
|||||||
try {
|
try {
|
||||||
const packageJson = await getPackageJson();
|
const packageJson = await getPackageJson();
|
||||||
const pluginNames = Object.keys(packageJson.dependencies).filter((name) => name.startsWith('@nocobase/plugin-'));
|
const pluginNames = Object.keys(packageJson.dependencies).filter((name) => name.startsWith('@nocobase/plugin-'));
|
||||||
return trim(pluginNames);
|
return trim(pluginNames.filter((pkg) => pkg && !excludes.includes(pkg)));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
1
storage/.gitignore
vendored
1
storage/.gitignore
vendored
@ -7,3 +7,4 @@ app-upgrading
|
|||||||
/verdaccio/storage
|
/verdaccio/storage
|
||||||
libs
|
libs
|
||||||
scripts
|
scripts
|
||||||
|
.cache
|
Loading…
x
Reference in New Issue
Block a user