Skip to content

Commit 13b4ba6

Browse files
chore(download): extract constants to JSON
Co-Authored-By: Aviv Keller <me@aviv.sh>
1 parent fd87584 commit 13b4ba6

File tree

5 files changed

+427
-336
lines changed

5 files changed

+427
-336
lines changed

apps/site/components/Downloads/Release/PrebuiltDownloadButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import type { FC } from 'react';
99
import Button from '#site/components/Common/Button';
1010
import { ReleaseContext } from '#site/providers/releaseProvider';
1111
import {
12-
OperatingSystemLabel,
1312
OS_NOT_SUPPORTING_INSTALLERS,
13+
OperatingSystemLabel,
1414
} from '#site/util/downloadUtils';
1515
import { getNodeDownloadUrl } from '#site/util/getNodeDownloadUrl';
1616

apps/site/types/userOS.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
export type UserOS = 'MAC' | 'WIN' | 'LINUX' | 'AIX' | 'OTHER';
1+
import type { OperatingSystemLabel } from '../util/downloadUtils/constants.json';
2+
import type downloadConstants from '../util/downloadUtils/constants.json';
23

3-
export type UserBitness = '64' | '32';
4+
// This infers the keys from OperatingSystemLabel as the UserOS type.
5+
export type UserOS = keyof typeof OperatingSystemLabel;
46

5-
export type UserArchitecture = 'arm' | 'x86';
7+
// Derive the union type of UserPlatform from the JSON array values.
8+
export type UserPlatform = (typeof downloadConstants.UserPlatform)[number];
69

7-
export type UserPlatform =
8-
| 'arm64'
9-
| 'armv7l'
10-
| 'ppc64le'
11-
| 'ppc64'
12-
| 's390x'
13-
| 'ppc64'
14-
| 'x64'
15-
| 'x86';
10+
// Derive the union type of UserBitness from the JSON array values.
11+
export type UserBitness = (typeof downloadConstants.UserBitness)[number];
12+
13+
// Derive the union type of UserArchitecture from the JSON array values.
14+
export type UserArchitecture =
15+
(typeof downloadConstants.UserArchitecture)[number];

apps/site/util/downloadUtils.tsx

Lines changed: 0 additions & 323 deletions
This file was deleted.

0 commit comments

Comments
 (0)