Skip to content

Commit

Permalink
Fix ts manifest build failing because of missing deps
Browse files Browse the repository at this point in the history
  • Loading branch information
stwiname committed Oct 23, 2023
1 parent 64d920c commit beda318
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"terser-webpack-plugin": "^5.3.7",
"ts-loader": "^9.2.6",
"tslib": "^2.3.1",
"typescript": ">=5.2.2",
"update-notifier": "5.1.0",
"webpack": "^5.76.0",
"webpack-merge": "^5.8.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/utils/build.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {execFile} from 'child_process';
import {existsSync, lstatSync} from 'fs';
import util from 'node:util';
import path from 'path';
import {Command} from '@oclif/core';
import {DEFAULT_TS_MANIFEST, extensionIsTs, tsProjectYamlPath} from '@subql/common';
import {DEFAULT_TS_MANIFEST, tsProjectYamlPath} from '@subql/common';
import * as ts from 'typescript';

const requireScriptWrapper = (scriptPath: string, outputPath: string): string =>
`import {toJsonObject} from '@subql/common';` +
Expand Down Expand Up @@ -38,14 +37,15 @@ export async function buildManifestFromLocation(location: string, command: Comma
return directory;
}

// eslint-disable-next-line @typescript-eslint/require-await
async function generateManifestFromTs(projectManifestEntry: string, command: Command): Promise<void> {
const projectYamlPath = tsProjectYamlPath(projectManifestEntry);
try {
await util.promisify(execFile)(
'npx',
['ts-node', '-e', requireScriptWrapper(projectManifestEntry, projectYamlPath)],
{cwd: path.dirname(projectManifestEntry)}
);
const result = ts.transpileModule(requireScriptWrapper(projectManifestEntry, projectYamlPath), {});

// Run the compiled output
eval(result.outputText);

command.log(`Project manifest generated to ${projectYamlPath}`);
} catch (error) {
throw new Error(`Failed to build ${projectManifestEntry}: ${error}`);
Expand Down
75 changes: 39 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6246,6 +6246,7 @@ __metadata:
terser-webpack-plugin: ^5.3.7
ts-loader: ^9.2.6
tslib: ^2.3.1
typescript: ^5.2.2
update-notifier: 5.1.0
webpack: ^5.76.0
webpack-merge: ^5.8.0
Expand Down Expand Up @@ -6388,11 +6389,19 @@ __metadata:
languageName: unknown
linkType: soft

"@subql/common@npm:3.1.1":
version: 3.1.1
resolution: "@subql/common@npm:3.1.1"
"@subql/common@^3.1.0, @subql/common@^3.1.1, @subql/common@workspace:*, @subql/common@workspace:packages/common":
version: 0.0.0-use.local
resolution: "@subql/common@workspace:packages/common"
dependencies:
"@subql/types-core": 0.1.1
"@subql/types-core": "workspace:*"
"@types/bn.js": 4.11.6
"@types/detect-port": ^1
"@types/fs-extra": ^9.0.13
"@types/js-yaml": ^4.0.5
"@types/pino": ^6.3.12
"@types/semver": ^7.3.9
"@types/tar": ^6.1.1
"@types/update-notifier": ^6
axios: ^0.27.2
class-transformer: ^0.5.1
class-validator: ^0.14.0
Expand All @@ -6402,13 +6411,12 @@ __metadata:
reflect-metadata: ^0.1.13
semver: ^7.5.2
update-notifier: 5.1.0
checksum: 1d1e3070f0a2f2368a7ba24f9b98012ca88362d51e7e53ed146026aa8c2844e8d58335496a19341facf4422aa2cac89b05e87860b0a4f73e542ca91f8240cdd0
languageName: node
linkType: hard
languageName: unknown
linkType: soft

"@subql/common@npm:^3.1.0, @subql/common@npm:^3.1.1":
version: 3.1.2
resolution: "@subql/common@npm:3.1.2"
"@subql/common@npm:3.1.1":
version: 3.1.1
resolution: "@subql/common@npm:3.1.1"
dependencies:
"@subql/types-core": 0.1.1
axios: ^0.27.2
Expand All @@ -6420,35 +6428,10 @@ __metadata:
reflect-metadata: ^0.1.13
semver: ^7.5.2
update-notifier: 5.1.0
checksum: e979fac54089276de67a3a498bdf53396ac3726542d9f38350bced06f45921ab937a885a9c6cf183f3f5e7c82877c8ce9e27a5a5bf1f6fae6113baf68b4b3e55
checksum: 1d1e3070f0a2f2368a7ba24f9b98012ca88362d51e7e53ed146026aa8c2844e8d58335496a19341facf4422aa2cac89b05e87860b0a4f73e542ca91f8240cdd0
languageName: node
linkType: hard

"@subql/common@workspace:*, @subql/common@workspace:packages/common":
version: 0.0.0-use.local
resolution: "@subql/common@workspace:packages/common"
dependencies:
"@subql/types-core": "workspace:*"
"@types/bn.js": 4.11.6
"@types/detect-port": ^1
"@types/fs-extra": ^9.0.13
"@types/js-yaml": ^4.0.5
"@types/pino": ^6.3.12
"@types/semver": ^7.3.9
"@types/tar": ^6.1.1
"@types/update-notifier": ^6
axios: ^0.27.2
class-transformer: ^0.5.1
class-validator: ^0.14.0
fs-extra: ^10.1.0
ipfs-http-client: 56
js-yaml: ^4.1.0
reflect-metadata: ^0.1.13
semver: ^7.5.2
update-notifier: 5.1.0
languageName: unknown
linkType: soft

"@subql/node-core@workspace:*, @subql/node-core@workspace:packages/node-core":
version: 0.0.0-use.local
resolution: "@subql/node-core@workspace:packages/node-core"
Expand Down Expand Up @@ -21685,6 +21668,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:^5.2.2":
version: 5.2.2
resolution: "typescript@npm:5.2.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c
languageName: node
linkType: hard

"typescript@patch:typescript@^4.9.5#~builtin<compat/typescript>":
version: 4.9.5
resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=493e53"
Expand All @@ -21695,6 +21688,16 @@ __metadata:
languageName: node
linkType: hard

"typescript@patch:typescript@^5.2.2#~builtin<compat/typescript>":
version: 5.2.2
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=493e53"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 07106822b4305de3f22835cbba949a2b35451cad50888759b6818421290ff95d522b38ef7919e70fb381c5fe9c1c643d7dea22c8b31652a717ddbd57b7f4d554
languageName: node
linkType: hard

"typical@npm:^4.0.0":
version: 4.0.0
resolution: "typical@npm:4.0.0"
Expand Down

0 comments on commit beda318

Please sign in to comment.