-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FontAwesome 5 #776
FontAwesome 5 #776
Changes from 1 commit
5340877
8e789bf
13e644a
c682035
a698fe1
5d2dae1
b144027
5c1e203
0f9b2a5
f1ef199
8a8a1d1
569473f
47cece2
6fd8697
50942b8
d952755
f6d6365
6bd1e49
8c3189e
7eb5d31
4d1503a
068dc30
d8763ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
/* eslint-disable no-console */ | ||
|
||
const fs = require('fs'); | ||
|
||
const json = fs.readFileSync('package.json', 'utf8'); | ||
|
||
const pack = JSON.parse(json); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it's better but I would do a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried it at first because it does look a lot cleaner but then node can't seem to find the file, it only works when I use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think fs is relative to pwd and require to the file. Try There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, require is relative to the file... I forgot about that! |
||
|
||
if (!pack.rnpm) { | ||
pack.rnpm = { | ||
assets: [], | ||
}; | ||
} else if (!pack.rnpm.assets) { | ||
pack.rnpm.assets = []; | ||
} | ||
|
||
for (let i = 0; i < pack.rnpm.assets.length; i += 1) | ||
if (pack.rnpm.assets[i] === './assets/fonts') process.exit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Total blackout here, of course that's what it should be! |
||
|
||
pack.rnpm.assets.push('./assets/fonts'); | ||
|
||
fs.writeFileSync('package.json', JSON.stringify(pack, null, 2), 'utf8'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very small detail, but most prefer files ending with a new line and many editors will add it by just saving. To avoid diffs, could you add one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do too, I don't know if it's git or my editor (currently JetBrains) but I have to have two blank lines at the end to make one blank line in the saved file. It seems like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant in the generated package.json There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, got it! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
|
||
echo "Please enter your FontAwesome5 npm token:" | ||
|
||
read fa5_token | ||
|
||
echo "Setting up npm config" | ||
|
||
npm config set "@fortawesome:registry" https://npm.fontawesome.com/ | ||
npm config set "//npm.fontawesome.com/:_authToken" $fa5_token | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming that this might already have been done before. Maybe we should check whether the setting already exists and not ask for token in that case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how to implement this, I can read the first variable and only set it to a new value if it is undefined. However, the second one is secret and I can't read anything from checking |
||
|
||
echo "Creating temporary folder" | ||
|
||
TEMP_DIR=`mktemp -d -t rnvi` | ||
echo "Created folder $TEMP_DIR" | ||
pushd $TEMP_DIR | ||
|
||
echo "Downloading FontAwesome5 Pro" | ||
|
||
npm pack @fortawesome/fontawesome-pro | ||
tar -xzf fortawesome-fontawesome-pro* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK |
||
mv package pro | ||
|
||
popd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Learned a new command today, thanks! |
||
|
||
echo "Copying font files" | ||
|
||
mkdir -p assets/fonts | ||
|
||
cp $TEMP_DIR/pro/webfonts/fa-brands-400.ttf assets/fonts/FontAwesome5_Pro_Brands.ttf | ||
cp $TEMP_DIR/pro/webfonts/fa-light-300.ttf assets/fonts/FontAwesome5_Pro_Light.ttf | ||
cp $TEMP_DIR/pro/webfonts/fa-regular-400.ttf assets/fonts/FontAwesome5_Pro_Regular.ttf | ||
cp $TEMP_DIR/pro/webfonts/fa-solid-900.ttf assets/fonts/FontAwesome5_Pro_Solid.ttf | ||
|
||
echo "Modifying package.json" | ||
|
||
add-font-assets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes $PATH variable to include |
||
|
||
echo "Linking project" | ||
|
||
react-native link | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is potentially dangerous, can we be explicit with only linking the current project? Didn't try but was thinking like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran with |
||
|
||
echo "Done" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
"description": "Customizable Icons for React Native with support for NavBar/TabBar/ToolbarAndroid, image source and full styling.", | ||
"main": "dist/index.js", | ||
"bin": { | ||
"add-font-assets": "./bin/add-font-assets.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to expose this script to the user? If so maybe document it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, it is only useful when running |
||
"fa5-upgrade": "./bin/fa5-upgrade.sh", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to prefix this somehow? I know There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know, looking through some |
||
"generate-icon": "./bin/generate-icon.js" | ||
}, | ||
"scripts": { | ||
|
@@ -23,8 +25,7 @@ | |
"build-materialcommunityicons": "./scripts/materialcommunityicons.sh", | ||
"build-octicons": "./scripts/octicons.sh", | ||
"build-zocial": "./scripts/zocial.sh", | ||
"build-simplelineicons": "./scripts/simplelineicons.sh", | ||
"fa5upgrade": "./scripts/fa5upgrade.sh" | ||
"build-simplelineicons": "./scripts/simplelineicons.sh" | ||
}, | ||
"keywords": [ | ||
"react-native", | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm run fa5-upgrade
or./node_modules/.bin/fa5-upgrade
, yeah?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm run fa5-upgrade
results innpm ERR! missing script: fa5-upgrade
for me../node_modules/.bin/fa5-upgrade
works but so doesfa5-upgrade
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that only works with yarn, let’s change to full bin path (current name is wrong now anyway). Not everybody has set up their path to include node_modules.