Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fork #1

Merged
merged 30 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3b86552
refactor: remove duplicated code in std/node/module (#5778)
disizali May 23, 2020
6feca0e
Fix Deno.dir and Diagnostics being present at stable runtime (#5750)
lucacasonato May 23, 2020
94f1de5
Fix example (#5775)
guzhongren May 23, 2020
c3c16f0
fix: TSX analysis in module graph loader (#5785)
bartlomieju May 23, 2020
2bbe475
docs: update permissions example (#5809)
bolatovumar May 24, 2020
f6e3160
feat(std/encoding): add base64 (#5811)
skdltmxn May 24, 2020
b7f0b07
Add unstable checks for unix transport (#5818)
SyrupThinker May 24, 2020
4ca0d6e
Re-enable several fetch tests (#5803)
mitch292 May 24, 2020
e934df5
fix: create HTTP cache lazily (#5795)
bartlomieju May 24, 2020
ee0b5bb
test: add utility function for assigning unique port to inspector (#5…
piscisaureus May 25, 2020
131f2a5
fix: BorrowMutError when evaluating expression in inspector console (…
piscisaureus May 24, 2020
20bf04d
Move getHeaderValueParams & hasHeaderValueOf to util.ts (#5824)
marcosc90 May 25, 2020
fbbb9f1
Add missing async delay import to code sample (#5837)
mrtns May 25, 2020
c9f0e34
Improve bufferFromStream (#5826)
marcosc90 May 25, 2020
1c4a966
fix: Allow ArrayBuffer as Fetch request body (#5831)
marcosc90 May 25, 2020
aef9f22
Fix typo (#5834)
raresraf May 25, 2020
08f74e1
fix(cli/web/fetch): Make Response constructor standard (#5787)
marcosc90 May 25, 2020
4ebd243
fix(std/testing/asserts): Support browsers (#5847)
nayeemrmn May 25, 2020
4e92ef7
Add more tests for fetch response body (#5852)
marcosc90 May 25, 2020
9090023
docs: "Getting started" manual updates (#5835)
cknight May 26, 2020
f462f7f
fix: parsing of JSX and TSX in SWC (#5870)
bartlomieju May 26, 2020
24c36fd
fix(std/log): use writeAllSync instead of writeSync (#5868)
fuxingZhang May 26, 2020
228f9c2
Use ts-expect-error instead of ts-ignore. (#5869)
kitsonk May 26, 2020
4447759
improve docs (#5872)
rwieruch May 26, 2020
845bc44
improve docs (#5873)
rwieruch May 26, 2020
d4711fe
docs: update JetBrains environment support (#5877)
crowlKats May 26, 2020
f7b4523
Add sponsor button (#5880)
ry May 26, 2020
27708fe
doc: various runtime doc updates (#5885)
cknight May 27, 2020
304d78f
Bump actions/checkout from v1 to v2 (#5882)
May 27, 2020
23bbb39
doc: official denoland extension (#5890)
justjavac May 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: denoland
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: git config --global core.symlinks true

- name: Clone repository
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
# Use depth > 1, because sometimes we need to rebuild master and if
# other commits have landed it will become impossible to rebuild if
Expand Down
2 changes: 1 addition & 1 deletion cli/deno_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl DenoDir {
root,
gen_cache: DiskCache::new(&gen_path),
};
deno_dir.gen_cache.ensure_location()?;
deno_dir.gen_cache.ensure_dir_exists(&gen_path)?;

Ok(deno_dir)
}
Expand Down
19 changes: 11 additions & 8 deletions cli/disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ impl DiskCache {
}

/// Ensures the location of the cache.
pub fn ensure_location(&self) -> io::Result<()> {
if self.location.is_dir() {
pub fn ensure_dir_exists(&self, path: &Path) -> io::Result<()> {
if path.is_dir() {
return Ok(());
}
fs::create_dir_all(&self.location).map_err(|e| {
fs::create_dir_all(&path).map_err(|e| {
io::Error::new(e.kind(), format!(
"Could not create TypeScript compiler cache location: {:?}\nCheck the permission of the directory.",
self.location
path
))
})
}
Expand Down Expand Up @@ -129,8 +129,7 @@ impl DiskCache {
pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> {
let path = self.location.join(filename);
match path.parent() {
Some(ref parent) => fs::create_dir_all(parent)
.map_err(|e| with_io_context(&e, format!("{:#?}", &path))),
Some(ref parent) => self.ensure_dir_exists(parent),
None => Ok(()),
}?;
deno_fs::write_file(&path, data, 0o666)
Expand All @@ -154,7 +153,9 @@ mod tests {
let mut cache_path = cache_location.path().to_owned();
cache_path.push("foo");
let cache = DiskCache::new(&cache_path);
cache.ensure_location().expect("Testing expect:");
cache
.ensure_dir_exists(&cache.location)
.expect("Testing expect:");
assert!(cache_path.is_dir());
}

Expand All @@ -166,7 +167,9 @@ mod tests {
cache_location.push("foo");
assert_eq!(cache_location.is_dir(), false);
let cache = DiskCache::new(&cache_location);
cache.ensure_location().expect("Testing expect:");
cache
.ensure_dir_exists(&cache.location)
.expect("Testing expect:");
assert_eq!(cache_location.is_dir(), true);
}

Expand Down
14 changes: 10 additions & 4 deletions cli/doc/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use crate::file_fetcher::map_file_extension;
use crate::op_error::OpError;
use crate::swc_common::comments::CommentKind;
use crate::swc_common::Span;
Expand All @@ -15,6 +16,7 @@ use deno_core::ModuleSpecifier;
use futures::Future;
use regex::Regex;
use std::collections::HashMap;
use std::path::PathBuf;
use std::pin::Pin;

use super::namespace::NamespaceDef;
Expand Down Expand Up @@ -57,9 +59,12 @@ impl DocParser {
file_name: &str,
source_code: &str,
) -> Result<ModuleDoc, SwcDiagnosticBuffer> {
self
.ast_parser
.parse_module(file_name, source_code, |parse_result| {
let media_type = map_file_extension(&PathBuf::from(file_name));
self.ast_parser.parse_module(
file_name,
media_type,
source_code,
|parse_result| {
let module = parse_result?;
let doc_entries =
self.get_doc_nodes_for_module_body(module.body.clone());
Expand All @@ -69,7 +74,8 @@ impl DocParser {
reexports,
};
Ok(module_doc)
})
},
)
}

pub async fn parse(&self, file_name: &str) -> Result<Vec<DocNode>, ErrBox> {
Expand Down
1 change: 0 additions & 1 deletion cli/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ impl GlobalState {
let dir = deno_dir::DenoDir::new(custom_root)?;
let deps_cache_location = dir.root.join("deps");
let http_cache = http_cache::HttpCache::new(&deps_cache_location);
http_cache.ensure_location()?;

let file_fetcher = SourceFileFetcher::new(
http_cache,
Expand Down
29 changes: 23 additions & 6 deletions cli/http_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ impl HttpCache {
}

/// Ensures the location of the cache.
pub fn ensure_location(&self) -> io::Result<()> {
if self.location.is_dir() {
fn ensure_dir_exists(&self, path: &Path) -> io::Result<()> {
if path.is_dir() {
return Ok(());
}
fs::create_dir_all(&self.location).map_err(|e| {
fs::create_dir_all(&path).map_err(|e| {
io::Error::new(
e.kind(),
format!(
"Could not create remote modules cache location: {:?}\nCheck the permission of the directory.",
self.location
path
),
)
})
Expand Down Expand Up @@ -163,7 +163,7 @@ impl HttpCache {
let parent_filename = cache_filename
.parent()
.expect("Cache filename should have a parent dir");
fs::create_dir_all(parent_filename)?;
self.ensure_dir_exists(parent_filename)?;
// Cache content
deno_fs::write_file(&cache_filename, content, 0o666)?;

Expand All @@ -187,8 +187,25 @@ mod tests {
let dir = TempDir::new().unwrap();
let mut cache_path = dir.path().to_owned();
cache_path.push("foobar");
// HttpCache should be created lazily on first use:
// when zipping up a local project with no external dependencies
// "$DENO_DIR/deps" is empty. When unzipping such project
// "$DENO_DIR/deps" might not get restored and in situation
// when directory is owned by root we might not be able
// to create that directory. However if it's not needed it
// doesn't make sense to return error in such specific scenarios.
// For more details check issue:
// https://github.com/denoland/deno/issues/5688
let cache = HttpCache::new(&cache_path);
assert!(cache.ensure_location().is_ok());
assert!(!cache.location.exists());
cache
.set(
&Url::parse("http://example.com/foo/bar.js").unwrap(),
HeadersMap::new(),
b"hello world",
)
.expect("Failed to add to cache");
assert!(cache.ensure_dir_exists(&cache.location).is_ok());
assert!(cache_path.is_dir());
}

Expand Down
8 changes: 1 addition & 7 deletions cli/js/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ export { chmodSync, chmod } from "./ops/fs/chmod.ts";
export { chownSync, chown } from "./ops/fs/chown.ts";
export { customInspect, inspect } from "./web/console.ts";
export { copyFileSync, copyFile } from "./ops/fs/copy_file.ts";
export {
Diagnostic,
DiagnosticCategory,
DiagnosticItem,
DiagnosticMessageChain,
} from "./diagnostics.ts";
export { chdir, cwd } from "./ops/fs/dir.ts";
export { errors } from "./errors.ts";
export {
Expand Down Expand Up @@ -59,7 +53,7 @@ export {
export { metrics, Metrics } from "./ops/runtime.ts";
export { mkdirSync, mkdir, MkdirOptions } from "./ops/fs/mkdir.ts";
export { connect, listen, Listener, Conn } from "./net.ts";
export { dir, env, exit, execPath } from "./ops/os.ts";
export { env, exit, execPath } from "./ops/os.ts";
export { run, RunOptions, Process, ProcessStatus } from "./process.ts";
export { DirEntry, readDirSync, readDir } from "./ops/fs/read_dir.ts";
export { readFileSync, readFile } from "./read_file.ts";
Expand Down
6 changes: 6 additions & 0 deletions cli/js/deno_unstable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ export {
PermissionStatus,
Permissions,
} from "./permissions.ts";
export {
Diagnostic,
DiagnosticCategory,
DiagnosticItem,
DiagnosticMessageChain,
} from "./diagnostics.ts";
8 changes: 4 additions & 4 deletions cli/js/error_stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,19 @@ function prepareStackTrace(
}
)
.map((callSite): string => {
// @ts-ignore
// @ts-expect-error
error.__callSiteEvals.push(Object.freeze(evaluateCallSite(callSite)));
const isInternal =
callSite.getFileName()?.startsWith("$deno$") ?? false;
const string = callSiteToString(callSite, isInternal);
// @ts-ignore
// @ts-expect-error
error.__formattedFrames.push(string);
return ` at ${colors.stripColor(string)}`;
})
.join("\n");
// @ts-ignore
// @ts-expect-error
Object.freeze(error.__callSiteEvals);
// @ts-ignore
// @ts-expect-error
Object.freeze(error.__formattedFrames);
return errorString;
}
Expand Down
11 changes: 5 additions & 6 deletions cli/js/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare namespace Deno {
*
* Deno.test({
* name: "example ignored test",
* ignore: Deno.build.os === "windows"
* ignore: Deno.build.os === "windows",
* fn(): void {
* // This test is ignored only on Windows machines
* },
Expand All @@ -73,7 +73,7 @@ declare namespace Deno {
* async fn() {
* const decoder = new TextDecoder("utf-8");
* const data = await Deno.readFile("hello_world.txt");
* assertEquals(decoder.decode(data), "Hello world")
* assertEquals(decoder.decode(data), "Hello world");
* }
* });
* ```
Expand All @@ -94,7 +94,7 @@ declare namespace Deno {
* Deno.test("My async test description", async ():Promise<void> => {
* const decoder = new TextDecoder("utf-8");
* const data = await Deno.readFile("hello_world.txt");
* assertEquals(decoder.decode(data), "Hello world")
* assertEquals(decoder.decode(data), "Hello world");
* });
* ```
* */
Expand Down Expand Up @@ -1612,10 +1612,9 @@ declare namespace Deno {
* const conn2 = await Deno.connect({ hostname: "192.0.2.1", port: 80 });
* const conn3 = await Deno.connect({ hostname: "[2001:db8::1]", port: 80 });
* const conn4 = await Deno.connect({ hostname: "golang.org", port: 80, transport: "tcp" });
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
* ```
*
* Requires `allow-net` permission for "tcp" and `allow-read` for unix. */
* Requires `allow-net` permission for "tcp". */
export function connect(options: ConnectOptions): Promise<Conn>;

export interface ConnectTlsOptions {
Expand Down Expand Up @@ -1828,7 +1827,7 @@ declare namespace Deno {
* ```ts
* const obj = {};
* obj.propA = 10;
* obj.propB = "hello"
* obj.propB = "hello";
* const objAsString = Deno.inspect(obj); // { propA: 10, propB: "hello" }
* console.log(obj); // prints same value as objAsString, e.g. { propA: 10, propB: "hello" }
* ```
Expand Down
21 changes: 7 additions & 14 deletions cli/js/lib.deno.shared_globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,12 @@ declare const Request: {
new (input: RequestInfo, init?: RequestInit): Request;
};

interface ResponseInit {
headers?: HeadersInit;
status?: number;
statusText?: string;
}

type ResponseType =
| "basic"
| "cors"
Expand All @@ -945,20 +951,7 @@ interface Response extends Body {

declare const Response: {
prototype: Response;

// TODO(#4667) Response constructor is non-standard.
// new(body?: BodyInit | null, init?: ResponseInit): Response;
new (
url: string,
status: number,
statusText: string,
headersList: Array<[string, string]>,
rid: number,
redirected_: boolean,
type_?: null | ResponseType,
body_?: null | Body
): Response;

new (body?: BodyInit | null, init?: ResponseInit): Response;
error(): Response;
redirect(url: string, status?: number): Response;
};
Expand Down
2 changes: 1 addition & 1 deletion cli/js/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ declare namespace Deno {
* const conn5 = await Deno.connect({ path: "/foo/bar.sock", transport: "unix" });
* ```
*
* Requires `allow-net` permission for "tcp" and `allow-read` for unix. */
* Requires `allow-net` permission for "tcp" and `allow-read` for "unix". */
export function connect(
options: ConnectOptions | UnixConnectOptions
): Promise<Conn>;
Expand Down
2 changes: 1 addition & 1 deletion cli/js/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function isRecoverableError(e: Error): boolean {
// Returns `true` if `close()` is called in REPL.
// We should quit the REPL when this function returns `true`.
function isCloseCalled(): boolean {
// @ts-ignore
// @ts-expect-error
return globalThis.closed;
}

Expand Down
4 changes: 2 additions & 2 deletions cli/js/runtime_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { log, immutableDefine } from "./util.ts";
// TODO: factor out `Deno` global assignment to separate function
// Add internal object to Deno object.
// This is not exposed as part of the Deno types.
// @ts-ignore
// @ts-expect-error
denoNs[internalSymbol] = internalObject;

let windowIsClosing = false;
Expand Down Expand Up @@ -71,7 +71,7 @@ export function bootstrapMainRuntime(): void {
throw new Error("Worker runtime already bootstrapped");
}
// Remove bootstrapping methods from global scope
// @ts-ignore
// @ts-expect-error
globalThis.bootstrap = undefined;
log("bootstrapMainRuntime");
hasBootstrapped = true;
Expand Down
4 changes: 2 additions & 2 deletions cli/js/runtime_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { setSignals } from "./signals.ts";
// TODO: factor out `Deno` global assignment to separate function
// Add internal object to Deno object.
// This is not exposed as part of the Deno types.
// @ts-ignore
// @ts-expect-error
denoNs[internalSymbol] = internalObject;

const encoder = new TextEncoder();
Expand Down Expand Up @@ -128,7 +128,7 @@ export function bootstrapWorkerRuntime(
throw new Error("Worker runtime already bootstrapped");
}
// Remove bootstrapping methods from global scope
// @ts-ignore
// @ts-expect-error
globalThis.bootstrap = undefined;
log("bootstrapWorkerRuntime");
hasBootstrapped = true;
Expand Down
4 changes: 1 addition & 3 deletions cli/js/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,10 @@ async function runTests({
const filterFn = createFilterFn(filter, skip);
const testApi = new TestApi(TEST_REGISTRY, filterFn, failFast);

// @ts-ignore
const originalConsole = globalThis.console;

if (disableLog) {
// @ts-ignore
// @ts-expect-error
globalThis.console = disabledConsole;
}

Expand All @@ -356,7 +355,6 @@ async function runTests({
}

if (disableLog) {
// @ts-ignore
globalThis.console = originalConsole;
}

Expand Down
Loading