Преглед изворни кода

Adds 3rd party licenses

main
Eric Amodio пре 3 година
родитељ
комит
f6355932b3
5 измењених фајлова са 1253 додато и 2 уклоњено
  1. +1143
    -0
      ThirdPartyNotices.txt
  2. +1
    -0
      package.json
  3. +107
    -0
      scripts/generateLicenses.js
  4. +1
    -1
      src/views/nodes/commitFileNode.ts
  5. +1
    -1
      src/views/nodes/fileRevisionAsCommitNode.ts

+ 1143
- 0
ThirdPartyNotices.txt
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 1
- 0
package.json Прегледај датотеку

@ -9694,6 +9694,7 @@
"update-dts": "pushd \"src/@types\" && npx vscode-dts dev && popd",
"update-dts:master": "pushd \"src/@types\" && npx vscode-dts master && popd",
"update-emoji": "node ./scripts/generateEmojiShortcodeMap.js",
"update-licenses": "node ./scripts/generateLicenses.js",
"vscode:prepublish": "yarn run bundle"
},
"dependencies": {

+ 107
- 0
scripts/generateLicenses.js Прегледај датотеку

@ -0,0 +1,107 @@
//@ts-check
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const fetch = require('node-fetch');
/** @typedef { { licenses: string; repository: string; licenseFile: string } } PackageInfo **/
/**
* @param { string } file
*/
async function generateThirdpartyNotices(file) {
file = path.join(process.cwd(), file);
const data = fs.readFileSync(file, 'utf8');
fs.rmSync(file);
/**
* @type { { [key: string]: PackageInfo } }
*/
const packages = JSON.parse(data);
// Add any packages used in directly in the code
/**
* @type [string, PackageInfo][]
*/
const codeOnlyPackages = [
[
'microsoft/vscode',
{
licenses: 'MIT',
repository: 'https://github.com/microsoft/vscode',
licenseFile: 'https://raw.github.com/microsoft/vscode/main/LICENSE.txt',
},
],
[
'chalk/ansi-regex',
{
licenses: 'MIT',
repository: 'https://github.com/chalk/ansi-regex',
licenseFile: 'https://raw.github.com/chalk/ansi-regex/main/license',
},
],
[
'sindresorhus/string-width',
{
licenses: 'MIT',
repository: 'https://github.com/sindresorhus/string-width',
licenseFile: 'https://raw.github.com/sindresorhus/string-width/main/license',
},
],
[
'sindresorhus/is-fullwidth-code-point',
{
licenses: 'MIT',
repository: 'https://github.com/sindresorhus/is-fullwidth-code-point',
licenseFile: 'https://raw.github.com/sindresorhus/is-fullwidth-code-point/main/license',
},
],
];
const packageOutputs = [];
const licenseOutputs = [];
let count = 0;
for (const [key, data] of Object.entries(packages).concat(codeOnlyPackages)) {
let name;
let version;
const index = key.lastIndexOf('@');
if (index !== -1) {
name = key.substr(0, index);
version = key.substr(index + 1);
} else {
name = key;
}
if (name === 'gitlens') continue;
let license;
if (data.licenseFile.startsWith('https://')) {
const response = await fetch(data.licenseFile);
license = await response.text();
} else {
license = fs.readFileSync(data.licenseFile, 'utf8');
}
packageOutputs.push(`${++count}. ${name}${version ? ` version ${version}` : ''} (${data.repository})`);
licenseOutputs.push(
`\n%% ${name} NOTICES AND INFORMATION BEGIN HERE\n=========================================\n${license}\n=========================================\nEND OF ${name} NOTICES AND INFORMATION`,
);
}
const content = `GitLens\n\nTHIRD-PARTY SOFTWARE NOTICES AND INFORMATION\nThis project incorporates components from the projects listed below.\n\n${packageOutputs.join(
'\n',
)}\n${licenseOutputs.join('\n')}`;
fs.writeFileSync(path.join(process.cwd(), 'ThirdPartyNotices.txt'), content, 'utf8');
}
async function generate() {
await exec('npx license-checker --json --production --relativeLicensePath > thirdparty.json');
void generateThirdpartyNotices('thirdparty.json');
}
void generate();

+ 1
- 1
src/views/nodes/commitFileNode.ts Прегледај датотеку

@ -46,7 +46,7 @@ export class CommitFileNode
async getTreeItem(): Promise<TreeItem> {
if (!this.commit.isFile) {
// See if we can get the commit directly from the multi-file commit
// Try to get the commit directly from the multi-file commit
const commit = this.commit.toFileCommit(this.file);
if (commit == null) {
const log = await Container.git.getLogForFile(this.repoPath, this.file.fileName, {

+ 1
- 1
src/views/nodes/fileRevisionAsCommitNode.ts Прегледај датотеку

@ -84,7 +84,7 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode
async getTreeItem(): Promise<TreeItem> {
if (!this.commit.isFile) {
// See if we can get the commit directly from the multi-file commit
// Try to get the commit directly from the multi-file commit
const commit = this.commit.toFileCommit(this.file);
if (commit == null) {
const log = await Container.git.getLogForFile(this.repoPath, this.file.fileName, {

Loading…
Откажи
Сачувај