Skip to content

Commit

Permalink
chore(*): create signing manager generator
Browse files Browse the repository at this point in the history
add contribution guidelines, basic docs, improve commit config
  • Loading branch information
monitz87 committed Feb 21, 2022
1 parent d82c4db commit 439f602
Show file tree
Hide file tree
Showing 14 changed files with 312 additions and 124 deletions.
47 changes: 32 additions & 15 deletions .cz-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
module.exports = {
types: [
{ value: 'feat', name: 'feat: A new feature' },
{ value: 'fix', name: 'fix: A bug fix' },
{ value: 'docs', name: 'docs: Documentation only changes' },
{
value: 'feat',
name: 'feat: A new feature',
},
{
value: 'fix',
name: 'fix: A bug fix',
},
{
value: 'docs',
name: 'docs: Documentation only changes',
},
{
value: 'style',
name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)',
Expand All @@ -15,24 +24,38 @@ module.exports = {
value: 'perf',
name: 'perf: A code change that improves performance',
},
{ value: 'test', name: 'test: Adding missing tests' },
{
value: 'test',
name: 'test: Adding missing tests',
},
{
value: 'chore',
name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation',
},
{ value: 'WIP', name: 'WIP: Work in progress' },
{
value: 'WIP',
name: 'WIP: Work in progress',
},
],
scopes: [
{
name: '*',
},
{
name: 'types',
},
{
name: 'local-signing-manager',
},
],
scopes: [{ name: 'types' }, { name: 'local-signing-manager' }, { name: '*' }],
allowTicketNumber: false,
isTicketNumberRequired: false,
ticketNumberPrefix: 'TICKET-',
ticketNumberRegExp: '\\d{1,5}',
// override the messages, defaults are as follows
messages: {
type: "Select the type of change that you're committing:",
scope:
'\nDenote the SCOPE of this change (affected package, choose "*" for changes that affect all packages):',
// used if allowCustomScopes is true
customScope: 'Denote the SCOPE of this change:',
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
Expand All @@ -41,12 +64,6 @@ module.exports = {
confirmCommit: 'Are you sure you want to proceed with the commit above?',
},
allowCustomScopes: false,
allowBreakingChanges: ['feat', 'fix'],
// skip any questions you want
skipQuestions: ['body'],
// limit subject length
allowBreakingChanges: ['feat', 'fix', 'chore'],
subjectLimit: 100,
// breaklineChar: '|', // It is supported for fields body and footer.
// footerPrefix : 'ISSUES CLOSED:'
// askForBreakingChangeFirst : true, // default is false
};
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
"editor.tabSize": 2,
"editor.formatOnSave": true,
"cSpell.words": [
"breakline",
"buildable",
"commitlint",
"hashicorp",
"nrwl",
"Polkadot",
"polymathnetwork",
"Polymesh",
"sonarcloud",
"tscpaths"
],
"cSpell.ignorePaths": [
Expand Down
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing

_DISCLAIMER: These guidelines (as well as all documentation) are in constant development. Any feedback is greatly appreciated. Just open a github issue and we will do our best to incorporate your suggestions within reason._

Thanks for your efforts in helping the Polymesh ecosystem grow!

We accept PRs with all kinds of contributions, including the creation of custom signing managers to support currently unsupported use cases.

## Custom Signing Managers

To create a new signing manager, run `yarn generate:signing-manager <name>`. This will create a `packages/<name>` directory with all the necessary configuration to build/test/release an npm package called `@polymathnetwork/<name>`. Unit tests must be written using the [jest](https://jestjs.io/) testing framework.

### Naming

The package should be called `<something>-signing-manager` (i.e. `hashicorp-vault-signing-manager`). Use existing packages as an example.

## Commits

This repo uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). For automated release versions to work properly, commits must have the affected package name as a scope. For example, if adding a new feature to the `local-signing-manager` package, the commit message should be `feat(local-signing-manager): sign raw messages`. Commits that affect more than one package can use `*` as a scope.

In order to ensure commits are properly formatted, we use husky to hijack the `git commit` command, so that it launches the commitizen CLI. Additionally, commit messages are validated with commitlint.

## PR Requirements

In order for a PR to be merged, it must:

- Produce no linting errors
- Have the proper type, scope and description in all commits
- Be reasonably type safe (avoid type assertions, non-null assertions and use of `any` and `unknown` within reason)
- Pass all unit tests
- Pass the sonarcloud quality gate (no code smells and 100% unit test coverage)
- Be properly documented with JSDoc comments
- Be added to the table in the project README
- Have an installation and usage example in its own README

On top of that, all PRs will be subject to review by the Polymesh association. The association reserves the right to reject submissions on any basis. That said, we certainly welcome and encourage external contributions.

As soon as your PR is merged, our CI pipeline will handle releasing new versions of all affected packages to npm.
97 changes: 11 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,19 @@


# SigningManagers

This project was generated using [Nx](https://nx.dev).

<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="450"></p>

🔎 **Smart, Fast and Extensible Build System**

## Adding capabilities to your workspace

Nx supports many plugins which add capabilities for developing different types of applications and different tools.

These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.

Below are our core plugins:

- [React](https://reactjs.org)
- `npm install --save-dev @nrwl/react`
- Web (no framework frontends)
- `npm install --save-dev @nrwl/web`
- [Angular](https://angular.io)
- `npm install --save-dev @nrwl/angular`
- [Nest](https://nestjs.com)
- `npm install --save-dev @nrwl/nest`
- [Express](https://expressjs.com)
- `npm install --save-dev @nrwl/express`
- [Node](https://nodejs.org)
- `npm install --save-dev @nrwl/node`

There are also many [community plugins](https://nx.dev/community) you could add.

## Generate an application

Run `nx g @nrwl/react:app my-app` to generate an application.

> You can use any of the plugins above to generate applications as well.
When using Nx, you can create multiple applications and libraries in the same workspace.

## Generate a library

Run `nx g @nrwl/react:lib my-lib` to generate a library.

> You can also use any of the plugins above to generate libraries as well.
Libraries are shareable across libraries and applications. They can be imported from `@signing-managers/mylib`.
Monorepo for Polymesh SDK compatible Signing Managers.

## Development server

Run `nx serve my-app` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `nx g @nrwl/react:component my-component --project=my-app` to generate a new component.

## Build

Run `nx build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.

## Running unit tests

Run `nx test my-app` to execute the unit tests via [Jest](https://jestjs.io).

Run `nx affected:test` to execute the unit tests affected by a change.

## Running end-to-end tests

Run `nx e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).

Run `nx affected:e2e` to execute the end-to-end tests affected by a change.

## Understand your workspace

Run `nx graph` to see a diagram of the dependencies of your projects.

## Further help

Visit the [Nx Documentation](https://nx.dev) to learn more.



## ☁ Nx Cloud
This project was generated using [Nx](https://nx.dev).

### Distributed Computation Caching & Distributed Task Execution
## Projects

<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-cloud-card.png"></p>
| Project | Package | Version | Links |
| ------------------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Local Signing Manager** | [`@polymathnetwork/local-signing-manager`](https://npmjs.com/package/@ng-easy/builders) | [![npm latest version](https://img.shields.io/npm/v/@polymathnetwork/local-signing-manager/latest.svg)](https://www.npmjs.com/package/@polymathnetwork/local-signing-manager) | [![README](https://img.shields.io/badge/README--green.svg)](/packages/local-signing-manager/README.md) [![CHANGELOG](https://img.shields.io/badge/CHANGELOG--orange.svg)](/packages/local-signing-manager/CHANGELOG.md) |

Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly.
## Scripts

Teams using Nx gain the advantage of building full-stack applications with their preferred framework alongside Nx’s advanced code generation and project dependency graph, plus a unified experience for both frontend and backend developers.
- Linting: `yarn lint <packageName>`
- Testing: `yarn test <packageName>`
- Building: `yarn build <packageName>`

Visit [Nx Cloud](https://nx.app/) to learn more.
You can also use nx commands directly with `yarn nx` (i.e. `yarn nx affected --targets=lint,test`)
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional', '@commitlint/config-nx-scopes'],
extends: ['@commitlint/config-conventional', 'cz'],
};
25 changes: 17 additions & 8 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,26 @@
"default": {
"runner": "@nrwl/workspace/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"lint",
"test",
"e2e"
]
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
},
"targetDependencies": {
"build": [{ "target": "build", "projects": "dependencies" }],
"release": [{ "target": "build", "projects": "self" }, { "target": "release", "projects": "dependencies" }]
"build": [
{
"target": "build",
"projects": "dependencies"
}
],
"release": [
{
"target": "build",
"projects": "self"
},
{
"target": "release",
"projects": "dependencies"
}
]
}
}
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"license": "MIT",
"scripts": {
"prepare": "is-ci || husky install",
"nx": "npx nx"
"nx": "npx nx",
"generate:signing-manager": "nx workspace-generator signing-manager",
"lint": "nx lint",
"test": "nx test",
"build": "nx build"
},
"private": true,
"dependencies": {
Expand All @@ -25,6 +29,7 @@
"@commitlint/config-nx-scopes": "^16.2.1",
"@ng-easy/builders": "^5.1.1",
"@nrwl/cli": "13.8.2",
"@nrwl/devkit": "13.8.2",
"@nrwl/eslint-plugin-nx": "13.8.2",
"@nrwl/jest": "13.8.2",
"@nrwl/js": "13.8.2",
Expand All @@ -34,9 +39,11 @@
"@nrwl/workspace": "13.8.2",
"@types/jest": "27.0.2",
"@types/node": "16.11.7",
"@types/require-from-string": "^1.2.1",
"@typescript-eslint/eslint-plugin": "~5.10.0",
"@typescript-eslint/parser": "~5.10.0",
"commitizen": "^4.2.4",
"commitlint-config-cz": "^0.13.3",
"cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^6.3.0",
"eslint": "~8.7.0",
Expand All @@ -46,16 +53,11 @@
"jest": "27.2.3",
"lint-staged": "^12.3.4",
"prettier": "^2.5.1",
"require-from-string": "^2.0.2",
"rxjs": "~6.6.7",
"ts-jest": "27.0.5",
"typescript": "~4.5.2"
},
"peerDependencies": {
"@polkadot/api": "5.1.1",
"@polkadot/util": "^7.0.2",
"@polkadot/util-crypto": "^7.0.2",
"@polymathnetwork/polymesh-sdk": ">=13.0.0"
},
"workspaces": [
"packages/**"
],
Expand Down
23 changes: 21 additions & 2 deletions packages/local-signing-manager/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# local-signing-manager

Polymesh SDK (v13+) compatible signing manager that stores private keys in memory.

This library was generated with [Nx](https://nx.dev).

## Running unit tests
## Usage

```typescript
import { LocalSigningManager } from '@polymathnetwork/local-signing-manager';
import { Polymesh } from '@polymathnetwork/polymesh-sdk';

// setup
const signingManager = await LocalSigningManager.create({
accounts: [
{
mnemonic: 'secret words will not be shared',
},
],
});

Run `nx test local-signing-manager` to execute the unit tests via [Jest](https://jestjs.io).
const sdk = await Polymesh.connect({
nodeUrl,
signingManager,
});
```
6 changes: 6 additions & 0 deletions packages/local-signing-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
},
"dependencies": {
"@polymathnetwork/signing-manager-types": "^1.0.1"
},
"peerDependencies": {
"@polkadot/api": "5.1.1",
"@polkadot/util": "^7.0.2",
"@polkadot/util-crypto": "^7.0.2",
"@polymathnetwork/polymesh-sdk": ">=13.0.0"
}
}
6 changes: 2 additions & 4 deletions packages/types/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# types

This library was generated with [Nx](https://nx.dev).

## Running unit tests
Base types for Signing Managers

Run `nx test types` to execute the unit tests via [Jest](https://jestjs.io).
This library was generated with [Nx](https://nx.dev).
Loading

0 comments on commit 439f602

Please sign in to comment.