MCPcopy
hub / github.com/leonhartX/gas-github / pull

Method pull

src/gas/script-api.js:6–79  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

4
5class ScriptApi {
6 pull(code) {
7 const config = getConfig();
8 const changed = $('.diff-file:checked').toArray().map(elem => elem.value);
9 const updatedFiles = changed.filter(f => code.scm[f]).map(f => {
10 const suffix = f.substr(f.lastIndexOf("."));
11 const file = f.substr(0, f.lastIndexOf("."));
12 let type;
13 switch (suffix) {
14 case ".html":
15 type = "HTML";
16 break;
17 case ".json":
18 type = "JSON";
19 break;
20 case config.filetype:
21 type = "SERVER_JS";
22 break;
23 }
24 return {
25 name: file,
26 source: code.scm[f],
27 type: type
28 }
29 });
30 const deleteFiles = changed.filter(f => !code.scm[f]);
31 const remainedFiles = Object.keys(code.gas)
32 .filter(f => !deleteFiles.includes(f) && !changed.includes(f))
33 .map(f => {
34 const suffix = f.substr(f.lastIndexOf("."));
35 const file = f.substr(0, f.lastIndexOf("."));
36 let type;
37 switch (suffix) {
38 case ".html":
39 type = "HTML";
40 break;
41 case ".json":
42 type = "JSON";
43 break;
44 case config.filetype:
45 type = "SERVER_JS";
46 break;
47 }
48 return {
49 name: file,
50 source: code.gas[f],
51 type: type
52 }
53 });
54 const files = updatedFiles.concat(remainedFiles);
55 console.log(files)
56
57 this.updateToken()
58 .then(() => {
59 return new Promise((resolve, reject) => {
60 $.ajax({
61 url: `${API_URL}/${getId()}/content?access_token=${context.gapiToken}`,
62 method: 'PUT',
63 contentType: 'application/json',

Callers 1

showDiffFunction · 0.80

Calls 4

updateTokenMethod · 0.95
getConfigFunction · 0.85
getIdFunction · 0.85
showLogFunction · 0.85

Tested by

no test coverage detected