From f626b04ebe320a96a220af29595c6ca84cf9a10a Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Sat, 12 Jan 2019 13:50:04 -0800 Subject: [PATCH] Reorgnanize repos, examples and tests (denoland/deno_std#105) Original: https://github.com/denoland/deno_std/commit/c5e6e015b5be19027f60c19ca86283d12f9258f3 --- examples/gist.ts | 2 +- examples/ws.ts | 4 ++-- flags/example.ts | 2 +- flags/{index.ts => mod.ts} | 0 flags/tests/all_bool.ts | 2 +- flags/tests/bool.ts | 2 +- flags/tests/dash.ts | 2 +- flags/tests/default_bool.ts | 2 +- flags/tests/dotted.ts | 2 +- flags/tests/kv_short.ts | 2 +- flags/tests/long.ts | 2 +- flags/tests/num.ts | 2 +- flags/tests/parse.ts | 2 +- flags/tests/short.ts | 2 +- flags/tests/stop_early.ts | 2 +- flags/tests/unknown.ts | 2 +- flags/tests/whitespace.ts | 2 +- {net => http}/README.md | 4 ++-- {net => http}/file_server.ts | 2 +- {net => http}/file_server_test.ts | 0 {net => http}/http.ts | 6 +++--- {net => http}/http_bench.ts | 2 +- {net => http}/http_status.ts | 0 {net => http}/http_test.ts | 4 ++-- http/mod.ts | 8 ++++++++ {net => io}/bufio.ts | 0 {net => io}/bufio_test.ts | 0 {net => io}/iotest.ts | 0 {net => io}/ioutil.ts | 0 {net => io}/ioutil_test.ts | 0 {net => io}/util.ts | 0 {logging => log}/README.md | 0 {logging => log}/handlers.ts | 0 {logging => log}/levels.ts | 0 {logging => log}/logger.ts | 0 logging/index.ts => log/mod.ts | 0 {logging => log}/test.ts | 2 +- test.ts | 15 ++++++++------- net/textproto.ts => textproto/mod.ts | 4 ++-- net/textproto_test.ts => textproto/test.ts | 6 +++--- net/ws.ts => ws/mod.ts | 6 +++--- {net => ws}/sha1.ts | 0 {net => ws}/sha1_test.ts | 0 net/ws_test.ts => ws/test.ts | 6 +++--- 44 files changed, 54 insertions(+), 45 deletions(-) rename flags/{index.ts => mod.ts} (100%) rename {net => http}/README.md (70%) rename {net => http}/file_server.ts (99%) rename {net => http}/file_server_test.ts (100%) rename {net => http}/http.ts (98%) rename {net => http}/http_bench.ts (89%) rename {net => http}/http_status.ts (100%) rename {net => http}/http_test.ts (98%) create mode 100644 http/mod.ts rename {net => io}/bufio.ts (100%) rename {net => io}/bufio_test.ts (100%) rename {net => io}/iotest.ts (100%) rename {net => io}/ioutil.ts (100%) rename {net => io}/ioutil_test.ts (100%) rename {net => io}/util.ts (100%) rename {logging => log}/README.md (100%) rename {logging => log}/handlers.ts (100%) rename {logging => log}/levels.ts (100%) rename {logging => log}/logger.ts (100%) rename logging/index.ts => log/mod.ts (100%) rename {logging => log}/test.ts (94%) rename net/textproto.ts => textproto/mod.ts (97%) rename net/textproto_test.ts => textproto/test.ts (95%) rename net/ws.ts => ws/mod.ts (98%) rename {net => ws}/sha1.ts (100%) rename {net => ws}/sha1_test.ts (100%) rename net/ws_test.ts => ws/test.ts (97%) diff --git a/examples/gist.ts b/examples/gist.ts index 7b3d59f870..1baff874ae 100755 --- a/examples/gist.ts +++ b/examples/gist.ts @@ -1,7 +1,7 @@ #!/usr/bin/env deno --allow-net --allow-env import { args, env, exit, readFile } from "deno"; -import { parse } from "https://deno.land/x/flags/index.ts"; +import { parse } from "https://deno.land/x/flags/mod.ts"; function pathBase(p: string): string { const parts = p.split("/"); diff --git a/examples/ws.ts b/examples/ws.ts index f8e711c49b..bc2a7bd0be 100644 --- a/examples/ws.ts +++ b/examples/ws.ts @@ -1,10 +1,10 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { serve } from "https://deno.land/x/net/http.ts"; +import { serve } from "https://deno.land/x/http/mod.ts"; import { acceptWebSocket, isWebSocketCloseEvent, isWebSocketPingEvent -} from "https://deno.land/x/net/ws.ts"; +} from "https://deno.land/x/ws/mod.ts"; async function main() { console.log("websocket server is running on 0.0.0.0:8080"); diff --git a/flags/example.ts b/flags/example.ts index 811aacd693..5aa0a50345 100644 --- a/flags/example.ts +++ b/flags/example.ts @@ -1,4 +1,4 @@ import { args } from "deno"; -import { parse } from "./index.ts"; +import { parse } from "./mod.ts"; console.dir(parse(args)); diff --git a/flags/index.ts b/flags/mod.ts similarity index 100% rename from flags/index.ts rename to flags/mod.ts diff --git a/flags/tests/all_bool.ts b/flags/tests/all_bool.ts index 2e0bba4ce4..07b12c2920 100755 --- a/flags/tests/all_bool.ts +++ b/flags/tests/all_bool.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; // flag boolean true (default all --args to boolean) test(function flagBooleanTrue() { diff --git a/flags/tests/bool.ts b/flags/tests/bool.ts index 5d135028e5..6fa014d8dd 100755 --- a/flags/tests/bool.ts +++ b/flags/tests/bool.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function flagBooleanDefaultFalse() { const argv = parse(["moo"], { diff --git a/flags/tests/dash.ts b/flags/tests/dash.ts index f8cec6ef7d..6ab1a7d75a 100755 --- a/flags/tests/dash.ts +++ b/flags/tests/dash.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function hyphen() { assertEqual(parse(["-n", "-"]), { n: "-", _: [] }); diff --git a/flags/tests/default_bool.ts b/flags/tests/default_bool.ts index 8cf6a720b2..82dab55386 100755 --- a/flags/tests/default_bool.ts +++ b/flags/tests/default_bool.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function booleanDefaultTrue() { const argv = parse([], { diff --git a/flags/tests/dotted.ts b/flags/tests/dotted.ts index 94867abb27..6b64e3b5e8 100755 --- a/flags/tests/dotted.ts +++ b/flags/tests/dotted.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function dottedAlias() { const argv = parse(["--a.b", "22"], { diff --git a/flags/tests/kv_short.ts b/flags/tests/kv_short.ts index 1050d77347..41853c1def 100755 --- a/flags/tests/kv_short.ts +++ b/flags/tests/kv_short.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function short() { const argv = parse(["-b=123"]); diff --git a/flags/tests/long.ts b/flags/tests/long.ts index 41c3e77436..d75ece3b2d 100755 --- a/flags/tests/long.ts +++ b/flags/tests/long.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function longOpts() { assertEqual(parse(["--bool"]), { bool: true, _: [] }); diff --git a/flags/tests/num.ts b/flags/tests/num.ts index 0588b51f6d..cc5b1b4e30 100755 --- a/flags/tests/num.ts +++ b/flags/tests/num.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function nums() { const argv = parse([ diff --git a/flags/tests/parse.ts b/flags/tests/parse.ts index 30551f875d..2633357616 100644 --- a/flags/tests/parse.ts +++ b/flags/tests/parse.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function _arseArgs() { assertEqual(parse(["--no-moo"]), { moo: false, _: [] }); diff --git a/flags/tests/short.ts b/flags/tests/short.ts index dee981351f..fe89943948 100755 --- a/flags/tests/short.ts +++ b/flags/tests/short.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function numbericShortArgs() { assertEqual(parse(["-n123"]), { n: 123, _: [] }); diff --git a/flags/tests/stop_early.ts b/flags/tests/stop_early.ts index ca64bf97ec..aef4d5dc56 100755 --- a/flags/tests/stop_early.ts +++ b/flags/tests/stop_early.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; // stops parsing on the first non-option when stopEarly is set test(function stopParsing() { diff --git a/flags/tests/unknown.ts b/flags/tests/unknown.ts index 2c87b18feb..e86f927965 100755 --- a/flags/tests/unknown.ts +++ b/flags/tests/unknown.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function booleanAndAliasIsNotUnknown() { const unknown = []; diff --git a/flags/tests/whitespace.ts b/flags/tests/whitespace.ts index 8373cd19e0..46ad094260 100755 --- a/flags/tests/whitespace.ts +++ b/flags/tests/whitespace.ts @@ -1,5 +1,5 @@ import { test, assertEqual } from "../../testing/mod.ts"; -import { parse } from "../index.ts"; +import { parse } from "../mod.ts"; test(function whitespaceShouldBeWhitespace() { assertEqual(parse(["-x", "\t"]).x, "\t"); diff --git a/net/README.md b/http/README.md similarity index 70% rename from net/README.md rename to http/README.md index 65f2b9ad76..e81e42a41d 100644 --- a/net/README.md +++ b/http/README.md @@ -3,7 +3,7 @@ Usage: ```typescript -import { serve } from "https://deno.land/x/net/http.ts"; +import { serve } from "https://deno.land/x/http/mod.ts"; const s = serve("0.0.0.0:8000"); async function main() { @@ -22,5 +22,5 @@ A small program for serving local files over HTTP. Add the following to your `.bash_profile` ``` -alias file_server="deno https://deno.land/x/net/file_server.ts --allow-net" +alias file_server="deno https://deno.land/x/http/file_server.ts --allow-net" ``` diff --git a/net/file_server.ts b/http/file_server.ts similarity index 99% rename from net/file_server.ts rename to http/file_server.ts index 72432abdd7..4437a44e41 100755 --- a/net/file_server.ts +++ b/http/file_server.ts @@ -10,7 +10,7 @@ import { ServerRequest, setContentLength, Response -} from "./http.ts"; +} from "./mod.ts"; import { cwd, DenoError, ErrorKind, args, stat, readDir, open } from "deno"; import { extname } from "../fs/path.ts"; import { contentType } from "../media_types/mod.ts"; diff --git a/net/file_server_test.ts b/http/file_server_test.ts similarity index 100% rename from net/file_server_test.ts rename to http/file_server_test.ts diff --git a/net/http.ts b/http/http.ts similarity index 98% rename from net/http.ts rename to http/http.ts index e360e0d868..da7bc0169e 100644 --- a/net/http.ts +++ b/http/http.ts @@ -1,8 +1,8 @@ import { listen, Conn, toAsyncIterator, Reader, copy } from "deno"; -import { BufReader, BufState, BufWriter } from "./bufio.ts"; -import { TextProtoReader } from "./textproto.ts"; +import { BufReader, BufState, BufWriter } from "../io/bufio.ts"; +import { TextProtoReader } from "../textproto/mod.ts"; import { STATUS_TEXT } from "./http_status.ts"; -import { assert } from "./util.ts"; +import { assert } from "../io/util.ts"; interface Deferred { promise: Promise<{}>; diff --git a/net/http_bench.ts b/http/http_bench.ts similarity index 89% rename from net/http_bench.ts rename to http/http_bench.ts index 8e1e24ad60..5aca12f55c 100644 --- a/net/http_bench.ts +++ b/http/http_bench.ts @@ -1,5 +1,5 @@ import * as deno from "deno"; -import { serve } from "./http.ts"; +import { serve } from "./mod.ts"; const addr = deno.args[1] || "127.0.0.1:4500"; const server = serve(addr); diff --git a/net/http_status.ts b/http/http_status.ts similarity index 100% rename from net/http_status.ts rename to http/http_status.ts diff --git a/net/http_test.ts b/http/http_test.ts similarity index 98% rename from net/http_test.ts rename to http/http_test.ts index 9235feb02b..ba0cec3e32 100644 --- a/net/http_test.ts +++ b/http/http_test.ts @@ -12,8 +12,8 @@ import { ServerRequest, setContentLength, Response -} from "./http.ts"; -import { BufWriter, BufReader } from "./bufio.ts"; +} from "./mod.ts"; +import { BufWriter, BufReader } from "../io/bufio.ts"; interface ResponseTest { response: Response; diff --git a/http/mod.ts b/http/mod.ts new file mode 100644 index 0000000000..217bd68b32 --- /dev/null +++ b/http/mod.ts @@ -0,0 +1,8 @@ +import { + serve, + listenAndServe, + Response, + setContentLength, + ServerRequest +} from "./http.ts"; +export { serve, listenAndServe, Response, setContentLength, ServerRequest }; diff --git a/net/bufio.ts b/io/bufio.ts similarity index 100% rename from net/bufio.ts rename to io/bufio.ts diff --git a/net/bufio_test.ts b/io/bufio_test.ts similarity index 100% rename from net/bufio_test.ts rename to io/bufio_test.ts diff --git a/net/iotest.ts b/io/iotest.ts similarity index 100% rename from net/iotest.ts rename to io/iotest.ts diff --git a/net/ioutil.ts b/io/ioutil.ts similarity index 100% rename from net/ioutil.ts rename to io/ioutil.ts diff --git a/net/ioutil_test.ts b/io/ioutil_test.ts similarity index 100% rename from net/ioutil_test.ts rename to io/ioutil_test.ts diff --git a/net/util.ts b/io/util.ts similarity index 100% rename from net/util.ts rename to io/util.ts diff --git a/logging/README.md b/log/README.md similarity index 100% rename from logging/README.md rename to log/README.md diff --git a/logging/handlers.ts b/log/handlers.ts similarity index 100% rename from logging/handlers.ts rename to log/handlers.ts diff --git a/logging/levels.ts b/log/levels.ts similarity index 100% rename from logging/levels.ts rename to log/levels.ts diff --git a/logging/logger.ts b/log/logger.ts similarity index 100% rename from logging/logger.ts rename to log/logger.ts diff --git a/logging/index.ts b/log/mod.ts similarity index 100% rename from logging/index.ts rename to log/mod.ts diff --git a/logging/test.ts b/log/test.ts similarity index 94% rename from logging/test.ts rename to log/test.ts index 17117ae8b6..fdc994eb79 100644 --- a/logging/test.ts +++ b/log/test.ts @@ -1,6 +1,6 @@ import { remove, open, readAll } from "deno"; import { assertEqual, test } from "../testing/mod.ts"; -import * as log from "index.ts"; +import * as log from "./mod.ts"; import { FileHandler } from "./handlers.ts"; // TODO: establish something more sophisticated diff --git a/test.ts b/test.ts index 8a35344574..994148178e 100755 --- a/test.ts +++ b/test.ts @@ -5,11 +5,6 @@ import "colors/test.ts"; import "datetime/test.ts"; import "examples/test.ts"; import "flags/test.ts"; -import "logging/test.ts"; -import "media_types/test.ts"; -import "net/bufio_test.ts"; -import "net/http_test.ts"; -import "net/textproto_test.ts"; import "fs/mkdirp_test.ts"; import "fs/path/basename_test.ts"; import "fs/path/dirname_test.ts"; @@ -20,12 +15,18 @@ import "fs/path/parse_format_test.ts"; import "fs/path/relative_test.ts"; import "fs/path/resolve_test.ts"; import "fs/path/zero_length_strings_test.ts"; +import "io/bufio_test.ts"; +import "http/http_test.ts"; +import "log/test.ts"; +import "media_types/test.ts"; import "testing/test.ts"; +import "textproto/test.ts"; +import "ws/test.ts"; -import { runTests, completePromise } from "net/file_server_test.ts"; +import { runTests, completePromise } from "http/file_server_test.ts"; const fileServer = run({ - args: ["deno", "--allow-net", "net/file_server.ts", ".", "--cors"] + args: ["deno", "--allow-net", "http/file_server.ts", ".", "--cors"] }); runTests(new Promise(res => setTimeout(res, 5000))); diff --git a/net/textproto.ts b/textproto/mod.ts similarity index 97% rename from net/textproto.ts rename to textproto/mod.ts index 832299e1c2..ee76472967 100644 --- a/net/textproto.ts +++ b/textproto/mod.ts @@ -3,8 +3,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -import { BufReader, BufState } from "./bufio.ts"; -import { charCode } from "./util.ts"; +import { BufReader, BufState } from "../io/bufio.ts"; +import { charCode } from "../io/util.ts"; const asciiDecoder = new TextDecoder(); function str(buf: Uint8Array): string { diff --git a/net/textproto_test.ts b/textproto/test.ts similarity index 95% rename from net/textproto_test.ts rename to textproto/test.ts index e0ae0749c7..0f8bee2275 100644 --- a/net/textproto_test.ts +++ b/textproto/test.ts @@ -3,9 +3,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -import { BufReader } from "./bufio.ts"; -import { TextProtoReader, append } from "./textproto.ts"; -import { stringsReader } from "./util.ts"; +import { BufReader } from "../io/bufio.ts"; +import { TextProtoReader, append } from "./mod.ts"; +import { stringsReader } from "../io/util.ts"; import { test, assert, assertEqual } from "../testing/mod.ts"; function reader(s: string): TextProtoReader { diff --git a/net/ws.ts b/ws/mod.ts similarity index 98% rename from net/ws.ts rename to ws/mod.ts index 5ce96b3ca8..b0b4909782 100644 --- a/net/ws.ts +++ b/ws/mod.ts @@ -1,8 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { Buffer, Writer, Conn } from "deno"; -import { ServerRequest } from "./http.ts"; -import { BufReader, BufWriter } from "./bufio.ts"; -import { readLong, readShort, sliceLongToBytes } from "./ioutil.ts"; +import { ServerRequest } from "../http/http.ts"; +import { BufReader, BufWriter } from "../io/bufio.ts"; +import { readLong, readShort, sliceLongToBytes } from "../io/ioutil.ts"; import { Sha1 } from "./sha1.ts"; export const OpCodeContinue = 0x0; diff --git a/net/sha1.ts b/ws/sha1.ts similarity index 100% rename from net/sha1.ts rename to ws/sha1.ts diff --git a/net/sha1_test.ts b/ws/sha1_test.ts similarity index 100% rename from net/sha1_test.ts rename to ws/sha1_test.ts diff --git a/net/ws_test.ts b/ws/test.ts similarity index 97% rename from net/ws_test.ts rename to ws/test.ts index 62e5a60891..bf800f7e36 100644 --- a/net/ws_test.ts +++ b/ws/test.ts @@ -1,6 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { Buffer } from "deno"; -import { BufReader } from "./bufio.ts"; +import { BufReader } from "../io/bufio.ts"; import { test, assert, assertEqual } from "../testing/mod.ts"; import { createSecAccept, @@ -11,8 +11,8 @@ import { OpCodeTextFrame, readFrame, unmask -} from "./ws.ts"; -import { serve } from "./http.ts"; +} from "./mod.ts"; +import { serve } from "../http/http.ts"; test(async function testReadUnmaskedTextFrame() { // unmasked single text frame with payload "Hello"