From a1ab08efaef901b99a2821c0baccecd0be4b077b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Kochen?= Date: Sun, 29 Oct 2023 13:39:57 +0100 Subject: [PATCH] Upgrade prettier --- package.json | 2 +- src/FetchOneCommand.ts | 4 ++-- src/InjectBuildCommand.ts | 18 ++++++++-------- src/InstallBinCommand.ts | 18 ++++++++-------- src/generate.ts | 44 +++++++++++++++++++-------------------- src/nixUtils.ts | 2 +- src/textUtils.ts | 4 ++-- yarn.lock | 12 +++++------ 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/package.json b/package.json index 570dc92..fec4507 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@yarnpkg/plugin-pnp": "^3.1.0", "babel-loader": "^8.1.0", "clipanion": "^3.0.0", - "prettier": "2.5.1", + "prettier": "3.0.3", "raw-loader": "^4.0.1", "typescript": "4.5.4", "webpack": "^5.35.0", diff --git a/src/FetchOneCommand.ts b/src/FetchOneCommand.ts index bec61dd..3dd05a5 100644 --- a/src/FetchOneCommand.ts +++ b/src/FetchOneCommand.ts @@ -18,7 +18,7 @@ export default class FetchOneCommand extends Command { async execute() { const configuration = await Configuration.find( this.context.cwd, - this.context.plugins + this.context.plugins, ); const { project } = await Project.find(configuration, this.context.cwd); const cache = await Cache.find(configuration); @@ -42,7 +42,7 @@ export default class FetchOneCommand extends Command { fetcher, report, }); - } + }, ); return report.exitCode(); diff --git a/src/InjectBuildCommand.ts b/src/InjectBuildCommand.ts index 6317ecd..b3e6c34 100644 --- a/src/InjectBuildCommand.ts +++ b/src/InjectBuildCommand.ts @@ -23,7 +23,7 @@ export default class InjectBuildCommand extends Command { async execute() { const configuration = await Configuration.find( this.context.cwd, - this.context.plugins + this.context.plugins, ); const { project } = await Project.find(configuration, this.context.cwd); @@ -48,7 +48,7 @@ export default class InjectBuildCommand extends Command { // the read-only permissions of our source path in the Nix store. const installLocation = ppath.join( project.cwd, - this.installLocation as PortablePath + this.installLocation as PortablePath, ); await xfs.mkdirpPromise(ppath.dirname(installLocation)); await execUtils.execvp("cp", ["-R", this.source, installLocation], { @@ -72,7 +72,7 @@ export default class InjectBuildCommand extends Command { (data: Buffer | string) => { globalHashGenerator.update(`\0`); globalHashGenerator.update(data); - } + }, ); const globalHash = globalHashGenerator.digest(`hex`); @@ -86,7 +86,7 @@ export default class InjectBuildCommand extends Command { const pkg = project.storedPackages.get(locator.locatorHash); if (typeof pkg === `undefined`) throw new Error( - `Assertion failed: The package should have been registered` + `Assertion failed: The package should have been registered`, ); const builder = createHash(`sha512`); @@ -97,20 +97,20 @@ export default class InjectBuildCommand extends Command { for (const descriptor of pkg.dependencies.values()) { const resolution = project.storedResolutions.get( - descriptor.descriptorHash + descriptor.descriptorHash, ); if (typeof resolution === `undefined`) throw new Error( `Assertion failed: The resolution (${structUtils.prettyDescriptor( project.configuration, - descriptor - )}) should have been registered` + descriptor, + )}) should have been registered`, ); const dependency = project.storedPackages.get(resolution); if (typeof dependency === `undefined`) throw new Error( - `Assertion failed: The package should have been registered` + `Assertion failed: The package should have been registered`, ); builder.update(getBaseHash(dependency)); @@ -133,7 +133,7 @@ export default class InjectBuildCommand extends Command { // `yarn install` later, which should clean it up again. project.storedBuildState.set(pkg.locatorHash, buildHash); await project.persistInstallStateFile(); - } + }, ); return report.exitCode(); diff --git a/src/InstallBinCommand.ts b/src/InstallBinCommand.ts index 5020a58..e0a3377 100644 --- a/src/InstallBinCommand.ts +++ b/src/InstallBinCommand.ts @@ -24,11 +24,11 @@ export default class InstallBinCommand extends Command { async execute() { const configuration = await Configuration.find( this.context.cwd, - this.context.plugins + this.context.plugins, ); const { project, workspace } = await Project.find( configuration, - this.context.cwd + this.context.cwd, ); const report = await StreamReport.start( @@ -44,7 +44,7 @@ export default class InstallBinCommand extends Command { const wrapperPath = ppath.join(binDir, name as Filename); const binaryPath = ppath.join( project.cwd, - npath.toPortablePath(binaryFile) + npath.toPortablePath(binaryFile), ); await this.writeWrapper(wrapperPath, binaryPath, { configuration, @@ -56,18 +56,18 @@ export default class InstallBinCommand extends Command { await project.resolveEverything({ report, lockfileOnly: true }); const binaries = await scriptUtils.getPackageAccessibleBinaries( project.topLevelWorkspace.anchoredLocator, - { project } + { project }, ); for (const [name, [_, binaryPath]] of binaries.entries()) { const wrapperPath = ppath.join(binDir, name as Filename); await this.writeWrapper( wrapperPath, npath.toPortablePath(binaryPath), - { configuration, project } + { configuration, project }, ); } } - } + }, ); return report.exitCode(); @@ -79,7 +79,7 @@ export default class InstallBinCommand extends Command { { configuration, project, - }: { configuration: Configuration; project: Project } + }: { configuration: Configuration; project: Project }, ) { let wrapper; switch (configuration.get(`nodeLinker`)) { @@ -88,14 +88,14 @@ export default class InstallBinCommand extends Command { const nodeOptions = []; if (await xfs.existsPromise(pnpPath.cjs)) { nodeOptions.push( - `--require "${npath.fromPortablePath(pnpPath.cjs)}"` + `--require "${npath.fromPortablePath(pnpPath.cjs)}"`, ); } if (await xfs.existsPromise(pnpPath.esmLoader)) { nodeOptions.push( `--experimental-loader "${ pathToFileURL(npath.fromPortablePath(pnpPath.esmLoader)).href - }"` + }"`, ); } wrapper = renderTmpl(binWrapperPnpTmpl, { diff --git a/src/generate.ts b/src/generate.ts index 65e8e68..7a64dce 100644 --- a/src/generate.ts +++ b/src/generate.ts @@ -25,7 +25,7 @@ import { tmpdir } from "os"; // Generator function that runs after `yarn install`. export default async ( project: Project, - opts: { cache: Cache; report: Report; mode?: InstallMode } + opts: { cache: Cache; report: Report; mode?: InstallMode }, ) => { const { configuration, cwd } = project; const { cache, report } = opts; @@ -40,7 +40,7 @@ export default async ( if (project.cwd.startsWith(tempDir)) { report.reportInfo( 0, - `Skipping Nixify, because ${project.cwd} appears to be a temporary directory` + `Skipping Nixify, because ${project.cwd} appears to be a temporary directory`, ); return; } @@ -57,7 +57,7 @@ export default async ( yarnPathExpr = json(yarnPathAbs); report.reportWarning( 0, - `The Yarn path ${yarnPathAbs} is outside the project - it may not be reachable by the Nix build` + `The Yarn path ${yarnPathAbs} is outside the project - it may not be reachable by the Nix build`, ); } @@ -67,7 +67,7 @@ export default async ( cacheFolderExpr = json(ppath.relative(cwd, cacheFolderAbs)); } else { throw Error( - `The cache folder ${cacheFolderAbs} is outside the project, this is currently not supported` + `The cache folder ${cacheFolderAbs} is outside the project, this is currently not supported`, ); } @@ -84,7 +84,7 @@ export default async ( if (!relativeSource.startsWith(cwd)) { report.reportWarning( 0, - `The config file ${source} is outside the project - it may not be reachable by the Nix build` + `The config file ${source} is outside the project - it may not be reachable by the Nix build`, ); } } @@ -93,7 +93,7 @@ export default async ( "./" + ppath.relative( ppath.dirname(nixExprPath), - ppath.resolve(cwd, 'yarn.lock' as PortablePath) + ppath.resolve(cwd, "yarn.lock" as PortablePath), ); // Build a list of cache entries so Nix can fetch them. @@ -149,11 +149,11 @@ export default async ( if (structUtils.isVirtualLocator(pkg)) { const devirtPkg = project.storedPackages.get( - structUtils.devirtualizeLocator(pkg).locatorHash + structUtils.devirtualizeLocator(pkg).locatorHash, ); if (!devirtPkg) { throw Error( - `Assertion failed: The locator should have been registered` + `Assertion failed: The locator should have been registered`, ); } @@ -162,11 +162,11 @@ export default async ( if (pkg.reference.startsWith("patch:")) { const depatchPkg = project.storedPackages.get( - patchUtils.parseLocator(pkg).sourceLocator.locatorHash + patchUtils.parseLocator(pkg).sourceLocator.locatorHash, ); if (!depatchPkg) { throw Error( - `Assertion failed: The locator should have been registered` + `Assertion failed: The locator should have been registered`, ); } @@ -175,18 +175,18 @@ export default async ( for (const dependency of pkg.dependencies.values()) { const resolution = project.storedResolutions.get( - dependency.descriptorHash + dependency.descriptorHash, ); if (!resolution) { throw Error( - "Assertion failed: The descriptor should have been registered" + "Assertion failed: The descriptor should have been registered", ); } const depPkg = project.storedPackages.get(resolution); if (!depPkg) { throw Error( - `Assertion failed: The locator should have been registered` + `Assertion failed: The locator should have been registered`, ); } @@ -217,13 +217,13 @@ export default async ( ppath.join( pnpUnpluggedFolder, structUtils.slugifyLocator(pkg), - structUtils.getIdentVendorPath(pkg) - ) + structUtils.getIdentVendorPath(pkg), + ), ); break; default: throw Error( - `The nodeLinker ${nodeLinker} is not supported for isolated Nix builds` + `The nodeLinker ${nodeLinker} is not supported for isolated Nix builds`, ); } @@ -236,7 +236,7 @@ export default async ( const pkg = project.storedPackages.get(locatorHash); if (!pkg) { throw Error( - `Assertion failed: The locator should have been registered` + `Assertion failed: The locator should have been registered`, ); } devirtPkg = pkg; @@ -261,7 +261,7 @@ export default async ( `version = ${json(pkg.version)};`, `reference = ${json(devirtPkg.reference)};`, `locators = [\n${locators}];`, - ].join(` `)} });` + ].join(` `)} });`, ); } @@ -273,7 +273,7 @@ export default async ( `yarn nixify inject-build \\`, ` ${json(injectLocatorStr)} \\`, ` $\{${isolatedProp}} \\`, - ` ${json(installLocation)}` + ` ${json(installLocation)}`, ); } if (isolatedIntegration.length > 0) { @@ -308,7 +308,7 @@ export default async ( await xfs.writeFilePromise(defaultExprPath, defaultExprTmpl); report.reportInfo( 0, - `A minimal default.nix was created. You may want to customize it.` + `A minimal default.nix was created. You may want to customize it.`, ); } } @@ -355,13 +355,13 @@ export default async ( { cwd: project.cwd, strict: true, - } + }, ); } if (numToPreload !== 0) { report.reportInfo( 0, - `Preloaded ${numToPreload} packages into the Nix store` + `Preloaded ${numToPreload} packages into the Nix store`, ); } } catch (err: any) { diff --git a/src/nixUtils.ts b/src/nixUtils.ts index 9fee708..fcf4a9c 100644 --- a/src/nixUtils.ts +++ b/src/nixUtils.ts @@ -46,7 +46,7 @@ export const computeFixedOutputStorePath = ( name: string, hashAlgorithm: string, hash: Buffer, - storePath = `/nix/store` as PortablePath + storePath = `/nix/store` as PortablePath, ) => { const hashHex = hash.toString("hex"); diff --git a/src/textUtils.ts b/src/textUtils.ts index 5b6f935..2491309 100644 --- a/src/textUtils.ts +++ b/src/textUtils.ts @@ -24,7 +24,7 @@ export const upperCamelize = (name: string) => export const indent = ( prefix: string, text: string, - includeEmptyLines = false + includeEmptyLines = false, ): string => text .split("\n") @@ -41,7 +41,7 @@ export const indent = ( */ export const renderTmpl = ( tmpl: string, - vars: { [name: string]: string | boolean } + vars: { [name: string]: string | boolean }, ): string => { let result = tmpl; for (const [name, value] of Object.entries(vars)) { diff --git a/yarn.lock b/yarn.lock index 57b872f..af085ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2654,12 +2654,12 @@ __metadata: languageName: node linkType: hard -"prettier@npm:2.5.1": - version: 2.5.1 - resolution: "prettier@npm:2.5.1" +"prettier@npm:3.0.3": + version: 3.0.3 + resolution: "prettier@npm:3.0.3" bin: - prettier: bin-prettier.js - checksum: 21b9408476ea1c544b0e45d51ceb94a84789ff92095abb710942d780c862d0daebdb29972d47f6b4d0f7ebbfb0ffbf56cc2cfa3e3e9d1cca54864af185b15b66 + prettier: bin/prettier.cjs + checksum: e10b9af02b281f6c617362ebd2571b1d7fc9fb8a3bd17e371754428cda992e5e8d8b7a046e8f7d3e2da1dcd21aa001e2e3c797402ebb6111b5cd19609dd228e0 languageName: node linkType: hard @@ -3359,7 +3359,7 @@ __metadata: "@yarnpkg/plugin-pnp": ^3.1.0 babel-loader: ^8.1.0 clipanion: ^3.0.0 - prettier: 2.5.1 + prettier: 3.0.3 raw-loader: ^4.0.1 typescript: 4.5.4 webpack: ^5.35.0