react-native-update-cli 2.24.1 → 2.25.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.
Files changed (95) hide show
  1. package/README.md +11 -4
  2. package/README.zh-CN.md +11 -4
  3. package/cli.json +7 -1
  4. package/lib/api.d.ts +2 -0
  5. package/lib/api.js +63 -18
  6. package/lib/app.js +25 -3
  7. package/lib/bin.js +39 -45
  8. package/lib/bundle-runner.d.ts +27 -0
  9. package/lib/bundle-runner.js +240 -21
  10. package/lib/bundle.d.ts +1 -1
  11. package/lib/bundle.js +19 -6
  12. package/lib/commands.d.ts +6 -0
  13. package/lib/commands.js +65 -0
  14. package/lib/locales/en.d.ts +5 -14
  15. package/lib/locales/en.js +5 -14
  16. package/lib/locales/zh.d.ts +5 -13
  17. package/lib/locales/zh.js +5 -13
  18. package/lib/package.js +4 -0
  19. package/lib/provider.d.ts +1 -1
  20. package/lib/provider.js +3 -1
  21. package/lib/symbolicate.js +11 -3
  22. package/lib/types.d.ts +1 -0
  23. package/lib/user.js +6 -0
  24. package/lib/utils/add-gitignore.js +7 -1
  25. package/lib/utils/dep-versions.d.ts +7 -0
  26. package/lib/utils/dep-versions.js +78 -26
  27. package/lib/utils/git.js +9 -6
  28. package/lib/utils/hermes-base.js +2 -1
  29. package/lib/utils/i18n.d.ts +5 -0
  30. package/lib/utils/i18n.js +14 -1
  31. package/lib/utils/index.d.ts +2 -1
  32. package/lib/utils/index.js +9 -4
  33. package/lib/utils/latest-version/index.js +8 -0
  34. package/lib/utils/runtime.d.ts +21 -0
  35. package/lib/utils/runtime.js +138 -5
  36. package/lib/utils/slim-sourcemap.d.ts +11 -0
  37. package/lib/utils/slim-sourcemap.js +22 -0
  38. package/lib/utils/zip-range.js +3 -2
  39. package/lib/versions.js +16 -15
  40. package/package.json +4 -2
  41. package/lib/index.d.ts +0 -1
  42. package/lib/index.js +0 -17
  43. package/src/api.ts +0 -470
  44. package/src/app.ts +0 -241
  45. package/src/auto-update.ts +0 -647
  46. package/src/bin-cresc.ts +0 -8
  47. package/src/bin.ts +0 -115
  48. package/src/bundle-pack.ts +0 -61
  49. package/src/bundle-runner.ts +0 -1430
  50. package/src/bundle.ts +0 -371
  51. package/src/cache.ts +0 -20
  52. package/src/diff.ts +0 -1010
  53. package/src/exports.ts +0 -17
  54. package/src/index.ts +0 -1
  55. package/src/install.ts +0 -50
  56. package/src/locales/en.ts +0 -257
  57. package/src/locales/zh.ts +0 -234
  58. package/src/native-package.ts +0 -338
  59. package/src/package.ts +0 -482
  60. package/src/provider.ts +0 -294
  61. package/src/symbolicate.ts +0 -159
  62. package/src/types.ts +0 -150
  63. package/src/user.ts +0 -39
  64. package/src/utils/add-gitignore.ts +0 -35
  65. package/src/utils/app-info-parser/aab.ts +0 -241
  66. package/src/utils/app-info-parser/apk.ts +0 -92
  67. package/src/utils/app-info-parser/app.ts +0 -7
  68. package/src/utils/app-info-parser/index.ts +0 -54
  69. package/src/utils/app-info-parser/ipa.ts +0 -109
  70. package/src/utils/app-info-parser/resource-finder.ts +0 -508
  71. package/src/utils/app-info-parser/utils.ts +0 -161
  72. package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
  73. package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
  74. package/src/utils/app-info-parser/zip.ts +0 -108
  75. package/src/utils/check-lockfile.ts +0 -93
  76. package/src/utils/check-plugin.ts +0 -38
  77. package/src/utils/command-result.ts +0 -24
  78. package/src/utils/constants.ts +0 -25
  79. package/src/utils/dep-versions.ts +0 -83
  80. package/src/utils/git.ts +0 -71
  81. package/src/utils/hbcTransform.ts +0 -649
  82. package/src/utils/hermes-base.ts +0 -1137
  83. package/src/utils/http-helper.ts +0 -152
  84. package/src/utils/i18n.ts +0 -39
  85. package/src/utils/index.ts +0 -698
  86. package/src/utils/latest-version/index.ts +0 -573
  87. package/src/utils/options.ts +0 -78
  88. package/src/utils/plugin-config.ts +0 -32
  89. package/src/utils/runtime.ts +0 -187
  90. package/src/utils/slim-sourcemap.ts +0 -83
  91. package/src/utils/zip-entries.ts +0 -209
  92. package/src/utils/zip-options.ts +0 -178
  93. package/src/utils/zip-range.ts +0 -727
  94. package/src/utils/zip-raw-writer.ts +0 -247
  95. package/src/versions.ts +0 -894
@@ -1,152 +0,0 @@
1
- import { defaultEndpoints } from './constants';
2
- import { runtimeFetch } from './runtime';
3
-
4
- // const baseUrl = `http://localhost:9000`;
5
- // let baseUrl = SERVER.main[0];
6
- // const baseUrl = `https://p.reactnative.cn/api`;
7
-
8
- export function promiseAny<T>(promises: Promise<T>[]) {
9
- return new Promise<T>((resolve, reject) => {
10
- let count = 0;
11
-
12
- for (const promise of promises) {
13
- Promise.resolve(promise)
14
- .then(resolve)
15
- .catch(() => {
16
- count++;
17
- if (count === promises.length) {
18
- reject(new Error('All promises were rejected'));
19
- }
20
- });
21
- }
22
- });
23
- }
24
-
25
- export const ping = async (url: string, signal?: AbortSignal) => {
26
- let timer: ReturnType<typeof setTimeout> | undefined;
27
- try {
28
- return await (Promise.race([
29
- runtimeFetch(url, {
30
- method: 'HEAD',
31
- signal,
32
- }).then(({ status }) => {
33
- if (status === 200) {
34
- return url;
35
- }
36
- throw new Error('ping failed');
37
- }),
38
- new Promise((_, reject) => {
39
- timer = setTimeout(() => {
40
- reject(new Error('ping timeout'));
41
- }, 5000);
42
- }),
43
- ]) as Promise<string | null>);
44
- } finally {
45
- // clear the timer so it doesn't keep the process alive for 5s
46
- clearTimeout(timer);
47
- }
48
- };
49
-
50
- const HEDGE_DELAY_MS = 250;
51
-
52
- // Hedged race instead of pinging every endpoint at once: the preferred (first)
53
- // url is tried immediately, each following one only after HEDGE_DELAY_MS of
54
- // silence (or immediately when a previous ping failed). The first success wins
55
- // and the losing pings are aborted. Falls back to urls[0] when all fail.
56
- export const testUrls = async (
57
- urls?: string[],
58
- hedgeDelayMs: number = HEDGE_DELAY_MS,
59
- ) => {
60
- if (!urls?.length) {
61
- return null;
62
- }
63
- return new Promise<string>((resolve) => {
64
- const controllers: AbortController[] = [];
65
- let nextIndex = 0;
66
- let pending = 0;
67
- let settled = false;
68
- let hedgeTimer: ReturnType<typeof setTimeout> | undefined;
69
-
70
- const finish = (
71
- winner: string | null,
72
- winnerController?: AbortController,
73
- ) => {
74
- if (settled) {
75
- return;
76
- }
77
- settled = true;
78
- if (hedgeTimer) {
79
- clearTimeout(hedgeTimer);
80
- }
81
- for (const controller of controllers) {
82
- if (controller !== winnerController) {
83
- controller.abort();
84
- }
85
- }
86
- resolve(winner ?? urls[0]);
87
- };
88
-
89
- const launchNext = () => {
90
- if (hedgeTimer) {
91
- clearTimeout(hedgeTimer);
92
- hedgeTimer = undefined;
93
- }
94
- if (settled || nextIndex >= urls.length) {
95
- return;
96
- }
97
- const url = urls[nextIndex++];
98
- const controller = new AbortController();
99
- controllers.push(controller);
100
- pending++;
101
- ping(url, controller.signal).then(
102
- () => finish(url, controller),
103
- () => {
104
- pending--;
105
- if (settled) {
106
- return;
107
- }
108
- if (nextIndex < urls.length) {
109
- // A failure frees its slot: hedge the next url right away.
110
- launchNext();
111
- } else if (pending === 0) {
112
- finish(null);
113
- }
114
- },
115
- );
116
- if (!settled && nextIndex < urls.length) {
117
- hedgeTimer = setTimeout(launchNext, hedgeDelayMs);
118
- }
119
- };
120
-
121
- launchNext();
122
- });
123
- };
124
-
125
- let baseUrlPromise: Promise<string> | undefined;
126
-
127
- async function resolveBaseUrl(): Promise<string> {
128
- const testEndpoint = process.env.PUSHY_REGISTRY || process.env.RNU_API;
129
- if (testEndpoint) {
130
- return testEndpoint;
131
- }
132
- const ret = await testUrls(defaultEndpoints.map((url) => `${url}/status`));
133
- let baseUrl = defaultEndpoints[0];
134
- if (ret) {
135
- // remove /status
136
- baseUrl = ret.replace('/status', '');
137
- }
138
- // console.log('baseUrl', baseUrl);
139
- return baseUrl;
140
- }
141
-
142
- /**
143
- * The API base url: the env override, or the first default endpoint that
144
- * answers a HEAD ping. Resolved lazily on the first API call (offline commands
145
- * such as `hdiff`/`help` never ping) and memoized for the process lifetime.
146
- */
147
- export const getBaseUrl = (): Promise<string> => {
148
- if (!baseUrlPromise) {
149
- baseUrlPromise = resolveBaseUrl();
150
- }
151
- return baseUrlPromise;
152
- };
package/src/utils/i18n.ts DELETED
@@ -1,39 +0,0 @@
1
- import i18next from 'i18next';
2
- import en from '../locales/en';
3
- import zh from '../locales/zh';
4
- import { IS_CRESC } from './constants';
5
-
6
- i18next.init({
7
- lng: IS_CRESC ? 'en' : 'zh',
8
- // debug: process.env.NODE_ENV !== 'production',
9
- // debug: true,
10
- resources: {
11
- en: {
12
- translation: en,
13
- },
14
- zh: {
15
- translation: zh,
16
- },
17
- },
18
- interpolation: {
19
- escapeValue: false,
20
- },
21
- });
22
-
23
- declare module 'i18next' {
24
- // Extend CustomTypeOptions
25
- interface CustomTypeOptions {
26
- // custom namespace type, if you changed it
27
- defaultNS: 'en';
28
- // custom resources type
29
- resources: {
30
- en: typeof en;
31
- zh: typeof zh;
32
- };
33
- // other
34
- }
35
- }
36
-
37
- export function t(key: string, options?: any): string {
38
- return i18next.t(key as any, options);
39
- }