Developer documentation
Package renamed
New package name: react-native-cross-components
These are some of the common use components Crossplatform use in our projects.
Table of contents generated with markdown-toc
Install with react-native-paper if you don't already have it.
Package renamed
Previous package name: @crossplatform/react-native-components
New package name: react-native-cross-components
npm i react-native-paper
npm i react-native-cross-component
Or if you're hanging with the cool kids
yarn add react-native-paper
yarn add react-native-cross-component
Adjust the rights on SH-files for your user (in root). Remarks: we use bash terminal in VS Code
yarn read-sh
Or manually:
sudo find . -name "\*.sh" | xargs chmod u+x
We use version 8 of the Java JDK. On OSX, remove any older versions according to this process
brew cask remove java
sudo rm -rf "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin"
sudo rm -rf "/Library/PreferencePanes/JavaControlPanel.prefPane"
sudo rm -rf "~/Library/Application Support/Oracle"
sudo rm -rf "~/Library/Java"
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
We're using latest stable. Install the version for your OS from:
You need the manager to log in to Microsoft from MacOS using Git.
If you've updated Java, re-install GCM after.
git-credential-manager install
These versions provides stable compatibility with React Native and other frameworks:
- Node v8.9.4 (
node --version
) - npm 5.6.0 (
npm --version
)
We install and run our scripts with yarn, as an alternative to npm:
We use Visual Studio Code with relevant plugins.
Always run after pull / clone!
- Installs global tools (npm packages, CLI tools)
- Cleans code using
yarn lint
Install global CLI tools required by the project
Executes lint.sh
that runs prettier and tslint code formatting, fixing inconsistencies.
Start TypeScript compiler. Run at least once to generate /lib folder where JavaScript resides. You can also...
Start TypeScript compiler and watch for changes.
Start the React-Native packager. You can also start it with options:
npm start -- --reset-cache
# or
yarn start -- --reset-cache
Run tests in watch mode, for development, updating snapshots as needed.
Runs the jest test runner on your tests in watch mode with interactive console. Remember to run u
option when prompted to update snapshots. This is alias to npm run test
Run tests as CI, not updating any snapshots. Run this before commit to ensure tests will work on build server.
You can run CI style tests in respective folder using
yarn test
But in development you would want to test and update Jest snapshots (--u
):
yarn test-watch
Generate documentation. Read more
Up the NPM package version before running npm publish
. Automatically run as prepublishOnly
command.
Use VS Code's debugging capabilities to maintain a effective development cycle.
Launch.json
configuration is not checked in, but here is the debug launch.json
for React-Native
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Expo",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
And finally Jest Test debugging:
({
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
"--collectCoverage=false"
],
"args": ["test", "--runInBand", "--no-cache", "--env=jsdom"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
},
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceRoot}/node_modules/jest/bin/jest",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
"--collectCoverage=false"
],
"args": ["${file}", "--no-cache", "--env=jsdom"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
})
The project is released through NPM
The source code is available on the Crossplatform GitHub.
- Update the version. This will also run build and linting.
yarn npm-version
- Publish the new version on NPM (if not logged in run
npm adduser
first)
npm publish --access public
Generate documentation using the docs
command
yarn docs
This will
- Generate docs using the
typedoc
library (yarn generate-docs
) - Publish to GitHub pages using the
gh-pages
library (yarn gh-pages
)