Unverified Commit f293aec9 authored by Hong Minhee's avatar Hong Minhee
Browse files

Utilize workspaces introduced in Deno 1.45.0

parent ac8cb1f2
Loading
Loading
Loading
Loading
+22 −18
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@ jobs:
      pull-requests: write
    steps:
    - uses: actions/checkout@v4
    - uses: denoland/setup-deno@v1
    - uses: denoland/setup-deno@v2
      with:
        deno-version: v1.x
        deno-version: v2.x
    - run: deno task cache
      working-directory: ${{ github.workspace }}/src/
    - run: deno task test --coverage=.cov --junit-path=.test-report.xml
@@ -42,13 +42,18 @@ jobs:
        check_name: "Test Results (Windows)"
        files: src/.test-report.xml
      continue-on-error: true
    - if: '!cancelled()'
      uses: codecov/test-results-action@v1
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        files: src/.test-report.xml
    - run: deno coverage --lcov .cov > .cov.lcov
      working-directory: ${{ github.workspace }}/src/
      continue-on-error: true
    - uses: codecov/codecov-action@v4
    - uses: codecov/codecov-action@v5
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        file: src/.cov.lcov
        files: src/.cov.lcov
      continue-on-error: true
    - run: "true"

@@ -60,9 +65,9 @@ jobs:
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v4
    - uses: denoland/setup-deno@v1
    - uses: denoland/setup-deno@v2
      with:
        deno-version: v1.x
        deno-version: v2.x
    - uses: actions/setup-node@v4
      with:
        node-version: lts/*
@@ -80,13 +85,10 @@ jobs:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: denoland/setup-deno@v1
    - uses: denoland/setup-deno@v2
      with:
        deno-version: v1.x
        deno-version: v2.x
    - run: deno task hooks:pre-commit
      working-directory: ${{ github.workspace }}/src/
    - run: deno task check
      working-directory: ${{ github.workspace }}/examples/blog/

  release-test:
    runs-on: ubuntu-latest
@@ -95,9 +97,9 @@ jobs:
      contents: read
    steps:
    - uses: actions/checkout@v4
    - uses: denoland/setup-deno@v1
    - uses: denoland/setup-deno@v2
      with:
        deno-version: v1.x
        deno-version: v2.x
    - uses: actions/setup-node@v4
      with:
        node-version: lts/*
@@ -120,9 +122,9 @@ jobs:
      contents: write
    steps:
    - uses: actions/checkout@v4
    - uses: denoland/setup-deno@v1
    - uses: denoland/setup-deno@v2
      with:
        deno-version: v1.x
        deno-version: v2.x
    - uses: actions/setup-node@v4
      with:
        node-version: lts/*
@@ -141,7 +143,7 @@ jobs:
        [[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]
        ! grep -i "to be released" CHANGES.md
      working-directory: ${{ github.workspace }}/src/
    # Don't know why, but the .gitignore list is not overriden by include list
    # Don't know why, but the .gitignore list is not overridden by include list
    # in deno.json:
    - run: rm vocab/.gitignore
      working-directory: ${{ github.workspace }}/src/
@@ -217,9 +219,9 @@ jobs:
      contents: read
    steps:
    - uses: actions/checkout@v4
    - uses: denoland/setup-deno@v1
    - uses: denoland/setup-deno@v2
      with:
        deno-version: v1.x
        deno-version: v2.x
    - run: deno task codegen
      working-directory: ${{ github.workspace }}/src/
    - uses: denoland/deployctl@v1
@@ -281,3 +283,5 @@ jobs:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
      timeout-minutes: 2

# cSpell: ignore submark softprops npmjs deployctl nwtgck
+5 −13
Original line number Diff line number Diff line
@@ -182,9 +182,7 @@ the repository in Visual Studio Code and get ready to hack on Fedify by running
the following commands at the *root* of the repository:

~~~~ bash
pushd src
deno task codegen
popd
code .
~~~~

@@ -212,14 +210,12 @@ Please click the *Install* button to install the Deno extension.

### Running the Fedify CLI

If you want to test your changes in the Fedify CLI, you can run `deno task run`
command at the *cli/* directory.  For example, if you want to test
If you want to test your changes in the Fedify CLI, you can run
`deno task -f @fedify/cli run` command.  For example, if you want to test
the `fedify lookup` subcommand, you can run the following command:

~~~~ bash
pushd cli/
deno task run lookup @fedify@hollo.social
popd
deno task -f @fedify/cli run lookup @fedify@hollo.social
~~~~

> [!TIP]
@@ -230,21 +226,17 @@ popd
#### Running the tests

If you want to test your changes in the Fedify library, you can run
`deno task test` command at the *src/* directory:
the following command:

~~~~ bash
pushd src/
deno task test
popd
deno task -f @fedify/fedify test
~~~~

If the tests pass, you should run `deno task test-all` command to test
the library with Deno, Node.js, and [Bun]:

~~~~ bash
pushd src/
deno task test-all
popd
~~~~

Of course, Node.js and Bun should be installed on your system to run the tests
+58 −16
Original line number Diff line number Diff line
@@ -3,7 +3,27 @@
  "version": "1.5.0",
  "license": "MIT",
  "exports": "./mod.ts",
  "importMap": "import_map.g.json",
  "imports": {
    "@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.4",
    "@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.4",
    "@cliffy/prompt": "jsr:@cliffy/prompt@1.0.0-rc.4",
    "@cliffy/table": "jsr:@cliffy/table@1.0.0-rc.4",
    "@cross/dir": "jsr:@cross/dir@^1.1.0",
    "@david/dax": "jsr:@david/dax@^0.41.0",
    "@hongminhee/localtunnel": "jsr:@hongminhee/localtunnel@^0.2.0",
    "@jimp/core": "npm:@jimp/core@^1.6.0",
    "@jimp/wasm-webp": "npm:@jimp/wasm-webp@^1.6.0",
    "@poppanator/http-constants": "npm:@poppanator/http-constants@^1.1.1",
    "@std/dotenv": "jsr:@std/dotenv@^0.225.2",
    "cli-highlight": "npm:cli-highlight@^2.1.11",
    "hono": "jsr:@hono/hono@^4.5.9",
    "hono/": "jsr:/@hono/hono@^4.5.9/",
    "icojs": "npm:icojs@^0.19.4",
    "jimp": "npm:jimp@^1.6.0",
    "json-preserve-indent": "npm:json-preserve-indent@^1.1.3",
    "ora": "npm:ora@^8.0.1",
    "shiki": "npm:shiki@^1.6.4"
  },
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "hono/jsx"
@@ -15,22 +35,44 @@
    "fedify-cli-*.zip",
    "npm"
  ],
  "unstable": [
    "fs",
    "kv",
    "process",
    "temporal"
  ],
  "tasks": {
    "fedify-codegen": "cat ../src/vocab/vocab.ts > /dev/null || (deno run --allow-read --allow-write --check ../src/codegen/main.ts ../src/vocab/ ../runtime/ > ../src/vocab/vocab.ts && deno fmt ../src/vocab/vocab.ts && deno cache ../src/vocab/vocab.ts && deno check ../src/vocab/vocab.ts)",
    "generate-import-map": "deno run --allow-read --allow-write scripts/generate_import_map.ts",
    "sync-version": "deno run --allow-read=deno.json --allow-write=deno.json scripts/sync_version.ts",
    "codegen": "deno task fedify-codegen && deno task generate-import-map && deno task sync-version",
    "check": "deno task codegen && deno fmt --check && deno lint && deno check **/*.ts",
    "run": "deno task codegen && deno run --allow-all mod.ts",
    "publish": "deno task codegen && deno task generate-import-map --release && deno publish",
    "publish-dry-run": "deno task codegen && deno publish --dry-run --allow-dirty",
    "pack": "deno task codegen && deno run -A scripts/pack.ts",
    "npm": "deno run --allow-read --allow-write --allow-run --allow-env npm/pack.ts"
    "codegen": {
      "command": "deno task -f @fedify/fedify codegen",
      "dependencies": [
        "sync-version"
      ]
    },
    "check": {
      "command": "deno task codegen && deno fmt --check && deno lint && deno check **/*.ts",
      "dependencies": [
        "codegen"
      ]
    },
    "run": {
      "command": "deno run --allow-all mod.ts",
      "dependencies": [
        "codegen"
      ]
    },
    "publish": {
      "command": "deno publish",
      "dependencies": [
        "codegen"
      ]
    },
    "publish-dry-run": "deno task publish --dry-run --allow-dirty",
    "pack": {
      "command": "deno run -A scripts/pack.ts",
      "dependencies": [
        "codegen"
      ]
    },
    "npm": {
      "command": "deno run --allow-read --allow-write --allow-run --allow-env npm/pack.ts",
      "dependencies": [
        "sync-version"
      ]
    }
  }
}
+0 −4
Original line number Diff line number Diff line
@@ -9,12 +9,8 @@
    "@hongminhee/localtunnel": "jsr:@hongminhee/localtunnel@^0.2.0",
    "@jimp/core": "npm:@jimp/core@^1.6.0",
    "@jimp/wasm-webp": "npm:@jimp/wasm-webp@^1.6.0",
    "@logtape/logtape": "jsr:@logtape/logtape@^0.8.1",
    "@poppanator/http-constants": "npm:@poppanator/http-constants@^1.1.1",
    "@std/dotenv": "jsr:@std/dotenv@^0.225.2",
    "@std/fs": "jsr:@std/fs@^0.229.3",
    "@std/path": "jsr:@std/path@^0.225.1",
    "@std/semver": "jsr:@std/semver@^0.224.3",
    "cli-highlight": "npm:cli-highlight@^2.1.11",
    "hono": "jsr:@hono/hono@^4.5.9",
    "hono/": "jsr:/@hono/hono@^4.5.9/",
+0 −25
Original line number Diff line number Diff line
import fedifyMetadata from "../../src/deno.json" with { type: "json" };
import cliImportMap from "../import_map.json" with { type: "json" };

const release = Deno.args[0] == "--release";

const fedifyImports = Object.fromEntries(
  Object.entries(fedifyMetadata.exports)
    .map(([k, v]) => [
      k.replace(/^\./, "@fedify/fedify"),
      release
        ? `jsr:${k.replace(/^\./, `@fedify/fedify@^${fedifyMetadata.version}`)}`
        : "../src/" + v,
    ]),
);

const importMap = {
  ...fedifyMetadata.imports,
  ...fedifyImports,
  ...cliImportMap.imports,
};

await Deno.writeTextFile(
  `${import.meta.dirname}/../import_map.g.json`,
  JSON.stringify({ imports: importMap }, null, 2) + "\n",
);
Loading