Skip to content

Commit 26c0fd8

Browse files
authored
Merge branch 'main' into fix-publish
2 parents b22d307 + aa9d3b0 commit 26c0fd8

19 files changed

+702
-281
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ jobs:
3131
- name: Run formatter
3232
run: yarn format
3333
- name: Build
34-
run: yarn build
34+
run: yarn build
35+
- name: Run tests
36+
run: yarn test

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
env:
4343
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_AUTO }}
4444
run: |
45-
npm publish
45+
npm publish

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ TODO\.md
7272
/certs/cert.pem
7373
/certs/server.cert
7474
/certs/server.key
75+
/esm

eslint.config.cjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
languageOptions: {
3+
ecmaVersion: "latest",
4+
sourceType: "module",
5+
globals: {
6+
window: "readonly",
7+
document: "readonly",
8+
process: "readonly",
9+
require: "readonly",
10+
},
11+
parserOptions: {
12+
project: "tsconfig.json",
13+
},
14+
},
15+
ignores: ["dist/*", "node_modules/*"],
16+
plugins: {
17+
"unused-imports": require("eslint-plugin-unused-imports"),
18+
"@typescript-eslint": require("@typescript-eslint/eslint-plugin"),
19+
"eslint-plugin-tsdoc": require("eslint-plugin-tsdoc"),
20+
},
21+
rules: {
22+
curly: "warn",
23+
"prefer-const": "warn",
24+
"no-else-return": "warn",
25+
complexity: ["warn", 1000],
26+
"no-unneeded-ternary": "warn",
27+
"no-alert": "warn",
28+
"no-empty": "warn",
29+
"no-useless-catch": "error",
30+
"require-await": "warn",
31+
"no-continue": "warn",
32+
"no-console": "warn",
33+
"unused-imports/no-unused-imports": "warn",
34+
"no-magic-numbers": "off",
35+
},
36+
};

eslint.config.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

jest.config.cjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/tests/integration/**/*.test.ts"],
5+
moduleFileExtensions: ["ts", "js"],
6+
transform: {
7+
"^.+\\.ts$": [
8+
"ts-jest",
9+
{
10+
tsconfig: "tsconfig.json",
11+
useESM: true,
12+
},
13+
],
14+
},
15+
extensionsToTreatAsEsm: [".ts"],
16+
moduleNameMapper: {
17+
"^(\\.{1,2}/.*)\\.js$": "$1",
18+
},
19+
transformIgnorePatterns: [
20+
"node_modules/(?!(jest-)?@?react-native|@react-native-community|@react-navigation)",
21+
],
22+
projects: [
23+
{
24+
displayName: "Node",
25+
testEnvironment: "node",
26+
testMatch: ["**/tests/integration/node/**/*.test.ts"],
27+
transform: {
28+
"^.+\\.ts$": [
29+
"ts-jest",
30+
{
31+
tsconfig: "tsconfig.json",
32+
useESM: true,
33+
},
34+
],
35+
},
36+
},
37+
{
38+
displayName: "Extension",
39+
testEnvironment: "./tests/integration/extension/environment.ts",
40+
testMatch: ["**/tests/integration/extension/**/*.test.ts"],
41+
transform: {
42+
"^.+\\.ts$": [
43+
"ts-jest",
44+
{
45+
tsconfig: "tsconfig.json",
46+
useESM: false,
47+
},
48+
],
49+
},
50+
},
51+
],
52+
};

jest.config.extension.cjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "./tests/integration/extension/environment.ts",
4+
testMatch: ["**/tests/integration/extension/**/*.test.ts"],
5+
moduleFileExtensions: ["ts", "js"],
6+
transform: {
7+
"^.+\\.ts$": [
8+
"ts-jest",
9+
{
10+
tsconfig: "tsconfig.json",
11+
},
12+
],
13+
},
14+
};

jest.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"name": "@zondax/ledger-mina-js",
3-
"author": "Zondax AG",
4-
"license": "Apache-2.0",
53
"version": "0.0.1",
64
"description": "Node API for the Mina App (Ledger Nano S, S+, X, Stax and Flex)",
75
"keywords": [
@@ -19,41 +17,61 @@
1917
"type": "git",
2018
"url": "git+https://github.com/zondax/ledger-mina-js.git"
2119
},
20+
"license": "Apache-2.0",
21+
"author": "Zondax AG",
22+
"type": "module",
2223
"main": "./dist/index.js",
24+
"module": "./dist/index.mjs",
25+
"browser": "./dist/index.browser.js",
2326
"types": "./dist/index.d.ts",
2427
"typings": "./dist/index.d.ts",
2528
"files": [
2629
"dist/**",
2730
"README.md"
2831
],
2932
"scripts": {
30-
"build": "tsc",
33+
"build": "rollup -c --bundleConfigAsCjs && tsc --emitDeclarationOnly",
34+
"build:js": "rollup -c --bundleConfigAsCjs",
35+
"build:types": "tsc --emitDeclarationOnly",
3136
"format": "FORCE_COLOR=1 prettier --write . && sort-package-json",
3237
"format:check": "FORCE_COLOR=1 prettier --check .",
3338
"lint": "eslint .",
3439
"lint:fix": "eslint --fix .",
35-
"test": "yarn build && jest",
40+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.cjs",
41+
"test:extension": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.cjs tests/integration/extension",
42+
"test:node": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.cjs tests/integration/node",
43+
"test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.cjs --watch",
3644
"upgrade": "bunx npm-check-updates -i"
3745
},
3846
"dependencies": {
3947
"@zondax/ledger-js": "^1.0.1"
4048
},
4149
"devDependencies": {
4250
"@ledgerhq/hw-transport-mocker": "^6.29.3",
43-
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
44-
"@types/jest": "29.5.13",
45-
"@types/node": "^22.6.1",
46-
"@typescript-eslint/eslint-plugin": "^8.7.0",
47-
"@typescript-eslint/parser": "^8.7.0",
48-
"eslint": "^9.11.1",
49-
"eslint-config-prettier": "^9.1.0",
51+
"@ledgerhq/hw-transport-node-hid": "^6.29.3",
52+
"@ledgerhq/hw-transport-webusb": "^6.29.3",
53+
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
54+
"@types/jest": "^29.5.14",
55+
"@types/node": "^22.15.3",
56+
"@typescript-eslint/eslint-plugin": "^8.31.0",
57+
"@typescript-eslint/parser": "^8.31.0",
58+
"cross-env": "^7.0.3",
59+
"esbuild": "^0.25.3",
60+
"eslint": "^9.25.1",
61+
"eslint-config-prettier": "^10.1.2",
5062
"eslint-plugin-import": "^2.30.0",
51-
"eslint-plugin-tsdoc": "^0.3.0",
63+
"eslint-plugin-tsdoc": "^0.4.0",
5264
"eslint-plugin-unused-imports": "^4.1.4",
65+
"jest": "^29.7.0",
66+
"jest-environment-jsdom": "^29.7.0",
5367
"prettier": "^3.3.3",
54-
"sort-package-json": "^2.10.1",
55-
"ts-jest": "^29.2.5",
56-
"typescript": "^5.6.2"
68+
"rollup": "^4.18.0",
69+
"rollup-plugin-dts": "^6.2.1",
70+
"rollup-plugin-esbuild": "^6.2.1",
71+
"rollup-plugin-typescript2": "^0.35.0",
72+
"sort-package-json": "^3.0.0",
73+
"ts-jest": "^29.3.2",
74+
"typescript": "^5.8.3"
5775
},
5876
"publishConfig": {
5977
"access": "public"

rollup.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const { default: esbuild } = require("rollup-plugin-esbuild");
2+
3+
const config = [
4+
// Node.js build (CommonJS)
5+
{
6+
input: `src/index.ts`,
7+
plugins: [esbuild()],
8+
output: [
9+
{
10+
file: "dist/index.js",
11+
format: "cjs",
12+
sourcemap: true,
13+
},
14+
],
15+
},
16+
// Web build (ESM)
17+
{
18+
input: `src/index.ts`,
19+
plugins: [esbuild()],
20+
output: [
21+
{
22+
file: "dist/index.mjs",
23+
format: "esm",
24+
sourcemap: true,
25+
},
26+
],
27+
},
28+
// Browser build (UMD)
29+
{
30+
input: `src/index.ts`,
31+
plugins: [esbuild()],
32+
output: [
33+
{
34+
file: "dist/index.browser.js",
35+
format: "umd",
36+
name: "MinaLedger",
37+
sourcemap: true,
38+
globals: {
39+
"@zondax/ledger-js": "LedgerJS",
40+
},
41+
},
42+
],
43+
},
44+
];
45+
46+
module.exports = config;

0 commit comments

Comments
 (0)