Skip to content
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
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Report a security vulnerability
url: https://github.com/revxshafi/sql-switch/security/advisories/new
url: https://github.com/creative-softworks/sql-switch/security/advisories/new
about: Please do not open a public issue for security problems. Report privately as described in SECURITY.md (the repository's Security tab).
- name: Questions & discussion
url: https://github.com/revxshafi/sql-switch/discussions
url: https://github.com/creative-softworks/sql-switch/discussions
about: Have a question or an idea to talk through? Start a discussion instead of filing an issue.
53 changes: 35 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Publish

# fires when you push a version tag (git tag v0.2.0 && git push origin v0.2.0), or by hand from the
# Actions tab. the actual publish is gated on the same typecheck/test/smoke/build a PR ran (via the
# package.json prepublishOnly hook), so a tag can't ship something that wouldn't have merged.
# Actions tab. two packages ship from this one repo => the real code as `sql-switch` (unscoped), and
# `@creative-softworks/sql-switch` (in scoped/) which just re-exports it. the actual publish is gated
# on the same typecheck/test/smoke/build a PR ran (package.json prepublishOnly), so a tag can't ship
# something that wouldn't have merged.
on:
push:
tags:
Expand All @@ -19,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
# OIDC => npm trusted publishing + provenance, so no long lived NPM_TOKEN has to live in secrets
# provenance attestation is signed with this even on token auth => keep it on
id-token: write

steps:
Expand All @@ -34,28 +36,43 @@ jobs:
with:
node-version: 22
cache: pnpm
# writes the ~/.npmrc that NODE_AUTH_TOKEN below fills in, for both publishes
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: pnpm install --frozen-lockfile

# a tag that doesn't match package.json is almost always a slip => cheaper to stop here than to
# unpublish. only runs for a real tag push, a manual workflow_dispatch run has no tag to check.
- name: Tag must match package.json version
# a tag that doesn't match is almost always a slip => cheaper to stop here than to unpublish.
# both package.json versions have to agree with the tag, and the scoped alias has to pin the
# unscoped version it re-exports, otherwise the two packages drift apart. tag push only.
- name: Versions must match the tag
if: github.ref_type == 'tag'
run: |
pkg="v$(node -p "require('./package.json').version")"
tag="${GITHUB_REF_NAME}"
echo "package.json=$pkg tag=$tag"
if [ "$pkg" != "$tag" ]; then
echo "::error::tag $tag does not match package.json version $pkg"
exit 1
fi

# npm (not pnpm) does the OIDC handshake for trusted publishing, and it needs a recent npm.
# prepublishOnly reruns typecheck/test/smoke/build first, and publishConfig.provenance is on =>
# the id-token: write permission above is what lets the provenance attestation get signed.
- name: Publish to npm
tag="${GITHUB_REF_NAME#v}"
root="$(node -p "require('./package.json').version")"
scoped="$(node -p "require('./scoped/package.json').version")"
pin="$(node -p "require('./scoped/package.json').dependencies['sql-switch']")"
echo "tag=$tag root=$root scoped=$scoped pin=$pin"
fail=0
[ "$root" = "$tag" ] || { echo "::error::package.json ($root) != tag ($tag)"; fail=1; }
[ "$scoped" = "$tag" ] || { echo "::error::scoped/package.json ($scoped) != tag ($tag)"; fail=1; }
[ "$pin" = "$tag" ] || { echo "::error::scoped pins sql-switch@$pin, expected $tag"; fail=1; }
exit $fail

# npm (not pnpm) does the publish + provenance, and it needs a recent npm. prepublishOnly reruns
# typecheck/test/smoke/build first => the gate is the same one a PR passed.
- name: Publish sql-switch (unscoped, the real code)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm install -g npm@latest
npm publish --access public

# the alias has no build step (three hand-written re-export files) => prepublishOnly doesn't run
# here, the gate above already covered the code it points at. depends on sql-switch@<tag> which
# the step above just published.
- name: Publish @creative-softworks/sql-switch (scoped alias)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: scoped
run: npm publish --access public
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ Initial pre-release of the universal SQLite/PostgreSQL DAL.
crashing, then recovers.
- Bidirectional engine swap => migrate data SQLite files <=> PostgreSQL schemas.

[Unreleased]: https://github.com/revxshafi/sql-switch/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/revxshafi/sql-switch/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/revxshafi/sql-switch/releases/tag/v0.1.0
[Unreleased]: https://github.com/creative-softworks/sql-switch/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/creative-softworks/sql-switch/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/creative-softworks/sql-switch/releases/tag/v0.1.0
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Thanks for taking a look. This is a small project, so the workflow is light.
## Getting set up

```bash
git clone https://github.com/revxshafi/sql-switch.git
git clone https://github.com/creative-softworks/sql-switch.git
cd sql-switch
pnpm install
```
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Universal hot-swappable database abstraction layer for Node.js. Run SQLite local
npm install sql-switch
```

Also published under the Creative-Softworks scope if you prefer the branded name — it re-exports
this package unchanged, so pick whichever reads better to you:

```bash
npm install @creative-softworks/sql-switch
```

The database drivers are **optional peer dependencies** — install only the one for the engine you
run, so a SQLite-only app never pulls in `pg` and its build, and vice versa:

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sql-switch",
"version": "0.2.0",
"version": "0.0.0",
"description": "Universal hot-swappable DAL — SQLite in dev, PostgreSQL in prod, same fluent API",
"type": "module",
"packageManager": "pnpm@10.26.1",
Expand Down Expand Up @@ -49,12 +49,12 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/revxshafi/sql-switch.git"
"url": "git+https://github.com/creative-softworks/sql-switch.git"
},
"bugs": {
"url": "https://github.com/revxshafi/sql-switch/issues"
"url": "https://github.com/creative-softworks/sql-switch/issues"
},
"homepage": "https://github.com/revxshafi/sql-switch#readme",
"homepage": "https://github.com/creative-softworks/sql-switch#readme",
"publishConfig": {
"access": "public",
"provenance": true
Expand Down
18 changes: 18 additions & 0 deletions scoped/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# @creative-softworks/sql-switch

Branded alias of [**sql-switch**](https://www.npmjs.com/package/sql-switch) — a universal, hot-swappable database abstraction layer: SQLite in dev, PostgreSQL in prod, one fluent API.

This package re-exports `sql-switch` unchanged. It exists so the library can be installed under the Creative-Softworks scope; the code, versions and docs all live in the main package.

```bash
npm install @creative-softworks/sql-switch
```

```ts
// the short unscoped name resolves too (it's pulled in as a dependency)
import { createDAL } from 'sql-switch';
```

Full documentation: https://github.com/creative-softworks/sql-switch#readme

Everything is identical to `sql-switch` at the same version — see that package for the API, guides and changelog.
4 changes: 4 additions & 0 deletions scoped/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// see index.js => forward the unscoped `sql-switch` package wholesale (named exports & the
// default `createDAL` alike). CJS entry, so `require('@creative-softworks/sql-switch')` is
// byte for byte what `require('sql-switch')` returns.
module.exports = require('sql-switch');
4 changes: 4 additions & 0 deletions scoped/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// types for the alias => re-export everything the unscoped package's declarations expose, the
// default included, so editors see the identical surface under either name.
export * from 'sql-switch';
export { default } from 'sql-switch';
5 changes: 5 additions & 0 deletions scoped/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// branded alias => the real code lives in the unscoped `sql-switch` package. this file just
// re-exports it, so `@creative-softworks/sql-switch` and `sql-switch` are the exact same API from
// one source of truth (one place bugs get fixed, one version to bump). ESM entry.
export * from 'sql-switch';
export { default } from 'sql-switch';
51 changes: 51 additions & 0 deletions scoped/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@creative-softworks/sql-switch",
"version": "0.0.0",
"description": "Branded alias of sql-switch — a universal hot-swappable DAL (SQLite in dev, PostgreSQL in prod, same fluent API). Re-exports the sql-switch package unchanged.",
"type": "module",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.js",
"require": "./index.cjs"
}
},
"main": "./index.cjs",
"module": "./index.js",
"types": "./index.d.ts",
"files": [
"index.js",
"index.cjs",
"index.d.ts",
"README.md"
],
"engines": {
"node": ">=22.0.0"
},
"keywords": [
"database",
"sqlite",
"postgresql",
"drizzle",
"dal",
"hot-swap"
],
"author": "Rev Albrecht von Nullpointer <160512015+revxshafi@users.noreply.github.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/creative-softworks/sql-switch.git",
"directory": "scoped"
},
"bugs": {
"url": "https://github.com/creative-softworks/sql-switch/issues"
},
"homepage": "https://github.com/creative-softworks/sql-switch#readme",
"publishConfig": {
"access": "public",
"provenance": true
},
"dependencies": {
"sql-switch": "0.0.0"
}
}