react-native-update-cli 2.29.1 → 2.29.3
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/account.js +2 -4
- package/lib/api.d.ts +1 -1
- package/lib/api.js +26 -44
- package/lib/app.js +13 -27
- package/lib/auto-update.d.ts +1 -1
- package/lib/auto-update.js +6 -16
- package/lib/bin.js +4 -6
- package/lib/bundle-pack.js +25 -27
- package/lib/bundle-runner.js +55 -54
- package/lib/bundle.js +18 -26
- package/lib/diff.js +32 -91
- package/lib/locales/en.d.ts +0 -10
- package/lib/locales/en.js +0 -10
- package/lib/locales/zh.d.ts +0 -10
- package/lib/locales/zh.js +0 -10
- package/lib/native-package.js +20 -60
- package/lib/package.d.ts +6 -1
- package/lib/package.js +59 -74
- package/lib/provider.js +3 -5
- package/lib/symbolicate.js +1 -16
- package/lib/utils/add-gitignore.js +0 -1
- package/lib/utils/app-info-parser/aab.d.ts +5 -22
- package/lib/utils/app-info-parser/aab.js +87 -192
- package/lib/utils/app-info-parser/apk.d.ts +12 -13
- package/lib/utils/app-info-parser/apk.js +28 -78
- package/lib/utils/app-info-parser/ipa.d.ts +2 -14
- package/lib/utils/app-info-parser/ipa.js +9 -70
- package/lib/utils/app-info-parser/resource-finder.d.ts +1 -26
- package/lib/utils/app-info-parser/resource-finder.js +41 -183
- package/lib/utils/app-info-parser/xml-parser/binary.d.ts +6 -55
- package/lib/utils/app-info-parser/xml-parser/binary.js +152 -556
- package/lib/utils/app-info-parser/zip.d.ts +6 -24
- package/lib/utils/app-info-parser/zip.js +19 -86
- package/lib/utils/check-plugin.d.ts +7 -5
- package/lib/utils/check-plugin.js +15 -25
- package/lib/utils/dep-versions.d.ts +0 -6
- package/lib/utils/dep-versions.js +2 -27
- package/lib/utils/failure-fingerprint.js +3 -4
- package/lib/utils/fs-helpers.d.ts +5 -0
- package/lib/utils/fs-helpers.js +19 -0
- package/lib/utils/git.d.ts +0 -1
- package/lib/utils/git.js +0 -8
- package/lib/utils/hash.d.ts +3 -0
- package/lib/utils/hash.js +19 -0
- package/lib/utils/hbcTransform.d.ts +9 -2
- package/lib/utils/hbcTransform.js +41 -70
- package/lib/utils/hermes-base.d.ts +1 -5
- package/lib/utils/hermes-base.js +93 -156
- package/lib/utils/hermes-literals.d.ts +5 -3
- package/lib/utils/hermes-literals.js +30 -53
- package/lib/utils/hermes-raw.d.ts +7 -0
- package/lib/utils/hermes-raw.js +26 -9
- package/lib/utils/http-helper.d.ts +0 -1
- package/lib/utils/http-helper.js +0 -20
- package/lib/utils/i18n.js +0 -2
- package/lib/utils/index.d.ts +5 -19
- package/lib/utils/index.js +95 -189
- package/lib/utils/latest-version.d.ts +19 -0
- package/lib/utils/latest-version.js +137 -0
- package/lib/utils/options.d.ts +2 -1
- package/lib/utils/options.js +5 -7
- package/lib/utils/zip-entries.d.ts +23 -0
- package/lib/utils/zip-entries.js +125 -102
- package/lib/utils/zip-options.js +29 -56
- package/lib/utils/zip-range.js +25 -65
- package/lib/versions.d.ts +5 -0
- package/lib/versions.js +86 -153
- package/package.json +1 -3
- package/lib/utils/app-info-parser/app.d.ts +0 -4
- package/lib/utils/app-info-parser/app.js +0 -10
- package/lib/utils/app-info-parser/index.d.ts +0 -16
- package/lib/utils/app-info-parser/index.js +0 -46
- package/lib/utils/app-info-parser/utils.d.ts +0 -31
- package/lib/utils/app-info-parser/utils.js +0 -135
- package/lib/utils/app-info-parser/xml-parser/manifest.d.ts +0 -10
- package/lib/utils/app-info-parser/xml-parser/manifest.js +0 -202
- package/lib/utils/latest-version/index.d.ts +0 -149
- package/lib/utils/latest-version/index.js +0 -326
- package/lib/utils/plugin-config.d.ts +0 -9
- package/lib/utils/plugin-config.js +0 -31
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapInfoResource = exports.isPrimitive = exports.isObject = exports.isBrowser = exports.isArray = exports.getBase64FromBuffer = exports.findIpaIconPath = exports.findApkIconPath = exports.decodeNullUnicode = void 0;
|
|
4
|
-
const objectType = (value) => Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
|
|
5
|
-
const isArray = (value) => objectType(value) === 'array';
|
|
6
|
-
exports.isArray = isArray;
|
|
7
|
-
const isObject = (value) => objectType(value) === 'object';
|
|
8
|
-
exports.isObject = isObject;
|
|
9
|
-
const isPrimitive = (value) => value === null ||
|
|
10
|
-
['boolean', 'number', 'string', 'undefined'].includes(objectType(value));
|
|
11
|
-
exports.isPrimitive = isPrimitive;
|
|
12
|
-
const isBrowser = () => typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
13
|
-
exports.isBrowser = isBrowser;
|
|
14
|
-
/**
|
|
15
|
-
* map file place with resourceMap
|
|
16
|
-
* @param {Object} apkInfo // json info parsed from .apk file
|
|
17
|
-
* @param {Object} resourceMap // resourceMap
|
|
18
|
-
*/
|
|
19
|
-
const mapInfoResource = (apkInfo, resourceMap) => {
|
|
20
|
-
const iteratorObj = (obj) => {
|
|
21
|
-
for (const i in obj) {
|
|
22
|
-
if (isArray(obj[i])) {
|
|
23
|
-
iteratorArray(obj[i]);
|
|
24
|
-
}
|
|
25
|
-
else if (isObject(obj[i])) {
|
|
26
|
-
iteratorObj(obj[i]);
|
|
27
|
-
}
|
|
28
|
-
else if (isPrimitive(obj[i])) {
|
|
29
|
-
if (isResources(obj[i])) {
|
|
30
|
-
obj[i] = resourceMap[transKeyToMatchResourceMap(obj[i])];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const iteratorArray = (array) => {
|
|
36
|
-
const l = array.length;
|
|
37
|
-
for (let i = 0; i < l; i++) {
|
|
38
|
-
if (isArray(array[i])) {
|
|
39
|
-
iteratorArray(array[i]);
|
|
40
|
-
}
|
|
41
|
-
else if (isObject(array[i])) {
|
|
42
|
-
iteratorObj(array[i]);
|
|
43
|
-
}
|
|
44
|
-
else if (isPrimitive(array[i])) {
|
|
45
|
-
if (isResources(array[i])) {
|
|
46
|
-
array[i] = resourceMap[transKeyToMatchResourceMap(array[i])];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const isResources = (attrValue) => {
|
|
52
|
-
if (!attrValue)
|
|
53
|
-
return false;
|
|
54
|
-
const value = typeof attrValue === 'string' ? attrValue : attrValue.toString();
|
|
55
|
-
return value.indexOf('resourceId:') === 0;
|
|
56
|
-
};
|
|
57
|
-
const transKeyToMatchResourceMap = (resourceId) => `@${resourceId.replace('resourceId:0x', '').toUpperCase()}`;
|
|
58
|
-
iteratorObj(apkInfo);
|
|
59
|
-
return apkInfo;
|
|
60
|
-
};
|
|
61
|
-
exports.mapInfoResource = mapInfoResource;
|
|
62
|
-
/**
|
|
63
|
-
* find .apk file's icon path from json info
|
|
64
|
-
* @param info // json info parsed from .apk file
|
|
65
|
-
*/
|
|
66
|
-
const findApkIconPath = (info) => {
|
|
67
|
-
if (!info.application.icon?.splice) {
|
|
68
|
-
return '';
|
|
69
|
-
}
|
|
70
|
-
const rulesMap = {
|
|
71
|
-
mdpi: 48,
|
|
72
|
-
hdpi: 72,
|
|
73
|
-
xhdpi: 96,
|
|
74
|
-
xxdpi: 144,
|
|
75
|
-
xxxhdpi: 192,
|
|
76
|
-
};
|
|
77
|
-
const resultMap = {};
|
|
78
|
-
const maxDpiIcon = { dpi: 120, icon: '' };
|
|
79
|
-
for (const i in rulesMap) {
|
|
80
|
-
info.application.icon.some((icon) => {
|
|
81
|
-
if (icon && icon.indexOf(i) !== -1) {
|
|
82
|
-
resultMap[`application-icon-${rulesMap[i]}`] = icon;
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
});
|
|
87
|
-
if (resultMap[`application-icon-${rulesMap[i]}`] &&
|
|
88
|
-
rulesMap[i] >= maxDpiIcon.dpi) {
|
|
89
|
-
maxDpiIcon.dpi = rulesMap[i];
|
|
90
|
-
maxDpiIcon.icon = resultMap[`application-icon-${rulesMap[i]}`];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (Object.keys(resultMap).length === 0 || !maxDpiIcon.icon) {
|
|
94
|
-
maxDpiIcon.dpi = 120;
|
|
95
|
-
maxDpiIcon.icon = info.application.icon[0] || '';
|
|
96
|
-
resultMap['applicataion-icon-120'] = maxDpiIcon.icon;
|
|
97
|
-
}
|
|
98
|
-
return maxDpiIcon.icon;
|
|
99
|
-
};
|
|
100
|
-
exports.findApkIconPath = findApkIconPath;
|
|
101
|
-
/**
|
|
102
|
-
* find .ipa file's icon path from json info
|
|
103
|
-
* @param info // json info parsed from .ipa file
|
|
104
|
-
*/
|
|
105
|
-
const findIpaIconPath = (info) => {
|
|
106
|
-
if (info.CFBundleIcons?.CFBundlePrimaryIcon?.CFBundleIconFiles?.length) {
|
|
107
|
-
return info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles[info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length - 1];
|
|
108
|
-
}
|
|
109
|
-
if (info.CFBundleIconFiles?.length) {
|
|
110
|
-
return info.CFBundleIconFiles[info.CFBundleIconFiles.length - 1];
|
|
111
|
-
}
|
|
112
|
-
return '.app/Icon.png';
|
|
113
|
-
};
|
|
114
|
-
exports.findIpaIconPath = findIpaIconPath;
|
|
115
|
-
/**
|
|
116
|
-
* transform buffer to base64
|
|
117
|
-
* @param {Buffer} buffer
|
|
118
|
-
*/
|
|
119
|
-
const getBase64FromBuffer = (buffer) => {
|
|
120
|
-
const base64 = typeof buffer === 'string' ? buffer : buffer.toString('base64');
|
|
121
|
-
return `data:image/png;base64,${base64}`;
|
|
122
|
-
};
|
|
123
|
-
exports.getBase64FromBuffer = getBase64FromBuffer;
|
|
124
|
-
/**
|
|
125
|
-
* 去除unicode空字符
|
|
126
|
-
* @param {String} str
|
|
127
|
-
*/
|
|
128
|
-
const decodeNullUnicode = (value) => {
|
|
129
|
-
if (typeof value === 'string') {
|
|
130
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: strips null unicode padding from decoded strings
|
|
131
|
-
return value.replace(/\u0000/g, '');
|
|
132
|
-
}
|
|
133
|
-
return value;
|
|
134
|
-
};
|
|
135
|
-
exports.decodeNullUnicode = decodeNullUnicode;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class ManifestParser {
|
|
2
|
-
private buffer;
|
|
3
|
-
private xmlParser;
|
|
4
|
-
constructor(buffer: Buffer, options?: Record<string, any>);
|
|
5
|
-
private collapseAttributes;
|
|
6
|
-
private parseIntents;
|
|
7
|
-
private parseApplication;
|
|
8
|
-
private isLauncherActivity;
|
|
9
|
-
parse(): Record<string, any>;
|
|
10
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ManifestParser = void 0;
|
|
4
|
-
// From https://github.com/openstf/adbkit-apkreader
|
|
5
|
-
const binary_1 = require("./binary");
|
|
6
|
-
const INTENT_MAIN = 'android.intent.action.MAIN';
|
|
7
|
-
const CATEGORY_LAUNCHER = 'android.intent.category.LAUNCHER';
|
|
8
|
-
class ManifestParser {
|
|
9
|
-
buffer;
|
|
10
|
-
xmlParser;
|
|
11
|
-
constructor(buffer, options = {}) {
|
|
12
|
-
this.buffer = buffer;
|
|
13
|
-
this.xmlParser = new binary_1.BinaryXmlParser(this.buffer, options);
|
|
14
|
-
}
|
|
15
|
-
collapseAttributes(element) {
|
|
16
|
-
const collapsed = Object.create(null);
|
|
17
|
-
const attributes = element.attributes;
|
|
18
|
-
for (let i = 0, len = attributes.length; i < len; i++) {
|
|
19
|
-
const attr = attributes[i];
|
|
20
|
-
collapsed[attr.name] = attr.typedValue.value;
|
|
21
|
-
}
|
|
22
|
-
return collapsed;
|
|
23
|
-
}
|
|
24
|
-
parseIntents(element, target) {
|
|
25
|
-
target.intentFilters = [];
|
|
26
|
-
target.metaData = [];
|
|
27
|
-
for (const child of element.childNodes) {
|
|
28
|
-
switch (child.nodeName) {
|
|
29
|
-
case 'intent-filter': {
|
|
30
|
-
const intentFilter = this.collapseAttributes(child);
|
|
31
|
-
intentFilter.actions = [];
|
|
32
|
-
intentFilter.categories = [];
|
|
33
|
-
intentFilter.data = [];
|
|
34
|
-
for (const item of child.childNodes) {
|
|
35
|
-
switch (item.nodeName) {
|
|
36
|
-
case 'action':
|
|
37
|
-
intentFilter.actions.push(this.collapseAttributes(item));
|
|
38
|
-
break;
|
|
39
|
-
case 'category':
|
|
40
|
-
intentFilter.categories.push(this.collapseAttributes(item));
|
|
41
|
-
break;
|
|
42
|
-
case 'data':
|
|
43
|
-
intentFilter.data.push(this.collapseAttributes(item));
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
target.intentFilters.push(intentFilter);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case 'meta-data':
|
|
51
|
-
target.metaData.push(this.collapseAttributes(child));
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
parseApplication(element) {
|
|
57
|
-
const app = this.collapseAttributes(element);
|
|
58
|
-
app.activities = [];
|
|
59
|
-
app.activityAliases = [];
|
|
60
|
-
app.launcherActivities = [];
|
|
61
|
-
app.services = [];
|
|
62
|
-
app.receivers = [];
|
|
63
|
-
app.providers = [];
|
|
64
|
-
app.usesLibraries = [];
|
|
65
|
-
app.metaData = [];
|
|
66
|
-
for (const child of element.childNodes) {
|
|
67
|
-
switch (child.nodeName) {
|
|
68
|
-
case 'activity': {
|
|
69
|
-
const activity = this.collapseAttributes(child);
|
|
70
|
-
this.parseIntents(child, activity);
|
|
71
|
-
app.activities.push(activity);
|
|
72
|
-
if (this.isLauncherActivity(activity)) {
|
|
73
|
-
app.launcherActivities.push(activity);
|
|
74
|
-
}
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
case 'activity-alias': {
|
|
78
|
-
const activityAlias = this.collapseAttributes(child);
|
|
79
|
-
this.parseIntents(child, activityAlias);
|
|
80
|
-
app.activityAliases.push(activityAlias);
|
|
81
|
-
if (this.isLauncherActivity(activityAlias)) {
|
|
82
|
-
app.launcherActivities.push(activityAlias);
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
case 'service': {
|
|
87
|
-
const service = this.collapseAttributes(child);
|
|
88
|
-
this.parseIntents(child, service);
|
|
89
|
-
app.services.push(service);
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
case 'receiver': {
|
|
93
|
-
const receiver = this.collapseAttributes(child);
|
|
94
|
-
this.parseIntents(child, receiver);
|
|
95
|
-
app.receivers.push(receiver);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case 'provider': {
|
|
99
|
-
const provider = this.collapseAttributes(child);
|
|
100
|
-
provider.grantUriPermissions = [];
|
|
101
|
-
provider.metaData = [];
|
|
102
|
-
provider.pathPermissions = [];
|
|
103
|
-
for (const item of child.childNodes) {
|
|
104
|
-
switch (item.nodeName) {
|
|
105
|
-
case 'grant-uri-permission':
|
|
106
|
-
provider.grantUriPermissions.push(this.collapseAttributes(item));
|
|
107
|
-
break;
|
|
108
|
-
case 'meta-data':
|
|
109
|
-
provider.metaData.push(this.collapseAttributes(item));
|
|
110
|
-
break;
|
|
111
|
-
case 'path-permission':
|
|
112
|
-
provider.pathPermissions.push(this.collapseAttributes(item));
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
app.providers.push(provider);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case 'uses-library':
|
|
120
|
-
app.usesLibraries.push(this.collapseAttributes(child));
|
|
121
|
-
break;
|
|
122
|
-
case 'meta-data':
|
|
123
|
-
app.metaData.push(this.collapseAttributes(child));
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return app;
|
|
128
|
-
}
|
|
129
|
-
isLauncherActivity(activity) {
|
|
130
|
-
return activity.intentFilters.some((filter) => {
|
|
131
|
-
const hasMain = filter.actions.some((action) => action.name === INTENT_MAIN);
|
|
132
|
-
if (!hasMain) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
return filter.categories.some((category) => category.name === CATEGORY_LAUNCHER);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
parse() {
|
|
139
|
-
const document = this.xmlParser.parse();
|
|
140
|
-
const manifest = this.collapseAttributes(document);
|
|
141
|
-
manifest.usesPermissions = [];
|
|
142
|
-
manifest.usesPermissionsSDK23 = [];
|
|
143
|
-
manifest.permissions = [];
|
|
144
|
-
manifest.permissionTrees = [];
|
|
145
|
-
manifest.permissionGroups = [];
|
|
146
|
-
manifest.instrumentation = null;
|
|
147
|
-
manifest.usesSdk = null;
|
|
148
|
-
manifest.usesConfiguration = null;
|
|
149
|
-
manifest.usesFeatures = [];
|
|
150
|
-
manifest.supportsScreens = null;
|
|
151
|
-
manifest.compatibleScreens = [];
|
|
152
|
-
manifest.supportsGlTextures = [];
|
|
153
|
-
manifest.application = Object.create(null);
|
|
154
|
-
for (const element of document.childNodes) {
|
|
155
|
-
switch (element.nodeName) {
|
|
156
|
-
case 'uses-permission':
|
|
157
|
-
manifest.usesPermissions.push(this.collapseAttributes(element));
|
|
158
|
-
break;
|
|
159
|
-
case 'uses-permission-sdk-23':
|
|
160
|
-
manifest.usesPermissionsSDK23.push(this.collapseAttributes(element));
|
|
161
|
-
break;
|
|
162
|
-
case 'permission':
|
|
163
|
-
manifest.permissions.push(this.collapseAttributes(element));
|
|
164
|
-
break;
|
|
165
|
-
case 'permission-tree':
|
|
166
|
-
manifest.permissionTrees.push(this.collapseAttributes(element));
|
|
167
|
-
break;
|
|
168
|
-
case 'permission-group':
|
|
169
|
-
manifest.permissionGroups.push(this.collapseAttributes(element));
|
|
170
|
-
break;
|
|
171
|
-
case 'instrumentation':
|
|
172
|
-
manifest.instrumentation = this.collapseAttributes(element);
|
|
173
|
-
break;
|
|
174
|
-
case 'uses-sdk':
|
|
175
|
-
manifest.usesSdk = this.collapseAttributes(element);
|
|
176
|
-
break;
|
|
177
|
-
case 'uses-configuration':
|
|
178
|
-
manifest.usesConfiguration = this.collapseAttributes(element);
|
|
179
|
-
break;
|
|
180
|
-
case 'uses-feature':
|
|
181
|
-
manifest.usesFeatures.push(this.collapseAttributes(element));
|
|
182
|
-
break;
|
|
183
|
-
case 'supports-screens':
|
|
184
|
-
manifest.supportsScreens = this.collapseAttributes(element);
|
|
185
|
-
break;
|
|
186
|
-
case 'compatible-screens':
|
|
187
|
-
for (const screen of element.childNodes) {
|
|
188
|
-
manifest.compatibleScreens.push(this.collapseAttributes(screen));
|
|
189
|
-
}
|
|
190
|
-
break;
|
|
191
|
-
case 'supports-gl-texture':
|
|
192
|
-
manifest.supportsGlTextures.push(this.collapseAttributes(element));
|
|
193
|
-
break;
|
|
194
|
-
case 'application':
|
|
195
|
-
manifest.application = this.parseApplication(element);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return manifest;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
exports.ManifestParser = ManifestParser;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type { Agent } from 'http';
|
|
2
|
-
interface RegistryVersions {
|
|
3
|
-
/**
|
|
4
|
-
* The latest version of the package found on the registry (if found).
|
|
5
|
-
*/
|
|
6
|
-
latest?: string;
|
|
7
|
-
/**
|
|
8
|
-
* The next version of the package found on the registry (if found).
|
|
9
|
-
*/
|
|
10
|
-
next?: string;
|
|
11
|
-
/**
|
|
12
|
-
* The latest version of the package found on the registry and satisfied by the wanted tag or version range.
|
|
13
|
-
*/
|
|
14
|
-
wanted?: string;
|
|
15
|
-
}
|
|
16
|
-
interface InstalledVersions {
|
|
17
|
-
/**
|
|
18
|
-
* The current local installed version of the package (if installed).
|
|
19
|
-
*/
|
|
20
|
-
local?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The current npm global installed version of the package (if installed).
|
|
23
|
-
*/
|
|
24
|
-
globalNpm?: string;
|
|
25
|
-
/**
|
|
26
|
-
* The current yarn global installed version of the package (if installed).
|
|
27
|
-
*/
|
|
28
|
-
globalYarn?: string;
|
|
29
|
-
}
|
|
30
|
-
interface LatestVersionPackage extends InstalledVersions, RegistryVersions {
|
|
31
|
-
/**
|
|
32
|
-
* The name of the package.
|
|
33
|
-
*/
|
|
34
|
-
name: string;
|
|
35
|
-
/**
|
|
36
|
-
* The tag or version range that was provided (if provided).
|
|
37
|
-
* @default "latest"
|
|
38
|
-
*/
|
|
39
|
-
wantedTagOrRange?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Whether the local or global installed versions (if any) could be upgraded or not, based on the wanted version.
|
|
42
|
-
*/
|
|
43
|
-
updatesAvailable: {
|
|
44
|
-
local: string | false;
|
|
45
|
-
globalNpm: string | false;
|
|
46
|
-
globalYarn: string | false;
|
|
47
|
-
} | false;
|
|
48
|
-
/**
|
|
49
|
-
* Any error that might have occurred during the process.
|
|
50
|
-
*/
|
|
51
|
-
error?: Error;
|
|
52
|
-
}
|
|
53
|
-
interface RequestOptions {
|
|
54
|
-
readonly ca?: string | Buffer | Array<string | Buffer>;
|
|
55
|
-
readonly rejectUnauthorized?: boolean;
|
|
56
|
-
readonly agent?: Agent | boolean;
|
|
57
|
-
readonly timeout?: number;
|
|
58
|
-
}
|
|
59
|
-
interface LatestVersionOptions {
|
|
60
|
-
/**
|
|
61
|
-
* Awaiting the api to return might take time, depending on the network, and might impact your package loading performance.
|
|
62
|
-
* You can use the cache mechanism to improve load performance and reduce unnecessary network requests.
|
|
63
|
-
* If `useCache` is not supplied, the api will always check for updates and wait for every requests to return before returning itself.
|
|
64
|
-
* If `useCache` is used (for each provided package):
|
|
65
|
-
* 1) a fresh cache (younger than `cacheMaxAge`, from the same registry) answers without any network request
|
|
66
|
-
* 2) otherwise the registry is queried and the cache refreshed; when that query fails, a stale cache (if any) is used instead.
|
|
67
|
-
* Combine with `unref` so a slow refresh never keeps the process alive.
|
|
68
|
-
* @default false
|
|
69
|
-
*/
|
|
70
|
-
readonly useCache?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* How long the cache for the provided packages should be used before being refreshed (in milliseconds).
|
|
73
|
-
* If `useCache` is not supplied, this option has no effect.
|
|
74
|
-
* If `0` is used, the cache is always refreshed (a stale cache still serves as a fallback when the refresh fails).
|
|
75
|
-
* @default ONE_DAY
|
|
76
|
-
*/
|
|
77
|
-
readonly cacheMaxAge?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Do not let the registry request keep the process alive: its socket is `unref`'d, so the process may exit before the
|
|
80
|
-
* request completes (the returned promise then simply never settles). Use for opportunistic background checks.
|
|
81
|
-
* @default false
|
|
82
|
-
*/
|
|
83
|
-
readonly unref?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* A JavaScript package registry url that implements the CommonJS Package Registry specification.
|
|
86
|
-
* @default "Looks at any registry urls in the .npmrc file or fallback to the default npm registry instead"
|
|
87
|
-
* @example <caption>.npmrc</caption>
|
|
88
|
-
* registry = 'https://custom-registry.com/'
|
|
89
|
-
* @pkgscope:registry = 'https://custom-registry.com/'
|
|
90
|
-
*/
|
|
91
|
-
readonly registryUrl?: string;
|
|
92
|
-
/**
|
|
93
|
-
* Set of options to be passed down to Node.js http/https request.
|
|
94
|
-
* @example <caption>Behind a proxy with self-signed certificate</caption>
|
|
95
|
-
* { ca: [ fs.readFileSync('proxy-cert.pem') ] }
|
|
96
|
-
* @example <caption>Bypassing certificate validation</caption>
|
|
97
|
-
* { rejectUnauthorized: false }
|
|
98
|
-
*/
|
|
99
|
-
readonly requestOptions?: RequestOptions;
|
|
100
|
-
}
|
|
101
|
-
interface LatestVersion {
|
|
102
|
-
/**
|
|
103
|
-
* Get latest versions of packages from of a package json like object.
|
|
104
|
-
* @param {PackageJson} item - A package json like object (with dependencies, devDependencies and peerDependencies attributes).
|
|
105
|
-
* @example { dependencies: { 'npm': 'latest' }, devDependencies: { 'npm': '1.3.2' }, peerDependencies: { '@scope/name': '^5.0.2' } }
|
|
106
|
-
* @param {LatestVersionOptions} [options] - An object optionally specifying the use of the cache, the max age of the cache, the registry url and the http or https options.
|
|
107
|
-
* If `useCache` is not supplied, the default of `false` is used.
|
|
108
|
-
* If `cacheMaxAge` is not supplied, the default of `one day` is used.
|
|
109
|
-
* If `registryUrl` is not supplied, the default from `.npmrc` is used or a fallback to the `npm registry url` instead.
|
|
110
|
-
* @returns {Promise<LatestVersionPackage[]>}
|
|
111
|
-
*/
|
|
112
|
-
(item: PackageJson, options?: LatestVersionOptions): Promise<LatestVersionPackage[]>;
|
|
113
|
-
/**
|
|
114
|
-
* Get latest version of a single package.
|
|
115
|
-
* @param {Package} item - A single package object (represented by a string that should match the following format: `${'@' | ''}${string}@${string}`)
|
|
116
|
-
* @example 'npm', 'npm@1.3.2', '@scope/name@^5.0.2'
|
|
117
|
-
* @param {LatestVersionOptions} [options] - An object optionally specifying the use of the cache, the max age of the cache, the registry url and the http or https options.
|
|
118
|
-
* If `useCache` is not supplied, the default of `false` is used.
|
|
119
|
-
* If `cacheMaxAge` is not supplied, the default of `one day` is used.
|
|
120
|
-
* If `registryUrl` is not supplied, the default from `.npmrc` is used or a fallback to the npm registry url instead.
|
|
121
|
-
* @returns {Promise<LatestVersionPackage>}
|
|
122
|
-
*/
|
|
123
|
-
(item: Package, options?: LatestVersionOptions): Promise<LatestVersionPackage>;
|
|
124
|
-
/**
|
|
125
|
-
* Get latest versions of a collection of packages.
|
|
126
|
-
* @param {Package[]} items - A collection of package object (represented by a string that should match the following format: `${'@' | ''}${string}@${string}`)
|
|
127
|
-
* @example ['npm', 'npm@1.3.2', '@scope/name@^5.0.2']
|
|
128
|
-
* @param {LatestVersionOptions} [options] - An object optionally specifying the use of the cache, the max age of the cache, the registry url and the http or https options.
|
|
129
|
-
* If `useCache` is not supplied, the default of `false` is used.
|
|
130
|
-
* If `cacheMaxAge` is not supplied, the default of `one day` is used.
|
|
131
|
-
* If `registryUrl` is not supplied, the default from `.npmrc` is used or a fallback to the npm registry url instead.
|
|
132
|
-
* @returns {Promise<LatestVersionPackage[]>}
|
|
133
|
-
*/
|
|
134
|
-
(items: Package[], options?: LatestVersionOptions): Promise<LatestVersionPackage[]>;
|
|
135
|
-
}
|
|
136
|
-
type PackageRange = `${'@' | ''}${string}@${string}`;
|
|
137
|
-
type Package = PackageRange | string;
|
|
138
|
-
type PackageJsonDependencies = Record<string, string>;
|
|
139
|
-
type PackageJson = Record<string, any> & ({
|
|
140
|
-
dependencies: PackageJsonDependencies;
|
|
141
|
-
} | {
|
|
142
|
-
devDependencies: PackageJsonDependencies;
|
|
143
|
-
} | {
|
|
144
|
-
peerDependencies: PackageJsonDependencies;
|
|
145
|
-
});
|
|
146
|
-
export declare const ONE_DAY: number;
|
|
147
|
-
declare const latestVersion: LatestVersion;
|
|
148
|
-
export type { LatestVersion, LatestVersionOptions, LatestVersionPackage, Package, PackageJson, PackageJsonDependencies, PackageRange, RegistryVersions, RequestOptions, };
|
|
149
|
-
export default latestVersion;
|