Skip to content

Commit 6ac5bd9

Browse files
committed
fix(release): accept CRLF query-string patch
1 parent 2e95e50 commit 6ac5bd9

8 files changed

Lines changed: 13 additions & 4 deletions

File tree

apps/mobile/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"backgroundImage": "./assets/images/android-icon-background.png",
5454
"monochromeImage": "./assets/images/android-icon-monochrome.png"
5555
},
56-
"versionCode": 132,
56+
"versionCode": 134,
5757
"package": "tech.dongdongbh.mindwtr",
5858
"permissions": [
5959
"RECORD_AUDIO",

apps/mobile/scripts/patch_query_string_cjs.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const COMPATIBLE_IMPORT = [
1313
'const decodeComponent = decodeComponentModule.default ?? decodeComponentModule;',
1414
].join('\n');
1515

16+
const hasCompatibleImport = (source) =>
17+
source.replaceAll('\r\n', '\n').includes(COMPATIBLE_IMPORT);
18+
1619
const readPackageMetadata = (packageDirectory) =>
1720
JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json'), 'utf8'));
1821

@@ -44,7 +47,7 @@ const patchQueryString = (mobileDirectory = path.resolve(__dirname, '..')) => {
4447

4548
const queryStringEntrypoint = path.join(queryStringDirectory, 'index.js');
4649
const source = fs.readFileSync(queryStringEntrypoint, 'utf8');
47-
if (!source.includes(COMPATIBLE_IMPORT)) {
50+
if (!hasCompatibleImport(source)) {
4851
const occurrences = source.split(ORIGINAL_IMPORT).length - 1;
4952
if (occurrences !== 1) {
5053
throw new Error(
@@ -69,4 +72,4 @@ if (require.main === module) {
6972
patchQueryString();
7073
}
7174

72-
module.exports = { patchQueryString };
75+
module.exports = { hasCompatibleImport, patchQueryString };

scripts/ci/validate-dependency-audit.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,15 @@ test("mobile query parsing keeps a patched CommonJS-compatible resolution", () =
103103
'["query-string@9.3.1"',
104104
]));
105105

106-
const { patchQueryString } = rootRequire(
106+
const { hasCompatibleImport, patchQueryString } = rootRequire(
107107
"../../apps/mobile/scripts/patch_query_string_cjs.js",
108108
);
109+
const compatibleImport = [
110+
"const decodeComponentModule = require('decode-uri-component');",
111+
"const decodeComponent = decodeComponentModule.default ?? decodeComponentModule;",
112+
];
113+
expect(hasCompatibleImport(compatibleImport.join("\n"))).toBe(true);
114+
expect(hasCompatibleImport(compatibleImport.join("\r\n"))).toBe(true);
109115
expect(() => patchQueryString()).not.toThrow();
110116

111117
const navigationRequire = createRequire(

0 commit comments

Comments
 (0)