(projectPath: string, project: ProjectSpecBase)
| 299 | } |
| 300 | |
| 301 | export async function prepareEnv(projectPath: string, project: ProjectSpecBase): Promise<void> { |
| 302 | //load and write manifest(project.ts/project.yaml) |
| 303 | const envPath = defaultEnvPath(projectPath); |
| 304 | const envDevelopPath = defaultEnvDevelopPath(projectPath); |
| 305 | const envLocalPath = defaultEnvLocalPath(projectPath); |
| 306 | const envDevelopLocalPath = defaultEnvDevelopLocalPath(projectPath); |
| 307 | |
| 308 | let chainId; |
| 309 | if (isProjectSpecV1_0_0(project)) { |
| 310 | chainId = project.chainId; |
| 311 | } else { |
| 312 | const tsPath = defaultTSManifestPath(projectPath); |
| 313 | const tsManifest = (await fs.promises.readFile(tsPath, 'utf8')).toString(); |
| 314 | |
| 315 | const match = tsManifest.match(CAPTURE_CHAIN_ID_REG); |
| 316 | if (match) { |
| 317 | chainId = match[2]; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | //adding env configs |
| 322 | const endpointStr = Array.isArray(project.endpoint) ? project.endpoint.join(',') : JSON.stringify(project.endpoint); |
| 323 | |
| 324 | const envData = `ENDPOINT=${endpointStr}\nCHAIN_ID=${chainId}`; |
| 325 | await fs.promises.writeFile(envPath, envData, 'utf8'); |
| 326 | await fs.promises.writeFile(envDevelopPath, envData, 'utf8'); |
| 327 | await fs.promises.writeFile(envLocalPath, envData, 'utf8'); |
| 328 | await fs.promises.writeFile(envDevelopLocalPath, envData, 'utf8'); |
| 329 | } |
| 330 | |
| 331 | export async function prepareGitIgnore(projectPath: string): Promise<void> { |
| 332 | //load and write .gitignore |
no test coverage detected