Skip to content

Commit

Permalink
Merge pull request #27 from jakeboone02/drop-vite
Browse files Browse the repository at this point in the history
Drop Vite and Yarn in favor of Bun
  • Loading branch information
jakeboone02 committed Jun 17, 2023
2 parents f5110a6 + ac07c1f commit 62cf0bf
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 9,362 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bun.lockb binary
15 changes: 9 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
- name: Set up Bun
uses: oven-sh/setup-bun@v1
with:
install-command: yarn --immutable
bun-version: latest

- name: Install dependencies
run: bun install

- name: Build
run: yarn build
run: bun run build

- name: Test
run: yarn test --ci --maxWorkers=2
run: bun run test --ci

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.node == '18.x'
# if: matrix.os == 'ubuntu-latest' && matrix.node == '18.x'
uses: codecov/codecov-action@v1
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,3 @@
node_modules
dist
coverage

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
541 changes: 0 additions & 541 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

550 changes: 0 additions & 550 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

This file was deleted.

874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.0.cjs

This file was deleted.

11 changes: 0 additions & 11 deletions .yarnrc.yml

This file was deleted.

Binary file added bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion ci/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "parcel build index.html"
},
"dependencies": {
"numeric-quantity": "1.0.2",
"numeric-quantity": "^2.0.0",
"parcel-bundler": "^1.12.5"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions ci/src/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
body {
font-family: 'Courier New', Courier, monospace;
}

th,
td {
border-bottom: 1px solid lightgray;
Expand Down
23 changes: 23 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,37 @@
border-bottom: 1px solid gray;
}
h1,
h2,
h3,
td {
font-family: 'Courier New', Courier, monospace;
}
#input {
display: flex;
flex-direction: row;
gap: 1rem;
}
</style>
</head>
<body>
<h1>numeric-quantity</h1>
<h3>Input</h3>
<div id="input">
<input type="text" autofocus /><span>=></span>
<div id="result"></div>
</div>
<h3>Tests</h3>
<div id="app"></div>
<script type="module" src="/src/dev.ts"></script>
<script>
const eventListener = e =>
(document.getElementById('result').innerText = numericQuantity(
e.target.value,
{ allowTrailingInvalid: true, romanNumerals: true }
));
for (const event of ['keyup', 'change']) {
document.querySelector('input').addEventListener(event, eventListener);
}
</script>
</body>
</html>
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"numerals"
],
"scripts": {
"start": "vite",
"start": "bun ./server.ts",
"build": "tsup",
"test": "jest",
"watch": "jest --watch",
Expand All @@ -46,19 +46,19 @@
},
"devDependencies": {
"@types/jest": "^29.5.2",
"@types/node": "^20.3.0",
"@types/node": "^20.3.1",
"bun-types": "^0.6.9",
"gh-pages": "^5.0.0",
"jest": "^29.5.0",
"np": "^8.0.3",
"np": "^8.0.4",
"open": "^9.1.0",
"prettier": "^2.8.8",
"prettier-plugin-organize-imports": "^3.2.2",
"ts-jest": "^29.1.0",
"tsup": "^6.7.0",
"typescript": "^5.1.3",
"vite": "^4.3.9"
"tsup": "^7.0.0",
"typescript": "^5.1.3"
},
"engines": {
"node": ">=16"
},
"packageManager": "yarn@3.6.0"
}
}
16 changes: 16 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Serve } from 'bun';
import open from 'open';

const dev = (await Bun.build({ entrypoints: ['./src/dev.ts'] })).outputs[0];

setTimeout(() => open('http://localhost:3000'), 500);

export default {
fetch(req: Request) {
const reqAsURL = new URL(req.url);
if (reqAsURL.pathname.endsWith('dev.ts')) {
return new Response(dev);
}
return new Response(Bun.file('./main.html'));
},
} satisfies Serve;
20 changes: 12 additions & 8 deletions src/dev.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { numericQuantity } from './numericQuantity';
import { numericQuantity } from './index';
import { numericQuantityTests } from './numericQuantityTests';

const app = document.querySelector<HTMLDivElement>('#app')!;

(globalThis as any).numericQuantity = numericQuantity;

const table = document.createElement('table');
table.setAttribute('cellpadding', '10');
table.setAttribute('cellpadding', '7');
table.setAttribute('cellspacing', '0');
const trCaptions = document.createElement('tr');
trCaptions.innerHTML = '<td>Call</td><td>Expected</td><td>Pass</td>';
Expand All @@ -18,15 +20,17 @@ for (const [title, tests] of Object.entries(numericQuantityTests)) {
tr.append(th);
table.appendChild(tr);

for (const test of tests) {
const result = numericQuantity(test[0]);
const pass = isNaN(test[1]) ? isNaN(result) : test[1] === result;
for (const [test, expect, opts] of tests) {
const result = numericQuantity(test, opts);
const pass = isNaN(expect) ? isNaN(result) : expect === result;
const testTR = document.createElement('tr');
const tdCall = document.createElement('td');
const tdResult = document.createElement('td');
const tdPassFail = document.createElement('td');
tdCall.innerText = `numericQuantity(${JSON.stringify(test[0])})`;
tdResult.innerText = `${numericQuantity(test[0])}`;
tdCall.innerText = `numericQuantity(${JSON.stringify(test)}${
opts ? `, ${JSON.stringify(opts)}` : ''
})`;
tdResult.innerText = `${result}`;
tdPassFail.innerText = pass ? '✅' : '❌';
testTR.appendChild(tdCall);
testTR.appendChild(tdResult);
Expand All @@ -35,4 +39,4 @@ for (const [title, tests] of Object.entries(numericQuantityTests)) {
}
}

document.body.appendChild(table);
app.appendChild(table);
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"compilerOptions": {
"types": ["bun-types", "jest"],
"isolatedModules": true,
"declaration": true,
"sourceMap": true,
"strict": true,
"module": "es6",
"module": "esnext",
"moduleResolution": "node",
"target": "ES2015",
"target": "es2017",
"esModuleInterop": true,
"baseUrl": ".",
"outDir": "dist",
"noEmit": true,
"lib": ["ES2015", "DOM"]
},
"include": ["./src"]
"include": [".", "./src"]
}
7 changes: 0 additions & 7 deletions vite.config.ts

This file was deleted.

Loading

0 comments on commit 62cf0bf

Please sign in to comment.