Skip to content

Commit

Permalink
migrate to esm to support ts
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Apr 9, 2023
1 parent 58a4fb4 commit af6a1ec
Show file tree
Hide file tree
Showing 31 changed files with 17,807 additions and 13,224 deletions.
13 changes: 13 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "8"
},
"modules": false
}
]
]
}
96 changes: 62 additions & 34 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,69 @@
module.exports = {
'env': {
'node': true,
'mocha': true,
'es6': true
env: {
node: true,
mocha: true,
es6: true,
},
'extends': 'eslint:recommended',
'parserOptions': {
'sourceType': 'module',
"ecmaVersion": 8
ignorePatterns: ['src/test/*.*'],
overrides: [],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier', // This should be the last entry.
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'simple-import-sort'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 8,
},
'rules': {
'indent': [
rules: {
'no-console': ['error'],
// "no-var": ["error"],
'comma-dangle': 0,
'prefer-const': 0,
// "quotes": ["error", "double"],
'comma-spacing': 0, // ["error", { before: false, after: true }],
'semi-spacing': 0, // ["warn", { before: false, after: true }],
'space-before-blocks': 0, // ["warn", "always"],
'switch-colon-spacing': ['warn', { after: true, before: false }],
'keyword-spacing': 0, // ["warn", { before: true, after: true }],
'template-curly-spacing': 0, // ["error", "never"],
'rest-spread-spacing': 0, // ["error", "never"],
'no-multi-spaces': 0, // ["warn", { ignoreEOLComments: false }],

'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
indent: 'off',
'linebreak-style': ['error', 'unix'],
semi: ['error', 'never'],
'spaced-comment': [
'error',
2,
'always',
{
'FunctionDeclaration': { 'parameters': 'first' },
'FunctionExpression': { 'parameters': 'first' },
'CallExpression': { 'arguments': 'first' },
'ArrayExpression': 'first',
'ObjectExpression': 'first'
}
line: {
markers: ['/'],
exceptions: ['-', '+'],
},
block: {
markers: ['!'],
exceptions: ['*'],
balanced: true,
},
},
],
'linebreak-style': [
'error',
(process.platform === 'win32' ? 'windows' : 'unix') // all windows platforms are denoted by win32
],
'semi': ['error', 'never'],
'spaced-comment': ['error', 'always', {
'line': {
'markers': ['/'],
'exceptions': ['-', '+']
},
'block': {
'markers': ['!'],
'exceptions': ['*'],
'balanced': true
}
}]
}
'@typescript-eslint/no-explicit-any': ['warn'],

'@typescript-eslint/prefer-optional-chain': 0, // ["warn"],
'no-empty-function': 0,
'@typescript-eslint/no-empty-function': 0, // ["warn"],
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-this-alias': 0,
'@typescript-eslint/no-empty-interface': ['warn'],

'@typescript-eslint/no-array-constructor': ['off'],

'no-extra-parens': 0,
'@typescript-eslint/no-extra-parens': 0,
},
}
58 changes: 29 additions & 29 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ master, release ]
branches: [master, release]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master]
schedule:
- cron: '37 2 * * 4'

Expand All @@ -32,39 +32,39 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
3 changes: 1 addition & 2 deletions .github/workflows/nodejs-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
SERVER_ENDPOINT: localhost:9000
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
MINIO_KMS_SECRET_KEY: "my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
MINIO_KMS_SECRET_KEY: 'my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw='
ACCESS_KEY: minio
SECRET_KEY: minio123
ENABLE_HTTPS: 0
Expand All @@ -39,4 +39,3 @@ jobs:
npm run lint
npm run browserify
npm run test
52 changes: 40 additions & 12 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,73 @@
name: CI - Linux

on:
push:
pull_request:
branches:
- master
jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'

- run: npm ci

- run: npm run format-check
- run: npm run lint

build:
name: Build on node lts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'

- run: npm ci

- run: npm run build

- run: npm run browserify

test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
max-parallel: 3
matrix:
node_version: [12.x, 14.x, 16.x, 17.x, 18.x, 19.x]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 0
ref: ''
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
- name: Start Server -> Run Unit and Functional Tests ( install, lint, browserify, test)
cache: 'npm'

- run: npm i

- name: Start Server -> Run Unit and Functional Tests (test)
env:
CI: true
MINIO_CI_CD: true
MINT_MODE: full
SERVER_ENDPOINT: localhost:9000
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
MINIO_KMS_SECRET_KEY: "my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
MINIO_KMS_SECRET_KEY: 'my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw='
ACCESS_KEY: minio
SECRET_KEY: minio123
ENABLE_HTTPS: 0
run: |
wget --quiet -O /tmp/minio https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x /tmp/minio
/tmp/minio -C /tmp/minio-config server /tmp/data{1...4} &
npm install
npm run lint
npm run browserify
npm run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules

/dist/
yarn.lock
/.parcel-cache/
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint-staged
9 changes: 9 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
spec: 'src/test/**/*.mjs',
exit: true,
reporter: 'spec',
ui: 'bdd',
timeout: 5000,
require: ['dotenv/config'],
'node-option': ['experimental-specifier-resolution=node', 'loader=ts-node/esm'],
}
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist/
*.md
/examples/
Loading

0 comments on commit af6a1ec

Please sign in to comment.