Skip to content

Commit

Permalink
Merge pull request #22 from ma4nn/dependabot/npm_and_yarn/replace-in-…
Browse files Browse the repository at this point in the history
…file-8.0.1

Bump replace-in-file from 7.2.0 to 8.0.1
  • Loading branch information
ma4nn authored Jun 25, 2024
2 parents 125f279 + 47cca81 commit 796cb33
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 92 deletions.
16 changes: 9 additions & 7 deletions build.js → build.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const replace = require('replace-in-file');
const crypto = require('crypto');
const pkg = require('./package.json');
const pkgLock = require('./package-lock.json');
import {replaceInFile} from 'replace-in-file'
import crypto from 'crypto';
import { readFile } from 'fs/promises';

simplifyVersion = version => version.replace(/^[=<>~^]/g, '');
majorMinorVersion = version => version.split('.').slice(0, -1).join('.');
const pkg = JSON.parse(await readFile(new URL('./package.json', import.meta.url)));
const pkgLock = JSON.parse(await readFile(new URL('./package-lock.json', import.meta.url)));

const simplifyVersion = version => version.replace(/^[=<>~^]/g, '');
const majorMinorVersion = version => version.split('.').slice(0, -1).join('.');

const urls = {
'bootstrap_js': 'https://cdn.jsdelivr.net/npm/bootstrap@' + simplifyVersion(pkgLock.packages["node_modules/bootstrap"].version) + '/dist/js/bootstrap.bundle.min.js',
Expand Down Expand Up @@ -41,6 +43,6 @@ async function calculateSris(urls) {
to: [majorMinorVersion(process.env.npm_package_version), process.env.INLINE_CSS, process.env.INLINE_JS, ...Object.values(urls), ...sris],
countMatches: true,
};
})().then(options => replace(options)
})().then(options => replaceInFile(options)
.then(results => results.every(result => (! result.hasChanged || result.numReplacements !== options.from.length) && (() => { throw new Error('error during build: no replacements done in file ' + result.file) })()))
);
139 changes: 56 additions & 83 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "moneymoney-sankey",
"description": "An extension for the great MoneyMoney app to export an interactive HTML Sankey Chart based on the transaction categories",
"version": "1.2.0",
"private": true,
"dependencies": {
"bootstrap": "^5.3.2",
"highcharts": "^11.4.3"
Expand All @@ -10,7 +11,7 @@
"clean-css-cli": "^5.6.3",
"html-validate": "^8.20.1",
"npm-run-all": "^4.1.5",
"replace-in-file": "^7.2.0",
"replace-in-file": "^8.0.1",
"terser": "^5.31.1",
"typescript": "^5.5.2"
},
Expand All @@ -19,7 +20,7 @@
"scripts": {
"build:css": "cleancss src/*.css",
"build:js": "tsc && terser --compress --mangle -- $npm_package_config_outputDir/*.js",
"build": "mkdir -p $npm_package_config_outputDir && cp src/SankeyChart.lua $npm_package_config_outputDir && INLINE_CSS=`npm run build:css --silent` INLINE_JS=`npm run build:js --silent` node ./build.js",
"build": "mkdir -p $npm_package_config_outputDir && cp src/SankeyChart.lua $npm_package_config_outputDir && INLINE_CSS=`npm run build:css --silent` INLINE_JS=`npm run build:js --silent` node ./build.mjs",
"test": "npm-run-all test:*",
"test:compile-validate": "lua ./src/SankeyChartTest.lua | html-validate --stdin",
"test:placeholder": "grep -qE '{{ ([a-zA-Z_]+) }}' $npm_package_config_outputDir/*.lua && (echo 'error: placeholders have not been replaced in dist!' && exit 1) || exit 0"
Expand Down

0 comments on commit 796cb33

Please sign in to comment.