From 0a505911176672137bda6c5321e850c0a0389425 Mon Sep 17 00:00:00 2001 From: DavidJones Date: Wed, 21 Feb 2024 22:56:46 +0800 Subject: [PATCH] fix: crlf to lf --- .prettierrc.js | 17 ++++++++++------- @cli/tidy-cli/src/actions/deps.ts | 3 ++- .../feature-readme/src/helper/dependencies.ts | 6 +++++- .../finder/findWorkspaceProject.spec.ts | 4 +++- .../cdn-upload-webpack-plugin/src/index.ts | 8 +++++--- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.prettierrc.js b/.prettierrc.js index 466e2fa7..d0383637 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,16 +1,19 @@ +/** @type {import('prettier').Config} */ module.exports = { - /** 一行的字符数, 如果超过会进行换行 */ + /** Compatible with Windows */ + endOfLine: 'lf', + /** The number of characters per line. If exceeded, a newline will be inserted. */ printWidth: 180, - /** 一个tab代表几个空格数 */ + /** The number of spaces per tab. */ tabWidth: 2, - /** 是否使用tab进行缩进 */ + /** Whether to use tabs for indentation. */ useTabs: false, - /** 字符串是否使用单引号 */ + /** Whether to use single quotes for strings. */ singleQuote: true, - /** 行位是否使用分号 */ + /** Whether to use semicolons at the end of lines. */ semi: false, - /** 是否使用尾逗号 */ + /** Whether to use trailing commas. */ trailingComma: 'es5', - /** 对象大括号直接是否有空格 */ + /** Whether to have spaces inside object braces. */ bracketSpacing: true, } diff --git a/@cli/tidy-cli/src/actions/deps.ts b/@cli/tidy-cli/src/actions/deps.ts index 46489cca..a9ad36be 100644 --- a/@cli/tidy-cli/src/actions/deps.ts +++ b/@cli/tidy-cli/src/actions/deps.ts @@ -109,7 +109,8 @@ export const tidyDeps = async (options?: TidyDepsOptions) => { */ if (missDependencies || missDevDependencies) { - await fs.writeFile(pkgJson, JSON.stringify(source, null, 2)) + const content = JSON.stringify(source, null, 2) + await fs.writeFile(pkgJson, content) } if (missDependencies) { diff --git a/@feature/feature-readme/src/helper/dependencies.ts b/@feature/feature-readme/src/helper/dependencies.ts index 327cd2cc..5ae1a23c 100644 --- a/@feature/feature-readme/src/helper/dependencies.ts +++ b/@feature/feature-readme/src/helper/dependencies.ts @@ -1,3 +1,4 @@ +import path from 'path' import { mapPathsToOrbitTree, stringifyOrbitTree } from '@dumlj/util-lib' import type { Context, TreeProject } from '../types' @@ -49,7 +50,10 @@ export function dependencies(context: Context) { } const { location, isPrivate } = project - const contentHTML = `${name}` + const posixLocation = location.split(path.sep).join('/') + const projectString = encodeURI(JSON.stringify({ ...project, location: posixLocation })) + const hrefAttr = url ? `href="${url}/tree/main/${posixLocation}"` : '' + const contentHTML = `${name}` const extraHTML = isPrivate ? 'PRIVATE' : '' return `${orbit} ${contentHTML}${extraHTML}` }) diff --git a/@lib/util-lib/__tests__/finder/findWorkspaceProject.spec.ts b/@lib/util-lib/__tests__/finder/findWorkspaceProject.spec.ts index 6e67073a..09e00d4d 100644 --- a/@lib/util-lib/__tests__/finder/findWorkspaceProject.spec.ts +++ b/@lib/util-lib/__tests__/finder/findWorkspaceProject.spec.ts @@ -188,6 +188,8 @@ describe('finder/findWorkspaceProject', () => { pattern: ['packages/*'], cwd: '', }) - ).rejects.toThrow(`The project name package-a is duplicated in the workspace.\n - ${path.join('packages/package-b/package.json')}\n - ${path.join('packages/package-a/package.json')}`) + ).rejects.toThrow( + `The project name package-a is duplicated in the workspace.\n - ${path.join('packages/package-b/package.json')}\n - ${path.join('packages/package-a/package.json')}` + ) }) }) diff --git a/@webpack-plugin/cdn-upload-webpack-plugin/src/index.ts b/@webpack-plugin/cdn-upload-webpack-plugin/src/index.ts index 3f61e82b..0264d5ee 100644 --- a/@webpack-plugin/cdn-upload-webpack-plugin/src/index.ts +++ b/@webpack-plugin/cdn-upload-webpack-plugin/src/index.ts @@ -133,9 +133,11 @@ export class CdnUploadWebpackPlugin extends SeedWebpackPlugin { compiler.hooks.thisCompilation.tap(this.pluginName, (compilation) => { compilation.hooks.afterProcessAssets.tap(this.pluginName, (compilationAssets) => { const entries = Object.entries(compilationAssets) - const assets = !Array.isArray(this.exclude) ? entries : entries.filter(([filePath]) => { - return !micromatch.isMatch(filePath, this.exclude!, { dot: true }) - }) + const assets = !Array.isArray(this.exclude) + ? entries + : entries.filter(([filePath]) => { + return !micromatch.isMatch(filePath, this.exclude!, { dot: true }) + }) if (!clients.length) { if (this.verbose) {