Skip to content

Commit

Permalink
Clean up project structure.
Browse files Browse the repository at this point in the history
When we used to publish to deno.land/x/, the entire source code
structure was exposed, so keeping embed.ts and mod.ts at the root
made sense.

Now that we publish to JSR, only things explicitly listed as exports in
deno.json[c] are public, and we can give them short paths there,
regardless of where they're located in our project directories.

So, let's move our source into src/.
  • Loading branch information
NfNitLoop committed Jul 1, 2024
1 parent a9d8b18 commit 015e219
Show file tree
Hide file tree
Showing 41 changed files with 38 additions and 44 deletions.
26 changes: 9 additions & 17 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "@nfnitloop/deno-embedder",
"version": "1.4.7",
"exports": {
".": "./mod.ts",
"./plugins/plugins": "./plugins/plugins.ts",
"./plugins/esbuild": "./plugins/esbuild.ts",
"./helpers/oak": "./helpers/oak.ts",
"./helpers/hono": "./helpers/hono.ts",
".": "./src/mod.ts",
"./plugins/plugins": "./src/plugins/plugins.ts",
"./plugins/esbuild": "./src/plugins/esbuild.ts",
"./helpers/oak": "./src/helpers/oak.ts",
"./helpers/hono": "./src/helpers/hono.ts",

// Allows easily running the example server:
"./examples/with-embedder": "./examples/with-embedder/server.ts",
Expand All @@ -18,20 +18,12 @@
"./examples/hono": "./examples/hono/server.ts",

// Needs to be exposed so that embedded files can import w/ JSR syntax. You shouldn't use this directly.
"./embed.ts": "./embed.ts"
"./embed.ts": "./src/embed.ts"
},
"publish": {
"include": [
"README.md",

"mod.ts",
"embed.ts",

// TODO: Move stuff into a src/ dir now that we have JSR exports. (<3)
"_src/**/*.ts",
"deps/**/*.ts",
"plugins/**/*.ts",
"helpers/**/*.ts",
"src/**/*.ts",
"examples/with-embedder/**/*.ts",
"examples/hono/**/*.ts"
]
Expand All @@ -41,7 +33,7 @@
"test": "deno task check && deno test --doc -A && deno task examples:test && deno task lints",

"check": "deno task check:main && deno task check:without-embedder && deno task examples:build && deno task examples:check && deno task check:publish",
"check:main": "deno check mod.ts embed.ts helpers/oak.ts helpers/hono.ts plugins/esbuild.ts",
"check:main": "deno check src/mod.ts src/embed.ts src/helpers/oak.ts src/helpers/hono.ts src/plugins/esbuild.ts",
"check:publish": "deno publish --dry-run --allow-dirty",
"check:without-embedder": "cd examples/without-embedder; deno task check",

Expand Down Expand Up @@ -79,7 +71,7 @@
// Has example code that references theoretical modules:
"README.md",
// Pseudocode doc block example:
"helpers/hono.ts"
"src/helpers/hono.ts"
]
}
}
1 change: 1 addition & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/hono/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/hono/embed/code/_app.js.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/hono/embed/code/dir.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/hono/embed/static/_Smiley.svg.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/hono/embed/static/_index.html.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/hono/embed/static/dir.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/hono/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// lives in the same repository as this example. You should import these from
// `jsr:@nfnitloop/deno-embedder@version`
//
import * as embedder from "../../mod.ts"
import { ESBuild } from "../../plugins/esbuild.ts"
import * as embedder from "../../src/mod.ts"
import { ESBuild } from "../../src/plugins/esbuild.ts"


export const options = {
Expand Down
4 changes: 2 additions & 2 deletions examples/hono/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hono } from "../../deps/hono.ts";
import { serveDir, serveStatic } from "../../helpers/hono.ts";
import { Hono } from "../../src/deps/hono.ts";
import { serveDir, serveStatic } from "../../src/helpers/hono.ts";
import staticFiles from "./embed/static/dir.ts";
import bundledJs from "./embed/code/dir.ts";

Expand Down
2 changes: 1 addition & 1 deletion examples/with-embedder/embed/code/_app.js.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/with-embedder/embed/code/dir.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/with-embedder/embed/static/_Smiley.svg.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/with-embedder/embed/static/_index.html.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/with-embedder/embed/static/dir.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/with-embedder/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// lives in the same repository as this example. You should import these from
// `jsr:@nfnitloop/deno-embedder@version`
//
import * as embedder from "../../mod.ts"
import { ESBuild } from "../../plugins/esbuild.ts"
import * as embedder from "../../src/mod.ts"
import { ESBuild } from "../../src/plugins/esbuild.ts"


export const options = {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-embedder/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { serveDir, oak } from "../../helpers/oak.ts"
import { serveDir, oak } from "../../src/helpers/oak.ts"
import staticFiles from "./embed/static/dir.ts"
import bundledJs from "./embed/code/dir.ts"
import sarcasm from "./browserCode/sarcasm.ts";
Expand Down
2 changes: 1 addition & 1 deletion examples/without-embedder/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Application } from "../../deps/oak.ts";
import { Application } from "../../src/deps/oak.ts";

const app = new Application();

Expand Down
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.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions mod.ts → src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { Command } from "./deps/cliffy/command.ts";

import * as embed from "./embed.ts"
import type { FileEmitter, Plugin } from "./plugins/plugins.ts"
import { recursiveReadDir } from "./_src/util.ts";
import { toJsr } from "./_src/jsr_fix.ts";
import { recursiveReadDir } from "./util.ts";
import { toJsr } from "./jsr_fix.ts";

const VERSION = "1.0.0"
const DIR_FILENAME = "dir.ts"
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion _src/util.ts → src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @module
*/

import { join as pathJoin } from "../deps/std/path.ts";
import { join as pathJoin } from "./deps/std/path.ts";

/** Read all files from a directory tree, recursively. */
export async function * recursiveReadDir(dir: string): AsyncGenerator<Deno.DirEntry> {
Expand Down
2 changes: 1 addition & 1 deletion tests/jsr_paths/sample/embedder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as embedder from "../../../mod.ts"
import * as embedder from "../../../src/mod.ts"

export const options = {
importMeta: import.meta,
Expand Down
2 changes: 1 addition & 1 deletion tests/jsr_paths/sample/src/embedded/_foo_bar.ts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/jsr_paths/sample/src/embedded/_foobar_.d_ts_.ts.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/jsr_paths/sample/src/embedded/dir.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/jsr_paths/sample/src/embedded/foo_bar/_baz.txt.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/jsr_paths/sample/src/embedded/foo_bar/_baz_etc.md.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 015e219

Please sign in to comment.