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

refactor: migrate helpers.js/s3-endpoints.js/signing.js to TypeScript #1137

Merged
merged 57 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
21e070a
migrate helpers.js to ts
trim21 May 5, 2023
37e6528
no need @internal on un-exported variable
trim21 May 5, 2023
af73d77
remove qs
trim21 May 5, 2023
367ae09
export all
trim21 May 5, 2023
1a23207
timeout
trim21 May 5, 2023
c9d7977
fix pipesetup
trim21 May 5, 2023
a7edf5e
dead code
trim21 May 5, 2023
be1c8de
use type narrow
trim21 May 5, 2023
e77d3e5
types
trim21 May 5, 2023
be6135d
remove type without actually value
trim21 May 5, 2023
4fc5d37
region
trim21 May 5, 2023
457594a
export type
trim21 May 5, 2023
13c4ccb
no need to split
trim21 May 5, 2023
411b222
Merge branch 'master' into ts/helpers
trim21 May 5, 2023
01e5281
type check
trim21 May 5, 2023
9959a78
use enum
trim21 May 5, 2023
ebb50aa
filename
trim21 May 5, 2023
a45f7e0
diff
trim21 May 5, 2023
ca38e38
deprecated type
trim21 May 5, 2023
deb282e
helper file
trim21 May 5, 2023
767303e
fix
trim21 May 5, 2023
f9fe211
Update src/helpers.ts
trim21 May 5, 2023
4f3629a
perfer const in typescript
trim21 May 5, 2023
2815daa
fix pipesetup type
trim21 May 5, 2023
3f4cdf7
type rename
trim21 May 6, 2023
53d161f
fix type
trim21 May 6, 2023
9fe8a3d
fix type
trim21 May 6, 2023
d6cb219
ci
trim21 May 6, 2023
7d0f34c
chore: upgrade deps
trim21 May 6, 2023
5aebc4d
upgrade old deps
trim21 May 6, 2023
d2052b5
ignore pnpm lock
trim21 May 6, 2023
8195e79
speedup build
trim21 May 6, 2023
1712bd5
bucket and object js required
trim21 May 6, 2023
aafe0fa
fix request header
trim21 May 6, 2023
401aded
fix enc headers
trim21 May 6, 2023
826eda1
fix enc type
trim21 May 6, 2023
4ec735a
import first
trim21 May 6, 2023
e98ed16
import as es
trim21 May 6, 2023
d3cd80d
move to internal
trim21 May 6, 2023
eb0e33a
rename type
trim21 May 6, 2023
37a84c3
signing.js
trim21 May 6, 2023
91c1a13
merge imports
trim21 May 6, 2023
851212f
sha256 type safe
trim21 May 6, 2023
ac5eee3
fix test
trim21 May 7, 2023
63022da
join string
trim21 May 7, 2023
13c91d0
unknown
trim21 May 7, 2023
b798fef
add more type
trim21 May 7, 2023
ac44cc5
extra type
trim21 May 9, 2023
37fa819
support node20
trim21 May 9, 2023
5488f6b
lock file
trim21 May 9, 2023
470d76f
support tested version
trim21 May 9, 2023
b677778
set engines.node
trim21 May 9, 2023
dddc770
drop old nodejs
trim21 May 9, 2023
6302038
build to node14
trim21 May 9, 2023
b6f924f
upgrade mocha
trim21 May 9, 2023
da76935
add node12 back to ci
trim21 May 10, 2023
d7b0c8f
code review
trim21 May 10, 2023
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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ module.exports = {
'import/no-commonjs': 'error',
},
},
{
files: ['./src/**/*.ts'],
rules: {
'prefer-const': 'error',
},
},
{
files: ['./tests/**/*'],
rules: {
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/nodejs-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
max-parallel: 2
matrix:
node_version: [12.x, 14.x, 16.x, 17.x, 18.x, 20.x]
node_version: [12.x, 14.x, 16.x, 18.x, 20.x]
os: [windows-latest]
steps:
- uses: actions/checkout@v3
Expand All @@ -28,6 +28,7 @@ jobs:
- run: npm i

- name: Start MinIO Server -> Run Unit and Functional Tests
timeout-minutes: 10
env:
CI: true
MINIO_CI_CD: true
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
max-parallel: 2
matrix:
node_version: [12.x, 14.x, 16.x, 17.x, 18.x, 20.x]
node_version: [12.x, 14.x, 16.x, 18.x, 20.x]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
Expand All @@ -28,6 +28,7 @@ jobs:
- run: npm i

- name: Start Server -> Run Unit and Functional Tests
timeout-minutes: 10
env:
CI: true
MINIO_CI_CD: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ node_modules
yarn.lock
.yarn/
.yarnrc.yml
pnpm-lock.yaml
39 changes: 17 additions & 22 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable no-console */
import { execSync } from 'node:child_process'
import { exec } from 'node:child_process'
import * as fs from 'node:fs'
import * as fsp from 'node:fs/promises'
import * as path from 'node:path'
import { promisify } from 'node:util'

import * as babel from '@babel/core'
import * as fsWalk from '@nodelib/fs.walk'
Expand Down Expand Up @@ -48,40 +49,40 @@ function options(module) {
constantReexports: true,
},
plugins: module === 'esm' ? plugins.splice(1) : plugins,
presets: [['@babel/env', { targets: { node: '8' }, modules: false }], ['@babel/preset-typescript']],
presets: [['@babel/env', { targets: { node: '14' }, modules: false }], ['@babel/preset-typescript']],
}
}

const extMap = { cjs: '.js', esm: '.mjs' }

async function buildFiles({ files, module, outDir }) {
console.log(`building for ${module}`)
execSync(`npx tsc --outDir ${outDir}`, { stdio: 'inherit' })
await promisify(exec)(`npx tsc --outDir ${outDir}`, { stdio: 'inherit' })

const opt = options(module)
for (const file of files) {
if (!file.dirent.isFile()) {
continue
}

if (file.path.endsWith('.d.ts')) {
continue
}

const outFilePath = path.join(outDir, path.relative('src/', file.path))
const outDirPath = path.dirname(outFilePath)

await fsp.mkdir(outDirPath, { recursive: true })
const distCodePath = outFilePath.replace(/\.[tj]s$/g, extMap[module])

if (file.path.endsWith('.d.ts')) {
await fsp.copyFile(file.path, outFilePath)
continue
}

try {
const result = await babel.transformAsync(fs.readFileSync(file.path).toString(), {
const result = await babel.transformAsync(await fsp.readFile(file.path, 'utf-8'), {
filename: file.path,
...opt,
})

const distCodePath = outFilePath.replace(/\.[tj]s$/g, extMap[module])

fs.writeFileSync(distCodePath, result.code)
await fsp.writeFile(distCodePath, result.code)
} catch (e) {
console.error(`failed to transpile ${file.path}`)
throw e
Expand All @@ -93,17 +94,11 @@ async function main() {
await fsp.rm('dist', { recursive: true, force: true })

const entries = fsWalk.walkSync('src/')
await buildFiles({
files: entries,
module: 'cjs',
outDir: './dist/main/',
})

await buildFiles({
files: entries,
module: 'esm',
outDir: './dist/esm/',
})

await Promise.all([
buildFiles({ files: entries, module: 'cjs', outDir: './dist/main/' }),
buildFiles({ files: entries, module: 'esm', outDir: './dist/esm/' }),
])

for (const file of fsWalk.walkSync('dist/esm/')) {
if (file.dirent.isDirectory()) {
Expand Down
Loading