|
| 1 | +import fs from 'fs-extra'; |
| 2 | +import { join } from 'path'; |
| 3 | + |
| 4 | +async function collectionCopy(rootDir: string) { |
| 5 | + // move optimized svgs to correct collection location |
| 6 | + const optimizedSrc = join(rootDir, 'dist', 'ionicons', 'svg'); |
| 7 | + const collectionDest = join(rootDir, 'dist', 'collection', 'components', 'icon', 'svg'); |
| 8 | + await fs.copy(optimizedSrc, collectionDest); |
| 9 | + |
| 10 | + // we don't to copy the src svgs to collection |
| 11 | + await fs.remove(join(rootDir, 'dist', 'collection', 'svg')); |
| 12 | + // We don't want to copy the test svg assets to collection |
| 13 | + await fs.remove(join(rootDir, 'dist', 'collection', 'components', 'test')); |
| 14 | + |
| 15 | + const cePackageDir = join(rootDir, 'components'); |
| 16 | + const cePackageJsonPath = join(cePackageDir, 'package.json'); |
| 17 | + const ceCjsPath = join(cePackageDir, 'index.cjs.js'); |
| 18 | + |
| 19 | + const emptyCjs = `/*empty cjs*/`; |
| 20 | + await fs.writeFile(ceCjsPath, emptyCjs); |
| 21 | + |
| 22 | + const cePackageJson = { |
| 23 | + name: 'ionicons/components', |
| 24 | + description: 'Ionicons custom element.', |
| 25 | + main: './index.cjs.js', |
| 26 | + module: './index.js', |
| 27 | + types: './index.d.ts', |
| 28 | + private: true, |
| 29 | + }; |
| 30 | + await fs.writeFile(cePackageJsonPath, JSON.stringify(cePackageJson, null, 2)); |
| 31 | + |
| 32 | + // this is temporary!!!! |
| 33 | + // removing the `type` from the d.ts export |
| 34 | + // to make it easier for users migrating between |
| 35 | + // of older versions of angular and typescript |
| 36 | + // to the newer verisons, where the `type` keyword |
| 37 | + // is used. This is a megahack, no doubt. |
| 38 | + const typesDist = join(rootDir, 'dist', 'types', 'index.d.ts'); |
| 39 | + let types = await fs.readFile(typesDist, 'utf8'); |
| 40 | + types = types.replace('export type', 'export'); |
| 41 | + await fs.writeFile(typesDist, types); |
| 42 | +} |
| 43 | + |
| 44 | +collectionCopy(join(__dirname, '..')); |
0 commit comments