mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 00:39:20 +08:00
update: 升级vben5.5.9到5.7.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import dayjs from 'dayjs';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import timezone from 'dayjs/plugin/timezone.js';
|
||||
import utc from 'dayjs/plugin/utc.js';
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
import { execa } from 'execa';
|
||||
|
||||
async function formatFile(filepath: string) {
|
||||
await execa('oxfmt', [filepath], {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
return await fs.readFile(filepath, 'utf8');
|
||||
}
|
||||
|
||||
export { formatFile };
|
||||
@@ -1,12 +1,12 @@
|
||||
export * from './constants';
|
||||
export * from './date';
|
||||
export { formatFile } from './formatter';
|
||||
export * from './fs';
|
||||
export * from './git';
|
||||
export { getStagedFiles, add as gitAdd } from './git';
|
||||
export { generatorContentHash } from './hash';
|
||||
export * from './monorepo';
|
||||
export { toPosixPath } from './path';
|
||||
export { prettierFormat } from './prettier';
|
||||
export * from './spinner';
|
||||
export type { Package } from '@manypkg/get-packages';
|
||||
export { default as colors } from 'chalk';
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
import { dirname } from 'node:path';
|
||||
import type { Package } from '@manypkg/get-packages';
|
||||
|
||||
import {
|
||||
getPackages as getPackagesFunc,
|
||||
getPackagesSync as getPackagesSyncFunc,
|
||||
} from '@manypkg/get-packages';
|
||||
import { findUpSync } from 'find-up';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
|
||||
import * as manypkg from '@manypkg/get-packages';
|
||||
const { getPackages: getPackagesFunc, getPackagesSync: getPackagesSyncFunc } =
|
||||
manypkg;
|
||||
|
||||
/**
|
||||
* 查找大仓的根目录
|
||||
* @param cwd
|
||||
*/
|
||||
function findMonorepoRoot(cwd: string = process.cwd()) {
|
||||
const lockFile = findUpSync('pnpm-lock.yaml', {
|
||||
cwd,
|
||||
type: 'file',
|
||||
});
|
||||
return dirname(lockFile || '');
|
||||
let currentDir = resolve(cwd);
|
||||
|
||||
while (true) {
|
||||
if (existsSync(join(currentDir, 'pnpm-lock.yaml'))) {
|
||||
return currentDir;
|
||||
}
|
||||
|
||||
const parentDir = dirname(currentDir);
|
||||
if (parentDir === currentDir) {
|
||||
return '';
|
||||
}
|
||||
|
||||
currentDir = parentDir;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +50,7 @@ async function getPackages() {
|
||||
*/
|
||||
async function getPackage(pkgName: string) {
|
||||
const { packages } = await getPackages();
|
||||
return packages.find((pkg) => pkg.packageJson.name === pkgName);
|
||||
return packages.find((pkg: Package) => pkg.packageJson.name === pkgName);
|
||||
}
|
||||
|
||||
export { findMonorepoRoot, getPackage, getPackages, getPackagesSync };
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
import { format, getFileInfo, resolveConfig } from 'prettier';
|
||||
|
||||
async function prettierFormat(filepath: string) {
|
||||
const prettierOptions = await resolveConfig(filepath, {});
|
||||
|
||||
const fileInfo = await getFileInfo(filepath);
|
||||
|
||||
const input = await fs.readFile(filepath, 'utf8');
|
||||
const output = await format(input, {
|
||||
...prettierOptions,
|
||||
parser: fileInfo.inferredParser as any,
|
||||
});
|
||||
if (output !== input) {
|
||||
await fs.writeFile(filepath, output, 'utf8');
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
export { prettierFormat };
|
||||
Reference in New Issue
Block a user