-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 639929f
Showing
40 changed files
with
6,707 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Publish Experimental Packages | ||
description: Bumps the version of an npm package and publishes it with an experimental tag. | ||
|
||
on: | ||
workflow_call: [] | ||
|
||
inputs: | ||
package_dir: | ||
description: Directory of the Package to Publish | ||
required: true | ||
default: './' | ||
|
||
outputs: | ||
VERSION_TAG: | ||
description: Generated Experimental Version Tag for This Package | ||
value: ${{ steps.version-tag.outputs.VERSION_TAG }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Construct Experimental Version Tag | ||
id: version-tag | ||
shell: bash | ||
run: | | ||
BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | sed -r 's/([a-z0-9])([A-Z])/\1-\L\2/g' | sed 's/_/-/g' | sed 's/\//-/g') | ||
echo "VERSION_TAG=$(echo $BRANCH_NAME)-experimental" >> $GITHUB_ENV | ||
echo "VERSION_TAG=$(echo $VERSION_TAG)" >> $GITHUB_OUTPUT | ||
- name: Bump ${{ inputs.package_dir }} | ||
shell: bash | ||
run: | | ||
cd ${{ inputs.package_dir }} | ||
PACKAGE_NAME=$(cat package.json | grep "name" | cut -d':' -f 2 | cut -d'"' -f 2) | ||
echo "PACKAGE_NAME=${PACKAGE_NAME}" >> $GITHUB_ENV | ||
# Matches any version that ends with "-author-ron-123-experimental.<number>". e.g. 1.0.0-leo-ron-123-experimental.0 | ||
REGEX="\-$VERSION_TAG.[0-9]\{1,\}$" | ||
# Get all versions | ||
ALL_VERSIONS=$(npm view $PACKAGE_NAME versions --json | jq -r '.[]') | ||
# Check if the experimental version already exists | ||
if ! echo "$ALL_VERSIONS" | grep -q "$REGEX"; then | ||
# If not, create it | ||
npm version prerelease --preid=$VERSION_TAG --no-git-tag-version | ||
else | ||
# Otherwise up it | ||
LATEST_VERSION=$(echo "$ALL_VERSIONS" | grep "$REGEX" | tail -1) | ||
npm version $(npx semver $LATEST_VERSION -i prerelease --preid="$VERSION_TAG") --no-git-tag-version | ||
fi | ||
- name: Publish to npm | ||
shell: bash | ||
run: cd ${{ inputs.package_dir }} && npm publish --tag="$VERSION_TAG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Publish Experimental Packages | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Deploy | ||
permissions: | ||
# Required for `actions/checkout@v3` | ||
contents: read | ||
# Required for `thollander/actions-comment-pull-request@v2` | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
|
||
# Needed only for bumping package version and publishing npm packages. | ||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
- run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_READ_AND_WRITE }}' > ~/.npmrc | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
|
||
- name: Install Dependencies | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Build Package | ||
run: bun run build | ||
|
||
- name: Bump Package | ||
uses: ./.github/actions/bump-version | ||
|
||
- name: Comment on PR | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
comment_tag: packages_announcement | ||
message: | | ||
Released an experimental package: | ||
```bash | ||
bun add @ronin/compiler@${{ env.VERSION_TAG }} | ||
``` | ||
This package will be removed after the pull request has been merged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Manually Publish npm Packages | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version_type: | ||
description: Choose a version type to bump the package version by. | ||
required: true | ||
default: 'patch' | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
- prerelease | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Deploy | ||
steps: | ||
- name: Generate GitHub App Token | ||
id: generate_token | ||
uses: tibdex/github-app-token@v1 | ||
with: | ||
app_id: ${{ secrets.ORG_GH_RONIN_APP_ID }} | ||
private_key: ${{ secrets.ORG_GH_RONIN_APP_PRIVATE_KEY }} | ||
|
||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
with: | ||
token: ${{ steps.generate_token.outputs.token }} | ||
|
||
# Needed only for bumping package version and publishing npm packages. | ||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
- run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_READ_AND_WRITE }}' > ~/.npmrc | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
|
||
- name: Install Dependencies | ||
run: bun install --frozen-lockfile | ||
|
||
- name: Build Package | ||
run: bun run build | ||
|
||
- name: Set Git Config | ||
run: | | ||
# See where these config values come from at https://stackoverflow.com/a/74071223 | ||
git config --global user.name "ronin-app[bot]" | ||
git config --global user.email 135042755+ronin-app[bot]@users.noreply.github.com | ||
- name: Bump Package | ||
run: | | ||
npm version ${{ inputs.version_type }} --git-tag-version=false | ||
echo "NEW_VERSION=$(npm pkg get version --workspaces=false | tr -d \")" >> $GITHUB_ENV | ||
- name: Push New Version | ||
run: | | ||
git fetch | ||
git checkout ${GITHUB_HEAD_REF} | ||
git pull origin ${GITHUB_HEAD_REF} | ||
git commit -a -m '${{ env.NEW_VERSION }}' --no-verify | ||
git tag -a ${{ env.NEW_VERSION }} -m '${{ env.NEW_VERSION }}' | ||
git push origin ${GITHUB_HEAD_REF} | ||
# Push tag | ||
git push origin ${{ env.NEW_VERSION }} | ||
- name: Publish npm Package | ||
run: npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Remove Experimental Packages | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [closed] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Remove Experimental Packages | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Node.js | ||
uses: actions/[email protected] | ||
- run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_READ_AND_WRITE }}' > ~/.npmrc | ||
|
||
# This converts the branch name into dash-case, so it can be used as a | ||
# valid dist-tag. | ||
- name: Extract Branch Name | ||
shell: bash | ||
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | sed -r 's/([a-z0-9])([A-Z])/\1-\L\2/g' | sed 's/_/-/g' | sed 's/\//-/g')" >> $GITHUB_ENV | ||
|
||
- name: Remove Experimental Packages | ||
run: npm dist-tag rm @ronin/compiler $BRANCH_NAME-experimental |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Validate | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 1.1.27 | ||
|
||
- name: Install Dependencies | ||
run: bun install | ||
|
||
- name: Lint | ||
run: bun run lint | ||
|
||
test: | ||
name: Testing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: 1.1.27 | ||
|
||
- name: Install Dependencies | ||
run: bun install | ||
|
||
- name: Test | ||
run: bun test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Dependencies | ||
node_modules | ||
|
||
# Build output | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["oven.bun-vscode", "biomejs.biome"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "biomejs.biome", | ||
"editor.rulers": [90, 120], | ||
"editor.insertSpaces": true, | ||
"editor.detectIndentation": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports.biome": "explicit" | ||
}, | ||
|
||
"javascript.updateImportsOnFileMove.enabled": "always", | ||
"typescript.updateImportsOnFileMove.enabled": "always", | ||
"javascript.preferences.importModuleSpecifier": "non-relative", | ||
"typescript.preferences.importModuleSpecifier": "non-relative", | ||
"typescript.suggest.autoImports": true, | ||
"typescript.preferences.quoteStyle": "single", | ||
"javascript.preferences.quoteStyle": "single", | ||
|
||
"[json][javascript][javascriptreact][typescript][typescriptreact]": { | ||
"editor.defaultFormatter": "biomejs.biome" | ||
}, | ||
|
||
"typescript.format.enable": false, | ||
"javascript.format.enable": false, | ||
|
||
"yaml.schemas": { | ||
"https://json.schemastore.org/github-workflow.json": ".github/workflows/*.yml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# RONIN Compiler | ||
|
||
This package compiles RONIN queries to SQL statements. | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { compileQueryInput } from '@ronin/compiler'; | ||
|
||
const query = { | ||
get: { | ||
accounts: null, | ||
}, | ||
}; | ||
|
||
const schemas = [ | ||
{ | ||
pluralSlug: 'accounts', | ||
slug: 'account', | ||
}, | ||
]; | ||
|
||
const { writeStatements, readStatement } = compileQueryInput(query, schemas); | ||
|
||
console.log(readStatement); | ||
// SELECT * FROM "accounts" ORDER BY "ronin.createdAt" DESC LIMIT 101 | ||
``` | ||
|
||
## Testing | ||
|
||
Use the following command to run the test suite: | ||
|
||
``` | ||
bun test | ||
``` |
Oops, something went wrong.