Skip to content

Commit

Permalink
fix: update types and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
d0whc3r committed Jul 6, 2020
1 parent 6215b2d commit 7f7a292
Show file tree
Hide file tree
Showing 7 changed files with 4,128 additions and 1,707 deletions.
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ stages:
- install
- test
- analysis
- release
- update

before_script:
Expand Down Expand Up @@ -64,6 +65,13 @@ sonarqube-reports-branch:
script:
- yarn sonar-scanner -Dsonar.login=${SONAR_TOKEN} -Dsonar.branch.name=${CI_BUILD_REF_NAME} -Dsonar.branch.target=master -Duser.home=./

semantic-release:
stage: release
only:
- master
script:
- yarn semantic-release

update-patch:
stage: update
when: manual
Expand Down
91 changes: 53 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"name": "d0whc3r",
"url": "https://github.com/d0whc3r"
},
"repository": "https://github.com/d0whc3r/node-s3.git",
"repository": {
"type": "git",
"url": "https://github.com/d0whc3r/node-s3.git"
},
"bin": {
"node-s3": "./bin/cli.js"
},
Expand Down Expand Up @@ -36,95 +39,100 @@
"cli": "node -r ts-node/register -r tsconfig-paths/register cli/cli.ts",
"build:clean": "rimraf dist bin",
"build:dist": "rollup -c",
"build:dts": "dts-bundle-generator -o dist/index.d.ts src/index.ts --umd-module-name=s3",
"build:pkg": "pkg -t node12-linux-x64 -o node-s3 bin/cli.js",
"build:pkg:windows": "pkg -t node12-win-x64 -o node-s3.exe bin/cli.js",
"build:pkg:macos": "pkg -t node12-macos-x64 -o node-s3 bin/cli.js",
"build:base": "yarn build:clean && yarn build:dist && yarn build:dts",
"build:dts": "dts-bundle-generator -o dist/index.d.ts src/index.ts",
"build:pkg": "pkg -t node14-linux-x64 -o node-s3 bin/cli.js",
"build:pkg:windows": "pkg -t node14-win-x64 -o node-s3.exe bin/cli.js",
"build:pkg:macos": "pkg -t node14-macos-x64 -o node-s3 bin/cli.js",
"build:base": "yarn build:clean && run-p build:dist build:dts",
"build": "yarn build:base && yarn build:pkg",
"build:windows": "yarn build:base && yarn build:pkg:windows",
"build:macos": "yarn build:base && yarn build:pkg:macos",
"build:windows": "run-s build:base build:pkg:windows",
"build:macos": "run-s build:base build:pkg:macos",
"test": "jest -i --colors",
"test:fakeci": "dotenv -e test.env -- yarn test",
"test:coverage": "yarn test --coverage",
"test:send-coverages": "yarn coverage:codecovs && yarn coverage:coveralls && yarn coverage:codacy",
"coverage:codecovs": "curl -s https://codecov.io/bash | bash",
"coverage:coveralls": "cat ./coverage/lcov.info | coveralls",
"coverage:codacy": "wget -q https://coverage.codacy.com/get.sh && bash get.sh report -l typescript -r coverage/lcov.info",
"postversion": "git push --follow-tags",
"eslint": "eslint -c .eslintrc.js --ext .ts --ext .js src cli",
"eslint:fix": "yarn eslint --fix",
"format": "pretty-quick \"{src,cli}/**/*.ts\" --write --staged"
"format": "pretty-quick \"{src,cli}/**/*.ts\" --write --staged",
"commit": "git-cz",
"semantic-release": "semantic-release",
"postversion": "git commit -am 'chore(bump): bump version [skip-ci]' && git push --follow-tags"
},
"dependencies": {
"archiver": "4.0.1",
"aws-sdk": "2.700.0",
"aws-sdk": "2.709.0",
"colors": "1.4.0",
"command-line-args": "5.1.1",
"command-line-usage": "6.1.0",
"dayjs": "1.8.28",
"dayjs": "1.8.29",
"glob": "7.1.6",
"mime-types": "2.1.27",
"mkdirp": "1.0.4",
"mysqldump": "3.2.0"
},
"devDependencies": {
"@babel/core": "7.10.2",
"@babel/plugin-syntax-import-meta": "7.10.1",
"@babel/plugin-transform-regenerator": "7.10.1",
"@babel/preset-env": "7.10.2",
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"@rollup/plugin-commonjs": "13.0.0",
"@babel/core": "7.10.4",
"@babel/plugin-syntax-import-meta": "7.10.4",
"@babel/plugin-transform-regenerator": "7.10.4",
"@babel/preset-env": "7.10.4",
"@commitlint/cli": "9.0.1",
"@commitlint/config-conventional": "9.0.1",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "8.0.1",
"@rollup/plugin-node-resolve": "8.1.0",
"@semantic-release/changelog": "5.0.1",
"@semantic-release/commit-analyzer": "8.0.1",
"@semantic-release/github": "7.0.7",
"@semantic-release/npm": "7.0.5",
"@semantic-release/release-notes-generator": "9.0.1",
"@types/archiver": "3.1.0",
"@types/command-line-args": "5.0.0",
"@types/command-line-usage": "5.0.1",
"@types/jest": "26.0.0",
"@types/jest": "26.0.3",
"@types/mime-types": "2.1.0",
"@types/mkdirp": "1.0.1",
"@types/node": "14.0.13",
"@types/node": "14.0.14",
"@types/rollup-plugin-node-builtins": "2.1.1",
"@types/rollup-plugin-node-globals": "1.4.0",
"@typescript-eslint/eslint-plugin": "3.3.0",
"@typescript-eslint/parser": "3.3.0",
"@typescript-eslint/eslint-plugin": "3.5.0",
"@typescript-eslint/parser": "3.5.0",
"builtin-modules": "3.1.0",
"core-js": "3.6.5",
"coveralls": "3.1.0",
"dotenv": "8.2.0",
"dotenv-cli": "3.1.0",
"dts-bundle-generator": "4.3.0",
"eslint": "7.2.0",
"dotenv-cli": "3.2.0",
"dts-bundle-generator": "5.0.0",
"esbuild": "0.5.21",
"eslint": "7.4.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-sonarjs": "0.5.0",
"find-node-modules": "2.0.0",
"husky": "4.2.5",
"jest": "26.0.1",
"jest": "26.1.0",
"jest-chain": "1.1.5",
"jest-extended": "0.11.5",
"jest-junit": "10.0.0",
"jest-junit": "11.0.1",
"jest-sonar-reporter": "2.0.0",
"lint-staged": "10.2.11",
"npm-run-all": "4.1.5",
"pkg": "4.4.8",
"pkg": "4.4.9",
"prettier": "2.0.5",
"pretty-quick": "2.0.1",
"regenerator-runtime": "0.13.5",
"rimraf": "3.0.2",
"rollup": "2.17.1",
"rollup-plugin-babel": "4.4.0",
"rollup": "2.19.0",
"rollup-plugin-auto-external": "2.0.0",
"rollup-plugin-esbuild": "2.1.0",
"rollup-plugin-node-builtins": "2.1.2",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-node-polyfills": "0.2.1",
"rollup-plugin-terser": "6.1.0",
"rollup-plugin-typescript2": "0.27.1",
"semantic-release": "17.1.1",
"sonar-scanner": "3.1.0",
"ts-jest": "26.1.0",
"ts-jest": "26.1.1",
"ts-node": "8.10.2",
"tsconfig-paths": "3.9.0",
"typescript": "3.9.5"
"typescript": "3.9.6"
},
"jestSonar": {
"reportPath": "coverage",
Expand All @@ -144,5 +152,12 @@
"{src,cli}/**/*.ts": [
"yarn format"
]
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
},
"czConfig": {
"path": "node_modules/cz-conventional-changelog"
}
}
111 changes: 26 additions & 85 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,111 +1,52 @@
import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import autoExternal from 'rollup-plugin-auto-external';
import esbuild from 'rollup-plugin-esbuild';
import json from '@rollup/plugin-json';
import nodeResolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import findNodeModules from 'find-node-modules';
import builtinModules from 'builtin-modules';
import pkgJson from './package.json';
import fs from 'fs';
import path from 'path';

let CHECKED_DEPS = [];

export default function odpRollupConfig(options) {
const extensions = ['.ts', '.js', '.mjs'];
const resolveOptions = {
mainFields: ['jsnext:main', 'es2017', 'es2015', 'module', 'main'],
mainFields: ['jsnext:main', 'es2020', 'es2018', 'es2017', 'es2015', 'module', 'main'],
preferBuiltins: true,
extensions,
modulesOnly: true,
browser: true
extensions: ['.ts', '.js', '.mjs', '.node'],
modulesOnly: false,
browser: false
};
const plugins = [
json({
exclude: 'node_modules/**',
preferConst: true,
compact: true,
namedExports: true,
indent: ' '
json(),
autoExternal({
builtins: true,
peerDependencies: true,
dependencies: true
}),
nodeResolve(resolveOptions),
typescript({
useTsconfigDeclarationDir: false,
tsconfigOverride: {
compilerOptions: { module: 'esnext' }
}
}),
commonjs(),
terser()
esbuild({
minify: true,
target: 'esnext'
})
];

function getContent(dir) {
return JSON.parse(fs.readFileSync(dir, 'utf8'));
}

function getDependencies(pkg) {
return [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})];
}

function getAllDependencies(dep) {
let result = [];
findNodeModules()
.map((dir) => path.resolve(process.cwd(), dir))
.forEach((dir) => {
const depPkg = path.join(dir, dep, 'package.json');
if (fs.existsSync(depPkg)) {
const content = getContent(depPkg);
const deps = getDependencies(content);
deps.forEach((d) => {
if (!CHECKED_DEPS.includes(d)) {
CHECKED_DEPS = [...CHECKED_DEPS, d];
result = [...result, ...getAllDependencies(d)];
}
});
result = [...result, ...deps];
}
});
return result;
}

function filterDependencies(pkg, deps) {
const { devDependencies } = pkg;
let result = [...deps];
if (devDependencies) {
result = result.filter((d) => !Object.keys(devDependencies).includes(d));
}
return result.filter((dep, index, array) => array.indexOf(dep) === index);
}

function getRecursiveDependencies(pkg) {
const deps = getDependencies(pkg);
let result = [...deps];
deps.forEach((dep) => {
CHECKED_DEPS = [...CHECKED_DEPS, dep];
result = [...result, ...getAllDependencies(dep)];
});
return filterDependencies(pkg, result);
}

const external = [...getRecursiveDependencies(pkgJson), ...builtinModules];
const outputConfig = { sourcemap: false, globals: {} };
const output = {
const external = [...builtinModules];
const outputMain = {
input: 'src/index.ts',
treeshake: true,
output: [
{ ...outputConfig, file: pkgJson.main, format: 'cjs' },
{ ...outputConfig, file: pkgJson.module, format: 'es' }
],
output: [{ sourcemap: false, file: pkgJson.main, format: 'cjs' }],
plugins,
external,
...options
};
const outputModule = {
...outputMain,
output: [{ sourcemap: false, file: pkgJson.module, format: 'esm' }]
};
return [
output,
outputMain,
outputModule,
{
...output,
...outputMain,
input: 'cli/cli.ts',
output: [{ ...outputConfig, file: 'bin/cli.js', format: 'cjs', banner: '#!/usr/bin/env node' }]
output: [{ sourcemap: false, file: 'bin/cli.js', format: 'cjs', banner: '#!/usr/bin/env node' }]
}
];
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import S3, { ClientConfiguration } from 'aws-sdk/clients/s3';
import { ClientConfiguration } from 'aws-sdk/clients/s3';
import { S3WrapperBuckets } from './s3/buckets';
import { S3WrapperFiles } from './s3/files';
import { S3Config, UploadOptions, UploadOptionsBasic } from './types';
import { Config } from './config';
import { S3 } from 'aws-sdk';

export class S3Wrapper {
public bucket = '';
Expand Down
8 changes: 4 additions & 4 deletions src/s3/files.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import S3, { Delete, DeleteObjectsOutput, GetObjectOutput, ObjectIdentifierList, ObjectList } from 'aws-sdk/clients/s3';
import { Delete, DeleteObjectsOutput, GetObjectOutput, ObjectIdentifierList, ObjectList } from 'aws-sdk/clients/s3';
import { S3WrapperBuckets } from './buckets';
import { UploadOptions, UploadOptionsBasic } from '../types';
import path from 'path';
Expand All @@ -12,7 +12,7 @@ import { Config } from '../config';
import glob from 'glob';
import { ManagedUpload } from 'aws-sdk/lib/s3/managed_upload';
import mysqldump from 'mysqldump';
import SendData = ManagedUpload.SendData;
import { S3 } from 'aws-sdk';

export class S3WrapperFiles {
private s3Buckets?: S3WrapperBuckets;
Expand Down Expand Up @@ -77,7 +77,7 @@ export class S3WrapperFiles {
} catch (e) {
return Promise.reject(e);
}
return new Promise<SendData>((resolve, reject) => {
return new Promise<ManagedUpload.SendData>((resolve, reject) => {
if (!replaced) {
return reject(Error(`${Config.TAG} File "${destination}" already exists in bucket "${bucket}" and will not be replaced`));
}
Expand Down Expand Up @@ -114,7 +114,7 @@ export class S3WrapperFiles {
const result = await this.compressFiles(files, zipName);
uploadFiles = [result];
}
let result: { [filename: string]: SendData } = {};
let result: { [filename: string]: ManagedUpload.SendData } = {};
for (const file of uploadFiles) {
if (file.includes('*')) {
const response = await this.uploadFiles(bucket, glob.sync(file), folderName, options);
Expand Down
File renamed without changes.
Loading

0 comments on commit 7f7a292

Please sign in to comment.