mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-12-17 10:52:34 +08:00
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:
11
src/api.ts
11
src/api.ts
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user