Skip to content

Commit

Permalink
chore: introduce prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
thepiwo committed Mar 6, 2024
1 parent f50464e commit 388f867
Show file tree
Hide file tree
Showing 38 changed files with 702 additions and 1,827 deletions.
30 changes: 14 additions & 16 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
"extends": [
"airbnb-base",
"airbnb-typescript/base"
],
"env": {
"node": true,
"mocha": true
},
"rules": {
"@typescript-eslint/no-use-before-define": "off",
"no-use-before-define": "off"
},
"parserOptions": {
"project": "./tsconfig.json"
},
"ignorePatterns": ["tests/**"]
"extends": ["plugin:prettier/recommended"],
"env": {
"node": true,
"mocha": true,
"es2020": true
},
"rules": {
"@typescript-eslint/no-use-before-define": "off",
"no-use-before-define": "off"
},
"parserOptions": {
"project": "./tsconfig.json"
},
"ignorePatterns": ["tests/**"]
}
18 changes: 9 additions & 9 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
title: ""
labels: bug
assignees: ''

assignees: ""
---

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

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -25,11 +25,11 @@ If applicable, add screenshots to help explain your problem.

**Please tell us about your environment:**

- Node Version: v0.0.0
- Protocol Version: 1
- Compiler version: v0.0.0
- VM Version: fate | fate2
- SDK Version: v0.0.0
- Python version: v3.7.0
- Node Version: v0.0.0
- Protocol Version: 1
- Compiler version: v0.0.0
- VM Version: fate | fate2
- SDK Version: v0.0.0
- Python version: v3.7.0

**Other information** (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. forum, telegram, etc)
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
title: ""
labels: feature
assignees: ''

assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish main docs
on:
push:
branches: ['main']
branches: ["main"]

jobs:
main:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish release docs
on:
release:
types: [released]

jobs:
main:
runs-on: ubuntu-latest
Expand All @@ -21,4 +21,4 @@ jobs:
- run: git config --global user.email "github-action@users.noreply.github.com"
- run: git config --global user.name "GitHub Action"
- run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
- run: mike deploy --push --update-aliases $RELEASE_VERSION latest
- run: mike deploy --push --update-aliases $RELEASE_VERSION latest
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build-and-test:
strategy:
matrix:
node-version: [ 16, 18, 20, 21 ]
node-version: [16, 18, 20, 21]
node-tag: [latest]
compiler-tag: [v7.6.1] # latest is v8.0.0-rc1 which is not supported by the sdk currently

Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ npm install -g @aeternity/aeproject

## Documentation

* [Quick Start](docs/index.md)
* [Project Initialization](docs/cli/init.md)
* [Local Environment](docs/cli/env.md)
* [Unit Testing](docs/cli/test.md)
* [AEproject Library](docs/lib.md)
* [Migration from 3.x.x to 4.x.x](docs/migration-from-3.x.x-to-4.x.x.md)

- [Quick Start](docs/index.md)
- [Project Initialization](docs/cli/init.md)
- [Local Environment](docs/cli/env.md)
- [Unit Testing](docs/cli/test.md)
- [AEproject Library](docs/lib.md)
- [Migration from 3.x.x to 4.x.x](docs/migration-from-3.x.x-to-4.x.x.md)

## Release Process

1. merge the release please PR
- as `@aeternity/aeproject` has a dependency on itself as library, the CI run before publishing to npm after merging might fail
2. build locally and publish
- checkout latest `origin/main` including the merged release please PR, ensure no local changes
- publish to npm using `npm publish` (does automatically clean-build, may require login if not already)
- publish to npm using `npm publish` (does automatically clean-build, may require login if not already)
18 changes: 12 additions & 6 deletions docs/cli/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,42 @@ aeproject env

The command is responsible for setting up a healthy local environment. The `env` command helps developers run a local node and a local compiler in dev-mode using docker. To spawn a fully functional environment it can take a couple of minutes depending on your system.

*If using Windows, WSL 2 needs to be used* for AEproject to work normally, see https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers
_If using Windows, WSL 2 needs to be used_ for AEproject to work normally, see https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers

You can stop both the node and the compiler by running

```text
aeproject env --stop
```

There are optional parameters **\-\-nodeVersion** and **\-\-compilerVersion**. To specify a specific version of node or compiler, or both

```text
aeproject env --nodeVersion v6.12.0
# or
aeproject env --compilerVersion v7.6.1
# or
aeproject env --nodeVersion v6.12.0 --compilerVersion v7.6.1
```

This also applies to the commands `aeproject node` and `aeproject compiler`.

To see whether you have running instances of the nodes along with a compiler you could run the following command

```text
aeproject env --info
```

**Note**: By default AEproject uses the `latest-bundle` tag of the official [docker images](https://hub.docker.com/r/aeternity/aeternity/tags).

**Compatibility**:
- aeproject until `v4.8.3` is only compatible with node versions `NODE_TAG <= v6.11.0` due to some changes in the devmode plugin
- aeproject uses the `-bundle` node docker images including dev mode, which are only published from `NODE_TAG >= v6.3.0`
- the default `aeternity.yaml` config file that ships with aeproject supports `NODE_TAG >= v6.8.0`
- the latest `@aeternity/aepp-sdk@13` is only compatible using `NODE_TAG >= v6.0.0` and `COMPILER_TAG >= v7.5.0`
- ARM64/Apple Silicon is supported from images `NODE_TAG >= v6.8.1` and `COMPILER_TAG >= v7.3.0`

- aeproject until `v4.8.3` is only compatible with node versions `NODE_TAG <= v6.11.0` due to some changes in the devmode plugin
- aeproject uses the `-bundle` node docker images including dev mode, which are only published from `NODE_TAG >= v6.3.0`
- the default `aeternity.yaml` config file that ships with aeproject supports `NODE_TAG >= v6.8.0`
- the latest `@aeternity/aepp-sdk@13` is only compatible using `NODE_TAG >= v6.0.0` and `COMPILER_TAG >= v7.5.0`
- ARM64/Apple Silicon is supported from images `NODE_TAG >= v6.8.1` and `COMPILER_TAG >= v7.3.0`

## Disclaimer

- Firewalls and any other security feature can block your docker/docker-compose requests. Please check that docker/docker-compose is NOT in its blocked list or has permission to make requests.
1 change: 1 addition & 0 deletions docs/cli/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ _Optionally_ a `folder` can be specified for the project to be initialized in, o
Creates a new project structure with a few folders in which the developer can create **contracts** and **tests**, as well as installing needed dependencies.

## Update existing project

For upgrade from old AEproject versions check out [Migration from 3.x.x to 4.x.x](../migration-from-3.x.x-to-4.x.x.md).

```text
Expand Down
35 changes: 24 additions & 11 deletions docs/cli/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
aeproject test
```

The `test` command helps developers run their unit tests for æternity projects. The command executes the tests scripts that are located in the **test** folder of your æternity project.
The `test` command helps developers run their unit tests for æternity projects. The command executes the tests scripts that are located in the **test** folder of your æternity project.

## Implement unit tests

Expand All @@ -17,55 +17,63 @@ In the `test/exampleTest.js` file you can find an example for unit testing using
Javascript testing framework used with [mocha](https://mochajs.org/) for assertions, documented at https://www.chaijs.com/api/assert/

```js
const { assert } = require('chai');
const { assert } = require("chai");
```

Helper and utilities for AEproject use, e.g. prefunded wallets, network definition and utility functions for SDK initialization and snapshotting.

```js
const { networks, utils, wallets } = require('@aeternity/aeproject');
const { networks, utils, wallets } = require("@aeternity/aeproject");
```

Read [AEproject Library](../lib.md) for a more detailed explanation about the usage of these imports.

### 2. SDK and Snapshotting Setup

Provide your initializations in mocha which need to be done once before all tests:

```js
before(async () => ...)
```

Initialize the default SDK instance with provided utils:

```js
aeSdk = utils.getSdk();
```

Get the filesystem definition for (custom) `includes` of the given contract:

```js
const filesystem = utils.getFilesystem(EXAMPLE_CONTRACT_SOURCE);
```

Read the contract source from the filesystem:

```js
const sourceCode = utils.getContractContent(EXAMPLE_CONTRACT_SOURCE);
```

Initialize the contract instance:

```js
contract = await aeSdk.initializeContract({ sourceCode, filesystem });
```

Deploy the contract:

```js
await contract.init();
```

Create a snapshot of the chain state once before all tests. This allows you to rollback to a clean state after each test if needed:

```js
await utils.createSnapshot(aeSdk);
```

Rollback to the previously created snapshot after each test for a clean state in the following tests:

```js
afterEach(async () => {
await utils.rollbackSnapshot(aeSdk);
Expand All @@ -75,14 +83,19 @@ afterEach(async () => {
### 3. Example Test

```javascript
it('ExampleContract: set and get', async () => {
const set = await contract.set(42, {onAccount: utils.getDefaultAccounts()[1]});
assert.equal(set.decodedEvents[0].name, 'SetXEvent');
assert.equal(set.decodedEvents[0].args[0], utils.getDefaultAccounts()[1].address);
assert.equal(set.decodedEvents[0].args[1], 42);

const {decodedResult} = await contract.get();
assert.equal(decodedResult, 42);
it("ExampleContract: set and get", async () => {
const set = await contract.set(42, {
onAccount: utils.getDefaultAccounts()[1],
});
assert.equal(set.decodedEvents[0].name, "SetXEvent");
assert.equal(
set.decodedEvents[0].args[0],
utils.getDefaultAccounts()[1].address,
);
assert.equal(set.decodedEvents[0].args[1], 42);

const { decodedResult } = await contract.get();
assert.equal(decodedResult, 42);
});
```

Expand Down
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Quick Start

## Requirements

In order to have AEproject working you must have installed the following:

```
nodejs >= 16
docker
Expand All @@ -10,11 +12,13 @@ docker
**Note:** on windows WSL 2 must be used

## Install

```text
npm install -g @aeternity/aeproject
```

## Init a project

```text
aeproject init [folder]
```
Expand All @@ -24,6 +28,7 @@ This will create the project scaffold with an example contract including tests a
Further explained in [Initialization Documentation](cli/init.md).

## Running a local environment

```text
aeproject env
```
Expand Down
Loading

0 comments on commit 388f867

Please sign in to comment.