From 81b85e7c2090531c54e6e07e2c115265b72a26b7 Mon Sep 17 00:00:00 2001 From: KeKs0r Date: Fri, 25 Oct 2024 16:46:12 +0800 Subject: [PATCH 1/5] Add build Script --- .github/workflows/ci.yml | 22 +++++++++++++--------- LICENSE | 21 +++++++++++++++++++++ build.ts | 26 ++++++++++++++++++++++++++ bun.lockb | Bin 9910 -> 17695 bytes package.json | 30 +++++++++++++++++++++++++----- src/index.ts | 2 +- tsconfig.json | 4 +++- 7 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 LICENSE create mode 100644 build.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e1cc1a..3915e68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,29 +8,33 @@ jobs: runs-on: blacksmith-2vcpu-ubuntu-2204 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: useblacksmith/cache@v5 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 - run: bun test + - name: 🧪 Test + run: bun run test + + - name: 📦 Build + run: bun run build diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..23c4293 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Marc Höffl + +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. diff --git a/build.ts b/build.ts new file mode 100644 index 0000000..2980545 --- /dev/null +++ b/build.ts @@ -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; + +await Promise.all([ + Bun.build({ + ...shared, + plugins: [dts()], + format: "esm", + naming: "[dir]/[name].js", + }), + Bun.build({ + ...shared, + format: "cjs", + naming: "[dir]/[name].cjs", + }), +]); diff --git a/bun.lockb b/bun.lockb index fc750a56d531895c94be598c1458bed1b880042f..85d83e2945ea6d36eb0011d9faa61750b2451a29 100755 GIT binary patch delta 6473 zcmds5d0bP+w@*SM1VnZvYyyI^B@p&S77+!JMJg6S!A6K78rc#=P#b(wwX}*lbr%u$ zA}AI`rBAVnR#a4wy5WMj6pPER+M+%b-#Is2i2m&R}Ufw2~cyOc|c8pihvFU8Ud6CR0tGj%IlMBpqz|jIxAOS ztKRU!@bvIT-#$w%q?x> zUzcUQlbwDaJ#GFB(@{mD)@|;Srd)k$SCFYMOpI|owVikVwDHVryTA|~J>TZ36;~$w zRrVLoDS=#5M0F2AOJw*T5Q@1TAnh zgG0%&R|jxCfD5aLp-D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j?1?jSvC7?i^_XGqIabQR|})UBqam-1>_8I=^Wrj$1&6#zd=ItvIX zbPe#NLLpm9sVG#irHlemCuz)Uj z{%9|qYf2hl2K9hW{QzoMr+U^2kfLStF=Q|FQ-pC?1#H`{64laVI6;K|Y}Eq3biW~7Cl@n$K}YNv0(*{IW( zrC-2J`7+W@OW?|Fc8d8k(m_Z3S-F8O<8)GFQ&w)IS8+DePdHnsKaiEJRKnRtS8=w} z&d%Wz?p7Le-(DTryj9XW2GxEr|I}CxuN6cMTWIIzGj#NpJE{+Mom8z8cxhhK9VfH_ zkGT0yZLtV#Ar|V_E;o&8@lj3}x=J)-w_vwoqiMKNbahTMr;pQuDif$G?mF&B?ryzI z(A9dG4020i&9mv?Bzt2uzUI%lY7nkoEnHb_j;oAKvI|D8Ha5?0xzacc4u`|y@Hk8k zm&0cFKh|9qFfn*p2Of&XA0AJn0#QnbkI-`1?U{lcwu*a4PQCE=W5=FQWLS$twWts! zazwT((~>T3cf}j?=ggPo=PQM;^NM^ip~bXFSTrV8Y1_Wz!H;(I<0h(`Nca`<_PV_P zRS4rR<`Q^6Qg_Zl3R2k9w zwO&{$)~D4{yt?c2i+>(iy(z2oE1WmR+h_BGX>T@BSyfn6DG+nT>jSZvzID!ASoZ(1 zs?Zpj=ikb??s}u}#p;dINQYuB>q7lm|MJmH>^4rGpi8l^`vc^PpY&)V_LZDie{+k! i_P_ohx#Qy$NP4OZag(G+(x&R3RD2!H?ii#}XZc?p9w~GH diff --git a/package.json b/package.json index 007caf3..1098edd 100644 --- a/package.json +++ b/package.json @@ -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" - } -} \ No newline at end of file + }, + "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 " +} diff --git a/src/index.ts b/src/index.ts index f67b2c6..ace0b6c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1 @@ -console.log("Hello via Bun!"); \ No newline at end of file +export * from "./create-engage"; diff --git a/tsconfig.json b/tsconfig.json index 238655f..cbc417f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,8 @@ // Some stricter flags (disabled by default) "noUnusedLocals": false, "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false + "noPropertyAccessFromIndexSignature": false, + + "declaration": true } } From 0a2c46ceb73423a7bf9f0d81d5686809c9d54597 Mon Sep 17 00:00:00 2001 From: KeKs0r Date: Fri, 25 Oct 2024 16:50:42 +0800 Subject: [PATCH 2/5] dont use blacksmith, migrate after to it --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3915e68..0690c88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: jobs: CI: - runs-on: blacksmith-2vcpu-ubuntu-2204 + runs-on: ubuntu-latest steps: - name: ⬇️ Checkout repo @@ -17,7 +17,7 @@ jobs: bun-version: latest - name: 💾 Setup bun cache - uses: useblacksmith/cache@v5 + uses: actions/cache@v3 with: path: ~/.bun/install/cache key: ${{ runner.os }}-bun-store-v1-${{ hashFiles('**/bun.lockb') }} From 26072c4a7349fbdeca5a7c0025324d94b341dd1f Mon Sep 17 00:00:00 2001 From: KeKs0r Date: Fri, 25 Oct 2024 16:51:17 +0800 Subject: [PATCH 3/5] proper test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0690c88..51be7a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: run: bun run typecheck - name: 🧪 Test - run: bun run test + run: bun test - name: 📦 Build run: bun run build From f7302b2062b14d4668cc90a3fb02497dc291cf7c Mon Sep 17 00:00:00 2001 From: KeKs0r Date: Fri, 25 Oct 2024 16:54:17 +0800 Subject: [PATCH 4/5] hardcode the agent --- src/__tests__/happydom.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/__tests__/happydom.ts b/src/__tests__/happydom.ts index f7372b3..2a4d873 100644 --- a/src/__tests__/happydom.ts +++ b/src/__tests__/happydom.ts @@ -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", + }, + }, +}); From 12e29302655b2da0aec459c0149dd73f73367baf Mon Sep 17 00:00:00 2001 From: KeKs0r Date: Fri, 25 Oct 2024 16:56:43 +0800 Subject: [PATCH 5/5] use cache v4 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51be7a5..e41bada 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: bun-version: latest - name: 💾 Setup bun cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.bun/install/cache key: ${{ runner.os }}-bun-store-v1-${{ hashFiles('**/bun.lockb') }}