fix: workflow executions not show and format codes (#1184)

Co-authored-by: sealday <sealday@gmail.com>
Reviewed-on: daoyoucloud/tachybase#1184
This commit is contained in:
sealday 2024-06-13 15:56:43 +08:00
parent 64741b1726
commit d99bd8f4a5
816 changed files with 2901 additions and 1942 deletions

View File

@ -1,5 +1,6 @@
import { getUmiConfig, IndexGenerator } from '@tachybase/devtools/umiConfig';
import path from 'path'; import path from 'path';
import { getUmiConfig, IndexGenerator } from '@tachybase/devtools/umiConfig';
import { defineConfig } from 'umi'; import { defineConfig } from 'umi';
const umiConfig = getUmiConfig(); const umiConfig = getUmiConfig();
@ -10,7 +11,8 @@ process.env.DID_YOU_KNOW = 'none';
const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '').split(',').filter((item) => !item.includes('preset')); // 因为现在 preset 是直接引入的,所以不能忽略,如果以后 preset 也是动态插件的形式引入,那么这里可以去掉 const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '').split(',').filter((item) => !item.includes('preset')); // 因为现在 preset 是直接引入的,所以不能忽略,如果以后 preset 也是动态插件的形式引入,那么这里可以去掉
const pluginDirs = (process.env.PLUGIN_PATH || 'packages/plugins/,packages/samples/,packages/pro-plugins/') const pluginDirs = (process.env.PLUGIN_PATH || 'packages/plugins/,packages/samples/,packages/pro-plugins/')
.split(',').map(item => path.join(process.cwd(), item)); .split(',')
.map((item) => path.join(process.cwd(), item));
const outputPluginPath = path.join(__dirname, 'src', '.plugins'); const outputPluginPath = path.join(__dirname, 'src', '.plugins');
const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs); const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs);
@ -36,7 +38,9 @@ export default defineConfig({
src: `${appPublicPath}browser-checker.js`, src: `${appPublicPath}browser-checker.js`,
}, },
{ {
content: isDevCmd ? '' : ` content: isDevCmd
? ''
: `
window['__webpack_public_path__'] = '{{env.APP_PUBLIC_PATH}}'; window['__webpack_public_path__'] = '{{env.APP_PUBLIC_PATH}}';
window['__tachybase_public_path__'] = '{{env.APP_PUBLIC_PATH}}'; window['__tachybase_public_path__'] = '{{env.APP_PUBLIC_PATH}}';
window['__tachybase_api_base_url__'] = '{{env.API_BASE_URL}}'; window['__tachybase_api_base_url__'] = '{{env.API_BASE_URL}}';
@ -71,7 +75,7 @@ export default defineConfig({
safari: 12, safari: 12,
}, },
codeSplitting: { codeSplitting: {
jsStrategy: 'depPerChunk' jsStrategy: 'depPerChunk',
}, },
chainWebpack(config, { env }) { chainWebpack(config, { env }) {
if (env === 'production') { if (env === 'production') {

View File

@ -39,101 +39,105 @@ function css_browser_selector(u) {
(!/opera|webtv/i.test(ua) && /msie\s(\d+)/.test(ua)) || /trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.test(ua) (!/opera|webtv/i.test(ua) && /msie\s(\d+)/.test(ua)) || /trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.test(ua)
? 'ie ie' + (/trident\/4\.0/.test(ua) ? '8' : RegExp.$1 == '11.0' ? '11' : RegExp.$1) ? 'ie ie' + (/trident\/4\.0/.test(ua) ? '8' : RegExp.$1 == '11.0' ? '11' : RegExp.$1)
: is('firefox/') : is('firefox/')
? g + ? g +
' ' + ' ' +
f + f +
(/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) (/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
? ' ' + f + RegExp.$2 + ' ' + f + RegExp.$2 + '_' + RegExp.$4 ? ' ' + f + RegExp.$2 + ' ' + f + RegExp.$2 + '_' + RegExp.$4
: '') : '')
: is('gecko/') : is('gecko/')
? g ? g
: is('opera') : is('opera')
? o + ? o +
(/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) (/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + '_' + RegExp.$4 ? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + '_' + RegExp.$4
: /opera(\s|\/)(\d+)\.(\d+)/.test(ua) : /opera(\s|\/)(\d+)\.(\d+)/.test(ua)
? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + '_' + RegExp.$3 ? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + '_' + RegExp.$3
: '') : '')
: is('konqueror') : is('konqueror')
? 'konqueror' ? 'konqueror'
: is('blackberry') : is('blackberry')
? bb + ? bb +
(/Version\/(\d+)(\.(\d+)+)/i.test(ua) (/Version\/(\d+)(\.(\d+)+)/i.test(ua)
? ' ' + bb + RegExp.$1 + ' ' + bb + RegExp.$1 + RegExp.$2.replace('.', '_') ? ' ' + bb + RegExp.$1 + ' ' + bb + RegExp.$1 + RegExp.$2.replace('.', '_')
: /Blackberry ?(([0-9]+)([a-z]?))[\/|;]/gi.test(ua) : /Blackberry ?(([0-9]+)([a-z]?))[\/|;]/gi.test(ua)
? ' ' + bb + RegExp.$2 + (RegExp.$3 ? ' ' + bb + RegExp.$2 + RegExp.$3 : '') ? ' ' + bb + RegExp.$2 + (RegExp.$3 ? ' ' + bb + RegExp.$2 + RegExp.$3 : '')
: '') : '')
: is('android') : is('android')
? a + ? a +
(/Version\/(\d+)(\.(\d+))+/i.test(ua) (/Version\/(\d+)(\.(\d+))+/i.test(ua)
? ' ' + a + RegExp.$1 + ' ' + a + RegExp.$1 + RegExp.$2.replace('.', '_') ? ' ' + a + RegExp.$1 + ' ' + a + RegExp.$1 + RegExp.$2.replace('.', '_')
: '') + : '') +
(/Android (.+); (.+) Build/i.test(ua) ? ' ' + dv + RegExp.$2.replace(/ /g, '_').replace(/-/g, '_') : '') (/Android (.+); (.+) Build/i.test(ua)
: is('chrome') ? ' ' + dv + RegExp.$2.replace(/ /g, '_').replace(/-/g, '_')
? w + : '')
' ' + : is('chrome')
c + ? w +
(/chrome\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ' ' +
? ' ' + c + RegExp.$2 + (RegExp.$4 > 0 ? ' ' + c + RegExp.$2 + '_' + RegExp.$4 : '') c +
: '') (/chrome\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
: is('iron') ? ' ' + c + RegExp.$2 + (RegExp.$4 > 0 ? ' ' + c + RegExp.$2 + '_' + RegExp.$4 : '')
? w + ' iron' : '')
: is('applewebkit/') : is('iron')
? w + ? w + ' iron'
' ' + : is('applewebkit/')
s + ? w +
(/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ' ' +
? ' ' + s + RegExp.$2 + ' ' + s + RegExp.$2 + RegExp.$3.replace('.', '_') s +
: / Safari\/(\d+)/i.test(ua) (/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)
? RegExp.$1 == '419' || RegExp.$1 == '417' || RegExp.$1 == '416' || RegExp.$1 == '412' ? ' ' + s + RegExp.$2 + ' ' + s + RegExp.$2 + RegExp.$3.replace('.', '_')
? ' ' + s + '2_0' : / Safari\/(\d+)/i.test(ua)
: RegExp.$1 == '312' ? RegExp.$1 == '419' || RegExp.$1 == '417' || RegExp.$1 == '416' || RegExp.$1 == '412'
? ' ' + s + '1_3' ? ' ' + s + '2_0'
: RegExp.$1 == '125' : RegExp.$1 == '312'
? ' ' + s + '1_2' ? ' ' + s + '1_3'
: RegExp.$1 == '85' : RegExp.$1 == '125'
? ' ' + s + '1_0' ? ' ' + s + '1_2'
: '' : RegExp.$1 == '85'
: '') ? ' ' + s + '1_0'
: is('mozilla/') : ''
? g : '')
: '', : is('mozilla/')
? g
: '',
is('android|mobi|mobile|j2me|iphone|ipod|ipad|blackberry|playbook|kindle|silk') ? m : '', is('android|mobi|mobile|j2me|iphone|ipod|ipad|blackberry|playbook|kindle|silk') ? m : '',
is('j2me') is('j2me')
? 'j2me' ? 'j2me'
: is('ipad|ipod|iphone') : is('ipad|ipod|iphone')
? (/CPU( iPhone)? OS (\d+[_|\.]\d+([_|\.]\d+)*)/i.test(ua) ? 'ios' + version('ios', RegExp.$2) : '') + ? (/CPU( iPhone)? OS (\d+[_|\.]\d+([_|\.]\d+)*)/i.test(ua) ? 'ios' + version('ios', RegExp.$2) : '') +
' ' + ' ' +
(/(ip(ad|od|hone))/gi.test(ua) ? RegExp.$1 : '') (/(ip(ad|od|hone))/gi.test(ua) ? RegExp.$1 : '')
: is('playbook') : is('playbook')
? 'playbook' ? 'playbook'
: is('kindle|silk') : is('kindle|silk')
? 'kindle' ? 'kindle'
: is('playbook') : is('playbook')
? 'playbook' ? 'playbook'
: is('mac') : is('mac')
? 'mac' + ? 'mac' +
(/mac os x ((\d+)[.|_](\d+))/.test(ua) ? ' mac' + RegExp.$2 + ' mac' + RegExp.$1.replace('.', '_') : '') (/mac os x ((\d+)[.|_](\d+))/.test(ua)
: is('win') ? ' mac' + RegExp.$2 + ' mac' + RegExp.$1.replace('.', '_')
? 'win' + : '')
(is('windows nt 6.2') : is('win')
? ' win8' ? 'win' +
: is('windows nt 6.1') (is('windows nt 6.2')
? ' win7' ? ' win8'
: is('windows nt 6.0') : is('windows nt 6.1')
? ' vista' ? ' win7'
: is('windows nt 5.2') || is('windows nt 5.1') : is('windows nt 6.0')
? ' win_xp' ? ' vista'
: is('windows nt 5.0') : is('windows nt 5.2') || is('windows nt 5.1')
? ' win_2k' ? ' win_xp'
: is('windows nt 4.0') || is('WinNT4.0') : is('windows nt 5.0')
? ' win_nt' ? ' win_2k'
: '') : is('windows nt 4.0') || is('WinNT4.0')
: is('freebsd') ? ' win_nt'
? 'freebsd' : '')
: is('x11|linux') : is('freebsd')
? 'linux' ? 'freebsd'
: '', : is('x11|linux')
? 'linux'
: '',
/[; |\[](([a-z]{2})(\-[a-z]{2})?)[)|;|\]]/i.test(ua) /[; |\[](([a-z]{2})(\-[a-z]{2})?)[)|;|\]]/i.test(ua)
? (lang + RegExp.$2).replace('-', '_') + (RegExp.$3 != '' ? (' ' + lang + RegExp.$1).replace('-', '_') : '') ? (lang + RegExp.$2).replace('-', '_') + (RegExp.$3 != '' ? (' ' + lang + RegExp.$1).replace('-', '_') : '')
: '', : '',

View File

@ -1 +1,11 @@
{"name":"","short_name":"","icons":[{"src":"./android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} {
"name": "",
"short_name": "",
"icons": [
{ "src": "./android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" }
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}

View File

@ -1,4 +1,4 @@
import { PluginConfiguration } from '@tachybase/server';
import process from 'process'; import process from 'process';
import { PluginConfiguration } from '@tachybase/server';
export default [process.env.PRESET_NAME ?? 'tachybase'] as PluginConfiguration[]; export default [process.env.PRESET_NAME ?? 'tachybase'] as PluginConfiguration[];

View File

@ -1,4 +1,5 @@
import { Gateway } from '@tachybase/server'; import { Gateway } from '@tachybase/server';
import { getConfig } from './config'; import { getConfig } from './config';
getConfig() getConfig()

View File

@ -1,26 +1,39 @@
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import path from 'path'; import path from 'path';
import type { Project } from '@pnpm/workspace.find-packages'; import type { Project } from '@pnpm/workspace.find-packages';
import chalk from 'chalk'; import chalk from 'chalk';
import execa from 'execa'; import execa from 'execa';
import { buildCjs } from './buildCjs'; import { buildCjs } from './buildCjs';
import { buildClient } from './buildClient'; import { buildClient } from './buildClient';
import { buildDeclaration } from './buildDeclaration'; import { buildDeclaration } from './buildDeclaration';
import { buildEsm } from './buildEsm'; import { buildEsm } from './buildEsm';
import { buildPlugin } from './buildPlugin'; import { buildPlugin } from './buildPlugin';
import { CORE_APP, CORE_CLIENT, ESM_PACKAGES, getCjsPackages, getPluginPackages, getPresetsPackages, PACKAGES_PATH, ROOT_PATH } from './constant'; import {
CORE_APP,
CORE_CLIENT,
ESM_PACKAGES,
getCjsPackages,
getPluginPackages,
getPresetsPackages,
PACKAGES_PATH,
ROOT_PATH,
} from './constant';
import { signals } from './stats'; import { signals } from './stats';
import { tarPlugin } from './tarPlugin'; import { tarPlugin } from './tarPlugin';
import { getPackageJson, getPkgLog, getUserConfig, PkgLog, readFromCache, toUnixPath, UserConfig, writeToCache } from './utils'; import {
getPackageJson,
getPkgLog,
getUserConfig,
PkgLog,
readFromCache,
toUnixPath,
UserConfig,
writeToCache,
} from './utils';
import { getPackages } from './utils/getPackages'; import { getPackages } from './utils/getPackages';
const BUILD_ERROR = 'build-error'; const BUILD_ERROR = 'build-error';
export async function build(pkgs: string[]) { export async function build(pkgs: string[]) {

View File

@ -1,8 +1,10 @@
import { build } from 'tsup';
import fg from 'fast-glob';
import path from 'path'; import path from 'path';
import chalk from 'chalk'; import chalk from 'chalk';
import { globExcludeFiles, EsbuildSupportExts } from './constant'; import fg from 'fast-glob';
import { build } from 'tsup';
import { EsbuildSupportExts, globExcludeFiles } from './constant';
import { PkgLog, UserConfig } from './utils'; import { PkgLog, UserConfig } from './utils';
export function buildCjs(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { export function buildCjs(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) {
@ -10,26 +12,30 @@ export function buildCjs(cwd: string, userConfig: UserConfig, sourcemap: boolean
const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd, absolute: true }); const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd, absolute: true });
const outDir = path.join(cwd, 'lib'); const outDir = path.join(cwd, 'lib');
const otherExts = Array.from(new Set(entry.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item)))); const otherExts = Array.from(
new Set(entry.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item))),
);
if (otherExts.length) { if (otherExts.length) {
log('%s will not be processed, only be copied to the lib directory.', chalk.yellow(otherExts.join(','))); log('%s will not be processed, only be copied to the lib directory.', chalk.yellow(otherExts.join(',')));
} }
return build(userConfig.modifyTsupConfig({ return build(
entry, userConfig.modifyTsupConfig({
splitting: false, entry,
clean: true, splitting: false,
bundle: false, clean: true,
silent: true, bundle: false,
sourcemap, silent: true,
treeshake: false, sourcemap,
target: 'node16', treeshake: false,
keepNames: true, target: 'node16',
outDir, keepNames: true,
loader: { outDir,
...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: 'copy' }), {}), loader: {
'.json': 'copy', ...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: 'copy' }), {}),
}, '.json': 'copy',
format: 'cjs', },
skipNodeModulesBundle: true, format: 'cjs',
})); skipNodeModulesBundle: true,
}),
);
} }

View File

@ -1,7 +1,8 @@
import path from 'path';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import fg from 'fast-glob'; import fg from 'fast-glob';
import fs from 'fs-extra'; import fs from 'fs-extra';
import path from 'path';
import { build as tsupBuild } from 'tsup'; import { build as tsupBuild } from 'tsup';
import { build as viteBuild } from 'vite'; import { build as viteBuild } from 'vite';
import { libInjectCss } from 'vite-plugin-lib-inject-css'; import { libInjectCss } from 'vite-plugin-lib-inject-css';

View File

@ -1,8 +1,9 @@
import path from 'path'; import path from 'path';
import { PkgLog, UserConfig } from './utils';
import { build as viteBuild } from 'vite';
import fg from 'fast-glob'; import fg from 'fast-glob';
import { build as viteBuild } from 'vite';
import { PkgLog, UserConfig } from './utils';
export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) {
log('build esm'); log('build esm');
@ -12,7 +13,9 @@ export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: b
await build(cwd, indexEntry, outDir, userConfig, sourcemap, log); await build(cwd, indexEntry, outDir, userConfig, sourcemap, log);
const clientEntry = fg.sync(['src/client/index.ts', 'src/client.ts'], { cwd, absolute: true, onlyFiles: true })?.[0]?.replaceAll(/\\/g, '/'); const clientEntry = fg
.sync(['src/client/index.ts', 'src/client.ts'], { cwd, absolute: true, onlyFiles: true })?.[0]
?.replaceAll(/\\/g, '/');
const clientOutDir = path.resolve(cwd, 'es/client'); const clientOutDir = path.resolve(cwd, 'es/client');
if (clientEntry) { if (clientEntry) {
await build(cwd, clientEntry, clientOutDir, userConfig, sourcemap, log); await build(cwd, clientEntry, clientOutDir, userConfig, sourcemap, log);
@ -26,7 +29,14 @@ export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: b
} }
} }
function build(cwd: string, entry: string, outDir: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { function build(
cwd: string,
entry: string,
outDir: string,
userConfig: UserConfig,
sourcemap: boolean = false,
log: PkgLog,
) {
const cwdWin = cwd.replaceAll(/\\/g, '/'); const cwdWin = cwd.replaceAll(/\\/g, '/');
const cwdUnix = cwd.replaceAll(/\//g, '\\'); const cwdUnix = cwd.replaceAll(/\//g, '\\');
const external = function (id: string) { const external = function (id: string) {

View File

@ -1,15 +1,16 @@
import path from 'path';
import ncc from '@vercel/ncc'; import ncc from '@vercel/ncc';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import chalk from 'chalk'; import chalk from 'chalk';
import fg from 'fast-glob'; import fg from 'fast-glob';
import fs from 'fs-extra'; import fs from 'fs-extra';
import path from 'path';
import { build as tsupBuild } from 'tsup'; import { build as tsupBuild } from 'tsup';
import { build as viteBuild } from 'vite'; import { build as viteBuild } from 'vite';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'; import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
import { EsbuildSupportExts, globExcludeFiles } from './constant'; import { EsbuildSupportExts, globExcludeFiles } from './constant';
import { PkgLog, UserConfig, getPackageJson } from './utils'; import { getPackageJson, PkgLog, UserConfig } from './utils';
import { import {
buildCheck, buildCheck,
checkFileSize, checkFileSize,
@ -123,9 +124,9 @@ const external = [
'lodash', 'lodash',
'china-division', 'china-division',
]; ];
const pluginPrefix = ( const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '@tachybase/plugin-,@tachybase/preset-,@hera/plugin-').split(
process.env.PLUGIN_PACKAGE_PREFIX || '@tachybase/plugin-,@tachybase/preset-,@hera/plugin-' ',',
).split(','); );
const target_dir = 'dist'; const target_dir = 'dist';
@ -150,7 +151,9 @@ export function deleteServerFiles(cwd: string, log: PkgLog) {
export function writeExternalPackageVersion(cwd: string, log: PkgLog) { export function writeExternalPackageVersion(cwd: string, log: PkgLog) {
log('write external version'); log('write external version');
const sourceFiles = fg.globSync(sourceGlobalFiles, { cwd, absolute: true }).map((item) => fs.readFileSync(item, 'utf-8')); const sourceFiles = fg
.globSync(sourceGlobalFiles, { cwd, absolute: true })
.map((item) => fs.readFileSync(item, 'utf-8'));
const sourcePackages = getSourcePackages(sourceFiles); const sourcePackages = getSourcePackages(sourceFiles);
const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix); const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix);
const data = excludePackages.reduce<Record<string, string>>((prev, packageName) => { const data = excludePackages.reduce<Record<string, string>>((prev, packageName) => {
@ -171,7 +174,9 @@ export function writeExternalPackageVersion(cwd: string, log: PkgLog) {
export async function buildServerDeps(cwd: string, serverFiles: string[], log: PkgLog) { export async function buildServerDeps(cwd: string, serverFiles: string[], log: PkgLog) {
log('build plugin server dependencies'); log('build plugin server dependencies');
const outDir = path.join(cwd, target_dir, 'node_modules'); const outDir = path.join(cwd, target_dir, 'node_modules');
const serverFileSource = serverFiles.filter(item => validExts.includes(path.extname(item))).map((item) => fs.readFileSync(item, 'utf-8')); const serverFileSource = serverFiles
.filter((item) => validExts.includes(path.extname(item)))
.map((item) => fs.readFileSync(item, 'utf-8'));
const sourcePackages = getSourcePackages(serverFileSource); const sourcePackages = getSourcePackages(serverFileSource);
const includePackages = getIncludePackages(sourcePackages, external, pluginPrefix); const includePackages = getIncludePackages(sourcePackages, external, pluginPrefix);
const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix); const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix);
@ -265,30 +270,34 @@ export async function buildPluginServer(cwd: string, userConfig: UserConfig, sou
const packageJson = getPackageJson(cwd); const packageJson = getPackageJson(cwd);
const serverFiles = fg.globSync(serverGlobalFiles, { cwd, absolute: true }); const serverFiles = fg.globSync(serverGlobalFiles, { cwd, absolute: true });
buildCheck({ cwd, packageJson, entry: 'server', files: serverFiles, log }); buildCheck({ cwd, packageJson, entry: 'server', files: serverFiles, log });
const otherExts = Array.from(new Set(serverFiles.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item)))); const otherExts = Array.from(
new Set(serverFiles.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item))),
);
if (otherExts.length) { if (otherExts.length) {
log('%s will not be processed, only be copied to the dist directory.', chalk.yellow(otherExts.join(','))); log('%s will not be processed, only be copied to the dist directory.', chalk.yellow(otherExts.join(',')));
} }
deleteServerFiles(cwd, log); deleteServerFiles(cwd, log);
await tsupBuild(userConfig.modifyTsupConfig({ await tsupBuild(
entry: serverFiles, userConfig.modifyTsupConfig({
splitting: false, entry: serverFiles,
clean: false, splitting: false,
bundle: false, clean: false,
silent: true, bundle: false,
treeshake: false, silent: true,
target: 'node16', treeshake: false,
sourcemap, target: 'node16',
outDir: path.join(cwd, target_dir), sourcemap,
format: 'cjs', outDir: path.join(cwd, target_dir),
skipNodeModulesBundle: true, format: 'cjs',
loader: { skipNodeModulesBundle: true,
...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: 'copy' }), {}), loader: {
'.json': 'copy', ...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: 'copy' }), {}),
}, '.json': 'copy',
})); },
}),
);
await buildServerDeps(cwd, serverFiles, log); await buildServerDeps(cwd, serverFiles, log);
} }
@ -316,45 +325,44 @@ export async function buildPluginClient(cwd: string, userConfig: UserConfig, sou
const entry = fg.globSync('src/client/index.{ts,tsx,js,jsx}', { absolute: true, cwd }); const entry = fg.globSync('src/client/index.{ts,tsx,js,jsx}', { absolute: true, cwd });
const outputFileName = 'index.js'; const outputFileName = 'index.js';
await viteBuild(userConfig.modifyViteConfig({ await viteBuild(
mode: process.env.NODE_ENV || 'production', userConfig.modifyViteConfig({
define: { mode: process.env.NODE_ENV || 'production',
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'), define: {
'process.env.__TEST__': false, 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
'process.env.__E2E__': process.env.__E2E__ ? true : false, 'process.env.__TEST__': false,
}, 'process.env.__E2E__': process.env.__E2E__ ? true : false,
logLevel: 'warn',
build: {
minify: process.env.NODE_ENV === 'production',
outDir,
cssCodeSplit: false,
emptyOutDir: true,
sourcemap,
lib: {
entry,
formats: ['umd'],
name: packageJson.name,
fileName: () => outputFileName,
}, },
target: ['es2015', 'edge88', 'firefox78', 'chrome87', 'safari14'], logLevel: 'warn',
rollupOptions: { build: {
cache: true, minify: process.env.NODE_ENV === 'production',
external: [...Object.keys(globals), 'react', 'react/jsx-runtime'], outDir,
output: { cssCodeSplit: false,
exports: 'named', emptyOutDir: true,
globals: { sourcemap,
react: 'React', lib: {
'react/jsx-runtime': 'jsxRuntime', entry,
...globals, formats: ['umd'],
name: packageJson.name,
fileName: () => outputFileName,
},
target: ['es2015', 'edge88', 'firefox78', 'chrome87', 'safari14'],
rollupOptions: {
cache: true,
external: [...Object.keys(globals), 'react', 'react/jsx-runtime'],
output: {
exports: 'named',
globals: {
react: 'React',
'react/jsx-runtime': 'jsxRuntime',
...globals,
},
}, },
}, },
}, },
}, plugins: [react(), cssInjectedByJsPlugin({ styleId: packageJson.name })],
plugins: [ }),
react(), );
cssInjectedByJsPlugin({ styleId: packageJson.name }),
],
}));
checkFileSize(outDir, log); checkFileSize(outDir, log);
} }

View File

@ -1,6 +1,7 @@
import type { Project } from '@pnpm/workspace.find-packages';
import path from 'path'; import path from 'path';
import type { Project } from '@pnpm/workspace.find-packages';
export const globExcludeFiles = [ export const globExcludeFiles = [
'!src/**/__tests__', '!src/**/__tests__',
'!src/**/__test__', '!src/**/__test__',

View File

@ -1,6 +1,5 @@
import { Options as TsupConfig } from 'tsup';
import { Options as TsupConfig } from 'tsup' import { InlineConfig as ViteConfig } from 'vite';
import { InlineConfig as ViteConfig } from 'vite'
export type PkgLog = (msg: string, ...args: any[]) => void; export type PkgLog = (msg: string, ...args: any[]) => void;

View File

@ -1,2 +1,2 @@
export * from './build'; export * from './build';
export * from './utils' export * from './utils';

View File

@ -1,10 +1,11 @@
import path from 'path'; import path from 'path';
import tar from 'tar';
import fg from 'fast-glob'; import fg from 'fast-glob';
import fs from 'fs-extra'; import fs from 'fs-extra';
import tar from 'tar';
import { PkgLog } from "./utils"; import { TAR_OUTPUT_DIR, tarIncludesFiles } from './constant';
import { TAR_OUTPUT_DIR, tarIncludesFiles } from './constant' import { PkgLog } from './utils';
export function tarPlugin(cwd: string, log: PkgLog) { export function tarPlugin(cwd: string, log: PkgLog) {
log('tar package'); log('tar package');
@ -12,14 +13,24 @@ export function tarPlugin(cwd: string, log: PkgLog) {
const npmIgnore = path.join(cwd, '.npmignore'); const npmIgnore = path.join(cwd, '.npmignore');
let files = pkg.files || []; let files = pkg.files || [];
if (fs.existsSync(npmIgnore)) { if (fs.existsSync(npmIgnore)) {
files = fs.readFileSync(npmIgnore, 'utf-8').split('\n').filter((item) => item.trim()).map(item => `!${item}`); files = fs
.readFileSync(npmIgnore, 'utf-8')
.split('\n')
.filter((item) => item.trim())
.map((item) => `!${item}`);
files.push('**/*'); files.push('**/*');
} }
// 必须包含的文件 // 必须包含的文件
files.push(...tarIncludesFiles); files.push(...tarIncludesFiles);
files = files.map((item: string) => item !== '**/*' && fs.existsSync(path.join(cwd, item.replace('!', ''))) && fs.statSync(path.join(cwd, item.replace('!', ''))).isDirectory() ? `${item}/**/*` : item); files = files.map((item: string) =>
item !== '**/*' &&
fs.existsSync(path.join(cwd, item.replace('!', ''))) &&
fs.statSync(path.join(cwd, item.replace('!', ''))).isDirectory()
? `${item}/**/*`
: item,
);
const tarball = path.join(TAR_OUTPUT_DIR, `${pkg.name}-${pkg.version}.tgz`); const tarball = path.join(TAR_OUTPUT_DIR, `${pkg.name}-${pkg.version}.tgz`);
const tarFiles = fg.sync(files, { cwd }); const tarFiles = fg.sync(files, { cwd });

View File

@ -1,8 +1,9 @@
import fs from 'fs'; import fs from 'fs';
import chalk from 'chalk';
import { builtinModules } from 'module'; import { builtinModules } from 'module';
import path from 'path'; import path from 'path';
import chalk from 'chalk';
const requireRegex = /require\s*\(['"`](.*?)['"`]\)/g; const requireRegex = /require\s*\(['"`](.*?)['"`]\)/g;
const importRegex = /^import(?:['"\s]*([\w*${}\s,]+)from\s*)?['"\s]['"\s](.*[@\w_-]+)['"\s].*/gm; const importRegex = /^import(?:['"\s]*([\w*${}\s,]+)from\s*)?['"\s]['"\s](.*[@\w_-]+)['"\s].*/gm;
@ -156,10 +157,14 @@ export function checkRequire(sourceFiles: string[], log: Log) {
export function checkFileSize(outDir: string, log: Log) { export function checkFileSize(outDir: string, log: Log) {
const files = fs.readdirSync(outDir); const files = fs.readdirSync(outDir);
files.forEach(file => { files.forEach((file) => {
const fileSize = getFileSize(path.join(outDir, file)); const fileSize = getFileSize(path.join(outDir, file));
if (fileSize > 1024 * 1024) { if (fileSize > 1024 * 1024) {
log(`The %s size %s exceeds 1MB. You can use dynamic import \`import()\` for lazy loading content.`, chalk.red(file), chalk.red(formatFileSize(fileSize))); log(
`The %s size %s exceeds 1MB. You can use dynamic import \`import()\` for lazy loading content.`,
chalk.red(file),
chalk.red(formatFileSize(fileSize)),
);
} }
}); });
} }

View File

@ -1,4 +1,5 @@
import path from 'path'; import path from 'path';
import fs from 'fs-extra'; import fs from 'fs-extra';
export function winPath(path: string) { export function winPath(path: string) {
@ -17,20 +18,15 @@ export function getRltExternalsFromDeps(
depExternals: Record<string, string>, depExternals: Record<string, string>,
current: { name: string; outputDir: string }, current: { name: string; outputDir: string },
) { ) {
return Object.entries(depExternals).reduce<Record<string, string>>( return Object.entries(depExternals).reduce<Record<string, string>>((r, [dep, target]) => {
(r, [dep, target]) => { // skip self
// skip self if (dep !== current.name) {
if (dep !== current.name) { // transform dep externals path to relative path
// transform dep externals path to relative path r[dep] = winPath(path.relative(current.outputDir, path.dirname(target)));
r[dep] = winPath( }
path.relative(current.outputDir, path.dirname(target)),
);
}
return r; return r;
}, }, {});
{},
);
} }
function findPackageJson(filePath) { function findPackageJson(filePath) {
@ -44,7 +40,7 @@ function findPackageJson(filePath) {
// 递归寻找直到根目录 // 递归寻找直到根目录
return findPackageJson(directory); return findPackageJson(directory);
} else { } else {
throw new Error('package.json not found.') throw new Error('package.json not found.');
} }
} }
@ -100,10 +96,10 @@ export function getDepsConfig(cwd: string, outDir: string, depsName: string[], e
pkg: depPkg, pkg: depPkg,
outputDir, outputDir,
mainFile, mainFile,
} };
return acc; return acc;
}, {}) }, {});
// process externals for deps // process externals for deps
Object.values(deps).forEach((depConfig) => { Object.values(deps).forEach((depConfig) => {

View File

@ -1,10 +1,11 @@
import Topo from '@hapi/topo';
import fg from 'fast-glob';
import path from 'path'; import path from 'path';
import Topo from '@hapi/topo';
import { findWorkspacePackages, type Project } from '@pnpm/workspace.find-packages';
import fg from 'fast-glob';
import { PACKAGES_PATH, ROOT_PATH } from '../constant'; import { PACKAGES_PATH, ROOT_PATH } from '../constant';
import { toUnixPath } from './utils'; import { toUnixPath } from './utils';
import { findWorkspacePackages } from '@pnpm/workspace.find-packages';
import type { Project } from '@pnpm/workspace.find-packages';
/** /**
* npm * npm

View File

@ -1,10 +1,12 @@
import chalk from 'chalk';
import path from 'path'; import path from 'path';
import chalk from 'chalk';
import { register } from 'esbuild-register/dist/node';
import fg from 'fast-glob'; import fg from 'fast-glob';
import fs from 'fs-extra'; import fs from 'fs-extra';
import { Options as TsupConfig } from 'tsup' import { Options as TsupConfig } from 'tsup';
import { InlineConfig as ViteConfig } from 'vite' import { InlineConfig as ViteConfig } from 'vite';
import { register } from 'esbuild-register/dist/node';
import { NODE_MODULES } from '../constant'; import { NODE_MODULES } from '../constant';
let previousColor = ''; let previousColor = '';
@ -73,9 +75,9 @@ export function getUserConfig(cwd: string) {
throw new Error(`Multiple build configs found: ${buildConfigs.join(', ')}`); throw new Error(`Multiple build configs found: ${buildConfigs.join(', ')}`);
} }
if (buildConfigs.length === 1) { if (buildConfigs.length === 1) {
const { unregister } = register({}) const { unregister } = register({});
const userConfig = require(path.join(cwd, buildConfigs[0])); const userConfig = require(path.join(cwd, buildConfigs[0]));
unregister() unregister();
Object.assign(config, userConfig.default || userConfig); Object.assign(config, userConfig.default || userConfig);
} }
return config; return config;

View File

@ -1,6 +1,8 @@
import { defineConfig } from 'tsup';
import fg from 'fast-glob';
import path from 'path'; import path from 'path';
import fg from 'fast-glob';
import { defineConfig } from 'tsup';
import { globExcludeFiles } from './src/constant'; import { globExcludeFiles } from './src/constant';
const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd: __dirname, absolute: true }); const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd: __dirname, absolute: true });

View File

@ -1,11 +1,12 @@
import { builtinModules, createRequire } from 'node:module'; import { builtinModules, createRequire } from 'node:module';
import esbuild from 'rollup-plugin-esbuild';
import process from 'node:process'; import process from 'node:process';
import dts from 'rollup-plugin-dts';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs'; import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json'; import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import { defineConfig } from 'rollup'; import { defineConfig } from 'rollup';
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
const pkg = require('./package.json'); const pkg = require('./package.json');

View File

@ -1,11 +1,11 @@
#!/usr/bin/env node #!/usr/bin/env node
import chalk from 'chalk'; import chalk from 'chalk';
import { initEnv, genTsConfigPaths } from './util';
import { Command } from 'commander'; import { Command } from 'commander';
import commands from './commands';
import semver from 'semver'; import semver from 'semver';
import commands from './commands';
import { genTsConfigPaths, initEnv } from './util';
const cli = new Command(); const cli = new Command();
cli.version((await import('../package.json')).version); cli.version((await import('../package.json')).version);

View File

@ -1,6 +1,8 @@
import { resolve } from 'path'; import { resolve } from 'path';
import { type Command } from 'commander'; import { type Command } from 'commander';
import { run, nodeCheck, isPackageValid, buildIndexHtml } from '../util';
import { buildIndexHtml, isPackageValid, nodeCheck, run } from '../util';
/** /**
* *

View File

@ -1,5 +1,6 @@
import { Command } from 'commander'; import { Command } from 'commander';
import { run, isDev } from '../util';
import { isDev, run } from '../util';
/** /**
* *

View File

@ -1,8 +1,9 @@
import { resolve } from 'path';
import { Command } from 'commander';
import { readFileSync, writeFileSync } from 'fs'; import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import { URL } from 'url'; import { URL } from 'url';
import { Command } from 'commander';
const __dirname = new URL('.', import.meta.url).pathname; const __dirname = new URL('.', import.meta.url).pathname;
export default (cli: Command) => { export default (cli: Command) => {

View File

@ -1,5 +1,7 @@
import { resolve } from 'path'; import { resolve } from 'path';
import { Command } from 'commander'; import { Command } from 'commander';
import { PluginGenerator } from '../plugin-generator'; import { PluginGenerator } from '../plugin-generator';
export default (cli: Command) => { export default (cli: Command) => {

View File

@ -1,7 +1,8 @@
import { Command } from 'commander'; import { Command } from 'commander';
import { run, postCheck, nodeCheck, promptForTs } from '../util';
import { getPortPromise } from 'portfinder'; import { getPortPromise } from 'portfinder';
import { nodeCheck, postCheck, promptForTs, run } from '../util';
export default (cli: Command) => { export default (cli: Command) => {
const { APP_PACKAGE_ROOT } = process.env; const { APP_PACKAGE_ROOT } = process.env;
cli cli

View File

@ -1,11 +1,13 @@
import { Command } from 'commander';
import { run, isPortReachable } from '../util';
import { execSync } from 'node:child_process'; import { execSync } from 'node:child_process';
import axios from 'axios';
import { pTest } from './p-test';
import { cpus } from 'os'; import { cpus } from 'os';
import treeKill from 'tree-kill';
import axios from 'axios';
import chalk from 'chalk'; import chalk from 'chalk';
import { Command } from 'commander';
import treeKill from 'tree-kill';
import { isPortReachable, run } from '../util';
import { pTest } from './p-test';
/** /**
* *

View File

@ -1,5 +1,6 @@
import { Command } from 'commander'; import { Command } from 'commander';
import { run, isDev, isProd, promptForTs } from '../util';
import { isDev, isProd, promptForTs, run } from '../util';
export default (cli: Command) => { export default (cli: Command) => {
const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env; const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env;

View File

@ -1,19 +1,20 @@
import { Command } from 'commander'; import { Command } from 'commander';
import { generateAppDir } from '../util'; import { generateAppDir } from '../util';
import global from './global';
import createNginxConf from './create-nginx-conf';
import build from './build'; import build from './build';
import tar from './tar';
import dev from './dev';
import start from './start';
import e2e from './e2e';
import clean from './clean'; import clean from './clean';
import createNginxConf from './create-nginx-conf';
import createPlugin from './create-plugin';
import dev from './dev';
import e2e from './e2e';
import global from './global';
import pm2 from './pm2'; import pm2 from './pm2';
import postinstall from './postinstall';
import start from './start';
import tar from './tar';
import test from './test'; import test from './test';
import umi from './umi'; import umi from './umi';
import upgrade from './upgrade'; import upgrade from './upgrade';
import postinstall from './postinstall';
import createPlugin from './create-plugin';
export default async (cli: Command) => { export default async (cli: Command) => {
generateAppDir(); generateAppDir();

View File

@ -1,10 +1,11 @@
import { execa } from 'execa'; import { existsSync, mkdirSync, readFileSync } from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';
import pAll from 'p-all';
import { parse } from 'dotenv'; import { parse } from 'dotenv';
import { existsSync, readFileSync, mkdirSync } from 'fs'; import { execa } from 'execa';
import fastGlob from 'fast-glob'; import fastGlob from 'fast-glob';
import lodash from 'lodash'; import lodash from 'lodash';
import pAll from 'p-all';
let ENV_FILE = resolve(process.cwd(), '.env.e2e'); let ENV_FILE = resolve(process.cwd(), '.env.e2e');

View File

@ -1,4 +1,5 @@
import { Command } from 'commander'; import { Command } from 'commander';
import { run } from '../util'; import { run } from '../util';
export default (cli: Command) => { export default (cli: Command) => {

View File

@ -1,9 +1,11 @@
import { Command } from 'commander';
import { run, isDev, isPackageValid, generatePlaywrightPath } from '../util';
import { resolve } from 'path';
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import { readFile, writeFile } from 'fs/promises'; import { readFile, writeFile } from 'fs/promises';
import { createStoragePluginsSymlink, createDevPluginsSymlink } from '@tachybase/utils/plugin-symlink'; import { resolve } from 'path';
import { createDevPluginsSymlink, createStoragePluginsSymlink } from '@tachybase/utils/plugin-symlink';
import { Command } from 'commander';
import { generatePlaywrightPath, isDev, isPackageValid, run } from '../util';
export default (cli: Command) => { export default (cli: Command) => {
const { APP_PACKAGE_ROOT } = process.env; const { APP_PACKAGE_ROOT } = process.env;

View File

@ -1,10 +1,12 @@
import { Command } from 'commander';
import { run, postCheck, promptForTs } from '../util';
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';
import chalk from 'chalk'; import chalk from 'chalk';
import { Command } from 'commander';
import _ from 'lodash'; import _ from 'lodash';
import { postCheck, promptForTs, run } from '../util';
export default (cli: Command) => { export default (cli: Command) => {
const { APP_PACKAGE_ROOT, NODE_ARGS } = process.env; const { APP_PACKAGE_ROOT, NODE_ARGS } = process.env;
cli cli

View File

@ -1,6 +1,8 @@
import { resolve } from 'path'; import { resolve } from 'path';
import { Command } from 'commander'; import { Command } from 'commander';
import { run, nodeCheck, isPackageValid } from '../util';
import { isPackageValid, nodeCheck, run } from '../util';
export default (cli: Command) => { export default (cli: Command) => {
cli cli

View File

@ -1,7 +1,9 @@
import { Command } from 'commander';
import { run } from '../util';
import { sep } from 'path'; import { sep } from 'path';
import { Command } from 'commander';
import { run } from '../util';
function addTestCommand(name: string, cli: Command) { function addTestCommand(name: string, cli: Command) {
return cli return cli
.command(name) .command(name)

View File

@ -1,5 +1,6 @@
import { Command } from 'commander'; import { Command } from 'commander';
import { run, isDev } from '../util';
import { isDev, run } from '../util';
export default (cli: Command) => { export default (cli: Command) => {
const { APP_PACKAGE_ROOT } = process.env; const { APP_PACKAGE_ROOT } = process.env;

View File

@ -1,7 +1,9 @@
import { Command } from 'commander';
import { resolve } from 'path';
import { run, promptForTs, runAppCommand, hasCorePackages, hasTsNode } from '../util';
import { existsSync, rmSync } from 'fs'; import { existsSync, rmSync } from 'fs';
import { resolve } from 'path';
import { Command } from 'commander';
import { hasCorePackages, hasTsNode, promptForTs, run, runAppCommand } from '../util';
export default (cli: Command) => { export default (cli: Command) => {
cli cli

View File

@ -1,12 +1,14 @@
import chalk from 'chalk';
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import { join, resolve } from 'path';
import { Generator } from '@umijs/utils';
import { readFile } from 'fs/promises'; import { readFile } from 'fs/promises';
import { genTsConfigPaths } from './util'; import { join, resolve } from 'path';
import { execa } from 'execa';
import { URL } from 'url'; import { URL } from 'url';
import { Generator } from '@umijs/utils';
import chalk from 'chalk';
import { execa } from 'execa';
import { genTsConfigPaths } from './util';
const __dirname = new URL('.', import.meta.url).pathname; const __dirname = new URL('.', import.meta.url).pathname;
function camelize(str: string) { function camelize(str: string) {
@ -40,7 +42,7 @@ export class PluginGenerator extends Generator {
...this.context, ...this.context,
packageName: name, packageName: name,
packageVersion, packageVersion,
tachybaseVersion: "0.0.1", tachybaseVersion: '0.0.1',
pascalCaseName: capitalize(camelize(name.split('/').pop())), pascalCaseName: capitalize(camelize(name.split('/').pop())),
}; };
} }

View File

@ -1,27 +1,32 @@
import {
cpSync as _cpSync,
existsSync as _existsSync,
writeFileSync as _writeFileSync,
copyFileSync,
cpSync,
existsSync,
mkdirSync,
readFileSync,
rmSync,
symlinkSync,
unlinkSync,
writeFileSync,
} from 'fs';
import { readFile, writeFile } from 'fs/promises';
import { createRequire } from 'module';
import { Socket } from 'net'; import { Socket } from 'net';
import { dirname, join, resolve, sep } from 'path';
import chalk from 'chalk'; import chalk from 'chalk';
import { config } from 'dotenv';
import { execa, Options } from 'execa'; import { execa, Options } from 'execa';
import fastGlob from 'fast-glob'; import fastGlob from 'fast-glob';
import { dirname, join, resolve, sep } from 'path';
import { readFile, writeFile } from 'fs/promises';
import { existsSync, mkdirSync, cpSync, writeFileSync } from 'fs';
import { config } from 'dotenv';
import {
unlinkSync,
symlinkSync,
existsSync as _existsSync,
rmSync,
cpSync as _cpSync,
copyFileSync,
readFileSync,
writeFileSync as _writeFileSync,
} from 'fs';
import { createRequire } from 'module';
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
export function isPackageValid(pkg: string) { export function isPackageValid(pkg: string) {
try { try {
require(pkg) require(pkg);
return true; return true;
} catch (error) { } catch (error) {
return false; return false;

View File

@ -1,4 +1,5 @@
import axios from 'axios'; import axios from 'axios';
import { APIClient } from '../APIClient'; import { APIClient } from '../APIClient';
describe('APIClient', () => { describe('APIClient', () => {

View File

@ -1,6 +1,7 @@
import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client';
import MockAdapter from 'axios-mock-adapter';
import React from 'react'; import React from 'react';
import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client';
import MockAdapter from 'axios-mock-adapter';
const apiClient = new APIClient(); const apiClient = new APIClient();

View File

@ -1,6 +1,7 @@
import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client';
import MockAdapter from 'axios-mock-adapter';
import React from 'react'; import React from 'react';
import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client';
import MockAdapter from 'axios-mock-adapter';
const apiClient = new APIClient(); const apiClient = new APIClient();

View File

@ -1,8 +1,9 @@
import { uid } from '@tachybase/schema'; import React from 'react';
import { APIClient, APIClientProvider, useAPIClient, useRequest } from '@tachybase/client'; import { APIClient, APIClientProvider, useAPIClient, useRequest } from '@tachybase/client';
import { uid } from '@tachybase/schema';
import { Button, Input, Space, Table } from 'antd'; import { Button, Input, Space, Table } from 'antd';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import React from 'react';
const apiClient = new APIClient(); const apiClient = new APIClient();

View File

@ -1,9 +1,11 @@
import React, { Component } from 'react';
import { render, screen, sleep, userEvent, waitFor } from '@tachybase/test/client'; import { render, screen, sleep, userEvent, waitFor } from '@tachybase/test/client';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import React, { Component } from 'react';
import { Link, Outlet } from 'react-router-dom'; import { Link, Outlet } from 'react-router-dom';
import { describe } from 'vitest'; import { describe } from 'vitest';
import { Application } from '../Application'; import { Application } from '../Application';
import { Plugin } from '../Plugin'; import { Plugin } from '../Plugin';

View File

@ -1,7 +1,8 @@
import { Application } from '../Application';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { Application } from '../Application';
describe('PluginSettingsManager', () => { describe('PluginSettingsManager', () => {
let app: Application; let app: Application;

View File

@ -1,11 +1,13 @@
import { render, screen, userEvent, sleep, waitFor } from '@tachybase/test/client'; import React, { FC } from 'react';
import { render, screen, sleep, userEvent, waitFor } from '@tachybase/test/client';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import React, { FC } from 'react';
import { Link, Outlet } from 'react-router-dom'; import { Link, Outlet } from 'react-router-dom';
import { beforeAll } from 'vitest'; import { beforeAll } from 'vitest';
import { Application } from '../Application'; import { Application } from '../Application';
import { RouteType, RouterManager, createRouterManager } from '../RouterManager'; import { createRouterManager, RouterManager, RouteType } from '../RouterManager';
describe('Router', () => { describe('Router', () => {
let app: Application; let app: Application;

View File

@ -1,9 +1,10 @@
import React from 'react'; import React from 'react';
import { fireEvent, render, screen, waitFor } from '@tachybase/test/client';
import { SchemaToolbarProvider, useSchemaToolbar, useSchemaToolbarRender } from '../schema-toolbar';
import { SchemaComponent, SchemaComponentProvider, SortableContext, SortableProvider } from '../../schema-component';
import { useFieldSchema } from '@tachybase/schema';
import { Application, ApplicationContext } from '@tachybase/client'; import { Application, ApplicationContext } from '@tachybase/client';
import { useFieldSchema } from '@tachybase/schema';
import { fireEvent, render, screen, waitFor } from '@tachybase/test/client';
import { SchemaComponent, SchemaComponentProvider, SortableContext, SortableProvider } from '../../schema-component';
import { SchemaToolbarProvider, useSchemaToolbar, useSchemaToolbarRender } from '../schema-toolbar';
describe('SchemaToolbar', () => { describe('SchemaToolbar', () => {
test('SchemaToolbarProvider & useSchemaToolbar', () => { test('SchemaToolbarProvider & useSchemaToolbar', () => {

View File

@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { SchemaComponent, SchemaComponentProvider } from '../../../schema-component';
import { render } from '@tachybase/test/client'; import { render } from '@tachybase/test/client';
import { SchemaComponent, SchemaComponentProvider } from '../../../schema-component';
import { withDynamicSchemaProps } from '../../hoc'; import { withDynamicSchemaProps } from '../../hoc';
const HelloComponent = withDynamicSchemaProps((props: any) => ( const HelloComponent = withDynamicSchemaProps((props: any) => (

View File

@ -1,6 +1,8 @@
import { render, screen } from '@tachybase/test/client';
import React from 'react'; import React from 'react';
import { render, screen } from '@tachybase/test/client';
import { describe } from 'vitest'; import { describe } from 'vitest';
import { compose, normalizeContainer } from '../utils'; import { compose, normalizeContainer } from '../utils';
describe('utils', () => { describe('utils', () => {

View File

@ -1,4 +1,5 @@
import { createContext } from 'react'; import { createContext } from 'react';
import { Application } from './Application'; import { Application } from './Application';
export const ApplicationContext = createContext<Application>(null); export const ApplicationContext = createContext<Application>(null);

View File

@ -1,4 +1,5 @@
import type { ButtonProps } from 'antd'; import type { ButtonProps } from 'antd';
import { SchemaInitializerItemType, SchemaInitializerItemTypeWithoutName, SchemaInitializerOptions } from './types'; import { SchemaInitializerItemType, SchemaInitializerItemTypeWithoutName, SchemaInitializerOptions } from './types';
export class SchemaInitializer<P1 = ButtonProps, P2 = {}> { export class SchemaInitializer<P1 = ButtonProps, P2 = {}> {

View File

@ -1,4 +1,5 @@
import { ButtonProps } from 'antd'; import { ButtonProps } from 'antd';
import { Application } from '../Application'; import { Application } from '../Application';
import { SchemaInitializer } from './SchemaInitializer'; import { SchemaInitializer } from './SchemaInitializer';
import { SchemaInitializerItemTypeWithoutName } from './types'; import { SchemaInitializerItemTypeWithoutName } from './types';

View File

@ -1,6 +1,7 @@
import { useForm } from '@tachybase/schema';
import React, { FC, useCallback, useMemo } from 'react'; import React, { FC, useCallback, useMemo } from 'react';
import { useActionContext, SchemaComponent } from '../../../schema-component'; import { useForm } from '@tachybase/schema';
import { SchemaComponent, useActionContext } from '../../../schema-component';
import { useSchemaInitializerItem } from '../context'; import { useSchemaInitializerItem } from '../context';
export interface SchemaInitializerActionModalProps { export interface SchemaInitializerActionModalProps {

View File

@ -1,5 +1,7 @@
import { Button, ButtonProps } from 'antd';
import React, { FC } from 'react'; import React, { FC } from 'react';
import { Button, ButtonProps } from 'antd';
import { Icon } from '../../../icon'; import { Icon } from '../../../icon';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
import { useGetAriaLabelOfSchemaInitializer } from '../../../schema-initializer/hooks/useGetAriaLabelOfSchemaInitializer'; import { useGetAriaLabelOfSchemaInitializer } from '../../../schema-initializer/hooks/useGetAriaLabelOfSchemaInitializer';

View File

@ -3,6 +3,7 @@ import React, { FC, memo, useMemo } from 'react';
import { useFindComponent } from '../../../schema-component'; import { useFindComponent } from '../../../schema-component';
import { SchemaInitializerItemContext } from '../context'; import { SchemaInitializerItemContext } from '../context';
import { SchemaInitializerItemType } from '../types'; import { SchemaInitializerItemType } from '../types';
export const SchemaInitializerChildren: FC<{ children: SchemaInitializerItemType[] }> = (props) => { export const SchemaInitializerChildren: FC<{ children: SchemaInitializerItemType[] }> = (props) => {
const { children } = props; const { children } = props;
if (!children) return null; if (!children) return null;

View File

@ -1,6 +1,7 @@
import { Divider, theme } from 'antd';
import React from 'react'; import React from 'react';
import { Divider, theme } from 'antd';
export const SchemaInitializerDivider = () => { export const SchemaInitializerDivider = () => {
const { token } = theme.useToken(); const { token } = theme.useToken();
return <Divider style={{ marginTop: token.marginXXS, marginBottom: token.marginXXS }} />; return <Divider style={{ marginTop: token.marginXXS, marginBottom: token.marginXXS }} />;

View File

@ -1,6 +1,8 @@
import React, { memo, ReactNode, useMemo } from 'react';
import { uid } from '@tachybase/schema'; import { uid } from '@tachybase/schema';
import classNames from 'classnames'; import classNames from 'classnames';
import React, { ReactNode, memo, useMemo } from 'react';
import { Icon } from '../../../icon'; import { Icon } from '../../../icon';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
import { useSchemaInitializerItem } from '../context'; import { useSchemaInitializerItem } from '../context';

View File

@ -1,5 +1,7 @@
import { theme } from 'antd';
import React, { FC } from 'react'; import React, { FC } from 'react';
import { theme } from 'antd';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
import { useSchemaInitializerItem } from '../context'; import { useSchemaInitializerItem } from '../context';
import { SchemaInitializerOptions } from '../types'; import { SchemaInitializerOptions } from '../types';

View File

@ -1,7 +1,9 @@
import { ButtonProps } from 'antd';
import React, { FC } from 'react'; import React, { FC } from 'react';
import { SchemaInitializerChildren } from './SchemaInitializerChildren';
import { ButtonProps } from 'antd';
import { SchemaInitializerOptions } from '../types'; import { SchemaInitializerOptions } from '../types';
import { SchemaInitializerChildren } from './SchemaInitializerChildren';
export type SchemaInitializerItemsProps<P1 = ButtonProps, P2 = {}> = P2 & { export type SchemaInitializerItemsProps<P1 = ButtonProps, P2 = {}> = P2 & {
options?: SchemaInitializerOptions<P1, P2>; options?: SchemaInitializerOptions<P1, P2>;

View File

@ -1,7 +1,9 @@
import { Select, SelectProps } from 'antd';
import React, { FC, useCallback, useMemo, useState } from 'react'; import React, { FC, useCallback, useMemo, useState } from 'react';
import { SchemaInitializerItemProps, SchemaInitializerItem } from './SchemaInitializerItem';
import { Select, SelectProps } from 'antd';
import { useSchemaInitializerItem } from '../context'; import { useSchemaInitializerItem } from '../context';
import { SchemaInitializerItem, SchemaInitializerItemProps } from './SchemaInitializerItem';
export interface SchemaInitializerSelectItemProps extends SchemaInitializerItemProps { export interface SchemaInitializerSelectItemProps extends SchemaInitializerItemProps {
options?: SelectProps['options']; options?: SelectProps['options'];

View File

@ -1,8 +1,10 @@
import { Switch } from 'antd';
import React, { FC } from 'react'; import React, { FC } from 'react';
import { SchemaInitializerItemProps, SchemaInitializerItem } from './SchemaInitializerItem';
import { Switch } from 'antd';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
import { useSchemaInitializerItem } from '../context'; import { useSchemaInitializerItem } from '../context';
import { SchemaInitializerItem, SchemaInitializerItemProps } from './SchemaInitializerItem';
export interface SchemaInitializerSwitchItemProps extends SchemaInitializerItemProps { export interface SchemaInitializerSwitchItemProps extends SchemaInitializerItemProps {
checked?: boolean; checked?: boolean;

View File

@ -1,4 +1,5 @@
import React, { createContext } from 'react'; import React, { createContext } from 'react';
import { InsertType, SchemaInitializerItemType, SchemaInitializerOptions } from '../types'; import { InsertType, SchemaInitializerItemType, SchemaInitializerOptions } from '../types';
export const SchemaInitializerContext = createContext<{ export const SchemaInitializerContext = createContext<{

View File

@ -1,4 +1,5 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useSchemaInitializerSubMenuContext } from '../components/SchemaInitializerSubMenu'; import { useSchemaInitializerSubMenuContext } from '../components/SchemaInitializerSubMenu';
/** /**

View File

@ -1,6 +1,8 @@
import { ISchema } from '@tachybase/schema';
import { ButtonProps, PopoverProps } from 'antd';
import { ComponentType, ReactNode } from 'react'; import { ComponentType, ReactNode } from 'react';
import { ISchema } from '@tachybase/schema';
import { ButtonProps, PopoverProps } from 'antd';
import type { import type {
SchemaInitializerActionModalProps, SchemaInitializerActionModalProps,
SchemaInitializerItemGroupProps, SchemaInitializerItemGroupProps,

View File

@ -1,10 +1,12 @@
import { ISchema, useFieldSchema } from '@tachybase/schema';
import { SchemaSettingsItemType } from './types';
import { useTranslation } from 'react-i18next';
import { createDesignable, useDesignable } from '../../schema-component';
import { saveAs } from 'file-saver';
import { useAPIClient } from '../../api-client';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { ISchema, useFieldSchema } from '@tachybase/schema';
import { saveAs } from 'file-saver';
import { useTranslation } from 'react-i18next';
import { useAPIClient } from '../../api-client';
import { createDesignable, useDesignable } from '../../schema-component';
import { SchemaSettingsItemType } from './types';
export const defaultSettingItems = [ export const defaultSettingItems = [
{ {

View File

@ -1,5 +1,7 @@
import { MenuOutlined } from '@ant-design/icons';
import React, { FC, useMemo } from 'react'; import React, { FC, useMemo } from 'react';
import { MenuOutlined } from '@ant-design/icons';
import { useGetAriaLabelOfDesigner } from '../../../schema-settings/hooks/useGetAriaLabelOfDesigner'; import { useGetAriaLabelOfDesigner } from '../../../schema-settings/hooks/useGetAriaLabelOfDesigner';
import { SchemaSettingOptions } from '../types'; import { SchemaSettingOptions } from '../types';

View File

@ -1,11 +1,11 @@
import { FC, useMemo } from 'react'; import React, { FC, useMemo } from 'react';
import { useField, useFieldSchema } from '@tachybase/schema';
import { useDesignable } from '../../../schema-component';
import { SchemaSettingsDropdown } from '../../../schema-settings'; import { SchemaSettingsDropdown } from '../../../schema-settings';
import { SchemaSettingOptions } from '../types'; import { SchemaSettingOptions } from '../types';
import { SchemaSettingsChildren } from './SchemaSettingsChildren'; import { SchemaSettingsChildren } from './SchemaSettingsChildren';
import { SchemaSettingsIcon } from './SchemaSettingsIcon'; import { SchemaSettingsIcon } from './SchemaSettingsIcon';
import React from 'react';
import { useDesignable } from '../../../schema-component';
import { useField, useFieldSchema } from '@tachybase/schema';
/** /**
* @internal * @internal

View File

@ -1,4 +1,5 @@
import { createContext, useContext } from 'react'; import { createContext, useContext } from 'react';
import { SchemaSettingsItemType } from '../types'; import { SchemaSettingsItemType } from '../types';
export const SchemaSettingItemContext = createContext<SchemaSettingsItemType>({} as any); export const SchemaSettingItemContext = createContext<SchemaSettingsItemType>({} as any);

View File

@ -1,4 +1,5 @@
import { ComponentType } from 'react'; import { ComponentType } from 'react';
import { import {
SchemaSettingsCascaderItemProps, SchemaSettingsCascaderItemProps,
SchemaSettingsItemProps, SchemaSettingsItemProps,

View File

@ -1,5 +1,4 @@
import React from 'react'; import React, { createContext, useContext } from 'react';
import { createContext, useContext } from 'react';
export const SchemaToolbarContext = createContext<any>({}); export const SchemaToolbarContext = createContext<any>({});
SchemaToolbarContext.displayName = 'SchemaToolbarContext'; SchemaToolbarContext.displayName = 'SchemaToolbarContext';

View File

@ -1,5 +1,6 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { ISchema } from '@tachybase/schema'; import { ISchema } from '@tachybase/schema';
import { useComponent, useDesignable } from '../../../schema-component'; import { useComponent, useDesignable } from '../../../schema-component';
import { SchemaToolbar, SchemaToolbarProps } from '../../../schema-settings/GeneralSchemaDesigner'; import { SchemaToolbar, SchemaToolbarProps } from '../../../schema-settings/GeneralSchemaDesigner';

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
import { FC, ReactNode } from 'react'; import React, { FC, ReactNode } from 'react';
import { CollectionProvider } from '../data-source/collection/CollectionProvider';
import { CollectionManagerProvider } from '../data-source/collection/CollectionManagerProvider';
import { CollectionOptions } from '../data-source/collection/Collection'; import { CollectionOptions } from '../data-source/collection/Collection';
import React from 'react'; import { CollectionManagerProvider } from '../data-source/collection/CollectionManagerProvider';
import { CollectionProvider } from '../data-source/collection/CollectionProvider';
/** /**
* @deprecated use `CollectionProvider` instead * @deprecated use `CollectionProvider` instead

View File

@ -1,17 +1,18 @@
import { DownOutlined, PlusOutlined } from '@ant-design/icons'; import React, { useMemo, useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { ISchema, useField, useForm } from '@tachybase/schema'; import { ISchema, uid, useField, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { DownOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, Dropdown, MenuProps } from 'antd'; import { Button, Dropdown, MenuProps } from 'antd';
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager_deprecated } from '../hooks'; import { useCollectionManager_deprecated } from '../hooks';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import * as components from './components'; import * as components from './components';
import { TemplateSummary } from './components/TemplateSummary'; import { TemplateSummary } from './components/TemplateSummary';

View File

@ -1,19 +1,20 @@
import { PlusOutlined } from '@ant-design/icons'; import React, { useCallback, useMemo, useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { useField, useForm } from '@tachybase/schema'; import { uid, useField, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { PlusOutlined } from '@ant-design/icons';
import { Button, Dropdown, MenuProps } from 'antd'; import { Button, Dropdown, MenuProps } from 'antd';
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import React, { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager_deprecated } from '../hooks'; import { useCollectionManager_deprecated } from '../hooks';
import useDialect from '../hooks/useDialect'; import useDialect from '../hooks/useDialect';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import * as components from './components'; import * as components from './components';
import { useFieldInterfaceOptions } from './interfaces'; import { useFieldInterfaceOptions } from './interfaces';

View File

@ -1,11 +1,12 @@
import { PlusOutlined } from '@ant-design/icons'; import React, { useMemo, useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { ISchema } from '@tachybase/schema'; import { ISchema, uid } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { PlusOutlined } from '@ant-design/icons';
import { Button, Dropdown, MenuProps } from 'antd'; import { Button, Dropdown, MenuProps } from 'antd';
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useRequest } from '../../api-client'; import { useRequest } from '../../api-client';
import { useCollectionRecordData } from '../../data-source'; import { useCollectionRecordData } from '../../data-source';
import { RecordProvider } from '../../record-provider'; import { RecordProvider } from '../../record-provider';

View File

@ -1,17 +1,18 @@
import React, { useEffect, useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { ISchema, useForm } from '@tachybase/schema'; import { ISchema, uid, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
import omit from 'lodash/omit'; import omit from 'lodash/omit';
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager_deprecated } from '../hooks'; import { useCollectionManager_deprecated } from '../hooks';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import * as components from './components'; import * as components from './components';
const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => {

View File

@ -1,20 +1,21 @@
import React, { useMemo, useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { ISchema, useForm } from '@tachybase/schema'; import { ISchema, uid, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
import omit from 'lodash/omit'; import omit from 'lodash/omit';
import set from 'lodash/set'; import set from 'lodash/set';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider'; import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager_deprecated } from '../hooks'; import { useCollectionManager_deprecated } from '../hooks';
import useDialect from '../hooks/useDialect'; import useDialect from '../hooks/useDialect';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import * as components from './components'; import * as components from './components';
const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => {

View File

@ -1,9 +1,10 @@
import { ArrayTable } from '@tachybase/components';
import { ISchema, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import cloneDeep from 'lodash/cloneDeep';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { ArrayTable } from '@tachybase/components';
import { ISchema, uid, useForm } from '@tachybase/schema';
import cloneDeep from 'lodash/cloneDeep';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { useRecord } from '../../record-provider'; import { useRecord } from '../../record-provider';
import { ActionContextProvider, SchemaComponent } from '../../schema-component'; import { ActionContextProvider, SchemaComponent } from '../../schema-component';

View File

@ -1,18 +1,19 @@
import React, { useMemo, useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { ISchema, useForm } from '@tachybase/schema'; import { ISchema, uid, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { omit, set } from 'lodash'; import { omit, set } from 'lodash';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { useCollectionParentRecordData } from '../../data-source'; import { useCollectionParentRecordData } from '../../data-source';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager_deprecated } from '../hooks'; import { useCollectionManager_deprecated } from '../hooks';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import * as components from './components'; import * as components from './components';
const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => {

View File

@ -1,18 +1,19 @@
import { PlusOutlined } from '@ant-design/icons'; import React, { useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { useField, useForm } from '@tachybase/schema'; import { uid, useField, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { PlusOutlined } from '@ant-design/icons';
import { Button } from 'antd'; import { Button } from 'antd';
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager_deprecated } from '../hooks'; import { useCollectionManager_deprecated } from '../hooks';
import { IField } from '../interfaces/types'; import { IField } from '../interfaces/types';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { PreviewFields } from '../templates/components/PreviewFields'; import { PreviewFields } from '../templates/components/PreviewFields';
import { PreviewTable } from '../templates/components/PreviewTable'; import { PreviewTable } from '../templates/components/PreviewTable';
import * as components from './components'; import * as components from './components';

View File

@ -1,18 +1,18 @@
import { SyncOutlined } from '@ant-design/icons';
import { FormLayout } from '@tachybase/components';
import { createForm } from '@tachybase/schema';
import { useField, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { Button } from 'antd';
import React, { useMemo, useState } from 'react'; import React, { useMemo, useState } from 'react';
import { FormLayout } from '@tachybase/components';
import { createForm, uid, useField, useForm } from '@tachybase/schema';
import { SyncOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient } from '../../api-client'; import { useAPIClient } from '../../api-client';
import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider'; import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';
import { ActionContextProvider, FormProvider, SchemaComponent, useActionContext } from '../../schema-component'; import { ActionContextProvider, FormProvider, SchemaComponent, useActionContext } from '../../schema-component';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { useCancelAction } from '../action-hooks'; import { useCancelAction } from '../action-hooks';
import { useCollectionManager_deprecated } from '../hooks/useCollectionManager_deprecated'; import { useCollectionManager_deprecated } from '../hooks/useCollectionManager_deprecated';
import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
import { FieldsConfigure, PreviewTable, SQLRequestProvider } from '../templates/components/sql-collection'; import { FieldsConfigure, PreviewTable, SQLRequestProvider } from '../templates/components/sql-collection';
const schema = { const schema = {

View File

@ -1,10 +1,11 @@
import React, { useMemo, useState } from 'react';
import { ArrayTable } from '@tachybase/components'; import { ArrayTable } from '@tachybase/components';
import { ISchema } from '@tachybase/schema'; import { ISchema, uid } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
import set from 'lodash/set'; import set from 'lodash/set';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client'; import { useAPIClient, useRequest } from '../../api-client';
import { useCollectionParentRecordData } from '../../data-source'; import { useCollectionParentRecordData } from '../../data-source';
import { RecordProvider, useRecord } from '../../record-provider'; import { RecordProvider, useRecord } from '../../record-provider';

View File

@ -1,6 +1,8 @@
import { observer } from '@tachybase/schema';
import { Tag } from 'antd';
import React from 'react'; import React from 'react';
import { observer } from '@tachybase/schema';
import { Tag } from 'antd';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
export const CollectionCategory = observer( export const CollectionCategory = observer(

View File

@ -1,6 +1,8 @@
import { observer } from '@tachybase/schema';
import { Tag } from 'antd';
import React from 'react'; import React from 'react';
import { observer } from '@tachybase/schema';
import { Tag } from 'antd';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
import { useCollectionManager_deprecated } from '../../hooks'; import { useCollectionManager_deprecated } from '../../hooks';

View File

@ -1,6 +1,8 @@
import { observer } from '@tachybase/schema';
import { Tag } from 'antd';
import React from 'react'; import React from 'react';
import { observer } from '@tachybase/schema';
import { Tag } from 'antd';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
import { useCollectionManager_deprecated } from '../../hooks'; import { useCollectionManager_deprecated } from '../../hooks';

View File

@ -1,5 +1,7 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useCollectionManager_deprecated } from '../../hooks'; import { useCollectionManager_deprecated } from '../../hooks';
import Summary from './Summary'; import Summary from './Summary';

View File

@ -1,7 +1,9 @@
import React, { useMemo } from 'react';
import { observer } from '@tachybase/schema'; import { observer } from '@tachybase/schema';
import { Tag } from 'antd'; import { Tag } from 'antd';
import { useAntdToken } from 'antd-style'; import { useAntdToken } from 'antd-style';
import React, { useMemo } from 'react';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
const Summary = observer( const Summary = observer(

View File

@ -1,5 +1,7 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useCollectionManager_deprecated } from '../../hooks'; import { useCollectionManager_deprecated } from '../../hooks';
import Summary from './Summary'; import Summary from './Summary';

View File

@ -1,7 +1,8 @@
import { Field } from '@tachybase/schema'; import React, { useEffect, useState } from 'react';
import { observer, useField, useForm } from '@tachybase/schema'; import { Field, observer, useField, useForm } from '@tachybase/schema';
import { Select, AutoComplete } from 'antd';
import React, { useState, useEffect } from 'react'; import { AutoComplete, Select } from 'antd';
import { useRecord } from '../../../record-provider'; import { useRecord } from '../../../record-provider';
import { useCompile } from '../../../schema-component'; import { useCompile } from '../../../schema-component';
import { useCollectionManager_deprecated } from '../../hooks'; import { useCollectionManager_deprecated } from '../../hooks';

View File

@ -1,5 +1,6 @@
import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface';
import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider'; import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider';
export const getOptions = ( export const getOptions = (

View File

@ -1,6 +1,8 @@
import { useField } from '@tachybase/schema';
import { Result } from 'ahooks/es/useRequest/src/types';
import React, { createContext, useContext, useEffect } from 'react'; import React, { createContext, useContext, useEffect } from 'react';
import { useField } from '@tachybase/schema';
import { Result } from 'ahooks/es/useRequest/src/types';
import { useCollectionManager_deprecated } from '.'; import { useCollectionManager_deprecated } from '.';
import { CollectionProvider_deprecated, useRecord } from '..'; import { CollectionProvider_deprecated, useRecord } from '..';
import { useAPIClient, useRequest } from '../api-client'; import { useAPIClient, useRequest } from '../api-client';

View File

@ -1,5 +1,4 @@
import { FormItem, Input } from '@tachybase/components'; import React from 'react';
import { ISchema, observer, useForm } from '@tachybase/schema';
import { import {
Action, Action,
CollectionField, CollectionField,
@ -8,7 +7,8 @@ import {
SchemaComponent, SchemaComponent,
SchemaComponentProvider, SchemaComponentProvider,
} from '@tachybase/client'; } from '@tachybase/client';
import React from 'react'; import { FormItem, Input } from '@tachybase/components';
import { ISchema, observer, useForm } from '@tachybase/schema';
export default observer(() => { export default observer(() => {
const collection = { const collection = {

View File

@ -8,6 +8,7 @@ import {
RecordProvider, RecordProvider,
useCollectionField_deprecated, useCollectionField_deprecated,
} from '@tachybase/client'; } from '@tachybase/client';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
const apiClient = new APIClient(); const apiClient = new APIClient();

View File

@ -1,11 +1,11 @@
import { ISchema } from '@tachybase/schema'; import React from 'react';
import { import {
AntdSchemaComponentProvider, AntdSchemaComponentProvider,
ExtendCollectionsProvider, ExtendCollectionsProvider,
SchemaComponent, SchemaComponent,
SchemaComponentProvider, SchemaComponentProvider,
} from '@tachybase/client'; } from '@tachybase/client';
import React from 'react'; import { ISchema } from '@tachybase/schema';
const schema: ISchema = { const schema: ISchema = {
type: 'object', type: 'object',

View File

@ -1,14 +1,10 @@
import { FormDrawer, FormLayout } from '@tachybase/components'; import React, { useContext } from 'react';
import { createForm } from '@tachybase/schema';
import { ISchema } from '@tachybase/schema';
import { FormContext, SchemaOptionsContext } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { import {
AntdSchemaComponentProvider, AntdSchemaComponentProvider,
Application, Application,
CardItem, CardItem,
CollectionManagerProvider_deprecated,
CollectionManagerProvider, CollectionManagerProvider,
CollectionManagerProvider_deprecated,
CollectionProvider_deprecated, CollectionProvider_deprecated,
FormItem, FormItem,
Grid, Grid,
@ -20,13 +16,15 @@ import {
SchemaComponentOptions, SchemaComponentOptions,
SchemaInitializer, SchemaInitializer,
SchemaInitializerItem, SchemaInitializerItem,
useCollectionManager_deprecated,
useCollectionManager, useCollectionManager,
useCollectionManager_deprecated,
useSchemaInitializer, useSchemaInitializer,
useSchemaInitializerItem, useSchemaInitializerItem,
} from '@tachybase/client'; } from '@tachybase/client';
import { FormDrawer, FormLayout } from '@tachybase/components';
import { createForm, FormContext, ISchema, SchemaOptionsContext, uid } from '@tachybase/schema';
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import React, { useContext } from 'react';
const collection: any = { const collection: any = {
name: 'posts', name: 'posts',

View File

@ -1,14 +1,16 @@
import { useCallback, useMemo, useState } from 'react';
import { uid } from '@tachybase/schema';
import { CascaderProps } from 'antd'; import { CascaderProps } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import { useCallback, useMemo, useState } from 'react';
import { useCompile, useSchemaComponentContext } from '../../schema-component'; import { useCollectionManager } from '../../data-source/collection/CollectionManagerProvider';
import { CollectionFieldOptions_deprecated, CollectionOptions } from '../types'; import { DEFAULT_DATA_SOURCE_KEY } from '../../data-source/data-source/DataSourceManager';
import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin';
import { uid } from '@tachybase/schema';
import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider'; import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider';
import { useDataSource } from '../../data-source/data-source/DataSourceProvider'; import { useDataSource } from '../../data-source/data-source/DataSourceProvider';
import { DEFAULT_DATA_SOURCE_KEY } from '../../data-source/data-source/DataSourceManager'; import { useCompile, useSchemaComponentContext } from '../../schema-component';
import { useCollectionManager } from '../../data-source/collection/CollectionManagerProvider'; import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin';
import { CollectionFieldOptions_deprecated, CollectionOptions } from '../types';
/** /**
* @deprecated use `useCollectionManager` instead * @deprecated use `useCollectionManager` instead

View File

@ -1,8 +1,9 @@
import { SchemaKey } from '@tachybase/schema';
import { useAPIClient } from '../../api-client';
import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin';
import { useCallback, useMemo } from 'react'; import { useCallback, useMemo } from 'react';
import { SchemaKey } from '@tachybase/schema';
import { useAPIClient } from '../../api-client';
import { useCollection } from '../../data-source/collection/CollectionProvider'; import { useCollection } from '../../data-source/collection/CollectionProvider';
import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin';
export type Collection_deprecated = ReturnType<typeof useCollection_deprecated>; export type Collection_deprecated = ReturnType<typeof useCollection_deprecated>;

View File

@ -1,5 +1,6 @@
import { render, screen, waitFor } from '@tachybase/test/client';
import React from 'react'; import React from 'react';
import { render, screen, waitFor } from '@tachybase/test/client';
import { CurrentAppInfoContext } from '../../../appInfo'; import { CurrentAppInfoContext } from '../../../appInfo';
import { Checkbox } from '../../../schema-component/antd/checkbox'; import { Checkbox } from '../../../schema-component/antd/checkbox';
import { Input } from '../../../schema-component/antd/input'; import { Input } from '../../../schema-component/antd/input';

View File

@ -1,4 +1,5 @@
import { ISchema } from '@tachybase/schema'; import { ISchema } from '@tachybase/schema';
import { defaultProps, operators } from '../'; import { defaultProps, operators } from '../';
import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface'; import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface';

Some files were not shown because too many files have changed in this diff Show More