react-native-update-cli 1.41.0-beta.0 → 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 +8 -10
- package/lib/index.js +3 -5
- package/lib/utils/constants.js +15 -4
- package/lib/versions.js +1 -1
- package/package.json +8 -1
- package/src/api.ts +5 -7
- package/src/index.ts +3 -8
- package/src/types.ts +0 -1
- package/src/utils/constants.ts +11 -4
- package/src/utils/index.ts +1 -1
- package/src/{versions.js → versions.ts} +2 -2
package/lib/api.js
CHANGED
|
@@ -50,7 +50,6 @@ const _tcpping = /*#__PURE__*/ _interop_require_default(require("tcp-ping"));
|
|
|
50
50
|
const _filesizeparser = /*#__PURE__*/ _interop_require_default(require("filesize-parser"));
|
|
51
51
|
const _constants = require("./utils/constants");
|
|
52
52
|
const _formdata = /*#__PURE__*/ _interop_require_default(require("form-data"));
|
|
53
|
-
const _constants1 = require("utils/constants");
|
|
54
53
|
function _interop_require_default(obj) {
|
|
55
54
|
return obj && obj.__esModule ? obj : {
|
|
56
55
|
default: obj
|
|
@@ -59,20 +58,20 @@ function _interop_require_default(obj) {
|
|
|
59
58
|
const tcpPing = _nodeutil.default.promisify(_tcpping.default.ping);
|
|
60
59
|
let session;
|
|
61
60
|
let savedSession;
|
|
62
|
-
const defaultEndpoint =
|
|
63
|
-
|
|
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;
|
|
64
63
|
const userAgent = `react-native-update-cli/${_packagejson.default.version}`;
|
|
65
64
|
const getSession = ()=>session;
|
|
66
65
|
const replaceSession = (newSession)=>{
|
|
67
66
|
session = newSession;
|
|
68
67
|
};
|
|
69
68
|
const loadSession = async ()=>{
|
|
70
|
-
if (_nodefs.default.existsSync(
|
|
69
|
+
if (_nodefs.default.existsSync(_constants.credentialFile)) {
|
|
71
70
|
try {
|
|
72
|
-
replaceSession(JSON.parse(_nodefs.default.readFileSync(
|
|
71
|
+
replaceSession(JSON.parse(_nodefs.default.readFileSync(_constants.credentialFile, 'utf8')));
|
|
73
72
|
savedSession = session;
|
|
74
73
|
} catch (e) {
|
|
75
|
-
console.error(`Failed to parse file ${
|
|
74
|
+
console.error(`Failed to parse file ${_constants.credentialFile}. Try to remove it manually.`);
|
|
76
75
|
throw e;
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -82,17 +81,16 @@ const saveSession = ()=>{
|
|
|
82
81
|
if (session !== savedSession) {
|
|
83
82
|
const current = session;
|
|
84
83
|
const data = JSON.stringify(current, null, 4);
|
|
85
|
-
_nodefs.default.writeFileSync(
|
|
84
|
+
_nodefs.default.writeFileSync(_constants.credentialFile, data, 'utf8');
|
|
86
85
|
savedSession = current;
|
|
87
86
|
}
|
|
88
87
|
};
|
|
89
88
|
const closeSession = ()=>{
|
|
90
|
-
if (_nodefs.default.existsSync(
|
|
91
|
-
_nodefs.default.unlinkSync(
|
|
89
|
+
if (_nodefs.default.existsSync(_constants.credentialFile)) {
|
|
90
|
+
_nodefs.default.unlinkSync(_constants.credentialFile);
|
|
92
91
|
savedSession = undefined;
|
|
93
92
|
}
|
|
94
93
|
session = undefined;
|
|
95
|
-
host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
|
96
94
|
};
|
|
97
95
|
async function query(url, options) {
|
|
98
96
|
const resp = await (0, _nodefetch.default)(url, options);
|
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:
|
|
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
|
|
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`命令来登录');
|
package/lib/utils/constants.js
CHANGED
|
@@ -9,6 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
IS_CRESC: function() {
|
|
13
|
+
return IS_CRESC;
|
|
14
|
+
},
|
|
12
15
|
credentialFile: function() {
|
|
13
16
|
return credentialFile;
|
|
14
17
|
},
|
|
@@ -22,7 +25,15 @@ _export(exports, {
|
|
|
22
25
|
return updateJson;
|
|
23
26
|
}
|
|
24
27
|
});
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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';
|
package/lib/versions.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "1.41.0-beta.
|
|
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,14 @@
|
|
|
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
|
},
|
|
74
81
|
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
|
package/src/api.ts
CHANGED
|
@@ -6,20 +6,21 @@ 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/constants';
|
|
9
|
+
import { pricingPageUrl, credentialFile, IS_CRESC } from './utils/constants';
|
|
10
10
|
import type { Session } from 'types';
|
|
11
11
|
import FormData from 'form-data';
|
|
12
|
-
import { credentialFile } from 'utils/constants';
|
|
13
12
|
|
|
14
13
|
const tcpPing = util.promisify(tcpp.ping);
|
|
15
14
|
|
|
16
15
|
let session: Session | undefined;
|
|
17
16
|
let savedSession: Session | undefined;
|
|
18
17
|
|
|
19
|
-
const defaultEndpoint =
|
|
18
|
+
const defaultEndpoint = IS_CRESC
|
|
20
19
|
? 'https://api.cresc.dev'
|
|
21
20
|
: 'https://update.reactnative.cn/api';
|
|
22
|
-
|
|
21
|
+
|
|
22
|
+
const host =
|
|
23
|
+
process.env.PUSHY_REGISTRY || process.env.RNU_API || defaultEndpoint;
|
|
23
24
|
|
|
24
25
|
const userAgent = `react-native-update-cli/${packageJson.version}`;
|
|
25
26
|
|
|
@@ -29,8 +30,6 @@ export const replaceSession = (newSession: { token: string }) => {
|
|
|
29
30
|
session = newSession;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
33
|
export const loadSession = async () => {
|
|
35
34
|
if (fs.existsSync(credentialFile)) {
|
|
36
35
|
try {
|
|
@@ -61,7 +60,6 @@ export const closeSession = () => {
|
|
|
61
60
|
savedSession = undefined;
|
|
62
61
|
}
|
|
63
62
|
session = undefined;
|
|
64
|
-
host = process.env.PUSHY_REGISTRY || defaultEndpoint;
|
|
65
63
|
};
|
|
66
64
|
|
|
67
65
|
async function query(url: string, options: fetch.RequestInit) {
|
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:
|
|
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
|
|
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
package/src/utils/constants.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
5
12
|
? 'https://cresc.dev/pricing'
|
|
6
13
|
: 'https://pushy.reactnative.cn/pricing.html';
|
package/src/utils/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { checkPlugins } from './check-plugin';
|
|
|
11
11
|
import { read } from 'read';
|
|
12
12
|
import { tempDir } from './constants';
|
|
13
13
|
|
|
14
|
-
export async function question(query: string, password
|
|
14
|
+
export async function question(query: string, password?: boolean) {
|
|
15
15
|
if (NO_INTERACTIVE) {
|
|
16
16
|
return '';
|
|
17
17
|
}
|
|
@@ -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 =
|
|
21
|
+
packageInfo = 'no package';
|
|
22
22
|
} else {
|
|
23
23
|
packageInfo = `[${packageInfo}]`;
|
|
24
24
|
}
|