| Total Complexity | 3 |
| Complexity/F | 3 |
| Lines of Code | 42 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import fs from 'fs'; |
||
| 2 | import path from 'path'; |
||
| 3 | import entitySchema from "../../test/_mocks_/entity-schema.json"; |
||
| 4 | import { EntitySchemaConverter } from "./entity-schema-converter"; |
||
| 5 | |||
| 6 | async function main() { |
||
| 7 | const gitCommitTag = process.env.CI_COMMIT_TAG; |
||
| 8 | |||
| 9 | if (!gitCommitTag || typeof gitCommitTag !== 'string') { |
||
| 10 | throw new Error('No git commit tag found. Please set the CI_COMMIT_TAG environment variable.'); |
||
| 11 | } |
||
| 12 | |||
| 13 | const converter = new EntitySchemaConverter(); |
||
| 14 | const packageName = '@shopware-ag/entity-schema-types' |
||
| 15 | const folderPackagePath = path.join(__dirname, '../../entity-schema-types'); |
||
| 16 | const definitionFileName = 'entity-schema-definition.d.ts'; |
||
| 17 | const packageVersion = gitCommitTag.replace('v6.', ''); |
||
| 18 | |||
| 19 | // Delete package folder if exists |
||
| 20 | if (fs.existsSync(folderPackagePath)) { |
||
| 21 | // @ts-ignore |
||
| 22 | fs.rmSync(folderPackagePath, { recursive: true }); |
||
| 23 | } |
||
| 24 | |||
| 25 | // Create new empty package folder |
||
| 26 | fs.mkdirSync(folderPackagePath); |
||
| 27 | |||
| 28 | // Create package.json |
||
| 29 | fs.writeFileSync(path.join(folderPackagePath, 'package.json'), JSON.stringify({ |
||
| 30 | name: packageName, |
||
| 31 | version: packageVersion, |
||
| 32 | description: 'TypeScript definition file for the corresponding entity schema', |
||
| 33 | license: 'MIT', |
||
| 34 | types: definitionFileName, |
||
| 35 | }, null, 4)); |
||
| 36 | |||
| 37 | // @ts-ignore |
||
| 38 | converter.convert(entitySchema, path.join(folderPackagePath, definitionFileName)); |
||
| 39 | } |
||
| 40 | |||
| 41 | main(); |
||
| 42 |