Skip to content
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
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish snapshot package
on:
push:
branches: [ 'master' ]
release:
types: [ published ]

permissions:
contents: read
id-token: write
jobs:
publish-snapshots:
environment:
name: NPMJS
url: ${{ steps.publish.outputs.url }}
name: Publish snapshot packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
node-version: '>=24.7.0' # Trusted publishing requires npm CLI version 11.5.1 or later.
- run: npm i
- if: ${{ github.event_name == 'push' }}
run: |
PACKAGE_NAME=$(jq --raw-output .name package.json)
npm version prerelease --preid=snapshot --no-git-tag-version
PREFIX=$(jq --raw-output .version package.json | sed 's/\.[0-9]\+$//')
NEXT=$(npm view $PACKAGE_NAME versions --json \
| jq --raw-output --arg prefix $PREFIX '[.[] | select(startswith($prefix))|capture("snapshot\\.(?<n>[0-9]+)").n|tonumber]|max + 1 // 0')
npm version $PREFIX.$NEXT --no-git-tag-version
echo "TAG=snapshot" >> $GITHUB_ENV
- if: ${{ github.event_name == 'release' }}
run: |
npm version $(echo ${{ github.release.tag_name }} | sed 's/^v//') --no-git-tag-version
echo "TAG=latest" >> $GITHUB_ENV
- id: publish
run: |
npm run build
npm publish --provenance --access public --tag $TAG
echo "url=https://www.npmjs.com/package/@waves/ts-lib-crypto/v/$(jq --raw-output .version package.json)" >> "$GITHUB_OUTPUT"
8 changes: 5 additions & 3 deletions build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { mkdir, readdir, exists as ex, readFile, writeFile } from 'fs'
import { exec } from 'child_process'
import { resolve } from 'path'
const ncp = require('ncp').ncp
const rimraf = require('rimraf')
import { rimraf } from 'rimraf'

export const p = (...path: string[]) => resolve(__dirname, ...path)

export const remove = (path: string): Promise<void> =>
new Promise((resolve, reject) => rimraf(path, (err: any) => err ? reject(err) : resolve()))
rimraf(path, { glob: false }).then(() => {})

export const copy = (src: string, dst: string): Promise<void> =>
new Promise((resolve, reject) => ncp(src, dst, (err: any) => err ? reject(err) : resolve()))
new Promise((resolve, reject) => {
ncp(src, dst, (err: any) => err ? reject(err) : resolve())
})

export const exists = (path: string): Promise<boolean> =>
new Promise((resolve, _) => ex(path, (exists) => resolve(exists)))
Expand Down
167 changes: 167 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import importPlugin from 'eslint-plugin-import';
import prettierPlugin from 'eslint-plugin-prettier';
import prettierConfig from 'eslint-config-prettier';

export default [
{
ignores: [
'node_modules/**',
'dist/**',
'.github/**',
'docs/**',
'coverage/**',
'**/*.d.ts'
],
},
js.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: './tsconfig.json',
sourceType: 'module',
ecmaVersion: 2020,
},
globals: {
node: true,
es2020: true,
jest: true,
},
},
plugins: {
'@typescript-eslint': tsPlugin,
import: importPlugin,
prettier: prettierPlugin,
},
rules: {
'max-len': 'off',
'no-unused-vars': 'off',
'no-restricted-globals': ['error', 'Buffer'],
'array-callback-return': 'warn',
'default-case': ['warn', { commentPattern: '^no default$' }],
'dot-location': ['warn', 'property'],
'eqeqeq': ['warn', 'smart'],
'new-parens': 'warn',
'no-caller': 'warn',
'no-eval': 'error',
'no-extend-native': 'warn',
'no-extra-bind': 'warn',
'no-extra-label': 'warn',
'no-implied-eval': 'error',
'no-iterator': 'warn',
'no-label-var': 'warn',
'no-labels': ['warn', { allowLoop: true, allowSwitch: false }],
'no-lone-blocks': 'warn',
'no-loop-func': 'warn',
'no-multi-str': 'warn',
'no-new-func': 'error',
'no-new-object': 'warn',
'no-new-wrappers': 'warn',
'no-obj-calls': 'warn',
'no-octal-escape': 'warn',
'no-restricted-syntax': ['warn', 'WithStatement'],
'no-script-url': 'warn',
'no-self-assign': 'warn',
'no-self-compare': 'warn',
'no-sequences': 'warn',
'no-template-curly-in-string': 'warn',
'no-throw-literal': 'error',
'no-unused-expressions': ['warn', {
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
}],
'no-useless-computed-key': 'warn',
'no-useless-concat': 'warn',
'no-useless-escape': 'warn',
'no-useless-rename': ['warn', {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
}],
'no-with': 'warn',
'no-whitespace-before-property': 'warn',
'padding-line-between-statements': ['warn',
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] }
],
'radix': ['warn'],
'require-await': 'off',
'require-yield': 'warn',
'rest-spread-spacing': ['warn', 'never'],
'strict': ['warn', 'never'],
'unicode-bom': ['warn', 'never'],
'use-isnan': 'warn',
'valid-typeof': 'warn',
'import/first': 'warn',
'import/newline-after-import': 'warn',
'import/no-absolute-path': 'warn',
'import/no-amd': 'warn',
'import/no-default-export': 'warn',
'import/no-extraneous-dependencies': ['warn', {
devDependencies: [
'**/*.test.ts',
'**/*.spec.ts',
'test/**/*',
'scripts/**/*'
],
peerDependencies: true,
optionalDependencies: false,
}],
'import/no-mutable-exports': 'warn',
'import/no-named-default': 'warn',
'import/no-self-import': 'warn',
'import/order': ['warn', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always'
}],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
'@typescript-eslint/explicit-function-return-type': ['warn', {
allowExpressions: true,
allowTypedFunctionExpressions: true,
}],
'@typescript-eslint/member-ordering': 'warn',
'@typescript-eslint/no-array-constructor': 'warn',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-empty-interface': ['warn', { allowSingleExtends: true }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'warn',
'@typescript-eslint/no-misused-new': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}],
'@typescript-eslint/no-use-before-define': 'warn',
'@typescript-eslint/no-useless-constructor': 'warn',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-includes': 'warn',
'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/prefer-regexp-exec': 'warn',
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
'@typescript-eslint/promise-function-async': 'warn',
'@typescript-eslint/quotes': ['warn', 'single'],
'@typescript-eslint/require-array-sort-compare': 'warn',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/type-annotation-spacing': 'warn',
},
},
{
files: ['**/*.test.ts', '**/*.spec.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'import/no-extraneous-dependencies': 'off',
'@typescript-eslint/require-await': 'off',
},
},
prettierConfig,
];
7 changes: 1 addition & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ module.exports = {
],
testRegex: '(/__tests__/.*|(\\.|/)(test))\\.tsx?$',
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest"
'^.+\\.(ts|tsx)$': ['ts-jest', { diagnostics: false }],
},
collectCoverage: true,
coverageReporters: [
"json-summary",
"text",
"lcov"
],
globals: {
'ts-jest': {
diagnostics: false,
},
},
preset: 'ts-jest',
testMatch: null,
testEnvironment: 'node',
Expand Down
Loading