Skip to content

Commit e31c869

Browse files
committed
Add initial project setup with package configuration, workflows, and source files
- Updated package.json with version, scripts, and repository information - Added Dependabot configuration for npm package updates - Created GitHub Actions workflows for publishing and testing - Added .gitignore and .npmignore files for build artifacts and dependencies - Configured Prettier with .prettierrc and .prettierignore - Implemented initial TypeScript setup with tsconfig.json - Developed SqliteMap class in src/index.ts for SQLite database interaction - Included MIT license file
1 parent 6e1cf3c commit e31c869

File tree

11 files changed

+474
-7
lines changed

11 files changed

+474
-7
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
timezone: "Etc/GMT-6"
13+
day: "friday"
14+
time: "06:00"

.github/workflows/publish.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Publish package
2+
3+
on:
4+
release:
5+
types: created
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
Publish:
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: write
16+
id-token: write
17+
18+
steps:
19+
- name: Setup Action
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: "latest"
28+
registry-url: https://registry.npmjs.org/
29+
30+
- name: Setup PNPM
31+
uses: pnpm/action-setup@v4
32+
33+
- name: Check for changes
34+
id: changes
35+
run: |
36+
if git rev-parse --verify ${{ github.event.before }} > /dev/null 2>&1; then
37+
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '^src/' && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT
38+
else
39+
echo "changed=true" >> $GITHUB_OUTPUT
40+
fi
41+
42+
- name: Install dependencies
43+
if: github.event_name == 'release' || (github.event_name == 'push' && steps.changes.outputs.changed == 'true')
44+
run: pnpm install --no-frozen-lockfile
45+
46+
- name: Build
47+
if: github.event_name == 'release' || (github.event_name == 'push' && steps.changes.outputs.changed == 'true')
48+
run: node --run build
49+
50+
- name: Generate dev version
51+
if: github.event_name == 'push' && steps.changes.outputs.changed == 'true'
52+
run: |
53+
CURRENT_VERSION=$(node -p "require('./package.json').version")
54+
DEV_VERSION="${CURRENT_VERSION}-dev.$(date +'%Y%m%d%H%M%S')"
55+
npm version "$DEV_VERSION" --no-git-tag-version
56+
57+
- name: Deprecate old dev versions
58+
if: github.event_name == 'push' && steps.changes.outputs.changed == 'true'
59+
run: |
60+
PACKAGE_NAME=$(node -p "require('./package.json').name")
61+
npm view "$PACKAGE_NAME" versions --json | jq -r '.[]' | grep -E 'dev\.[0-9]+' | while read -r old_version; do
62+
echo "Deprecating $PACKAGE_NAME@$old_version"
63+
npm deprecate "$PACKAGE_NAME@$old_version" "Deprecated - use latest dev version" || true
64+
done
65+
env:
66+
NODE_AUTH_TOKEN: ${{secrets.NODETOKEN}}
67+
68+
- name: Deprecate dev versions on release
69+
if: github.event_name == 'release'
70+
run: |
71+
PACKAGE_NAME=$(node -p "require('./package.json').name")
72+
npm view "$PACKAGE_NAME" versions --json | jq -r '.[]' | grep -E 'dev\.[0-9]+' | while read -r old_version; do
73+
echo "Deprecating $PACKAGE_NAME@$old_version"
74+
npm deprecate "$PACKAGE_NAME@$old_version" "Deprecated - superseded by stable release" || true
75+
done
76+
env:
77+
NODE_AUTH_TOKEN: ${{secrets.NODETOKEN}}
78+
79+
- name: Publish release
80+
if: github.event_name == 'release'
81+
run: pnpm publish --provenance --access public --no-git-checks
82+
env:
83+
NODE_AUTH_TOKEN: ${{secrets.NODETOKEN}}
84+
85+
- name: Publish dev
86+
if: github.event_name == 'push' && steps.changes.outputs.changed == 'true'
87+
run: pnpm publish --provenance --access public --no-git-checks --tag dev
88+
env:
89+
NODE_AUTH_TOKEN: ${{secrets.NODETOKEN}}

.github/workflows/test.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Code Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
# Setup Action
16+
- name: Setup Action
17+
uses: actions/checkout@v4
18+
19+
# Setup Node.js
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "latest"
24+
25+
# Setup PNPM
26+
- name: Setup PNPM
27+
uses: pnpm/action-setup@v4
28+
29+
# Install dependencies
30+
- name: Install dependencies
31+
run: pnpm install --no-frozen-lockfile
32+
33+
# Run test
34+
- name: Run test
35+
run: node --run test

.gitignore

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
*.zip
10+
11+
# Diagnostic reports (https://nodejs.org/api/report.html)
12+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13+
14+
# Runtime data
15+
pids
16+
*.pid
17+
*.seed
18+
*.pid.lock
19+
20+
# Directory for instrumented libs generated by jscoverage/JSCover
21+
lib-cov
22+
23+
# Coverage directory used by tools like istanbul
24+
coverage
25+
*.lcov
26+
27+
# nyc test coverage
28+
.nyc_output
29+
30+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
31+
.grunt
32+
33+
# Bower dependency directory (https://bower.io/)
34+
bower_components
35+
36+
# node-waf configuration
37+
.lock-wscript
38+
39+
# Compiled binary addons (https://nodejs.org/api/addons.html)
40+
build/Release
41+
42+
# Dependency directories
43+
node_modules/
44+
jspm_packages/
45+
46+
# Snowpack dependency directory (https://snowpack.dev/)
47+
web_modules/
48+
49+
# TypeScript cache
50+
*.tsbuildinfo
51+
52+
# Optional npm cache directory
53+
.npm
54+
55+
# Optional eslint cache
56+
.eslintcache
57+
58+
# Optional stylelint cache
59+
.stylelintcache
60+
61+
# Microbundle cache
62+
.rpt2_cache/
63+
.rts2_cache_cjs/
64+
.rts2_cache_es/
65+
.rts2_cache_umd/
66+
67+
# Optional REPL history
68+
.node_repl_history
69+
70+
# Output of 'npm pack'
71+
*.tgz
72+
73+
# Yarn Integrity file
74+
.yarn-integrity
75+
76+
# dotenv environment variable files
77+
.env
78+
.env.development.local
79+
.env.test.local
80+
.env.production.local
81+
.env.local
82+
pnpm-lock.yaml
83+
package-lock.json
84+
config.json
85+
*.csv
86+
*.js
87+
88+
# parcel-bundler cache (https://parceljs.org/)
89+
.cache
90+
.parcel-cache
91+
92+
# Next.js build output
93+
.next
94+
out
95+
96+
# Nuxt.js build / generate output
97+
.nuxt
98+
dist
99+
100+
# Gatsby files
101+
.cache/
102+
# Comment in the public line in if your project uses Gatsby and not Next.js
103+
# https://nextjs.org/blog/next-9-1#public-directory-support
104+
# public
105+
106+
# vuepress build output
107+
.vuepress/dist
108+
109+
# vuepress v2.x temp and cache directory
110+
.temp
111+
.cache
112+
113+
# Docusaurus cache and generated files
114+
.docusaurus
115+
116+
# Serverless directories
117+
.serverless/
118+
119+
# FuseBox cache
120+
.fusebox/
121+
122+
# DynamoDB Local files
123+
.dynamodb/
124+
125+
# TernJS port file
126+
.tern-port
127+
128+
# Stores VSCode versions used for testing VSCode extensions
129+
.vscode-test
130+
131+
# yarn v2
132+
.yarn/cache
133+
.yarn/unplugged
134+
.yarn/build-state.yml
135+
.yarn/install-state.gz
136+
.pnp.*

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.test.ts
2+
*.test.js
3+
.github/
4+
src/
5+
.gitignore
6+
.prettierignore
7+
.prettierrc
8+
tsconfig.json

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tsconfig.json
2+
index.js

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"endOfLine": "crlf",
3+
"arrowParens": "always",
4+
"trailingComma": "none",
5+
"semi": false,
6+
"useTabs": false,
7+
"singleQuote": false,
8+
"bracketSpacing": true,
9+
"tabWidth": 4,
10+
"printWidth": 120
11+
}

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2026 xcfio
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

package.json

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
{
22
"name": "node-sqlite-map",
3-
"version": "0.0.0",
3+
"version": "0.0.1",
44
"description": "",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
9-
"keywords": [],
105
"author": "xcfio",
6+
"homepage": "https://github.com/xcfio/node-sqlite-map#readme",
7+
"type": "commonjs",
118
"license": "MIT",
12-
"packageManager": "pnpm@10.25.0"
9+
"main": "./out/index.js",
10+
"scripts": {
11+
"lint": "prettier --config=.prettierrc --check src",
12+
"fmt": "prettier --config=.prettierrc --write src",
13+
"test": "tsc --noEmit",
14+
"dev": "tsc --watch",
15+
"build": "tsc"
16+
},
17+
"keywords": [
18+
"sqlite",
19+
"node-sqlite",
20+
"map"
21+
],
22+
"repository": {
23+
"type": "git",
24+
"url": "https://github.com/xcfio/node-sqlite-map"
25+
},
26+
"bugs": {
27+
"url": "https://github.com/xcfio/node-sqlite-map/issues",
28+
"email": "omarfaruksxp@gmail.com"
29+
},
30+
"packageManager": "pnpm@10.33.0",
31+
"publishConfig": {
32+
"access": "public",
33+
"tag": "latest"
34+
},
35+
"engines": {
36+
"node": ">=22.5"
37+
},
38+
"devDependencies": {
39+
"@types/node": "^25.5.2"
40+
}
1341
}
1442

src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { DatabaseSync, DatabaseSyncOptions } from "node:sqlite"
2+
export { version } from "../package.json"
3+
4+
export class SqliteMap<K, V> {
5+
private db: DatabaseSync
6+
7+
constructor(path: string, options?: DatabaseSyncOptions) {
8+
this.db = new DatabaseSync(path, options)
9+
this.db.exec("CREATE TABLE IF NOT EXISTS map (key TEXT PRIMARY KEY, value TEXT)")
10+
}
11+
}

0 commit comments

Comments
 (0)