@graphprotocol/graph-cli 0.37.3-alpha-20230111132934-b4190fb → 0.37.3-alpha-20230111134832-100975c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.37.3-alpha-20230111132934-b4190fb
3
+ ## 0.37.3-alpha-20230111134832-100975c
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -26,16 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
29
  const semver_1 = __importDefault(require("semver"));
31
- const toolbox = __importStar(require("gluegun/toolbox"));
32
- const js_yaml_1 = __importDefault(require("js-yaml"));
30
+ const toolbox = __importStar(require("gluegun"));
33
31
  const versions_1 = require("./util/versions");
34
32
  const load_manifest_1 = require("./util/load-manifest");
35
33
  // If any of the manifest apiVersions are 0.0.1, replace them with 0.0.2
36
34
  exports.default = {
37
35
  name: 'Bump mapping apiVersion from 0.0.1 to 0.0.2',
38
- predicate: async ({ sourceDir, manifestFile }) => {
36
+ predicate: async ({ sourceDir, manifestFile, }) => {
39
37
  // Obtain the graph-ts version, if possible
40
38
  let graphTsVersion;
41
39
  try {
@@ -71,8 +69,14 @@ exports.default = {
71
69
  // and replace the values in the data structures here; unfortunately
72
70
  // writing that back to the file messes with the formatting more than
73
71
  // we'd like; that's why for now, we use a simple patching approach
74
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: 0.0.1', 'g'), 'apiVersion: 0.0.2');
75
- await toolbox.patching.replace(manifestFile, new RegExp("apiVersion: '0.0.1'", 'g'), "apiVersion: '0.0.2'");
76
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: "0.0.1"', 'g'), 'apiVersion: "0.0.2"');
72
+ await toolbox.patching.replace(manifestFile,
73
+ // @ts-expect-error toolbox patching seems to accept RegExp
74
+ new RegExp('apiVersion: 0.0.1', 'g'), 'apiVersion: 0.0.2');
75
+ await toolbox.patching.replace(manifestFile,
76
+ // @ts-expect-error toolbox patching seems to accept RegExp
77
+ new RegExp("apiVersion: '0.0.1'", 'g'), "apiVersion: '0.0.2'");
78
+ await toolbox.patching.replace(manifestFile,
79
+ // @ts-expect-error toolbox patching seems to accept RegExp
80
+ new RegExp('apiVersion: "0.0.1"', 'g'), 'apiVersion: "0.0.2"');
77
81
  },
78
82
  };
@@ -27,13 +27,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const semver_1 = __importDefault(require("semver"));
30
- const toolbox = __importStar(require("gluegun/toolbox"));
30
+ const toolbox = __importStar(require("gluegun"));
31
31
  const load_manifest_1 = require("./util/load-manifest");
32
32
  const versions_1 = require("./util/versions");
33
33
  // If any of the manifest apiVersions are 0.0.2, replace them with 0.0.3
34
34
  exports.default = {
35
35
  name: 'Bump mapping apiVersion from 0.0.2 to 0.0.3',
36
- predicate: async ({ sourceDir, manifestFile }) => {
36
+ predicate: async ({ sourceDir, manifestFile, }) => {
37
37
  // Obtain the graph-ts version, if possible
38
38
  let graphTsVersion;
39
39
  try {
@@ -69,8 +69,14 @@ exports.default = {
69
69
  // and replace the values in the data structures here; unfortunately
70
70
  // writing that back to the file messes with the formatting more than
71
71
  // we'd like; that's why for now, we use a simple patching approach
72
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: 0.0.2', 'g'), 'apiVersion: 0.0.3');
73
- await toolbox.patching.replace(manifestFile, new RegExp("apiVersion: '0.0.2'", 'g'), "apiVersion: '0.0.3'");
74
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: "0.0.2"', 'g'), 'apiVersion: "0.0.3"');
72
+ await toolbox.patching.replace(manifestFile,
73
+ // @ts-expect-error toolbox patching seems to accept RegExp
74
+ new RegExp('apiVersion: 0.0.2', 'g'), 'apiVersion: 0.0.3');
75
+ await toolbox.patching.replace(manifestFile,
76
+ // @ts-expect-error toolbox patching seems to accept RegExp
77
+ new RegExp("apiVersion: '0.0.2'", 'g'), "apiVersion: '0.0.3'");
78
+ await toolbox.patching.replace(manifestFile,
79
+ // @ts-expect-error toolbox patching seems to accept RegExp
80
+ new RegExp('apiVersion: "0.0.2"', 'g'), 'apiVersion: "0.0.3"');
75
81
  },
76
82
  };
@@ -26,16 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
29
  const semver_1 = __importDefault(require("semver"));
31
- const toolbox = __importStar(require("gluegun/toolbox"));
32
- const js_yaml_1 = __importDefault(require("js-yaml"));
30
+ const toolbox = __importStar(require("gluegun"));
33
31
  const load_manifest_1 = require("./util/load-manifest");
34
32
  const versions_1 = require("./util/versions");
35
33
  // If any of the manifest apiVersions are 0.0.3, replace them with 0.0.4
36
34
  exports.default = {
37
35
  name: 'Bump mapping apiVersion from 0.0.3 to 0.0.4',
38
- predicate: async ({ sourceDir, manifestFile }) => {
36
+ predicate: async ({ sourceDir, manifestFile, }) => {
39
37
  // Obtain the graph-ts version, if possible
40
38
  let graphTsVersion;
41
39
  try {
@@ -71,8 +69,14 @@ exports.default = {
71
69
  // and replace the values in the data structures here; unfortunately
72
70
  // writing that back to the file messes with the formatting more than
73
71
  // we'd like; that's why for now, we use a simple patching approach
74
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: 0.0.3', 'g'), 'apiVersion: 0.0.4');
75
- await toolbox.patching.replace(manifestFile, new RegExp("apiVersion: '0.0.3'", 'g'), "apiVersion: '0.0.4'");
76
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: "0.0.3"', 'g'), 'apiVersion: "0.0.4"');
72
+ await toolbox.patching.replace(manifestFile,
73
+ // @ts-expect-error toolbox patching seems to accept RegExp
74
+ new RegExp('apiVersion: 0.0.3', 'g'), 'apiVersion: 0.0.4');
75
+ await toolbox.patching.replace(manifestFile,
76
+ // @ts-expect-error toolbox patching seems to accept RegExp
77
+ new RegExp("apiVersion: '0.0.3'", 'g'), "apiVersion: '0.0.4'");
78
+ await toolbox.patching.replace(manifestFile,
79
+ // @ts-expect-error toolbox patching seems to accept RegExp
80
+ new RegExp('apiVersion: "0.0.3"', 'g'), 'apiVersion: "0.0.4"');
77
81
  },
78
82
  };
@@ -26,16 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
29
  const semver_1 = __importDefault(require("semver"));
31
- const toolbox = __importStar(require("gluegun/toolbox"));
32
- const js_yaml_1 = __importDefault(require("js-yaml"));
30
+ const toolbox = __importStar(require("gluegun"));
33
31
  const load_manifest_1 = require("./util/load-manifest");
34
32
  const versions_1 = require("./util/versions");
35
33
  // If any of the manifest apiVersions are 0.0.4, replace them with 0.0.5
36
34
  exports.default = {
37
35
  name: 'Bump mapping apiVersion from 0.0.4 to 0.0.5',
38
- predicate: async ({ sourceDir, manifestFile }) => {
36
+ predicate: async ({ sourceDir, manifestFile, }) => {
39
37
  // Obtain the graph-ts version, if possible
40
38
  let graphTsVersion;
41
39
  try {
@@ -73,8 +71,14 @@ exports.default = {
73
71
  // and replace the values in the data structures here; unfortunately
74
72
  // writing that back to the file messes with the formatting more than
75
73
  // we'd like; that's why for now, we use a simple patching approach
76
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: 0.0.4', 'g'), 'apiVersion: 0.0.5');
77
- await toolbox.patching.replace(manifestFile, new RegExp("apiVersion: '0.0.4'", 'g'), "apiVersion: '0.0.5'");
78
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: "0.0.4"', 'g'), 'apiVersion: "0.0.5"');
74
+ await toolbox.patching.replace(manifestFile,
75
+ // @ts-expect-error toolbox patching seems to accept RegExp
76
+ new RegExp('apiVersion: 0.0.4', 'g'), 'apiVersion: 0.0.5');
77
+ await toolbox.patching.replace(manifestFile,
78
+ // @ts-expect-error toolbox patching seems to accept RegExp
79
+ new RegExp("apiVersion: '0.0.4'", 'g'), "apiVersion: '0.0.5'");
80
+ await toolbox.patching.replace(manifestFile,
81
+ // @ts-expect-error toolbox patching seems to accept RegExp
82
+ new RegExp('apiVersion: "0.0.4"', 'g'), 'apiVersion: "0.0.5"');
79
83
  },
80
84
  };
@@ -26,16 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
29
  const semver_1 = __importDefault(require("semver"));
31
- const toolbox = __importStar(require("gluegun/toolbox"));
32
- const js_yaml_1 = __importDefault(require("js-yaml"));
30
+ const toolbox = __importStar(require("gluegun"));
33
31
  const load_manifest_1 = require("./util/load-manifest");
34
32
  const versions_1 = require("./util/versions");
35
33
  // If any of the manifest apiVersions are 0.0.5, replace them with 0.0.6
36
34
  exports.default = {
37
35
  name: 'Bump mapping apiVersion from 0.0.5 to 0.0.6',
38
- predicate: async ({ sourceDir, manifestFile }) => {
36
+ predicate: async ({ sourceDir, manifestFile, }) => {
39
37
  // Obtain the graph-ts version, if possible
40
38
  let graphTsVersion;
41
39
  try {
@@ -73,8 +71,14 @@ exports.default = {
73
71
  // and replace the values in the data structures here; unfortunately
74
72
  // writing that back to the file messes with the formatting more than
75
73
  // we'd like; that's why for now, we use a simple patching approach
76
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: 0.0.5', 'g'), 'apiVersion: 0.0.6');
77
- await toolbox.patching.replace(manifestFile, new RegExp("apiVersion: '0.0.5'", 'g'), "apiVersion: '0.0.6'");
78
- await toolbox.patching.replace(manifestFile, new RegExp('apiVersion: "0.0.5"', 'g'), 'apiVersion: "0.0.6"');
74
+ await toolbox.patching.replace(manifestFile,
75
+ // @ts-expect-error toolbox patching seems to accept RegExp
76
+ new RegExp('apiVersion: 0.0.5', 'g'), 'apiVersion: 0.0.6');
77
+ await toolbox.patching.replace(manifestFile,
78
+ // @ts-expect-error toolbox patching seems to accept RegExp
79
+ new RegExp("apiVersion: '0.0.5'", 'g'), "apiVersion: '0.0.6'");
80
+ await toolbox.patching.replace(manifestFile,
81
+ // @ts-expect-error toolbox patching seems to accept RegExp
82
+ new RegExp('apiVersion: "0.0.5"', 'g'), 'apiVersion: "0.0.6"');
79
83
  },
80
84
  };
@@ -22,19 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
- const toolbox = __importStar(require("gluegun/toolbox"));
31
- const js_yaml_1 = __importDefault(require("js-yaml"));
26
+ const toolbox = __importStar(require("gluegun"));
32
27
  const load_manifest_1 = require("./util/load-manifest");
33
28
  // Spec version to 0.0.2 uses top level templates. graph-cli no longer supports
34
29
  // 0.0.1 which used nested templates.
35
30
  exports.default = {
36
31
  name: 'Bump manifest specVersion from 0.0.1 to 0.0.2',
37
- predicate: async ({ sourceDir, manifestFile }) => {
32
+ predicate: async ({ manifestFile }) => {
38
33
  let manifest = await (0, load_manifest_1.loadManifest)(manifestFile);
39
34
  return (manifest &&
40
35
  typeof manifest === 'object' &&
@@ -22,13 +22,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
- const toolbox = __importStar(require("gluegun/toolbox"));
31
- const js_yaml_1 = __importDefault(require("js-yaml"));
26
+ const toolbox = __importStar(require("gluegun"));
32
27
  const load_manifest_1 = require("./util/load-manifest");
33
28
  // Spec version 0.0.4 uses feature management, but features are
34
29
  // detected and validated by the graph-node instance during subgraph
@@ -38,7 +33,7 @@ const load_manifest_1 = require("./util/load-manifest");
38
33
  // non-canonical.
39
34
  exports.default = {
40
35
  name: 'Bump manifest specVersion from 0.0.2 to 0.0.4',
41
- predicate: async ({ sourceDir, manifestFile }) => {
36
+ predicate: async ({ manifestFile }) => {
42
37
  let manifest = await (0, load_manifest_1.loadManifest)(manifestFile);
43
38
  return (manifest &&
44
39
  typeof manifest === 'object' &&
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getGraphTsVersion = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const js_yaml_1 = __importDefault(require("js-yaml"));
10
- const getGraphTsVersion = async (sourceDir) => {
9
+ async function getGraphTsVersion(sourceDir) {
11
10
  let graphTsPath;
12
11
  for (let dir = path_1.default.resolve(sourceDir);
13
12
  // Terminate after the root dir or when we have found node_modules
@@ -23,7 +22,7 @@ const getGraphTsVersion = async (sourceDir) => {
23
22
  }
24
23
  let pkgJsonFile = path_1.default.join(graphTsPath, 'package.json');
25
24
  let data = await fs_extra_1.default.readFile(pkgJsonFile);
26
- let jsonData = JSON.parse(data);
25
+ let jsonData = JSON.parse(data.toString());
27
26
  return jsonData.version;
28
- };
27
+ }
29
28
  exports.getGraphTsVersion = getGraphTsVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphprotocol/graph-cli",
3
- "version": "0.37.3-alpha-20230111132934-b4190fb",
3
+ "version": "0.37.3-alpha-20230111134832-100975c",
4
4
  "license": "(Apache-2.0 OR MIT)",
5
5
  "description": "CLI for building for and deploying to The Graph",
6
6
  "main": "dist/cli.js",
@@ -40,6 +40,7 @@
40
40
  "@types/fs-extra": "^9.0.13",
41
41
  "@types/jest": "^26.0.24",
42
42
  "@types/js-yaml": "^3.12.7",
43
+ "@types/semver": "^7.3.13",
43
44
  "@types/which": "^2.0.1",
44
45
  "copyfiles": "^2.4.1",
45
46
  "jest": "26.0.0",
@@ -1,14 +1,18 @@
1
- import fs from 'fs-extra'
2
1
  import semver from 'semver'
3
- import * as toolbox from 'gluegun/toolbox'
4
- import yaml from 'js-yaml'
2
+ import * as toolbox from 'gluegun'
5
3
  import { getGraphTsVersion } from './util/versions'
6
4
  import { loadManifest } from './util/load-manifest'
7
5
 
8
6
  // If any of the manifest apiVersions are 0.0.1, replace them with 0.0.2
9
7
  export default {
10
8
  name: 'Bump mapping apiVersion from 0.0.1 to 0.0.2',
11
- predicate: async ({ sourceDir, manifestFile }) => {
9
+ predicate: async ({
10
+ sourceDir,
11
+ manifestFile,
12
+ }: {
13
+ sourceDir: string
14
+ manifestFile: string
15
+ }) => {
12
16
  // Obtain the graph-ts version, if possible
13
17
  let graphTsVersion
14
18
  try {
@@ -28,7 +32,7 @@ export default {
28
32
  typeof manifest === 'object' &&
29
33
  Array.isArray(manifest.dataSources) &&
30
34
  (manifest.dataSources.reduce(
31
- (hasOldMappings, dataSource) =>
35
+ (hasOldMappings: boolean, dataSource: any) =>
32
36
  hasOldMappings ||
33
37
  (typeof dataSource === 'object' &&
34
38
  dataSource.mapping &&
@@ -38,7 +42,7 @@ export default {
38
42
  ) ||
39
43
  (Array.isArray(manifest.templates) &&
40
44
  manifest.templates.reduce(
41
- (hasOldMappings, template) =>
45
+ (hasOldMappings: boolean, template: any) =>
42
46
  hasOldMappings ||
43
47
  (typeof template === 'object' &&
44
48
  template.mapping &&
@@ -48,23 +52,26 @@ export default {
48
52
  )))
49
53
  )
50
54
  },
51
- apply: async ({ manifestFile }) => {
55
+ apply: async ({ manifestFile }: { manifestFile: string }) => {
52
56
  // Make sure we catch all variants; we could load the manifest
53
57
  // and replace the values in the data structures here; unfortunately
54
58
  // writing that back to the file messes with the formatting more than
55
59
  // we'd like; that's why for now, we use a simple patching approach
56
60
  await toolbox.patching.replace(
57
61
  manifestFile,
62
+ // @ts-expect-error toolbox patching seems to accept RegExp
58
63
  new RegExp('apiVersion: 0.0.1', 'g'),
59
64
  'apiVersion: 0.0.2',
60
65
  )
61
66
  await toolbox.patching.replace(
62
67
  manifestFile,
68
+ // @ts-expect-error toolbox patching seems to accept RegExp
63
69
  new RegExp("apiVersion: '0.0.1'", 'g'),
64
70
  "apiVersion: '0.0.2'",
65
71
  )
66
72
  await toolbox.patching.replace(
67
73
  manifestFile,
74
+ // @ts-expect-error toolbox patching seems to accept RegExp
68
75
  new RegExp('apiVersion: "0.0.1"', 'g'),
69
76
  'apiVersion: "0.0.2"',
70
77
  )
@@ -1,12 +1,18 @@
1
1
  import semver from 'semver'
2
- import * as toolbox from 'gluegun/toolbox'
2
+ import * as toolbox from 'gluegun'
3
3
  import { loadManifest } from './util/load-manifest'
4
4
  import { getGraphTsVersion } from './util/versions'
5
5
 
6
6
  // If any of the manifest apiVersions are 0.0.2, replace them with 0.0.3
7
7
  export default {
8
8
  name: 'Bump mapping apiVersion from 0.0.2 to 0.0.3',
9
- predicate: async ({ sourceDir, manifestFile }) => {
9
+ predicate: async ({
10
+ sourceDir,
11
+ manifestFile,
12
+ }: {
13
+ sourceDir: string
14
+ manifestFile: string
15
+ }) => {
10
16
  // Obtain the graph-ts version, if possible
11
17
  let graphTsVersion
12
18
  try {
@@ -26,7 +32,7 @@ export default {
26
32
  typeof manifest === 'object' &&
27
33
  Array.isArray(manifest.dataSources) &&
28
34
  (manifest.dataSources.reduce(
29
- (hasOldMappings, dataSource) =>
35
+ (hasOldMappings: boolean, dataSource: any) =>
30
36
  hasOldMappings ||
31
37
  (typeof dataSource === 'object' &&
32
38
  dataSource.mapping &&
@@ -36,7 +42,7 @@ export default {
36
42
  ) ||
37
43
  (Array.isArray(manifest.templates) &&
38
44
  manifest.templates.reduce(
39
- (hasOldMappings, template) =>
45
+ (hasOldMappings: boolean, template: any) =>
40
46
  hasOldMappings ||
41
47
  (typeof template === 'object' &&
42
48
  template.mapping &&
@@ -46,23 +52,26 @@ export default {
46
52
  )))
47
53
  )
48
54
  },
49
- apply: async ({ manifestFile }) => {
55
+ apply: async ({ manifestFile }: { manifestFile: string }) => {
50
56
  // Make sure we catch all variants; we could load the manifest
51
57
  // and replace the values in the data structures here; unfortunately
52
58
  // writing that back to the file messes with the formatting more than
53
59
  // we'd like; that's why for now, we use a simple patching approach
54
60
  await toolbox.patching.replace(
55
61
  manifestFile,
62
+ // @ts-expect-error toolbox patching seems to accept RegExp
56
63
  new RegExp('apiVersion: 0.0.2', 'g'),
57
64
  'apiVersion: 0.0.3',
58
65
  )
59
66
  await toolbox.patching.replace(
60
67
  manifestFile,
68
+ // @ts-expect-error toolbox patching seems to accept RegExp
61
69
  new RegExp("apiVersion: '0.0.2'", 'g'),
62
70
  "apiVersion: '0.0.3'",
63
71
  )
64
72
  await toolbox.patching.replace(
65
73
  manifestFile,
74
+ // @ts-expect-error toolbox patching seems to accept RegExp
66
75
  new RegExp('apiVersion: "0.0.2"', 'g'),
67
76
  'apiVersion: "0.0.3"',
68
77
  )
@@ -1,14 +1,18 @@
1
- import fs from 'fs-extra'
2
1
  import semver from 'semver'
3
- import * as toolbox from 'gluegun/toolbox'
4
- import yaml from 'js-yaml'
2
+ import * as toolbox from 'gluegun'
5
3
  import { loadManifest } from './util/load-manifest'
6
4
  import { getGraphTsVersion } from './util/versions'
7
5
 
8
6
  // If any of the manifest apiVersions are 0.0.3, replace them with 0.0.4
9
7
  export default {
10
8
  name: 'Bump mapping apiVersion from 0.0.3 to 0.0.4',
11
- predicate: async ({ sourceDir, manifestFile }) => {
9
+ predicate: async ({
10
+ sourceDir,
11
+ manifestFile,
12
+ }: {
13
+ sourceDir: string
14
+ manifestFile: string
15
+ }) => {
12
16
  // Obtain the graph-ts version, if possible
13
17
  let graphTsVersion
14
18
  try {
@@ -28,7 +32,7 @@ export default {
28
32
  typeof manifest === 'object' &&
29
33
  Array.isArray(manifest.dataSources) &&
30
34
  (manifest.dataSources.reduce(
31
- (hasOldMappings, dataSource) =>
35
+ (hasOldMappings: boolean, dataSource: any) =>
32
36
  hasOldMappings ||
33
37
  (typeof dataSource === 'object' &&
34
38
  dataSource.mapping &&
@@ -38,7 +42,7 @@ export default {
38
42
  ) ||
39
43
  (Array.isArray(manifest.templates) &&
40
44
  manifest.templates.reduce(
41
- (hasOldMappings, template) =>
45
+ (hasOldMappings: boolean, template: any) =>
42
46
  hasOldMappings ||
43
47
  (typeof template === 'object' &&
44
48
  template.mapping &&
@@ -48,23 +52,26 @@ export default {
48
52
  )))
49
53
  )
50
54
  },
51
- apply: async ({ manifestFile }) => {
55
+ apply: async ({ manifestFile }: { manifestFile: string }) => {
52
56
  // Make sure we catch all variants; we could load the manifest
53
57
  // and replace the values in the data structures here; unfortunately
54
58
  // writing that back to the file messes with the formatting more than
55
59
  // we'd like; that's why for now, we use a simple patching approach
56
60
  await toolbox.patching.replace(
57
61
  manifestFile,
62
+ // @ts-expect-error toolbox patching seems to accept RegExp
58
63
  new RegExp('apiVersion: 0.0.3', 'g'),
59
64
  'apiVersion: 0.0.4',
60
65
  )
61
66
  await toolbox.patching.replace(
62
67
  manifestFile,
68
+ // @ts-expect-error toolbox patching seems to accept RegExp
63
69
  new RegExp("apiVersion: '0.0.3'", 'g'),
64
70
  "apiVersion: '0.0.4'",
65
71
  )
66
72
  await toolbox.patching.replace(
67
73
  manifestFile,
74
+ // @ts-expect-error toolbox patching seems to accept RegExp
68
75
  new RegExp('apiVersion: "0.0.3"', 'g'),
69
76
  'apiVersion: "0.0.4"',
70
77
  )
@@ -1,14 +1,18 @@
1
- import fs from 'fs-extra'
2
1
  import semver from 'semver'
3
- import * as toolbox from 'gluegun/toolbox'
4
- import yaml from 'js-yaml'
2
+ import * as toolbox from 'gluegun'
5
3
  import { loadManifest } from './util/load-manifest'
6
4
  import { getGraphTsVersion } from './util/versions'
7
5
 
8
6
  // If any of the manifest apiVersions are 0.0.4, replace them with 0.0.5
9
7
  export default {
10
8
  name: 'Bump mapping apiVersion from 0.0.4 to 0.0.5',
11
- predicate: async ({ sourceDir, manifestFile }) => {
9
+ predicate: async ({
10
+ sourceDir,
11
+ manifestFile,
12
+ }: {
13
+ sourceDir: string
14
+ manifestFile: string
15
+ }) => {
12
16
  // Obtain the graph-ts version, if possible
13
17
  let graphTsVersion
14
18
  try {
@@ -24,13 +28,13 @@ export default {
24
28
  // Only migrate if the graph-ts version is >= 0.22.0...
25
29
  // Coerce needed because we may be dealing with an alpha version
26
30
  // and in the `semver` library this would not return true on equality.
27
- semver.gte(semver.coerce(graphTsVersion), '0.22.0') &&
31
+ semver.gte(semver.coerce(graphTsVersion)!, '0.22.0') &&
28
32
  // ...and we have a manifest with mapping > apiVersion = 0.0.4
29
33
  manifest &&
30
34
  typeof manifest === 'object' &&
31
35
  Array.isArray(manifest.dataSources) &&
32
36
  (manifest.dataSources.reduce(
33
- (hasOldMappings, dataSource) =>
37
+ (hasOldMappings: boolean, dataSource: any) =>
34
38
  hasOldMappings ||
35
39
  (typeof dataSource === 'object' &&
36
40
  dataSource.mapping &&
@@ -40,7 +44,7 @@ export default {
40
44
  ) ||
41
45
  (Array.isArray(manifest.templates) &&
42
46
  manifest.templates.reduce(
43
- (hasOldMappings, template) =>
47
+ (hasOldMappings: boolean, template: any) =>
44
48
  hasOldMappings ||
45
49
  (typeof template === 'object' &&
46
50
  template.mapping &&
@@ -50,23 +54,26 @@ export default {
50
54
  )))
51
55
  )
52
56
  },
53
- apply: async ({ manifestFile }) => {
57
+ apply: async ({ manifestFile }: { manifestFile: string }) => {
54
58
  // Make sure we catch all variants; we could load the manifest
55
59
  // and replace the values in the data structures here; unfortunately
56
60
  // writing that back to the file messes with the formatting more than
57
61
  // we'd like; that's why for now, we use a simple patching approach
58
62
  await toolbox.patching.replace(
59
63
  manifestFile,
64
+ // @ts-expect-error toolbox patching seems to accept RegExp
60
65
  new RegExp('apiVersion: 0.0.4', 'g'),
61
66
  'apiVersion: 0.0.5',
62
67
  )
63
68
  await toolbox.patching.replace(
64
69
  manifestFile,
70
+ // @ts-expect-error toolbox patching seems to accept RegExp
65
71
  new RegExp("apiVersion: '0.0.4'", 'g'),
66
72
  "apiVersion: '0.0.5'",
67
73
  )
68
74
  await toolbox.patching.replace(
69
75
  manifestFile,
76
+ // @ts-expect-error toolbox patching seems to accept RegExp
70
77
  new RegExp('apiVersion: "0.0.4"', 'g'),
71
78
  'apiVersion: "0.0.5"',
72
79
  )
@@ -1,14 +1,18 @@
1
- import fs from 'fs-extra'
2
1
  import semver from 'semver'
3
- import * as toolbox from 'gluegun/toolbox'
4
- import yaml from 'js-yaml'
2
+ import * as toolbox from 'gluegun'
5
3
  import { loadManifest } from './util/load-manifest'
6
4
  import { getGraphTsVersion } from './util/versions'
7
5
 
8
6
  // If any of the manifest apiVersions are 0.0.5, replace them with 0.0.6
9
7
  export default {
10
8
  name: 'Bump mapping apiVersion from 0.0.5 to 0.0.6',
11
- predicate: async ({ sourceDir, manifestFile }) => {
9
+ predicate: async ({
10
+ sourceDir,
11
+ manifestFile,
12
+ }: {
13
+ sourceDir: string
14
+ manifestFile: string
15
+ }) => {
12
16
  // Obtain the graph-ts version, if possible
13
17
  let graphTsVersion
14
18
  try {
@@ -24,13 +28,13 @@ export default {
24
28
  // Only migrate if the graph-ts version is >= 0.24.0...
25
29
  // Coerce needed because we may be dealing with an alpha version
26
30
  // and in the `semver` library this would not return true on equality.
27
- semver.gte(semver.coerce(graphTsVersion), '0.24.0') &&
31
+ semver.gte(semver.coerce(graphTsVersion)!, '0.24.0') &&
28
32
  // ...and we have a manifest with mapping > apiVersion = 0.0.5
29
33
  manifest &&
30
34
  typeof manifest === 'object' &&
31
35
  Array.isArray(manifest.dataSources) &&
32
36
  (manifest.dataSources.reduce(
33
- (hasOldMappings, dataSource) =>
37
+ (hasOldMappings: boolean, dataSource: any) =>
34
38
  hasOldMappings ||
35
39
  (typeof dataSource === 'object' &&
36
40
  dataSource.mapping &&
@@ -40,7 +44,7 @@ export default {
40
44
  ) ||
41
45
  (Array.isArray(manifest.templates) &&
42
46
  manifest.templates.reduce(
43
- (hasOldMappings, template) =>
47
+ (hasOldMappings: boolean, template: any) =>
44
48
  hasOldMappings ||
45
49
  (typeof template === 'object' &&
46
50
  template.mapping &&
@@ -50,23 +54,26 @@ export default {
50
54
  )))
51
55
  )
52
56
  },
53
- apply: async ({ manifestFile }) => {
57
+ apply: async ({ manifestFile }: { manifestFile: string }) => {
54
58
  // Make sure we catch all variants; we could load the manifest
55
59
  // and replace the values in the data structures here; unfortunately
56
60
  // writing that back to the file messes with the formatting more than
57
61
  // we'd like; that's why for now, we use a simple patching approach
58
62
  await toolbox.patching.replace(
59
63
  manifestFile,
64
+ // @ts-expect-error toolbox patching seems to accept RegExp
60
65
  new RegExp('apiVersion: 0.0.5', 'g'),
61
66
  'apiVersion: 0.0.6',
62
67
  )
63
68
  await toolbox.patching.replace(
64
69
  manifestFile,
70
+ // @ts-expect-error toolbox patching seems to accept RegExp
65
71
  new RegExp("apiVersion: '0.0.5'", 'g'),
66
72
  "apiVersion: '0.0.6'",
67
73
  )
68
74
  await toolbox.patching.replace(
69
75
  manifestFile,
76
+ // @ts-expect-error toolbox patching seems to accept RegExp
70
77
  new RegExp('apiVersion: "0.0.5"', 'g'),
71
78
  'apiVersion: "0.0.6"',
72
79
  )
@@ -1,13 +1,11 @@
1
- import fs from 'fs-extra'
2
- import * as toolbox from 'gluegun/toolbox'
3
- import yaml from 'js-yaml'
1
+ import * as toolbox from 'gluegun'
4
2
  import { loadManifest } from './util/load-manifest'
5
3
 
6
4
  // Spec version to 0.0.2 uses top level templates. graph-cli no longer supports
7
5
  // 0.0.1 which used nested templates.
8
6
  export default {
9
7
  name: 'Bump manifest specVersion from 0.0.1 to 0.0.2',
10
- predicate: async ({ sourceDir, manifestFile }) => {
8
+ predicate: async ({ manifestFile }: { manifestFile: string }) => {
11
9
  let manifest = await loadManifest(manifestFile)
12
10
  return (
13
11
  manifest &&
@@ -16,7 +14,7 @@ export default {
16
14
  manifest.specVersion === '0.0.1'
17
15
  )
18
16
  },
19
- apply: async ({ manifestFile }) => {
17
+ apply: async ({ manifestFile }: { manifestFile: string }) => {
20
18
  await toolbox.patching.replace(
21
19
  manifestFile,
22
20
  'specVersion: 0.0.1',
@@ -1,6 +1,4 @@
1
- import fs from 'fs-extra'
2
- import * as toolbox from 'gluegun/toolbox'
3
- import yaml from 'js-yaml'
1
+ import * as toolbox from 'gluegun'
4
2
  import { loadManifest } from './util/load-manifest'
5
3
 
6
4
  // Spec version 0.0.4 uses feature management, but features are
@@ -11,7 +9,7 @@ import { loadManifest } from './util/load-manifest'
11
9
  // non-canonical.
12
10
  export default {
13
11
  name: 'Bump manifest specVersion from 0.0.2 to 0.0.4',
14
- predicate: async ({ sourceDir, manifestFile }) => {
12
+ predicate: async ({ manifestFile }: { manifestFile: string }) => {
15
13
  let manifest = await loadManifest(manifestFile)
16
14
  return (
17
15
  manifest &&
@@ -20,7 +18,7 @@ export default {
20
18
  (manifest.specVersion === '0.0.2' || manifest.specVersion === '0.0.3')
21
19
  )
22
20
  },
23
- apply: async ({ manifestFile }) => {
21
+ apply: async ({ manifestFile }: { manifestFile: string }) => {
24
22
  await toolbox.patching.patch(manifestFile, {
25
23
  insert: 'specVersion: 0.0.4',
26
24
  replace: new RegExp(`specVersion: ['"]?0.0.[23]['"]?`),
@@ -2,12 +2,10 @@ import fs from 'fs-extra'
2
2
  import path from 'path'
3
3
  import yaml from 'js-yaml'
4
4
 
5
- async function loadManifest(manifestFile) {
5
+ export async function loadManifest(manifestFile: string) {
6
6
  if (manifestFile.match(/.js$/)) {
7
7
  return require(path.resolve(manifestFile))
8
8
  } else {
9
9
  return yaml.safeLoad(await fs.readFile(manifestFile, 'utf-8'))
10
10
  }
11
11
  }
12
-
13
- export { loadManifest }
@@ -1,12 +1,11 @@
1
1
  import path from 'path'
2
2
  import fs from 'fs-extra'
3
- import yaml from 'js-yaml'
4
3
 
5
- const getGraphTsVersion = async sourceDir => {
6
- let graphTsPath
4
+ export async function getGraphTsVersion(sourceDir: string) {
5
+ let graphTsPath!: string
7
6
 
8
7
  for (
9
- let dir = path.resolve(sourceDir);
8
+ let dir: string | undefined = path.resolve(sourceDir);
10
9
  // Terminate after the root dir or when we have found node_modules
11
10
  dir !== undefined;
12
11
  // Continue with the parent directory, terminate after the root dir
@@ -28,8 +27,6 @@ const getGraphTsVersion = async sourceDir => {
28
27
 
29
28
  let pkgJsonFile = path.join(graphTsPath, 'package.json')
30
29
  let data = await fs.readFile(pkgJsonFile)
31
- let jsonData = JSON.parse(data)
30
+ let jsonData = JSON.parse(data.toString())
32
31
  return jsonData.version
33
32
  }
34
-
35
- export { getGraphTsVersion }