parent
fbe0fc1738
commit
e68e1b40ce
@ -1,16 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import { preferences } from '@vben-core/preferences';
|
||||
import { Toaster } from '@vben-core/shadcn-ui';
|
||||
|
||||
import { CozeAssistant } from '../coze-assistant';
|
||||
|
||||
interface Props {
|
||||
enableAiAssistant?: boolean;
|
||||
isMobile?: boolean;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'GlobalProvider' });
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
enableAiAssistant: false,
|
||||
isMobile: false,
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<Toaster />
|
||||
<CozeAssistant
|
||||
v-if="preferences.app.aiAssistant"
|
||||
:is-mobile="preferences.app.isMobile"
|
||||
/>
|
||||
<CozeAssistant v-if="enableAiAssistant" :is-mobile="isMobile" />
|
||||
<slot></slot>
|
||||
</template>
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
import type { CAC } from 'cac';
|
||||
|
||||
import { extname } from 'node:path';
|
||||
|
||||
import { getStagedFiles } from '@vben/node-utils';
|
||||
|
||||
import { circularDepsDetect, printCircles } from 'circular-dependency-scanner';
|
||||
|
||||
const IGNORE_DIR = [
|
||||
'dist',
|
||||
'.turbo',
|
||||
'output',
|
||||
'.cache',
|
||||
'scripts',
|
||||
'internal',
|
||||
// 'packages/@vben-core/shared/shadcn-ui/',
|
||||
'packages/@vben-core/ui-kit/menu-ui/src/',
|
||||
].join(',');
|
||||
|
||||
const IGNORE = [`**/{${IGNORE_DIR}}/**`];
|
||||
|
||||
interface CommandOptions {
|
||||
staged: boolean;
|
||||
verbose: boolean;
|
||||
}
|
||||
|
||||
async function checkCircular({ staged, verbose }: CommandOptions) {
|
||||
const results = await circularDepsDetect({
|
||||
absolute: staged,
|
||||
cwd: process.cwd(),
|
||||
ignore: IGNORE,
|
||||
});
|
||||
|
||||
if (staged) {
|
||||
let files = await getStagedFiles();
|
||||
|
||||
files = files.filter((file) =>
|
||||
['.cjs', '.js', '.jsx', '.mjs', '.ts', '.tsx', '.vue'].includes(
|
||||
extname(file),
|
||||
),
|
||||
);
|
||||
const circularFiles: string[][] = [];
|
||||
|
||||
for (const file of files) {
|
||||
for (const result of results) {
|
||||
const resultFiles = result.flat();
|
||||
if (resultFiles.includes(file)) {
|
||||
circularFiles.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
verbose && printCircles(circularFiles);
|
||||
} else {
|
||||
verbose && printCircles(results);
|
||||
}
|
||||
}
|
||||
|
||||
function defineCheckCircularCommand(cac: CAC) {
|
||||
cac
|
||||
.command('check-circular')
|
||||
.option(
|
||||
'--staged',
|
||||
'Whether it is the staged commit mode, in which mode, if there is a circular dependency, an alarm will be given.',
|
||||
)
|
||||
.usage(`Analysis of project circular dependencies.`)
|
||||
.action(async ({ staged }) => {
|
||||
await checkCircular({ staged, verbose: true });
|
||||
});
|
||||
}
|
||||
|
||||
export { defineCheckCircularCommand };
|
||||
Loading…
Reference in new issue