(projectPath: string, project: ProjectSpecBase)
| 18 | } from './init-controller'; |
| 19 | |
| 20 | async function testYAML(projectPath: string, project: ProjectSpecBase): Promise<{old: Document; new: Document}> { |
| 21 | const yamlPath = path.join(`${projectPath}`, `project.yaml`); |
| 22 | const manifest = await fs.promises.readFile(yamlPath, 'utf8'); |
| 23 | const data = parseDocument(manifest); |
| 24 | |
| 25 | const clonedData = data.clone(); |
| 26 | clonedData.set('description', project.description ?? data.get('description')); |
| 27 | |
| 28 | // network type should be collection |
| 29 | const network: any = clonedData.get('network'); |
| 30 | network.set('endpoint', 'http://def not real endpoint'); |
| 31 | clonedData.set('version', 'not real version'); |
| 32 | clonedData.set('name', 'not real name'); |
| 33 | |
| 34 | if (isProjectSpecV1_0_0(project)) { |
| 35 | network.set('chainId', 'random chainId'); |
| 36 | } else if (isProjectSpecV0_2_0(project)) { |
| 37 | network.set('genesisHash', 'random genesisHash'); |
| 38 | } |
| 39 | return { |
| 40 | old: data, |
| 41 | new: clonedData, |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | async function fileExists(file: string): Promise<boolean> { |
| 46 | await fs.promises.access(file, fs.constants.F_OK); |
no test coverage detected