Skip to content

Commit b81dae8

Browse files
committed
chore: Remove replace-in-file
1 parent f91b133 commit b81dae8

File tree

3 files changed

+35
-75
lines changed

3 files changed

+35
-75
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
"nodemon": "^2.0.16",
122122
"npm-run-all": "^4.1.5",
123123
"prettier": "^3.1.1",
124-
"replace-in-file": "^4.0.0",
125124
"rimraf": "^3.0.2",
126125
"rollup": "^4.13.0",
127126
"rollup-plugin-cleanup": "^3.2.1",

scripts/versionbump.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
const replace = require('replace-in-file');
1+
const { readFile, writeFile } = require('node:fs').promises;
22
const pjson = require(`${process.cwd()}/package.json`);
33

4-
const files = process.argv.slice(2);
5-
if (files.length === 0) {
6-
console.error('Please provide files to bump');
7-
process.exit(1);
8-
}
4+
const REPLACE_REGEX = /\d+\.\d+.\d+(?:-\w+(?:\.\w+)?)?/g;
5+
6+
async function run() {
7+
const files = process.argv.slice(2);
8+
if (files.length === 0) {
9+
// eslint-disable-next-line no-console
10+
console.error('[versionbump] Please provide files to bump');
11+
process.exit(1);
12+
}
913

10-
replace({
11-
files: files,
12-
from: /\d+\.\d+.\d+(?:-\w+(?:\.\w+)?)?/g,
13-
to: pjson.version,
14-
})
15-
.then(changedFiles => {
16-
console.log('Modified files:', changedFiles.join(', '));
17-
})
18-
.catch(error => {
19-
console.error('Error occurred:', error);
14+
try {
15+
await Promise.all(
16+
files.map(async file => {
17+
const data = String(await readFile(file, 'utf8'));
18+
await writeFile(file, data.replace(REPLACE_REGEX, pjson.version));
19+
}),
20+
);
21+
22+
// eslint-disable-next-line no-console
23+
console.log(`[versionbump] Bumped version for ${files.join(', ')}`);
24+
} catch (error) {
25+
// eslint-disable-next-line no-console
26+
console.error('[versionbump] Error occurred:', error);
2027
process.exit(1);
21-
});
28+
}
29+
}
30+
31+
run();

yarn.lock

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9450,6 +9450,7 @@
94509450
"@types/unist" "*"
94519451

94529452
"@types/history-4@npm:@types/[email protected]", "@types/history-5@npm:@types/[email protected]", "@types/history@*":
9453+
name "@types/history-4"
94539454
version "4.7.8"
94549455
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.8.tgz#49348387983075705fe8f4e02fb67f7daaec4934"
94559456
integrity sha512-S78QIYirQcUoo6UJZx9CSP0O2ix9IaeAXwQi26Rhr/+mg7qqPy8TzaxHSUut7eGjL8WmLccT7/MXf304WjqHcA==
@@ -13868,7 +13869,7 @@ [email protected]:
1386813869
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42"
1386913870
integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==
1387013871

13871-
camelcase@^5.0.0, camelcase@^5.3.1:
13872+
camelcase@^5.3.1:
1387213873
version "5.3.1"
1387313874
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
1387413875
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
@@ -14291,15 +14292,6 @@ clipboardy@^4.0.0:
1429114292
is-wsl "^3.1.0"
1429214293
is64bit "^2.0.0"
1429314294

14294-
cliui@^6.0.0:
14295-
version "6.0.0"
14296-
resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
14297-
integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
14298-
dependencies:
14299-
string-width "^4.2.0"
14300-
strip-ansi "^6.0.0"
14301-
wrap-ansi "^6.2.0"
14302-
1430314295
cliui@^7.0.2:
1430414296
version "7.0.4"
1430514297
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
@@ -15468,7 +15460,7 @@ decamelize-keys@^1.1.0:
1546815460
decamelize "^1.1.0"
1546915461
map-obj "^1.0.0"
1547015462

15471-
decamelize@^1.1.0, decamelize@^1.2.0:
15463+
decamelize@^1.1.0:
1547215464
version "1.2.0"
1547315465
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
1547415466
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
@@ -19243,7 +19235,7 @@ get-amd-module-type@^5.0.1:
1924319235
ast-module-types "^5.0.0"
1924419236
node-source-walk "^6.0.1"
1924519237

19246-
get-caller-file@^2.0.1, get-caller-file@^2.0.5:
19238+
get-caller-file@^2.0.5:
1924719239
version "2.0.5"
1924819240
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
1924919241
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
@@ -28943,6 +28935,7 @@ react-is@^18.0.0:
2894328935
"@remix-run/router" "1.0.2"
2894428936

2894528937
"react-router-6@npm:[email protected]", [email protected]:
28938+
name react-router-6
2894628939
version "6.3.0"
2894728940
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.3.0.tgz#3970cc64b4cb4eae0c1ea5203a80334fdd175557"
2894828941
integrity sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==
@@ -29534,15 +29527,6 @@ repeat-string@^1.6.1:
2953429527
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
2953529528
integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=
2953629529

29537-
replace-in-file@^4.0.0:
29538-
version "4.3.1"
29539-
resolved "https://registry.yarnpkg.com/replace-in-file/-/replace-in-file-4.3.1.tgz#c67c92178b38052008e379197cc0d86ca927f7b0"
29540-
integrity sha512-FqVvfmpqGTD2JRGI1JjJ86b24P17x/WWwGdxExeyJxnh/2rVQz2+jXfD1507UnnhEQw092X0u0DPCBf1WC4ooQ==
29541-
dependencies:
29542-
chalk "^2.4.2"
29543-
glob "^7.1.6"
29544-
yargs "^15.0.2"
29545-
2954629530
require-at@^1.0.6:
2954729531
version "1.0.6"
2954829532
resolved "https://registry.yarnpkg.com/require-at/-/require-at-1.0.6.tgz#9eb7e3c5e00727f5a4744070a7f560d4de4f6e6a"
@@ -29567,11 +29551,6 @@ require-in-the-middle@^7.1.1:
2956729551
module-details-from-path "^1.0.3"
2956829552
resolve "^1.22.1"
2956929553

29570-
require-main-filename@^2.0.0:
29571-
version "2.0.0"
29572-
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
29573-
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
29574-
2957529554
requireindex@^1.2.0:
2957629555
version "1.2.0"
2957729556
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef"
@@ -31467,6 +31446,7 @@ string-template@~0.2.1:
3146731446
integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=
3146831447

3146931448
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
31449+
name string-width-cjs
3147031450
version "4.2.3"
3147131451
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
3147231452
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -34507,11 +34487,6 @@ which-collection@^1.0.1:
3450734487
is-weakmap "^2.0.2"
3450834488
is-weakset "^2.0.3"
3450934489

34510-
which-module@^2.0.0:
34511-
version "2.0.0"
34512-
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
34513-
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
34514-
3451534490
which-pm-runs@^1.1.0:
3451634491
version "1.1.0"
3451734492
resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.1.0.tgz#35ccf7b1a0fce87bd8b92a478c9d045785d3bf35"
@@ -34692,6 +34667,7 @@ workerpool@^6.4.0:
3469234667
integrity sha512-i3KR1mQMNwY2wx20ozq2EjISGtQWDIfV56We+yGJ5yDs8jTwQiLLaqHlkBHITlCuJnYlVRmXegxFxZg7gqI++A==
3469334668

3469434669
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
34670+
name wrap-ansi-cjs
3469534671
version "7.0.0"
3469634672
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
3469734673
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -34700,7 +34676,7 @@ workerpool@^6.4.0:
3470034676
string-width "^4.1.0"
3470134677
strip-ansi "^6.0.0"
3470234678

34703-
wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
34679+
wrap-ansi@^6.0.1:
3470434680
version "6.2.0"
3470534681
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
3470634682
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
@@ -34913,14 +34889,6 @@ [email protected], yargs-parser@^21.0.0, yargs-parser@^21.1.1:
3491334889
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
3491434890
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
3491534891

34916-
yargs-parser@^18.1.2:
34917-
version "18.1.3"
34918-
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
34919-
integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
34920-
dependencies:
34921-
camelcase "^5.0.0"
34922-
decamelize "^1.2.0"
34923-
3492434892
[email protected], yargs@^16.1.1, yargs@^16.2.0:
3492534893
version "16.2.0"
3492634894
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
@@ -34947,23 +34915,6 @@ [email protected]:
3494734915
y18n "^5.0.5"
3494834916
yargs-parser "^21.0.0"
3494934917

34950-
yargs@^15.0.2:
34951-
version "15.4.1"
34952-
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
34953-
integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
34954-
dependencies:
34955-
cliui "^6.0.0"
34956-
decamelize "^1.2.0"
34957-
find-up "^4.1.0"
34958-
get-caller-file "^2.0.1"
34959-
require-directory "^2.1.1"
34960-
require-main-filename "^2.0.0"
34961-
set-blocking "^2.0.0"
34962-
string-width "^4.2.0"
34963-
which-module "^2.0.0"
34964-
y18n "^4.0.0"
34965-
yargs-parser "^18.1.2"
34966-
3496734918
yargs@^17.2.1:
3496834919
version "17.7.2"
3496934920
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"

0 commit comments

Comments
 (0)