diff --git a/.pnp.cjs b/.pnp.cjs index f86d6d5b5f87..55897a695929 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -9521,6 +9521,7 @@ const RAW_RUNTIME_STATE = "packageLocation": "./packages/yarnpkg-fslib/",\ "packageDependencies": [\ ["@yarnpkg/fslib", "workspace:packages/yarnpkg-fslib"],\ + ["@iarna/toml", "npm:2.2.5"],\ ["@yarnpkg/libzip", "virtual:b73ceab179a3b4f89c4a5be81bd0c20a80eda623489cb284f304cc8104dbb771916bbc246d0ba809faebd8459cb6554cf114954badb021279ea7aee216456122#workspace:packages/yarnpkg-libzip"],\ ["tslib", "npm:2.6.2"]\ ],\ diff --git a/.yarn/versions/30105cf3.yml b/.yarn/versions/30105cf3.yml new file mode 100644 index 000000000000..d648e285cff4 --- /dev/null +++ b/.yarn/versions/30105cf3.yml @@ -0,0 +1,36 @@ +releases: + "@yarnpkg/fslib": minor + "@yarnpkg/sdks": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - vscode-zipfs + - "@yarnpkg/builder" + - "@yarnpkg/cli" + - "@yarnpkg/core" + - "@yarnpkg/doctor" + - "@yarnpkg/libzip" + - "@yarnpkg/nm" + - "@yarnpkg/pnp" + - "@yarnpkg/pnpify" + - "@yarnpkg/shell" diff --git a/packages/yarnpkg-fslib/package.json b/packages/yarnpkg-fslib/package.json index 873bfb5777a9..a325e8ea46be 100644 --- a/packages/yarnpkg-fslib/package.json +++ b/packages/yarnpkg-fslib/package.json @@ -9,6 +9,7 @@ }, "sideEffects": false, "dependencies": { + "@iarna/toml": "^2.2.5", "tslib": "^2.4.0" }, "devDependencies": { diff --git a/packages/yarnpkg-fslib/sources/FakeFS.ts b/packages/yarnpkg-fslib/sources/FakeFS.ts index 27ccfc8eebbb..8a589843dd7b 100644 --- a/packages/yarnpkg-fslib/sources/FakeFS.ts +++ b/packages/yarnpkg-fslib/sources/FakeFS.ts @@ -1,3 +1,4 @@ +import {stringify as tomlStringify} from '@iarna/toml'; import {createHash} from 'crypto'; import {EventEmitter} from 'events'; import {Dirent as NodeDirent, ReadStream} from 'fs'; @@ -767,6 +768,14 @@ export abstract class FakeFS

{ return this.writeFileSync(p, `${JSON.stringify(data, null, space)}\n`); } + async writeTomlPromise(p: P, data: any) { + return await this.writeFilePromise(p, tomlStringify(data)); + } + + writeTomlSync(p: P, data: any) { + return this.writeFileSync(p, tomlStringify(data)); + } + async preserveTimePromise(p: P, cb: () => Promise

) { const stat = await this.lstatPromise(p); diff --git a/packages/yarnpkg-fslib/sources/path.ts b/packages/yarnpkg-fslib/sources/path.ts index ec12897452b0..383439a54814 100644 --- a/packages/yarnpkg-fslib/sources/path.ts +++ b/packages/yarnpkg-fslib/sources/path.ts @@ -33,6 +33,7 @@ export const Filename = { pnpEsmLoader: `.pnp.loader.mjs` as Filename, rc: `.yarnrc.yml` as Filename, env: `.env` as Filename, + reuseToml: `REUSE.toml` as Filename, }; export type TolerateLiterals = { diff --git a/packages/yarnpkg-sdks/sources/generateSdk.ts b/packages/yarnpkg-sdks/sources/generateSdk.ts index 7a64a65ea6f2..f607802c104b 100644 --- a/packages/yarnpkg-sdks/sources/generateSdk.ts +++ b/packages/yarnpkg-sdks/sources/generateSdk.ts @@ -117,6 +117,11 @@ type TemplateOptions = { const TEMPLATE = (relPnpApiPath: PortablePath, module: string, {setupEnv = false, usePnpify = false, wrapModule}: TemplateOptions) => [ `#!/usr/bin/env node\n`, `\n`, + // REUSE-IgnoreStart + `// SPDX-FileCopyrightText: 2016-present Yarn Contributors\n`, + `// SPDX-License-Identifier: BSD-2-Clause\n`, + // REUSE-IgnoreEnd + `\n`, `const {existsSync} = require(\`fs\`);\n`, `const {createRequire, register} = require(\`module\`);\n`, `const {resolve} = require(\`path\`);\n`, @@ -272,6 +277,7 @@ export class Wrapper { await this.writePackageBinaries(); await this.writeManifest(); + await this.writeReuseToml(); } async writePackageBinaries() { @@ -319,6 +325,39 @@ export class Wrapper { this.paths.set(Filename.manifest, relProjectPath); } + async writeReuseToml() { + const topLevelInformation = this.pnpApi.getPackageInformation(this.pnpApi.topLevel)!; + const projectRoot = npath.toPortablePath(topLevelInformation.packageLocation); + + const absWrapperPath = ppath.join(this.target, this.name, `REUSE.toml`); + const relProjectPath = ppath.relative(projectRoot, absWrapperPath); + + await xfs.mkdirPromise(ppath.dirname(absWrapperPath), {recursive: true}); + + const object = { + version: 1, + annotations: [ + { + path: [ + `package.json`, + ], + precedence: `closest`, + // REUSE-IgnoreStart + 'SPDX-FileCopyrightText': [ + `2016-present Yarn Contributors`, + ], + 'SPDX-License-Identifier': [ + `BSD-2-Clause`, + ], + // REUSE-IgnoreEnd + }, + ], + }; + await xfs.writeTomlPromise(absWrapperPath, object); + + this.paths.set(Filename.reuseToml, relProjectPath); + } + async writeBinary(relPackagePath: PortablePath, options: TemplateOptions & {requirePath?: PortablePath} = {}) { await this.writeFile(relPackagePath, {...options, mode: 0o755}); } diff --git a/yarn.lock b/yarn.lock index 715c4570f200..f9d2fb0e096c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5682,6 +5682,7 @@ __metadata: version: 0.0.0-use.local resolution: "@yarnpkg/fslib@workspace:packages/yarnpkg-fslib" dependencies: + "@iarna/toml": "npm:^2.2.5" "@yarnpkg/libzip": "workspace:^" tslib: "npm:^2.4.0" languageName: unknown