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 all commits
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
1 change: 1 addition & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .yarn/versions/30105cf3.yml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions packages/yarnpkg-fslib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"sideEffects": false,
"dependencies": {
"@iarna/toml": "^2.2.5",
"tslib": "^2.4.0"
},
"devDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions packages/yarnpkg-fslib/sources/FakeFS.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -767,6 +768,14 @@ export abstract class FakeFS<P extends Path> {
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<P | void>) {
const stat = await this.lstatPromise(p);

Expand Down
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
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading