Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build Script #2

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,36 @@ on:

jobs:
CI:
runs-on: blacksmith-2vcpu-ubuntu-2204
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: ⬇️ Checkout repo
uses: actions/checkout@v3

- name: Setup Bun
- name: 🔥 Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- uses: useblacksmith/cache@v5
name: Setup bun cache
- name: 💾 Setup bun cache
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-store-v1-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-store-v1

- name: Install dependencies
- name: 📥 Download deps
run: bun install --frozen-lockfile

- name: Run linter (Biome)
- name: 🔍 Lint
run: bun run lint

- name: Run type check
- name: 🧐 Type check
run: bun run typecheck

- name: Run tests
- name: 🧪 Test
run: bun test

- name: 📦 Build
run: bun run build
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Marc Höffl <https://github.com/keks0r>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { $, type BuildConfig } from "bun";
import dts from "bun-plugin-dts";

await $`rm -rf dist`;

const shared = {
entrypoints: ["./src/index.ts"],
target: "browser",
sourcemap: "external",
minify: true,
outdir: "./dist",
} satisfies Partial<BuildConfig>;

await Promise.all([
Bun.build({
...shared,
plugins: [dts()],
format: "esm",
naming: "[dir]/[name].js",
}),
Bun.build({
...shared,
format: "cjs",
naming: "[dir]/[name].cjs",
}),
]);
Binary file modified bun.lockb
Binary file not shown.
30 changes: 25 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
{
"name": "numia-engage-sdk",
"module": "src/index.ts",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"scripts": {
"lint": "biome lint .",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"build": "bun build.ts"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@happy-dom/global-registrator": "^15.7.4",
"@types/bun": "latest"
"@types/bun": "latest",
"bun-plugin-dts": "^0.3.0"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"p-retry": "^6.2.0"
}
}
},
"files": [
"dist"
],
"license": "MIT",
"homepage": "https://github.com/numiadata/numia-engage-sdk",
"repository": {
"type": "git",
"url": "git+https://github.com/numiadata/numia-engage-sdk.git"
},
"bugs": "https://github.com/numiadata/numia-engage-sdk/issues",
"author": "Marc Höffl <marc@numia.xyz>"
}
11 changes: 10 additions & 1 deletion src/__tests__/happydom.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import { GlobalRegistrator } from "@happy-dom/global-registrator";

GlobalRegistrator.register({ url: "http://numia.xyz" });
GlobalRegistrator.register({
url: "http://numia.xyz",
settings: {
navigator: {
// Need to hardcode, due to difference local and in CI
userAgent:
"Mozilla/5.0 (X11; Darwin arm64) AppleWebKit/537.36 (KHTML, like Gecko) HappyDOM/0.0.0",
},
},
});
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log("Hello via Bun!");
export * from "./create-engage";
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
"noPropertyAccessFromIndexSignature": false,

"declaration": true
}
}
Loading