Skip to content

Commit

Permalink
Reorgnanize repos, examples and tests (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
hayd authored and ry committed Jan 12, 2019
1 parent 41312ad commit c5e6e01
Show file tree
Hide file tree
Showing 44 changed files with 54 additions and 45 deletions.
2 changes: 1 addition & 1 deletion examples/gist.ts
Original file line number Diff line number Diff line change
@@ -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("/");
Expand Down
4 changes: 2 additions & 2 deletions examples/ws.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
2 changes: 1 addition & 1 deletion flags/example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { args } from "deno";
import { parse } from "./index.ts";
import { parse } from "./mod.ts";

console.dir(parse(args));
File renamed without changes.
2 changes: 1 addition & 1 deletion flags/tests/all_bool.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/bool.ts
Original file line number Diff line number Diff line change
@@ -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"], {
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/dash.ts
Original file line number Diff line number Diff line change
@@ -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: "-", _: [] });
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/default_bool.ts
Original file line number Diff line number Diff line change
@@ -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([], {
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/dotted.ts
Original file line number Diff line number Diff line change
@@ -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"], {
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/kv_short.ts
Original file line number Diff line number Diff line change
@@ -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"]);
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/long.ts
Original file line number Diff line number Diff line change
@@ -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, _: [] });
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/num.ts
Original file line number Diff line number Diff line change
@@ -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([
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/parse.ts
Original file line number Diff line number Diff line change
@@ -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, _: [] });
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/short.ts
Original file line number Diff line number Diff line change
@@ -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, _: [] });
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/stop_early.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/unknown.ts
Original file line number Diff line number Diff line change
@@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion flags/tests/whitespace.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
4 changes: 2 additions & 2 deletions net/README.md → http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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"
```
2 changes: 1 addition & 1 deletion net/file_server.ts → http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions net/http.ts → http/http.ts
Original file line number Diff line number Diff line change
@@ -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<{}>;
Expand Down
2 changes: 1 addition & 1 deletion net/http_bench.ts → http/http_bench.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions net/http_test.ts → http/http_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions http/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {
serve,
listenAndServe,
Response,
setContentLength,
ServerRequest
} from "./http.ts";
export { serve, listenAndServe, Response, setContentLength, ServerRequest };
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion logging/test.ts → log/test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 8 additions & 7 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)));
Expand Down
4 changes: 2 additions & 2 deletions net/textproto.ts → textproto/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions net/textproto_test.ts → textproto/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions net/ws.ts → ws/mod.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions net/ws_test.ts → ws/test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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"
Expand Down

0 comments on commit c5e6e01

Please sign in to comment.