├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib ├── cli.js └── main.js ├── package.json └── test └── main.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | end_of_line = lf 8 | charset = utf-8 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | testdata 2 | node_modules 3 | coverage 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["standard", "prettier"], 3 | "plugins": ["import", "mocha"], 4 | "env": { 5 | "mocha": true 6 | }, 7 | "rules": { 8 | "prefer-template": "error", 9 | "mocha/no-exclusive-tests": "error", 10 | "mocha/no-nested-tests": "error", 11 | "mocha/no-identical-title": "error", 12 | "prefer-const": [ 13 | "error", 14 | { 15 | "destructuring": "all", 16 | "ignoreReadBeforeAssign": false 17 | } 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 'on': 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | test: 8 | runs-on: ubuntu-18.04 9 | name: Node ${{ matrix.node }} 10 | strategy: 11 | matrix: 12 | node: 13 | - '12' 14 | - '14' 15 | - '16' 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Setup node 19 | uses: actions/setup-node@v1 20 | with: 21 | node-version: ${{ matrix.node }} 22 | - run: npm install 23 | - run: npm test 24 | 25 | test-targets: 26 | runs-on: ubuntu-18.04 27 | name: ${{ matrix.targets.name }} 28 | strategy: 29 | matrix: 30 | targets: 31 | - name: 'Lint' 32 | target: 'lint' 33 | - name: 'Coverage' 34 | target: 'coverage' 35 | 36 | steps: 37 | - uses: actions/checkout@v2 38 | - name: Setup node 39 | uses: actions/setup-node@v1 40 | with: 41 | node-version: '14' 42 | - run: npm install 43 | - run: npm run ${{ matrix.targets.target }} 44 | - name: Upload coverage 45 | uses: coverallsapp/github-action@master 46 | with: 47 | github-token: ${{ secrets.GITHUB_TOKEN }} 48 | if: ${{ matrix.targets.target == 'coverage' }} 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | .nyc_output 4 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock = false 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | /testdata/ 2 | /node_modules/ 3 | /coverage/ 4 | /.nyc_output/ 5 | 6 | # Don't fight npm i --save 7 | /package.json 8 | 9 | # Generated 10 | /CHANGELOG.md 11 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### v2.0.2 (2021-01-23) 2 | 3 | #### Pull requests 4 | 5 | - [#89](https://github.com/papandreou/bringhome/pull/89) Upgrade assetgraph to version 6.4.5 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 6 | 7 | #### Commits to master 8 | 9 | - [Use a ^ version range for assetgraph](https://github.com/papandreou/bringhome/commit/916753b3c7b6b894f44643106a8d27a41dea5715) ([Andreas Lind](mailto:andreas.lind@peakon.com)) 10 | 11 | ### v2.0.1 (2021-01-19) 12 | 13 | #### Pull requests 14 | 15 | - [#88](https://github.com/papandreou/bringhome/pull/88) Upgrade assetgraph to version 6.4.4 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 16 | - [#87](https://github.com/papandreou/bringhome/pull/87) Upgrade assetgraph to version 6.4.2 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 17 | - [#85](https://github.com/papandreou/bringhome/pull/85) Upgrade assetgraph to version 6.4.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 18 | - [#84](https://github.com/papandreou/bringhome/pull/84) Upgrade eslint-config-prettier to version 7.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 19 | - [#83](https://github.com/papandreou/bringhome/pull/83) Upgrade eslint-plugin-standard to version 5.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 20 | - [#81](https://github.com/papandreou/bringhome/pull/81) Upgrade unexpected-sinon to version 11.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 21 | - [#82](https://github.com/papandreou/bringhome/pull/82) Upgrade prettier to version 2.2.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 22 | - [#79](https://github.com/papandreou/bringhome/pull/79) Upgrade assetgraph to version 6.3.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 23 | - [#78](https://github.com/papandreou/bringhome/pull/78) Upgrade assetgraph to version 6.2.2 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 24 | - [#77](https://github.com/papandreou/bringhome/pull/77) Upgrade eslint-config-standard to version 16.0.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 25 | - [#75](https://github.com/papandreou/bringhome/pull/75) Upgrade eslint-config-standard to version 15.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 26 | - [#74](https://github.com/papandreou/bringhome/pull/74) Upgrade assetgraph to version 6.2.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 27 | 28 | #### Commits to master 29 | 30 | - [Update httpception to ^4.0.1](https://github.com/papandreou/bringhome/commit/d88bf3a96101776221d3ae42d08d11bfe81d94b2) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 31 | - [Add CHANGELOG.md + offline-github-changelog integration](https://github.com/papandreou/bringhome/commit/a0be07460be04135f954b9c5ab18f13057c52615) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 32 | - [Sanitize .prettierignore](https://github.com/papandreou/bringhome/commit/83534d3c399fe3b695fe128bd9de2a3184e1272c) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 33 | - [Also check \*.json and \*.md with prettier](https://github.com/papandreou/bringhome/commit/c5cc4a5ae5fbd30fef7ed90ba8147728e587c6d2) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 34 | - [Update unexpected + plugins](https://github.com/papandreou/bringhome/commit/2ceb7d647d1a2ecca5619515802c1676a7b09bfb) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 35 | - [+1 more](https://github.com/papandreou/bringhome/compare/v2.0.0...v2.0.1) 36 | 37 | ### v2.0.0 (2020-09-11) 38 | 39 | #### Pull requests 40 | 41 | - [#72](https://github.com/papandreou/bringhome/pull/72) Upgrade prettier to version 2.1.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 42 | - [#71](https://github.com/papandreou/bringhome/pull/71) Upgrade assetgraph to version 6.2.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 43 | - [#70](https://github.com/papandreou/bringhome/pull/70) Upgrade eslint-plugin-mocha to version 8.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 44 | - [#69](https://github.com/papandreou/bringhome/pull/69) Upgrade assetgraph to version 6.1.3 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 45 | - [#68](https://github.com/papandreou/bringhome/pull/68) Upgrade assetgraph to version 6.1.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 46 | - [#67](https://github.com/papandreou/bringhome/pull/67) Upgrade assetgraph to version 6.0.8 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 47 | - [#65](https://github.com/papandreou/bringhome/pull/65) Upgrade assetgraph to version 6.0.7 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 48 | - [#64](https://github.com/papandreou/bringhome/pull/64) Upgrade assetgraph to version 6.0.6 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 49 | - [#63](https://github.com/papandreou/bringhome/pull/63) Upgrade eslint-plugin-mocha to version 7.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 50 | - [#62](https://github.com/papandreou/bringhome/pull/62) Upgrade eslint to version 7.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 51 | - [#60](https://github.com/papandreou/bringhome/pull/60) Upgrade sinon to version 9.0.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 52 | - [#58](https://github.com/papandreou/bringhome/pull/58) Upgrade mocha to version 7.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 53 | - [#57](https://github.com/papandreou/bringhome/pull/57) Upgrade assetgraph to version 6.0.5 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 54 | - [#56](https://github.com/papandreou/bringhome/pull/56) Upgrade eslint-plugin-node to version 11.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 55 | - [#54](https://github.com/papandreou/bringhome/pull/54) Upgrade nyc to version 15.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 56 | - [#55](https://github.com/papandreou/bringhome/pull/55) Upgrade sinon to version 8.0.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 57 | - [#53](https://github.com/papandreou/bringhome/pull/53) Upgrade assetgraph to version 6.0.4 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 58 | - [#52](https://github.com/papandreou/bringhome/pull/52) Upgrade assetgraph to version 6.0.3 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 59 | - [#51](https://github.com/papandreou/bringhome/pull/51) Upgrade assetgraph to version 6.0.2 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 60 | - [#50](https://github.com/papandreou/bringhome/pull/50) Upgrade yargs to version 15.0.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 61 | - [#49](https://github.com/papandreou/bringhome/pull/49) Upgrade prettier to version 1.19.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 62 | - [#48](https://github.com/papandreou/bringhome/pull/48) Upgrade assetgraph to version 6.0.1 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 63 | 64 | #### Commits to master 65 | 66 | - [Drop node.js 8 support, add 14 \(semver-major\)](https://github.com/papandreou/bringhome/commit/76993673dadb7d1b303f7b090eb51ccf0480bea1) ([Andreas Lind](mailto:andreas.lind@peakon.com)) 67 | - [Update yargs to version 16.0.3](https://github.com/papandreou/bringhome/commit/6028ca41d11d7766cc465323ae8d8222aac91c40) ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 68 | - [Fix typo](https://github.com/papandreou/bringhome/commit/5dae2fdf79304ab7173eda607d3525796acb2e42) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 69 | - [Fix CI setup, only run lint on node.js 12](https://github.com/papandreou/bringhome/commit/666aaf879ca6cc994fb7435d62fbb0912f7d14c8) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 70 | - [prettier --write '\*\*\/\*.js'](https://github.com/papandreou/bringhome/commit/4bcfed1b926810c6972298992688d3c998299d71) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 71 | - [+2 more](https://github.com/papandreou/bringhome/compare/v1.8.0...v2.0.0) 72 | 73 | ### v1.8.0 (2019-09-14) 74 | 75 | - [#47](https://github.com/papandreou/bringhome/pull/47) Upgrade eslint-plugin-node to version 10.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 76 | - [#46](https://github.com/papandreou/bringhome/pull/46) Upgrade yargs to version 14.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 77 | - [#45](https://github.com/papandreou/bringhome/pull/45) Upgrade eslint-config-standard to version 14.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 78 | - [#44](https://github.com/papandreou/bringhome/pull/44) Upgrade assetgraph to version 6.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 79 | 80 | ### v1.7.0 (2019-08-15) 81 | 82 | #### Pull requests 83 | 84 | - [#43](https://github.com/papandreou/bringhome/pull/43) Upgrade rimraf to version 3.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 85 | - [#42](https://github.com/papandreou/bringhome/pull/42) Upgrade assetgraph to version 5.12.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 86 | - [#41](https://github.com/papandreou/bringhome/pull/41) Upgrade assetgraph to version 5.11.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 87 | - [#39](https://github.com/papandreou/bringhome/pull/39) Upgrade httpception to version 3.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 88 | - [#38](https://github.com/papandreou/bringhome/pull/38) Upgrade eslint to version 6.0.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 89 | - [#37](https://github.com/papandreou/bringhome/pull/37) Upgrade assetgraph to version 5.10.0 ([depfu[bot]](mailto:23717796+depfu[bot]@users.noreply.github.com)) 90 | - [#36](https://github.com/papandreou/bringhome/pull/36) Upgrade assetgraph to version 5.9.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 91 | - [#35](https://github.com/papandreou/bringhome/pull/35) Upgrade prettier to version 1.18.2 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 92 | - [#34](https://github.com/papandreou/bringhome/pull/34) Upgrade nyc to version 14.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 93 | - [#33](https://github.com/papandreou/bringhome/pull/33) Upgrade prettier to version 1.17.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 94 | - [#32](https://github.com/papandreou/bringhome/pull/32) Upgrade assetgraph to version 5.8.4 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 95 | - [#31](https://github.com/papandreou/bringhome/pull/31) Upgrade assetgraph to version 5.8.3 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 96 | - [#30](https://github.com/papandreou/bringhome/pull/30) Upgrade assetgraph to version 5.8.1 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 97 | - [#29](https://github.com/papandreou/bringhome/pull/29) Upgrade assetgraph to version 5.7.1 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 98 | - [#28](https://github.com/papandreou/bringhome/pull/28) Upgrade assetgraph to version 5.6.4 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 99 | - [#27](https://github.com/papandreou/bringhome/pull/27) Upgrade mocha to version 6.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 100 | - [#26](https://github.com/papandreou/bringhome/pull/26) Upgrade assetgraph to version 5.6.3 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 101 | - [#24](https://github.com/papandreou/bringhome/pull/24) Upgrade assetgraph to version 5.6.2 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 102 | - [#25](https://github.com/papandreou/bringhome/pull/25) Upgrade yargs to version 13.1.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 103 | - [#23](https://github.com/papandreou/bringhome/pull/23) Upgrade assetgraph to version 5.6.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 104 | 105 | #### Commits to master 106 | 107 | - [Avoid the deprecated require\('url'\).resolve](https://github.com/papandreou/bringhome/commit/f9321af991be237ad720c3461b5cc02e536ed1f8) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 108 | - [eslint --fix . && prettier --write '\*\*\/\*.js'](https://github.com/papandreou/bringhome/commit/5f605707345ddf3cbbf07a86f59aa9fc8bafe046) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 109 | - [Replace eslint-config-pretty-standard with eslint-config-{prettier,standard}, add eslint-plugin-mocha](https://github.com/papandreou/bringhome/commit/340061ade4cb29bd402db0a12b236c8192327634) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 110 | - [Don't run lint as part of test](https://github.com/papandreou/bringhome/commit/69f9d80a4d36a3356d0d5cc8c830d80c067009da) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 111 | 112 | ### v1.6.0 (2019-02-03) 113 | 114 | #### Pull requests 115 | 116 | - [#20](https://github.com/papandreou/bringhome/pull/20) Upgrade prettier to version 1.16.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 117 | - [#19](https://github.com/papandreou/bringhome/pull/19) Upgrade assetgraph to version 5.4.1 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 118 | - [#18](https://github.com/papandreou/bringhome/pull/18) Upgrade unexpected to version 11.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 119 | - [#15](https://github.com/papandreou/bringhome/pull/15) Upgrade sinon to version 7.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 120 | - [#14](https://github.com/papandreou/bringhome/pull/14) Upgrade assetgraph to version 5.3.1 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 121 | - [#13](https://github.com/papandreou/bringhome/pull/13) Upgrade eslint-plugin-prettier to version 3.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 122 | - [#11](https://github.com/papandreou/bringhome/pull/11) Upgrade nyc to version 13.0.1 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 123 | - [#10](https://github.com/papandreou/bringhome/pull/10) Upgrade @gustavnikolaj\/async-main-wrap to version 3.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 124 | 125 | #### Commits to master 126 | 127 | - [Update assetgraph to 5.5.1](https://github.com/papandreou/bringhome/commit/61fb9b3c96603452c589b1474b77a76c979081ca) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 128 | - [Update assetgraph to version 5.5.0](https://github.com/papandreou/bringhome/commit/22e6244eabaf63eaba63048a396bd5869dc7616d) ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 129 | - [Lock down prettier to ~1.15.2 to prevent random breakage when a new minor version gets released](https://github.com/papandreou/bringhome/commit/2b4bcfaba94b865ba2197b92b942968755d20f6b) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 130 | - [eslint --fix .](https://github.com/papandreou/bringhome/commit/1c38502a84d8e4bf9cd3c9df6366804c74bd9490) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 131 | - [Travis: Stick with node.js 8.11](https://github.com/papandreou/bringhome/commit/c23a5a16b563a6ceef387a397a727e1583722534) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 132 | - [+3 more](https://github.com/papandreou/bringhome/compare/v1.5.0...v1.6.0) 133 | 134 | ### v1.5.0 (2018-08-18) 135 | 136 | #### Pull requests 137 | 138 | - [#9](https://github.com/papandreou/bringhome/pull/9) Upgrade nyc to version 12.0.2 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 139 | - [#3](https://github.com/papandreou/bringhome/pull/3) Upgrade assetgraph to version 5.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 140 | - [#5](https://github.com/papandreou/bringhome/pull/5) Upgrade yargs to version 12.0.1 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 141 | - [#7](https://github.com/papandreou/bringhome/pull/7) Upgrade eslint-config-pretty-standard to version 2.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 142 | - [#8](https://github.com/papandreou/bringhome/pull/8) Upgrade httpception to version 2.0.0 ([depfu[bot]](mailto:depfu[bot]@users.noreply.github.com)) 143 | 144 | #### Commits to master 145 | 146 | - [Make sure that JavaScriptStaticUrl relations aren't converted to relative urls](https://github.com/papandreou/bringhome/commit/e315ae50d622488443a19012e5ff33c0f37ca289) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 147 | - [Update CLI docs in README](https://github.com/papandreou/bringhome/commit/5bb9d3bc13be6914e68fa5760ef397e2a8c007c9) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 148 | - [Add the checkIncompatibleTypes transform](https://github.com/papandreou/bringhome/commit/6d0b2cf903963aa2264cca80da74fc51c2205b94) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 149 | 150 | ### v1.4.0 (2018-07-18) 151 | 152 | - [--omit-scripts: Skip SvgInlineEventHandler relations](https://github.com/papandreou/bringhome/commit/4ba9e3a2978edda42534e5b5b155b7a1f771c66a) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 153 | - [--omit-scripts: Unwrap <noscript> blocks](https://github.com/papandreou/bringhome/commit/297458328fad94bc6eef720d306442d9f6bf9e27) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 154 | - [Skip HtmlServiceWorkerRegistration relations in --omit-scripts mode](https://github.com/papandreou/bringhome/commit/9f4e0c877a7976350ef2e4e8f4346a31a94cd566) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 155 | - [Ensure that the downloaded files have an extension \(to make them more likely to be served with the correct C-T\)](https://github.com/papandreou/bringhome/commit/f391665abd96dc76f3f158f7c50023c2e311a918) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 156 | 157 | ### v1.3.2 (2018-07-14) 158 | 159 | - [Handle the entry point url being redirected](https://github.com/papandreou/bringhome/commit/1ce7bb5db58450bbd26256daefcadadede4a21f3) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 160 | - [Implement --pretty switch](https://github.com/papandreou/bringhome/commit/4d0b9b002f84f1f1c66b78dd8b69c18807dcd5c8) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 161 | - [Fix test](https://github.com/papandreou/bringhome/commit/330acc965237676b304f3e883b2983a3aa2827ba) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 162 | - [Remove accidentally committed code](https://github.com/papandreou/bringhome/commit/ee41a08dcbfde8b0e52ce531e3e2b93a7caffcee) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 163 | - [Remove unnecessary template string](https://github.com/papandreou/bringhome/commit/2bd4e6db5db017a6b291224edf24fb15f4af9c01) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 164 | - [+1 more](https://github.com/papandreou/bringhome/compare/v1.3.1...v1.3.2) 165 | 166 | ### v1.3.1 (2018-07-14) 167 | 168 | - [Add the default extension when moving files out of the way](https://github.com/papandreou/bringhome/commit/1e154e088d2a7045d95de73291dbad7ad305b62d) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 169 | - [Handle the case where a file collides with a directory](https://github.com/papandreou/bringhome/commit/f7164d6e23c617d5f7f5ad74b33bd1cc4f2d4b98) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 170 | 171 | ### v1.3.0 (2018-07-13) 172 | 173 | - [Don't follow JsonUrl relations \(they tend to point at Html assets\)](https://github.com/papandreou/bringhome/commit/5c93baeb2b84263ce2e1b86c59fee53cc58b0fdd) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 174 | - [Don't break when there are cyclic references](https://github.com/papandreou/bringhome/commit/70a2d19cb55f7685fd066ee3b4c93b4ddbcd66cf) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 175 | 176 | ### v1.2.0 (2018-07-12) 177 | 178 | - [Handle HTTP redirects](https://github.com/papandreou/bringhome/commit/3c075e43570cce8e64d66614293e4966658ccf2e) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 179 | - [Remove comment blaming teepee, turns out it's node's http client that collapses headers](https://github.com/papandreou/bringhome/commit/53494a91a6f9b9fb3f939115a6726e5f9b42986e) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 180 | 181 | ### v1.1.1 (2018-07-12) 182 | 183 | - [Fix parsing of process.argv](https://github.com/papandreou/bringhome/commit/39c3de55c84beee69183fdd9541220ae626e9c91) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 184 | - [Add nyc config to package.json](https://github.com/papandreou/bringhome/commit/dc4a7682c22ec6499f383b4b878ba1cb6f30546c) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 185 | - [coverage: Echo command to open the coverage report](https://github.com/papandreou/bringhome/commit/142194c165fd2fa1c67129d2bcdc6b93d497c770) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 186 | - [Clean up CI config](https://github.com/papandreou/bringhome/commit/ef45a596fb9b450e659f5fe3c60ad3e07719027a) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 187 | 188 | ### v1.1.0 (2018-07-12) 189 | 190 | - [Implement -H|--header switch](https://github.com/papandreou/bringhome/commit/5712667c92db3e8d7c428f5a0614178e79b40b2e) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 191 | - [Implement -s|--silent switch](https://github.com/papandreou/bringhome/commit/9426a66713356f9b8a0e9ef4b79d348affb6166a) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 192 | - [Add quick README](https://github.com/papandreou/bringhome/commit/249b42fb0cbc5fc2d9a7e35b04055bfd56ffd0da) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 193 | 194 | ### v1.0.0 (2018-07-12) 195 | 196 | - [Fix year in license](https://github.com/papandreou/bringhome/commit/653d0f1aa74f08c6fc9222169b1c1551eb1be9cb) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 197 | - [Fix --self-contained](https://github.com/papandreou/bringhome/commit/1a5422a657d6d7a558e196bf192c7ebdd0f374cc) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 198 | - [Rewrite to relative urls whenever possible](https://github.com/papandreou/bringhome/commit/519089165500d072cbe32b6c957c1a6a4e78631e) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 199 | - [Don't return anything from main.js to appease async-main-wrap](https://github.com/papandreou/bringhome/commit/c71d83d31ca10abbc21299e5b6dc5feea4b95207) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 200 | - [Omit other types of relations that point at JavaScript when --omit-scripts is passed](https://github.com/papandreou/bringhome/commit/4a6dfe238e7a45c3d8b1c92aa21e6c13ccb60b3e) ([Andreas Lind](mailto:andreaslindpetersen@gmail.com)) 201 | - [+5 more](https://github.com/papandreou/bringhome/compare/4a6dfe238e7a45c3d8b1c92aa21e6c13ccb60b3e...v1.0.0) 202 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Andreas Lind 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of the author nor the names of contributors may 15 | be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 19 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bringhome 2 | 3 | `wget`/`Save page as`-like tool for downloading a web page and its assets to a local directory, rewriting its internal references to relative urls. 4 | 5 | ## Installation 6 | 7 | ``` 8 | npm install -g bringhome 9 | ``` 10 | 11 | ## Usage 12 | 13 | ``` 14 | bringhome https://example.com/ -o localdir 15 | 16 | Options: 17 | --help Show help [boolean] 18 | --version Show version number [boolean] 19 | --output, -o Directory where results should be written to (or 20 | file in --self-contained mode) [string] [required] 21 | --header, -H Specify a custom header and value to pass when 22 | retrieving assets, eg. -H 'Foo: bar'. Can be 23 | repeated [array] [default: []] 24 | --recursive, -r Crawl all HTML-pages linked with relative and root 25 | relative links. This stays inside your domain 26 | [boolean] [default: false] 27 | --pretty Pretty print downloaded assets 28 | [boolean] [default: false] 29 | --omit-scripts Leave out JavaScript [boolean] [default: false] 30 | --self-contained Inline all assets, producing a single, 31 | self-contained "archive" HTML file. Alters the 32 | meaning of the --output switch so it specifies the 33 | desired location of the file 34 | [boolean] [default: false] 35 | --silent, -s Do not write anything to stdout 36 | [boolean] [default: false] 37 | ``` 38 | 39 | ## Releases 40 | 41 | [Changelog](https://github.com/papandreou/bringhome/blob/master/CHANGELOG.md) 42 | -------------------------------------------------------------------------------- /lib/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | require('@gustavnikolaj/async-main-wrap')(require('./main'))( 4 | process.argv.slice(2), 5 | console 6 | ); 7 | -------------------------------------------------------------------------------- /lib/main.js: -------------------------------------------------------------------------------- 1 | const AssetGraph = require('assetgraph'); 2 | const urlTools = require('urltools'); 3 | const urlModule = require('url'); 4 | const writeFileAsync = require('util').promisify(require('fs').writeFile); 5 | const uniq = require('lodash.uniq'); 6 | const yargs = require('yargs'); 7 | 8 | module.exports = async function cliTool(argv, console) { 9 | const { 10 | output, 11 | 'omit-scripts': omitScripts, 12 | recursive, 13 | pretty, 14 | 'self-contained': selfContained, 15 | silent, 16 | header: headers, 17 | _: nonOptionArgs, 18 | } = yargs(argv) 19 | .usage('$0 https://example.com/ -o localdir') 20 | .options('output', { 21 | alias: 'o', 22 | describe: 23 | 'Directory where results should be written to (or file in --self-contained mode)', 24 | type: 'string', 25 | demand: true, 26 | }) 27 | .options('header', { 28 | alias: 'H', 29 | describe: 30 | "Specify a custom header and value to pass when retrieving assets, eg. -H 'Foo: bar'. Can be repeated", 31 | type: 'string', 32 | array: true, 33 | default: [], 34 | }) 35 | .options('recursive', { 36 | alias: 'r', 37 | describe: 38 | 'Crawl all HTML-pages linked with relative and root relative links. This stays inside your domain', 39 | type: 'boolean', 40 | default: false, 41 | }) 42 | .options('pretty', { 43 | describe: 'Pretty print downloaded assets', 44 | type: 'boolean', 45 | default: false, 46 | }) 47 | .options('omit-scripts', { 48 | describe: 'Leave out JavaScript', 49 | type: 'boolean', 50 | default: false, 51 | }) 52 | .options('self-contained', { 53 | describe: 54 | 'Inline all assets, producing a single, self-contained "archive" HTML file. Alters the meaning of the --output switch so it specifies the desired location of the file', 55 | type: 'boolean', 56 | default: false, 57 | }) 58 | .options('silent', { 59 | alias: 's', 60 | describe: 'Do not write anything to stdout', 61 | type: 'boolean', 62 | default: false, 63 | }) 64 | .demand(1) 65 | .wrap(72).argv; 66 | 67 | const inputUrls = nonOptionArgs.map((arg) => 68 | /^https?:\/\//i.test(arg) ? arg : `http://${arg}` 69 | ); 70 | 71 | if (selfContained && inputUrls.length > 1) { 72 | throw new Error('--self-contained mode only supports a single input url'); 73 | } 74 | 75 | const assetGraph = new AssetGraph(); 76 | const teepeeHeaders = assetGraph.teepee.headers; 77 | for (const header of headers) { 78 | const matchKeyValue = header.match(/^([^:]*):\s?(.*)$/); 79 | if (matchKeyValue) { 80 | const [, name, value] = matchKeyValue; 81 | if (Array.isArray(teepeeHeaders[name])) { 82 | teepeeHeaders[name].push(value); 83 | } else if (teepeeHeaders[name] === undefined) { 84 | teepeeHeaders[name] = value; 85 | } else { 86 | teepeeHeaders[name] = [teepeeHeaders[name], value]; 87 | } 88 | } else { 89 | throw new Error(`Cannot parse header: ${header}`); 90 | } 91 | } 92 | 93 | // In selfContained mode this will come out as file:///path/to/index.html/ 94 | // We'll deal with that case further below 95 | const outRoot = output && urlTools.urlOrFsPathToUrl(output, true); 96 | 97 | const resourceHintTypes = [ 98 | 'HtmlPreconnectLink', 99 | 'HtmlPrefetchLink', 100 | 'HtmlPreloadLink', 101 | 'HtmlPrerenderLink', 102 | 'HtmlDnsPrefetchLink', 103 | ]; 104 | 105 | const omitTypes = []; 106 | if (omitScripts) { 107 | omitTypes.push( 108 | 'HtmlScript', 109 | 'HtmlInlineEventHandler', 110 | 'SvgScript', 111 | 'SvgInlineEventHandler', 112 | 'HtmlServiceWorkerRegistration' 113 | ); 114 | } 115 | 116 | const anchorTypes = ['HtmlAnchor', 'SvgAnchor', 'HtmlMetaRefresh']; 117 | 118 | const noFollowRelationTypes = [ 119 | ...anchorTypes, 120 | ...resourceHintTypes, 121 | ...omitTypes, 122 | 'HtmlOpenGraph', 123 | 'RssChannelLink', 124 | 'JsonUrl', 125 | ]; 126 | 127 | let followRelationsQuery; 128 | if (recursive) { 129 | followRelationsQuery = { 130 | $or: [ 131 | { 132 | type: { 133 | $nin: noFollowRelationTypes, 134 | }, 135 | }, 136 | { type: { $nin: resourceHintTypes }, crossorigin: false }, 137 | ], 138 | }; 139 | } else { 140 | noFollowRelationTypes.push('HtmlAlternateLink'); 141 | followRelationsQuery = { 142 | type: { 143 | $nin: noFollowRelationTypes, 144 | }, 145 | }; 146 | } 147 | 148 | if (silent) { 149 | // Avoid failing on assetGraph.warn 150 | // It would be better if logEvents supported a custom console implementation 151 | assetGraph.on('warn', () => {}); 152 | } else { 153 | await assetGraph.logEvents(); 154 | } 155 | await assetGraph.loadAssets(inputUrls); 156 | await assetGraph.populate({ 157 | followRelations: followRelationsQuery, 158 | }); 159 | 160 | await assetGraph.checkIncompatibleTypes(); 161 | 162 | for (const relation of assetGraph 163 | .findRelations({ type: 'HttpRedirect' }) 164 | .sort((a, b) => a.id - b.id)) { 165 | if (relation.from.isInitial) { 166 | assetGraph.warn( 167 | new Error(`${relation.from.url} redirected to ${relation.to.url}`) 168 | ); 169 | relation.to.isInitial = true; 170 | relation.from.isInitial = false; 171 | } 172 | } 173 | 174 | const origins = uniq( 175 | assetGraph 176 | .findAssets({ isInitial: true }) 177 | .map((asset) => new urlModule.URL(asset.url).origin) 178 | ); 179 | if (origins.length > 1) { 180 | throw new Error( 181 | `The pages to bring home must have the same origin, but saw multiple:\n ${origins.join( 182 | '\n ' 183 | )}` 184 | ); 185 | } 186 | const origin = origins[0]; 187 | 188 | for (const redirect of assetGraph.findRelations({ 189 | type: 'HttpRedirect', 190 | })) { 191 | for (const incomingRelation of redirect.from.incomingRelations) { 192 | incomingRelation.to = redirect.to; 193 | } 194 | assetGraph.removeAsset(redirect.from); 195 | } 196 | 197 | if (pretty) { 198 | for (const asset of assetGraph.findAssets({ isLoaded: true })) { 199 | if (asset.prettyPrint) { 200 | asset.prettyPrint(); 201 | } 202 | } 203 | } 204 | 205 | for (const relation of assetGraph.findRelations({ 206 | hrefType: { $in: ['rootRelative', 'protocolRelative', 'absolute'] }, 207 | })) { 208 | relation.hrefType = 209 | relation.type === 'JavaScriptStaticUrl' ? 'rootRelative' : 'relative'; 210 | } 211 | 212 | // Make sure that JavaScriptStaticUrl relations don't end up as relative 213 | // because fromUrl and toUrl are outside assetGraph.root: 214 | assetGraph.root = outRoot; 215 | 216 | await assetGraph.moveAssets( 217 | { isInline: false, isLoaded: true }, 218 | (asset, assetGraph) => { 219 | let baseUrl; 220 | if (asset.origin === origin) { 221 | baseUrl = outRoot; 222 | } else { 223 | baseUrl = `${outRoot}${asset.hostname}${ 224 | asset.port ? `:${asset.port}` : '' 225 | }/`; 226 | } 227 | return new urlModule.URL( 228 | `${asset.path.replace(/^\//, '')}${asset.baseName || 'index'}${ 229 | asset.extension || asset.defaultExtension 230 | }`, 231 | baseUrl 232 | ).href; 233 | } 234 | ); 235 | 236 | // Make sure no asset file names collide with implicit dirs so that 237 | // writeAssetsToDisc is safe: 238 | const reservedUrls = new Set(); 239 | for (const asset of assetGraph.findAssets({ 240 | isInline: false, 241 | isLoaded: true, 242 | })) { 243 | if (asset.url.startsWith(outRoot)) { 244 | const relative = urlTools.buildRelativeUrl(outRoot, asset.url); 245 | if (relative.includes('/')) { 246 | const fragments = relative.split('/').slice(0, -1); 247 | for (let i = 0; i < fragments.length; i += 1) { 248 | reservedUrls.add(outRoot + fragments.slice(0, i + 1).join('/')); 249 | } 250 | } 251 | } 252 | } 253 | 254 | for (const asset of assetGraph.findAssets({ 255 | url: { 256 | $in: [...reservedUrls], 257 | }, 258 | })) { 259 | let nextSuffixToTry = 1; 260 | let targetUrl; 261 | do { 262 | targetUrl = new urlModule.URL( 263 | `${asset.baseName}-${nextSuffixToTry}${ 264 | asset.extension || asset.defaultExtension 265 | }`, 266 | asset.url 267 | ).href; 268 | nextSuffixToTry += 1; 269 | } while (assetGraph._urlIndex[targetUrl]); 270 | asset.url = targetUrl; 271 | } 272 | 273 | if (omitTypes.length > 0) { 274 | for (const relation of assetGraph.findRelations({ 275 | type: { $in: omitTypes }, 276 | })) { 277 | relation.detach(); 278 | } 279 | } 280 | 281 | if (selfContained) { 282 | await assetGraph.inlineRelations({ 283 | to: { isLoaded: true }, 284 | type: { 285 | $nin: [...noFollowRelationTypes, 'SourceMapFile', 'SourceMapSource'], 286 | }, 287 | }); 288 | } 289 | 290 | // Hack: Find a better way to kill blocks', async function () { 657 | httpception([ 658 | { 659 | request: 'GET https://example.com/', 660 | response: { 661 | headers: { 662 | 'Content-Type': 'text/html; charset=utf-8', 663 | }, 664 | body: ` 665 | 666 | 667 | 668 | 669 | 670 | `, 671 | }, 672 | }, 673 | ]); 674 | 675 | await main( 676 | ['-s', '--omit-scripts', '-o', outputDir, 'https://example.com/'], 677 | mockConsole 678 | ); 679 | 680 | expect(await readdirAsync(pathModule.resolve(outputDir)), 'to equal', [ 681 | 'index.html', 682 | ]); 683 | 684 | expect( 685 | await readFileAsync( 686 | pathModule.resolve(outputDir, 'index.html'), 687 | 'utf-8' 688 | ), 689 | 'to contain', 690 | 'foobarquux' 691 | ).and('not to contain', 'noscript'); 692 | }); 693 | 694 | it('should rewrite relations found in the