1
0
mirror of https://gitcode.com/github-mirrors/react-native-update-cli.git synced 2025-12-17 10:52:34 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Refactor project configuration and dependencies

- Move IS_CRESC logic to constants module
- Update package.json with new type definitions
- Simplify global variable usage
- Update bun.lock with latest package versions
- Improve type safety and configuration management
This commit is contained in:
sunnylqm
2025-02-19 22:53:24 +08:00
parent 04b5d12daa
commit 4e51f291ca
7 changed files with 71 additions and 35 deletions

View File

@@ -6,7 +6,7 @@ import ProgressBar from 'progress';
import packageJson from '../package.json';
import tcpp from 'tcp-ping';
import filesizeParser from 'filesize-parser';
import { pricingPageUrl, credentialFile } from './utils/constants';
import { pricingPageUrl, credentialFile, IS_CRESC } from './utils/constants';
import type { Session } from 'types';
import FormData from 'form-data';
@@ -15,10 +15,12 @@ const tcpPing = util.promisify(tcpp.ping);
let session: Session | undefined;
let savedSession: Session | undefined;
const defaultEndpoint = global.IS_CRESC
const defaultEndpoint = IS_CRESC
? 'https://api.cresc.dev'
: 'https://update.reactnative.cn/api';
let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
const host =
process.env.PUSHY_REGISTRY || process.env.RNU_API || defaultEndpoint;
const userAgent = `react-native-update-cli/${packageJson.version}`;
@@ -28,8 +30,6 @@ export const replaceSession = (newSession: { token: string }) => {
session = newSession;
};
export const loadSession = async () => {
if (fs.existsSync(credentialFile)) {
try {
@@ -60,7 +60,6 @@ export const closeSession = () => {
savedSession = undefined;
}
session = undefined;
host = process.env.PUSHY_REGISTRY || defaultEndpoint;
};
async function query(url: string, options: fetch.RequestInit) {