(projectPath: string)
| 139 | } |
| 140 | |
| 141 | export async function readDefaults(projectPath: string): Promise<{ |
| 142 | endpoint: ProjectNetworkConfig['endpoint']; |
| 143 | author: string; |
| 144 | description: string; |
| 145 | isMultiChainProject: boolean; |
| 146 | }> { |
| 147 | const packageData = await fs.promises.readFile(`${projectPath}/package.json`); |
| 148 | const currentPackage = JSON.parse(packageData.toString()); |
| 149 | const author: string = currentPackage.author; |
| 150 | const description: string = currentPackage.description; |
| 151 | let endpoint: ProjectNetworkConfig['endpoint']; |
| 152 | let isMultiChainProject = false; |
| 153 | const defaultTsPath = defaultTSManifestPath(projectPath); |
| 154 | const defaultYamlPath = defaultYamlManifestPath(projectPath); |
| 155 | const defaultMultiChainPath = defaultMultiChainYamlManifestPath(projectPath); |
| 156 | |
| 157 | if (fs.existsSync(defaultTsPath)) { |
| 158 | const tsManifest = await fs.promises.readFile(defaultTsPath, 'utf8'); |
| 159 | const extractedTsValues = extractFromTs(tsManifest.toString(), { |
| 160 | endpoint: ENDPOINT_REG, |
| 161 | }); |
| 162 | |
| 163 | endpoint = extractedTsValues.endpoint ?? []; |
| 164 | } else if (fs.existsSync(defaultYamlPath)) { |
| 165 | const yamlManifest = await fs.promises.readFile(defaultYamlPath, 'utf8'); |
| 166 | const extractedYamlValues = parseDocument(yamlManifest).toJS() as ProjectManifestV1_0_0; |
| 167 | endpoint = extractedYamlValues.network.endpoint; |
| 168 | } else if (fs.existsSync(defaultMultiChainPath)) { |
| 169 | endpoint = []; |
| 170 | isMultiChainProject = true; |
| 171 | } else { |
| 172 | throw new Error('Failed to read manifest file while preparing the project'); |
| 173 | } |
| 174 | |
| 175 | return {endpoint, author, description, isMultiChainProject}; |
| 176 | } |
| 177 | |
| 178 | export async function prepare( |
| 179 | projectPath: string, |
no test coverage detected