Skip to content

Commit

Permalink
+ glob pattern matching
Browse files Browse the repository at this point in the history
+ exit code 1 on error
+ choose mode/quality
+ cli help
+ allow to overwrite files
  • Loading branch information
dzek69 committed Apr 29, 2021
1 parent 64d5eac commit 2bcda4c
Show file tree
Hide file tree
Showing 22 changed files with 6,524 additions and 59 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[{package.json,*.yml}]
indent_size = 2
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": [
"@dzek69/eslint-config-base",
"@dzek69/eslint-config-typescript"
],
"env": {
"node": true
},
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.lint.json"
},
"ignorePatterns": [],
"overrides": [
{
"files": [
"src/*.spec.*", "src/**/*.spec.*"
],
"env": {
"jest": true
},
"rules": {
"func-names": "off",
"global-require": "off",
"max-lines": "off",
"max-lines-per-function": "off",
"max-statements": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"no-unused-labels": "off"
}
}
]
}
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
/.idea/
/node_modules/
/docs/
/dist/
/esm/
/node_modules/

/*.tgz
*.log
*.tsbuildinfo
17 changes: 17 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/.idea/
/build-scripts/
/test/

/babel.config.cjs
/jest.config.cjs
/yarn.lock
/*.tgz
/*.log
/.yarnclean
/nodemon.json
/.editorconfig
/tsconfig.*

*.d.ts
*.map
/.eslintrc.json
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [UNRELEASED]
(nothing yet)

## [1.0.0] - 2021-04-29
### Added
- glob pattern matching
- exit code 1 on error
- choose mode/quality
- cli help
- allow to overwrite files

## [0.0.1] - 2018-01-30
### Added
- first version
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Jacek Nowacki
Copyright (c) 2021 Jacek Nowacki

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# brotli-cli

A basic Brotli CLI files compressor. W.I.P. CLI api will change.
Brotli files compressor.
Decompression feature will come.

Based on `brotli` npm module.

Expand All @@ -9,17 +10,26 @@ Based on `brotli` npm module.
### Global install

1. `npm i -g brotli-cli`
1. `brotli-cli file1.txt file2.svg file3.js`
1. `brotli-cli compress file1.txt file2.svg file3.js`

Files will be created in the same directory, but with `.br` extension appended. Overwriting will occur without asking.

Run
1. `brotli-cli help` for help and more examples.

### Local install

You need npm 5.2+ for this:

1. `npm i brotli-cli`
1. `npx brotli-cli file1.txt file2.svg file3.js`

### Run without installing

You need npm 5.2+ for this:

1. `npx brotli-cli file1.txt file2.svg file3.js`

## License

MIT
MIT
6 changes: 6 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};
7 changes: 7 additions & 0 deletions build-scripts/compile.cjs.after.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import fs from "fs-extra";

(async () => {
console.info("[CJS compile post-processing started]");
await fs.writeFile("./dist/package.json", JSON.stringify({ type: "commonjs" }))
console.info("[CJS compile post-processing ended]");
})();
26 changes: 0 additions & 26 deletions index.js

This file was deleted.

16 changes: 16 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
// testMatch: [],
collectCoverageFrom: [
'src/**/*.{mjs,js,jsx,ts,tsx}',
'!**/*.d.ts'
],
setupFiles: [
'<rootDir>/test/bootstrap.cjs'
],
testURL: 'http://localhost:8080',
moduleNameMapper: {
'^(.*)\.js$': '$1',
},
};


6 changes: 6 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "ts,json",
"ignore": ["src/**/*.spec.ts"],
"exec": "node --loader ts-node/esm ./src/index.ts"
}
57 changes: 49 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,57 @@
{
"name": "brotli-cli",
"version": "0.0.1",
"main": "index.js",
"repository": "https://github.com/dzek69/brotli-cli.git",
"author": "Jacek Nowacki <[email protected]>",
"version": "1.0.0",
"repository": "[email protected]:dzek69/brotli-cli.git",
"author": "Jacek Nowacki",
"license": "MIT",
"bin": "index.js",
"scripts": {
"test": "NODE_ENV=test jest",
"docs": "typedoc src/index.ts --out docs --listInvalidSymbolLinks --includes tutorials",
"compile": "yarn compile:cjs",
"compile:cjs": "rm -rf dist && tsc --project tsconfig.cjs.json && node ./build-scripts/compile.cjs.after.mjs",
"typecheck": "tsc --noEmit",
"lint": "eslint src --ext .ts,.tsx,.js,.jsx,.mjs",
"lint:fix": "yarn lint --fix",
"prepack": "yarn compile",
"prepublishOnly": "yarn lint && yarn test && yarn docs",
"start:dev": "nodemon",
"start:dev:compatibility": "TS_NODE_FILES=true yarn start:dev"
},
"bin": "./dist/index.js",
"type": "module",
"dependencies": {
"better-custom-error": "^4.0.1",
"brotli": "^1.3.2",
"fs-extra": "^5.0.0"
"fast-glob": "^3.2.5",
"yargs": "^16.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@dzek69/eslint-config-base": "^2.0.0",
"@dzek69/eslint-config-typescript": "^0.2.4",
"@types/brotli": "^1.3.0",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"eslint": "^7.14.0",
"fs-extra": "^9.0.1",
"husky": "^4.3.0",
"jest": "^26.6.3",
"must": "^0.13.4",
"nodemon": "^2.0.6",
"ts-node": "^9.0.0",
"typedoc": "^0.20.35",
"typescript": "^4.2.4"
},
"husky": {
"hooks": {
"pre-push": "yarn prepublishOnly && yarn compile"
}
},
"engines": {
"node": ">=6.4.0"
"libraryTemplate": {
"version": "3.0.2",
"language": "typescript",
"fixDefaultForCommonJS": true
}
}
9 changes: 9 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createError } from "better-custom-error";

const NoFilesError = createError("NoFilesError");
const CompressionProcessError = createError("CompressionProcessError");

export {
NoFilesError,
CompressionProcessError,
};
5 changes: 5 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("tests", () => {
it("are working", () => {
true.must.be.true();
});
});
Loading

0 comments on commit 2bcda4c

Please sign in to comment.