20cfde5ea3
This reverts commit40ced41cce
. GitLab removed the SDL files from the docs:baedeb4ee8
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
/*
|
|
* Copycat. Copyright (C) 2020 selfisekai <laura@selfisekai.rocks> and other contributors.
|
|
*
|
|
* This is free software, and you are welcome to redistribute it
|
|
* under the GNU General Public License 3.0 or later; see the LICENSE file for details,
|
|
* or, if the file is unavailable, visit <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
|
*/
|
|
|
|
import { getIntrospectionQuery } from 'graphql';
|
|
import got, { Options as GotOptions } from 'got';
|
|
import { createWriteStream } from 'fs';
|
|
import path from 'path';
|
|
import { pipeline as pipelineUnpromised } from 'stream';
|
|
import { promisify } from 'util';
|
|
|
|
const pipeline = promisify(pipelineUnpromised);
|
|
|
|
const introspection = {
|
|
method: 'POST' as 'POST',
|
|
body: JSON.stringify({ query: getIntrospectionQuery() }),
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
};
|
|
|
|
const schemas: [
|
|
string, // vendor
|
|
'graphql' | 'json', // filetype
|
|
[string | URL, GotOptions & { isStream?: true | undefined }],
|
|
][] = [
|
|
['github', 'graphql', ['https://docs.github.com/public/schema.docs.graphql', {}]],
|
|
['gitlab', 'json', ['https://gitlab.com/api/graphql', introspection]],
|
|
];
|
|
|
|
Promise.all(
|
|
schemas.map(([vendor, filetype, downloadConfig]) =>
|
|
pipeline(
|
|
got.stream(...downloadConfig),
|
|
createWriteStream(
|
|
path.resolve(__dirname, '..', 'src', 'vendor', vendor, `schema.${filetype}`),
|
|
),
|
|
),
|
|
),
|
|
).then(() => console.log('done!'));
|