Skip to content

Commit

Permalink
Merge branch 'command-retry-loop' into 'master'
Browse files Browse the repository at this point in the history
Automatically retry CLI commands after session unlocking

See merge request MatrixAI/Engineering/Polykey/js-polykey!213
  • Loading branch information
CMCDragonkai committed Nov 24, 2021
2 parents 475266f + 063a366 commit 6ecb478
Show file tree
Hide file tree
Showing 323 changed files with 16,236 additions and 15,196 deletions.
61 changes: 56 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,36 @@
"prettier",
"prettier/@typescript-eslint"
],
"plugins": [
"import"
],
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module",
"ecmaVersion": 2020
},
"globals": {
"fail": "readonly"
},
"rules": {
"linebreak-style": ["error", "unix"],
"no-empty": 1,
"no-undef": 1,
"no-undef": 0,
"no-useless-catch": 1,
"no-prototype-builtins": 1,
"no-constant-condition": 0,
"no-useless-escape" : 0,
"no-console": "error",
"eqeqeq": ["error", "smart"],
"spaced-comment": [
"warn",
"always",
{
"line": {
"exceptions": ["-"]
},
"block": {
"exceptions": ["*"]
}
}
],
"capitalized-comments": [
"warn",
"always",
Expand All @@ -39,6 +52,34 @@
"ignoreConsecutiveComments": true
}
],
"import/order": [
"error",
{
"groups": [
"type",
"builtin",
"external",
"internal",
"index",
"sibling",
"parent",
"object"
],
"pathGroups": [
{
"pattern": "@",
"group": "internal"
},
{
"pattern": "@/**",
"group": "internal"
}
],
"pathGroupsExcludedImportTypes": [
"type"
]
}
],
"@typescript-eslint/no-namespace": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
Expand All @@ -56,6 +97,16 @@
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-empty-interface": 0,
"@typescript-eslint/consistent-type-imports": ["error"],
"no-throw-literal": "off",
"@typescript-eslint/no-throw-literal": ["error"],
"@typescript-eslint/no-floating-promises": ["error", {
"ignoreVoid": true,
"ignoreIIFE": true
}],
"@typescript-eslint/no-misused-promises": ["error", {
"checksVoidReturn": false
}],
"@typescript-eslint/naming-convention": [
"error",
{
Expand All @@ -66,7 +117,7 @@
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"format": ["camelCase", "UPPER_CASE", "PascalCase"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allowSingleOrDouble"
},
Expand Down
63 changes: 14 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
# js-polykey
# Polykey

[![pipeline status](https://gitlab.com/MatrixAI/open-source/js-polykey/badges/master/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/js-polykey/commits/master)

This is the core library for running PolyKey. It provides a CLI `polykey` or `pk` for interacting with the PolyKey system.

For reference and development guide, see the: [wiki](https://github.com/MatrixAI/js-polykey/wiki).

The master-project for Polykey is https://github.com/MatrixAI/Polykey.
For tutorials, how-to guides, reference and theory, see the [wiki](https://github.com/MatrixAI/Polykey/wiki).

## Installation

Building the package:
### NPM

```sh
nix-build -E '(import ./pkgs.nix).callPackage ./default.nix {}'
npm install --save polykey
```

### Nix/NixOS

Building the releases:

```sh
nix-build ./release.nix --attr application
nix-build ./release.nix --attr docker
nix-build ./release.nix --attr package.linux.x64.elf
nix-build ./release.nix --attr package.windows.x64.exe
nix-build ./release.nix --attr package.macos.x64.macho
```

Install into Nix user profile:
Expand All @@ -29,6 +32,8 @@ Install into Nix user profile:
nix-env -f ./release.nix --install --attr application
```

### Docker

Install into Docker:

```sh
Expand Down Expand Up @@ -62,63 +67,23 @@ Once you update the `src/proto/schemas` files, run this to update the `src/proto
npm run proto-generate
```

### Calling Executables
### Executing Commands

When calling executables in development, use this style:
When calling commands in development, use this style:

```sh
npm run polykey -- p1 p2 p3
```

The `--` is necessary to make `npm` understand that the parameters are for your own executable, and not parameters to `npm`.

### Path Aliases

Due to https://github.com/microsoft/TypeScript/issues/10866, you cannot use path aliases without a bundler like Webpack to further transform the generated JavaScript code in order to resolve the path aliases. Because this is a simple library demonstration, there's no need to use a bundler. In fact, for such libraries, it is far more efficient to not bundle the code.

However we have left the path alias configuration in `tsconfig.json`, `jest.config.js` and in the tests we are making use of the `@` alias.

### Using the REPL

```
$ npm run ts-node
> import fs from 'fs';
> fs
> import { Library } from '@';
> Library
> import Library as Library2 from './src/lib/Library';
```

You can also create test files in `./src`, and run them with `npm run ts-node ./src/test.ts`.

This allows you to test individual pieces of typescript code and it makes it easier when doing large scale rearchitecting of TypeScript code.

#### VSCode Path Aliases

VSCode cannot follow path aliases in our tests due to
https://github.com/microsoft/vscode/issues/94474.

To resolve this, add `./tests/**/*` into the `tsconfig` `include` section:

```json
"include": [
"./src/**/*",
"./tests/**/*'
]
```

This will however make `tsc` build the `tests` into the `dist` output.

**Therefore this fix should only be done in your own workspace, do not commit or push this change up.**


### Docs Generation

```sh
npm run docs
```

See the docs at: https://matrixai.github.io/TypeScript-Demo-Lib/
See the docs at: https://matrixai.github.io/Polykey/

### Publishing

Expand Down
Loading

0 comments on commit 6ecb478

Please sign in to comment.