Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide licensing information according to REUSE Specification version 3.3 for generated editor SDK files #6637

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Provide licensing information according to REUSE Specification versio…
…n 3.3 for generated editor SDK files
  • Loading branch information
kalrish committed Dec 18, 2024
commit ed42eeee3401e43bb818670042e7b1f5c703743b
1 change: 1 addition & 0 deletions packages/yarnpkg-fslib/sources/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
Expand Down
39 changes: 39 additions & 0 deletions packages/yarnpkg-sdks/sources/generateSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down Expand Up @@ -272,6 +277,7 @@ export class Wrapper {
await this.writePackageBinaries();

await this.writeManifest();
await this.writeReuseToml();
}

async writePackageBinaries() {
Expand Down Expand Up @@ -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});
}
Expand Down