Skip to content

Commit eb5f74d

Browse files
author
Heimer Nguyen
committed
Initial commit for React Native Image Code Scanner library, including core functionality for barcode scanning, example app, and configuration files. Added support for iOS and Android platforms, with comprehensive documentation and setup instructions.
0 parents  commit eb5f74d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4614
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
indent_style = space
10+
indent_size = 2
11+
12+
end_of_line = lf
13+
charset = utf-8
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pbxproj -text
2+
# specific for windows script files
3+
*.bat text eol=crlf
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 🐛 Bug report
2+
description: Report a reproducible bug or regression in this library.
3+
labels: [bug]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
# Bug report
9+
10+
👋 Hi!
11+
12+
**Please fill the following carefully before opening a new issue ❗**
13+
*(Your issue may be closed if it doesn't provide the required pieces of information)*
14+
- type: checkboxes
15+
attributes:
16+
label: Before submitting a new issue
17+
description: Please perform simple checks first.
18+
options:
19+
- label: I tested using the latest version of the library, as the bug might be already fixed.
20+
required: true
21+
- label: I tested using a [supported version](https://github.com/reactwg/react-native-releases/blob/main/docs/support.md) of react native.
22+
required: true
23+
- label: I checked for possible duplicate issues, with possible answers.
24+
required: true
25+
- type: textarea
26+
id: summary
27+
attributes:
28+
label: Bug summary
29+
description: |
30+
Provide a clear and concise description of what the bug is.
31+
If needed, you can also provide other samples: error messages / stack traces, screenshots, gifs, etc.
32+
validations:
33+
required: true
34+
- type: input
35+
id: library-version
36+
attributes:
37+
label: Library version
38+
description: What version of the library are you using?
39+
placeholder: "x.x.x"
40+
validations:
41+
required: true
42+
- type: textarea
43+
id: react-native-info
44+
attributes:
45+
label: Environment info
46+
description: Run `react-native info` in your terminal and paste the results here.
47+
render: shell
48+
validations:
49+
required: true
50+
- type: textarea
51+
id: steps-to-reproduce
52+
attributes:
53+
label: Steps to reproduce
54+
description: |
55+
You must provide a clear list of steps and code to reproduce the problem.
56+
value: |
57+
1. …
58+
2. …
59+
validations:
60+
required: true
61+
- type: input
62+
id: reproducible-example
63+
attributes:
64+
label: Reproducible example repository
65+
description: Please provide a link to a repository on GitHub with a reproducible example.
66+
validations:
67+
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Feature Request 💡
4+
url: https://github.com/nguyenthanhan/react-native-image-code-scanner/discussions/new?category=ideas
5+
about: If you have a feature request, please create a new discussion on GitHub.
6+
- name: Discussions on GitHub 💬
7+
url: https://github.com/nguyenthanhan/react-native-image-code-scanner/discussions
8+
about: If this library works as promised but you need help, please ask questions there.

.github/actions/setup/action.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Setup
2+
description: Setup Node.js and install dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Node.js
8+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
9+
with:
10+
node-version-file: .nvmrc
11+
12+
- name: Restore dependencies
13+
id: yarn-cache
14+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
15+
with:
16+
path: |
17+
**/node_modules
18+
.yarn/install-state.gz
19+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
20+
restore-keys: |
21+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
22+
${{ runner.os }}-yarn-
23+
24+
- name: Install dependencies
25+
if: steps.yarn-cache.outputs.cache-hit != 'true'
26+
run: yarn install --immutable
27+
shell: bash
28+
29+
- name: Cache dependencies
30+
if: steps.yarn-cache.outputs.cache-hit != 'true'
31+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
32+
with:
33+
path: |
34+
**/node_modules
35+
.yarn/install-state.gz
36+
key: ${{ steps.yarn-cache.outputs.cache-primary-key }}

.github/workflows/ci.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
merge_group:
10+
types:
11+
- checks_requested
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
20+
- name: Setup
21+
uses: ./.github/actions/setup
22+
23+
- name: Lint files
24+
run: yarn lint
25+
26+
- name: Typecheck files
27+
run: yarn typecheck
28+
29+
test:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34+
35+
- name: Setup
36+
uses: ./.github/actions/setup
37+
38+
- name: Run unit tests
39+
run: yarn test --maxWorkers=2 --coverage
40+
41+
build-library:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46+
47+
- name: Setup
48+
uses: ./.github/actions/setup
49+
50+
- name: Build package
51+
run: yarn prepare
52+
53+
build-android:
54+
runs-on: ubuntu-latest
55+
env:
56+
TURBO_CACHE_DIR: .turbo/android
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
60+
61+
- name: Setup
62+
uses: ./.github/actions/setup
63+
64+
- name: Cache turborepo for Android
65+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
66+
with:
67+
path: ${{ env.TURBO_CACHE_DIR }}
68+
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
69+
restore-keys: |
70+
${{ runner.os }}-turborepo-android-
71+
72+
- name: Check turborepo cache for Android
73+
run: |
74+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
75+
76+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
77+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
78+
fi
79+
80+
- name: Install JDK
81+
if: env.turbo_cache_hit != 1
82+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
83+
with:
84+
distribution: 'zulu'
85+
java-version: '17'
86+
87+
- name: Finalize Android SDK
88+
if: env.turbo_cache_hit != 1
89+
run: |
90+
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
91+
92+
- name: Cache Gradle
93+
if: env.turbo_cache_hit != 1
94+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
95+
with:
96+
path: |
97+
~/.gradle/wrapper
98+
~/.gradle/caches
99+
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
100+
restore-keys: |
101+
${{ runner.os }}-gradle-
102+
103+
- name: Build example for Android
104+
env:
105+
JAVA_OPTS: "-XX:MaxHeapSize=6g"
106+
run: |
107+
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
108+
109+
build-ios:
110+
runs-on: macos-latest
111+
env:
112+
XCODE_VERSION: 16.2
113+
TURBO_CACHE_DIR: .turbo/ios
114+
steps:
115+
- name: Checkout
116+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
117+
118+
- name: Setup
119+
uses: ./.github/actions/setup
120+
121+
- name: Cache turborepo for iOS
122+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
123+
with:
124+
path: ${{ env.TURBO_CACHE_DIR }}
125+
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
126+
restore-keys: |
127+
${{ runner.os }}-turborepo-ios-
128+
129+
- name: Check turborepo cache for iOS
130+
run: |
131+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
132+
133+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
134+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
135+
fi
136+
137+
- name: Use appropriate Xcode version
138+
if: env.turbo_cache_hit != 1
139+
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
140+
with:
141+
xcode-version: ${{ env.XCODE_VERSION }}
142+
143+
- name: Install cocoapods
144+
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
145+
run: |
146+
cd example
147+
bundle install
148+
bundle exec pod repo update --verbose
149+
bundle exec pod install --project-directory=ios
150+
151+
- name: Build example for iOS
152+
run: |
153+
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

.github/workflows/publish.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to publish (leave empty to use package.json version)'
10+
required: false
11+
type: string
12+
tag:
13+
description: 'npm tag (latest, beta, next)'
14+
required: false
15+
default: 'latest'
16+
type: choice
17+
options:
18+
- latest
19+
- beta
20+
- next
21+
22+
jobs:
23+
publish:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
packages: write
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: '18'
36+
registry-url: 'https://registry.npmjs.org'
37+
38+
- name: Install Yarn
39+
run: npm install -g yarn
40+
41+
- name: Install dependencies
42+
run: yarn install --frozen-lockfile
43+
44+
- name: Run tests
45+
run: yarn test
46+
47+
- name: Lint
48+
run: yarn lint
49+
50+
- name: Typecheck
51+
run: yarn typecheck
52+
53+
- name: Build package
54+
run: yarn build
55+
56+
- name: Set version
57+
if: github.event.inputs.version != ''
58+
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version
59+
60+
- name: Publish to npm
61+
run: |
62+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
63+
npm publish --tag ${{ github.event.inputs.tag }}
64+
else
65+
npm publish
66+
fi
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
69+
70+
- name: Create GitHub Release Notes
71+
if: github.event_name != 'release'
72+
uses: actions/create-release@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
with:
76+
tag_name: v${{ github.event.inputs.version || 'package.json version' }}
77+
release_name: Release v${{ github.event.inputs.version || 'package.json version' }}
78+
body: |
79+
## Changes
80+
81+
See [CHANGELOG.md](https://github.com/nguyenthanhan/react-native-image-code-scanner/blob/main/CHANGELOG.md) for details.
82+
draft: false
83+
prerelease: ${{ github.event.inputs.tag != 'latest' }}

0 commit comments

Comments
 (0)