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

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,8 +48,9 @@ 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
+ const _constants1 = require("utils/constants");
53
54
  function _interop_require_default(obj) {
54
55
  return obj && obj.__esModule ? obj : {
55
56
  default: obj
@@ -58,7 +59,7 @@ function _interop_require_default(obj) {
58
59
  const tcpPing = _nodeutil.default.promisify(_tcpping.default.ping);
59
60
  let session;
60
61
  let savedSession;
61
- const defaultEndpoint = 'https://update.reactnative.cn/api';
62
+ const defaultEndpoint = global.IS_CRESC ? 'https://api.cresc.dev' : 'https://update.reactnative.cn/api';
62
63
  let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
63
64
  const userAgent = `react-native-update-cli/${_packagejson.default.version}`;
64
65
  const getSession = ()=>session;
@@ -66,12 +67,12 @@ const replaceSession = (newSession)=>{
66
67
  session = newSession;
67
68
  };
68
69
  const loadSession = async ()=>{
69
- if (_nodefs.default.existsSync('.update')) {
70
+ if (_nodefs.default.existsSync(_constants1.credentialFile)) {
70
71
  try {
71
- replaceSession(JSON.parse(_nodefs.default.readFileSync('.update', 'utf8')));
72
+ replaceSession(JSON.parse(_nodefs.default.readFileSync(_constants1.credentialFile, 'utf8')));
72
73
  savedSession = session;
73
74
  } catch (e) {
74
- console.error('Failed to parse file `.update`. Try to remove it manually.');
75
+ console.error(`Failed to parse file ${_constants1.credentialFile}. Try to remove it manually.`);
75
76
  throw e;
76
77
  }
77
78
  }
@@ -81,13 +82,13 @@ const saveSession = ()=>{
81
82
  if (session !== savedSession) {
82
83
  const current = session;
83
84
  const data = JSON.stringify(current, null, 4);
84
- _nodefs.default.writeFileSync('.update', data, 'utf8');
85
+ _nodefs.default.writeFileSync(_constants1.credentialFile, data, 'utf8');
85
86
  savedSession = current;
86
87
  }
87
88
  };
88
89
  const closeSession = ()=>{
89
- if (_nodefs.default.existsSync('.update')) {
90
- _nodefs.default.unlinkSync('.update');
90
+ if (_nodefs.default.existsSync(_constants1.credentialFile)) {
91
+ _nodefs.default.unlinkSync(_constants1.credentialFile);
91
92
  savedSession = undefined;
92
93
  }
93
94
  session = undefined;
@@ -156,17 +157,17 @@ async function uploadFile(fn, key) {
156
157
  }
157
158
  const fileSize = _nodefs.default.statSync(fn).size;
158
159
  if (maxSize && fileSize > (0, _filesizeparser.default)(maxSize)) {
159
- throw new Error(`此文件大小 ${(fileSize / 1048576).toFixed(1)}m , 超出当前额度 ${maxSize} 。您可以考虑升级付费业务以提升此额度。详情请访问: ${_utils.pricingPageUrl}`);
160
+ throw new Error(`此文件大小 ${(fileSize / 1048576).toFixed(1)}m , 超出当前额度 ${maxSize} 。您可以考虑升级付费业务以提升此额度。详情请访问: ${_constants.pricingPageUrl}`);
160
161
  }
161
- const bar = new _progress.default(' 上传中 [:bar] :percent :etas', {
162
+ const bar = new _progress.default(' Uploading [:bar] :percent :etas', {
162
163
  complete: '=',
163
164
  incomplete: ' ',
164
165
  total: fileSize
165
166
  });
166
167
  const form = new _formdata.default();
167
- Object.entries(formData).forEach(([k, v])=>{
168
+ for (const [k, v] of Object.entries(formData)){
168
169
  form.append(k, v);
169
- });
170
+ }
170
171
  const fileStream = _nodefs.default.createReadStream(fn);
171
172
  fileStream.on('data', (data)=>{
172
173
  bar.tick(data.length);
@@ -0,0 +1,28 @@
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
+ credentialFile: function() {
13
+ return credentialFile;
14
+ },
15
+ pricingPageUrl: function() {
16
+ return pricingPageUrl;
17
+ },
18
+ tempDir: function() {
19
+ return tempDir;
20
+ },
21
+ updateJson: function() {
22
+ return updateJson;
23
+ }
24
+ });
25
+ const credentialFile = global.IS_CRESC ? '.cresc.token' : '.update';
26
+ const updateJson = global.IS_CRESC ? 'cresc.config.json' : 'update.json';
27
+ const tempDir = global.IS_CRESC ? '.cresc.temp' : '.pushy';
28
+ const pricingPageUrl = global.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/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.0",
4
4
  "description": "Command tools for javaScript updater with `pushy` service for react native apps.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -70,5 +70,6 @@
70
70
  "@swc/core": "^1.9.3",
71
71
  "@types/node": "^22.9.3",
72
72
  "typescript": "^5.7.2"
73
- }
73
+ },
74
+ "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
74
75
  }
package/src/.DS_Store ADDED
Binary file
package/src/api.ts CHANGED
@@ -6,16 +6,19 @@ 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 } from './utils/constants';
10
10
  import type { Session } from 'types';
11
11
  import FormData from 'form-data';
12
+ import { credentialFile } from 'utils/constants';
12
13
 
13
14
  const tcpPing = util.promisify(tcpp.ping);
14
15
 
15
16
  let session: Session | undefined;
16
17
  let savedSession: Session | undefined;
17
18
 
18
- const defaultEndpoint = 'https://update.reactnative.cn/api';
19
+ const defaultEndpoint = global.IS_CRESC
20
+ ? 'https://api.cresc.dev'
21
+ : 'https://update.reactnative.cn/api';
19
22
  let host = process.env.PUSHY_REGISTRY || defaultEndpoint;
20
23
 
21
24
  const userAgent = `react-native-update-cli/${packageJson.version}`;
@@ -26,14 +29,16 @@ export const replaceSession = (newSession: { token: string }) => {
26
29
  session = newSession;
27
30
  };
28
31
 
32
+
33
+
29
34
  export const loadSession = async () => {
30
- if (fs.existsSync('.update')) {
35
+ if (fs.existsSync(credentialFile)) {
31
36
  try {
32
- replaceSession(JSON.parse(fs.readFileSync('.update', 'utf8')));
37
+ replaceSession(JSON.parse(fs.readFileSync(credentialFile, 'utf8')));
33
38
  savedSession = session;
34
39
  } catch (e) {
35
40
  console.error(
36
- 'Failed to parse file `.update`. Try to remove it manually.',
41
+ `Failed to parse file ${credentialFile}. Try to remove it manually.`,
37
42
  );
38
43
  throw e;
39
44
  }
@@ -45,14 +50,14 @@ export const saveSession = () => {
45
50
  if (session !== savedSession) {
46
51
  const current = session;
47
52
  const data = JSON.stringify(current, null, 4);
48
- fs.writeFileSync('.update', data, 'utf8');
53
+ fs.writeFileSync(credentialFile, data, 'utf8');
49
54
  savedSession = current;
50
55
  }
51
56
  };
52
57
 
53
58
  export const closeSession = () => {
54
- if (fs.existsSync('.update')) {
55
- fs.unlinkSync('.update');
59
+ if (fs.existsSync(credentialFile)) {
60
+ fs.unlinkSync(credentialFile);
56
61
  savedSession = undefined;
57
62
  }
58
63
  session = undefined;
@@ -137,7 +142,7 @@ export async function uploadFile(fn: string, key?: string) {
137
142
  );
138
143
  }
139
144
 
140
- const bar = new ProgressBar(' 上传中 [:bar] :percent :etas', {
145
+ const bar = new ProgressBar(' Uploading [:bar] :percent :etas', {
141
146
  complete: '=',
142
147
  incomplete: ' ',
143
148
  total: fileSize,
@@ -145,9 +150,9 @@ export async function uploadFile(fn: string, key?: string) {
145
150
 
146
151
  const form = new FormData();
147
152
 
148
- Object.entries(formData).forEach(([k, v]) => {
153
+ for (const [k, v] of Object.entries(formData)) {
149
154
  form.append(k, v);
150
- });
155
+ }
151
156
  const fileStream = fs.createReadStream(fn);
152
157
  fileStream.on('data', (data) => {
153
158
  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;
Binary file
@@ -0,0 +1,6 @@
1
+ export const credentialFile = global.IS_CRESC ? '.cresc.token' : '.update';
2
+ export const updateJson = global.IS_CRESC ? 'cresc.config.json' : 'update.json';
3
+ export const tempDir = global.IS_CRESC ? '.cresc.temp' : '.pushy';
4
+ export const pricingPageUrl = global.IS_CRESC
5
+ ? 'https://cresc.dev/pricing'
6
+ : '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 };