diff --git a/bench_util/benches/op_baseline.rs b/bench_util/benches/op_baseline.rs index 9c3ac16c4b..f8ae32b353 100644 --- a/bench_util/benches/op_baseline.rs +++ b/bench_util/benches/op_baseline.rs @@ -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}; diff --git a/bench_util/benches/utf8.rs b/bench_util/benches/utf8.rs index 363300d5e1..2bbf439b67 100644 --- a/bench_util/benches/utf8.rs +++ b/bench_util/benches/utf8.rs @@ -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; diff --git a/cli/bench/http/deno_http_flash_ops_spawn.js b/cli/bench/http/deno_http_flash_ops_spawn.js index 6ee39a84a8..b9d11462ff 100644 --- a/cli/bench/http/deno_http_flash_ops_spawn.js +++ b/cli/bench/http/deno_http_flash_ops_spawn.js @@ -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"); } diff --git a/cli/bench/http/deno_http_flash_spawn.js b/cli/bench/http/deno_http_flash_spawn.js index eb827b34b1..e47acffc59 100644 --- a/cli/bench/http/deno_http_flash_spawn.js +++ b/cli/bench/http/deno_http_flash_spawn.js @@ -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"); } diff --git a/cli/bench/http/deno_http_native_headers.js b/cli/bench/http/deno_http_native_headers.js index 23ef1e0600..7c1eaa5832 100644 --- a/cli/bench/http/deno_http_native_headers.js +++ b/cli/bench/http/deno_http_native_headers.js @@ -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) }); diff --git a/cli/bench/http/deno_http_ops.js b/cli/bench/http/deno_http_ops.js index f65b32170f..3fd0bef316 100644 --- a/cli/bench/http/deno_http_ops.js +++ b/cli/bench/http/deno_http_ops.js @@ -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) }); diff --git a/cli/bench/http/node_reactdom_ssr.js b/cli/bench/http/node_reactdom_ssr.js index 5e784b946a..f82b504d79 100644 --- a/cli/bench/http/node_reactdom_ssr.js +++ b/cli/bench/http/node_reactdom_ssr.js @@ -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; diff --git a/cli/bench/napi/bench.js b/cli/bench/napi/bench.js index 5917d3a28c..63215a217c 100644 --- a/cli/bench/napi/bench.js +++ b/cli/bench/napi/bench.js @@ -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(); diff --git a/cli/bench/stdio/stdio.js b/cli/bench/stdio/stdio.js index 1d11c273dd..e53016df24 100644 --- a/cli/bench/stdio/stdio.js +++ b/cli/bench/stdio/stdio.js @@ -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); diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs index 28547dcf6b..cef33e3549 100644 --- a/cli/cache/parsed_source.rs +++ b/cli/cache/parsed_source.rs @@ -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; diff --git a/cli/js.rs b/cli/js.rs index 4bf3da6273..06a6a5fd9b 100644 --- a/cli/js.rs +++ b/cli/js.rs @@ -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; diff --git a/cli/lsp/client.rs b/cli/lsp/client.rs index 25c97d9d52..b39678667f 100644 --- a/cli/lsp/client.rs +++ b/cli/lsp/client.rs @@ -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; diff --git a/cli/ops/bench.rs b/cli/ops/bench.rs index 9b70cfa79c..2181a139c7 100644 --- a/cli/ops/bench.rs +++ b/cli/ops/bench.rs @@ -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, filter: TestFilter, diff --git a/cli/tests/unit/abort_controller_test.ts b/cli/tests/unit/abort_controller_test.ts index 6b7bea899b..2df953773b 100644 --- a/cli/tests/unit/abort_controller_test.ts +++ b/cli/tests/unit/abort_controller_test.ts @@ -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() { diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/command_test.ts index 2a0562c933..e7f9405354 100644 --- a/cli/tests/unit/command_test.ts +++ b/cli/tests/unit/command_test.ts @@ -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, diff --git a/cli/tests/unit/dom_exception_test.ts b/cli/tests/unit/dom_exception_test.ts index b6b6a44404..d0a0b8a942 100644 --- a/cli/tests/unit/dom_exception_test.ts +++ b/cli/tests/unit/dom_exception_test.ts @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + import { assertEquals, assertNotEquals, diff --git a/cli/tests/unit/fs_events_test.ts b/cli/tests/unit/fs_events_test.ts index 2888a05f88..cdfb676570 100644 --- a/cli/tests/unit/fs_events_test.ts +++ b/cli/tests/unit/fs_events_test.ts @@ -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. diff --git a/cli/tests/unit/network_interfaces_test.ts b/cli/tests/unit/network_interfaces_test.ts index a0e6e691a1..287b7d421f 100644 --- a/cli/tests/unit/network_interfaces_test.ts +++ b/cli/tests/unit/network_interfaces_test.ts @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + import { assert } from "./test_util.ts"; Deno.test( diff --git a/cli/tests/unit/opcall_test.ts b/cli/tests/unit/opcall_test.ts index 9707318555..61c3c88491 100644 --- a/cli/tests/unit/opcall_test.ts +++ b/cli/tests/unit/opcall_test.ts @@ -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() { diff --git a/cli/tests/unit/path_from_url_test.ts b/cli/tests/unit/path_from_url_test.ts index f375d84f4f..9842c29c2b 100644 --- a/cli/tests/unit/path_from_url_test.ts +++ b/cli/tests/unit/path_from_url_test.ts @@ -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 diff --git a/cli/tests/unit/read_text_file_test.ts b/cli/tests/unit/read_text_file_test.ts index 5e455c5832..e78276dde8 100644 --- a/cli/tests/unit/read_text_file_test.ts +++ b/cli/tests/unit/read_text_file_test.ts @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + import { assert, assertEquals, diff --git a/cli/tests/unit/ref_unref_test.ts b/cli/tests/unit/ref_unref_test.ts index da6e95efc8..7ce72a1708 100644 --- a/cli/tests/unit/ref_unref_test.ts +++ b/cli/tests/unit/ref_unref_test.ts @@ -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 () => { diff --git a/cli/tests/unit/structured_clone_test.ts b/cli/tests/unit/structured_clone_test.ts index c60b38a8a7..722c9c8cc5 100644 --- a/cli/tests/unit/structured_clone_test.ts +++ b/cli/tests/unit/structured_clone_test.ts @@ -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 diff --git a/cli/tests/unit/version_test.ts b/cli/tests/unit/version_test.ts index 3b371a2bcf..55a4bc6c97 100644 --- a/cli/tests/unit/version_test.ts +++ b/cli/tests/unit/version_test.ts @@ -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() { diff --git a/cli/tests/unit/wasm_test.ts b/cli/tests/unit/wasm_test.ts index 03ed0e2981..73d243de8f 100644 --- a/cli/tests/unit/wasm_test.ts +++ b/cli/tests/unit/wasm_test.ts @@ -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 diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index 86d9f38ab7..c522bf1e6e 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + import { assert, assertEquals, diff --git a/cli/tests/unit/webgpu_test.ts b/cli/tests/unit/webgpu_test.ts index c903736f8d..decceb0f91 100644 --- a/cli/tests/unit/webgpu_test.ts +++ b/cli/tests/unit/webgpu_test.ts @@ -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; diff --git a/cli/tests/unit/write_text_file_test.ts b/cli/tests/unit/write_text_file_test.ts index c835349284..8ce0ea6020 100644 --- a/cli/tests/unit/write_text_file_test.ts +++ b/cli/tests/unit/write_text_file_test.ts @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + import { assert, assertEquals, diff --git a/cli/tools/coverage/merge.rs b/cli/tools/coverage/merge.rs index 7fe382d240..29d26da3c6 100644 --- a/cli/tools/coverage/merge.rs +++ b/cli/tools/coverage/merge.rs @@ -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; diff --git a/cli/tools/coverage/range_tree.rs b/cli/tools/coverage/range_tree.rs index 19b3257f87..8b3d36cd81 100644 --- a/cli/tools/coverage/range_tree.rs +++ b/cli/tools/coverage/range_tree.rs @@ -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; diff --git a/cli/util/console.rs b/cli/util/console.rs index c36b274db6..ac78ca4df5 100644 --- a/cli/util/console.rs +++ b/cli/util/console.rs @@ -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. diff --git a/cli/util/path.rs b/cli/util/path.rs index 6df982f4ed..76e2a1b6fa 100644 --- a/cli/util/path.rs +++ b/cli/util/path.rs @@ -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; diff --git a/cli/worker.rs b/cli/worker.rs index 2f8a9b6873..7e06166505 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -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; diff --git a/core/error_codes.rs b/core/error_codes.rs index 6a8dd9fa3a..874aa4ec64 100644 --- a/core/error_codes.rs +++ b/core/error_codes.rs @@ -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> { diff --git a/core/snapshot_util.rs b/core/snapshot_util.rs index bacc0c6aeb..b35cabbfa9 100644 --- a/core/snapshot_util.rs +++ b/core/snapshot_util.rs @@ -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]); diff --git a/ext/broadcast_channel/in_memory_broadcast_channel.rs b/ext/broadcast_channel/in_memory_broadcast_channel.rs index 595a7cc13a..7c9c68ae0d 100644 --- a/ext/broadcast_channel/in_memory_broadcast_channel.rs +++ b/ext/broadcast_channel/in_memory_broadcast_channel.rs @@ -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>>); diff --git a/ext/crypto/decrypt.rs b/ext/crypto/decrypt.rs index c83ff55bd9..6c4d5b6ba5 100644 --- a/ext/crypto/decrypt.rs +++ b/ext/crypto/decrypt.rs @@ -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 { diff --git a/ext/crypto/ed25519.rs b/ext/crypto/ed25519.rs index b7ff99d8b1..898366bbc1 100644 --- a/ext/crypto/ed25519.rs +++ b/ext/crypto/ed25519.rs @@ -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; diff --git a/ext/crypto/encrypt.rs b/ext/crypto/encrypt.rs index 9420acdbd5..f34e0cbc6b 100644 --- a/ext/crypto/encrypt.rs +++ b/ext/crypto/encrypt.rs @@ -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 { diff --git a/ext/crypto/export_key.rs b/ext/crypto/export_key.rs index 0cbb2f6764..ec76bac928 100644 --- a/ext/crypto/export_key.rs +++ b/ext/crypto/export_key.rs @@ -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 { diff --git a/ext/crypto/generate_key.rs b/ext/crypto/generate_key.rs index 9ecbb8d117..2a9452c433 100644 --- a/ext/crypto/generate_key.rs +++ b/ext/crypto/generate_key.rs @@ -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 = Lazy::new(|| BigUint::from_u64(3).unwrap()); diff --git a/ext/crypto/import_key.rs b/ext/crypto/import_key.rs index 07c7f3f6fc..42eab0e6ca 100644 --- a/ext/crypto/import_key.rs +++ b/ext/crypto/import_key.rs @@ -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 { diff --git a/ext/crypto/shared.rs b/ext/crypto/shared.rs index d2f7d53e82..4ecb35dc27 100644 --- a/ext/crypto/shared.rs +++ b/ext/crypto/shared.rs @@ -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; diff --git a/ext/crypto/x25519.rs b/ext/crypto/x25519.rs index 1e64e99092..0ecdf4ddc0 100644 --- a/ext/crypto/x25519.rs +++ b/ext/crypto/x25519.rs @@ -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; diff --git a/ext/flash/chunked.rs b/ext/flash/chunked.rs index d414f211ea..711dd717d4 100644 --- a/ext/flash/chunked.rs +++ b/ext/flash/chunked.rs @@ -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; diff --git a/ext/flash/sendfile.rs b/ext/flash/sendfile.rs index 43b5323a40..92e8f2bb78 100644 --- a/ext/flash/sendfile.rs +++ b/ext/flash/sendfile.rs @@ -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; diff --git a/ext/flash/socket.rs b/ext/flash/socket.rs index 8256be8a0c..77881d5363 100644 --- a/ext/flash/socket.rs +++ b/ext/flash/socket.rs @@ -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; diff --git a/ext/node/module_es_shim.js b/ext/node/module_es_shim.js index 164e18db53..f32006b4a5 100644 --- a/ext/node/module_es_shim.js +++ b/ext/node/module_es_shim.js @@ -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; diff --git a/ext/node/path.rs b/ext/node/path.rs index 8477fe7137..f0ce52002d 100644 --- a/ext/node/path.rs +++ b/ext/node/path.rs @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + use std::path::Component; use std::path::PathBuf; diff --git a/ext/url/benches/url_ops.rs b/ext/url/benches/url_ops.rs index 63810733dd..2bf113f540 100644 --- a/ext/url/benches/url_ops.rs +++ b/ext/url/benches/url_ops.rs @@ -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}; diff --git a/ext/url/urlpattern.rs b/ext/url/urlpattern.rs index 99fd216644..dcb3eaac8f 100644 --- a/ext/url/urlpattern.rs +++ b/ext/url/urlpattern.rs @@ -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; diff --git a/ext/web/benches/encoding.rs b/ext/web/benches/encoding.rs index 8c9eaeb6c0..01fba9e662 100644 --- a/ext/web/benches/encoding.rs +++ b/ext/web/benches/encoding.rs @@ -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; diff --git a/ext/web/benches/timers_ops.rs b/ext/web/benches/timers_ops.rs index 2ba93c5e13..024d523604 100644 --- a/ext/web/benches/timers_ops.rs +++ b/ext/web/benches/timers_ops.rs @@ -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; diff --git a/ext/web/blob.rs b/ext/web/blob.rs index 24cd13454e..e4ba93a2f7 100644 --- a/ext/web/blob.rs +++ b/ext/web/blob.rs @@ -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; diff --git a/ext/web/message_port.rs b/ext/web/message_port.rs index 48c899216a..f287fc82d7 100644 --- a/ext/web/message_port.rs +++ b/ext/web/message_port.rs @@ -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; diff --git a/ops/fast_call.rs b/ops/fast_call.rs index f2ed8cb2d7..b8fdf91bfe 100644 --- a/ops/fast_call.rs +++ b/ops/fast_call.rs @@ -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, diff --git a/ops/optimizer.rs b/ops/optimizer.rs index 2d68a296fd..3f22a867b8 100644 --- a/ops/optimizer.rs +++ b/ops/optimizer.rs @@ -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 diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js index 9d4aa3e9f2..de733d7eb1 100644 --- a/runtime/js/40_spawn.js +++ b/runtime/js/40_spawn.js @@ -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) => { diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index a531deb842..51562589ea 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + use std::cell::RefCell; use std::rc::Rc; diff --git a/runtime/ops/spawn.rs b/runtime/ops/spawn.rs index f552e96907..e5bf10cf05 100644 --- a/runtime/ops/spawn.rs +++ b/runtime/ops/spawn.rs @@ -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; diff --git a/serde_v8/magic/u16string.rs b/serde_v8/magic/u16string.rs index 22868ccfb2..11554738af 100644 --- a/serde_v8/magic/u16string.rs +++ b/serde_v8/magic/u16string.rs @@ -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); ); diff --git a/test_ffi/tests/event_loop_integration.ts b/test_ffi/tests/event_loop_integration.ts index c3b34cc8ff..e44c66ab69 100644 --- a/test_ffi/tests/event_loop_integration.ts +++ b/test_ffi/tests/event_loop_integration.ts @@ -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"], diff --git a/test_napi/src/primitives.rs b/test_napi/src/primitives.rs index 2d951ebfa3..e29c7c368b 100644 --- a/test_napi/src/primitives.rs +++ b/test_napi/src/primitives.rs @@ -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::*; diff --git a/test_util/src/assertions.rs b/test_util/src/assertions.rs index ecee14b1f9..a004530b6e 100644 --- a/test_util/src/assertions.rs +++ b/test_util/src/assertions.rs @@ -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 $(,)?) => { diff --git a/test_util/src/npm.rs b/test_util/src/npm.rs index 6e393d8353..738a1090aa 100644 --- a/test_util/src/npm.rs +++ b/test_util/src/npm.rs @@ -1,3 +1,5 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + use std::collections::HashMap; use std::fs; diff --git a/test_util/src/pty.rs b/test_util/src/pty.rs index 4970e08f43..b2d7201ae4 100644 --- a/test_util/src/pty.rs +++ b/test_util/src/pty.rs @@ -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; diff --git a/test_util/src/temp_dir.rs b/test_util/src/temp_dir.rs index cab55cc14d..01dce8f1ab 100644 --- a/test_util/src/temp_dir.rs +++ b/test_util/src/temp_dir.rs @@ -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; diff --git a/tools/README.md b/tools/README.md index 59860ca1b1..e88f8d8928 100644 --- a/tools/README.md +++ b/tools/README.md @@ -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. diff --git a/tools/copyright_checker.js b/tools/copyright_checker.js new file mode 100644 index 0000000000..706f59dbdf --- /dev/null +++ b/tools/copyright_checker.js @@ -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();