1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 16:19:12 -05:00

chore: add copyright_checker tool and add the missing copyright (#17285)

This commit is contained in:
Yiyu Lin 2023-01-13 15:51:32 +08:00 committed by GitHub
parent 5707a958ac
commit a00e432297
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 276 additions and 49 deletions

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_bench_util::bench_or_profile;
use deno_bench_util::bencher::{benchmark_group, Bencher};
use deno_bench_util::{bench_js_async, bench_js_sync};

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_bench_util::bench_js_sync_with;
use deno_bench_util::bench_or_profile;
use deno_bench_util::bencher::benchmark_group;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
if (Deno.build.os !== "linux") {
throw new Error("SO_REUSEPORT is only supported on Linux");
}

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
if (Deno.build.os !== "linux") {
throw new Error("SO_REUSEPORT is only supported on Linux");
}

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
const addr = Deno.args[0] || "127.0.0.1:4500";
const [hostname, port] = addr.split(":");
const listener = Deno.listen({ hostname, port: Number(port) });

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
const addr = Deno.args[0] || "127.0.0.1:4500";
const [hostname, port] = addr.split(":");
const tcp = Deno.listen({ hostname, port: Number(port) });

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
var Gd = Object.create;
var Ac = Object.defineProperty;
var Xd = Object.getOwnPropertyDescriptor;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { loadTestLibrary } from "../../../test_napi/common.js";
const lib = loadTestLibrary();

View file

@ -1,5 +1,6 @@
// From https://github.com/just-js/benchmarks/tree/main/01-stdio
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
//
// From https://github.com/just-js/benchmarks/tree/main/01-stdio
const blocksize = parseInt(Deno.args[0] || 65536);
const buf = new Uint8Array(blocksize);

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::collections::HashMap;
use std::path::Path;
use std::path::PathBuf;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::Snapshot;
use log::debug;
use once_cell::sync::Lazy;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;

View file

@ -1,6 +1,9 @@
use crate::tools::bench::BenchDescription;
use crate::tools::bench::BenchEvent;
use crate::tools::test::TestFilter;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::time;
use deno_core::error::generic_error;
use deno_core::error::AnyError;
use deno_core::op;
@ -12,12 +15,13 @@ use deno_runtime::permissions::ChildPermissionsArg;
use deno_runtime::permissions::PermissionsContainer;
use serde::Deserialize;
use serde::Serialize;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::time;
use tokio::sync::mpsc::UnboundedSender;
use uuid::Uuid;
use crate::tools::bench::BenchDescription;
use crate::tools::bench::BenchEvent;
use crate::tools::test::TestFilter;
pub fn init(
sender: UnboundedSender<BenchEvent>,
filter: TestFilter,

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "./test_util.ts";
Deno.test(function basicAbortController() {

View file

@ -1,4 +1,5 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import {
assert,
assertEquals,

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import {
assertEquals,
assertNotEquals,

View file

@ -1,4 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals, assertThrows, delay } from "./test_util.ts";
// TODO(ry) Add more tests to specify format.

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert } from "./test_util.ts";
Deno.test(

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertStringIncludes, unreachable } from "./test_util.ts";
Deno.test(async function sendAsyncStackTrace() {

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assertEquals, assertThrows } from "./test_util.ts";
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import {
assert,
assertEquals,

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assertNotEquals, execCode } from "./test_util.ts";
Deno.test("[unrefOp] unref'ing invalid ops does not have effects", async () => {

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals, assertThrows } from "./test_util.ts";
// Basic tests for the structured clone algorithm. Mainly tests TypeScript

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "./test_util.ts";
Deno.test(function version() {

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals, assertRejects } from "./test_util.ts";
// The following blob can be created by taking the following s-expr and pass

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import {
assert,
assertEquals,

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "./test_util.ts";
let isCI: boolean;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import {
assert,
assertEquals,

View file

@ -1,6 +1,7 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
//
// Forked from https://github.com/demurgos/v8-coverage/tree/d0ca18da8740198681e0bc68971b0a6cdb11db3e/rust
// Copyright 2021 Charles Samborski. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use super::json_types::CoverageRange;
use super::json_types::FunctionCoverage;

View file

@ -1,6 +1,7 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
//
// Forked from https://github.com/demurgos/v8-coverage/tree/d0ca18da8740198681e0bc68971b0a6cdb11db3e/rust
// Copyright 2021 Charles Samborski. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use super::json_types::CoverageRange;
use std::iter::Peekable;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_runtime::ops::tty::ConsoleSize;
/// Gets the console size.

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::borrow::Cow;
use std::path::Path;
use std::path::PathBuf;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::Arc;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use anyhow::Error;
pub fn get_error_code(err: &Error) -> Option<&'static str> {

View file

@ -1,9 +1,12 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::path::Path;
use std::path::PathBuf;
use crate::Extension;
use crate::JsRuntime;
use crate::RuntimeOptions;
use crate::Snapshot;
use std::path::Path;
use std::path::PathBuf;
pub type CompressionCb = dyn Fn(&mut Vec<u8>, &[u8]);

View file

@ -1,14 +1,16 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use crate::BroadcastChannel;
use std::sync::Arc;
use async_trait::async_trait;
use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex;
use std::sync::Arc;
use tokio::sync::broadcast;
use tokio::sync::mpsc;
use uuid::Uuid;
use crate::BroadcastChannel;
#[derive(Clone)]
pub struct InMemoryBroadcastChannel(Arc<Mutex<broadcast::Sender<Message>>>);

View file

@ -1,4 +1,5 @@
use crate::shared::*;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use aes::cipher::block_padding::Pkcs7;
use aes::cipher::BlockDecryptMut;
use aes::cipher::KeyIvInit;
@ -29,6 +30,8 @@ use sha2::Sha256;
use sha2::Sha384;
use sha2::Sha512;
use crate::shared::*;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DecryptOptions {

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::ZeroCopyBuf;

View file

@ -1,4 +1,4 @@
use crate::shared::*;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use aes::cipher::block_padding::Pkcs7;
use aes::cipher::BlockEncryptMut;
@ -31,6 +31,8 @@ use sha2::Sha256;
use sha2::Sha384;
use sha2::Sha512;
use crate::shared::*;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EncryptOptions {

View file

@ -1,4 +1,5 @@
use crate::shared::*;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use const_oid::AssociatedOid;
use const_oid::ObjectIdentifier;
use deno_core::error::custom_error;
@ -15,6 +16,8 @@ use spki::der::Decode;
use spki::der::Encode;
use spki::AlgorithmIdentifier;
use crate::shared::*;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExportKeyOptions {

View file

@ -1,4 +1,5 @@
use crate::shared::*;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::ZeroCopyBuf;
@ -12,6 +13,8 @@ use rsa::BigUint;
use rsa::RsaPrivateKey;
use serde::Deserialize;
use crate::shared::*;
// Allowlist for RSA public exponents.
static PUB_EXPONENT_1: Lazy<BigUint> =
Lazy::new(|| BigUint::from_u64(3).unwrap());

View file

@ -1,5 +1,5 @@
use crate::key::CryptoNamedCurve;
use crate::shared::*;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::ZeroCopyBuf;
@ -12,6 +12,9 @@ use serde::Serialize;
use spki::der::Decode;
use spki::der::Encode;
use crate::key::CryptoNamedCurve;
use crate::shared::*;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum KeyData {

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::borrow::Cow;
use deno_core::error::custom_error;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use curve25519_dalek::montgomery::MontgomeryPoint;
use deno_core::error::AnyError;
use deno_core::op;

View file

@ -1,7 +1,8 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
//
// Based on https://github.com/frewsxcv/rust-chunked-transfer/blob/5c08614458580f9e7a85124021006d83ce1ed6e9/src/decoder.rs
// Copyright 2015 The tiny-http Contributors
// Copyright 2015 The rust-chunked-transfer Contributors
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::error::Error;
use std::fmt;

View file

@ -1,5 +1,5 @@
// Forked from https://github.com/Thomasdezeeuw/sendfile/blob/024f82cd4dede9048392a5bd6d8afcd4d5aa83d5/src/lib.rs
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Forked from https://github.com/Thomasdezeeuw/sendfile/blob/024f82cd4dede9048392a5bd6d8afcd4d5aa83d5/src/lib.rs
use std::future::Future;
use std::io;

View file

@ -1,12 +1,13 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::cell::UnsafeCell;
use std::future::Future;
use std::io::{Read, Write};
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use deno_core::error::AnyError;
use mio::net::TcpStream;
use std::{
cell::UnsafeCell,
future::Future,
io::{Read, Write},
pin::Pin,
sync::{Arc, Mutex},
};
use tokio::sync::mpsc;
use crate::ParseStatus;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
const m = Deno[Deno.internal].require.Module;
export const _cache = m._cache;
export const _extensions = m._extensions;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::path::Component;
use std::path::PathBuf;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_bench_util::bench_js_sync;
use deno_bench_util::bench_or_profile;
use deno_bench_util::bencher::{benchmark_group, Bencher};

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op;

View file

@ -1,8 +1,9 @@
use deno_core::Extension;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_bench_util::bench_js_sync;
use deno_bench_util::bench_or_profile;
use deno_bench_util::bencher::{benchmark_group, Bencher};
use deno_core::Extension;
use deno_web::BlobStore;
struct Permissions;

View file

@ -1,8 +1,9 @@
use deno_core::Extension;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_bench_util::bench_js_async;
use deno_bench_util::bench_or_profile;
use deno_bench_util::bencher::{benchmark_group, Bencher};
use deno_core::Extension;
use deno_web::BlobStore;
struct Permissions;

View file

@ -1,18 +1,19 @@
use async_trait::async_trait;
use deno_core::error::type_error;
use deno_core::op;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use deno_core::parking_lot::Mutex;
use deno_core::url::Url;
use deno_core::ZeroCopyBuf;
use serde::{Deserialize, Serialize};
use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt::Debug;
use std::rc::Rc;
use std::sync::Arc;
use async_trait::async_trait;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::parking_lot::Mutex;
use deno_core::url::Url;
use deno_core::ZeroCopyBuf;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::Location;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::borrow::Cow;
use std::cell::RefCell;
use std::rc::Rc;

View file

@ -1,6 +1,6 @@
/// Code generation for V8 fast calls.
use crate::optimizer::FastValue;
use crate::optimizer::Optimizer;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
//! Code generation for V8 fast calls.
use pmutil::{q, Quote, ToTokensExt};
use proc_macro2::{Span, TokenStream};
use quote::quote;
@ -9,6 +9,9 @@ use syn::{
Ident, ItemFn, ItemImpl, Path, PathArguments, PathSegment, Type, TypePath,
};
use crate::optimizer::FastValue;
use crate::optimizer::Optimizer;
pub(crate) struct FastImplItems {
pub(crate) impl_and_fn: TokenStream,
pub(crate) decl: TokenStream,

View file

@ -1,10 +1,13 @@
/// Optimizer for #[op]
use crate::Op;
use pmutil::{q, Quote};
use proc_macro2::TokenStream;
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
//! Optimizer for #[op]
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::fmt::Formatter;
use pmutil::{q, Quote};
use proc_macro2::TokenStream;
use syn::{
parse_quote, punctuated::Punctuated, token::Colon2,
AngleBracketedGenericArguments, FnArg, GenericArgument, PatType, Path,
@ -12,6 +15,8 @@ use syn::{
TypeReference, TypeSlice, TypeTuple,
};
use crate::Op;
#[derive(Debug)]
pub(crate) enum BailoutReason {
// Recoverable errors

View file

@ -1,4 +1,4 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
"use strict";
((window) => {

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::cell::RefCell;
use std::rc::Rc;

View file

@ -1,4 +1,4 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use super::io::ChildStderrResource;
use super::io::ChildStdinResource;

View file

@ -1,6 +1,9 @@
use super::transl8::{impl_magic, impl_wrapper, FromV8, ToV8};
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use crate::Error;
use super::transl8::{impl_magic, impl_wrapper, FromV8, ToV8};
impl_wrapper!(
pub struct U16String(Vec<u16>);
);

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
const targetDir = Deno.execPath().replace(/[^\/\\]+$/, "");
const [libPrefix, libSuffix] = {
darwin: ["lib", "dylib"],

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use crate::assert_napi_ok;
use crate::napi_new_property;
use napi_sys::*;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
#[macro_export]
macro_rules! assert_ends_with {
($left:expr, $right:expr $(,)?) => {

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::collections::HashMap;
use std::fs;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::collections::HashMap;
use std::io::Read;
use std::path::Path;

View file

@ -1,3 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use std::fs;
use std::path::Path;
use std::path::PathBuf;

View file

@ -72,3 +72,16 @@ on top, somewhat similar to `git subtree`.
2. Run `./tools/wgpu_sync.js`
3. Double check changes, possibly patch
4. Commit & send a PR with the updates
## copyright_checker.js
`copyright_checker.js` is used to check copyright headers in the codebase.
To run the _copyright checker_:
```sh
deno run --allow-read --allow-run --unstable ./tools/copyright_checker.js
```
Then it will check all code files in the repository and report any files that
are not properly licensed.

View file

@ -0,0 +1,84 @@
#!/usr/bin/env -S deno run --unstable --allow-read --allow-run
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { getSources, ROOT_PATH } from "./util.js";
const buffer = new Uint8Array(1024);
const textDecoder = new TextDecoder();
async function readFirstPartOfFile(filePath) {
const file = await Deno.open(filePath, { read: true });
try {
const byteCount = await file.read(buffer);
return textDecoder.decode(buffer.slice(0, byteCount ?? 0));
} finally {
file.close();
}
}
async function checkCopyright() {
const sourceFiles = await getSources(ROOT_PATH, [
// js and ts
"*.js",
"*.ts",
":!:.github/mtime_cache/action.js",
":!:cli/tests/testdata/**",
":!:cli/bench/testdata/**",
":!:cli/tsc/dts/**",
":!:cli/tsc/*typescript.js",
":!:cli/tsc/compiler.d.ts",
":!:test_util/wpt/**",
":!:tools/**", // these files are starts with `#!/usr/bin/env`
":!:cli/tools/init/templates/**",
// rust
"*.rs",
":!:ops/optimizer_tests/**",
// toml
"*Cargo.toml",
]);
let totalCount = 0;
const sourceFilesSet = new Set(sourceFiles);
for (const file of sourceFilesSet) {
const ERROR_MSG = "Copyright header is missing: ";
const fileText = await readFirstPartOfFile(file);
if (file.endsWith("Cargo.toml")) {
if (
!fileText.startsWith(
"# Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.",
)
) {
console.log(ERROR_MSG + file);
totalCount += 1;
}
continue;
}
if (
!fileText.startsWith(
"// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.",
)
) {
console.log(ERROR_MSG + file);
totalCount += 1;
}
}
console.log("\nTotal errors: " + totalCount);
if (totalCount > 0) {
Deno.exit(1);
}
}
async function main() {
await Deno.chdir(ROOT_PATH);
await checkCopyright();
}
await main();