Skip to content
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

Mobile: Snickerdoodle Nodeify package init #918

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ packages/test-harness/data/insight/*

# Mobile
packages/mobile/ios/Pods
packages/mobile-nodeify/node_modules

# Dapps Data
documentation/sdql/examples/output
283 changes: 283 additions & 0 deletions packages/mobile-nodeify/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this eslint so different from the other .eslint? Is that a react native thing?

"env": {
"es6": true,
"node": true
},
"globals": {
// react native
"window": true,
"__DEV__": true,
"localStorage": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"accessor-pairs": "error",
"array-bracket-spacing": "warn",
"array-callback-return": "warn",
"arrow-body-style": "warn",
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": [
"error",
{
"after": true,
"before": true
}
],
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": [
"error",
"1tbs"
],
"callback-return": "error",
"camelcase": "warn",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "off",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": [
"error",
"last"
],
"complexity": "error",
"computed-property-spacing": "error",
"consistent-return": "warn",
"consistent-this": "warn",
"curly": "off",
"default-case": "error",
"dot-location": "off",
"dot-notation": "warn",
"eol-last": "warn",
"eqeqeq": "warn",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "warn",
"func-style": "warn",
"generator-star-spacing": "off",
"global-require": "off",
"guard-for-in": "warn",
"handle-callback-err": "warn",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"line-comment-position": "warn",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "warn",
"lines-around-directive": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "warn",
"max-nested-callbacks": "error",
"max-params": "warn",
"max-statements": "off",
"max-statements-per-line": "error",
"multiline-ternary": "warn",
"new-cap": "error",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "warn",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-case-declarations": "warn",
"no-catch-shadow": "warn",
"no-cond-assign": "warn",
"no-confusing-arrow": "error",
"no-console": "warn",
"no-constant-condition": "warn",
"no-continue": "warn",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-ex-assign": "off",
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"no-empty-function": "off",
"no-eq-null": "warn",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "warn",
"no-extra-semi": "warn",
"no-floating-decimal": "error",
"no-implicit-coercion": "warn",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": "warn",
"no-invalid-this": "warn",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "warn",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "error",
"no-mixed-requires": "error",
"no-multi-assign": "warn",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "warn",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "warn",
"no-path-concat": "error",
"no-process-env": "off",
"no-process-exit": "off",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "warn",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "warn",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "off",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "warn",
"no-undefined": "warn",
"no-underscore-dangle": "warn",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-unused-vars": "warn",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "warn",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "warn",
"no-void": "error",
"no-warning-comments": "warn",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-newline": "off",
"object-curly-spacing": [
"error",
"always"
],
"object-property-newline": [
"error",
{
"allowMultiplePropertiesPerLine": true
}
],
"object-shorthand": "warn",
"one-var": "off",
"one-var-declaration-per-line": "error",
"operator-assignment": "error",
"operator-linebreak": "error",
"padded-blocks": "off",
"prefer-const": "warn",
"prefer-destructuring": "warn",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "warn",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": "error",
"require-await": "error",
"require-jsdoc": "off",
"require-yield": "off",
"rest-spread-spacing": [
"error",
"never"
],
"semi": "off",
"semi-spacing": "error",
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "error",
"space-before-blocks": "error",
"space-before-function-paren": "error",
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": [
"error",
"always"
],
"strict": "error",
"symbol-description": "error",
"template-curly-spacing": [
"error",
"never"
],
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "warn",
"vars-on-top": "off",
"wrap-iife": "error",
"wrap-regex": "warn",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
};
Binary file not shown.
95 changes: 95 additions & 0 deletions packages/mobile-nodeify/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# SnickerDoodle Nodeify

description

## Installation

To deploy this project run

```bash
npm -i sd-nodeify or yarn add sd-nodeify
```

```bash
./node_modules/.bin/sd-nodeify --hack --install
```

```bash
cd ios && pod install
```

In your babel.config.js, add a module resolver

```bash
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
+ [
+ 'module-resolver',
+ {
+ alias: {
+ 'crypto': 'react-native-quick-crypto',
+ 'stream': 'stream-browserify',
+ 'buffer': '@craftzdog/react-native-buffer',
+ 'argon': 'react-native-argon2',
+ },
+ },
+ ],
...
],
'@babel/plugin-syntax-import-assertions',
'babel-plugin-transform-typescript-metadata',
'babel-plugin-parameter-decorator',
['@babel/plugin-proposal-decorators', { legacy: true }],
};
```

In your metro.config.js, add resolver to module_exports

```bash
const extraNodeModules = {
stream: require.resolve('stream-browserify'),
crypto: require.resolve('react-native-quick-crypto'),
zlib: require.resolve('browserify-zlib'),
argon2: require.resolve('react-native-argon2'),
};
// rest of your code
module.exports = {
...
resolver: {
...
extraNodeModules: require('node-libs-react-native'),
},
}
```

Add required imports to your index.ts

```bash
+ import './shim.js';
+ require('node-libs-react-native/globals.js');
+ import 'reflect-metadata';
+ import setGlobalVars from 'indexeddbshim/dist/indexeddbshim-noninvasive';
+ import SQLite from 'react-native-sqlite-2';
+ import { MobileStorageUtils } from 'sd-nodeify';

To activate indexeddb in your project

setGlobalVars(global, {
checkOrigin: false,
win: SQLite,
});
```

In index.ts or whenever you want you can call SnickerdoodleCore

```bash
import { SnickerdoodleCore } from '@snickerdoodlelabs/core';
...
new SnickerdoodleCore(
coreConfig, // Config file for SnickerdoodleCore
new MobileStorageUtils(),
undefined,
undefined,
);
```
Loading