diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..79cff88 --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,18 @@ +name: Check +"on": + push: + branches: + - main + pull_request: + branches: + - main +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v1 + - name: Format + run: deno fmt && git diff-index --quiet HEAD + - name: Lint + run: deno lint && git diff-index --quiet HEAD diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..24b0f5e --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,17 @@ +name: Publish +"on": + push: + branches: + - main + workflow_dispatch: {} +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v1 + - name: Publish package + run: deno publish diff --git a/README.md b/README.md index 69678b0..34e664c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,60 @@ -# html +# [@fartlabs/ht](https://jsr.io/@fartlabs/ht) + +[![JSR score](https://jsr.io/badges/@fartlabs/ht/score)](https://jsr.io/@fartlabs/ht) +[![GitHub Actions](https://github.com/FartLabs/ht/actions/workflows/check.yaml/badge.svg)](https://github.com/FartLabs/ht/actions/workflows/check.yaml) An HTML rendering library. + +## Getting started + +1\. [Install Deno](https://docs.deno.com/runtime/manual). + +2\. Start a new Deno project. + +```sh +deno init +``` + +3\. Add html as a project dependency. + +```sh +deno add @fartlabs/ht +``` + +4\. Add a file ending in `.[j|t]s` to your project. For example, `main.ts`. + +```ts +import { a } from "@fartlabs/ht"; + +const html = a({ href: "https://example.com" }, "Hello, world!"); + +Deno.writeTextFileSync("index.html", html); +``` + +5\. Compile your html by running the `.[j|t]s` file. + +```sh +deno run --allow-write main.ts +``` + +Resulting `index.html`: + +```html +Hello, world! +``` + +## Contribute + +We appreciate your help! + +### Style + +Run `deno fmt` to format the code. + +Run `deno lint` to lint the code. + +Run `deno task generate` to generate code. + +--- + +Developed with ❤️ [**@FartLabs**](https://github.com/FartLabs) diff --git a/cli/codegen.ts b/cli/codegen.ts index 304adee..396e09e 100644 --- a/cli/codegen.ts +++ b/cli/codegen.ts @@ -15,7 +15,7 @@ * └── ./mod.ts */ -import { Project } from "ts_morph"; +import { Project } from "ts-morph"; import bcd from "@mdn/browser-compat-data" with { type: "json" }; /** @@ -209,8 +209,10 @@ if (import.meta.main) { // Update the deno.json exports. const denoConfig = JSON.parse(await Deno.readTextFile("./deno.json")); denoConfig.exports = { + "./cli/codegen.ts": "./cli/codegen.ts", + "./lib/global_attributes.ts": "./lib/global_attributes.ts", + "./lib/render.ts": "./lib/render.ts", ".": "./mod.ts", - "./cli/codegen": "./cli/codegen.ts", ...Object.fromEntries(descriptors.map((descriptor) => [ `./${descriptor.tag}`, `./${descriptor.tag}.ts`, diff --git a/deno.json b/deno.json index b9dc590..dd13765 100644 --- a/deno.json +++ b/deno.json @@ -1,15 +1,19 @@ { "lock": false, + "name": "@fartlabs/ht", + "version": "0.0.1", "imports": { "@mdn/browser-compat-data": "npm:@mdn/browser-compat-data@^5.5.19", - "ts_morph": "https://deno.land/x/ts_morph@22.0.0/mod.ts" + "ts-morph": "npm:ts-morph@^22.0.0" }, "tasks": { "generate": "deno run -A cli/codegen.ts" }, "exports": { + "./cli/codegen.ts": "./cli/codegen.ts", + "./lib/global_attributes.ts": "./lib/global_attributes.ts", + "./lib/render.ts": "./lib/render.ts", ".": "./mod.ts", - "./cli/codegen": "./cli/codegen.ts", "./a": "./a.ts", "./abbr": "./abbr.ts", "./acronym": "./acronym.ts",