mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-22 17:10:53 +02:00
aba07c27b8
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FabianLars <fabianlars@fabianlars.de> Co-authored-by: FabianLars <FabianLars@users.noreply.github.com> Co-authored-by: Alexandre Dang <124160233+vdang-crabnebula@users.noreply.github.com> Co-authored-by: Ludea <ludovicw35@hotmail.com> Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com> Co-authored-by: Duke Jones <104690+dukejones@users.noreply.github.com> Co-authored-by: NaokiM03 <37442712+NaokiM03@users.noreply.github.com> Co-authored-by: Thibault <thibault_poisson@orange.fr> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: David Blythe <49919035+writeDavid@users.noreply.github.com> Co-authored-by: Lucas Nogueira <lucas@tauri.studio> fix(stronghold): change wrong argument name for `remove` (#422) fix(window-state): correctly set decoration state if no saved state exists, fixes #421 (#424) fix(stronghold): return null if there is no record (#129) fix(window-state): propagate promise (#435) closes #432 fix(window-state): manual default implentation (#425) fix(window-state): manual default implentation, closes #421 fix(deps): update rust crate iota-crypto to 0.21 (#438) fix readme example (#447) fix: handle recursive directory correctly (#455) fix(deps): update rust crate sqlx to 0.7. plugin-sql msrv is now 1.65 (#464) fix(persisted-scope): separately save asset protocol patterns (#459) fix(deps): update rust crate iota-crypto to 0.22 (#475) fix(deps): update tauri monorepo to v1.4.0 (#482) resolve to v15.1.0 (#489) fix(deps): update rust crate iota-crypto to 0.23 (#495)
122 lines
2.7 KiB
JavaScript
122 lines
2.7 KiB
JavaScript
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import fs from "fs";
|
|
import path from "path";
|
|
import readline from "readline";
|
|
|
|
const header = `Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
|
SPDX-License-Identifier: Apache-2.0
|
|
SPDX-License-Identifier: MIT`;
|
|
const ignoredLicense = "// Copyright 2021 Jonas Kruckenberg";
|
|
|
|
const extensions = [".rs", ".js", ".ts", ".yml", ".swift", ".kt"];
|
|
const ignore = [
|
|
"target",
|
|
"templates",
|
|
"node_modules",
|
|
"gen",
|
|
"dist",
|
|
"dist-js",
|
|
".svelte-kit",
|
|
"api-iife.js",
|
|
];
|
|
|
|
async function checkFile(file) {
|
|
if (
|
|
extensions.some((e) => file.endsWith(e)) &&
|
|
!ignore.some((i) => file.endsWith(i))
|
|
) {
|
|
const fileStream = fs.createReadStream(file);
|
|
const rl = readline.createInterface({
|
|
input: fileStream,
|
|
crlfDelay: Infinity,
|
|
});
|
|
|
|
let contents = ``;
|
|
let i = 0;
|
|
for await (let line of rl) {
|
|
// ignore empty lines, allow shebang, swift-tools-version and bundler license
|
|
if (
|
|
line.length === 0 ||
|
|
line.startsWith("#!") ||
|
|
line.startsWith("// swift-tools-version:") ||
|
|
line === ignoredLicense
|
|
) {
|
|
continue;
|
|
}
|
|
|
|
// strip comment marker
|
|
if (line.startsWith("// ")) {
|
|
line = line.substring(3);
|
|
} else if (line.startsWith("# ")) {
|
|
line = line.substring(2);
|
|
}
|
|
|
|
contents += line;
|
|
if (++i === 3) {
|
|
break;
|
|
}
|
|
contents += "\n";
|
|
}
|
|
if (contents !== header) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
async function check(src) {
|
|
const missingHeader = [];
|
|
|
|
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
const p = path.join(src, entry.name);
|
|
|
|
if (entry.isSymbolicLink() || ignore.includes(entry.name)) {
|
|
continue;
|
|
}
|
|
|
|
if (entry.isDirectory()) {
|
|
const missing = await check(p);
|
|
missingHeader.push(...missing);
|
|
} else {
|
|
const isMissing = await checkFile(p);
|
|
if (isMissing) {
|
|
missingHeader.push(p);
|
|
}
|
|
}
|
|
}
|
|
|
|
return missingHeader;
|
|
}
|
|
|
|
const [_bin, _script, ...files] = process.argv;
|
|
|
|
if (files.length > 0) {
|
|
async function run() {
|
|
const missing = [];
|
|
for (const f of files) {
|
|
const isMissing = await checkFile(f);
|
|
if (isMissing) {
|
|
missing.push(f);
|
|
}
|
|
}
|
|
if (missing.length > 0) {
|
|
console.log(missing.join("\n"));
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
run();
|
|
} else {
|
|
check(path.resolve(new URL(import.meta.url).pathname, "../../..")).then(
|
|
(missing) => {
|
|
if (missing.length > 0) {
|
|
console.log(missing.join("\n"));
|
|
process.exit(1);
|
|
}
|
|
},
|
|
);
|
|
}
|