MCPcopy Create free account
hub / github.com/decaporg/decap-cms / setupGitGateway

Function setupGitGateway

cypress/plugins/gitGateway.js:171–263  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

169};
170
171async function setupGitGateway(options) {
172 const { provider, ...rest } = options;
173 const result = await methods[provider].setup(rest);
174
175 if (process.env.RECORD_FIXTURES) {
176 const { netlifyApiToken } = getEnvs();
177
178 console.log(`Creating Netlify Site for provider: ${provider}`);
179 let site_id, ssl_url;
180 try {
181 ({ site_id, ssl_url } = await methods[provider].createSite(netlifyApiToken, result));
182 } catch (e) {
183 console.log(e);
184 throw e;
185 }
186
187 console.log('Enabling identity for site:', site_id);
188 // Enable Netlify Identity
189 await fetchWithTimeout(netlifyApiToken, `sites/${site_id}/identity`, 'POST', {});
190
191 console.log('Enabling git gateway for site:', site_id);
192 const token = methods[provider].token();
193 // Enable Git Gateway
194 await fetchWithTimeout(netlifyApiToken, `sites/${site_id}/services/git/instances`, 'POST', {
195 [provider]: {
196 repo: `${result.owner}/${result.repo}`,
197 access_token: token,
198 },
199 });
200
201 console.log('Enabling large media for site:', site_id);
202 // Enable Large Media
203 await fetchWithTimeout(netlifyApiToken, `sites/${site_id}/services/large-media/instances`, 'POST', {});
204
205 const git = getGitClient(result.tempDir);
206 await git.raw([
207 'config',
208 '-f',
209 '.lfsconfig',
210 'lfs.url',
211 `https://${site_id}.netlify.com/.netlify/large-media`,
212 ]);
213 await git.addConfig('commit.gpgsign', 'false');
214 await git.add('.lfsconfig');
215 await git.commit('add .lfsconfig');
216 await git.push('origin', 'master');
217
218 await waitForDeploys(netlifyApiToken, site_id);
219 console.log('Creating user for site:', site_id, 'with email:', email);
220
221 try {
222 // Create a user account via Netlify Identity
223 await fetchWithTimeout(
224 netlifyApiToken,
225 `${ssl_url}/.netlify/functions/create-user`,
226 'POST',
227 { email, password },
228 'text'

Callers 1

setupBackendFunction · 0.85

Calls 5

getGitClientFunction · 0.85
waitForDeploysFunction · 0.85
getEnvsFunction · 0.70
fetchWithTimeoutFunction · 0.70
commitMethod · 0.45

Tested by

no test coverage detected