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

Use tsdown instead of dnt

parent 69ef7dbc
Loading
Loading
Loading
Loading
+26 −11
Original line number Diff line number Diff line
@@ -28,9 +28,13 @@ jobs:
    - uses: denoland/setup-deno@v1
      with:
        deno-version: v2.x
    - uses: pnpm/action-setup@v4
      with:
        version: 10
    - uses: actions/setup-node@v4
      with:
        node-version: lts/*
        cache: pnpm
    - uses: oven-sh/setup-bun@v1
      with:
        bun-version: latest
@@ -40,9 +44,9 @@ jobs:
      with:
        files: .test-report.xml
    - run: deno task check
    - run: deno task dnt
    - run: bun run ./test_runner.js
      working-directory: ${{ github.workspace }}/npm/
    - run: pnpm install
    - run: pnpm test
    - run: pnpm test:bun

  publish:
    if: github.event_name == 'push'
@@ -56,31 +60,42 @@ jobs:
    - uses: denoland/setup-deno@v1
      with:
        deno-version: v2.x
    - uses: pnpm/action-setup@v4
      with:
        version: 10
    - uses: actions/setup-node@v4
      with:
        node-version: lts/*
        cache: pnpm
    - if: github.ref_type == 'branch'
      run: |
        set -ex
        jq \
          --arg build "$GITHUB_RUN_NUMBER" \
          --arg commit "${GITHUB_SHA::8}" \
          '.version = .version + "-dev." + $build + "+" + $commit' \
          deno.json > deno.json.tmp
        mv deno.json.tmp deno.json
        jq \
          --arg build "$GITHUB_RUN_NUMBER" \
          '.version = .version + "-dev." + $build' \
          package.json > package.json.tmp
        mv package.json.tmp package.json
    - if: github.ref_type == 'tag'
      run: '[[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]'
    - run: 'deno task dnt "$(jq -r .version deno.json)"'
      env:
        DNT_TEST: false
      run: |
        set -ex
        [[ "$(jq -r .version deno.json)" = "$GITHUB_REF_NAME" ]]
        [[ "$(jq -r .version package.json)" = "$GITHUB_REF_NAME" ]]
    - run: |
        set -ex
        npm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
        pnpm install
        pnpm config set //registry.npmjs.org/:_authToken "$NPM_AUTH_TOKEN"
        if [[ "$GITHUB_REF_TYPE" = "tag" ]]; then
          npm publish --provenance --access public
          pnpm publish --provenance --access public --no-git-checks
        else
          npm publish --provenance --access public --tag dev
          pnpm publish --provenance --access public --no-git-checks --tag dev
        fi
      env:
        NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
      working-directory: ${{ github.workspace }}/npm/
        NPM_CONFIG_PROVENANCE: "true"
    - run: deno publish --allow-dirty
+2 −0
Original line number Diff line number Diff line
.dnt-import-map.json
dist/
node_modules/
npm/
+9 −5
Original line number Diff line number Diff line
@@ -9,18 +9,22 @@
  },
  "imports": {
    "@deno/dnt": "jsr:@deno/dnt@^0.41.3",
    "@fedify/fedify": "jsr:@fedify/fedify@1.5.0",
    "@logtape/logtape": "jsr:@logtape/logtape@^0.9.0",
    "@std/assert": "jsr:@std/assert@^0.226.0",
    "@fedify/fedify": "jsr:@fedify/fedify@1.7.2",
    "@logtape/logtape": "jsr:@logtape/logtape@^1.0.0",
    "@std/assert": "jsr:@std/assert@^1.0.4",
    "@std/async": "jsr:@std/async@^1.0.5",
    "postgres": "npm:postgres@^3.4.5"
    "postgres": "npm:postgres@^3.4.7",
    "tsdown": "npm:tsdown@^0.12.9"
  },
  "nodeModulesDir": "none",
  "unstable": [
    "temporal"
  ],
  "exclude": [
    ".github",
    "npm"
    ".test-report.xml",
    "npm",
    "pnpm-lock.yaml"
  ],
  "tasks": {
    "check": "deno fmt --check && deno lint && deno check */*.ts",
+423 −64

File changed.

Preview size limit exceeded, changes collapsed.

dnt.ts

deleted100644 → 0
+0 −86
Original line number Diff line number Diff line
import { build, emptyDir } from "@deno/dnt";
import metadata from "./deno.json" with { type: "json" };

await emptyDir("./npm");

const importMap = ".dnt-import-map.json";
await Deno.writeTextFile(
  importMap,
  JSON.stringify({
    imports: {
      ...metadata.imports,
      "@fedify/fedify": metadata.imports["@fedify/fedify"].replace(
        /^jsr:/,
        "npm:",
      ),
      "@logtape/logtape": metadata.imports["@logtape/logtape"].replace(
        /^jsr:/,
        "npm:",
      ),
    },
  }),
);

await build({
  package: {
    // package.json properties
    name: metadata.name,
    version: Deno.args[0] ?? metadata.version,
    description: "PostgreSQL drivers for Fedify",
    keywords: ["fedify", "postgresql", "postgres"],
    license: "MIT",
    author: {
      name: "Hong Minhee",
      email: "hong@minhee.org",
      url: "https://hongminhee.org/",
    },
    homepage: "https://github.com/fedify-dev/postgres",
    repository: {
      type: "git",
      url: "git+https://github.com/fedify-dev/postgres.git",
    },
    bugs: {
      url: "https://github.com/fedify-dev/postgres/issues",
    },
    funding: [
      "https://opencollective.com/fedify",
      "https://github.com/sponsors/dahlia",
    ],
  },
  outDir: "./npm",
  entryPoints: [
    "./mod.ts",
    { name: "./kv", path: "./src/kv.ts" },
    { name: "./mq", path: "./src/mq.ts" },
  ],
  importMap,
  shims: {
    deno: true,
    custom: [
      {
        package: {
          name: "@js-temporal/polyfill",
          version: "^0.5.0",
        },
        globalNames: [
          {
            name: "Temporal",
            exportName: "Temporal",
          },
        ],
      },
    ],
  },
  typeCheck: "both",
  declaration: "separate",
  declarationMap: true,
  test: Deno.env.get("DNT_TEST") !== "false",
  async postBuild() {
    await Deno.copyFile("LICENSE", "npm/LICENSE");
    await Deno.copyFile("README.md", "npm/README.md");
  },
});

await Deno.remove(importMap);

// cSpell: ignore Minhee
Loading