@graphprotocol/graph-cli 0.38.1-alpha-20230208031649-b554fda → 0.38.1-alpha-20230208032550-ddc8362
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/commands/codegen.js +38 -61
- package/oclif.manifest.json +52 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/commands/codegen.js
CHANGED
|
@@ -27,69 +27,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const path_1 = __importDefault(require("path"));
|
|
30
|
-
const
|
|
30
|
+
const core_1 = require("@oclif/core");
|
|
31
31
|
const DataSourcesExtractor = __importStar(require("../command-helpers/data-sources"));
|
|
32
|
-
const gluegun_1 = require("../command-helpers/gluegun");
|
|
33
32
|
const version_1 = require("../command-helpers/version");
|
|
34
33
|
const debug_1 = __importDefault(require("../debug"));
|
|
35
34
|
const protocols_1 = __importDefault(require("../protocols"));
|
|
36
35
|
const type_generator_1 = __importDefault(require("../type-generator"));
|
|
37
|
-
const HELP = `
|
|
38
|
-
${chalk_1.default.bold('graph codegen')} [options] ${chalk_1.default.bold('[<subgraph-manifest>]')}
|
|
39
|
-
Options:
|
|
40
|
-
-h, --help Show usage information
|
|
41
|
-
-o, --output-dir <path> Output directory for generated types (default: generated/)
|
|
42
|
-
--skip-migrations Skip subgraph migrations (default: false)
|
|
43
|
-
-w, --watch Regenerate types when subgraph files change (default: false)
|
|
44
|
-
-u, --uncrashable Generate Float Subgraph Uncrashable helper file
|
|
45
|
-
-uc, --uncrashable-config <path> Directory for uncrashable config (default: ./uncrashable-config.yaml)
|
|
46
|
-
`;
|
|
47
36
|
const codegenDebug = (0, debug_1.default)('graph-cli:codegen');
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Obtain tools
|
|
52
|
-
const { filesystem, print } = toolbox;
|
|
53
|
-
// Read CLI parameters
|
|
54
|
-
let { h, help, o, outputDir, skipMigrations, w, watch, u, uncrashable, uc, uncrashableConfig } = toolbox.parameters.options;
|
|
55
|
-
// Support both long and short option variants
|
|
56
|
-
help || (help = h);
|
|
57
|
-
outputDir || (outputDir = o);
|
|
58
|
-
watch || (watch = w);
|
|
59
|
-
uncrashable || (uncrashable = u);
|
|
60
|
-
let uncrashable_config = uncrashableConfig || uc;
|
|
61
|
-
let manifest;
|
|
62
|
-
try {
|
|
63
|
-
[manifest] = (0, gluegun_1.fixParameters)(toolbox.parameters, {
|
|
64
|
-
h,
|
|
65
|
-
help,
|
|
66
|
-
skipMigrations,
|
|
67
|
-
w,
|
|
68
|
-
watch,
|
|
69
|
-
u,
|
|
70
|
-
uncrashable,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
print.error(e.message);
|
|
75
|
-
process.exitCode = 1;
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
37
|
+
class CodegenCommand extends core_1.Command {
|
|
38
|
+
async run() {
|
|
39
|
+
const { args: { 'subgraph-manifest': manifest }, flags: { 'output-dir': outputDir, 'skip-migrations': skipMigrations, watch, uncrashable, 'uncrashable-config': uncrashableConfig, }, } = await this.parse(CodegenCommand);
|
|
78
40
|
codegenDebug('Initialized codegen manifest: %o', manifest);
|
|
79
|
-
// Fall back to default values for options / parameters
|
|
80
|
-
outputDir =
|
|
81
|
-
outputDir !== undefined && outputDir !== '' ? outputDir : filesystem.path('generated');
|
|
82
|
-
manifest =
|
|
83
|
-
manifest !== undefined && manifest !== '' ? manifest : filesystem.resolve('subgraph.yaml');
|
|
84
|
-
uncrashable_config =
|
|
85
|
-
uncrashable_config !== undefined && uncrashable_config !== ''
|
|
86
|
-
? uncrashable_config
|
|
87
|
-
: filesystem.resolve('uncrashable-config.yaml');
|
|
88
|
-
// Show help text if requested
|
|
89
|
-
if (help) {
|
|
90
|
-
print.info(HELP);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
41
|
let protocol;
|
|
94
42
|
try {
|
|
95
43
|
// Checks to make sure codegen doesn't run against
|
|
@@ -104,9 +52,7 @@ exports.default = {
|
|
|
104
52
|
protocol = protocols_1.default.fromDataSources(dataSourcesAndTemplates);
|
|
105
53
|
}
|
|
106
54
|
catch (e) {
|
|
107
|
-
|
|
108
|
-
process.exitCode = 1;
|
|
109
|
-
return;
|
|
55
|
+
this.error(e, { exit: 1 });
|
|
110
56
|
}
|
|
111
57
|
const generator = new type_generator_1.default({
|
|
112
58
|
subgraphManifest: manifest,
|
|
@@ -114,7 +60,7 @@ exports.default = {
|
|
|
114
60
|
skipMigrations,
|
|
115
61
|
protocol,
|
|
116
62
|
uncrashable,
|
|
117
|
-
uncrashableConfig
|
|
63
|
+
uncrashableConfig,
|
|
118
64
|
});
|
|
119
65
|
// Watch working directory for file updates or additions, trigger
|
|
120
66
|
// type generation (if watch argument specified)
|
|
@@ -124,5 +70,36 @@ exports.default = {
|
|
|
124
70
|
else if (!(await generator.generateTypes())) {
|
|
125
71
|
process.exitCode = 1;
|
|
126
72
|
}
|
|
127
|
-
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.default = CodegenCommand;
|
|
76
|
+
CodegenCommand.description = 'Generates AssemblyScript types for a subgraph.';
|
|
77
|
+
CodegenCommand.args = {
|
|
78
|
+
'subgraph-manifest': core_1.Args.string({
|
|
79
|
+
required: true,
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
CodegenCommand.flags = {
|
|
83
|
+
'output-dir': core_1.Flags.string({
|
|
84
|
+
summary: 'Output directory for generated types.',
|
|
85
|
+
char: 'o',
|
|
86
|
+
default: 'generated/',
|
|
87
|
+
}),
|
|
88
|
+
'skip-migrations': core_1.Flags.boolean({
|
|
89
|
+
summary: 'Skip subgraph migrations.',
|
|
90
|
+
}),
|
|
91
|
+
watch: core_1.Flags.boolean({
|
|
92
|
+
summary: 'Regenerate types when subgraph files change.',
|
|
93
|
+
char: 'w',
|
|
94
|
+
}),
|
|
95
|
+
uncrashable: core_1.Flags.boolean({
|
|
96
|
+
summary: 'Generate Float Subgraph Uncrashable helper file.',
|
|
97
|
+
char: 'u',
|
|
98
|
+
}),
|
|
99
|
+
'uncrashable-config': core_1.Flags.string({
|
|
100
|
+
summary: 'Directory for uncrashable config.',
|
|
101
|
+
aliases: ['uc'],
|
|
102
|
+
default: 'uncrashable-config.yaml',
|
|
103
|
+
dependsOn: ['uncrashable'],
|
|
104
|
+
}),
|
|
128
105
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.38.1-alpha-
|
|
2
|
+
"version": "0.38.1-alpha-20230208032550-ddc8362",
|
|
3
3
|
"commands": {
|
|
4
4
|
"add": {
|
|
5
5
|
"id": "add",
|
|
@@ -132,13 +132,61 @@
|
|
|
132
132
|
},
|
|
133
133
|
"codegen": {
|
|
134
134
|
"id": "codegen",
|
|
135
|
-
"description": "Generates AssemblyScript types for a subgraph",
|
|
135
|
+
"description": "Generates AssemblyScript types for a subgraph.",
|
|
136
|
+
"strict": true,
|
|
136
137
|
"pluginName": "@graphprotocol/graph-cli",
|
|
137
138
|
"pluginAlias": "@graphprotocol/graph-cli",
|
|
138
139
|
"pluginType": "core",
|
|
139
140
|
"aliases": [],
|
|
140
|
-
"flags": {
|
|
141
|
-
|
|
141
|
+
"flags": {
|
|
142
|
+
"output-dir": {
|
|
143
|
+
"name": "output-dir",
|
|
144
|
+
"type": "option",
|
|
145
|
+
"char": "o",
|
|
146
|
+
"summary": "Output directory for generated types.",
|
|
147
|
+
"multiple": false,
|
|
148
|
+
"default": "generated/"
|
|
149
|
+
},
|
|
150
|
+
"skip-migrations": {
|
|
151
|
+
"name": "skip-migrations",
|
|
152
|
+
"type": "boolean",
|
|
153
|
+
"summary": "Skip subgraph migrations.",
|
|
154
|
+
"allowNo": false
|
|
155
|
+
},
|
|
156
|
+
"watch": {
|
|
157
|
+
"name": "watch",
|
|
158
|
+
"type": "boolean",
|
|
159
|
+
"char": "w",
|
|
160
|
+
"summary": "Regenerate types when subgraph files change.",
|
|
161
|
+
"allowNo": false
|
|
162
|
+
},
|
|
163
|
+
"uncrashable": {
|
|
164
|
+
"name": "uncrashable",
|
|
165
|
+
"type": "boolean",
|
|
166
|
+
"char": "u",
|
|
167
|
+
"summary": "Generate Float Subgraph Uncrashable helper file.",
|
|
168
|
+
"allowNo": false
|
|
169
|
+
},
|
|
170
|
+
"uncrashable-config": {
|
|
171
|
+
"name": "uncrashable-config",
|
|
172
|
+
"type": "option",
|
|
173
|
+
"summary": "Directory for uncrashable config.",
|
|
174
|
+
"multiple": false,
|
|
175
|
+
"dependsOn": [
|
|
176
|
+
"uncrashable"
|
|
177
|
+
],
|
|
178
|
+
"default": "uncrashable-config.yaml",
|
|
179
|
+
"aliases": [
|
|
180
|
+
"uc"
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"args": {
|
|
185
|
+
"subgraph-manifest": {
|
|
186
|
+
"name": "subgraph-manifest",
|
|
187
|
+
"required": true
|
|
188
|
+
}
|
|
189
|
+
}
|
|
142
190
|
},
|
|
143
191
|
"create": {
|
|
144
192
|
"id": "create",
|
package/package.json
CHANGED