Skip to content

Commit

Permalink
Deno (#20)
Browse files Browse the repository at this point in the history
* add deno adapter

* create domco - deno

* changeset

* add docs

* bump / doc
  • Loading branch information
rossrobino authored Sep 12, 2024
1 parent f38238a commit d52d692
Show file tree
Hide file tree
Showing 34 changed files with 765 additions and 391 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-cars-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"domco": minor
---

Adds `deno deploy` adapter
5 changes: 5 additions & 0 deletions .changeset/quiet-geese-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-domco": patch
---

add `deno` as a pm -- detects and outputs deno project template
Binary file added apps/docs/public/images/deno/build-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions apps/docs/src/content/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,28 @@ export default defineConfig({

### Cloudflare

The [Cloudflare](https://cloudflare.com) adapter outputs your app to work on Cloudflare Pages.
The [Cloudflare](https://cloudflare.com) adapter outputs your app to run on [Cloudflare Pages](https://pages.cloudflare.com/).

- Function runs on [workerd](https://github.com/cloudflare/workerd).
- Outputs public assets to be served on Cloudflare's CDN.

![A screenshot of the Cloudflare Build Settings UI. Set the Framework Preset field to "None", set the build command to "npm run build", and the build output directory to ".cloudflare".](/_vercel/image?url=/images/cloudflare/build-settings.png&w=1280&q=100)

- Functions run on the [Workers Runtime](https://developers.cloudflare.com/workers/runtime-apis/).
- Outputs public assets to be served on Cloudflare's CDN.
### Deno

The [Deno](https://deno.com) adapter outputs your app to run on [Deno Deploy](https://deno.com/deploy).

- Function runs on Deno.
- Static files are served with [`@std/http/file-server`](https://jsr.io/@std/http).

![A screenshot of the Deno Deploy Project Configuration UI. Set the Framework Preset field to "None", set the build command to "deno run -A npm:vite build", and the entrypoint to "dist/server/main.js".](/_vercel/image?url=/images/deno/build-settings.png&w=1280&q=100)

### Vercel

The [Vercel](https://vercel.com) adapter outputs your app to the [Build Output API](https://vercel.com/docs/build-output-api/v3) specification.

![A screenshot of the Vercel Build and Development Settings UI. Set the Framework Preset field to "Other" and leave all of the other options blank.](/_vercel/image?url=/images/vercel/build-settings.png&w=1280&q=100)

- Functions run on [Node.js](https://vercel.com/docs/functions/runtimes#node.js), [Node.js with ISR](https://vercel.com/docs/incremental-static-regeneration), or [Edge Runtime](https://vercel.com/docs/functions/runtimes/edge-runtime).
- Function runs on [Node.js](https://vercel.com/docs/functions/runtimes#node.js), [Node.js with ISR](https://vercel.com/docs/incremental-static-regeneration), or [Edge Runtime](https://vercel.com/docs/functions/runtimes/edge-runtime).
- Outputs public assets to be served on Vercel's [Edge Network](https://vercel.com/docs/edge-network/overview).
- Supports on demand [Image Optimization](https://vercel.com/docs/image-optimization) when configured in the adapter config. Set the `src` attribute of an image using the `/_vercel/image/...` [optimized URL format](https://vercel.com/docs/image-optimization#optimized-url-format). In `dev` and `preview` modes, domco will redirect to the original image.

![A screenshot of the Vercel Build and Development Settings UI. Set the Framework Preset field to "Other" and leave all of the other options blank.](/_vercel/image?url=/images/vercel/build-settings.png&w=1280&q=100)
42 changes: 25 additions & 17 deletions apps/docs/src/generated/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ Message to log when the build is complete.
The name of the adapter.

<a id="noexternal" name="noexternal"></a>

##### noExternal?

> `optional` **noExternal**: `SSROptions`\[`"noExternal"`\]
Passed into Vite `config.ssr.noExternal`.

<a id="previewmiddleware" name="previewmiddleware"></a>

##### previewMiddleware?
Expand All @@ -64,17 +72,17 @@ The script to run after Vite build is complete.

`any`

<a id="ssrtarget" name="ssrtarget"></a>
<a id="target" name="target"></a>

##### ssrTarget
##### target?

> **ssrTarget**: `SSRTarget`
> `optional` **target**: `SSRTarget`
Target for SSR build.
Passed into Vite `config.ssr.target`.

#### Defined in

[types/public/index.ts:44](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L44)
[types/public/index.ts:44](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L44)

---

Expand All @@ -86,7 +94,7 @@ Target for SSR build.
#### Type Parameters

**AdapterOptions** = `object`
**AdapterOptions** = `never`

#### Parameters

Expand All @@ -98,7 +106,7 @@ Target for SSR build.

#### Defined in

[types/public/index.ts:83](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L83)
[types/public/index.ts:78](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L78)

---

Expand Down Expand Up @@ -140,7 +148,7 @@ The name of the entrypoint without extension.

#### Defined in

[types/public/index.ts:29](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L29)
[types/public/index.ts:29](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L29)

---

Expand All @@ -160,7 +168,7 @@ The name of the entrypoint without extension.

#### Defined in

[types/public/index.ts:146](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L146)
[types/public/index.ts:141](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L141)

---

Expand Down Expand Up @@ -190,7 +198,7 @@ Path to apply the middleware to.

#### Defined in

[types/public/index.ts:7](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L7)
[types/public/index.ts:7](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L7)

---

Expand Down Expand Up @@ -229,7 +237,7 @@ inject middleware.

#### Defined in

[types/public/index.ts:15](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L15)
[types/public/index.ts:15](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L15)

---

Expand Down Expand Up @@ -286,7 +294,7 @@ export default defineConfig({

#### Defined in

[types/public/index.ts:109](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L109)
[types/public/index.ts:104](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L104)

---

Expand Down Expand Up @@ -447,7 +455,7 @@ declare module "hono" {

#### Defined in

[types/public/index.ts:171](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L171)
[types/public/index.ts:166](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L166)

---

Expand All @@ -467,7 +475,7 @@ declare module "hono" {

#### Defined in

[types/public/index.ts:144](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L144)
[types/public/index.ts:139](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L139)

---

Expand All @@ -494,7 +502,7 @@ export const prerender: Prerender = ["/", "/post-1", "/post-2"];

#### Defined in

[types/public/index.ts:142](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L142)
[types/public/index.ts:137](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L137)

---

Expand All @@ -516,7 +524,7 @@ export const prerender: Prerender = ["/", "/post-1", "/post-2"];

#### Defined in

[types/public/index.ts:148](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/types/public/index.ts#L148)
[types/public/index.ts:143](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/types/public/index.ts#L143)

## Functions

Expand Down Expand Up @@ -553,4 +561,4 @@ export default defineConfig({

#### Defined in

[plugin/index.ts:31](https://github.com/rossrobino/domco/blob/fde430c2d32883df987ac54237edd49a27dfdd7e/packages/domco/src/plugin/index.ts#L31)
[plugin/index.ts:31](https://github.com/rossrobino/domco/blob/b818d1141c9ab3d2c6ee8351170a98e520e95923/packages/domco/src/plugin/index.ts#L31)
5 changes: 2 additions & 3 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions packages/create-domco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"LICENSE.md"
],
"scripts": {
"test": "rm -rf ./create-domco-test && echo 'Create your project in `create-domco-test`\n\n' && node ./dist/bin.js",
"test:clean": "rm -rf ./create-domco-test",
"test": "build:js && npm run test:clean && echo 'Create your project in `create-domco-test`\n\n' && node ./dist/bin.js",
"dev": "tsc --watch",
"build:clean": "rm -rf ./dist",
"build:js": "tsc",
"build": "npm run build:clean && npm run build:js"
"build": "npm run test:clean && npm run build:clean && npm run build:js"
},
"author": {
"name": "Ross Robino",
Expand Down
100 changes: 2 additions & 98 deletions packages/create-domco/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,100 +1,4 @@
#!/usr/bin/env node
import { getFiles } from "./template/index.js";
import * as p from "@clack/prompts";
import { writeFile, mkdir } from "node:fs/promises";
import { dirname, join } from "node:path";
import process from "node:process";
import whichPmRuns from "which-pm-runs";
import { createDomco } from "./index.js";

/**
* Writes an array of files to the specified directory.
* @param directory - the directory to write the files to
* @param files - the files to write
* @returns a Promise that resolves when all the files have been written
*/
const writeFiles = async (
directory: string,
files: { name: string; contents: string }[],
) => {
return Promise.all(
files.map(async (file) => {
const filePath = join(directory, file.name);
const fileDirectory = dirname(filePath);

// Ensure directory exists
await mkdir(fileDirectory, { recursive: true });

// Write file
return writeFile(filePath, file.contents);
}),
);
};

const pm = whichPmRuns()?.name || "npm";

p.intro("Welcome to domco");

let dir = await p.text({
message: "Where should your project be created?",
defaultValue: ".",
placeholder: "(Enter for current directory)",
});

if (p.isCancel(dir)) {
p.cancel("Operation cancelled.");
process.exit(0);
} else {
const lang = await p.select({
message: "Select language",
options: [
{ label: "TypeScript", value: "ts" },
{ label: "JavaScript", value: "js" },
],
});

if (p.isCancel(lang)) {
p.cancel("Operation cancelled.");
process.exit(0);
} else {
const extras = await p.multiselect({
message: "Select additional options (use arrow keys/space bar)",
required: false,
options: [
{
value: "prettier",
label: "Add Prettier for formatting",
},
{
value: "tailwind",
label: "Add TailwindCSS for styling",
},
],
});

if (p.isCancel(extras)) {
p.cancel("Operation cancelled.");
process.exit(0);
} else {
const prettier = extras.includes("prettier");
const tailwind = extras.includes("tailwind");

const s = p.spinner();

s.start("Creating project");

await writeFiles(
dir,
getFiles({ lang: String(lang), prettier, tailwind }),
);

s.stop("Files created");

p.note(
`${dir === "." ? "" : `cd ${dir}\n`}${pm} install\n${pm} run dev`,
`Next steps`,
);

p.outro(`https://github.com/rossrobino/domco`);
}
}
}
createDomco();
10 changes: 10 additions & 0 deletions packages/create-domco/src/dependencies/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const dependencies = {
domco: "0.12.0",
hono: "4.6.1",
autoprefixer: "10.4.20",
prettier: "3.3.3",
prettierTailwind: "0.6.6",
tailwind: "3.4.11",
typescript: "5.6.0",
vite: "5.4.3",
} as const;
Loading

0 comments on commit d52d692

Please sign in to comment.