@bagelink/sdk 1.2.151 → 1.2.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.ts +22 -2
- package/bin/utils.ts +4 -0
- package/package.json +2 -1
package/bin/index.ts
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import fs from 'node:fs'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
import { openAPI } from '@bagelink/sdk'
|
|
6
|
+
import { splitClientCode } from './splitClientGen'
|
|
6
7
|
import { formatAndWriteCode, getKwargs, handleAuthCode, runEsLintOnDir } from './utils'
|
|
7
8
|
|
|
8
|
-
const { bagelinkDir, withAuth, openApiUrl, proc } = getKwargs()
|
|
9
|
+
const { bagelinkDir, withAuth, shouldSplitFiles, openApiUrl, proc } = getKwargs()
|
|
9
10
|
|
|
10
11
|
export async function loadTypes() {
|
|
11
12
|
const { types, code } = await openAPI(
|
|
@@ -15,6 +16,7 @@ export async function loadTypes() {
|
|
|
15
16
|
|
|
16
17
|
if (!fs.existsSync(bagelinkDir)) fs.mkdirSync(bagelinkDir)
|
|
17
18
|
|
|
19
|
+
// Generate monolithic files first
|
|
18
20
|
const typesPath = join(bagelinkDir, 'types.d.ts')
|
|
19
21
|
await formatAndWriteCode(typesPath, types)
|
|
20
22
|
|
|
@@ -24,8 +26,26 @@ export async function loadTypes() {
|
|
|
24
26
|
const indexPath = join(bagelinkDir, 'index.ts')
|
|
25
27
|
await formatAndWriteCode(indexPath, `export * from './api'\nexport * from './types.d'`)
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
// Optionally split into organized files
|
|
30
|
+
if (shouldSplitFiles) {
|
|
31
|
+
try {
|
|
32
|
+
await splitClientCode({
|
|
33
|
+
bagelinkDir,
|
|
34
|
+
useDirectories: true,
|
|
35
|
+
})
|
|
36
|
+
// remove monolithic files if splitting is successful
|
|
37
|
+
console.log('Cleaning up monolithic temporary files...')
|
|
38
|
+
fs.rmSync(apiPath, { force: true })
|
|
39
|
+
fs.rmSync(typesPath, { force: true })
|
|
40
|
+
fs.rmSync(indexPath, { force: true })
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('Error splitting client code:', error)
|
|
43
|
+
// Continue with monolithic files if splitting fails
|
|
44
|
+
}
|
|
45
|
+
}
|
|
28
46
|
|
|
47
|
+
await handleAuthCode(withAuth, bagelinkDir)
|
|
48
|
+
console.log('Attempting to format generated files...')
|
|
29
49
|
await runEsLintOnDir(bagelinkDir)
|
|
30
50
|
|
|
31
51
|
console.log('Client & type files generated successfully!!!')
|
package/bin/utils.ts
CHANGED
|
@@ -13,6 +13,9 @@ const [_, __, dirFlag, withAuthArg] = proc.argv as Partial<string[]>
|
|
|
13
13
|
|
|
14
14
|
const withAuth = withAuthArg === '--auth'
|
|
15
15
|
|
|
16
|
+
// Parse command line arguments
|
|
17
|
+
const shouldSplitFiles = proc.argv.includes('--split')
|
|
18
|
+
|
|
16
19
|
if (dirFlag !== undefined) {
|
|
17
20
|
console.log(`using passed in dir to generate sdk client: ${dirFlag}`)
|
|
18
21
|
} else {
|
|
@@ -34,6 +37,7 @@ export function getKwargs() {
|
|
|
34
37
|
openApiUrl,
|
|
35
38
|
bagelinkDir,
|
|
36
39
|
withAuth,
|
|
40
|
+
shouldSplitFiles,
|
|
37
41
|
cwd,
|
|
38
42
|
env,
|
|
39
43
|
proc
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.153",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Neveh Allon",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@typescript-eslint/typescript-estree": "^8.32.0",
|
|
53
54
|
"axios": "^1.9.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|