chore: Resolve merge conflicts
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint-config-turbo": "^2.0.9",
|
||||
"eslint-config-turbo": "^2.0.10",
|
||||
"eslint-plugin-command": "^0.2.3",
|
||||
"eslint-plugin-import-x": "^3.1.0"
|
||||
},
|
||||
@@ -39,7 +39,7 @@
|
||||
"eslint": "^9.8.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-jsdoc": "^48.10.1",
|
||||
"eslint-plugin-jsdoc": "^48.10.2",
|
||||
"eslint-plugin-jsonc": "^2.16.0",
|
||||
"eslint-plugin-n": "^17.10.1",
|
||||
"eslint-plugin-no-only-tests": "^3.1.0",
|
||||
|
@@ -30,13 +30,20 @@
|
||||
"dependencies": {
|
||||
"@changesets/git": "^3.0.0",
|
||||
"@manypkg/get-packages": "^2.2.2",
|
||||
"chalk": "^5.3.0",
|
||||
"consola": "^3.2.3",
|
||||
"dayjs": "^1.11.12",
|
||||
"execa": "^9.3.0",
|
||||
"find-up": "^7.0.0",
|
||||
"fs-extra": "^11.2.0",
|
||||
"nanoid": "^5.0.7",
|
||||
"ora": "^8.0.1",
|
||||
"pkg-types": "^1.1.3",
|
||||
"prettier": "^3.3.3",
|
||||
"rimraf": "^6.0.1",
|
||||
"zx": "^8.1.4"
|
||||
"rimraf": "^6.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chalk": "^2.2.0",
|
||||
"@types/fs-extra": "^11.0.4"
|
||||
}
|
||||
}
|
||||
|
@@ -1,24 +1,32 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import { $ } from 'zx';
|
||||
import { execa } from 'execa';
|
||||
|
||||
export * from '@changesets/git';
|
||||
|
||||
/**
|
||||
* 获取暂存区文件
|
||||
*/
|
||||
async function getStagedFiles() {
|
||||
async function getStagedFiles(): Promise<string[]> {
|
||||
try {
|
||||
$.verbose = false;
|
||||
const { stdout: lines } =
|
||||
await $`git -c submodule.recurse=false diff --staged --diff-filter=ACMR --name-only --ignore-submodules -z`;
|
||||
const { stdout } = await execa('git', [
|
||||
'-c',
|
||||
'submodule.recurse=false',
|
||||
'diff',
|
||||
'--staged',
|
||||
'--diff-filter=ACMR',
|
||||
'--name-only',
|
||||
'--ignore-submodules',
|
||||
'-z',
|
||||
]);
|
||||
|
||||
let changedList = lines ? lines.replace(/\0$/, '').split('\0') : [];
|
||||
let changedList = stdout ? stdout.replace(/\0$/, '').split('\0') : [];
|
||||
changedList = changedList.map((item) => path.resolve(process.cwd(), item));
|
||||
const changedSet = new Set(changedList);
|
||||
changedSet.delete('');
|
||||
return [...changedSet];
|
||||
} catch {
|
||||
} catch (error) {
|
||||
console.error('Failed to get staged files:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@@ -6,9 +6,12 @@ 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';
|
||||
export { consola } from 'consola';
|
||||
export * from 'execa';
|
||||
export { default as fs } from 'fs-extra';
|
||||
export { nanoid } from 'nanoid';
|
||||
export { type PackageJson, readPackageJSON } from 'pkg-types';
|
||||
export { rimraf } from 'rimraf';
|
||||
export { $, chalk as colors, fs, spinner } from 'zx';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import fs from 'fs-extra';
|
||||
import { format, getFileInfo, resolveConfig } from 'prettier';
|
||||
import { fs } from 'zx';
|
||||
|
||||
async function prettierFormat(filepath: string) {
|
||||
const prettierOptions = await resolveConfig(filepath, {});
|
||||
|
24
internal/node-utils/src/spinner.ts
Normal file
24
internal/node-utils/src/spinner.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import ora, { Ora } from 'ora';
|
||||
|
||||
interface SpinnerOptions {
|
||||
failedText?: string;
|
||||
successText?: string;
|
||||
title: string;
|
||||
}
|
||||
export async function spinner<T>(
|
||||
{ failedText, successText, title }: SpinnerOptions,
|
||||
callback: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
const loading: Ora = ora(title).start();
|
||||
|
||||
try {
|
||||
const result = await callback();
|
||||
loading.succeed(successText || 'Success!');
|
||||
return result;
|
||||
} catch (error) {
|
||||
loading.fail(failedText || 'Failed!');
|
||||
throw error;
|
||||
} finally {
|
||||
loading.stop();
|
||||
}
|
||||
}
|
@@ -32,7 +32,6 @@
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"html-minifier-terser": "^7.2.0",
|
||||
"nitropack": "^2.9.7",
|
||||
"portfinder": "^1.0.32",
|
||||
"resolve.exports": "^2.0.2",
|
||||
"vite-plugin-lib-inject-css": "^2.1.1",
|
||||
"vite-plugin-pwa": "^0.20.1",
|
||||
|
@@ -5,7 +5,6 @@ import type { NitroMockPluginOptions } from '../typing';
|
||||
import { colors, consola, getPackage } from '@vben/node-utils';
|
||||
|
||||
import { build, createDevServer, createNitro, prepare } from 'nitropack';
|
||||
import portfinder from 'portfinder';
|
||||
|
||||
const hmrKeyRe = /^runtimeConfig\.|routeRules\./;
|
||||
|
||||
@@ -78,11 +77,6 @@ async function runNitroServer(rootDir: string, port: number, verbose: boolean) {
|
||||
nitro.hooks.hookOnce('restart', reload);
|
||||
|
||||
const server = createDevServer(nitro);
|
||||
// 端口已经存在
|
||||
const availablePort = await portfinder.getPortPromise({ port });
|
||||
if (availablePort !== port) {
|
||||
return;
|
||||
}
|
||||
await server.listen(port, { showURL: false });
|
||||
await prepare(nitro);
|
||||
await build(nitro);
|
||||
@@ -92,5 +86,5 @@ async function runNitroServer(rootDir: string, port: number, verbose: boolean) {
|
||||
consola.success(colors.bold(colors.green('Nitro Mock Server started.')));
|
||||
}
|
||||
};
|
||||
await reload();
|
||||
return await reload();
|
||||
}
|
||||
|
Reference in New Issue
Block a user