fix(build): generate Suwayomi WebUI revision
This commit is contained in:
22
src/features/theme/services/MaterialYouRevision.test.ts
Normal file
22
src/features/theme/services/MaterialYouRevision.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { formatWebUIRevision } from '@/features/theme/services/MaterialYouRevision.ts';
|
||||
|
||||
describe('formatWebUIRevision', () => {
|
||||
it('matches the revision format required by Suwayomi custom WebUI builds', () => {
|
||||
assert.equal(formatWebUIRevision(3356), 'r3356\n');
|
||||
});
|
||||
|
||||
it('rejects invalid git commit counts', () => {
|
||||
assert.throws(() => formatWebUIRevision(0), /positive integer/);
|
||||
assert.throws(() => formatWebUIRevision(4.5), /positive integer/);
|
||||
});
|
||||
});
|
||||
15
src/features/theme/services/MaterialYouRevision.ts
Normal file
15
src/features/theme/services/MaterialYouRevision.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
export const formatWebUIRevision = (commitCount: number): string => {
|
||||
if (!Number.isInteger(commitCount) || commitCount < 1) {
|
||||
throw new Error('WebUI revision commit count must be a positive integer');
|
||||
}
|
||||
|
||||
return `r${commitCount}\n`;
|
||||
};
|
||||
Reference in New Issue
Block a user