react-native-update-cli 1.40.1 → 1.41.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/api.js CHANGED
@@ -48,7 +48,7 @@ const _progress = /*#__PURE__*/ _interop_require_default(require("progress"));
48
48
  const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
49
49
  const _tcpping = /*#__PURE__*/ _interop_require_default(require("tcp-ping"));
50
50
  const _filesizeparser = /*#__PURE__*/ _interop_require_default(require("filesize-parser"));
51
- const _utils = require("./utils");
51
+ const _constants = require("./utils/constants");
52
52
  const _formdata = /*#__PURE__*/ _interop_require_default(require("form-data"));
53
53
  function _interop_require_default(obj) {
54
54
  return obj && obj.__esModule ? obj : {
@@ -58,20 +58,20 @@ function _interop_require_default(obj) {
58
58
  const tcpPing = _nodeutil.default.promisify(_tcpping.default.ping);
59
59
  let session;
60
60
  let savedSession;
61
- const defaultEndpoint = 'https://update.reactnative.cn/api';
62
- let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
61
+ const defaultEndpoint = _constants.IS_CRESC ? 'https://api.cresc.dev' : 'https://update.reactnative.cn/api';
62
+ const host = process.env.PUSHY_REGISTRY || process.env.RNU_API || defaultEndpoint;
63
63
  const userAgent = `react-native-update-cli/${_packagejson.default.version}`;
64
64
  const getSession = ()=>session;
65
65
  const replaceSession = (newSession)=>{
66
66
  session = newSession;
67
67
  };
68
68
  const loadSession = async ()=>{
69
- if (_nodefs.default.existsSync('.update')) {
69
+ if (_nodefs.default.existsSync(_constants.credentialFile)) {
70
70
  try {
71
- replaceSession(JSON.parse(_nodefs.default.readFileSync('.update', 'utf8')));
71
+ replaceSession(JSON.parse(_nodefs.default.readFileSync(_constants.credentialFile, 'utf8')));
72
72
  savedSession = session;
73
73
  } catch (e) {
74
- console.error('Failed to parse file `.update`. Try to remove it manually.');
74
+ console.error(`Failed to parse file ${_constants.credentialFile}. Try to remove it manually.`);
75
75
  throw e;
76
76
  }
77
77
  }
@@ -81,17 +81,16 @@ const saveSession = ()=>{
81
81
  if (session !== savedSession) {
82
82
  const current = session;
83
83
  const data = JSON.stringify(current, null, 4);
84
- _nodefs.default.writeFileSync('.update', data, 'utf8');
84
+ _nodefs.default.writeFileSync(_constants.credentialFile, data, 'utf8');
85
85
  savedSession = current;
86
86
  }
87
87
  };
88
88
  const closeSession = ()=>{
89
- if (_nodefs.default.existsSync('.update')) {
90
- _nodefs.default.unlinkSync('.update');
89
+ if (_nodefs.default.existsSync(_constants.credentialFile)) {
90
+ _nodefs.default.unlinkSync(_constants.credentialFile);
91
91
  savedSession = undefined;
92
92
  }
93
93
  session = undefined;
94
- host = process.env.PUSHY_REGISTRY || defaultEndpoint;
95
94
  };
96
95
  async function query(url, options) {
97
96
  const resp = await (0, _nodefetch.default)(url, options);
@@ -156,17 +155,17 @@ async function uploadFile(fn, key) {
156
155
  }
157
156
  const fileSize = _nodefs.default.statSync(fn).size;
158
157
  if (maxSize && fileSize > (0, _filesizeparser.default)(maxSize)) {
159
- throw new Error(`此文件大小 ${(fileSize / 1048576).toFixed(1)}m , 超出当前额度 ${maxSize} 。您可以考虑升级付费业务以提升此额度。详情请访问: ${_utils.pricingPageUrl}`);
158
+ throw new Error(`此文件大小 ${(fileSize / 1048576).toFixed(1)}m , 超出当前额度 ${maxSize} 。您可以考虑升级付费业务以提升此额度。详情请访问: ${_constants.pricingPageUrl}`);
160
159
  }
161
- const bar = new _progress.default(' 上传中 [:bar] :percent :etas', {
160
+ const bar = new _progress.default(' Uploading [:bar] :percent :etas', {
162
161
  complete: '=',
163
162
  incomplete: ' ',
164
163
  total: fileSize
165
164
  });
166
165
  const form = new _formdata.default();
167
- Object.entries(formData).forEach(([k, v])=>{
166
+ for (const [k, v] of Object.entries(formData)){
168
167
  form.append(k, v);
169
- });
168
+ }
170
169
  const fileStream = _nodefs.default.createReadStream(fn);
171
170
  fileStream.on('data', (data)=>{
172
171
  bar.tick(data.length);
package/lib/index.js CHANGED
@@ -7,19 +7,17 @@ const _api = require("./api");
7
7
  const _updatenotifier = /*#__PURE__*/ _interop_require_default(require("update-notifier"));
8
8
  const _utils = require("./utils");
9
9
  const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
10
- const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
11
10
  const _i18next = /*#__PURE__*/ _interop_require_default(require("i18next"));
12
11
  const _en = /*#__PURE__*/ _interop_require_default(require("./locales/en"));
13
12
  const _zh = /*#__PURE__*/ _interop_require_default(require("./locales/zh"));
13
+ const _constants = require("./utils/constants");
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
16
16
  default: obj
17
17
  };
18
18
  }
19
- const scriptName = _nodepath.default.basename(process.argv[1]);
20
- global.IS_CRESC = scriptName === 'cresc';
21
19
  _i18next.default.init({
22
- lng: global.IS_CRESC ? 'en' : 'zh',
20
+ lng: _constants.IS_CRESC ? 'en' : 'zh',
23
21
  // debug: process.env.NODE_ENV !== 'production',
24
22
  resources: {
25
23
  en: _en.default,
@@ -54,7 +52,7 @@ async function run() {
54
52
  }
55
53
  const argv = require('cli-arguments').parse(require('../cli.json'));
56
54
  global.NO_INTERACTIVE = argv.options['no-interactive'];
57
- global.USE_ACC_OSS = argv.options['acc'];
55
+ global.USE_ACC_OSS = argv.options.acc;
58
56
  (0, _api.loadSession)().then(()=>commands[argv.command](argv)).catch((err)=>{
59
57
  if (err.status === 401) {
60
58
  console.log('尚未登录。\n请在项目目录中运行`pushy login`命令来登录');
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ IS_CRESC: function() {
13
+ return IS_CRESC;
14
+ },
15
+ credentialFile: function() {
16
+ return credentialFile;
17
+ },
18
+ pricingPageUrl: function() {
19
+ return pricingPageUrl;
20
+ },
21
+ tempDir: function() {
22
+ return tempDir;
23
+ },
24
+ updateJson: function() {
25
+ return updateJson;
26
+ }
27
+ });
28
+ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
29
+ function _interop_require_default(obj) {
30
+ return obj && obj.__esModule ? obj : {
31
+ default: obj
32
+ };
33
+ }
34
+ const scriptName = _nodepath.default.basename(process.argv[1]);
35
+ const IS_CRESC = scriptName === 'cresc';
36
+ const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
37
+ const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
38
+ const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
39
+ const pricingPageUrl = IS_CRESC ? 'https://cresc.dev/pricing' : 'https://pushy.reactnative.cn/pricing.html';
@@ -24,9 +24,6 @@ _export(exports, {
24
24
  getRNVersion: function() {
25
25
  return getRNVersion;
26
26
  },
27
- pricingPageUrl: function() {
28
- return pricingPageUrl;
29
- },
30
27
  printVersionCommand: function() {
31
28
  return printVersionCommand;
32
29
  },
@@ -50,6 +47,7 @@ const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
50
47
  const _latestversion = /*#__PURE__*/ _interop_require_default(require("@badisi/latest-version"));
51
48
  const _checkplugin = require("./check-plugin");
52
49
  const _read = require("read");
50
+ const _constants = require("./constants");
53
51
  function _interop_require_default(obj) {
54
52
  return obj && obj.__esModule ? obj : {
55
53
  default: obj
@@ -177,7 +175,7 @@ async function getIpaInfo(fn) {
177
175
  ...appCredential
178
176
  };
179
177
  }
180
- const localDir = _nodepath.default.resolve(_nodeos.default.homedir(), '.pushy');
178
+ const localDir = _nodepath.default.resolve(_nodeos.default.homedir(), _constants.tempDir);
181
179
  _fsextra.default.ensureDirSync(localDir);
182
180
  function saveToLocal(originPath, destName) {
183
181
  // TODO
@@ -221,4 +219,3 @@ async function printVersionCommand() {
221
219
  }
222
220
  }
223
221
  }
224
- const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';
package/lib/versions.js CHANGED
@@ -23,7 +23,7 @@ async function showVersion(appId, offset) {
23
23
  packageInfo += `...and ${count - 3} more`;
24
24
  }
25
25
  if (count === 0) {
26
- packageInfo = `(no package)`;
26
+ packageInfo = 'no package';
27
27
  } else {
28
28
  packageInfo = `[${packageInfo}]`;
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "1.40.1",
3
+ "version": "1.41.0-beta.1",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -68,7 +68,15 @@
68
68
  "@biomejs/biome": "^1.9.4",
69
69
  "@swc/cli": "^0.5.1",
70
70
  "@swc/core": "^1.9.3",
71
+ "@types/filesize-parser": "^1.5.3",
72
+ "@types/fs-extra": "^11.0.4",
71
73
  "@types/node": "^22.9.3",
74
+ "@types/node-fetch": "^2.6.12",
75
+ "@types/progress": "^2.0.7",
76
+ "@types/semver": "^7.5.8",
77
+ "@types/tcp-ping": "^0.1.6",
78
+ "@types/update-notifier": "^6.0.8",
72
79
  "typescript": "^5.7.2"
73
- }
80
+ },
81
+ "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
74
82
  }
package/src/.DS_Store ADDED
Binary file
package/src/api.ts CHANGED
@@ -6,7 +6,7 @@ import ProgressBar from 'progress';
6
6
  import packageJson from '../package.json';
7
7
  import tcpp from 'tcp-ping';
8
8
  import filesizeParser from 'filesize-parser';
9
- import { pricingPageUrl } from './utils';
9
+ import { pricingPageUrl, credentialFile, IS_CRESC } from './utils/constants';
10
10
  import type { Session } from 'types';
11
11
  import FormData from 'form-data';
12
12
 
@@ -15,8 +15,12 @@ const tcpPing = util.promisify(tcpp.ping);
15
15
  let session: Session | undefined;
16
16
  let savedSession: Session | undefined;
17
17
 
18
- const defaultEndpoint = 'https://update.reactnative.cn/api';
19
- let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
18
+ const defaultEndpoint = IS_CRESC
19
+ ? 'https://api.cresc.dev'
20
+ : 'https://update.reactnative.cn/api';
21
+
22
+ const host =
23
+ process.env.PUSHY_REGISTRY || process.env.RNU_API || defaultEndpoint;
20
24
 
21
25
  const userAgent = `react-native-update-cli/${packageJson.version}`;
22
26
 
@@ -27,13 +31,13 @@ export const replaceSession = (newSession: { token: string }) => {
27
31
  };
28
32
 
29
33
  export const loadSession = async () => {
30
- if (fs.existsSync('.update')) {
34
+ if (fs.existsSync(credentialFile)) {
31
35
  try {
32
- replaceSession(JSON.parse(fs.readFileSync('.update', 'utf8')));
36
+ replaceSession(JSON.parse(fs.readFileSync(credentialFile, 'utf8')));
33
37
  savedSession = session;
34
38
  } catch (e) {
35
39
  console.error(
36
- 'Failed to parse file `.update`. Try to remove it manually.',
40
+ `Failed to parse file ${credentialFile}. Try to remove it manually.`,
37
41
  );
38
42
  throw e;
39
43
  }
@@ -45,18 +49,17 @@ export const saveSession = () => {
45
49
  if (session !== savedSession) {
46
50
  const current = session;
47
51
  const data = JSON.stringify(current, null, 4);
48
- fs.writeFileSync('.update', data, 'utf8');
52
+ fs.writeFileSync(credentialFile, data, 'utf8');
49
53
  savedSession = current;
50
54
  }
51
55
  };
52
56
 
53
57
  export const closeSession = () => {
54
- if (fs.existsSync('.update')) {
55
- fs.unlinkSync('.update');
58
+ if (fs.existsSync(credentialFile)) {
59
+ fs.unlinkSync(credentialFile);
56
60
  savedSession = undefined;
57
61
  }
58
62
  session = undefined;
59
- host = process.env.PUSHY_REGISTRY || defaultEndpoint;
60
63
  };
61
64
 
62
65
  async function query(url: string, options: fetch.RequestInit) {
@@ -137,7 +140,7 @@ export async function uploadFile(fn: string, key?: string) {
137
140
  );
138
141
  }
139
142
 
140
- const bar = new ProgressBar(' 上传中 [:bar] :percent :etas', {
143
+ const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
141
144
  complete: '=',
142
145
  incomplete: ' ',
143
146
  total: fileSize,
@@ -145,9 +148,9 @@ export async function uploadFile(fn: string, key?: string) {
145
148
 
146
149
  const form = new FormData();
147
150
 
148
- Object.entries(formData).forEach(([k, v]) => {
151
+ for (const [k, v] of Object.entries(formData)) {
149
152
  form.append(k, v);
150
- });
153
+ }
151
154
  const fileStream = fs.createReadStream(fn);
152
155
  fileStream.on('data', (data) => {
153
156
  bar.tick(data.length);
package/src/bundle.ts CHANGED
@@ -297,7 +297,7 @@ function getHermesOSBin() {
297
297
 
298
298
  async function checkGradleConfig() {
299
299
  let enableHermes = false;
300
- let crunchPngs;
300
+ let crunchPngs: boolean | undefined;
301
301
  try {
302
302
  const gradleConfig = await g2js.parseFile('android/app/build.gradle');
303
303
  crunchPngs = gradleConfig.android.buildTypes.release.crunchPngs;
package/src/index.ts CHANGED
@@ -4,18 +4,13 @@ import { loadSession } from './api';
4
4
  import updateNotifier from 'update-notifier';
5
5
  import { printVersionCommand } from './utils';
6
6
  import pkg from '../package.json';
7
- import path from 'node:path';
8
7
  import i18next from 'i18next';
9
8
  import en from './locales/en';
10
9
  import zh from './locales/zh';
11
-
12
- const scriptName: 'cresc' | 'pushy' = path.basename(process.argv[1]) as
13
- | 'cresc'
14
- | 'pushy';
15
- global.IS_CRESC = scriptName === 'cresc';
10
+ import { IS_CRESC } from './utils/constants';
16
11
 
17
12
  i18next.init({
18
- lng: global.IS_CRESC ? 'en' : 'zh',
13
+ lng: IS_CRESC ? 'en' : 'zh',
19
14
  // debug: process.env.NODE_ENV !== 'production',
20
15
  resources: {
21
16
  en,
@@ -57,7 +52,7 @@ async function run() {
57
52
 
58
53
  const argv = require('cli-arguments').parse(require('../cli.json'));
59
54
  global.NO_INTERACTIVE = argv.options['no-interactive'];
60
- global.USE_ACC_OSS = argv.options['acc'];
55
+ global.USE_ACC_OSS = argv.options.acc;
61
56
 
62
57
  loadSession()
63
58
  .then(() => commands[argv.command](argv))
package/src/types.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  declare global {
2
2
  var NO_INTERACTIVE: boolean;
3
3
  var USE_ACC_OSS: boolean;
4
- var IS_CRESC: boolean;
5
4
  }
6
5
 
7
6
  export interface Session {
Binary file
@@ -0,0 +1,13 @@
1
+ import path from 'node:path';
2
+
3
+ const scriptName: 'cresc' | 'pushy' = path.basename(process.argv[1]) as
4
+ | 'cresc'
5
+ | 'pushy';
6
+ export const IS_CRESC = scriptName === 'cresc';
7
+
8
+ export const credentialFile = IS_CRESC ? '.cresc.token' : '.update';
9
+ export const updateJson = IS_CRESC ? 'cresc.config.json' : 'update.json';
10
+ export const tempDir = IS_CRESC ? '.cresc.temp' : '.pushy';
11
+ export const pricingPageUrl = IS_CRESC
12
+ ? 'https://cresc.dev/pricing'
13
+ : 'https://pushy.reactnative.cn/pricing.html';
@@ -9,8 +9,9 @@ import latestVersion from '@badisi/latest-version';
9
9
  import { checkPlugins } from './check-plugin';
10
10
 
11
11
  import { read } from 'read';
12
+ import { tempDir } from './constants';
12
13
 
13
- export async function question(query, password) {
14
+ export async function question(query: string, password?: boolean) {
14
15
  if (NO_INTERACTIVE) {
15
16
  return '';
16
17
  }
@@ -21,7 +22,7 @@ export async function question(query, password) {
21
22
  });
22
23
  }
23
24
 
24
- export function translateOptions(options) {
25
+ export function translateOptions(options: Record<string, string>) {
25
26
  const ret = {};
26
27
  for (const key in options) {
27
28
  const v = options[key];
@@ -163,16 +164,16 @@ export async function getIpaInfo(fn: string) {
163
164
  return { versionName, buildTime, ...appCredential };
164
165
  }
165
166
 
166
- const localDir = path.resolve(os.homedir(), '.pushy');
167
+ const localDir = path.resolve(os.homedir(), tempDir);
167
168
  fs.ensureDirSync(localDir);
168
- export function saveToLocal(originPath, destName) {
169
+ export function saveToLocal(originPath: string, destName: string) {
169
170
  // TODO
170
171
  // const destPath = path.join(localDir, destName);
171
172
  // fs.ensureDirSync(path.dirname(destPath));
172
173
  // fs.copyFileSync(originPath, destPath);
173
174
  }
174
175
 
175
- async function getLatestVersion(pkgName) {
176
+ async function getLatestVersion(pkgName: string) {
176
177
  return Promise.race([
177
178
  latestVersion(pkgName)
178
179
  .then((p) => p.latest)
@@ -225,6 +226,6 @@ export async function printVersionCommand() {
225
226
  }
226
227
  }
227
228
 
228
- export const pricingPageUrl = 'https://pushy.reactnative.cn/pricing.html';
229
+
229
230
 
230
231
  export { checkPlugins };
@@ -5,7 +5,7 @@ import { checkPlatform, getSelectedApp } from './app';
5
5
  import { choosePackage } from './package';
6
6
  import { compare } from 'compare-versions';
7
7
 
8
- async function showVersion(appId, offset) {
8
+ async function showVersion(appId: string, offset: number) {
9
9
  const { data, count } = await get(`/app/${appId}/version/list`);
10
10
  console.log(`Offset ${offset}`);
11
11
  for (const version of data) {
@@ -18,7 +18,7 @@ async function showVersion(appId, offset) {
18
18
  packageInfo += `...and ${count - 3} more`;
19
19
  }
20
20
  if (count === 0) {
21
- packageInfo = `(no package)`;
21
+ packageInfo = 'no package';
22
22
  } else {
23
23
  packageInfo = `[${packageInfo}]`;
24
24
  }