-
Notifications
You must be signed in to change notification settings - Fork 0
Proposed v1.0.0 of Schema Codegen #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c97e1b
85f8e9a
0285b58
94b5574
443195f
316b196
5e50b72
a79d1df
9b03e11
eb85f6a
4e7ec9d
c037296
62589ad
774385d
c699896
482a774
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * @HarperFast/developers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| merge_group: | ||
| branches: | ||
| - main | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| # Needed for semantic-release to create GitHub releases and publish to npm via OIDC | ||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: Release | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Release | ||
| environment: Release | ||
| # Ensure releases run only when code reaches main via GitHub Merge Queue, or when manually dispatched | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
cb1kenobi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| with: | ||
| fetch-depth: 0 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: npm | ||
| registry-url: 'https://registry.npmjs.org' | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Check lint | ||
| run: npm run lint:check | ||
| - name: Check format | ||
| run: npm run format:check | ||
| - name: Run unit tests | ||
| run: npm test | ||
| - name: Semantic Release | ||
| if: ${{ github.event_name == 'push' }} | ||
| uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_CONFIG_PROVENANCE: true | ||
| - name: Publish to NPM | ||
| run: npm publish --provenance | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: Verify Commits | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, edited, reopened, ready_for_review] | ||
| push: | ||
| branches: [main] | ||
| jobs: | ||
| commitlint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - name: Commitlint | ||
| uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1 | ||
| with: | ||
| configFile: commitlint.config.cjs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Verify PR | ||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| branches: [main] | ||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: npm | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Check lint | ||
| run: npm run lint:check | ||
|
|
||
| format: | ||
| name: Format | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| cache: npm | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Check format | ||
| run: npm run format:check | ||
|
|
||
| test: | ||
| name: Test (${{ matrix.os }}, Node ${{ matrix.node-version }}) | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] | ||
| node-version: [20, 22, 24] | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: npm | ||
| - name: Install dependencies | ||
| run: npm ci | ||
| - name: Run unit tests | ||
| run: npm test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "$schema": "./node_modules/oxfmt/configuration_schema.json", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case you're curious, here's rocksdb-js' oxfmt config: https://github.com/HarperFast/rocksdb-js/blob/main/.oxfmtrc.json. Most of the settings are the defaults and could have been omitted.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I've got it down to the minimum in this repo -- are there other ones that you think should be the norm for Harper? Single quotes and tabs.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, I'll start applying this consistently across other repos I touch like Studio, Agent and create harper. |
||
| "singleQuote": true, | ||
| "useTabs": true | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "$schema": "./node_modules/oxlint/configuration_schema.json", | ||
| "ignorePatterns": [], | ||
| "rules": {}, | ||
| "overrides": [] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| module.exports = { | ||
| extends: ['@commitlint/config-conventional'], | ||
| rules: { | ||
| 'subject-case': [0, 'never'], | ||
| 'body-max-line-length': [0, 'never'], | ||
| 'footer-max-line-length': [0, 'never'], | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| extensionModule: ./extensionModule.ts | ||
| extensionModule: ./extensionModule.js |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /** @typedef {import('harperdb').Scope} Scope */ | ||
| import { setTimeout as delay } from 'node:timers/promises'; | ||
| import { setLogger } from './utils/logger.js'; | ||
| import { regenerateAll } from './utils/regenerateAll.js'; | ||
|
|
||
| export const suppressHandleApplicationWarning = true; | ||
|
|
||
| /** | ||
| * @param {Scope} scope | ||
| */ | ||
| export async function handleApplication(scope) { | ||
| setLogger(scope.logger); | ||
|
|
||
| if (!process.env.DEV_MODE) { | ||
| scope.logger.trace?.('@harperfast/schema-codegen skipping execution outside of dev mode'); | ||
| return; | ||
| } | ||
|
|
||
| const watchConfig = scope.options.get(['watch']); | ||
| const shouldWatch = watchConfig === true || watchConfig === undefined; | ||
| const globalTypes = /** @type {string} */ (scope.options.get(['globalTypes'])) || | ||
| './schema.globalTypes.d.ts'; | ||
| const schemaTypes = /** @type {string} */ (scope.options.get(['schemaTypes'])) || | ||
| './schema.types.ts'; | ||
| const jsdoc = /** @type {string | undefined} */ (scope.options.get(['jsdoc'])); | ||
|
|
||
| if (shouldWatch) { | ||
| scope.on('close', scopeClosed); | ||
| } | ||
|
|
||
| // Do not await this. | ||
| delay(500).then(() => { | ||
| // Initial generation | ||
| regenerateAll(globalTypes, schemaTypes, jsdoc); | ||
|
|
||
| if (shouldWatch) { | ||
| // Watch for schema/database changes via events | ||
| scope.databaseEvents.on('updateTable', updateTable); | ||
| scope.databaseEvents.on('dropTable', dropTable); | ||
| scope.databaseEvents.on('dropDatabase', dropDatabase); | ||
| } | ||
| }); | ||
|
|
||
| function updateTable() { | ||
| regenerateAll(globalTypes, schemaTypes, jsdoc); | ||
| } | ||
|
|
||
| function dropTable() { | ||
| regenerateAll(globalTypes, schemaTypes, jsdoc); | ||
| } | ||
|
|
||
| function dropDatabase() { | ||
| regenerateAll(globalTypes, schemaTypes, jsdoc); | ||
| } | ||
|
|
||
| function scopeClosed() { | ||
| scope.databaseEvents.off('updateTable', updateTable); | ||
| scope.databaseEvents.off('dropTable', dropTable); | ||
| scope.databaseEvents.off('dropDatabase', dropDatabase); | ||
| scope.off('close', scopeClosed); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.