Skip to content

Commit

Permalink
Enable SDK generation (#10)
Browse files Browse the repository at this point in the history
* Enable and modify generate script

* ci: Generate code

* Add http and webmock deps

* Update rspec config

* Add specs

* ci: Generate code

---------

Co-authored-by: Seam Bot <[email protected]>
  • Loading branch information
andrii-balitskyi and seambot authored May 6, 2024
1 parent 433f43a commit 12465c2
Show file tree
Hide file tree
Showing 92 changed files with 3,319 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--format documentation
--color
--require spec_helper
--pattern "{spec,lib}/**/*_spec.rb"
--pattern "spec/**/*_spec.rb"
34 changes: 33 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,44 @@ PATH
remote: .
specs:
seam (2.0.0a1)
http (~> 5.2)

GEM
remote: https://rubygems.org/
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ansi (1.5.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.7)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.1)
docile (1.4.0)
domain_name (0.6.20240107)
ffi (1.16.3)
ffi-compiler (1.3.2)
ffi (>= 1.15.5)
rake
gem-release (2.2.2)
hashdiff (1.1.0)
http (5.2.0)
addressable (~> 2.8)
base64 (~> 0.1)
http-cookie (~> 1.0)
http-form_data (~> 2.2)
llhttp-ffi (~> 0.5.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
llhttp-ffi (0.5.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
multi_json (1.15.0)
parallel (1.24.0)
parse_gemspec (1.0.0)
Expand All @@ -24,6 +50,7 @@ GEM
parser (3.3.0.5)
ast (~> 2.4.1)
racc
public_suffix (5.0.5)
racc (1.7.3)
rainbow (3.1.1)
rake (13.2.1)
Expand Down Expand Up @@ -85,6 +112,10 @@ GEM
unicode-display_width (>= 1.1.1, < 3)
thor (1.3.1)
unicode-display_width (2.5.0)
webmock (3.0.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff

PLATFORMS
ruby
Expand All @@ -100,6 +131,7 @@ DEPENDENCIES
simplecov (~> 0.21)
simplecov-console (~> 0.9)
standard (~> 1.3)
webmock (~> 3.0.0)

BUNDLED WITH
2.5.7
2.4.19
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require "rspec/core/rake_task"
require "standard/rake"

RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = "--pattern {spec,lib}/**/*_spec.rb"
t.rspec_opts = "--pattern spec/**/*_spec.rb"
end

task default: %i[lint test]
Expand Down
33 changes: 22 additions & 11 deletions generate-routes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dirname, posix, resolve } from 'node:path'
import { dirname, posix } from 'node:path'
import { fileURLToPath } from 'node:url'

import {
Expand All @@ -8,22 +8,33 @@ import {
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))
const libName = 'lib'
const libPath = posix.join(rootPath, libName)
const seamName = 'seam'
const seamPath = posix.join(libPath, seamName)
const libVersionPath = posix.join(seamPath, 'version.rb')
const libVersionRelativePath = posix.join(libName, seamName, 'version.rb')

const pathsToDelete = [
`${libPath}/**/*`,
`!${libPath}/seam/`,
`!${libVersionPath}`,
]

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

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

const files = Object.entries(fileSystem)
.filter(([fileName]) => fileName.startsWith(`${libPrefix}/`))
.filter(([fileName]) => !fileName.startsWith(`${libPrefix}/version.rb`))
.filter(([fileName]) => fileName.startsWith(`${libName}/`))
.filter(([fileName]) => !fileName.startsWith(libVersionRelativePath))
.map(([fileName, fileContent]) =>
fileName.startsWith('lib/seamapi.rb')
? ['lib/seam.rb', fileContent]
: [fileName, fileContent],
)

// TODO: Enable later
// writeFs(rootPath, Object.fromEntries(files))
writeFs(rootPath, Object.fromEntries(files))
70 changes: 68 additions & 2 deletions lib/seam.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

129 changes: 129 additions & 0 deletions lib/seam/client.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 12465c2

Please sign in to comment.