Skip to content

Commit a31db06

Browse files
Added native icons publish (#211)
* Added native icons publish * updated workflow * added --yes flag in npx * minor changes * update README * Ignored the dist folder * edited dist/index generation * minor changes * README updation * README updation * function name change * removed dist * indev generation edits --------- Co-authored-by: Abhay V Ashokan <[email protected]>
1 parent 6e26426 commit a31db06

File tree

6 files changed

+121
-3
lines changed

6 files changed

+121
-3
lines changed

.github/workflows/create_and_publish_releases.yml

+25
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,28 @@ jobs:
7979
with:
8080
access: "public"
8181
token: ${{ secrets.NPM_TOKEN }}
82+
83+
generate_and_publish_native:
84+
name: "Generate and Publish Native Icons"
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout the repository
88+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
89+
90+
- name: Setup git user
91+
run: |
92+
git config user.name "Abhay V Ashokan"
93+
git config user.email "[email protected]"
94+
95+
- name: Setup NodeJS LTS version
96+
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
97+
with:
98+
node-version-file: '.nvmrc'
99+
100+
- name: Generate native icons
101+
working-directory: ./native
102+
run: yarn generate
103+
104+
- name: Publish native package to NPM
105+
working-directory: ./native
106+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc && yarn publish --access public

.github/workflows/publish.yml

+21
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,24 @@ jobs:
2727
with:
2828
access: "public"
2929
token: ${{ secrets.NPM_TOKEN }}
30+
31+
publish_native:
32+
name: Publish Native Package to npm
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout the repository
36+
uses: actions/checkout@v3
37+
38+
- name: Setup NodeJS LTS version
39+
uses: actions/setup-node@v3
40+
with:
41+
node-version: "18.12.0"
42+
43+
- name: Generate native icons
44+
working-directory: ./native
45+
run: yarn generate
46+
47+
- name: Publish the native package on NPM
48+
working-directory: ./native
49+
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc && yarn publish --access public
50+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/out-tsc
66
/dist
77
/generate
8+
native/dist
89

910
# Runtime data
1011
pids

README.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
11
# neetoIcons
22

3-
The neetoIcons library is a collection of SVG React component icons that drives
3+
The neetoIcons and neetoIconsRN library are a collection of SVG React component icons that drives
44
the experience in the neeto products built at BigBinary.
55

66
### Installation
77

8+
Web:
9+
810
```
911
yarn add @bigbinary/neeto-icons
1012
```
1113

14+
React Native:
15+
16+
```
17+
yarn add @bigbinary/neeto-icons-rn
18+
```
19+
20+
1221
### Usage
1322

23+
Web:
24+
1425
```javascript
1526
import { Clock } from "@bigbinary/neeto-icons";
1627
```
1728

29+
React Native:
30+
31+
```javascript
32+
import { Icons } from "@bigbinary/neeto-icons-rn";
33+
import { AppIcons } from "@bigbinary/neeto-icons-rn";
34+
import { Logos } from "@bigbinary/neeto-icons-rn";
35+
import { Misc as MiscIcons } from "@bigbinary/neeto-icons-rn";
36+
import { TypefaceLogos } from "@bigbinary/neeto-icons-rn";
37+
38+
const { Archive } = Icons;
39+
```
40+
1841
Anywhere in your React file
1942

2043
```jsx
@@ -85,7 +108,7 @@ Anywhere in your React file
85108

86109
# Building and releasing.
87110

88-
The `@bigbinary/neeto-icons` package gets published to NPM when we merge a PR
111+
The `@bigbinary/neeto-icons` and `@bigbinary/neeto-icons-rn` package gets published to NPM when we merge a PR
89112
with `patch`, `minor` or `major` label to the `main` branch. The `patch` label
90113
is used for bug fixes, `minor` label is used for new features and `major` label
91114
is used for breaking changes. You can checkout the `Create and publish releases`
@@ -101,6 +124,6 @@ github actions will automatically publish the built package to npm. You can
101124
checkout the `Publish to npm` workflow in GitHub Actions to get a live update.
102125

103126
Please note that before publishing the package, you need to verify the
104-
functionality in some of the neeto web-apps locally using `yalc` package
127+
functionality in some of the neeto web and mobile apps locally using `yalc` package
105128
manager. The usage of yalc is explained in this video:
106129
https://youtu.be/QBiYGP0Rhe0

native/index-template.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const path = require("path");
2+
const fs = require("fs");
3+
4+
function defaultIndexTemplate(filePaths) {
5+
const exportEntries = filePaths.map(({ path: filePath }) => {
6+
const basename = path.basename(filePath, path.extname(filePath));
7+
const exportName = /^\d/.test(basename) ? `Svg${basename}` : basename;
8+
return `export { default as ${exportName} } from './${basename}'`;
9+
});
10+
const distPath = path.join(__dirname, "dist");
11+
const folderNames = fs
12+
.readdirSync(distPath, { withFileTypes: true })
13+
.filter((entry) => entry.isDirectory())
14+
.map((entry) => entry.name);
15+
16+
const indexPath = path.join(distPath, "index.js");
17+
const importStatements = folderNames.map(
18+
(folderName) =>
19+
`import * as ${folderName.replace(
20+
/^./,
21+
folderName[0].toUpperCase()
22+
)} from './${folderName}';`
23+
);
24+
let indexContent = importStatements;
25+
const exportStatement = `export { ${folderNames
26+
.map((folderName) => folderName.replace(/^./, folderName[0].toUpperCase()))
27+
.join(", ")} }`;
28+
indexContent.push(exportStatement);
29+
fs.writeFileSync(indexPath, indexContent.join("\n"));
30+
31+
return exportEntries.join("\n");
32+
}
33+
34+
module.exports = defaultIndexTemplate;

native/package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@bigbinary/neeto-icons-rn",
3+
"version": "1.0.0",
4+
"main": "./dist/index.js",
5+
"author": "sangameshsomawar",
6+
"license": "MIT",
7+
"scripts": {
8+
"generate": "npx --yes @svgr/cli --out-dir dist --native --index-template index-template.js -- ../source"
9+
},
10+
"devDependencies": {},
11+
"dependencies": {},
12+
"repository": "https://github.com/bigbinary/neeto-icons.git",
13+
"sideEffects": false
14+
}

0 commit comments

Comments
 (0)