@@ -56,16 +56,21 @@ export async function triggerImport(
56
56
const { api } = context ;
57
57
const { force = false , updateGitInfo = false , standalone, eventTimestamp } = options ;
58
58
59
+ const spaceId =
60
+ typeof spaceInstallation . space === 'string'
61
+ ? spaceInstallation . space
62
+ : spaceInstallation . space . id ;
63
+
59
64
const config = getSpaceConfigOrThrow ( spaceInstallation ) ;
60
65
61
66
if ( ! config . key ) {
62
- logger . info ( `No configuration found for space ${ spaceInstallation . space } , skipping import` ) ;
67
+ logger . info ( `No configuration found for space ${ spaceId } , skipping import` ) ;
63
68
return ;
64
69
}
65
70
66
71
assertIsDefined ( config . branch , { label : 'config.branch' } ) ;
67
72
68
- logger . info ( `Initiating an import from GitHub to GitBook space ${ spaceInstallation . space } ` ) ;
73
+ logger . info ( `Initiating an import from GitHub to GitBook space ${ spaceId } ` ) ;
69
74
70
75
const auth = await getRepositoryAuth ( context , config ) ;
71
76
const repoTreeURL = getGitTreeURL ( config ) ;
@@ -74,7 +79,7 @@ export async function triggerImport(
74
79
urlWithAuth . username = auth . username ;
75
80
urlWithAuth . password = auth . password ;
76
81
77
- await api . spaces . importGitRepository ( spaceInstallation . space , {
82
+ await api . spaces . importGitRepository ( spaceId , {
78
83
url : urlWithAuth . toString ( ) ,
79
84
ref : standalone ?. ref || config . branch ,
80
85
repoTreeURL,
@@ -113,18 +118,23 @@ export async function triggerExport(
113
118
const { api } = context ;
114
119
const { force = false , updateGitInfo = false , eventTimestamp } = options ;
115
120
121
+ const spaceId =
122
+ typeof spaceInstallation . space === 'string'
123
+ ? spaceInstallation . space
124
+ : spaceInstallation . space . id ;
125
+
116
126
const config = getSpaceConfigOrThrow ( spaceInstallation ) ;
117
127
118
128
if ( ! config . key ) {
119
- logger . info ( `No configuration found for space ${ spaceInstallation . space } , skipping export` ) ;
129
+ logger . info ( `No configuration found for space ${ spaceId } , skipping export` ) ;
120
130
return ;
121
131
}
122
132
123
133
assertIsDefined ( config . branch , { label : 'config.branch' } ) ;
124
134
125
- logger . info ( `Initiating an export from space ${ spaceInstallation . space } to GitHub` ) ;
135
+ logger . info ( `Initiating an export from space ${ spaceId } to GitHub` ) ;
126
136
127
- const { data : revision } = await api . spaces . getCurrentRevision ( spaceInstallation . space ) ;
137
+ const { data : revision } = await api . spaces . getCurrentRevision ( spaceId ) ;
128
138
129
139
const auth = await getRepositoryAuth ( context , config ) ;
130
140
const repoTreeURL = getGitTreeURL ( config ) ;
@@ -133,7 +143,7 @@ export async function triggerExport(
133
143
urlWithAuth . username = auth . username ;
134
144
urlWithAuth . password = auth . password ;
135
145
136
- await api . spaces . exportToGitRepository ( spaceInstallation . space , {
146
+ await api . spaces . exportToGitRepository ( spaceId , {
137
147
url : urlWithAuth . toString ( ) ,
138
148
ref : config . branch ,
139
149
repoTreeURL,
@@ -160,7 +170,12 @@ export async function updateCommitWithPreviewLinks(
160
170
) {
161
171
const config = getSpaceConfigOrThrow ( spaceInstallation ) ;
162
172
163
- const { data : space } = await runtime . api . spaces . getSpaceById ( spaceInstallation . space ) ;
173
+ const spaceId =
174
+ typeof spaceInstallation . space === 'string'
175
+ ? spaceInstallation . space
176
+ : spaceInstallation . space . id ;
177
+
178
+ const { data : space } = await runtime . api . spaces . getSpaceById ( spaceId ) ;
164
179
165
180
const context = `GitBook${ config . projectDirectory ? ` (${ config . projectDirectory } )` : '' } ` ;
166
181
0 commit comments