Generate ThirdPartyNotices.txt

This commit is contained in:
Nick Guerrera 2021-03-17 16:37:52 -07:00
Родитель e80311d9af
Коммит fe6bc05b7d
4 изменённых файлов: 328 добавлений и 1 удалений

Просмотреть файл

@ -10,3 +10,4 @@
!dist/**/*.js.map
!extension-shim.js
!README.md
!ThirdPartyNotices.txt

Просмотреть файл

@ -0,0 +1,186 @@
adl-vscode
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
Do Not Translate or Localize
This project incorporates components from the projects listed below. The
original copyright notices and the licenses under which Microsoft received such
components are set forth below. Microsoft reserves all rights not expressly
granted herein, whether by implication, estoppel or otherwise.
1. balanced-match version 1.0.0 (https://github.com/juliangruber/balanced-match)
2. brace-expansion version 1.1.11 (https://github.com/juliangruber/brace-expansion)
3. concat-map version 0.0.1 (https://github.com/substack/node-concat-map)
4. lru-cache version 6.0.0 (https://github.com/isaacs/node-lru-cache)
5. minimatch version 3.0.4 (https://github.com/isaacs/minimatch)
6. semver version 7.3.4 (https://github.com/npm/node-semver)
7. yallist version 4.0.0 (https://github.com/isaacs/yallist)
%% balanced-match NOTICES AND INFORMATION BEGIN HERE
=====================================================
(MIT)
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=====================================================");
END OF balanced-match NOTICES AND INFORMATION
%% brace-expansion NOTICES AND INFORMATION BEGIN HERE
=====================================================
MIT License
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=====================================================");
END OF brace-expansion NOTICES AND INFORMATION
%% concat-map NOTICES AND INFORMATION BEGIN HERE
=====================================================
This software is released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=====================================================");
END OF concat-map NOTICES AND INFORMATION
%% lru-cache NOTICES AND INFORMATION BEGIN HERE
=====================================================
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
=====================================================");
END OF lru-cache NOTICES AND INFORMATION
%% minimatch NOTICES AND INFORMATION BEGIN HERE
=====================================================
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
=====================================================");
END OF minimatch NOTICES AND INFORMATION
%% semver NOTICES AND INFORMATION BEGIN HERE
=====================================================
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
=====================================================");
END OF semver NOTICES AND INFORMATION
%% yallist NOTICES AND INFORMATION BEGIN HERE
=====================================================
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
=====================================================");
END OF yallist NOTICES AND INFORMATION

Просмотреть файл

@ -19,12 +19,17 @@
"categories": [
"Programming Languages"
],
"files": [
"adl-vscode-*.vsix",
"ThirdPartyNotices.txt"
],
"scripts": {
"build": "npm run compile && npm run generate-tmlanguage && npm run rollup && npm run package-vsix",
"build": "npm run compile && npm run generate-tmlanguage && npm run rollup && npm run generate-third-party-notices && npm run package-vsix",
"prepare": "npm run build",
"compile": "tsc -p .",
"watch": "tsc -p . --watch",
"generate-tmlanguage": "node dist-dev/adl.tmlanguage.js",
"generate-third-party-notices": "node scripts/generate-third-party-notices.js",
"rollup": "rollup --config --failAfterWarnings 2>&1",
"package-vsix": "vsce package --yarn",
"check-format": "prettier --list-different --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"**/*.{ts,js,json}\"",

Просмотреть файл

@ -0,0 +1,135 @@
const { join, dirname, basename, resolve } = require("path");
const { promises } = require("fs");
const { readFile, writeFile, readdir, stat } = promises;
const skipDirs = new Set(["node_modules", "dist-dev"]);
main().catch((e) => console.error(e.stack));
async function main() {
const root = resolve("./");
const rootName = basename(root);
const packages = await findThirdPartyPackages();
const packageRoots = [...packages.keys()].sort();
let text = `${rootName}
THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
Do Not Translate or Localize
This project incorporates components from the projects listed below. The
original copyright notices and the licenses under which Microsoft received such
components are set forth below. Microsoft reserves all rights not expressly
granted herein, whether by implication, estoppel or otherwise.
`;
let i = 1;
for (const packageRoot of packageRoots) {
const package = packages.get(packageRoot);
const url = getUrl(package);
text += `\n${i++}. ${package.name} version ${package.version} (${url})`;
}
for (const packageRoot of packageRoots) {
const package = packages.get(packageRoot);
const license = await getLicense(packageRoot);
text += `\n\n
%% ${package.name} NOTICES AND INFORMATION BEGIN HERE
=====================================================
${license}
=====================================================");
END OF ${package.name} NOTICES AND INFORMATION`;
}
await writeFile("ThirdPartyNotices.txt", text);
}
async function findThirdPartyPackages() {
const root = resolve("./");
const rootName = basename(root);
const packages = new Map();
for await (const map of projectSourcemaps(root)) {
const contents = JSON.parse(await readFile(map, "utf-8"));
const sources = contents.sources;
for (const source of sources) {
const sourcePath = join(dirname(map), source);
const packageRoot = await getPackageRoot(sourcePath);
const package = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf-8"));
if (package.name === rootName || /microsoft/i.test(JSON.stringify(package.author))) {
continue;
}
if (!packages.has(packageRoot)) {
packages.set(packageRoot, package);
}
}
}
return packages;
}
async function* projectSourcemaps(rootPath) {
const files = await readdir(rootPath, { withFileTypes: true });
for (const file of files) {
const filepath = join(rootPath, file.name);
if (file.isDirectory()) {
if (skipDirs.has(file.name)) {
continue;
}
yield* projectSourcemaps(filepath);
} else {
if (file.name.endsWith(".js.map")) {
yield filepath;
}
}
}
}
async function getPackageRoot(filename) {
const dir = dirname(filename);
try {
const pkgPath = join(dir, "package.json");
await stat(pkgPath);
return dir;
} catch (e) {
if (e.code === "ENOENT") {
return getPackageRoot(dir);
}
throw e;
}
}
function getUrl(package) {
let url = package.repository;
if (typeof url !== "string") {
url = package.repository?.url;
}
if (!url) {
throw new Error(`Cannot find URL for ${package}`);
}
url = url.replace(/^git\+/, "");
url = url.replace(/\.git$/, "");
url = url.replace(/^git:\/\//, "https://");
return url;
}
async function getLicense(packageRoot) {
for (const licenseName of ["LICENSE", "LICENSE.txt", "LICENSE.md"]) {
const licensePath = join(packageRoot, licenseName);
try {
let text = (await readFile(licensePath)).toString("utf-8");
text = text.replace("&lt;", "<");
text = text.replace("&gt;", ">");
return text;
} catch (err) {
if (err.code === "ENOENT") {
continue;
}
throw err;
}
}
throw new Error(`Cannot get license for ${packageRoot}, license file not found.`);
}