diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6dfb8a8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = tab +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 +indent_style = space + +[*.js.snap] +trim_trailing_whitespace = false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f02a6b4 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +name: mix-replacer +on: [push] +jobs: + Jest-Tests: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + args: + - LARAVEL_MIX_VERSION: ^5.0.4 + - LARAVEL_MIX_VERSION: ^6.0.25 + os: [ubuntu-latest, windows-latest, macos-latest] + node-version: [12.x, 13.x, 14.x] + steps: + - uses: actions/checkout@v2 + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache_name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}-${{ matrix.args.LARAVEL_MIX_VERSION }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm install laravel-mix@${{matrix.args.LARAVEL_MIX_VERSION}} -f + - run: npm run test:ci diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8261843..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: node_js -node_js: - - 10 - - 11 - - 12 - - 13 - - 14 - -os: - - linux - - windows - - osx - -cache: npm - -install: - - npm install - -script: - - npm run test - -after_success: - - bash <(curl -s https://codecov.io/bash) -Z -v diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c4270c..bac9d9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v.2.0.0 + +- Required minimal Node engine version 12.x +- Required minimal `laravel-mix` version 6.0.25 +- Remove `lodash` dependecie + ## v1.3.2 - Fix typos in `README.md`. diff --git a/README.md b/README.md index 0d3f70f..5f85163 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,13 @@ [![codecov](https://codecov.io/gh/soufyakoub/mix-replacer/branch/master/graph/badge.svg)](https://codecov.io/gh/soufyakoub/mix-replacer) [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/soufyakoub/mix-replacer/blob/master/LICENSE) +# Last versions + +**mix-replacer@2.0.0** work from **laravel-mix@^5.0.4** to **laravel-mix@6.0.25**, but if you using **Node 10.x**, just **laravel-mix@^5.0.4** work because, the minimal Node version for **laravel-mix@6.0.25** is **12.x**. + # mix-replacer -> A [laravel-mix](https://laravel-mix.com/docs/5.0/versioning) extension to copy files +> A [laravel-mix](https://laravel-mix.com/docs/versioning) extension to copy files > and append hash queries to public urls. ## Installation @@ -103,9 +107,6 @@ Running tests is as simple as typing `npm run test` in a terminal from the proje Coverage reports are generated to `tests/coverage`. -| :warning: make sure your node.js version is `>= 10.14.2`, [here's why](https://github.com/facebook/jest/issues/9538)| -|---| - ## Contributing Please feel free to submit issues and pull requests. diff --git a/jest.config.js b/jest.config.js index d3e9828..556e405 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,9 +1,17 @@ + +const { execSync } = require("child_process"); const path = require("path"); const IS_UNIX = path.sep === "/"; const SEP = path.sep; -const ROOT = IS_UNIX ? "/" : "C:\\"; +const ROOT = IS_UNIX ? "/" : getWindowsRoot(); const CWD = path.resolve(); +function getWindowsRoot(){ + // In Github Actions environment the hard drive is D:\ + // this should get correct path. + return execSync("chdir").toString().split("\\")[0] + "\\"; +} + module.exports = { verbose: true, collectCoverage: true, diff --git a/package.json b/package.json index 4349428..2409f78 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "mix-replacer", - "version": "1.3.2", + "version": "2.0.0", "description": "A laravel-mix extension to copy files append hash queries to public urls.", "main": "src/index.js", "scripts": { - "test": "jest" + "test": "jest", + "test:ci": "jest --runInBand --ci" }, "repository": { "type": "git", @@ -35,21 +36,20 @@ "src" ], "engines": { - "node": ">= 10.12.0" + "node": ">= 12.0.0" }, "devDependencies": { - "laravel-mix": "^5.0.4", + "@types/jest": "^26.0.0", "glob": "^7.1.6", - "uuid": "^8.1.0", - "jest": "^26.0.1", - "@types/jest": "^26.0.0" + "jest": "^27.0.6", + "laravel-mix": "^6.0.25", + "uuid": "^8.1.0" }, "peerDependencies": { - "laravel-mix": "^5.0.0", - "glob": "^7.0.0" + "glob": "^7.0.0", + "laravel-mix": "^6.0.25" }, "dependencies": { - "lodash": "^4.17.19", "validate": "^5.1.0" } } diff --git a/src/helpers.js b/src/helpers.js index e0a3099..c4400fc 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -6,6 +6,13 @@ function escapeRegExp(string) { return string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); } +function merge(defaultOptions, overrideOptions) { + for (let key in overrideOptions) { + defaultOptions[key] = overrideOptions[key]; + } +} + module.exports = { escapeRegExp, + merge }; diff --git a/src/options.js b/src/options.js index 9038230..7634034 100644 --- a/src/options.js +++ b/src/options.js @@ -1,5 +1,5 @@ -const _ = require("lodash"); const Schema = require("validate"); +const {merge: mergeOptions} = require("./helpers"); const schema = new Schema({ delimiters: { @@ -36,7 +36,7 @@ function merge(new_options) { throw errors[0]; } - _.merge(options, new_options); + mergeOptions(options, new_options); } module.exports = {