Skip to content

Commit

Permalink
Add Makefile and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesdemers committed Dec 6, 2023
1 parent 6b336cb commit 2ec9d90
Show file tree
Hide file tree
Showing 13 changed files with 1,896 additions and 1,501 deletions.
24 changes: 24 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## 📖 Description

<!-- What does this pull request bring to this project? Why do we need it? -->

## ⚠️ Problem

<!-- Description of what is the problem that we're trying to solve -->

## 🤓 Solution

<!-- The most exhaustive description of what is the solution and WHY it's the best solution -->

## 📝 Notes

<!-- Any additional notes that might be helpful for reviewers? -->

## 📓 References

<!-- Does this pull request fix any reported issue (eg. `Fixes #34`) in this repository? -->

## 🦀 Dispatch

- `#dispatch/react`
- `#dispatch/react-native`
12 changes: 4 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ jobs:
node-version: 16.14
cache: 'yarn'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Run eslint
run: yarn run lint
- name: Run Prettier
run: yarn run prettier-check
- name: Run type check
run: yarn run type-check
run: make ci-dependencies
- name: Run checks
run: make check-all
- name: Run Tests
run: yarn run test
run: make ci-test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib
coverage
node_modules
example/.expo
62 changes: 62 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Contributing

When it comes to open source, there are different ways you can contribute, all of which are valuable. Here’s few guidelines that should help you as you prepare your contribution.

## Initial steps

Before you start working on a contribution, create an issue describing what you want to build. It’s possible someone else is already working on something similar, or perhaps there is a reason that feature isn’t implemented. The maintainers will point you in the right direction.

<!-- ## Submitting a Pull Request
- Fork the repo
- Clone your forked repository: `git clone [email protected]:{your_username}/react-native-killswitch.git`
- Enter the directory: `cd react-native-killswitch`
- Create a new branch off the `main` branch: `git checkout -b your-feature-name`
- Implement your contributions (see the Development section for more information)
- Push your branch to the repo: `git push origin your-feature-name`
- Go to https://github.com/mirego/react-native-killswitch/compare and select the branch you just pushed in the "compare:" dropdown
- Submit the PR. The maintainers will follow up. -->

## Development

The following steps will get you setup to contribute changes to this repo:

1. Fork this repo.

2. Clone your forked repo: `git clone [email protected]:{your_username}/react-native-killswitch.git`

3. Run `make dependencies` to install dependencies for the library and the sample app.

4. Start playing with the code! You can do some experimentation with the sample app provided in the `example` folder or start implementing a feature right away.

### Commands

**`make test`**

- Runs all Jest tests

**`make check-all`**

- Runs linting, format-checking, type-checking

**`make format`**

- Runs formatting on the codebase

**`make start-example`**

- Runs the sample app with Expo

### Tests

react-native-killswitch uses Jest for testing. After implementing your contribution, write tests for it. Just create a new file under `src/__tests__` or add additional tests to the appropriate existing file.

Before submitting your PR, run `make test` to make sure there are no (unintended) breaking changes.

### Documentation

The react-native-killswitch documentation lives in the README.md. Be sure to document any API changes you implement.

## License

By contributing your code to the react-native-killswitch GitHub repository, you agree to license your contribution under the BSD 3-Clause license.
98 changes: 98 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Build configuration
# -------------------

APP_NAME = `grep -m1 name package.json | awk -F: '{ print $$2 }' | sed 's/[ ",]//g'`
APP_VERSION = `grep -m1 version package.json | awk -F: '{ print $$2 }' | sed 's/[ ",]//g'`
GIT_REVISION = `git rev-parse HEAD`

# Linter and formatter configuration
# ----------------------------------

PRETTIER_FILES_PATTERN = '{src,example}/**/*.{js,ts,tsx,svg,json}' '**/*.md'
SCRIPTS_PATTERN = '{src,example}/**/*.{js,ts,tsx}'

# Introspection targets
# ---------------------

.PHONY: help
help: header targets

.PHONY: header
header:
@echo "\033[34mEnvironment\033[0m"
@echo "\033[34m---------------------------------------------------------------\033[0m"
@printf "\033[33m%-23s\033[0m" "APP_NAME"
@printf "\033[35m%s\033[0m" $(APP_NAME)
@echo ""
@printf "\033[33m%-23s\033[0m" "APP_VERSION"
@printf "\033[35m%s\033[0m" $(APP_VERSION)
@echo ""
@printf "\033[33m%-23s\033[0m" "GIT_REVISION"
@printf "\033[35m%s\033[0m" $(GIT_REVISION)
@echo "\n"

.PHONY: targets
targets:
@echo "\033[34mTargets\033[0m"
@echo "\033[34m---------------------------------------------------------------\033[0m"
@perl -nle'print $& if m{^[a-zA-Z_-\d]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-22s\033[0m %s\n", $$1, $$2}'

# Development targets
# -------------------

.PHONY: dependencies
dependencies: ## Install dependencies required by the application
- yarn install
- yarn --cwd example install

.PHONY: ci-dependencies
ci-dependencies: ## Install dependencies required by the application in CI
yarn install --frozen-lockfile

.PHONY: ci-test
ci-test: ## Run the test suite in CI
CI=true yarn test --forceExit --detectOpenHandles

.PHONY: test
test: ## Run the test suite
yarn test --forceExit --detectOpenHandles

.PHONY: start-example
start-example: ## Run the test suite
yarn --cwd example start

# Check, lint and format targets
# ------------------------------

.PHONY: check
check: check-format lint

.PHONY: check-all
check-all: check-format lint check-types

.PHONY: check-format
check-format:
yarn prettier --check $(PRETTIER_FILES_PATTERN)

.PHONY: check-types
check-types:
yarn tsc --noEmit

.PHONY: format
format: ## Format project files
- yarn prettier --write $(PRETTIER_FILES_PATTERN)
- yarn eslint --fix $(SCRIPTS_PATTERN)

.PHONY: lint
lint: ## Lint project files
yarn eslint --max-warnings 0 $(SCRIPTS_PATTERN)

# Release
# ------------------------------
.PHONY: version
version:
- yarn version

.PHONY: release
release:
- yarn run release-it
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<p>
<strong>React Native Killswitch</strong> is a library built by <a href="https://www.mirego.com">Mirego</a> that allows mobile developers to apply<br /> runtime version-specific behaviors to their React Native application.
</p>

<a href="https://github.com/mirego/react-native-killswitch/actions/workflows/ci.yaml"><img src="https://github.com/mirego/react-native-killswitch/actions/workflows/ci.yaml/badge.svg?branch=main" /></a>
<a href="https://github.com/mirego/react-native-killswitch/tags"><img src="https://img.shields.io/npm/v/react-native-killswitch.svg"></a><br /><br />

<a href="https://github.com/mirego/react-native-killswitch/actions/workflows/ci.yaml"><img src="https://github.com/mirego/react-native-killswitch/actions/workflows/ci.yaml/badge.svg?branch=main" /></a>
<a href="https://github.com/mirego/react-native-killswitch/tags"><img src="https://img.shields.io/npm/v/react-native-killswitch.svg"></a><br /><br />

</div>

## What is Killswitch?
Expand Down
8 changes: 0 additions & 8 deletions example/.expo/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions example/.expo/devices.json

This file was deleted.

4 changes: 1 addition & 3 deletions example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"expo": "~47.0.8",
"expo-status-bar": "~1.4.2",
"react": "18.1.0",
"react-native": "0.70.5"
"react-native": "0.70.8"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"babel-plugin-module-resolver": "^4.1.0"
},
"private": true
}
}
Loading

0 comments on commit 2ec9d90

Please sign in to comment.