-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING: Stop exposing internal things from mod.ts (#170)
- Loading branch information
Showing
6 changed files
with
140 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,69 @@ | ||
// Generated by tools/make_mod.ts. Don't edit. | ||
export * from "./command.ts"; | ||
export * from "./connection.ts"; | ||
export * from "./errors.ts"; | ||
export * from "./executor.ts"; | ||
export * from "./io.ts"; | ||
export * from "./pipeline.ts"; | ||
export * from "./pubsub.ts"; | ||
export * from "./redis.ts"; | ||
export * from "./stream.ts"; | ||
export { connect, parseURL } from "./redis.ts"; | ||
export { | ||
ConnectionClosedError, | ||
EOFError, | ||
ErrorReplyError, | ||
InvalidStateError, | ||
SubscriptionClosedError, | ||
} from "./errors.ts"; | ||
export type { RedisCommands } from "./command.ts"; | ||
export type { Connection, RedisConnectionOptions } from "./connection.ts"; | ||
export type { | ||
ArrayReply, | ||
Bulk, | ||
BulkNil, | ||
BulkReply, | ||
BulkString, | ||
ConditionalArray, | ||
ErrorReply, | ||
Integer, | ||
IntegerReply, | ||
Raw, | ||
RawReplyOrError, | ||
RedisRawReply, | ||
Status, | ||
StatusReply, | ||
} from "./io.ts"; | ||
export type { RedisPipeline } from "./pipeline.ts"; | ||
export type { RedisPubSubMessage, RedisSubscription } from "./pubsub.ts"; | ||
export type { Redis, RedisConnectOptions } from "./redis.ts"; | ||
export type { | ||
StartEndCount, | ||
XAddFieldValues, | ||
XClaimJustXId, | ||
XClaimMessages, | ||
XClaimOpts, | ||
XClaimReply, | ||
XConsumerDetail, | ||
XGroupDetail, | ||
XId, | ||
XIdAdd, | ||
XIdCreateGroup, | ||
XIdGroupRead, | ||
XIdInput, | ||
XIdNeg, | ||
XIdPos, | ||
XInfoConsumer, | ||
XInfoConsumersReply, | ||
XInfoGroup, | ||
XInfoGroupsReply, | ||
XInfoStreamFullReply, | ||
XInfoStreamReply, | ||
XKeyId, | ||
XKeyIdGroup, | ||
XKeyIdGroupLike, | ||
XKeyIdLike, | ||
XMaxlen, | ||
XMessage, | ||
XPendingConsumer, | ||
XPendingCount, | ||
XPendingReply, | ||
XReadGroupOpts, | ||
XReadIdData, | ||
XReadOpts, | ||
XReadReply, | ||
XReadReplyRaw, | ||
XReadStream, | ||
XReadStreamRaw, | ||
} from "./stream.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,77 @@ | ||
#!/usr/bin/env deno run --allow-read --allow-write | ||
#!/usr/bin/env deno run --allow-read --allow-write --allow-run | ||
|
||
const encoder = new TextEncoder(); | ||
const decoder = new TextDecoder(); | ||
|
||
interface Node { | ||
kind: string; | ||
name: string; | ||
} | ||
|
||
async function doc(fileName: string): Promise<Array<Node>> { | ||
const deno = Deno.run({ | ||
cmd: [Deno.execPath(), "doc", "--json", fileName], | ||
stdout: "piped", | ||
}); | ||
try { | ||
const out = await Deno.readAll(deno.stdout); | ||
return JSON.parse(decoder.decode(out)); | ||
} finally { | ||
deno.stdout.close(); | ||
deno.close(); | ||
} | ||
} | ||
|
||
async function fmt(content: string): Promise<string> { | ||
const deno = Deno.run({ | ||
cmd: [Deno.execPath(), "fmt", "-"], | ||
stdin: "piped", | ||
stdout: "piped", | ||
}); | ||
try { | ||
await Deno.writeAll(deno.stdin, encoder.encode(content)); | ||
deno.stdin.close(); | ||
const formattedContent = decoder.decode(await Deno.readAll(deno.stdout)); | ||
return formattedContent; | ||
} finally { | ||
deno.stdout.close(); | ||
deno.close(); | ||
} | ||
} | ||
|
||
const files = [...Deno.readDirSync(".")].filter((f) => { | ||
const name = f.name; | ||
if (!name || name === "mod.ts") return false; | ||
return name.endsWith(".ts") && !name.endsWith("_test.ts") && | ||
!name.endsWith(".d.ts"); | ||
}).map((f) => f.name).sort(); | ||
let content = "// Generated by tools/make_mod.ts. Don't edit.\n"; | ||
let content = `// Generated by tools/make_mod.ts. Don't edit.\n`; | ||
|
||
// Expose public functions from redis.ts. | ||
{ | ||
const fileName = "redis.ts"; | ||
const functions = (await doc(fileName)).filter((node) => { | ||
return node.kind === "function"; | ||
}).map((node) => node.name); | ||
content += `export { ${functions.join(",")} } from "./${fileName}";\n`; | ||
} | ||
|
||
// Expose public classes from errors.ts | ||
{ | ||
const fileName = "errors.ts"; | ||
const classes = (await doc(fileName)).filter((node) => { | ||
return node.kind === "class"; | ||
}).map((node) => node.name); | ||
content += `export { ${classes.join(",")} } from "./${fileName}";\n`; | ||
} | ||
|
||
// Expose types from *.ts. | ||
for (const f of files) { | ||
content += `export * from "./${f}";\n`; | ||
const types = (await doc(f)).filter((node) => { | ||
return node.kind === "interface" || node.kind === "typeAlias"; | ||
}).map((node) => node.name); | ||
if (types.length > 0) { | ||
content += `export type { ${types.join(",")} } from "./${f}"\n`; | ||
} | ||
} | ||
Deno.writeFileSync("mod.ts", new TextEncoder().encode(content)); | ||
Deno.writeFileSync("mod.ts", encoder.encode(await fmt(content))); |