Skip to content

Commit

Permalink
Swapped bun for pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwf committed Jan 10, 2025
1 parent 3a722f9 commit 53a3cfc
Show file tree
Hide file tree
Showing 10 changed files with 4,377 additions and 22 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build + test

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: ["18", "20"]

name: Node ${{ matrix.node }} build
steps:
- uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ matrix.node }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node }}-pnpm-store-
- run: pnpm i --frozen-lockfile
- run: pnpm run build
- run: pnpm run test
- run: pnpm run lint
80 changes: 79 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1 +1,79 @@
# Need to publish the NPM package when a tag changes with a matrix build of aarch64 and
name: Release NPM package

on:
push:
tags: ["v*"]

jobs:
build:
runs-on: ubuntu-latest
name: Node build
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: "18.x"

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-18-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-18-pnpm-store-
- run: pnpm i --frozen-lockfile
- run: pnpm run build
- run: pnpm run test

release:
needs: [build]
runs-on: ubuntu-latest
name: Release
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: "18.x"

- name: Set tag
id: tagName
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-18-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-18-pnpm-store-
- run: pnpm i --frozen-lockfile

- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion __tests__/util/__snapshots__/auto-slug.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`auto slug test can create a slug from multiple examples 1`] = `
{
Expand Down
2 changes: 1 addition & 1 deletion __tests__/util/all-directories.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect } from "bun:test";
import { describe, expect, test } from "vitest";
import { allDirectories } from "../../src/util/all-directories";

describe("allDirectories", () => {
Expand Down
15 changes: 5 additions & 10 deletions __tests__/util/auto-slug.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { describe, test, expect } from "bun:test";
import { compileSlugConfig } from "../../src/util/slug-engine.ts";
import { describe, expect, test } from "vitest";

describe("auto slug test", () => {
test("can create a slug from multiple examples", () => {
function createAutoSlug(
samples: string[],
{
idSeparator = "-",
slugPrefix = "manifests/",
}: { idSeparator?: string; slugPrefix?: string } = {},
{ idSeparator = "-", slugPrefix = "manifests/" }: { idSeparator?: string; slugPrefix?: string } = {}
) {
// Find a prefix common to ALL samples
const parts = samples.map((s) => s.split("/"));
Expand Down Expand Up @@ -38,11 +34,10 @@ describe("auto slug test", () => {
}

const maxSegments = Math.max(...parts.map((p) => p.length));
const variableSegments =
maxSegments - prefixParts.length - suffixParts.length;
const variableSegments = maxSegments - prefixParts.length - suffixParts.length;

const prefix = prefixParts.join("/");
const suffix = "/" + suffixParts.reverse().join("/");
const suffix = `/${suffixParts.reverse().join("/")}`;

let startLetter = "a";

Expand All @@ -59,7 +54,7 @@ describe("auto slug test", () => {

return {
prefix,
pattern: "/" + variableParts.join(idSeparator) + suffix,
pattern: `/${variableParts.join(idSeparator)}${suffix}`,
slugTemplate: slugPrefix + variableParts.join(idSeparator),
};
}
Expand Down
8 changes: 2 additions & 6 deletions __tests__/util/slug-engine.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { describe, test, expect } from "bun:test";
import {
compileReverseSlugConfig,
compileSlugConfig,
SlugConfig,
} from "../../src/util/slug-engine";
import { describe, expect, test } from "vitest";
import { SlugConfig, compileReverseSlugConfig, compileSlugConfig } from "../../src/util/slug-engine";

describe("slug-engine", () => {
// New strategy.
Expand Down
2 changes: 1 addition & 1 deletion __tests__/util/tree-from-directories.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect } from "bun:test";
import { describe, expect, test } from "vitest";
import { treeFromDirectories } from "../../src/util/tree-from-directories";

describe("treeFromDirectories", () => {
Expand Down
Binary file removed bun.lockb
Binary file not shown.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"typings": "lib/scripts.d.ts",
"scripts": {
"dev": "bun run ./src/index.ts serve",
"build": "bun run build:cli && bun run build:server && bun run build:client && bun run build:node-client",
"build": "pnpm run build:cli && pnpm run build:server && pnpm run build:client && pnpm run build:node-client",
"build:cli": "tsup-node src/index.ts --no-splitting --outDir build --format esm --env.NODE_ENV production",
"build:server": "tsup-node src/entrypoint.ts --no-splitting --outDir build/server --format esm --env.NODE_ENV production",
"build:client": "tsup src/dev/client.ts --outDir build",
"build:node-client": "tsup src/dev/node-client.ts --outDir build",
"lint": "publint",
"prepack": "bun run build"
"test": "vitest",
"prepack": "pnpm run build"
},
"exports": {
".": {
Expand Down Expand Up @@ -102,6 +103,7 @@
"typescript": "^5.2.2",
"typesense": "1.7.2",
"unionfs": "^4.5.4",
"vitest": "^2.1.8",
"yaml": "^2.6.1",
"zod": "^3.24.1"
}
Expand Down
Loading

0 comments on commit 53a3cfc

Please sign in to comment.