From d0524f6180ca90c40561c79c9f910d815c723973 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 15:57:22 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=A7=AA=20test:=20add=20coverage=20for?= =?UTF-8?q?=20constants=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- tests/constants.test.ts | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/constants.test.ts diff --git a/tests/constants.test.ts b/tests/constants.test.ts new file mode 100644 index 0000000..2bf7f17 --- /dev/null +++ b/tests/constants.test.ts @@ -0,0 +1,42 @@ +import { describe, expect, it } from 'bun:test'; + +const loadConstantsWithArgv = async (argv1: string) => { + const originalArgv = process.argv; + process.argv = ['node', argv1]; + const url = `../src/utils/constants.ts?t=${Date.now()}_${Math.random()}`; + const mod = await import(url); + process.argv = originalArgv; + return mod; +}; + +describe('constants', () => { + it('should initialize correctly when script is cresc', async () => { + const mod = await loadConstantsWithArgv('/usr/local/bin/cresc'); + expect(mod.scriptName).toBe('cresc'); + expect(mod.IS_CRESC).toBe(true); + expect(mod.credentialFile).toBe('.cresc.token'); + expect(mod.updateJson).toBe('cresc.config.json'); + expect(mod.tempDir).toBe('.cresc.temp'); + expect(mod.pricingPageUrl).toBe('https://cresc.dev/pricing'); + expect(mod.defaultEndpoints).toEqual(['https://api.cresc.dev', 'https://api.cresc.app']); + }); + + it('should initialize correctly when script is pushy', async () => { + const mod = await loadConstantsWithArgv('/usr/local/bin/pushy'); + expect(mod.scriptName).toBe('pushy'); + expect(mod.IS_CRESC).toBe(false); + expect(mod.credentialFile).toBe('.update'); + expect(mod.updateJson).toBe('update.json'); + expect(mod.tempDir).toBe('.pushy'); + expect(mod.pricingPageUrl).toBe('https://pushy.reactnative.cn/pricing.html'); + expect(mod.defaultEndpoints).toEqual(['https://update.reactnative.cn/api', 'https://update.react-native.cn/api']); + }); + + it('should identify PPK bundle file names correctly', async () => { + const { isPPKBundleFileName } = await import('../src/utils/constants.ts'); + expect(isPPKBundleFileName('index.bundlejs')).toBe(true); + expect(isPPKBundleFileName('bundle.harmony.js')).toBe(true); + expect(isPPKBundleFileName('index.js')).toBe(false); + expect(isPPKBundleFileName('main.bundlejs')).toBe(false); + }); +}); From 56ed8627390be60ab6b2a8ceb7acc4f7a64361e3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 15:59:01 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A7=AA=20test:=20add=20coverage=20for?= =?UTF-8?q?=20constants=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- tests/constants.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/constants.test.ts b/tests/constants.test.ts index 2bf7f17..fcaefed 100644 --- a/tests/constants.test.ts +++ b/tests/constants.test.ts @@ -18,7 +18,10 @@ describe('constants', () => { expect(mod.updateJson).toBe('cresc.config.json'); expect(mod.tempDir).toBe('.cresc.temp'); expect(mod.pricingPageUrl).toBe('https://cresc.dev/pricing'); - expect(mod.defaultEndpoints).toEqual(['https://api.cresc.dev', 'https://api.cresc.app']); + expect(mod.defaultEndpoints).toEqual([ + 'https://api.cresc.dev', + 'https://api.cresc.app', + ]); }); it('should initialize correctly when script is pushy', async () => { @@ -28,8 +31,13 @@ describe('constants', () => { expect(mod.credentialFile).toBe('.update'); expect(mod.updateJson).toBe('update.json'); expect(mod.tempDir).toBe('.pushy'); - expect(mod.pricingPageUrl).toBe('https://pushy.reactnative.cn/pricing.html'); - expect(mod.defaultEndpoints).toEqual(['https://update.reactnative.cn/api', 'https://update.react-native.cn/api']); + expect(mod.pricingPageUrl).toBe( + 'https://pushy.reactnative.cn/pricing.html', + ); + expect(mod.defaultEndpoints).toEqual([ + 'https://update.reactnative.cn/api', + 'https://update.react-native.cn/api', + ]); }); it('should identify PPK bundle file names correctly', async () => { From 988a7487d9f5e33d65b007c03310c80bd043f245 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Mon, 18 May 2026 08:01:08 +0000 Subject: [PATCH 3/4] fix: apply CodeRabbit auto-fixes Fixed 2 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit --- package.json | 4 ++-- tests/constants.test.ts | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 11e09e0..119dea8 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "cli.json" ], "scripts": { - "build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build && chmod +x lib/bin.js", - "prepublishOnly": "bun run build", + "build": "rm -rf lib && swc src -d lib --strip-leading-paths && npm run typecheck:build && chmod +x lib/bin.js", + "prepublishOnly": "npm run build", "typecheck": "tsc --noEmit", "typecheck:build": "tsc -p tsconfig.build.json", "lint": "bun run typecheck && biome check .", diff --git a/tests/constants.test.ts b/tests/constants.test.ts index fcaefed..78272d3 100644 --- a/tests/constants.test.ts +++ b/tests/constants.test.ts @@ -3,10 +3,13 @@ import { describe, expect, it } from 'bun:test'; const loadConstantsWithArgv = async (argv1: string) => { const originalArgv = process.argv; process.argv = ['node', argv1]; - const url = `../src/utils/constants.ts?t=${Date.now()}_${Math.random()}`; - const mod = await import(url); - process.argv = originalArgv; - return mod; + try { + const url = `../src/utils/constants.ts?t=${Date.now()}_${Math.random()}`; + const mod = await import(url); + return mod; + } finally { + process.argv = originalArgv; + } }; describe('constants', () => { From 2a62660f0f8d30b199e29e4dda80b875c6ba3393 Mon Sep 17 00:00:00 2001 From: Sunny Luo Date: Mon, 18 May 2026 16:05:05 +0800 Subject: [PATCH 4/4] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 119dea8..11e09e0 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "cli.json" ], "scripts": { - "build": "rm -rf lib && swc src -d lib --strip-leading-paths && npm run typecheck:build && chmod +x lib/bin.js", - "prepublishOnly": "npm run build", + "build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build && chmod +x lib/bin.js", + "prepublishOnly": "bun run build", "typecheck": "tsc --noEmit", "typecheck:build": "tsc -p tsconfig.build.json", "lint": "bun run typecheck && biome check .",