@graphprotocol/graph-cli 0.37.3-alpha-20230111132934-b4190fb → 0.37.3-alpha-20230111142142-c48ca88
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 +1 -1
- package/dist/command-helpers/compiler.js +3 -3
- package/dist/compiler/index.js +33 -22
- package/dist/migrations/mapping_api_version_0_0_1.js +11 -7
- package/dist/migrations/mapping_api_version_0_0_2.js +11 -5
- package/dist/migrations/mapping_api_version_0_0_3.js +11 -7
- package/dist/migrations/mapping_api_version_0_0_4.js +11 -7
- package/dist/migrations/mapping_api_version_0_0_5.js +11 -7
- package/dist/migrations/spec_version_0_0_2.js +2 -7
- package/dist/migrations/spec_version_0_0_3.js +2 -7
- package/dist/migrations/util/versions.js +3 -4
- package/package.json +2 -1
- package/src/command-helpers/{compiler.js → compiler.ts} +24 -7
- package/src/command-helpers/ipfs-http-client.d.ts +1 -0
- package/src/compiler/{index.js → index.ts} +110 -62
- package/src/migrations/{mapping_api_version_0_0_1.js → mapping_api_version_0_0_1.ts} +14 -7
- package/src/migrations/{mapping_api_version_0_0_2.js → mapping_api_version_0_0_2.ts} +14 -5
- package/src/migrations/{mapping_api_version_0_0_3.js → mapping_api_version_0_0_3.ts} +14 -7
- package/src/migrations/{mapping_api_version_0_0_4.js → mapping_api_version_0_0_4.ts} +15 -8
- package/src/migrations/{mapping_api_version_0_0_5.js → mapping_api_version_0_0_5.ts} +15 -8
- package/src/migrations/{spec_version_0_0_2.js → spec_version_0_0_2.ts} +3 -5
- package/src/migrations/{spec_version_0_0_3.js → spec_version_0_0_3.ts} +3 -5
- package/src/migrations/util/{load-manifest.js → load-manifest.ts} +1 -3
- package/src/migrations/util/{versions.js → versions.ts} +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -29,10 +29,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.createCompiler = void 0;
|
|
30
30
|
const URL = require('url').URL;
|
|
31
31
|
const ipfs_http_client_1 = __importDefault(require("ipfs-http-client"));
|
|
32
|
-
const toolbox = __importStar(require("gluegun
|
|
32
|
+
const toolbox = __importStar(require("gluegun"));
|
|
33
33
|
const compiler_1 = __importDefault(require("../compiler"));
|
|
34
34
|
// Helper function to construct a subgraph compiler
|
|
35
|
-
|
|
35
|
+
function createCompiler(manifest, { ipfs, headers, outputDir, outputFormat, skipMigrations, blockIpfsMethods, protocol, }) {
|
|
36
36
|
// Parse the IPFS URL
|
|
37
37
|
let url;
|
|
38
38
|
try {
|
|
@@ -62,5 +62,5 @@ The IPFS URL must be of the following format: http(s)://host[:port]/[path]`);
|
|
|
62
62
|
blockIpfsMethods,
|
|
63
63
|
protocol,
|
|
64
64
|
});
|
|
65
|
-
}
|
|
65
|
+
}
|
|
66
66
|
exports.createCompiler = createCompiler;
|
package/dist/compiler/index.js
CHANGED
|
@@ -32,17 +32,25 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
32
32
|
const immutable_1 = __importDefault(require("immutable"));
|
|
33
33
|
const path_1 = __importDefault(require("path"));
|
|
34
34
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
35
|
-
const toolbox = __importStar(require("gluegun
|
|
35
|
+
const toolbox = __importStar(require("gluegun"));
|
|
36
36
|
const spinner_1 = require("../command-helpers/spinner");
|
|
37
37
|
const subgraph_1 = __importDefault(require("../subgraph"));
|
|
38
38
|
const watcher_1 = __importDefault(require("../watcher"));
|
|
39
39
|
const migrations_1 = require("../migrations");
|
|
40
40
|
const asc = __importStar(require("./asc"));
|
|
41
|
-
const subgraph_2 = __importDefault(require("../protocols/substreams/subgraph"));
|
|
42
41
|
const debug_1 = __importDefault(require("../debug"));
|
|
43
42
|
let compilerDebug = (0, debug_1.default)('graph-cli:compiler');
|
|
44
43
|
class Compiler {
|
|
44
|
+
options;
|
|
45
|
+
ipfs;
|
|
46
|
+
sourceDir;
|
|
47
|
+
blockIpfsMethods;
|
|
48
|
+
libsDirs;
|
|
49
|
+
globalsFile;
|
|
50
|
+
protocol;
|
|
51
|
+
ABI;
|
|
45
52
|
constructor(options) {
|
|
53
|
+
this.options = options;
|
|
46
54
|
this.options = options;
|
|
47
55
|
this.ipfs = options.ipfs;
|
|
48
56
|
this.sourceDir = path_1.default.dirname(options.subgraphManifest);
|
|
@@ -70,6 +78,10 @@ class Compiler {
|
|
|
70
78
|
}
|
|
71
79
|
this.globalsFile = path_1.default.join(globalsLib, globalsFile);
|
|
72
80
|
}
|
|
81
|
+
// @ts-expect-error might be assigned, might not
|
|
82
|
+
if (!this.globalsFile) {
|
|
83
|
+
throw new Error('Globals file is missing.');
|
|
84
|
+
}
|
|
73
85
|
this.protocol = this.options.protocol;
|
|
74
86
|
this.ABI = this.protocol.getABI();
|
|
75
87
|
process.on('uncaughtException', function (e) {
|
|
@@ -121,11 +133,12 @@ class Compiler {
|
|
|
121
133
|
async loadSubgraph({ quiet } = { quiet: false }) {
|
|
122
134
|
const subgraphLoadOptions = { protocol: this.protocol, skipValidation: false };
|
|
123
135
|
if (quiet) {
|
|
124
|
-
return subgraph_1.default.load(this.options.subgraphManifest, subgraphLoadOptions)
|
|
136
|
+
return (await subgraph_1.default.load(this.options.subgraphManifest, subgraphLoadOptions))
|
|
137
|
+
.result;
|
|
125
138
|
}
|
|
126
139
|
else {
|
|
127
140
|
const manifestPath = this.displayPath(this.options.subgraphManifest);
|
|
128
|
-
return await (0, spinner_1.withSpinner)(`Load subgraph from ${manifestPath}`, `Failed to load subgraph from ${manifestPath}`, `Warnings loading subgraph from ${manifestPath}`, async (
|
|
141
|
+
return await (0, spinner_1.withSpinner)(`Load subgraph from ${manifestPath}`, `Failed to load subgraph from ${manifestPath}`, `Warnings loading subgraph from ${manifestPath}`, async () => {
|
|
129
142
|
return subgraph_1.default.load(this.options.subgraphManifest, subgraphLoadOptions);
|
|
130
143
|
});
|
|
131
144
|
}
|
|
@@ -138,11 +151,11 @@ class Compiler {
|
|
|
138
151
|
files.push(this.options.subgraphManifest);
|
|
139
152
|
// Add all file paths specified in manifest
|
|
140
153
|
files.push(path_1.default.resolve(subgraph.getIn(['schema', 'file'])));
|
|
141
|
-
subgraph.get('dataSources').map(dataSource => {
|
|
154
|
+
subgraph.get('dataSources').map((dataSource) => {
|
|
142
155
|
files.push(dataSource.getIn(['mapping', 'file']));
|
|
143
156
|
// Only watch ABI related files if the target protocol has support/need for them.
|
|
144
157
|
if (this.protocol.hasABIs()) {
|
|
145
|
-
dataSource.getIn(['mapping', 'abis']).map(abi => {
|
|
158
|
+
dataSource.getIn(['mapping', 'abis']).map((abi) => {
|
|
146
159
|
files.push(abi.get('file'));
|
|
147
160
|
});
|
|
148
161
|
}
|
|
@@ -154,7 +167,7 @@ class Compiler {
|
|
|
154
167
|
throw Error(`Failed to load subgraph: ${e.message}`);
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
|
-
async watchAndCompile(onCompiled
|
|
170
|
+
async watchAndCompile(onCompiled) {
|
|
158
171
|
let compiler = this;
|
|
159
172
|
let spinner;
|
|
160
173
|
// Create watcher and recompile once and then on every change to a watched file
|
|
@@ -165,9 +178,7 @@ class Compiler {
|
|
|
165
178
|
spinner.info(`File change detected: ${this.displayPath(changedFile)}\n`);
|
|
166
179
|
}
|
|
167
180
|
let ipfsHash = await compiler.compile();
|
|
168
|
-
|
|
169
|
-
onCompiled(ipfsHash);
|
|
170
|
-
}
|
|
181
|
+
onCompiled?.(ipfsHash);
|
|
171
182
|
spinner.start();
|
|
172
183
|
},
|
|
173
184
|
onCollectFiles: async () => await compiler.getFilesToWatch(),
|
|
@@ -203,10 +214,10 @@ class Compiler {
|
|
|
203
214
|
// Cache compiled files so identical input files are only compiled once
|
|
204
215
|
let compiledFiles = new Map();
|
|
205
216
|
await asc.ready();
|
|
206
|
-
subgraph = subgraph.update('dataSources', dataSources => dataSources.map(dataSource => dataSource.updateIn(['mapping', 'file'], mappingPath => this._compileDataSourceMapping(this.protocol, dataSource, mappingPath, compiledFiles, spinner))));
|
|
207
|
-
subgraph = subgraph.update('templates', templates => templates === undefined
|
|
217
|
+
subgraph = subgraph.update('dataSources', (dataSources) => dataSources.map((dataSource) => dataSource.updateIn(['mapping', 'file'], (mappingPath) => this._compileDataSourceMapping(this.protocol, dataSource, mappingPath, compiledFiles, spinner))));
|
|
218
|
+
subgraph = subgraph.update('templates', (templates) => templates === undefined
|
|
208
219
|
? templates
|
|
209
|
-
: templates.map(template => template.updateIn(['mapping', 'file'], mappingPath => this._compileTemplateMapping(template, mappingPath, compiledFiles, spinner))));
|
|
220
|
+
: templates.map((template) => template.updateIn(['mapping', 'file'], (mappingPath) => this._compileTemplateMapping(template, mappingPath, compiledFiles, spinner))));
|
|
210
221
|
return subgraph;
|
|
211
222
|
});
|
|
212
223
|
}
|
|
@@ -327,12 +338,12 @@ class Compiler {
|
|
|
327
338
|
return path_1.default.relative(this.options.outputDir, targetFile);
|
|
328
339
|
});
|
|
329
340
|
// Copy data source files and update their paths
|
|
330
|
-
subgraph = subgraph.update('dataSources', dataSources => dataSources.map(dataSource => {
|
|
341
|
+
subgraph = subgraph.update('dataSources', (dataSources) => dataSources.map(dataSource => {
|
|
331
342
|
let updatedDataSource = dataSource;
|
|
332
343
|
if (this.protocol.hasABIs()) {
|
|
333
344
|
updatedDataSource = updatedDataSource
|
|
334
345
|
// Write data source ABIs to the output directory
|
|
335
|
-
.updateIn(['mapping', 'abis'], abis => abis.map(abi => abi.update('file', abiFile => {
|
|
346
|
+
.updateIn(['mapping', 'abis'], (abis) => abis.map((abi) => abi.update('file', (abiFile) => {
|
|
336
347
|
abiFile = path_1.default.resolve(this.sourceDir, abiFile);
|
|
337
348
|
let abiData = this.ABI.load(abi.get('name'), abiFile);
|
|
338
349
|
return path_1.default.relative(this.options.outputDir, this._writeSubgraphFile(abiFile, JSON.stringify(abiData.data.toJS(), null, 2), this.sourceDir, this.subgraphDir(this.options.outputDir, dataSource), spinner));
|
|
@@ -341,7 +352,7 @@ class Compiler {
|
|
|
341
352
|
if (protocol.name == 'substreams') {
|
|
342
353
|
updatedDataSource = updatedDataSource
|
|
343
354
|
// Write data source ABIs to the output directory
|
|
344
|
-
.updateIn(['source', 'package'], substreamsPackage => substreamsPackage.update('file', packageFile => {
|
|
355
|
+
.updateIn(['source', 'package'], (substreamsPackage) => substreamsPackage.update('file', (packageFile) => {
|
|
345
356
|
packageFile = path_1.default.resolve(this.sourceDir, packageFile);
|
|
346
357
|
let packageContent = fs_extra_1.default.readFileSync(packageFile);
|
|
347
358
|
return path_1.default.relative(this.options.outputDir, this._writeSubgraphFile(packageFile, packageContent, this.sourceDir, this.subgraphDir(this.options.outputDir, dataSource), spinner));
|
|
@@ -350,17 +361,17 @@ class Compiler {
|
|
|
350
361
|
}
|
|
351
362
|
// The mapping file is already being written to the output
|
|
352
363
|
// directory by the AssemblyScript compiler
|
|
353
|
-
return updatedDataSource.updateIn(['mapping', 'file'], mappingFile => path_1.default.relative(this.options.outputDir, path_1.default.resolve(this.sourceDir, mappingFile)));
|
|
364
|
+
return updatedDataSource.updateIn(['mapping', 'file'], (mappingFile) => path_1.default.relative(this.options.outputDir, path_1.default.resolve(this.sourceDir, mappingFile)));
|
|
354
365
|
}));
|
|
355
366
|
// Copy template files and update their paths
|
|
356
367
|
subgraph = subgraph.update('templates', templates => templates === undefined
|
|
357
368
|
? templates
|
|
358
|
-
: templates.map(template => {
|
|
369
|
+
: templates.map((template) => {
|
|
359
370
|
let updatedTemplate = template;
|
|
360
371
|
if (this.protocol.hasABIs()) {
|
|
361
372
|
updatedTemplate = updatedTemplate
|
|
362
373
|
// Write template ABIs to the output directory
|
|
363
|
-
.updateIn(['mapping', 'abis'], abis => abis.map(abi => abi.update('file', abiFile => {
|
|
374
|
+
.updateIn(['mapping', 'abis'], (abis) => abis.map(abi => abi.update('file', (abiFile) => {
|
|
364
375
|
abiFile = path_1.default.resolve(this.sourceDir, abiFile);
|
|
365
376
|
let abiData = this.ABI.load(abi.get('name'), abiFile);
|
|
366
377
|
return path_1.default.relative(this.options.outputDir, this._writeSubgraphFile(abiFile, JSON.stringify(abiData.data.toJS(), null, 2), this.sourceDir, this.subgraphDir(this.options.outputDir, template), spinner));
|
|
@@ -368,7 +379,7 @@ class Compiler {
|
|
|
368
379
|
}
|
|
369
380
|
// The mapping file is already being written to the output
|
|
370
381
|
// directory by the AssemblyScript compiler
|
|
371
|
-
return updatedTemplate.updateIn(['mapping', 'file'], mappingFile => path_1.default.relative(this.options.outputDir, path_1.default.resolve(this.sourceDir, mappingFile)));
|
|
382
|
+
return updatedTemplate.updateIn(['mapping', 'file'], (mappingFile) => path_1.default.relative(this.options.outputDir, path_1.default.resolve(this.sourceDir, mappingFile)));
|
|
372
383
|
}));
|
|
373
384
|
// Write the subgraph manifest itself
|
|
374
385
|
let outputFilename = path_1.default.join(this.options.outputDir, 'subgraph.yaml');
|
|
@@ -434,7 +445,7 @@ class Compiler {
|
|
|
434
445
|
subgraph = subgraph.setIn(update.keyPath, update.value);
|
|
435
446
|
}
|
|
436
447
|
// Upload the subgraph itself
|
|
437
|
-
return await this._uploadSubgraphDefinitionToIPFS(subgraph
|
|
448
|
+
return await this._uploadSubgraphDefinitionToIPFS(subgraph);
|
|
438
449
|
});
|
|
439
450
|
}
|
|
440
451
|
async _uploadFileToIPFS(maybeRelativeFile, uploadedFiles, spinner) {
|
|
@@ -444,7 +455,7 @@ class Compiler {
|
|
|
444
455
|
let uploadCacheKey = this.cacheKeyForFile(absoluteFile);
|
|
445
456
|
let alreadyUploaded = uploadedFiles.has(uploadCacheKey);
|
|
446
457
|
if (!alreadyUploaded) {
|
|
447
|
-
let content = Buffer.from(await fs_extra_1.default.readFile(absoluteFile
|
|
458
|
+
let content = Buffer.from(await fs_extra_1.default.readFile(absoluteFile, { encoding: 'utf-8' }));
|
|
448
459
|
let hash = await this._uploadToIPFS({
|
|
449
460
|
path: path_1.default.relative(this.options.outputDir, absoluteFile),
|
|
450
461
|
content: content,
|
|
@@ -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
|
|
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,
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
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,
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
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,
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
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,
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
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,
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
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 ({
|
|
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
|
|
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 ({
|
|
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
|
-
|
|
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-
|
|
3
|
+
"version": "0.37.3-alpha-20230111142142-c48ca88",
|
|
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,13 +1,32 @@
|
|
|
1
1
|
const URL = require('url').URL
|
|
2
2
|
import ipfsHttpClient from 'ipfs-http-client'
|
|
3
|
-
import * as toolbox from 'gluegun
|
|
3
|
+
import * as toolbox from 'gluegun'
|
|
4
4
|
import Compiler from '../compiler'
|
|
5
|
+
import Protocol from '../protocols'
|
|
6
|
+
|
|
7
|
+
interface CreateCompilerOptions {
|
|
8
|
+
ipfs: any
|
|
9
|
+
headers: any
|
|
10
|
+
outputDir: string
|
|
11
|
+
outputFormat: string
|
|
12
|
+
skipMigrations: boolean
|
|
13
|
+
blockIpfsMethods: boolean
|
|
14
|
+
protocol: Protocol
|
|
15
|
+
}
|
|
5
16
|
|
|
6
17
|
// Helper function to construct a subgraph compiler
|
|
7
|
-
|
|
8
|
-
manifest,
|
|
9
|
-
{
|
|
10
|
-
|
|
18
|
+
export function createCompiler(
|
|
19
|
+
manifest: string,
|
|
20
|
+
{
|
|
21
|
+
ipfs,
|
|
22
|
+
headers,
|
|
23
|
+
outputDir,
|
|
24
|
+
outputFormat,
|
|
25
|
+
skipMigrations,
|
|
26
|
+
blockIpfsMethods,
|
|
27
|
+
protocol,
|
|
28
|
+
}: CreateCompilerOptions,
|
|
29
|
+
) {
|
|
11
30
|
// Parse the IPFS URL
|
|
12
31
|
let url
|
|
13
32
|
try {
|
|
@@ -39,5 +58,3 @@ The IPFS URL must be of the following format: http(s)://host[:port]/[path]`)
|
|
|
39
58
|
protocol,
|
|
40
59
|
})
|
|
41
60
|
}
|
|
42
|
-
|
|
43
|
-
export { createCompiler }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'ipfs-http-client'
|