Skip to content

Commit

Permalink
Prepare repo for the public (#1)
Browse files Browse the repository at this point in the history
Changes to achieve open source readiness
  • Loading branch information
mrashed-dev authored Jul 20, 2022
1 parent 47307cb commit 18fbca5
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
lib
example
50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
env: {
es6: true,
node: true,
browser: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: ['@typescript-eslint', 'react'],
extends: [
'eslint:recommended',
'prettier',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
],
rules: {
'no-console': ['error', { allow: ['warn', 'error', 'time'] }],
'react/jsx-pascal-case': 2,
'react/no-multi-comp': 2,
'react/prefer-es6-class': 2,
'react/prefer-stateless-function': 2,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variableLike',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'variable',
modifiers: ['destructured'],
format: null,
},
],
'no-undef': 'error',
},
};
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Report a bug or issue to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Some steps involved to reproduce the bug and any code samples you can share.
```
// Helps us with reproducing the error :)
```

**Expected behavior**
A clear and concise description of what you expected to happen.

**SDK Version:**
Providing the SDK version can help with the reproduction of the issue and to know if a change could have broken something.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Description
<!-- Add information about what your PR achieves -->

# Usage
<!-- If your PR brings a new feature or a change to how you use the SDK, show it off here! -->
```typescript jsx
// Adding a code snippet also helps if it makes sense to do so :)
```

# License
I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.
30 changes: 30 additions & 0 deletions .github/workflows/pull-reqeust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pull Request
on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main

jobs:
checks:
runs-on: ubuntu-latest
name: Lint and check code styling
steps:
- uses: actions/checkout@v2
- name: Setup Nodejs ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install dependencies and build
run: npm install

- name: Run lint checks
run: npm run lint:ci

- name: Run prettier checks
run: npm run lint:prettier:check
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
lib
example
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changelog

### 0.1.0 / TBD
* Initial release of the Nylas React SDK
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contribute to Nylas
👍🎉 First off, thanks for taking the time to contribute! 🎉👍

The following is a set of guidelines for contributing to the Nylas JavaScript SDK; these are guidelines, not rules, so please use your best judgement and feel free to propose changes to this document via pull request.

## How to Ask a Question

If you have a question about how to use the JavaScript SDK, please [create an issue](https://github.com/nylas/nylas-js/issues) and label it as a question. If you have more general questions about the Nylas Communications Platform, or the Nylas Email, Calendar, and Contacts API, please reach out to [email protected] to get help.

## How To Contribute
### Report a Bug or Request a Feature

If you encounter any bugs while using this software, or want to request a new feature or enhancement, please [create an issue](https://github.com/nylas/nylas-js/issues) to report it, and make sure you add a label to indicate what type of issue it is.

### Contribute Code

Pull requests are welcome for bug fixes. If you want to implement something new, [please request a feature](https://github.com/nylas/nylas-js/issues) first so we can discuss it.

While writing your code contribution, make sure you lint your code by running:

`npm run lint`

and apply our code styling standards:

`npm run lint:prettier`

To use the package during local development, symlink the directory:

`npm link` in the `nylas-js` directory
`npm link @nylas/nylas-js` in the directory with your code that uses the package

### Creating a Pull Request

When your code is ready to be submitted, you can [submit a pull request](https://help.github.com/articles/creating-a-pull-request/) to begin the code review process. Please ensure to title it appropriately with a nice, quick summary of what the PR is achieving. We've also provided a [template for pull requests](pull_request_template.md) as a guide.

All PRs from contributors that aren't employed by Nylas must contain the following text in the PR description: "I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner."
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)
----

Copyright (c) 2014-2015 InboxApp, Inc. and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<a href="https://www.nylas.com/">
<img src="https://brand.nylas.com/assets/downloads/logo_horizontal_png/Nylas-Logo-Horizontal-Blue_.png" alt="Aimeos logo" title="Aimeos" align="right" height="60" />
</a>

# Nylas React SDK

![npm](https://img.shields.io/npm/v/@nylas/nylas-react)
Expand All @@ -10,7 +14,7 @@ Here are some resources to help you get started:
- [Nylas API Reference](https://developer.nylas.com/docs/api/)


# Install
## ⚙️ Install

To install the Nylas React SDK, you will first need to have [npm](https://www.npmjs.com/get-npm) installed on your machine.

Expand All @@ -27,7 +31,7 @@ cd nylas-react
npm install
```

# Usage
## ⚡️ Usage

The Nylas React SDK provides an easy way to implement authentication in your react application.

Expand All @@ -46,11 +50,13 @@ These are the following options that can be passed in to configure an instance o
* authWithRedirect - The function for building, and redirecting to, the authentication URL
* exchangeCodeFromUrlForToken - The function for parsing the code from the authentication URL and exchanging it for an access token

# Contributing
## 💙 Contributing

Interested in contributing to the Nylas JavaScript SDK project? Thanks so much for your interest! We are always looking for improvements to the project and contributions from open-source developers are greatly appreciated.

Please refer to [Contributing](Contributing.md) for information about how to make contributions to this project. We welcome questions, bug reports, and pull requests.

# License
## 📝License

This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms.

Expand Down
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,26 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc"
"build": "tsc",
"lint": "eslint --ext .js,.ts -f visualstudio .",
"lint:fix": "npm run lint -- --fix",
"lint:ci": "npm run lint:fix -- --quiet",
"lint:prettier": "prettier --write '**/*.{ts,js}'",
"lint:prettier:check": "prettier --check '**/*.{ts,js}'"
},
"dependencies": {
"@nylas/nylas-js": "^0.1.0"
},
"devDependencies": {
"typescript": "^4.7.4",
"react": "^18.2.0",
"@types/react": "^18.0.12"
"@types/react": "^18.0.12",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"prettier": "^2.7.1"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export {
default as NylasContainer,
NylasContainerOptions
NylasContainerOptions,
} from './nylas-container';
export {
default as NylasContext,
NylasContextInterface,
useNylas
useNylas,
} from './nylas-context';
export {
NylasProps,
AuthUrlOptions,
ExchangeCodeOptions
} from '@nylas/nylas-js';
ExchangeCodeOptions,
} from '@nylas/nylas-js';
13 changes: 8 additions & 5 deletions src/nylas-context.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import * as React from 'react';
import Nylas, {AuthUrlOptions, ExchangeCodeOptions} from "@nylas/nylas-js";
import Nylas, { AuthUrlOptions, ExchangeCodeOptions } from '@nylas/nylas-js';

export interface NylasContextInterface {
client: Nylas;
authState: boolean;
authWithRedirect(opts: AuthUrlOptions): Promise<void|boolean>;
exchangeCodeFromUrlForToken(opts?: ExchangeCodeOptions): Promise<string | boolean>;
authWithRedirect(opts: AuthUrlOptions): Promise<void | boolean>;
exchangeCodeFromUrlForToken(
opts?: ExchangeCodeOptions
): Promise<string | boolean>;
}

const NylasContext = React.createContext<NylasContextInterface | null>(null);

export const useNylas = (): NylasContextInterface => React.useContext(NylasContext) as NylasContextInterface;
export const useNylas = (): NylasContextInterface =>
React.useContext(NylasContext) as NylasContextInterface;

export default NylasContext;
export default NylasContext;

0 comments on commit 18fbca5

Please sign in to comment.