Skip to content

Commit

Permalink
refactor(monorepo): create a monorepo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Sep 12, 2023
1 parent 3120df4 commit 06f95ad
Show file tree
Hide file tree
Showing 121 changed files with 29,447 additions and 32,889 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md
55 changes: 55 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
'root': true,
'parser': '@typescript-eslint/parser',
'env': {
'es6': true,
},
'ignorePatterns': [
'node_modules',
'build',
'coverage',
'src/contracts/ethers-typechain',
],
'plugins': [
'import',
'eslint-comments',
],
'extends': [
'eslint:recommended',
'plugin:eslint-comments/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'prettier',
],
'globals': {
'BigInt': true,
'console': true,
'WebAssembly': true,
},
'rules': {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'eslint-comments/disable-enable-pair': [
'error',
{
'allowWholeFile': true,
},
],
'import/order': [
'error',
{
'newlines-between': 'always',
'alphabetize': {
'order': 'asc',
},
},
],
'sort-imports': [
'error',
{
'ignoreDeclarationSort': true,
'ignoreCase': true,
},
],
},
};
53 changes: 0 additions & 53 deletions .eslintrc.json

This file was deleted.

64 changes: 16 additions & 48 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,33 @@ jobs:
os: [ ubuntu-latest ]

steps:
- name: Checkout repo
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
- uses: pnpm/action-setup@v2
with:
node-version: ${{ matrix.node }}
version: 8.1

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Check
run: yarn run package-check
- run: pnpm install

- name: Build
run: yarn build
run: pnpm build

- name: Lint
run: pnpm ci:lint

- name: Test
run: yarn test
run: pnpm test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true

- name: BundleMon
uses: lironer/bundlemon-action@v1

build_examples:
name: Build project examples

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '16.x' ]
os: [ ubuntu-latest ]
example:
[
'nodejs',
'react-craco',
'react-webpack-5-experiments',
'webpack-5-experiments',
'webpack-bundler',
]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
with:
working-directory: examples/${{ matrix.example }}

- name: Build
run: CI=false yarn build
working-directory: examples/${{ matrix.example }}
# TODO: Fix or replace bundlemon on CI
# - name: Analyze bundle size
# uses: lironer/bundlemon-action@v1
16 changes: 10 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
*.log
.DS_Store
node_modules
build
dist
*.log
*.tsbuildinfo
.DS_Store
coverage
example/dist
.husky
.env
types
dist
.nvmrc
!examples/**/.env
src/contracts/ethers-typechain
contracts/compiled
examples/*/pnpm-lock.yaml
pnpm-debug.log
docs-json
docs
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
11 changes: 7 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# package.json is formatted by package managers, so we ignore it here
package.json
coverage
build
types/ethers-contracts
**/dist/**
**/types/**
**/build/**
CHANGELOG.md
**/*.sol
README.md
/packages/nucypher-ts/src/contracts/ethers-typechain/
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"proseWrap": "always"
}
38 changes: 1 addition & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
# nucypher-ts

A TypeScript library for interacting with access control functionality in the browser.

Full documentation can be found [here](https://docs.threshold.network/app-development/threshold-access-control-tac).

> **Warning**
>
> `nucypher-ts` is under [active development](https://github.com/nucypher/nucypher-ts/pulls):
>
> - SDK does not support policy revocation.
> - We expect breaking changes.
## Installation

```
yarn add @nucypher/nucypher-ts
```

## Tutorial

To learn more, follow the tutorial at Threshold Network's [docs](https://docs.threshold.network/app-development/threshold-access-control-tac/get-started-with-tac).

## Examples

See [`nucypher-ts/examples`](https://github.com/nucypher/nucypher-ts/tree/main/examples) to find out how to integrate `nucypher-ts` into your favorite web framework.

We also provide two code samples of TAC applications:

- [nucypher/tdec-sandbox](https://github.com/nucypher/tdec-sandbox)
- [nucypher/tdec-nft-example](https://github.com/nucypher/tdec-nft-example)

These examples showcase integration with React-based web application and an end-to-end flow of creating conditioned encryption, and encrypting & decrypting data.

# Contributing

If you would like to contribute to the development of `nucypher-ts`, please see our [Contributing Guide](CONTRIBUTING.md). You can also join our [Discord](http://discord.gg/threshold) and say hello!
# nucypher-ts-mono
41 changes: 0 additions & 41 deletions examples/api-example.ts

This file was deleted.

50 changes: 25 additions & 25 deletions examples/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
const bodyParser = require('body-parser');
const cors = require('cors');
const express = require('express');
const router = require('express').Router();
const nucypher = require('@nucypher/nucypher-ts');

router.get('/', (req, res) => {
const config = {
// Public Porter endpoint on Tapir network
porterUri: 'https://porter-tapir.nucypher.community',
};

const secretKey = nucypher.SecretKey.fromBytes(Buffer.from('fake-secret-key-32-bytes-bob-xxx'));
const bob = nucypher.Bob.fromSecretKey(config, secretKey);

res.send(bob.decryptingKey.toString());
});

const app = express();
app.use(bodyParser.json());
app.use(cors());
app.use(router);

const port = 3000;
app.listen(port, () => console.log(`Listening on port ${port}!`));
const bodyParser = require('body-parser');
const cors = require('cors');
const express = require('express');
const router = require('express').Router();
const nucypher = require('@nucypher/nucypher-ts');

router.get('/', (req, res) => {
const config = {
// Public Porter endpoint on Tapir network
porterUri: 'https://porter-tapir.nucypher.community',
};

const secretKey = nucypher.SecretKey.fromBytes(Buffer.from('fake-secret-key-32-bytes-bob-xxx'));
const bob = nucypher.Bob.fromSecretKey(config, secretKey);

res.send(bob.decryptingKey.toString());
});

const app = express();
app.use(bodyParser.json());
app.use(cors());
app.use(router);

const port = 3000;
app.listen(port, () => console.log(`Listening on port ${port}!`));
Loading

0 comments on commit 06f95ad

Please sign in to comment.