forked from dotansimha/graphql-code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatch-graphql.js
More file actions
25 lines (19 loc) · 886 Bytes
/
match-graphql.js
File metadata and controls
25 lines (19 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const { writeFileSync } = require('fs');
const { resolve } = require('path');
const { argv, cwd } = require('process');
const pkgPath = resolve(cwd(), './package.json');
const pkg = require(pkgPath);
const version = argv[2];
// eslint-disable-next-line logical-assignment-operators -- can be removed after drop support of Node.js 12
pkg.resolutions = pkg.resolutions || {};
if (pkg.resolutions.graphql.startsWith(version)) {
// eslint-disable-next-line no-console
console.info(`GraphQL v${version} is match! Skipping.`);
return;
}
const npmVersion = version.includes('-') ? version : `^${version}`;
pkg.devDependencies.graphql = npmVersion;
pkg.resolutions.graphql = npmVersion;
pkg.resolutions['**/apollo-language-server/graphql'] = npmVersion;
pkg.resolutions['**/@types/graphql-upload/graphql'] = npmVersion;
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf8');