Skip to content

Commit

Permalink
Rollback asc version (#1849)
Browse files Browse the repository at this point in the history
* rollback asc

* add changesets

* chore(dependencies): updated changesets for modified dependencies

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
YaroShkvorets and github-actions[bot] authored Dec 17, 2024
1 parent 8f2f892 commit 00e0a83
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 48 deletions.
5 changes: 5 additions & 0 deletions .changeset/@graphprotocol_graph-cli-1849-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphprotocol/graph-cli": patch
---
dependencies updates:
- Updated dependency [`[email protected]` ↗︎](https://www.npmjs.com/package/assemblyscript/v/0.19.23) (from `0.27.31`, in `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/green-islands-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': minor
---

Update all dependencies
5 changes: 5 additions & 0 deletions .changeset/heavy-socks-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

Fix `graph add` flag parameters parsing
11 changes: 11 additions & 0 deletions .changeset/new-gorillas-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@graphprotocol/graph-cli': minor
---

- add networks registry support
- improve `graph init` flow
- filter through the networks as you type
- more information about the networks
- remove unnecessary options depending on the selection
- ESC key to go back
- allow specifying ipfs/url for substreams package
5 changes: 5 additions & 0 deletions .changeset/short-keys-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

fix bug with clashing \_id field name in schema
5 changes: 5 additions & 0 deletions .changeset/swift-jobs-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

fix generated example entity id uniqueness
5 changes: 5 additions & 0 deletions .changeset/wet-toys-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

rollback asc version
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@oclif/plugin-warn-if-update-available": "^3.1.24",
"@pinax/graph-networks-registry": "^0.6.5",
"@whatwg-node/fetch": "^0.10.1",
"assemblyscript": "0.27.31",
"assemblyscript": "0.19.23",
"binary-install": "^1.1.0",
"chokidar": "4.0.1",
"debug": "4.3.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/command-helpers/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function appendApiVersionForGraph(inputString: string) {
}

// Helper function to construct a subgraph compiler
export async function createCompiler(
export function createCompiler(
manifest: string,
{
ipfs,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class BuildCommand extends Command {
await updateSubgraphNetwork(manifest, network, networkFile, identifierName);
}

const compiler = await createCompiler(manifest, {
const compiler = createCompiler(manifest, {
ipfs,
outputDir,
outputFormat,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export default class DeployCommand extends Command {
await updateSubgraphNetwork(manifest, network, networkFile, identifierName);
}

const compiler = await createCompiler(manifest, {
const compiler = createCompiler(manifest, {
ipfs,
headers,
outputDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default class PublishCommand extends Command {
this.error(e, { exit: 1 });
}

const compiler = await createCompiler(manifest, {
const compiler = createCompiler(manifest, {
ipfs,
outputDir: 'build/',
outputFormat: 'wasm',
Expand Down
25 changes: 20 additions & 5 deletions packages/cli/src/compiler/asc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import asc from 'assemblyscript/asc';
import * as asc from 'assemblyscript/cli/asc';

const createExitHandler = (inputFile: string) => () => {
throw new Error(`The AssemblyScript compiler crashed when compiling this file: '${inputFile}'
Expand All @@ -14,14 +14,28 @@ const setupExitHandler = (exitHandler: (code: number) => void) =>
const removeExitHandler = (exitHandler: (code: number) => void) =>
process.removeListener('exit', exitHandler);

const assemblyScriptCompiler = async (argv: string[], options: asc.APIOptions) =>
await asc.main(argv, options);
// Important note, the `asc.main` callback function parameter is synchronous,
// that's why this function doesn't need to be `async` and the throw works properly.
const assemblyScriptCompiler = (argv: string[], options: asc.APIOptions) =>
asc.main(argv, options, err => {
if (err) {
throw err;
}
return 0;
});

const compilerDefaults = {
stdout: process.stdout,
stderr: process.stdout,
};

// You MUST call this function once before compiling anything.
// Internally it just delegates to the AssemblyScript compiler
// which just delegates to the binaryen lib.
export const ready = async () => {
await asc.ready;
};

export interface CompileOptions {
inputFile: string;
global: string;
Expand All @@ -34,12 +48,13 @@ export interface CompileOptions {
// it requires an asynchronous wait. Whenever you call this function,
// it doesn't matter how many times, just make sure you call `ready`
// once before everything..
export const compile = async ({ inputFile, global, baseDir, libs, outputFile }: CompileOptions) => {
export const compile = ({ inputFile, global, baseDir, libs, outputFile }: CompileOptions) => {
const exitHandler = createExitHandler(inputFile);

setupExitHandler(exitHandler);

const compilerArgs = [
'--explicitStart',
'--exportRuntime',
'--runtime',
'stub',
Expand All @@ -55,7 +70,7 @@ export const compile = async ({ inputFile, global, baseDir, libs, outputFile }:
'--debug',
];

await assemblyScriptCompiler(compilerArgs, compilerDefaults);
assemblyScriptCompiler(compilerArgs, compilerDefaults);

// only if compiler succeeded, that is, when the line above doesn't throw
removeExitHandler(exitHandler);
Expand Down
63 changes: 27 additions & 36 deletions packages/cli/src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,41 +246,32 @@ export default class Compiler {
// Cache compiled files so identical input files are only compiled once
const compiledFiles = new Map();

// Handle data sources
const dataSources = subgraph.get('dataSources');
const compiledDataSources = await Promise.all(
dataSources.map(async (dataSource: any) => {
const mappingPath = dataSource.getIn(['mapping', 'file']);
const compiledPath = await this._compileDataSourceMapping(
this.protocol,
dataSource,
mappingPath,
compiledFiles,
spinner,
validate,
);
return dataSource.setIn(['mapping', 'file'], compiledPath);
}),
);
subgraph = subgraph.set('dataSources', compiledDataSources);

// Handle templates if they exist
const templates = subgraph.get('templates');
if (templates !== undefined) {
const compiledTemplates = await Promise.all(
templates.map(async (template: any) => {
const mappingPath = template.getIn(['mapping', 'file']);
const compiledPath = await this._compileTemplateMapping(
template,
await asc.ready();

subgraph = subgraph.update('dataSources', (dataSources: any[]) =>
dataSources.map((dataSource: any) =>
dataSource.updateIn(['mapping', 'file'], (mappingPath: string) =>
this._compileDataSourceMapping(
this.protocol,
dataSource,
mappingPath,
compiledFiles,
spinner,
);
return template.setIn(['mapping', 'file'], compiledPath);
}),
);
subgraph = subgraph.set('templates', compiledTemplates);
}
validate,
),
),
),
);

subgraph = subgraph.update('templates', (templates: any) =>
templates === undefined
? templates
: templates.map((template: any) =>
template.updateIn(['mapping', 'file'], (mappingPath: string) =>
this._compileTemplateMapping(template, mappingPath, compiledFiles, spinner),
),
),
);

return subgraph;
},
Expand Down Expand Up @@ -343,7 +334,7 @@ export default class Compiler {
return missingHandlers;
}

async _compileDataSourceMapping(
_compileDataSourceMapping(
protocol: Protocol,
dataSource: immutable.Map<any, any>,
mappingPath: string,
Expand Down Expand Up @@ -397,7 +388,7 @@ export default class Compiler {
}
const global = path.relative(baseDir, this.globalsFile);

await asc.compile({
asc.compile({
inputFile,
global,
baseDir,
Expand All @@ -424,7 +415,7 @@ export default class Compiler {
}
}

async _compileTemplateMapping(
_compileTemplateMapping(
template: immutable.Collection<any, any>,
mappingPath: string,
compiledFiles: Map<any, any>,
Expand Down Expand Up @@ -478,7 +469,7 @@ export default class Compiler {
}
const global = path.relative(baseDir, this.globalsFile);

await asc.compile({
asc.compile({
inputFile,
global,
baseDir,
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00e0a83

Please sign in to comment.