Skip to content

Commit 5d34943

Browse files
fix: add missing collection-copy script
1 parent f81cf00 commit 5d34943

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"build": "run-s clean build.* prettier",
4747
"build.files": "tsx scripts/build.ts",
4848
"build.component": "stencil build",
49+
"build.collection": "tsx scripts/collection-copy.ts",
4950
"clean": "rimraf dist components icons www",
5051
"prettier": "npm run prettier.base -- --write",
5152
"prettier.base": "prettier --cache \"./({bin,scripts,src,test}/**/*.{ts,tsx,js,jsx})|bin/stencil|.github/(**/)?*.(yml|yaml)|*.js\"",
@@ -69,7 +70,7 @@
6970
"fs-extra": "^11.3.0",
7071
"jest": "^30.0.4",
7172
"jest-cli": "^30.0.4",
72-
"jest-stencil-runner": "^0.0.7",
73+
"jest-stencil-runner": "^0.0.8",
7374
"npm-run-all2": "^8.0.4",
7475
"prettier": "^3.6.2",
7576
"puppeteer": "^24.12.0",

scripts/collection-copy.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

Comments
 (0)