Skip to content

Commit

Permalink
Add generate script (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x authored Apr 19, 2024
1 parent ab946d7 commit 433f43a
Show file tree
Hide file tree
Showing 5 changed files with 1,550 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/** linguist-generated
2 changes: 2 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
run: bundle install
- name: Normalize package-lock.json
run: npm install
- name: Generate code
run: npm run generate
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
29 changes: 29 additions & 0 deletions generate-routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { dirname, posix, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

import {
generateRubySDK as generateSdk,
writeFs,
} from '@seamapi/nextlove-sdk-generator'
import { openapi } from '@seamapi/types/connect'
import { deleteAsync } from 'del'

const libNameParts = ['lib', 'seam']
const libPrefix = posix.join(...libNameParts)
const libVersionPath = posix.join(libPrefix, 'version.rb')

const rootPath = dirname(fileURLToPath(import.meta.url))

// TODO: Enable later
// await deleteAsync([`${libPrefix}/**`, `!${libVersionPath}`])

const fileSystem = await generateSdk({
openApiSpecObject: openapi,
})

const files = Object.entries(fileSystem)
.filter(([fileName]) => fileName.startsWith(`${libPrefix}/`))
.filter(([fileName]) => !fileName.startsWith(`${libPrefix}/version.rb`))

// TODO: Enable later
// writeFs(rootPath, Object.fromEntries(files))
Loading

0 comments on commit 433f43a

Please sign in to comment.