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

Refactoring + repo structure #66

Open
wants to merge 6 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
39 changes: 24 additions & 15 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Main"
name: 'Main'
on:
- push

Expand All @@ -10,27 +10,36 @@ jobs:
datetime: ${{ steps.get-datetime.outputs.datetime }}
steps:
- id: get-user
run: echo "::set-output name=uid_gid::$(id -u):$(id -g)"
run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT
- id: get-datetime
run: echo "::set-output name=datetime::$(date +'%Y%m%d%H%M%S')"
run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT

build:
needs: [configure]
runs-on: ubuntu-latest
container:
image: node:20-bookworm
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
HEAD_BRANCH_NAME: ${{ github.head_ref }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true

- name: Install node
uses: actions/setup-node@v2
- name: Install dependencies
run: yarn install
- name: Run linter
run: yarn lint
- name: Run formatter
run: yarn format
- name: Build
run: yarn build
- name: Unit tests
run: yarn test
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
scope: '@zondax'

- uses: oven-sh/setup-bun@v1

- run: bun install

- run: bun run format:check

- run: bun lint

- run: bun test
36 changes: 27 additions & 9 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,50 @@ jobs:
datetime: ${{ steps.get-datetime.outputs.datetime }}
steps:
- id: get-datetime
run: echo "::set-output name=datetime::$(date +'%Y%m%d%H%M%S')"
run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT

publish_npm_package:
runs-on: ubuntu-latest
runs-on: zondax-runners
container:
image: node:20-bookworm
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
HEAD_BRANCH_NAME: ${{ github.head_ref }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: true

- name: Install node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
scope: '@zondax'

- uses: oven-sh/setup-bun@v1

- run: bun install

- run: mv README-npm.md README.md
- name: Install yarn
run: npm install -g yarn
- run: yarn install
- run: yarn build
- run: bun run build

- name: Get latest release version number
id: get_version
uses: battila7/get-version-action@v2

- name: Show version
run: echo ${{ steps.get_version.outputs.version }}

- name: Update tag
run: |
echo Publishing as ${{ steps.get_version.outputs.version }}
npm --allow-same-version --no-git-tag-version version ${{ steps.get_version.outputs.version }}

- name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_AUTO }}
NODE_REPO_SERVER: 'https://registry.npmjs.org'
run: |
npm config set registry $NODE_REPO_SERVER
npm config set //registry.npmjs.org/:_authToken $NODE_AUTH_TOKEN
npm publish
78 changes: 4 additions & 74 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,79 +1,9 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

\.idea/

.vscode

TODO\.md

\dist
/certs/cert.pem
/certs/server.cert
/certs/server.key

/.idea
/node_modules/
/output/
/dist/

/yarn.lock
node_modules
.yarn/*
!.yarn/releases
!.yarn/plugins
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.yarn
node_modules
dist
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"singleQuote": true,
"arrowParens": "avoid",
"semi": false,
"useTabs": false,
"printWidth": 140,
"tabWidth": 2,
"importOrder": ["^@(.*)/(.*)$", "^[./]"],
"trailingComma": "es5",
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
}
4 changes: 0 additions & 4 deletions .prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2018 - 2023 Zondax AG
Copyright Zondax AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Empty file removed certs/.gitkeep
Empty file.
12 changes: 0 additions & 12 deletions certs/openssl.cnf

This file was deleted.

Binary file removed docs/example.png
Binary file not shown.
50 changes: 25 additions & 25 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
module.exports = {
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
window: "readonly",
document: "readonly",
process: "readonly",
require: "readonly",
window: 'readonly',
document: 'readonly',
process: 'readonly',
require: 'readonly',
},
parserOptions: {
project: "tsconfig.json",
project: 'tsconfig.json',
},
},
ignores: ["dist/*", "node_modules/*"],
ignores: ['dist/*', 'node_modules/*'],
plugins: {
"unused-imports": require("eslint-plugin-unused-imports"),
"@typescript-eslint": require("@typescript-eslint/eslint-plugin"),
"eslint-plugin-tsdoc": require("eslint-plugin-tsdoc"),
'unused-imports': require('eslint-plugin-unused-imports'),
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
'eslint-plugin-tsdoc': require('eslint-plugin-tsdoc'),
},
rules: {
curly: "warn",
"prefer-const": "warn",
"no-else-return": "warn",
complexity: ["warn", 1000],
"no-unneeded-ternary": "warn",
"no-alert": "warn",
"no-empty": "warn",
"no-useless-catch": "error",
"require-await": "warn",
"no-continue": "warn",
"no-console": "warn",
"unused-imports/no-unused-imports": "warn",
"no-magic-numbers": "off",
curly: 'warn',
'prefer-const': 'warn',
'no-else-return': 'warn',
complexity: ['warn', 1000],
'no-unneeded-ternary': 'warn',
'no-alert': 'warn',
'no-empty': 'warn',
'no-useless-catch': 'error',
'require-await': 'warn',
'no-continue': 'warn',
'no-console': 'warn',
'unused-imports/no-unused-imports': 'warn',
'no-magic-numbers': 'off',
},
};
}
9 changes: 6 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
preset: 'ts-jest',
testEnvironment: 'node',
transformIgnorePatterns: ['^.+\\.js$'],
modulePaths: ['<rootDir>/src', '<rootDir>/tests'],
runner: 'jest-serial-runner',
}
Loading