chore: Resolve merge conflicts

This commit is contained in:
vben
2024-07-31 21:26:54 +08:00
parent 4074a88c13
commit 082847c441
44 changed files with 772 additions and 475 deletions

View File

@@ -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"
}
}

View File

@@ -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 [];
}
}

View File

@@ -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';

View File

@@ -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, {});

View 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();
}
}