Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: prettier #14

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ jobs:
id: cache-node-modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
key:
${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-${{
hashFiles('**/package.json') }}

- uses: actions/cache@v2
name: Cache Jest cache
Expand All @@ -49,18 +51,18 @@ jobs:

- run: yarn install
id: install

- run: yarn run build
id: turbo

- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}

- uses: ArtiomTr/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
package-manager: yarn
github-token: ${{ secrets.GITHUB_TOKEN }}
package-manager: yarn

- name: Tests
run: yarn run test:ci
14 changes: 7 additions & 7 deletions .github/workflows/pipeline-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: pipeline-release
on:
pull_request:
branches:
- "release-*"
- "master"
- 'release-*'
- 'master'
tags-ignore:
- "*"
- '*'

concurrency:
group: ci-tests-${{ github.ref }}-1
Expand Down Expand Up @@ -51,12 +51,12 @@ jobs:

- run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

- uses: "marvinpinto/action-automatic-releases@latest"
- uses: 'marvinpinto/action-automatic-releases@latest'
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
repo_token: '${{ secrets.GITHUB_TOKEN }}'
automatic_release_tag: 'latest'
prerelease: true
files: |
LICENSE.md
packages/**/*.tgz
id: "automatic_releases"
id: 'automatic_releases'
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.yarn/*
.cache
public/
build/
Expand All @@ -15,4 +16,3 @@ dist/
*.uml
*.json
*.js
*.d.ts
7 changes: 3 additions & 4 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* @file Prettier configuration for Conformance
* @version 1.0.6
* @version 1.0.8
* @summary base config adapted from AirBNB to maximize performance
* @schema http://json.schemastore.org/prettierrc
*/

'use strict';

module.exports = {
arrowParens: 'always',
bracketSpacing: true,
cursorOffset: 1,
endOfLine: 'lf',
jsxBracketSameLine: false,
jsxSingleQuote: false,
Expand All @@ -21,6 +21,5 @@ module.exports = {
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
embeddedLanguageFormatting: "auto"

embeddedLanguageFormatting: 'auto'
};
74 changes: 74 additions & 0 deletions gen-readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

const fs = require("fs");
const path = require("path");

const src = __dirname + "/../src";

const exclude = [
".DS_Store",
"util.ts",
"index.tsx",
"index.ts",
"iconIndex.tsx",
];

const include = [".tsx", ".ts"];

const excludeExt = [".json", ".md"];

const basicDocjs = (name) => `<${name}> </${name}>`;
const basicReadme = (name) => `
# ${name}
## Abstract

## Usage

## Development

### Related

| Library | Description | NPM |
| ------------ | ----------------------------------------- | ------------------------------------------------ |
| @disco3/types | types | https://www.npmjs.com/package/@disco3/types |

### License
See [LICENSE](LICENSE.md)
`;

const sourceFiles = fs
.readdirSync(src)
.map((sourcePath) => path.parse(sourcePath))
// .filter((parsedPath) => include.includes(parsedPath.ext))
.filter((parsedPath) => !exclude.includes(parsedPath.base))
.filter((parsedPath) => !excludeExt.includes(parsedPath.ext));

// sourceFiles.map((parsedPath) => fs.mkdirSync(src + "/" + parsedPath.name));

console.log(sourceFiles);

sourceFiles.map((parsedPath) => {
// const oldPath = src + "/" + parsedPath.base;
// const newPath = src + "/" + parsedPath.name + "/" + parsedPath.base;
// console.log(oldPath, newPath);
// fs.renameSync(oldPath, newPath, function (err) {
// if (err) throw err;
// // console.log('Successfully renamed - AKA moved!')
// });
// const readmePath = src + "/" + parsedPath.name + "/" + "README.md";
const docsJsonPath = src + "/" + parsedPath.name + "/" + "docs.json";

const docsJsPath = src + "/" + parsedPath.name + "/" + "docs.js";

if (fs.existsSync(docsJsonPath)) {
fs.unlinkSync(docsJsonPath);
}
// fs.writeFileSync(readmePath, basicReadme(parsedPath.name), "utf8");

if (fs.existsSync(docsJsPath)) {
// do something
} else {
fs.writeFileSync(docsJsPath, basicDocjs(parsedPath.name), "utf8");
}
});

// console.log(sourceFiles)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@disco3/monorepo",
"version": "0.0.1",
"version": "0.0.2",
"private": true,
"workspaces": [
"packages/*"
Expand Down
70 changes: 69 additions & 1 deletion packages/core/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Web3ReactHooks, initializeConnector } from '.';
import { act, renderHook } from '@testing-library/react-hooks';

import type { Actions } from '@disco3/types';
import { Connector } from '@disco3/types';

import type { Web3ReactHooks, Web3ReactPriorityHooks } from '.';
import { getPriorityConnector, initializeConnector } from '.';

class MockConnector extends Connector {
constructor(actions: Actions) {
super(actions);
Expand All @@ -19,6 +21,8 @@ class MockConnector extends Connector {
}
}

class MockConnector2 extends MockConnector {}

describe('#initializeConnector', () => {
let connector: MockConnector;
let hooks: Web3ReactHooks;
Expand Down Expand Up @@ -123,3 +127,67 @@ describe('#initializeConnector', () => {
expect(error).toBeInstanceOf(Error);
});
});

describe('#useHighestPriorityConnector', () => {
let connector: MockConnector;
let hooks: Web3ReactHooks;
let store: Web3ReactStore;

let connector2: MockConnector;
let hooks2: Web3ReactHooks;
let store2: Web3ReactStore;

let priorityConnectorHooks: Web3ReactPriorityHooks;

beforeEach(() => {
[connector, hooks, store] = initializeConnector(
(actions) => new MockConnector(actions),
);
[connector2, hooks2, store2] = initializeConnector(
(actions) => new MockConnector2(actions),
);

priorityConnectorHooks = getPriorityConnector(
[connector, hooks],
[connector2, hooks2],
);
});

test('returns first connector if both are uninitialized', () => {
const {
result: { current: priorityConnector },
} = renderHook(() => priorityConnectorHooks.usePriorityConnector());

expect(priorityConnector).toBeInstanceOf(MockConnector);
expect(priorityConnector).not.toBeInstanceOf(MockConnector2);
});

test('returns first connector if it is initialized', () => {
act(() => connector.update({ chainId: 1, accounts: [] }));
const {
result: { current: priorityConnector },
} = renderHook(() => priorityConnectorHooks.usePriorityConnector());

const {
result: { current: isActive },
} = renderHook(() => priorityConnectorHooks.usePriorityIsActive());
expect(isActive).toBe(true);

expect(priorityConnector).toBeInstanceOf(MockConnector);
expect(priorityConnector).not.toBeInstanceOf(MockConnector2);
});

test('returns second connector if it is initialized', () => {
act(() => connector2.update({ chainId: 1, accounts: [] }));
const {
result: { current: priorityConnector },
} = renderHook(() => priorityConnectorHooks.usePriorityConnector());

const {
result: { current: isActive },
} = renderHook(() => priorityConnectorHooks.usePriorityIsActive());
expect(isActive).toBe(true);

expect(priorityConnector).toBeInstanceOf(MockConnector2);
});
});
Loading