forked from subquery/subql
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
28 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,10 @@ | ||
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
import fs from 'fs'; | ||
import path from 'path'; | ||
import {loadFromJsonOrYaml} from '@subql/common'; | ||
import {EthereumProjectManifestVersioned, VersionedProjectManifest} from './versioned'; | ||
|
||
export function parseEthereumProjectManifest(raw: unknown): EthereumProjectManifestVersioned { | ||
const projectManifest = new EthereumProjectManifestVersioned(raw as VersionedProjectManifest); | ||
projectManifest.validate(); | ||
return projectManifest; | ||
} | ||
|
||
export function loadEthereumProjectManifest(file: string): EthereumProjectManifestVersioned { | ||
let manifestPath = file; | ||
if (fs.existsSync(file) && fs.lstatSync(file).isDirectory()) { | ||
const yamlFilePath = path.join(file, 'project.yaml'); | ||
const jsonFilePath = path.join(file, 'project.json'); | ||
if (fs.existsSync(yamlFilePath)) { | ||
manifestPath = yamlFilePath; | ||
} else if (fs.existsSync(jsonFilePath)) { | ||
manifestPath = jsonFilePath; | ||
} else { | ||
throw new Error(`Could not find project manifest under dir ${file}`); | ||
} | ||
} | ||
|
||
const doc = loadFromJsonOrYaml(manifestPath); | ||
const projectManifest = new EthereumProjectManifestVersioned(doc as VersionedProjectManifest); | ||
projectManifest.validate(); | ||
return projectManifest; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters