@graphprotocol/graph-cli 0.37.3-alpha-20230113140726-64762bb → 0.37.3-alpha-20230113140856-3e7bd95

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/cli.js +2 -2
  3. package/dist/command-helpers/auth.js +7 -7
  4. package/dist/command-helpers/compiler.js +2 -2
  5. package/dist/command-helpers/fs.js +2 -2
  6. package/dist/command-helpers/network.js +2 -2
  7. package/dist/command-helpers/network.test.js +2 -2
  8. package/dist/command-helpers/node.js +3 -3
  9. package/dist/command-helpers/scaffold.js +3 -3
  10. package/dist/commands/codegen.js +2 -2
  11. package/dist/commands/create.js +2 -2
  12. package/dist/commands/deploy.js +4 -4
  13. package/dist/commands/init.js +13 -13
  14. package/dist/commands/local.js +17 -17
  15. package/dist/commands/remove.js +2 -2
  16. package/dist/commands/test.js +14 -14
  17. package/dist/compiler/index.js +47 -47
  18. package/dist/migrations/util/load-manifest.js +2 -2
  19. package/dist/migrations/util/versions.js +5 -5
  20. package/dist/protocols/ethereum/abi.js +2 -2
  21. package/dist/protocols/ethereum/codegen/abi.js +3 -3
  22. package/dist/protocols/ethereum/codegen/abi.test.js +2 -2
  23. package/dist/protocols/ethereum/type-generator.js +7 -7
  24. package/dist/subgraph.js +7 -7
  25. package/dist/type-generator.js +10 -10
  26. package/dist/validation/manifest.js +4 -4
  27. package/dist/validation/schema.js +2 -2
  28. package/dist/watcher.js +2 -2
  29. package/package.json +1 -1
  30. package/src/cli.ts +1 -1
  31. package/src/command-helpers/auth.ts +3 -3
  32. package/src/command-helpers/compiler.ts +1 -1
  33. package/src/command-helpers/fs.ts +1 -1
  34. package/src/command-helpers/network.test.ts +1 -1
  35. package/src/command-helpers/network.ts +1 -1
  36. package/src/command-helpers/node.ts +1 -1
  37. package/src/command-helpers/scaffold.ts +1 -1
  38. package/src/commands/codegen.ts +1 -1
  39. package/src/commands/create.ts +1 -1
  40. package/src/commands/deploy.ts +2 -2
  41. package/src/commands/init.ts +3 -3
  42. package/src/commands/local.ts +4 -4
  43. package/src/commands/remove.ts +1 -1
  44. package/src/commands/test.ts +3 -3
  45. package/src/compiler/index.ts +2 -2
  46. package/src/migrations/util/load-manifest.ts +1 -1
  47. package/src/migrations/util/versions.ts +1 -1
  48. package/src/protocols/ethereum/abi.ts +1 -1
  49. package/src/protocols/ethereum/codegen/abi.test.ts +1 -1
  50. package/src/protocols/ethereum/codegen/abi.ts +1 -1
  51. package/src/protocols/ethereum/type-generator.ts +1 -1
  52. package/src/subgraph.ts +1 -1
  53. package/src/type-generator.ts +1 -1
  54. package/src/validation/manifest.ts +2 -2
  55. package/src/validation/schema.ts +1 -1
  56. package/src/watcher.ts +1 -1
  57. package/tests/cli/init.test.ts +1 -1
  58. package/tests/cli/spawn-command.d.ts +1 -1
  59. package/tests/cli/util.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @graphprotocol/graph-cli
2
2
 
3
- ## 0.37.3-alpha-20230113140726-64762bb
3
+ ## 0.37.3-alpha-20230113140856-3e7bd95
4
4
 
5
5
  ### Patch Changes
6
6
 
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.run = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
7
+ const path_1 = __importDefault(require("path"));
8
8
  const gluegun_1 = require("gluegun");
9
9
  const run = async (argv) => {
10
10
  let builder = (0, gluegun_1.build)().brand('graph').src(__dirname);
@@ -19,7 +19,7 @@ const run = async (argv) => {
19
19
  }
20
20
  }));
21
21
  // Inject potential plugin directories
22
- builder = pluginDirs.reduce((cli, dir) => cli.plugin(node_path_1.default.join(dir, '@graphprotocol', 'indexer-cli', 'dist')), builder);
22
+ builder = pluginDirs.reduce((cli, dir) => cli.plugin(path_1.default.join(dir, '@graphprotocol', 'indexer-cli', 'dist')), builder);
23
23
  const cli = builder.help().version().defaultCommand().create();
24
24
  return await cli.run(argv);
25
25
  };
@@ -27,17 +27,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.saveDeployKey = exports.identifyDeployKey = void 0;
30
- const node_fs_1 = __importDefault(require("node:fs"));
31
- const node_os_1 = __importDefault(require("node:os"));
32
- const node_path_1 = __importDefault(require("node:path"));
30
+ const fs_1 = __importDefault(require("fs"));
31
+ const os_1 = __importDefault(require("os"));
32
+ const path_1 = __importDefault(require("path"));
33
33
  const toolbox = __importStar(require("gluegun"));
34
34
  const node_1 = require("./node");
35
- const homedir = node_os_1.default.homedir();
36
- const CONFIG_PATH = node_path_1.default.join(homedir, '/.graph-cli.json');
35
+ const homedir = os_1.default.homedir();
36
+ const CONFIG_PATH = path_1.default.join(homedir, '/.graph-cli.json');
37
37
  const getConfig = () => {
38
38
  let config;
39
39
  try {
40
- config = JSON.parse(node_fs_1.default.readFileSync(CONFIG_PATH).toString());
40
+ config = JSON.parse(fs_1.default.readFileSync(CONFIG_PATH).toString());
41
41
  }
42
42
  catch {
43
43
  config = {};
@@ -67,7 +67,7 @@ const saveDeployKey = async (node, deployKey) => {
67
67
  node = (0, node_1.normalizeNodeUrl)(node);
68
68
  const config = getConfig();
69
69
  config[node] = deployKey;
70
- node_fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify(config));
70
+ fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify(config));
71
71
  }
72
72
  catch (e) {
73
73
  throw new Error(`Error storing deploy key: ${e.message}`);
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.createCompiler = void 0;
30
- const node_url_1 = require("node:url");
30
+ const url_1 = require("url");
31
31
  const toolbox = __importStar(require("gluegun"));
32
32
  const ipfs_http_client_1 = __importDefault(require("ipfs-http-client"));
33
33
  const compiler_1 = __importDefault(require("../compiler"));
@@ -36,7 +36,7 @@ function createCompiler(manifest, { ipfs, headers, outputDir, outputFormat, skip
36
36
  // Parse the IPFS URL
37
37
  let url;
38
38
  try {
39
- url = ipfs ? new node_url_1.URL(ipfs) : undefined;
39
+ url = ipfs ? new url_1.URL(ipfs) : undefined;
40
40
  }
41
41
  catch (e) {
42
42
  toolbox.print.error(`Invalid IPFS URL: ${ipfs}
@@ -4,6 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.displayPath = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const displayPath = (p) => node_path_1.default.relative(process.cwd(), p);
7
+ const path_1 = __importDefault(require("path"));
8
+ const displayPath = (p) => path_1.default.relative(process.cwd(), p);
9
9
  exports.displayPath = displayPath;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.updateNetworksFile = exports.initNetworksConfig = exports.updateSubgraphNetwork = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
7
+ const path_1 = __importDefault(require("path"));
8
8
  const yaml_1 = __importDefault(require("yaml"));
9
9
  const spinner_1 = require("./spinner");
10
10
  const updateSubgraphNetwork = async (toolbox, manifest, network, networksFile, identifierName) => await (0, spinner_1.withSpinner)(`Update sources network`, `Failed to update sources network`, `Warnings while updating sources network`, async (spinner) => {
@@ -52,7 +52,7 @@ const updateSubgraphNetwork = async (toolbox, manifest, network, networksFile, i
52
52
  });
53
53
  exports.updateSubgraphNetwork = updateSubgraphNetwork;
54
54
  const initNetworksConfig = async (toolbox, directory, identifierName) => await (0, spinner_1.withSpinner)(`Initialize networks config`, `Failed to initialize networks config`, `Warnings while initializing networks config`, async () => {
55
- const subgraphStr = toolbox.filesystem.read(node_path_1.default.join(directory, 'subgraph.yaml'));
55
+ const subgraphStr = toolbox.filesystem.read(path_1.default.join(directory, 'subgraph.yaml'));
56
56
  const subgraph = yaml_1.default.parse(subgraphStr);
57
57
  const networks = subgraph.dataSources.reduce((acc, source) => Object.assign(acc, {
58
58
  [source.network]: {
@@ -26,11 +26,11 @@ 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 node_path_1 = __importDefault(require("node:path"));
29
+ const path_1 = __importDefault(require("path"));
30
30
  const toolbox = __importStar(require("gluegun"));
31
31
  const yaml_1 = __importDefault(require("yaml"));
32
32
  const network_1 = require("./network");
33
- const SUBGRAPH_PATH_BASE = node_path_1.default.join(__dirname, '..', '..', '..', '..', 'examples', 'example-subgraph');
33
+ const SUBGRAPH_PATH_BASE = path_1.default.join(__dirname, '..', '..', '..', '..', 'examples', 'example-subgraph');
34
34
  describe('initNetworksConfig', () => {
35
35
  beforeAll(async () => {
36
36
  await (0, network_1.initNetworksConfig)(toolbox, SUBGRAPH_PATH_BASE, 'address');
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.chooseNodeUrl = exports.normalizeNodeUrl = exports.validateNodeUrl = void 0;
4
- const node_url_1 = require("node:url");
4
+ const url_1 = require("url");
5
5
  const gluegun_1 = require("gluegun");
6
6
  const SUBGRAPH_STUDIO_URL = 'https://api.studio.thegraph.com/deploy/';
7
7
  const HOSTED_SERVICE_URL = 'https://api.thegraph.com/deploy/';
8
- const validateNodeUrl = (node) => new node_url_1.URL(node);
8
+ const validateNodeUrl = (node) => new url_1.URL(node);
9
9
  exports.validateNodeUrl = validateNodeUrl;
10
- const normalizeNodeUrl = (node) => new node_url_1.URL(node).toString();
10
+ const normalizeNodeUrl = (node) => new url_1.URL(node).toString();
11
11
  exports.normalizeNodeUrl = normalizeNodeUrl;
12
12
  function chooseNodeUrl({ product, studio, node, allowSimpleName, }) {
13
13
  if (node) {
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writeTestsFiles = exports.writeMapping = exports.writeSchema = exports.writeABI = exports.writeScaffold = exports.generateScaffold = exports.generateDataSource = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
7
+ const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const gluegun_1 = require("gluegun");
10
10
  const immutable_1 = require("immutable");
@@ -44,7 +44,7 @@ const writeScaffoldDirectory = async (scaffold, directory, spinner) => {
44
44
  await fs_extra_1.default.mkdirs(directory);
45
45
  const promises = Object.keys(scaffold).map(async (basename) => {
46
46
  const content = scaffold[basename];
47
- const filename = node_path_1.default.join(directory, basename);
47
+ const filename = path_1.default.join(directory, basename);
48
48
  // Write file or recurse into subdirectory
49
49
  if (typeof content === 'string') {
50
50
  await fs_extra_1.default.writeFile(filename, content, 'utf-8');
@@ -53,7 +53,7 @@ const writeScaffoldDirectory = async (scaffold, directory, spinner) => {
53
53
  return; // continue loop
54
54
  }
55
55
  else {
56
- writeScaffoldDirectory(content, node_path_1.default.join(directory, basename), spinner);
56
+ writeScaffoldDirectory(content, path_1.default.join(directory, basename), spinner);
57
57
  }
58
58
  });
59
59
  await Promise.all(promises);
@@ -26,7 +26,7 @@ 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 node_path_1 = __importDefault(require("node:path"));
29
+ const path_1 = __importDefault(require("path"));
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
31
  const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
32
32
  const gluegun_1 = require("../command-helpers/gluegun");
@@ -99,7 +99,7 @@ exports.default = {
99
99
  // because that would mean the CLI would generate code to
100
100
  // the wrong AssemblyScript version.
101
101
  await (0, version_1.assertManifestApiVersion)(manifest, '0.0.5');
102
- await (0, version_1.assertGraphTsVersion)(node_path_1.default.dirname(manifest), '0.25.0');
102
+ await (0, version_1.assertGraphTsVersion)(path_1.default.dirname(manifest), '0.25.0');
103
103
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest);
104
104
  protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
105
105
  }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_url_1 = require("node:url");
6
+ const url_1 = require("url");
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const auth_1 = require("../command-helpers/auth");
9
9
  const jsonrpc_1 = require("../command-helpers/jsonrpc");
@@ -55,7 +55,7 @@ exports.default = {
55
55
  process.exitCode = 1;
56
56
  return;
57
57
  }
58
- const requestUrl = new node_url_1.URL(node);
58
+ const requestUrl = new url_1.URL(node);
59
59
  const client = (0, jsonrpc_1.createJsonRpcClient)(requestUrl);
60
60
  // Exit with an error code if the client couldn't be created
61
61
  if (!client) {
@@ -26,8 +26,8 @@ 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 node_path_1 = __importDefault(require("node:path"));
30
- const node_url_1 = require("node:url");
29
+ const path_1 = __importDefault(require("path"));
30
+ const url_1 = require("url");
31
31
  const chalk_1 = __importDefault(require("chalk"));
32
32
  const auth_1 = require("../command-helpers/auth");
33
33
  const compiler_1 = require("../command-helpers/compiler");
@@ -198,7 +198,7 @@ exports.default = {
198
198
  // because that would mean the CLI would try to compile code
199
199
  // using the wrong AssemblyScript compiler.
200
200
  await (0, version_1.assertManifestApiVersion)(manifest, '0.0.5');
201
- await (0, version_1.assertGraphTsVersion)(node_path_1.default.dirname(manifest), '0.25.0');
201
+ await (0, version_1.assertGraphTsVersion)(path_1.default.dirname(manifest), '0.25.0');
202
202
  const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest);
203
203
  protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
204
204
  }
@@ -240,7 +240,7 @@ exports.default = {
240
240
  }
241
241
  versionLabel = inputs.versionLabel;
242
242
  }
243
- const requestUrl = new node_url_1.URL(node);
243
+ const requestUrl = new url_1.URL(node);
244
244
  const client = (0, jsonrpc_1.createJsonRpcClient)(requestUrl);
245
245
  // Exit with an error code if the client couldn't be created
246
246
  if (!client) {
@@ -26,9 +26,9 @@ 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 node_fs_1 = __importDefault(require("node:fs"));
30
- const node_os_1 = __importDefault(require("node:os"));
31
- const node_path_1 = __importDefault(require("node:path"));
29
+ const fs_1 = __importDefault(require("fs"));
30
+ const os_1 = __importDefault(require("os"));
31
+ const path_1 = __importDefault(require("path"));
32
32
  const chalk_1 = __importDefault(require("chalk"));
33
33
  const graphCli = __importStar(require("../cli"));
34
34
  const abi_1 = require("../command-helpers/abi");
@@ -147,7 +147,7 @@ const processInitForm = async (toolbox, { protocol, product, studio, node, abi,
147
147
 
148
148
  Examples:
149
149
 
150
- $ graph init ${node_os_1.default.userInfo().username}/${name}
150
+ $ graph init ${os_1.default.userInfo().username}/${name}
151
151
  $ graph init ${name} --allow-simple-name`;
152
152
  }
153
153
  },
@@ -482,7 +482,7 @@ const revalidateSubgraphName = async (toolbox, subgraphName, { allowSimpleName }
482
482
 
483
483
  Examples:
484
484
 
485
- $ graph init ${node_os_1.default.userInfo().username}/${subgraphName}
485
+ $ graph init ${os_1.default.userInfo().username}/${subgraphName}
486
486
  $ graph init ${subgraphName} --allow-simple-name`);
487
487
  return false;
488
488
  }
@@ -490,7 +490,7 @@ const revalidateSubgraphName = async (toolbox, subgraphName, { allowSimpleName }
490
490
  const initRepository = async (toolbox, directory) => await (0, spinner_1.withSpinner)(`Initialize subgraph repository`, `Failed to initialize subgraph repository`, `Warnings while initializing subgraph repository`, async () => {
491
491
  // Remove .git dir in --from-example mode; in --from-contract, we're
492
492
  // starting from an empty directory
493
- const gitDir = node_path_1.default.join(directory, '.git');
493
+ const gitDir = path_1.default.join(directory, '.git');
494
494
  if (toolbox.filesystem.exists(gitDir)) {
495
495
  toolbox.filesystem.remove(gitDir);
496
496
  }
@@ -523,7 +523,7 @@ const runCodegen = async (toolbox, directory, codegenCommand) => await (0, spinn
523
523
  });
524
524
  const printNextSteps = (toolbox, { subgraphName, directory }, { commands, }) => {
525
525
  const { print } = toolbox;
526
- const relativeDir = node_path_1.default.relative(process.cwd(), directory);
526
+ const relativeDir = path_1.default.relative(process.cwd(), directory);
527
527
  // Print instructions
528
528
  print.success(`
529
529
  Subgraph ${print.colors.blue(subgraphName)} created in ${print.colors.blue(relativeDir)}
@@ -554,15 +554,15 @@ const initSubgraphFromExample = async (toolbox, { fromExample, allowSimpleName,
554
554
  // Clone the example subgraph repository
555
555
  const cloned = await (0, spinner_1.withSpinner)(`Cloning example subgraph`, `Failed to clone example subgraph`, `Warnings while cloning example subgraph`, async () => {
556
556
  // Create a temporary directory
557
- const prefix = node_path_1.default.join(node_os_1.default.tmpdir(), 'example-subgraph-');
558
- const tmpDir = node_fs_1.default.mkdtempSync(prefix);
557
+ const prefix = path_1.default.join(os_1.default.tmpdir(), 'example-subgraph-');
558
+ const tmpDir = fs_1.default.mkdtempSync(prefix);
559
559
  try {
560
560
  await system.run(`git clone http://github.com/graphprotocol/example-subgraphs ${tmpDir}`);
561
561
  // If an example is not specified, use the default one
562
562
  if (fromExample === undefined || fromExample === true) {
563
563
  fromExample = DEFAULT_EXAMPLE_SUBGRAPH;
564
564
  }
565
- const exampleSubgraphPath = node_path_1.default.join(tmpDir, String(fromExample));
565
+ const exampleSubgraphPath = path_1.default.join(tmpDir, String(fromExample));
566
566
  if (!filesystem.exists(exampleSubgraphPath)) {
567
567
  return { result: false, error: `Example not found: ${fromExample}` };
568
568
  }
@@ -580,7 +580,7 @@ const initSubgraphFromExample = async (toolbox, { fromExample, allowSimpleName,
580
580
  try {
581
581
  // It doesn't matter if we changed the URL we clone the YAML,
582
582
  // we'll check it's network anyway. If it's a studio subgraph we're dealing with.
583
- const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(node_path_1.default.join(directory, 'subgraph.yaml'));
583
+ const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(path_1.default.join(directory, 'subgraph.yaml'));
584
584
  for (const { network } of dataSourcesAndTemplates) {
585
585
  (0, studio_1.validateStudioNetwork)({ studio, product, network });
586
586
  }
@@ -774,13 +774,13 @@ const addAnotherContract = async (toolbox, { protocolInstance, directory }) => {
774
774
  const { abi, contract, contractName } = await toolbox.prompt.ask(
775
775
  // @ts-expect-error questions do somehow fit
776
776
  questions);
777
- if (node_fs_1.default.existsSync(directory)) {
777
+ if (fs_1.default.existsSync(directory)) {
778
778
  process.chdir(directory);
779
779
  }
780
780
  const commandLine = ['add', contract, '--contract-name', contractName];
781
781
  if (abiFromFile) {
782
782
  if (abi.includes(directory)) {
783
- commandLine.push('--abi', node_path_1.default.normalize(abi.replace(directory, '')));
783
+ commandLine.push('--abi', path_1.default.normalize(abi.replace(directory, '')));
784
784
  }
785
785
  else {
786
786
  commandLine.push('--abi', abi);
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_child_process_1 = require("node:child_process");
7
- const node_http_1 = __importDefault(require("node:http"));
8
- const node_net_1 = __importDefault(require("node:net"));
9
- const node_path_1 = __importDefault(require("node:path"));
6
+ const child_process_1 = require("child_process");
7
+ const http_1 = __importDefault(require("http"));
8
+ const net_1 = __importDefault(require("net"));
9
+ const path_1 = __importDefault(require("path"));
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  const docker_compose_1 = __importDefault(require("docker-compose"));
12
12
  const strip_ansi_1 = __importDefault(require("strip-ansi"));
@@ -63,7 +63,7 @@ exports.default = {
63
63
  }
64
64
  const testCommand = params[0];
65
65
  // Obtain the Docker Compose file for services that the tests run against
66
- composeFile ||= node_path_1.default.join(__dirname, '..', '..', 'resources', 'test', standaloneNode ? 'docker-compose-standalone-node.yml' : 'docker-compose.yml');
66
+ composeFile ||= path_1.default.join(__dirname, '..', '..', 'resources', 'test', standaloneNode ? 'docker-compose-standalone-node.yml' : 'docker-compose.yml');
67
67
  // parse timeout. Defaults to 120 seconds
68
68
  timeout = Math.abs(parseInt(timeout)) || 120000;
69
69
  if (!filesystem.exists(composeFile)) {
@@ -200,7 +200,7 @@ const indent = (indentation, str) => str
200
200
  .join('\n');
201
201
  const configureTestEnvironment = async (toolbox, tempdir, composeFile, nodeImage) => await (0, spinner_1.withSpinner)(`Configure test environment`, `Failed to configure test environment`, `Warnings configuring test environment`, async () => {
202
202
  // Temporary compose file
203
- const tempComposeFile = node_path_1.default.join(tempdir, 'compose', 'docker-compose.yml');
203
+ const tempComposeFile = path_1.default.join(tempdir, 'compose', 'docker-compose.yml');
204
204
  // Copy the compose file to the temporary directory
205
205
  toolbox.filesystem.copy(composeFile, tempComposeFile);
206
206
  // Substitute the graph-node image with the custom one, if appropriate
@@ -233,7 +233,7 @@ const waitFor = async (timeout, testFn) => {
233
233
  const startTestEnvironment = async (tempdir) => await (0, spinner_1.withSpinner)(`Start test environment`, `Failed to start test environment`, `Warnings starting test environment`, async (_spinner) => {
234
234
  // Bring up the test environment
235
235
  await docker_compose_1.default.upAll({
236
- cwd: node_path_1.default.join(tempdir, 'compose'),
236
+ cwd: path_1.default.join(tempdir, 'compose'),
237
237
  });
238
238
  });
239
239
  const waitForTestEnvironment = async ({ skipWaitForEthereum, skipWaitForIpfs, skipWaitForPostgres, timeout, }) => await (0, spinner_1.withSpinner)(`Wait for test environment`, `Failed to wait for test environment`, `Warnings waiting for test environment`, async (spinner) => {
@@ -243,7 +243,7 @@ const waitForTestEnvironment = async ({ skipWaitForEthereum, skipWaitForIpfs, sk
243
243
  }
244
244
  else {
245
245
  await waitFor(timeout, async () => new Promise((resolve, reject) => {
246
- node_http_1.default
246
+ http_1.default
247
247
  .get('http://localhost:15001/api/v0/version', () => {
248
248
  resolve();
249
249
  })
@@ -259,7 +259,7 @@ const waitForTestEnvironment = async ({ skipWaitForEthereum, skipWaitForIpfs, sk
259
259
  }
260
260
  else {
261
261
  await waitFor(timeout, async () => new Promise((resolve, reject) => {
262
- node_http_1.default
262
+ http_1.default
263
263
  .get('http://localhost:18545', () => {
264
264
  resolve();
265
265
  })
@@ -276,7 +276,7 @@ const waitForTestEnvironment = async ({ skipWaitForEthereum, skipWaitForIpfs, sk
276
276
  else {
277
277
  await waitFor(timeout, async () => new Promise((resolve, reject) => {
278
278
  try {
279
- const socket = node_net_1.default.connect(15432, 'localhost', () => resolve());
279
+ const socket = net_1.default.connect(15432, 'localhost', () => resolve());
280
280
  socket.on('error', e => reject(new Error(`Could not connect to Postgres: ${e}`)));
281
281
  socket.end();
282
282
  }
@@ -291,13 +291,13 @@ const stopTestEnvironment = async (tempdir) => await (0, spinner_1.withSpinner)(
291
291
  // Our containers do not respond quickly to the SIGTERM which `down` tries before timing out
292
292
  // and killing them, so speed things up by sending a SIGKILL right away.
293
293
  try {
294
- await docker_compose_1.default.kill({ cwd: node_path_1.default.join(tempdir, 'compose') });
294
+ await docker_compose_1.default.kill({ cwd: path_1.default.join(tempdir, 'compose') });
295
295
  }
296
296
  catch (e) {
297
297
  // Do nothing, we will just try to run 'down'
298
298
  // to bring down the environment
299
299
  }
300
- await docker_compose_1.default.down({ cwd: node_path_1.default.join(tempdir, 'compose') });
300
+ await docker_compose_1.default.down({ cwd: path_1.default.join(tempdir, 'compose') });
301
301
  });
302
302
  const startGraphNode = async (standaloneNode, standaloneNodeArgs, nodeOutputChunks) => await (0, spinner_1.withSpinner)(`Start Graph node`, `Failed to start Graph node`, `Warnings starting Graph node`, async (spinner) => {
303
303
  const defaultArgs = [
@@ -324,7 +324,7 @@ const startGraphNode = async (standaloneNode, standaloneNodeArgs, nodeOutputChun
324
324
  };
325
325
  const args = standaloneNodeArgs ? standaloneNodeArgs.split(' ') : defaultArgs;
326
326
  const env = { ...defaultEnv, ...process.env };
327
- const nodeProcess = (0, node_child_process_1.spawn)(standaloneNode, args, {
327
+ const nodeProcess = (0, child_process_1.spawn)(standaloneNode, args, {
328
328
  cwd: process.cwd(),
329
329
  env,
330
330
  });
@@ -339,7 +339,7 @@ const startGraphNode = async (standaloneNode, standaloneNodeArgs, nodeOutputChun
339
339
  });
340
340
  const waitForGraphNode = async (timeout) => await (0, spinner_1.withSpinner)(`Wait for Graph node`, `Failed to wait for Graph node`, `Warnings waiting for Graph node`, async () => {
341
341
  await waitFor(timeout, async () => new Promise((resolve, reject) => {
342
- node_http_1.default
342
+ http_1.default
343
343
  .get('http://localhost:18000', { timeout }, () => resolve())
344
344
  .on('error', e => reject(e));
345
345
  }));
@@ -355,20 +355,20 @@ const collectGraphNodeLogs = async (tempdir, standaloneNode, nodeOutputChunks) =
355
355
  // Pull the logs from docker compose
356
356
  const logs = await docker_compose_1.default.logs('graph-node', {
357
357
  follow: false,
358
- cwd: node_path_1.default.join(tempdir, 'compose'),
358
+ cwd: path_1.default.join(tempdir, 'compose'),
359
359
  });
360
360
  return (0, strip_ansi_1.default)(logs.out.trim()).replace(/graph-node_1 {2}\| /g, '');
361
361
  };
362
362
  const collectEthereumLogs = async (tempdir) => {
363
363
  const logs = await docker_compose_1.default.logs('ethereum', {
364
364
  follow: false,
365
- cwd: node_path_1.default.join(tempdir, 'compose'),
365
+ cwd: path_1.default.join(tempdir, 'compose'),
366
366
  });
367
367
  return (0, strip_ansi_1.default)(logs.out.trim()).replace(/ethereum_1 {2}\| /g, '');
368
368
  };
369
369
  const runTests = async (testCommand) => await (0, spinner_1.withSpinner)(`Run tests`, `Failed to run tests`, `Warnings running tests`, async () => new Promise(resolve => {
370
370
  const output = [];
371
- const testProcess = (0, node_child_process_1.spawn)(String(testCommand), { shell: true });
371
+ const testProcess = (0, child_process_1.spawn)(String(testCommand), { shell: true });
372
372
  testProcess.stdout.on('data', data => output.push(Buffer.from(data)));
373
373
  testProcess.stderr.on('data', data => output.push(Buffer.from(data)));
374
374
  testProcess.on('close', code => {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_url_1 = require("node:url");
6
+ const url_1 = require("url");
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const auth_1 = require("../command-helpers/auth");
9
9
  const jsonrpc_1 = require("../command-helpers/jsonrpc");
@@ -55,7 +55,7 @@ exports.default = {
55
55
  process.exitCode = 1;
56
56
  return;
57
57
  }
58
- const requestUrl = new node_url_1.URL(node);
58
+ const requestUrl = new url_1.URL(node);
59
59
  const client = (0, jsonrpc_1.createJsonRpcClient)(requestUrl);
60
60
  // Exit with an error code if the client couldn't be created
61
61
  if (!client) {
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_child_process_1 = require("node:child_process");
7
- const node_os_1 = __importDefault(require("node:os"));
8
- const node_path_1 = __importDefault(require("node:path"));
6
+ const child_process_1 = require("child_process");
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
9
  const binary_install_raw_1 = require("binary-install-raw");
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  const gluegun_1 = require("gluegun");
@@ -33,7 +33,7 @@ exports.default = {
33
33
  const testsFolder = './tests';
34
34
  const opts = {
35
35
  testsFolder,
36
- cachePath: node_path_1.default.join(testsFolder, '.latest.json'),
36
+ cachePath: path_1.default.join(testsFolder, '.latest.json'),
37
37
  };
38
38
  // Support both long and short option variants
39
39
  opts.coverage = coverage || c;
@@ -145,13 +145,13 @@ async function runBinary(datasource, opts) {
145
145
  args.length > 0 ? binary.run(...args) : binary.run();
146
146
  }
147
147
  async function getPlatform(logsOpt) {
148
- const type = node_os_1.default.type();
149
- const arch = node_os_1.default.arch();
150
- const cpuCore = node_os_1.default.cpus()[0];
148
+ const type = os_1.default.type();
149
+ const arch = os_1.default.arch();
150
+ const cpuCore = os_1.default.cpus()[0];
151
151
  const isAppleSilicon = arch === 'arm64' && /Apple (M1|M2|processor)/.test(cpuCore.model);
152
152
  const linuxInfo = type === 'Linux' ? await getLinuxInfo() : {};
153
153
  const linuxDistro = linuxInfo.name;
154
- const release = linuxInfo.version || node_os_1.default.release();
154
+ const release = linuxInfo.version || os_1.default.release();
155
155
  const majorVersion = parseInt(linuxInfo.version || '', 10) || semver_1.default.major(release);
156
156
  if (logsOpt) {
157
157
  gluegun_1.print.info(`OS type: ${linuxDistro || type}\nOS arch: ${arch}\nOS release: ${release}\nOS major version: ${majorVersion}\nCPU model: ${cpuCore.model}`);
@@ -210,7 +210,7 @@ async function runDocker(datasource, opts) {
210
210
  // Get current working directory
211
211
  const current_folder = gluegun_1.filesystem.cwd();
212
212
  // Declate dockerfilePath with default location
213
- const dockerfilePath = node_path_1.default.join(opts.testsFolder || 'tests', '.docker/Dockerfile');
213
+ const dockerfilePath = path_1.default.join(opts.testsFolder || 'tests', '.docker/Dockerfile');
214
214
  // Check if the Dockerfil already exists
215
215
  const dockerfileExists = gluegun_1.filesystem.exists(dockerfilePath);
216
216
  // Generate the Dockerfile only if it doesn't exists,
@@ -219,7 +219,7 @@ async function runDocker(datasource, opts) {
219
219
  await dockerfile(dockerfilePath, versionOpt, latestVersion);
220
220
  }
221
221
  // Run a command to check if matchstick image already exists
222
- (0, node_child_process_1.exec)('docker images -q matchstick', (_error, stdout, _stderr) => {
222
+ (0, child_process_1.exec)('docker images -q matchstick', (_error, stdout, _stderr) => {
223
223
  // Collect all(if any) flags and options that have to be passed to the matchstick binary
224
224
  let testArgs = '';
225
225
  if (coverageOpt)
@@ -247,24 +247,24 @@ async function runDocker(datasource, opts) {
247
247
  // Use spawn() and {stdio: 'inherit'} so we can see the logs in real time.
248
248
  if (!dockerfileExists || stdout === '' || versionOpt || forceOpt) {
249
249
  if (stdout !== '') {
250
- (0, node_child_process_1.exec)('docker image rm matchstick', (_error, stdout, _stderr) => {
250
+ (0, child_process_1.exec)('docker image rm matchstick', (_error, stdout, _stderr) => {
251
251
  gluegun_1.print.info(chalk_1.default.bold(`Removing matchstick image\n${stdout}`));
252
252
  });
253
253
  }
254
254
  // Build a docker image. If the process has executed successfully
255
255
  // run a container from that image.
256
- (0, node_child_process_1.spawn)('docker', ['build', '-f', dockerfilePath, '-t', 'matchstick', '.'], {
256
+ (0, child_process_1.spawn)('docker', ['build', '-f', dockerfilePath, '-t', 'matchstick', '.'], {
257
257
  stdio: 'inherit',
258
258
  }).on('close', code => {
259
259
  if (code === 0) {
260
- (0, node_child_process_1.spawn)('docker', dockerRunOpts, { stdio: 'inherit' });
260
+ (0, child_process_1.spawn)('docker', dockerRunOpts, { stdio: 'inherit' });
261
261
  }
262
262
  });
263
263
  }
264
264
  else {
265
265
  gluegun_1.print.info('Docker image already exists. Skipping `docker build` command.');
266
266
  // Run the container from the existing matchstick docker image
267
- (0, node_child_process_1.spawn)('docker', dockerRunOpts, { stdio: 'inherit' });
267
+ (0, child_process_1.spawn)('docker', dockerRunOpts, { stdio: 'inherit' });
268
268
  }
269
269
  });
270
270
  }