Skip to content

Commit 6c4b30f

Browse files
committed
Initial thumbdrive commit
0 parents  commit 6c4b30f

37 files changed

Lines changed: 5019 additions & 0 deletions

.cursor/rules/tests.mdc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
description: "how to run tests"
3+
alwaysApply: true
4+
---
5+
6+
Tests are written using vitest and live in the `spec` dir. Run all the tests with `pnpm test`. Run one test with `pnpm test -- -t "some test name"`
7+
8+
Don't just skip tests if you can't get them to work, that's unhelpful. Keep working to get them passing, or if stuck, ask for guidance from the user.

.envrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.5; then
2+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.5/direnvrc" "sha256-RuwIS+QKFj/T9M2TFXScjBsLR6V3A17YVoEW/Q6AZ1w="
3+
fi
4+
5+
use flake
6+
7+
source_env_if_exists .envrc.local

.eslintrc.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
module.exports = {
2+
extends: "@gadgetinc/eslint-config",
3+
parserOptions: {
4+
tsconfigRootDir: __dirname,
5+
project: ["tsconfig.json"],
6+
},
7+
rules: {
8+
"lodash/import-scope": "off",
9+
"lodash/callback-binding": "off",
10+
"lodash/chain-style": "off",
11+
"lodash/collection-method-value": "off",
12+
"lodash/collection-ordering": "off",
13+
"lodash/collection-return": "off",
14+
"lodash/consistent-compose": "off",
15+
"lodash/identity-shorthand": "off",
16+
"lodash/matches-prop-shorthand": "off",
17+
"lodash/matches-shorthand": "off",
18+
"lodash/no-commit": "off",
19+
"lodash/no-double-unwrap": "off",
20+
"lodash/no-extra-args": "off",
21+
"lodash/no-unbound-this": "off",
22+
"lodash/path-style": "off",
23+
"lodash/prefer-compact": "off",
24+
"lodash/prefer-constant": "off",
25+
"lodash/prefer-filter": "off",
26+
"lodash/prefer-find": "off",
27+
"lodash/prefer-flat-map": "off",
28+
"lodash/prefer-get": "off",
29+
"lodash/prefer-includes": "off",
30+
"lodash/prefer-is-nil": "off",
31+
"lodash/prefer-lodash-chain": "off",
32+
"lodash/prefer-lodash-method": "off",
33+
"lodash/prefer-lodash-typecheck": "off",
34+
"lodash/prefer-map": "off",
35+
"lodash/prefer-matches": "off",
36+
"lodash/prefer-noop": "off",
37+
"lodash/prefer-over-quantifier": "off",
38+
"lodash/prefer-reject": "off",
39+
"lodash/prefer-startswith": "off",
40+
"lodash/prefer-thru": "off",
41+
"lodash/prefer-times": "off",
42+
"lodash/prefer-wrapper-method": "off",
43+
"lodash/prop-shorthand": "off",
44+
"lodash/unwrap": "off",
45+
"@typescript-eslint/no-unsafe-argument": "off",
46+
"@typescript-eslint/no-non-null-assertion": "off",
47+
"@typescript-eslint/ban-types": [
48+
"error",
49+
{
50+
extendDefaults: true,
51+
types: {
52+
Function: false,
53+
"{}": false,
54+
},
55+
},
56+
],
57+
"jest/no-disabled-tests": "off",
58+
"jest/no-focused-tests": "off",
59+
"jest/no-identical-title": "off",
60+
"jest/prefer-to-have-length": "off",
61+
"jest/valid-expect": "off",
62+
"jest/expect-expect": "off",
63+
"jest/no-alias-methods": "off",
64+
"jest/no-commented-out-tests": "off",
65+
"jest/no-conditional-expect": "off",
66+
"jest/no-deprecated-functions": "off",
67+
"jest/no-done-callback": "off",
68+
"jest/no-duplicate-hooks": "off",
69+
"jest/no-export": "off",
70+
"jest/no-hooks": "off",
71+
"jest/no-if": "off",
72+
"jest/no-interpolation-in-snapshots": "off",
73+
"jest/no-jasmine-globals": "off",
74+
"jest/no-jest-import": "off",
75+
"jest/no-large-snapshots": "off",
76+
"jest/no-mocks-import": "off",
77+
"jest/no-restricted-matchers": "off",
78+
"jest/no-standalone-expect": "off",
79+
"jest/no-test-prefixes": "off",
80+
"jest/no-test-return-statement": "off",
81+
"jest/prefer-called-with": "off",
82+
"jest/prefer-expect-assertions": "off",
83+
"jest/prefer-hooks-on-top": "off",
84+
"jest/prefer-spy-on": "off",
85+
"jest/prefer-strict-equal": "off",
86+
"jest/prefer-to-be": "off",
87+
"jest/prefer-to-contain": "off",
88+
"jest/prefer-todo": "off",
89+
"jest/require-hook": "off",
90+
"jest/require-to-throw-message": "off",
91+
"jest/require-top-level-describe": "off",
92+
"jest/valid-describe-callback": "off",
93+
"jest/valid-title": "off",
94+
},
95+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Setup test environment"
2+
description: ""
3+
inputs: {}
4+
outputs: {}
5+
runs:
6+
using: "composite"
7+
steps:
8+
- uses: cachix/install-nix-action@v18
9+
with:
10+
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
11+
- run: |
12+
source <(nix print-dev-env --show-trace)
13+
output_file="nix-env.txt"
14+
15+
# Clear the output file
16+
> $output_file
17+
18+
# Loop over each variable in the environment
19+
while IFS='=' read -r -d '' name value; do
20+
# Skip if the variable is a function or read-only or non-alphanumeric
21+
[[ "$(declare -p $name)" =~ "declare -[a-z]*r[a-z]* " ]] && continue
22+
[[ ! $name =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]] && continue
23+
24+
# Check if the variable value contains a newline
25+
if [[ "$value" != *$'\n'* ]]; then
26+
# It doesn't, so write the variable and its value (stripping quotes) to the file
27+
echo "${name}=${value//\"/}" >> $output_file
28+
fi
29+
done < <(env -0)
30+
31+
# useful for debugging what env is exported
32+
# cat nix-env.txt
33+
shell: bash
34+
- run: cat nix-env.txt >> "$GITHUB_ENV"
35+
shell: bash
36+
37+
- name: Get pnpm store directory
38+
id: pnpm-cache
39+
shell: bash
40+
run: |
41+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
42+
43+
- uses: actions/cache@v3
44+
name: Setup pnpm cache
45+
with:
46+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
47+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
48+
restore-keys: |
49+
${{ runner.os }}-pnpm-store-
50+
51+
- name: Install dependencies
52+
shell: bash
53+
run: pnpm install

.github/workflows/benchmark.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Benchmark"
2+
on:
3+
push:
4+
workflow_call:
5+
workflow_dispatch:
6+
jobs:
7+
bench:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2.3.4
11+
- uses: ./.github/actions/setup-test-env
12+
- name: Run benchmarks
13+
shell: bash
14+
run: pnpm x spec/bench/thumbdrive.bench.ts

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "package.json"
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
uses: ./.github/workflows/test.yml
13+
release:
14+
needs: test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: ./.github/actions/setup-test-env
19+
- id: npm-publish
20+
name: Publish to npm
21+
uses: JS-DevTools/npm-publish@v1
22+
with:
23+
token: ${{ secrets.NPM_TOKEN }}
24+
access: public
25+
- name: Publish release to github
26+
uses: softprops/action-gh-release@v1
27+
if: ${{ steps.npm-publish.outputs.type != 'none' }}
28+
with:
29+
tag_name: ${{ steps.npm-publish.outputs.version }}
30+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: "Test"
2+
on:
3+
push:
4+
workflow_call:
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2.3.4
10+
- uses: ./.github/actions/setup-test-env
11+
- name: Build
12+
shell: bash
13+
run: pnpm build
14+
- name: Test
15+
shell: bash
16+
run: pnpm test
17+
18+
test-e2e:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2.3.4
22+
- uses: ./.github/actions/setup-test-env
23+
- name: Build
24+
shell: bash
25+
run: pnpm build
26+
- name: Test E2E
27+
shell: bash
28+
run: pnpm e2e
29+
30+
lint:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v2.3.4
34+
- uses: ./.github/actions/setup-test-env
35+
- name: Lint
36+
shell: bash
37+
run: pnpm lint

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_STORE
2+
dist
3+
node_modules
4+
*~
5+
*.pyc
6+
.module-cache
7+
*.gem
8+
*.log*
9+
*.sublime-project
10+
*.sublime-workspace
11+
.idea
12+
*.iml
13+
.direnv
14+
*.cpuprofile
15+
*.heapprofile
16+
test-results

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test
2+
.editorconfig
3+
.eslintrc
4+
.npmignore
5+
LICENSE.txt
6+
Makefile
7+
rollup.config.js

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"@gadgetinc/prettier-config"

0 commit comments

Comments
 (0)