Skip to content

Commit 12465c2

Browse files
Enable SDK generation (#10)
* 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]>
1 parent 433f43a commit 12465c2

File tree

92 files changed

+3319
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3319
-36
lines changed

.rspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
--format documentation
22
--color
33
--require spec_helper
4-
--pattern "{spec,lib}/**/*_spec.rb"
4+
--pattern "spec/**/*_spec.rb"

Gemfile.lock

+33-1
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,44 @@ PATH
22
remote: .
33
specs:
44
seam (2.0.0a1)
5+
http (~> 5.2)
56

67
GEM
78
remote: https://rubygems.org/
89
specs:
10+
addressable (2.8.6)
11+
public_suffix (>= 2.0.2, < 6.0)
912
ansi (1.5.0)
1013
ast (2.4.2)
14+
base64 (0.2.0)
15+
bigdecimal (3.1.7)
16+
crack (1.0.0)
17+
bigdecimal
18+
rexml
1119
diff-lcs (1.5.1)
1220
docile (1.4.0)
21+
domain_name (0.6.20240107)
22+
ffi (1.16.3)
23+
ffi-compiler (1.3.2)
24+
ffi (>= 1.15.5)
25+
rake
1326
gem-release (2.2.2)
27+
hashdiff (1.1.0)
28+
http (5.2.0)
29+
addressable (~> 2.8)
30+
base64 (~> 0.1)
31+
http-cookie (~> 1.0)
32+
http-form_data (~> 2.2)
33+
llhttp-ffi (~> 0.5.0)
34+
http-cookie (1.0.5)
35+
domain_name (~> 0.5)
36+
http-form_data (2.3.0)
1437
json (2.7.2)
1538
language_server-protocol (3.17.0.3)
1639
lint_roller (1.1.0)
40+
llhttp-ffi (0.5.0)
41+
ffi-compiler (~> 1.0)
42+
rake (~> 13.0)
1743
multi_json (1.15.0)
1844
parallel (1.24.0)
1945
parse_gemspec (1.0.0)
@@ -24,6 +50,7 @@ GEM
2450
parser (3.3.0.5)
2551
ast (~> 2.4.1)
2652
racc
53+
public_suffix (5.0.5)
2754
racc (1.7.3)
2855
rainbow (3.1.1)
2956
rake (13.2.1)
@@ -85,6 +112,10 @@ GEM
85112
unicode-display_width (>= 1.1.1, < 3)
86113
thor (1.3.1)
87114
unicode-display_width (2.5.0)
115+
webmock (3.0.1)
116+
addressable (>= 2.3.6)
117+
crack (>= 0.3.2)
118+
hashdiff
88119

89120
PLATFORMS
90121
ruby
@@ -100,6 +131,7 @@ DEPENDENCIES
100131
simplecov (~> 0.21)
101132
simplecov-console (~> 0.9)
102133
standard (~> 1.3)
134+
webmock (~> 3.0.0)
103135

104136
BUNDLED WITH
105-
2.5.7
137+
2.4.19

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require "rspec/core/rake_task"
55
require "standard/rake"
66

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

1111
task default: %i[lint test]

generate-routes.js

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { dirname, posix, resolve } from 'node:path'
1+
import { dirname, posix } from 'node:path'
22
import { fileURLToPath } from 'node:url'
33

44
import {
@@ -8,22 +8,33 @@ import {
88
import { openapi } from '@seamapi/types/connect'
99
import { deleteAsync } from 'del'
1010

11-
const libNameParts = ['lib', 'seam']
12-
const libPrefix = posix.join(...libNameParts)
13-
const libVersionPath = posix.join(libPrefix, 'version.rb')
14-
1511
const rootPath = dirname(fileURLToPath(import.meta.url))
12+
const libName = 'lib'
13+
const libPath = posix.join(rootPath, libName)
14+
const seamName = 'seam'
15+
const seamPath = posix.join(libPath, seamName)
16+
const libVersionPath = posix.join(seamPath, 'version.rb')
17+
const libVersionRelativePath = posix.join(libName, seamName, 'version.rb')
18+
19+
const pathsToDelete = [
20+
`${libPath}/**/*`,
21+
`!${libPath}/seam/`,
22+
`!${libVersionPath}`,
23+
]
1624

17-
// TODO: Enable later
18-
// await deleteAsync([`${libPrefix}/**`, `!${libVersionPath}`])
25+
await deleteAsync(pathsToDelete)
1926

2027
const fileSystem = await generateSdk({
2128
openApiSpecObject: openapi,
2229
})
2330

2431
const files = Object.entries(fileSystem)
25-
.filter(([fileName]) => fileName.startsWith(`${libPrefix}/`))
26-
.filter(([fileName]) => !fileName.startsWith(`${libPrefix}/version.rb`))
32+
.filter(([fileName]) => fileName.startsWith(`${libName}/`))
33+
.filter(([fileName]) => !fileName.startsWith(libVersionRelativePath))
34+
.map(([fileName, fileContent]) =>
35+
fileName.startsWith('lib/seamapi.rb')
36+
? ['lib/seam.rb', fileContent]
37+
: [fileName, fileContent],
38+
)
2739

28-
// TODO: Enable later
29-
// writeFs(rootPath, Object.fromEntries(files))
40+
writeFs(rootPath, Object.fromEntries(files))

lib/seam.rb

+68-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/seam/client.rb

+129
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)