@react-native-vector-icons/common 0.0.1-alpha.10 → 0.0.1-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -8
- package/lib/commonjs/create-icon-set.js +2 -18
- package/lib/commonjs/create-icon-set.js.map +1 -1
- package/lib/commonjs/ensure-native-module-available.js +1 -1
- package/lib/commonjs/ensure-native-module-available.js.map +1 -1
- package/lib/commonjs/scripts/common.js +49 -0
- package/lib/commonjs/scripts/common.js.map +1 -0
- package/lib/commonjs/scripts/getFonts.js +6 -40
- package/lib/commonjs/scripts/getFonts.js.map +1 -1
- package/lib/commonjs/scripts/updatePlist.js +54 -0
- package/lib/commonjs/scripts/updatePlist.js.map +1 -0
- package/lib/module/create-icon-set.js +1 -17
- package/lib/module/create-icon-set.js.map +1 -1
- package/lib/module/scripts/common.js +41 -0
- package/lib/module/scripts/common.js.map +1 -0
- package/lib/module/scripts/getFonts.js +6 -39
- package/lib/module/scripts/getFonts.js.map +1 -1
- package/lib/module/scripts/updatePlist.js +49 -0
- package/lib/module/scripts/updatePlist.js.map +1 -0
- package/lib/typescript/src/create-icon-set.d.ts.map +1 -1
- package/lib/typescript/src/scripts/common.d.ts +2 -0
- package/lib/typescript/src/scripts/common.d.ts.map +1 -0
- package/lib/typescript/src/scripts/updatePlist.d.ts +3 -0
- package/lib/typescript/src/scripts/updatePlist.d.ts.map +1 -0
- package/package.json +15 -10
- package/react-native-vector-icons.podspec +40 -15
- package/src/create-icon-set.tsx +0 -20
- package/src/scripts/common.ts +51 -0
- package/src/scripts/getFonts.ts +6 -47
- package/src/scripts/updatePlist.ts +60 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
[](https://npmjs.com/package/@react-native-vector-icons/common.svg) [](https://npmjs.com/package/@react-native-vector-icons/common)
|
|
4
4
|
|
|
5
5
|
# React Native Vector Icons
|
|
6
6
|
|
|
@@ -11,6 +11,9 @@ extension and styling effortless.
|
|
|
11
11
|
|
|
12
12
|
For the integration of `.svg` files natively, you can explore [`react-native-vector-image`](https://github.com/oblador/react-native-vector-image).
|
|
13
13
|
|
|
14
|
+
> [!TIP]
|
|
15
|
+
> If you are still using the old single package `react-native-vector-icons` please visit https://github.com/oblador/react-native-vector-icons/tree/legacy
|
|
16
|
+
|
|
14
17
|
## Table of Contents
|
|
15
18
|
|
|
16
19
|
- [Sponsorship](#sponsorship)
|
|
@@ -42,14 +45,14 @@ Should you find this library beneficial, kindly contemplate the option of
|
|
|
42
45
|
|
|
43
46
|
RNVI comes with the following supported icons. You can [search NPM](https://www.npmjs.com/search?q=keywords%3Areact-native-vector-icons-icon) for third party icons.
|
|
44
47
|
|
|
45
|
-
### Actively maintained
|
|
48
|
+
### Actively maintained
|
|
46
49
|
- [`AntDesign`](https://ant.design/components/icon) from Ant Group (v4.4.2 with _449_ icons)
|
|
47
50
|
- [`Feather`](http://feathericons.com) created by Cole Bemis & Contributors (v4.29.2 featuring _287_ icons)
|
|
48
|
-
- [`FontAwesome 6`](https://fontawesome.com/search) designed by Fonticons, Inc. (v6.
|
|
51
|
+
- [`FontAwesome 6`](https://fontawesome.com/search) designed by Fonticons, Inc. (v6.6.0 featuring _2050_ free and _30213_ pro icons)
|
|
49
52
|
- [`Foundation`](http://zurb.com/playground/foundation-icon-fonts-3) by ZURB, Inc. (v3.0 with _283_ icons)
|
|
50
53
|
- [`Ionicons`](https://ionic.io/ionicons) crafted by Ionic (v7.4.0 containing _1356_ icons)
|
|
51
54
|
- [`MaterialDesignIcons`](https://pictogrammers.com/library/mdi/) from MaterialDesignIcons.com (v7.4.47 including _7448_ icons)
|
|
52
|
-
- [`Octicons`](https://primer.style/foundations/icons) designed by Github, Inc. (v19.
|
|
55
|
+
- [`Octicons`](https://primer.style/foundations/icons) designed by Github, Inc. (v19.11.0 with _331_ icons)
|
|
53
56
|
|
|
54
57
|
### No longer maintained upstream
|
|
55
58
|
- [`Entypo`](http://entypo.com) by Daniel Bruce (v1.0.1 with _411_ icons)
|
|
@@ -75,16 +78,16 @@ See [MIGRATION.md](MIGRATION.md) if you are migrating from `react-native-vector-
|
|
|
75
78
|
```sh
|
|
76
79
|
npm install --save @react-native-vector-icons/fontawesome6 @react-native-vector-icons/evilicons
|
|
77
80
|
```
|
|
78
|
-
1. Depending on the platform you're targeting (iOS/Android/Windows), follow the appropriate setup instructions.
|
|
81
|
+
1. Depending on the platform you're targeting (iOS/Android/Windows), follow the appropriate setup instructions below.
|
|
79
82
|
1. If you are using one of the following fonts refer to their guides for further instructions
|
|
80
|
-
* [FontAwesome 5](packages/fontawesome5/README.md)
|
|
81
|
-
* [FontAwesome 5 Pro](packages/fontawesome5-pro/README.md)
|
|
82
83
|
* [FontAwesome 6](packages/fontawesome6/README.md)
|
|
83
84
|
* [FontAwesome 6 Pro](packages/fontawesome6-pro/README.md)
|
|
85
|
+
* [FontAwesome 5](packages/fontawesome5/README.md)
|
|
86
|
+
* [FontAwesome 5 Pro](packages/fontawesome5-pro/README.md)
|
|
84
87
|
* [Fontello](packages/fontello/README.md)
|
|
85
88
|
* [Icomoon](packages/icomoon/README.md)
|
|
86
89
|
|
|
87
|
-
###
|
|
90
|
+
### Android
|
|
88
91
|
|
|
89
92
|
Nothing else needed.
|
|
90
93
|
|
|
@@ -92,6 +95,40 @@ Nothing else needed.
|
|
|
92
95
|
|
|
93
96
|
To use the bundled icons on iOS, follow these steps:
|
|
94
97
|
|
|
98
|
+
1. Edit `Info.plist` and add a property called **Fonts provided by application** (or **UIAppFonts** if Xcode autocomplete is not working):
|
|
99
|
+
<details>
|
|
100
|
+
<summary>List of all available fonts to copy & paste in Info.plist</summary>
|
|
101
|
+
```xml
|
|
102
|
+
<key>UIAppFonts</key>
|
|
103
|
+
<array>
|
|
104
|
+
<string>AntDesign.ttf</string>
|
|
105
|
+
<string>Entypo.ttf</string>
|
|
106
|
+
<string>EvilIcons.ttf</string>
|
|
107
|
+
<string>Feather.ttf</string>
|
|
108
|
+
<string>FontAwesome.ttf</string>
|
|
109
|
+
<string>FontAwesome5_Brands.ttf</string>
|
|
110
|
+
<string>FontAwesome5_Regular.ttf</string>
|
|
111
|
+
<string>FontAwesome5_Solid.ttf</string>
|
|
112
|
+
<string>FontAwesome6_Brands.ttf</string>
|
|
113
|
+
<string>FontAwesome6_Regular.ttf</string>
|
|
114
|
+
<string>FontAwesome6_Solid.ttf</string>
|
|
115
|
+
<string>Fontisto.ttf</string>
|
|
116
|
+
<string>Foundation.ttf</string>
|
|
117
|
+
<string>Ionicons.ttf</string>
|
|
118
|
+
<string>MaterialDesignIcons.ttf</string>
|
|
119
|
+
<string>MaterialIcons.ttf</string>
|
|
120
|
+
<string>Octicons.ttf</string>
|
|
121
|
+
<string>SimpleLineIcons.ttf</string>
|
|
122
|
+
<string>Zocial.ttf</string>
|
|
123
|
+
</array>
|
|
124
|
+
```
|
|
125
|
+
</details>
|
|
126
|
+
|
|
127
|
+
Alternatively you can use the included script to update it for you.
|
|
128
|
+
```sh
|
|
129
|
+
npm run rnvi-update-plist packages.json ios/AppName/Info.plist
|
|
130
|
+
```
|
|
131
|
+
|
|
95
132
|
1. Update your pods
|
|
96
133
|
```sh
|
|
97
134
|
cd ios && pod update
|
|
@@ -9,10 +9,10 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
var _NativeVectorIcons = _interopRequireDefault(require("./NativeVectorIcons"));
|
|
10
10
|
var _createIconSourceCache = _interopRequireDefault(require("./create-icon-source-cache"));
|
|
11
11
|
var _ensureNativeModuleAvailable = _interopRequireDefault(require("./ensure-native-module-available"));
|
|
12
|
-
function _interopRequireDefault(
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
15
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
16
16
|
const DEFAULT_ICON_SIZE = exports.DEFAULT_ICON_SIZE = 12;
|
|
17
17
|
const DEFAULT_ICON_COLOR = exports.DEFAULT_ICON_COLOR = 'black';
|
|
18
18
|
const createIconSet = (glyphMap, fontFamily, fontFile, fontStyle) => {
|
|
@@ -112,22 +112,6 @@ const createIconSet = (glyphMap, fontFamily, fontFile, fontStyle) => {
|
|
|
112
112
|
throw error;
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
-
const loadFont = async () => {
|
|
116
|
-
if (_reactNative.Platform.OS !== 'ios') {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
(0, _ensureNativeModuleAvailable.default)();
|
|
120
|
-
const [filename, extension] = fontFile.split('.'); // FIXME: what if filename has two dots?
|
|
121
|
-
if (!filename) {
|
|
122
|
-
// NOTE: Thie is impossible but TypeScript doesn't know that
|
|
123
|
-
throw new Error('Font needs a filename.');
|
|
124
|
-
}
|
|
125
|
-
if (!extension) {
|
|
126
|
-
throw new Error('Font needs a filename extensison.');
|
|
127
|
-
}
|
|
128
|
-
await _NativeVectorIcons.default.loadFontWithFileName(filename, extension, 'react-native-vector-icons');
|
|
129
|
-
};
|
|
130
|
-
loadFont();
|
|
131
115
|
const IconNamespace = Object.assign(WrappedIcon, {
|
|
132
116
|
getImageSource,
|
|
133
117
|
getImageSourceSync
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_NativeVectorIcons","_interopRequireDefault","_createIconSourceCache","_ensureNativeModuleAvailable","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_NativeVectorIcons","_interopRequireDefault","_createIconSourceCache","_ensureNativeModuleAvailable","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","DEFAULT_ICON_SIZE","exports","DEFAULT_ICON_COLOR","createIconSet","glyphMap","fontFamily","fontFile","fontStyle","fontBasename","replace","fontReference","Platform","select","windows","android","web","resolveGlyph","name","glyph","String","fromCodePoint","Icon","size","color","style","children","allowFontScaling","innerRef","props","styleDefaults","fontSize","styleOverrides","fontWeight","newProps","createElement","Text","ref","selectable","WrappedIcon","forwardRef","displayName","imageSourceCache","createIconSourceCache","getImageSourceSync","ensureNativeModuleAvailable","processedColor","processColor","cacheKey","imagePath","NativeIconAPI","getImageForFontSync","value","uri","scale","PixelRatio","setValue","error","setError","getImageSource","getImageForFont","IconNamespace"],"sourceRoot":"../../src","sources":["create-icon-set.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,4BAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA2E,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,C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C,GAAG,EAAEJ,SAAS;QAAEK,KAAK,EAAEC,uBAAU,CAACxE,GAAG,CAAC;MAAE,CAAC;MACzD2D,gBAAgB,CAACc,QAAQ,CAACR,QAAQ,EAAEI,KAAK,CAAC;MAC1C,OAAOA,KAAK;IACd,CAAC,CAAC,OAAOK,KAAK,EAAE;MACdf,gBAAgB,CAACgB,QAAQ,CAACV,QAAQ,EAAES,KAAc,CAAC;MACnD,MAAMA,KAAK;IACb;EACF,CAAC;EAED,MAAMI,aAAa,GAAG1E,MAAM,CAACS,MAAM,CAAC2C,WAAW,EAAE;IAC/CoB,cAAc;IACdf;EACF,CAAC,CAAC;EAEF,OAAOiB,aAAa;AACtB,CAAC;AAAC3D,OAAA,CAAAE,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = ensureNativeModuleAvailable;
|
|
7
7
|
var _NativeVectorIcons = _interopRequireDefault(require("./NativeVectorIcons"));
|
|
8
|
-
function _interopRequireDefault(
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
function ensureNativeModuleAvailable() {
|
|
10
10
|
if (!_NativeVectorIcons.default) {
|
|
11
11
|
throw new Error('The native RNVectorIcons API is not available, did you properly integrate the module? Please verify your autolinking setup and recompile.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_NativeVectorIcons","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"names":["_NativeVectorIcons","_interopRequireDefault","require","e","__esModule","default","ensureNativeModuleAvailable","NativeIconAPI","Error"],"sourceRoot":"../../src","sources":["ensure-native-module-available.ts"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjC,SAASG,2BAA2BA,CAAA,EAAG;EACpD,IAAI,CAACC,0BAAa,EAAE;IAClB,MAAM,IAAIC,KAAK,CACb,2IACF,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFontPaths = void 0;
|
|
7
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
8
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
|
+
var _cliTools = require("@react-native-community/cli-tools");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const getPackageJson = filename => {
|
|
12
|
+
const packageData = _nodeFs.default.readFileSync(filename, 'utf-8');
|
|
13
|
+
const packageJson = JSON.parse(packageData);
|
|
14
|
+
return packageJson;
|
|
15
|
+
};
|
|
16
|
+
const getPackageFontDirectories = packageJsonFilename => {
|
|
17
|
+
const rootPackageJson = getPackageJson(packageJsonFilename);
|
|
18
|
+
const dependencies = Object.keys(rootPackageJson.dependencies || {});
|
|
19
|
+
const packageDirs = [];
|
|
20
|
+
dependencies.forEach(dependency => {
|
|
21
|
+
const dir = (0, _cliTools.resolveNodeModuleDir)(packageJsonFilename, dependency);
|
|
22
|
+
const packageJson = getPackageJson(`${dir}/package.json`);
|
|
23
|
+
if (packageJson.keywords?.includes?.('react-native-vector-icons-icon')) {
|
|
24
|
+
packageDirs.push(`${dir}/fonts`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return packageDirs;
|
|
28
|
+
};
|
|
29
|
+
const getLocalFontsDir = packageJsonFilename => {
|
|
30
|
+
const rootPackageJson = getPackageJson(packageJsonFilename);
|
|
31
|
+
const config = rootPackageJson.reactNativeVectorIcons || {};
|
|
32
|
+
return `${_nodePath.default.dirname(packageJsonFilename)}/${config.fontDir || 'rnvi-fonts'}`;
|
|
33
|
+
};
|
|
34
|
+
const getFonts = fontDir => {
|
|
35
|
+
if (!_nodeFs.default.existsSync(fontDir)) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const fonts = _nodeFs.default.readdirSync(fontDir);
|
|
39
|
+
const fontPaths = fonts.map(font => `${fontDir}/${font}`);
|
|
40
|
+
return fontPaths;
|
|
41
|
+
};
|
|
42
|
+
const getFontPaths = packageJsonFilename => {
|
|
43
|
+
const packageDirs = getPackageFontDirectories(packageJsonFilename);
|
|
44
|
+
packageDirs.push(getLocalFontsDir(packageJsonFilename));
|
|
45
|
+
const fonts = packageDirs.map(getFonts);
|
|
46
|
+
return fonts.flat();
|
|
47
|
+
};
|
|
48
|
+
exports.getFontPaths = getFontPaths;
|
|
49
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_nodeFs","_interopRequireDefault","require","_nodePath","_cliTools","e","__esModule","default","getPackageJson","filename","packageData","fs","readFileSync","packageJson","JSON","parse","getPackageFontDirectories","packageJsonFilename","rootPackageJson","dependencies","Object","keys","packageDirs","forEach","dependency","dir","resolveNodeModuleDir","keywords","includes","push","getLocalFontsDir","config","reactNativeVectorIcons","path","dirname","fontDir","getFonts","existsSync","fonts","readdirSync","fontPaths","map","font","getFontPaths","flat","exports"],"sourceRoot":"../../../src","sources":["scripts/common.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAAyE,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzE,MAAMG,cAAc,GAAIC,QAAgB,IAAK;EAC3C,MAAMC,WAAW,GAAGC,eAAE,CAACC,YAAY,CAACH,QAAQ,EA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,IAAK,GAAGP,OAAO,IAAIO,IAAI,EAAE,CAAC;EAE3D,OAAOF,SAAS;AAClB,CAAC;AAEM,MAAMG,YAAY,GAAI1B,mBAA2B,IAAK;EAC3D,MAAMK,WAAW,GAAGN,yBAAyB,CAACC,mBAAmB,CAAC;EAClEK,WAAW,CAACO,IAAI,CAACC,gBAAgB,CAACb,mBAAmB,CAAC,CAAC;EACvD,MAAMqB,KAAK,GAAGhB,WAAW,CAACmB,GAAG,CAACL,QAAQ,CAAC;EACvC,OAAOE,KAAK,CAACM,IAAI,CAAC,CAAC;AACrB,CAAC;AAACC,OAAA,CAAAF,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -1,45 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const rootDir = process.argv[2];
|
|
9
|
-
if (!rootDir) {
|
|
10
|
-
throw new Error('Need rootDir as first argument');
|
|
4
|
+
var _common = require("./common");
|
|
5
|
+
const packageJsonFilename = process.argv[2];
|
|
6
|
+
if (!packageJsonFilename) {
|
|
7
|
+
throw new Error('Need the path to the roo package.json as the first argument');
|
|
11
8
|
}
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const packageJson = JSON.parse(packageData);
|
|
15
|
-
return packageJson;
|
|
16
|
-
};
|
|
17
|
-
const getPackages = () => {
|
|
18
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
19
|
-
const dependencies = Object.keys(rootPackageJson.dependencies || {});
|
|
20
|
-
const packageDirs = [];
|
|
21
|
-
dependencies.forEach(dependency => {
|
|
22
|
-
const dir = (0, _cliTools.resolveNodeModuleDir)(rootDir, dependency);
|
|
23
|
-
const packageJson = getPackageJson(dir);
|
|
24
|
-
if (packageJson.keywords?.includes?.('react-native-vector-icons-icon')) {
|
|
25
|
-
packageDirs.push(dir);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return packageDirs;
|
|
29
|
-
};
|
|
30
|
-
const getFonts = dir => {
|
|
31
|
-
const fontDirs = [`${dir}/fonts`];
|
|
32
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
33
|
-
const config = rootPackageJson.reactNativeVectorIcons || {};
|
|
34
|
-
fontDirs.push(`${rootDir}/${config.fontDir || 'rnvi-fonts'}`);
|
|
35
|
-
fontDirs.forEach(fontDir => {
|
|
36
|
-
if (!_nodeFs.default.existsSync(fontDir)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const fonts = _nodeFs.default.readdirSync(fontDir);
|
|
40
|
-
fonts.forEach(font => console.log(`${fontDir}/${font}`)); // eslint-disable-line no-console
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
const packageDirs = getPackages();
|
|
44
|
-
packageDirs.forEach(dir => getFonts(dir));
|
|
9
|
+
const fonts = (0, _common.getFontPaths)(packageJsonFilename);
|
|
10
|
+
fonts.flatMap(console.log); // eslint-disable-line no-console
|
|
45
11
|
//# sourceMappingURL=getFonts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_common","require","packageJsonFilename","process","argv","Error","fonts","getFontPaths","flatMap","console","log"],"sourceRoot":"../../../src","sources":["scripts/getFonts.ts"],"mappings":"AAAA;AAAmB;;AAEnB,IAAAA,OAAA,GAAAC,OAAA;AAEA,MAAMC,mBAAmB,GAAGC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;AAC3C,IAAI,CAACF,mBAAmB,EAAE;EACxB,MAAM,IAAIG,KAAK,CAAC,6DAA6D,CAAC;AAChF;AAEA,MAAMC,KAAK,GAAG,IAAAC,oBAAY,EAACL,mBAAmB,CAAC;AAC/CI,KAAK,CAACE,OAAO,CAACC,OAAO,CAACC,GAAG,CAAC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
6
|
+
var path = _interopRequireWildcard(require("node:path"));
|
|
7
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
|
+
var plist = _interopRequireWildcard(require("plist"));
|
|
9
|
+
var _common = require("./common");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const getFontName = fontPath => path.basename(fontPath);
|
|
14
|
+
const packageJsonFilename = process.argv[2];
|
|
15
|
+
if (!packageJsonFilename) {
|
|
16
|
+
throw new Error('Need the path to the root package.json as the first argument');
|
|
17
|
+
}
|
|
18
|
+
const infoPlistFilename = process.argv[3];
|
|
19
|
+
if (!infoPlistFilename) {
|
|
20
|
+
throw new Error('Need the path to the Info.plist as the second argument');
|
|
21
|
+
}
|
|
22
|
+
const fonts = (0, _common.getFontPaths)(packageJsonFilename);
|
|
23
|
+
console.log(`Found ${fonts.length} fonts`);
|
|
24
|
+
const infoPlistContent = _nodeFs.default.readFileSync(infoPlistFilename, 'utf8');
|
|
25
|
+
const infoPlist = plist.parse(infoPlistContent);
|
|
26
|
+
const plistFonts = new Set(infoPlist.UIAppFonts || []);
|
|
27
|
+
const providedFonts = new Set(fonts.map(getFontName));
|
|
28
|
+
let hasChanges = false;
|
|
29
|
+
|
|
30
|
+
// Check for missing fonts and add them
|
|
31
|
+
providedFonts.forEach(font => {
|
|
32
|
+
if (!plistFonts.has(font)) {
|
|
33
|
+
plistFonts.add(font);
|
|
34
|
+
console.log(_chalk.default.green(`Added ${font}`));
|
|
35
|
+
hasChanges = true;
|
|
36
|
+
} else {
|
|
37
|
+
console.log(`Existing ${font}`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Check for extra fonts in Info.plist
|
|
42
|
+
plistFonts.forEach(font => {
|
|
43
|
+
if (!providedFonts.has(font)) {
|
|
44
|
+
console.log(_chalk.default.red(`Extra ${font} (Please remove manually if not needed)`));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Update Info.plist if there were changes
|
|
49
|
+
if (hasChanges) {
|
|
50
|
+
infoPlist.UIAppFonts = Array.from(plistFonts);
|
|
51
|
+
const updatedInfoPlistContent = plist.build(infoPlist).replace(/^ {2}/gm, '').replace(/ {2}/gm, '\t');
|
|
52
|
+
_nodeFs.default.writeFileSync(infoPlistFilename, updatedInfoPlistContent, 'utf8');
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=updatePlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_nodeFs","_interopRequireDefault","require","path","_interopRequireWildcard","_chalk","plist","_common","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getFontName","fontPath","basename","packageJsonFilename","process","argv","Error","infoPlistFilename","fonts","getFontPaths","console","log","length","infoPlistContent","fs","readFileSync","infoPlist","parse","plistFonts","Set","UIAppFonts","providedFonts","map","hasChanges","forEach","font","add","chalk","green","red","Array","from","updatedInfoPlistContent","build","replace","writeFileSync"],"sour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,GAAG,CAACD,IAAI,CAAC;IACpBf,OAAO,CAACC,GAAG,CAACgB,cAAK,CAACC,KAAK,CAAC,SAASH,IAAI,EAAE,CAAC,CAAC;IACzCF,UAAU,GAAG,IAAI;EACnB,CAAC,MAAM;IACLb,OAAO,CAACC,GAAG,CAAC,YAAYc,IAAI,EAAE,CAAC;EACjC;AACF,CAAC,CAAC;;AAEF;AACAP,UAAU,CAACM,OAAO,CAAEC,IAAI,IAAK;EAC3B,IAAI,CAACJ,aAAa,CAAClC,GAAG,CAACsC,IAAI,CAAC,EAAE;IAC5Bf,OAAO,CAACC,GAAG,CAACgB,cAAK,CAACE,GAAG,CAAC,SAASJ,IAAI,yCAAyC,CAAC,CAAC;EAChF;AACF,CAAC,CAAC;;AAEF;AACA,IAAIF,UAAU,EAAE;EACdP,SAAS,CAACI,UAAU,GAAGU,KAAK,CAACC,IAAI,CAACb,UAAU,CAAC;EAC7C,MAAMc,uBAAuB,GAAGtD,KAAK,CAACuD,KAAK,CAACjB,SAAS,CAAC,CAACkB,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;EAErGpB,eAAE,CAACqB,aAAa,CAAC5B,iBAAiB,EAAEyB,uBAAuB,EAAE,MAAM,CAAC;AACtE","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { forwardRef } from 'react';
|
|
3
3
|
import { PixelRatio, Platform, Text, processColor } from 'react-native';
|
|
4
4
|
import NativeIconAPI from './NativeVectorIcons';
|
|
@@ -103,22 +103,6 @@ export const createIconSet = (glyphMap, fontFamily, fontFile, fontStyle) => {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
const loadFont = async () => {
|
|
107
|
-
if (Platform.OS !== 'ios') {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
ensureNativeModuleAvailable();
|
|
111
|
-
const [filename, extension] = fontFile.split('.'); // FIXME: what if filename has two dots?
|
|
112
|
-
if (!filename) {
|
|
113
|
-
// NOTE: Thie is impossible but TypeScript doesn't know that
|
|
114
|
-
throw new Error('Font needs a filename.');
|
|
115
|
-
}
|
|
116
|
-
if (!extension) {
|
|
117
|
-
throw new Error('Font needs a filename extensison.');
|
|
118
|
-
}
|
|
119
|
-
await NativeIconAPI.loadFontWithFileName(filename, extension, 'react-native-vector-icons');
|
|
120
|
-
};
|
|
121
|
-
loadFont();
|
|
122
106
|
const IconNamespace = Object.assign(WrappedIcon, {
|
|
123
107
|
getImageSource,
|
|
124
108
|
getImageSourceSync
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","PixelRatio","Platform","Text","processColor","NativeIconAPI","createIconSourceCache","ensureNativeModuleAvailable","DEFAULT_ICON_SIZE","DEFAULT_ICON_COLOR","createIconSet","glyphMap","fontFamily","fontFile","fontStyle","fontBasename","replace","fontReference","select","windows","android","web","default","resolveGlyph","name","glyph","String","fromCodePoint","Icon","size","color","style","children","allowFontScaling","innerRef","props","styleDefaults","fontSize","styleOverrides","fontWeight","newProps","createElement","_extends","ref","selectable","WrappedIcon","displayName","imageSourceCache","getImageSourceSync","processedColor","cacheKey","has","get","imagePath","getImageForFontSync","value","uri","scale","setValue","error","setError","getImageSource","getImageForFont","
|
|
1
|
+
{"version":3,"names":["React","forwardRef","PixelRatio","Platform","Text","processColor","NativeIconAPI","createIconSourceCache","ensureNativeModuleAvailable","DEFAULT_ICON_SIZE","DEFAULT_ICON_COLOR","createIconSet","glyphMap","fontFamily","fontFile","fontStyle","fontBasename","replace","fontReference","select","windows","android","web","default","resolveGlyph","name","glyph","String","fromCodePoint","Icon","size","color","style","children","allowFontScaling","innerRef","props","styleDefaults","fontSize","styleOverrides","fontWeight","newProps","createElement","_extends","ref","selectable","WrappedIcon","displayName","imageSourceCache","getImageSourceSync","processedColor","cacheKey","has","get","imagePath","getImageForFontSync","value","uri","scale","setValue","error","setError","getImageSource","getImageForFont","IconNamespace","Object","assign"],"sourceRoot":"../../src","sources":["create-icon-set.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAkB,OAAO;AAEnD,SAASC,UAAU,EAAEC,QAAQ,EAAEC,IAAI,EAAkCC,YAAY,QAAQ,cAAc;AAEvG,OAAOC,aAAa,MAAM,qBAAqB;AAC/C,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,2BAA2B,MAAM,kCAAkC;AAE1E,OAAO,MAAMC,iBAAiB,GAAG,EAAE;AACnC,OAAO,MAAMC,kBAAkB,GAAG,OAAO;AASzC,OAAO,MAAMC,aAAa,GAAGA,CAC3BC,QAAY,EACZC,UAAkB,EAClBC,QAAgB,EAChBC,SAA8B,KAC3B;EACH;EACA,MAAMC,YAAY,GAAGF,QAAQ,GAAGA,QAAQ,CAACG,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,GAAGJ,UAAU;EAEjF,MAAMK,aAAa,GAAGf,QAAQ,CAACgB,MAAM,CAAC;IACpCC,OAAO,EAAE,WAAWN,QAAQ,IAAID,UAAU,EAAE;IAC5CQ,OAAO,EAAEL,YAAY;IACrBM,GAAG,EAAEN,YAAY;IACjBO,OAAO,EAAEV;EACX,CAAC,CAAC;EAEF,MAAMW,YAAY,GAAIC,IAAc,IAAK;IACvC,MAAMC,KAAK,GAAGd,QAAQ,CAACa,IAAI,CAAC,IAAI,GAAG;IAEnC,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAOC,MAAM,CAACC,aAAa,CAACF,KAAK,CAAC;IACpC;IAEA,OAAOA,KAAK;EACd,CAAC;EAED,MAAMG,IAAI,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,eAAe,CACnD7C,aAAa,EACbQ,KAAK,EACLI,IAAI,EACJoB,cAAc,CAAY;MAC5B,CAAC;MACD,MAAMM,KAAK,GAAG;QAAEC,GAAG,EAAEH,SAAS;QAAEI,KAAK,EAAExD,UAAU,CAACmD,GAAG,CAAC;MAAE,CAAC;MACzDL,gBAAgB,CAACW,QAAQ,CAACR,QAAQ,EAAEK,KAAK,CAAC;MAC1C,OAAOA,KAAK;IACd,CAAC,CAAC,OAAOI,KAAK,EAAE;MACdZ,gBAAgB,CAACa,QAAQ,CAACV,QAAQ,EAAES,KAAc,CAAC;MACnD,MAAMA,KAAK;IACb;EACF,CAAC;EAED,MAAMI,aAAa,GAAGC,MAAM,CAACC,MAAM,CAACpB,WAAW,EAAE;IAC/CgB,cAAc;IACdb;EACF,CAAC,CAAC;EAEF,OAAOe,aAAa;AACtB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolveNodeModuleDir } from '@react-native-community/cli-tools';
|
|
4
|
+
const getPackageJson = filename => {
|
|
5
|
+
const packageData = fs.readFileSync(filename, 'utf-8');
|
|
6
|
+
const packageJson = JSON.parse(packageData);
|
|
7
|
+
return packageJson;
|
|
8
|
+
};
|
|
9
|
+
const getPackageFontDirectories = packageJsonFilename => {
|
|
10
|
+
const rootPackageJson = getPackageJson(packageJsonFilename);
|
|
11
|
+
const dependencies = Object.keys(rootPackageJson.dependencies || {});
|
|
12
|
+
const packageDirs = [];
|
|
13
|
+
dependencies.forEach(dependency => {
|
|
14
|
+
const dir = resolveNodeModuleDir(packageJsonFilename, dependency);
|
|
15
|
+
const packageJson = getPackageJson(`${dir}/package.json`);
|
|
16
|
+
if (packageJson.keywords?.includes?.('react-native-vector-icons-icon')) {
|
|
17
|
+
packageDirs.push(`${dir}/fonts`);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return packageDirs;
|
|
21
|
+
};
|
|
22
|
+
const getLocalFontsDir = packageJsonFilename => {
|
|
23
|
+
const rootPackageJson = getPackageJson(packageJsonFilename);
|
|
24
|
+
const config = rootPackageJson.reactNativeVectorIcons || {};
|
|
25
|
+
return `${path.dirname(packageJsonFilename)}/${config.fontDir || 'rnvi-fonts'}`;
|
|
26
|
+
};
|
|
27
|
+
const getFonts = fontDir => {
|
|
28
|
+
if (!fs.existsSync(fontDir)) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const fonts = fs.readdirSync(fontDir);
|
|
32
|
+
const fontPaths = fonts.map(font => `${fontDir}/${font}`);
|
|
33
|
+
return fontPaths;
|
|
34
|
+
};
|
|
35
|
+
export const getFontPaths = packageJsonFilename => {
|
|
36
|
+
const packageDirs = getPackageFontDirectories(packageJsonFilename);
|
|
37
|
+
packageDirs.push(getLocalFontsDir(packageJsonFilename));
|
|
38
|
+
const fonts = packageDirs.map(getFonts);
|
|
39
|
+
return fonts.flat();
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fs","path","resolveNodeModuleDir","getPackageJson","filename","packageData","readFileSync","packageJson","JSON","parse","getPackageFontDirectories","packageJsonFilename","rootPackageJson","dependencies","Object","keys","packageDirs","forEach","dependency","dir","keywords","includes","push","getLocalFontsDir","config","reactNativeVectorIcons","dirname","fontDir","getFonts","existsSync","fonts","readdirSync","fontPaths","map","font","getFontPaths","flat"],"sourceRoot":"../../../src","sources":["scripts/common.ts"],"mappings":"AAAA,OAAOA,EAAE,MAAM,SAAS;AACxB,OAAOC,IAAI,MAAM,WAAW;AAC5B,SAASC,oBAAoB,QAAQ,mCAAmC;AAExE,MAAMC,cAAc,GAAIC,QAAgB,IAAK;EAC3C,MAAMC,WAAW,GAAGL,EAAE,CAACM,YAAY,CAACF,QAAQ,EAAE,OAAO,CAAC;EACtD,MAAMG,WAAW,GAAGC,IAAI,CAACC,KAAK,CAACJ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S;AAClB,CAAC;AAED,OAAO,MAAMG,YAAY,GAAIxB,mBAA2B,IAAK;EAC3D,MAAMK,WAAW,GAAGN,yBAAyB,CAACC,mBAAmB,CAAC;EAClEK,WAAW,CAACM,IAAI,CAACC,gBAAgB,CAACZ,mBAAmB,CAAC,CAAC;EACvD,MAAMmB,KAAK,GAAGd,WAAW,CAACiB,GAAG,CAACL,QAAQ,CAAC;EACvC,OAAOE,KAAK,CAACM,IAAI,CAAC,CAAC;AACrB,CAAC","ignoreList":[]}
|
|
@@ -1,42 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!rootDir) {
|
|
7
|
-
throw new Error('Need rootDir as first argument');
|
|
2
|
+
import { getFontPaths } from "./common";
|
|
3
|
+
const packageJsonFilename = process.argv[2];
|
|
4
|
+
if (!packageJsonFilename) {
|
|
5
|
+
throw new Error('Need the path to the roo package.json as the first argument');
|
|
8
6
|
}
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const packageJson = JSON.parse(packageData);
|
|
12
|
-
return packageJson;
|
|
13
|
-
};
|
|
14
|
-
const getPackages = () => {
|
|
15
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
16
|
-
const dependencies = Object.keys(rootPackageJson.dependencies || {});
|
|
17
|
-
const packageDirs = [];
|
|
18
|
-
dependencies.forEach(dependency => {
|
|
19
|
-
const dir = resolveNodeModuleDir(rootDir, dependency);
|
|
20
|
-
const packageJson = getPackageJson(dir);
|
|
21
|
-
if (packageJson.keywords?.includes?.('react-native-vector-icons-icon')) {
|
|
22
|
-
packageDirs.push(dir);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return packageDirs;
|
|
26
|
-
};
|
|
27
|
-
const getFonts = dir => {
|
|
28
|
-
const fontDirs = [`${dir}/fonts`];
|
|
29
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
30
|
-
const config = rootPackageJson.reactNativeVectorIcons || {};
|
|
31
|
-
fontDirs.push(`${rootDir}/${config.fontDir || 'rnvi-fonts'}`);
|
|
32
|
-
fontDirs.forEach(fontDir => {
|
|
33
|
-
if (!fs.existsSync(fontDir)) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const fonts = fs.readdirSync(fontDir);
|
|
37
|
-
fonts.forEach(font => console.log(`${fontDir}/${font}`)); // eslint-disable-line no-console
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
const packageDirs = getPackages();
|
|
41
|
-
packageDirs.forEach(dir => getFonts(dir));
|
|
7
|
+
const fonts = getFontPaths(packageJsonFilename);
|
|
8
|
+
fonts.flatMap(console.log); // eslint-disable-line no-console
|
|
42
9
|
//# sourceMappingURL=getFonts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getFontPaths","packageJsonFilename","process","argv","Error","fonts","flatMap","console","log"],"sourceRoot":"../../../src","sources":["scripts/getFonts.ts"],"mappings":"AAAA;AAEA,SAASA,YAAY,QAAQ,UAAU;AAEvC,MAAMC,mBAAmB,GAAGC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;AAC3C,IAAI,CAACF,mBAAmB,EAAE;EACxB,MAAM,IAAIG,KAAK,CAAC,6DAA6D,CAAC;AAChF;AAEA,MAAMC,KAAK,GAAGL,YAAY,CAACC,mBAAmB,CAAC;AAC/CI,KAAK,CAACC,OAAO,CAACC,OAAO,CAACC,GAAG,CAAC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import * as plist from 'plist';
|
|
7
|
+
import { getFontPaths } from "./common";
|
|
8
|
+
const getFontName = fontPath => path.basename(fontPath);
|
|
9
|
+
const packageJsonFilename = process.argv[2];
|
|
10
|
+
if (!packageJsonFilename) {
|
|
11
|
+
throw new Error('Need the path to the root package.json as the first argument');
|
|
12
|
+
}
|
|
13
|
+
const infoPlistFilename = process.argv[3];
|
|
14
|
+
if (!infoPlistFilename) {
|
|
15
|
+
throw new Error('Need the path to the Info.plist as the second argument');
|
|
16
|
+
}
|
|
17
|
+
const fonts = getFontPaths(packageJsonFilename);
|
|
18
|
+
console.log(`Found ${fonts.length} fonts`);
|
|
19
|
+
const infoPlistContent = fs.readFileSync(infoPlistFilename, 'utf8');
|
|
20
|
+
const infoPlist = plist.parse(infoPlistContent);
|
|
21
|
+
const plistFonts = new Set(infoPlist.UIAppFonts || []);
|
|
22
|
+
const providedFonts = new Set(fonts.map(getFontName));
|
|
23
|
+
let hasChanges = false;
|
|
24
|
+
|
|
25
|
+
// Check for missing fonts and add them
|
|
26
|
+
providedFonts.forEach(font => {
|
|
27
|
+
if (!plistFonts.has(font)) {
|
|
28
|
+
plistFonts.add(font);
|
|
29
|
+
console.log(chalk.green(`Added ${font}`));
|
|
30
|
+
hasChanges = true;
|
|
31
|
+
} else {
|
|
32
|
+
console.log(`Existing ${font}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Check for extra fonts in Info.plist
|
|
37
|
+
plistFonts.forEach(font => {
|
|
38
|
+
if (!providedFonts.has(font)) {
|
|
39
|
+
console.log(chalk.red(`Extra ${font} (Please remove manually if not needed)`));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Update Info.plist if there were changes
|
|
44
|
+
if (hasChanges) {
|
|
45
|
+
infoPlist.UIAppFonts = Array.from(plistFonts);
|
|
46
|
+
const updatedInfoPlistContent = plist.build(infoPlist).replace(/^ {2}/gm, '').replace(/ {2}/gm, '\t');
|
|
47
|
+
fs.writeFileSync(infoPlistFilename, updatedInfoPlistContent, 'utf8');
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=updatePlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fs","path","chalk","plist","getFontPaths","getFontName","fontPath","basename","packageJsonFilename","process","argv","Error","infoPlistFilename","fonts","console","log","length","infoPlistContent","readFileSync","infoPlist","parse","plistFonts","Set","UIAppFonts","providedFonts","map","hasChanges","forEach","font","has","add","green","red","Array","from","updatedInfoPlistContent","build","replace","writeFileSync"],"sourceRoot":"../../../src","sources":["scripts/updatePlist.ts"],"mappings":"AAAA;AACA;AAEA,OAAOA,EAAE,MAAM,SAAS;AACxB,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,YAAY,QAAQ,UAAU;AAEvC,MAAMC,WAAW,GAAIC,QAAgB,IAAKL,IAAI,CAACM,QAAQ,CAACD,QAAQ,CAAC;AAEjE,MAAME,mBAAmB,GAAGC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;AAC3C,IAAI,CAACF,mBAAmB,EAAE;EACxB,MAAM,IAAIG,KAAK,CAAC,8DAA8D,CAAC;AACjF;AAEA,MAAMC,iBAAiB,GAAGH,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;AACzC,IAAI,CAACE,iBAAiB,EAAE;EACtB,MAAM,IAAID,KAAK,CAAC,wDAAwD,CAAC;AAC3E;AAEA,MAAME,KAAK,GAAGT,YAAY,CAACI,mBAAmB,CAAC;AAC/CM,OAAO,CAACC,GAAG,CAAC,SAASF,KAAK,CAACG,MAAM,QAAQ,CAAC;AAE1C,MAAMC,gBAAgB,GAAGjB,EAAE,CAACkB,YAAY,CAACN,iBAAiB,EAAE,MAAM,CAAC;AACnE,MAAMO,SAAS,GAAGhB,KAAK,CAACiB,KAAK,CAACH,gBAAgB,CAA6B;AAI3E,MAAMI,UAAU,GAAG,IAAIC,GAAG,CAACH,SAAS,CAACI,UAAU,IAAI,EAAE,CAAC;AACtD,MAAMC,aAAa,GAAG,IAAIF,GAAG,CAACT,KAAK,CAACY,GAAG,CAACpB,WAAW,CAAC,CAAC;AAErD,IAAIqB,UAAU,GAAG,KAAK;;AAEtB;AACAF,aAAa,CAACG,OAAO,CAAEC,IAAI,IAAK;EAC9B,IAAI,CAACP,UAAU,CAACQ,GAAG,CAACD,IAAI,CAAC,EAAE;IACzBP,UAAU,CAACS,GAAG,CAACF,IAAI,CAAC;IACpBd,OAAO,CAACC,GAAG,CAACb,KAAK,CAAC6B,KAAK,CAAC,SAASH,IAAI,EAAE,CAAC,CAAC;IACzCF,UAAU,GAAG,IAAI;EACnB,CAAC,MAAM;IACLZ,OAAO,CAACC,GAAG,CAAC,YAAYa,IAAI,EAAE,CAAC;EACjC;AACF,CAAC,CAAC;;AAEF;AACAP,UAAU,CAACM,OAAO,CAAEC,IAAI,IAAK;EAC3B,IAAI,CAACJ,aAAa,CAACK,GAAG,CAACD,IAAI,CAAC,EAAE;IAC5Bd,OAAO,CAACC,GAAG,CAACb,KAAK,CAAC8B,GAAG,CAAC,SAASJ,IAAI,yCAAyC,CAAC,CAAC;EAChF;AACF,CAAC,CAAC;;AAEF;AACA,IAAIF,UAAU,EAAE;EACdP,SAAS,CAACI,UAAU,GAAGU,KAAK,CAACC,IAAI,CAACb,UAAU,CAAC;EAC7C,MAAMc,uBAAuB,GAAGhC,KAAK,CAACiC,KAAK,CAACjB,SAAS,CAAC,CAACkB,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;EAErGrC,EAAE,CAACsC,aAAa,CAAC1B,iBAAiB,EAAEuB,uBAAuB,EAAE,MAAM,CAAC;AACtE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-icon-set.d.ts","sourceRoot":"","sources":["../../../src/create-icon-set.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC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gDACd,EAAE,cACA,MAAM,YACR,MAAM,cACJ,SAAS,CAAC,OAAO,CAAC;;;YARtB,SAAS,CAAC,OAAO,CAAC;;;2BA2GlB,MAAM,EAAE,yBAEP,SAAS,CAAC,OAAO,CAAC;;;;+BAlCnB,MAAM,EAAE,yBAEP,SAAS,CAAC,OAAO,CAAC;;;;CAmE5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/scripts/common.ts"],"names":[],"mappings":"AA6CA,eAAO,MAAM,YAAY,wBAAyB,MAAM,aAKvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updatePlist.d.ts","sourceRoot":"","sources":["../../../../src/scripts/updatePlist.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-vector-icons/common",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.12",
|
|
4
4
|
"description": "Customizable Icons for React Native with support for image source and full styling.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
"postpack": "rm README.md",
|
|
33
33
|
"watch": "onchange 'src/**' --initial -- yarn run prepare"
|
|
34
34
|
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"rnvi-update-plist": "lib/commonjs/scripts/updatePlist.js"
|
|
37
|
+
},
|
|
35
38
|
"keywords": [
|
|
36
39
|
"react-native",
|
|
37
40
|
"ios",
|
|
@@ -68,28 +71,30 @@
|
|
|
68
71
|
"registry": "https://registry.npmjs.org/"
|
|
69
72
|
},
|
|
70
73
|
"dependencies": {
|
|
71
|
-
"@react-native-community/cli-tools": "^13.6.
|
|
74
|
+
"@react-native-community/cli-tools": "^13.6.9",
|
|
75
|
+
"chalk": "^5.3.0",
|
|
76
|
+
"plist": "^3.1.0",
|
|
72
77
|
"prop-types": "^15.8.1",
|
|
73
78
|
"yargs": "^17.7.2"
|
|
74
79
|
},
|
|
75
80
|
"devDependencies": {
|
|
76
81
|
"@types/jest": "^29.5.12",
|
|
77
|
-
"@types/
|
|
78
|
-
"@types/react
|
|
82
|
+
"@types/plist": "^3.0.5",
|
|
83
|
+
"@types/react": "~18.3.3",
|
|
79
84
|
"css-social-buttons": "^1.1.1",
|
|
80
85
|
"del-cli": "^5.1.0",
|
|
81
86
|
"jest": "^29.7.0",
|
|
82
87
|
"onchange": "^7.1.0",
|
|
83
88
|
"oslllo-svg-fixer": "^4.0.1",
|
|
84
89
|
"pod-install": "^0.2.2",
|
|
85
|
-
"prettier": "^3.2
|
|
86
|
-
"react": "18.
|
|
87
|
-
"react-native": "0.73.
|
|
90
|
+
"prettier": "^3.3.2",
|
|
91
|
+
"react": "18.3.1",
|
|
92
|
+
"react-native": "0.73.8",
|
|
88
93
|
"react-native-builder-bob": "^0.23.2",
|
|
89
|
-
"release-it": "^17.
|
|
94
|
+
"release-it": "^17.4.0",
|
|
90
95
|
"svg2ttf": "^6.0.3",
|
|
91
96
|
"svgicons2svgfont": "^12.0.0",
|
|
92
|
-
"typescript": "^5.4.
|
|
97
|
+
"typescript": "^5.4.2"
|
|
93
98
|
},
|
|
94
99
|
"peerDependencies": {
|
|
95
100
|
"react": "*",
|
|
@@ -130,5 +135,5 @@
|
|
|
130
135
|
"javaPackageName": "com.reactnativevectoricons.common"
|
|
131
136
|
}
|
|
132
137
|
},
|
|
133
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "81705d3c613d370af68b3d3471b2492f3225ad2f"
|
|
134
139
|
}
|
|
@@ -21,33 +21,58 @@ Pod::Spec.new do |s|
|
|
|
21
21
|
:script => "
|
|
22
22
|
set -e
|
|
23
23
|
|
|
24
|
-
#
|
|
24
|
+
# This script borrows from the standard resource copy script https://gist.github.com/vonovak/d8f1a37804438f05bae22be1e8cd53c1
|
|
25
25
|
# We need two key bits of information
|
|
26
|
-
# Project Root -
|
|
26
|
+
# Project Root - Where the package.json for the RN app lives
|
|
27
27
|
# Xcode Build Dir to copy the fonts into - We look for the directory that ends in .app
|
|
28
28
|
|
|
29
|
-
echo
|
|
29
|
+
echo \"(RNVI) START_COPY_FONTS\"
|
|
30
30
|
|
|
31
|
-
echo PWD: $(pwd)
|
|
32
|
-
echo PODS_ROOT: \"$PODS_ROOT\"
|
|
33
|
-
echo PODS_CONFIGURATION_BUILD_DIR: \"$PODS_CONFIGURATION_BUILD_DIR\"
|
|
31
|
+
echo \"(RNVI) PWD: $(pwd)\"
|
|
34
32
|
|
|
33
|
+
#############
|
|
34
|
+
# Find the fonts we need to copy
|
|
35
|
+
#############
|
|
36
|
+
|
|
37
|
+
# Assume the project root is always two directories above the POD_ROOT
|
|
38
|
+
echo \"(RNVI) PODS_ROOT: $PODS_ROOT\"
|
|
35
39
|
PROJECT_ROOT=\"${PODS_ROOT}/../..\"
|
|
36
|
-
echo \"PROJECT_ROOT: $PROJECT_ROOT\"
|
|
40
|
+
echo \"(RNVI) PROJECT_ROOT: $PROJECT_ROOT\"
|
|
41
|
+
|
|
42
|
+
# Items we need to copy for rsync
|
|
43
|
+
RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
|
|
44
|
+
|
|
45
|
+
node \"#{__dir__}/lib/commonjs/scripts/getFonts.js\" \"$PROJECT_ROOT\"/package.json > \"$RESOURCES_TO_COPY\"
|
|
37
46
|
|
|
47
|
+
#############
|
|
48
|
+
# Find the destination we copy to
|
|
49
|
+
#############
|
|
50
|
+
|
|
51
|
+
echo \"(RNVI) PODS_CONFIGURATION_BUILD_DIR: $PODS_CONFIGURATION_BUILD_DIR\"
|
|
38
52
|
XCODE_DIR=$(ls -d \"$PODS_CONFIGURATION_BUILD_DIR\"/*.app)
|
|
53
|
+
echo \"(RNVI) XCODE_DIR: $XCODE_DIR\"
|
|
39
54
|
DEST_DIR=\"${XCODE_DIR}/react-native-vector-icons\"
|
|
40
|
-
echo
|
|
41
|
-
echo
|
|
55
|
+
echo \"(RNVI) DEST_DIR: $DEST_DIR\"
|
|
56
|
+
echo I $INSTALL_DIR
|
|
42
57
|
mkdir -p \"$DEST_DIR\"
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
#############
|
|
60
|
+
# Copy the fonts
|
|
61
|
+
#############
|
|
62
|
+
echo \"(RNVI) Copying the following files to $DEST_DIR\"
|
|
63
|
+
cat \"$RESOURCES_TO_COPY\" | sed 's/^/(RNVI) /'
|
|
64
|
+
|
|
65
|
+
# NOTE: Should we add --delete and remove old fonts automagically? NOt doing it yet as it feels risky
|
|
66
|
+
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from=\"$RESOURCES_TO_COPY\" / \"$DEST_DIR\"
|
|
67
|
+
# TODO: How do we test this is right?
|
|
68
|
+
if [[ \"${ACTION}\" == \"install\" ]] && [[ \"${SKIP_INSTALL}\" == \"NO\" ]]; then
|
|
69
|
+
mkdir -p \"${INSTALL_DIR}/react-native-vector-icons\"
|
|
70
|
+
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from=\"$RESOURCES_TO_COPY\" / \"${INSTALL_DIR}/react-native-vector-icons\"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
rm -f \"$RESOURCES_TO_COPY\"
|
|
49
74
|
|
|
50
|
-
echo END:RNVI_COPY_FONTS
|
|
75
|
+
echo \"(RNVI) END:RNVI_COPY_FONTS\"
|
|
51
76
|
",
|
|
52
77
|
}
|
|
53
78
|
|
package/src/create-icon-set.tsx
CHANGED
|
@@ -150,26 +150,6 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
const loadFont = async () => {
|
|
154
|
-
if (Platform.OS !== 'ios') {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
ensureNativeModuleAvailable();
|
|
158
|
-
|
|
159
|
-
const [filename, extension] = fontFile.split('.'); // FIXME: what if filename has two dots?
|
|
160
|
-
if (!filename) {
|
|
161
|
-
// NOTE: Thie is impossible but TypeScript doesn't know that
|
|
162
|
-
throw new Error('Font needs a filename.');
|
|
163
|
-
}
|
|
164
|
-
if (!extension) {
|
|
165
|
-
throw new Error('Font needs a filename extensison.');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
await NativeIconAPI.loadFontWithFileName(filename, extension, 'react-native-vector-icons');
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
loadFont();
|
|
172
|
-
|
|
173
153
|
const IconNamespace = Object.assign(WrappedIcon, {
|
|
174
154
|
getImageSource,
|
|
175
155
|
getImageSourceSync,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolveNodeModuleDir } from '@react-native-community/cli-tools';
|
|
4
|
+
|
|
5
|
+
const getPackageJson = (filename: string) => {
|
|
6
|
+
const packageData = fs.readFileSync(filename, 'utf-8');
|
|
7
|
+
const packageJson = JSON.parse(packageData);
|
|
8
|
+
|
|
9
|
+
return packageJson;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const getPackageFontDirectories = (packageJsonFilename: string) => {
|
|
13
|
+
const rootPackageJson = getPackageJson(packageJsonFilename);
|
|
14
|
+
const dependencies = Object.keys(rootPackageJson.dependencies || {});
|
|
15
|
+
|
|
16
|
+
const packageDirs: string[] = [];
|
|
17
|
+
dependencies.forEach((dependency) => {
|
|
18
|
+
const dir = resolveNodeModuleDir(packageJsonFilename, dependency);
|
|
19
|
+
const packageJson = getPackageJson(`${dir}/package.json`);
|
|
20
|
+
if (packageJson.keywords?.includes?.('react-native-vector-icons-icon')) {
|
|
21
|
+
packageDirs.push(`${dir}/fonts`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return packageDirs;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getLocalFontsDir = (packageJsonFilename: string) => {
|
|
29
|
+
const rootPackageJson = getPackageJson(packageJsonFilename);
|
|
30
|
+
const config = rootPackageJson.reactNativeVectorIcons || {};
|
|
31
|
+
|
|
32
|
+
return `${path.dirname(packageJsonFilename)}/${config.fontDir || 'rnvi-fonts'}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getFonts = (fontDir: string) => {
|
|
36
|
+
if (!fs.existsSync(fontDir)) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const fonts = fs.readdirSync(fontDir);
|
|
41
|
+
const fontPaths = fonts.map((font) => `${fontDir}/${font}`);
|
|
42
|
+
|
|
43
|
+
return fontPaths;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const getFontPaths = (packageJsonFilename: string) => {
|
|
47
|
+
const packageDirs = getPackageFontDirectories(packageJsonFilename);
|
|
48
|
+
packageDirs.push(getLocalFontsDir(packageJsonFilename));
|
|
49
|
+
const fonts = packageDirs.map(getFonts);
|
|
50
|
+
return fonts.flat();
|
|
51
|
+
};
|
package/src/scripts/getFonts.ts
CHANGED
|
@@ -1,52 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { resolveNodeModuleDir } from '@react-native-community/cli-tools';
|
|
3
|
+
import { getFontPaths } from "./common";
|
|
6
4
|
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
9
|
-
throw new Error('Need
|
|
5
|
+
const packageJsonFilename = process.argv[2];
|
|
6
|
+
if (!packageJsonFilename) {
|
|
7
|
+
throw new Error('Need the path to the roo package.json as the first argument');
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const packageJson = JSON.parse(packageData);
|
|
15
|
-
|
|
16
|
-
return packageJson;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const getPackages = () => {
|
|
20
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
21
|
-
const dependencies = Object.keys(rootPackageJson.dependencies || {});
|
|
22
|
-
|
|
23
|
-
const packageDirs: string[] = [];
|
|
24
|
-
dependencies.forEach((dependency) => {
|
|
25
|
-
const dir = resolveNodeModuleDir(rootDir, dependency);
|
|
26
|
-
const packageJson = getPackageJson(dir);
|
|
27
|
-
if (packageJson.keywords?.includes?.('react-native-vector-icons-icon')) {
|
|
28
|
-
packageDirs.push(dir);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return packageDirs;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const getFonts = (dir: string) => {
|
|
35
|
-
const fontDirs = [`${dir}/fonts`];
|
|
36
|
-
|
|
37
|
-
const rootPackageJson = getPackageJson(rootDir);
|
|
38
|
-
const config = rootPackageJson.reactNativeVectorIcons || {};
|
|
39
|
-
fontDirs.push(`${rootDir}/${config.fontDir || 'rnvi-fonts'}`);
|
|
40
|
-
|
|
41
|
-
fontDirs.forEach((fontDir) => {
|
|
42
|
-
if (!fs.existsSync(fontDir)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const fonts = fs.readdirSync(fontDir);
|
|
47
|
-
fonts.forEach((font) => console.log(`${fontDir}/${font}`)); // eslint-disable-line no-console
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const packageDirs = getPackages();
|
|
52
|
-
packageDirs.forEach((dir) => getFonts(dir));
|
|
10
|
+
const fonts = getFontPaths(packageJsonFilename);
|
|
11
|
+
fonts.flatMap(console.log); // eslint-disable-line no-console
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import * as plist from 'plist';
|
|
8
|
+
|
|
9
|
+
import { getFontPaths } from "./common";
|
|
10
|
+
|
|
11
|
+
const getFontName = (fontPath: string) => path.basename(fontPath);
|
|
12
|
+
|
|
13
|
+
const packageJsonFilename = process.argv[2];
|
|
14
|
+
if (!packageJsonFilename) {
|
|
15
|
+
throw new Error('Need the path to the root package.json as the first argument');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const infoPlistFilename = process.argv[3];
|
|
19
|
+
if (!infoPlistFilename) {
|
|
20
|
+
throw new Error('Need the path to the Info.plist as the second argument');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const fonts = getFontPaths(packageJsonFilename);
|
|
24
|
+
console.log(`Found ${fonts.length} fonts`);
|
|
25
|
+
|
|
26
|
+
const infoPlistContent = fs.readFileSync(infoPlistFilename, 'utf8');
|
|
27
|
+
const infoPlist = plist.parse(infoPlistContent) as Record<string, string[]>;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const plistFonts = new Set(infoPlist.UIAppFonts || []);
|
|
32
|
+
const providedFonts = new Set(fonts.map(getFontName));
|
|
33
|
+
|
|
34
|
+
let hasChanges = false;
|
|
35
|
+
|
|
36
|
+
// Check for missing fonts and add them
|
|
37
|
+
providedFonts.forEach((font) => {
|
|
38
|
+
if (!plistFonts.has(font)) {
|
|
39
|
+
plistFonts.add(font);
|
|
40
|
+
console.log(chalk.green(`Added ${font}`));
|
|
41
|
+
hasChanges = true;
|
|
42
|
+
} else {
|
|
43
|
+
console.log(`Existing ${font}`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Check for extra fonts in Info.plist
|
|
48
|
+
plistFonts.forEach((font) => {
|
|
49
|
+
if (!providedFonts.has(font)) {
|
|
50
|
+
console.log(chalk.red(`Extra ${font} (Please remove manually if not needed)`));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Update Info.plist if there were changes
|
|
55
|
+
if (hasChanges) {
|
|
56
|
+
infoPlist.UIAppFonts = Array.from(plistFonts);
|
|
57
|
+
const updatedInfoPlistContent = plist.build(infoPlist).replace(/^ {2}/gm, '').replace(/ {2}/gm, '\t');
|
|
58
|
+
|
|
59
|
+
fs.writeFileSync(infoPlistFilename, updatedInfoPlistContent, 'utf8');
|
|
60
|
+
}
|