@hot-updater/cli-tools 1.0.2 → 1.0.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/dist/index.mjs +45 -30
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -45048,64 +45048,72 @@ function isUnsafeProperty(key) {
|
|
|
45048
45048
|
return key === "__proto__";
|
|
45049
45049
|
}
|
|
45050
45050
|
//#endregion
|
|
45051
|
-
//#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/object/
|
|
45051
|
+
//#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/object/mergeWith.mjs
|
|
45052
45052
|
/**
|
|
45053
45053
|
* Merges the properties of the source object into the target object.
|
|
45054
45054
|
*
|
|
45055
|
-
*
|
|
45056
|
-
*
|
|
45057
|
-
* If
|
|
45055
|
+
* You can provide a custom `merge` function to control how properties are merged. It should return the value to be set in the target object.
|
|
45056
|
+
*
|
|
45057
|
+
* If it returns `undefined`, a default deep merge will be applied for arrays and objects:
|
|
45058
|
+
*
|
|
45059
|
+
* - If a property in the source object is an array or an object and the corresponding property in the target object is also an array or object, they will be merged.
|
|
45060
|
+
* - If a property in the source object is undefined, it will not overwrite a defined property in the target object.
|
|
45058
45061
|
*
|
|
45059
45062
|
* Note that this function mutates the target object.
|
|
45060
45063
|
*
|
|
45061
45064
|
* @param {T} target - The target object into which the source object properties will be merged. This object is modified in place.
|
|
45062
45065
|
* @param {S} source - The source object whose properties will be merged into the target object.
|
|
45066
|
+
* @param {(targetValue: any, sourceValue: any, key: string, target: T, source: S) => any} merge - A custom merge function that defines how properties should be combined. It receives the following arguments:
|
|
45067
|
+
* - `targetValue`: The current value of the property in the target object.
|
|
45068
|
+
* - `sourceValue`: The value of the property in the source object.
|
|
45069
|
+
* - `key`: The key of the property being merged.
|
|
45070
|
+
* - `target`: The target object.
|
|
45071
|
+
* - `source`: The source object.
|
|
45072
|
+
*
|
|
45063
45073
|
* @returns {T & S} The updated target object with properties from the source object merged in.
|
|
45064
45074
|
*
|
|
45065
45075
|
* @template T - Type of the target object.
|
|
45066
45076
|
* @template S - Type of the source object.
|
|
45067
45077
|
*
|
|
45068
45078
|
* @example
|
|
45069
|
-
* const target = { a: 1, b:
|
|
45070
|
-
* const source = { b:
|
|
45071
|
-
*
|
|
45072
|
-
* const result = merge(target, source);
|
|
45073
|
-
* console.log(result);
|
|
45074
|
-
* // Output: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 5 }
|
|
45079
|
+
* const target = { a: 1, b: 2 };
|
|
45080
|
+
* const source = { b: 3, c: 4 };
|
|
45075
45081
|
*
|
|
45082
|
+
* mergeWith(target, source, (targetValue, sourceValue) => {
|
|
45083
|
+
* if (typeof targetValue === 'number' && typeof sourceValue === 'number') {
|
|
45084
|
+
* return targetValue + sourceValue;
|
|
45085
|
+
* }
|
|
45086
|
+
* });
|
|
45087
|
+
* // Returns { a: 1, b: 5, c: 4 }
|
|
45076
45088
|
* @example
|
|
45077
|
-
* const target = { a: [1
|
|
45078
|
-
* const source = { a: [3], b:
|
|
45089
|
+
* const target = { a: [1], b: [2] };
|
|
45090
|
+
* const source = { a: [3], b: [4] };
|
|
45079
45091
|
*
|
|
45080
|
-
* const result =
|
|
45081
|
-
*
|
|
45082
|
-
*
|
|
45092
|
+
* const result = mergeWith(target, source, (objValue, srcValue) => {
|
|
45093
|
+
* if (Array.isArray(objValue)) {
|
|
45094
|
+
* return objValue.concat(srcValue);
|
|
45095
|
+
* }
|
|
45096
|
+
* });
|
|
45083
45097
|
*
|
|
45084
|
-
*
|
|
45085
|
-
* const target = { a: null };
|
|
45086
|
-
* const source = { a: [1, 2, 3] };
|
|
45087
|
-
*
|
|
45088
|
-
* const result = merge(target, source);
|
|
45089
|
-
* console.log(result);
|
|
45090
|
-
* // Output: { a: [1, 2, 3] }
|
|
45098
|
+
* expect(result).toEqual({ a: [1, 3], b: [2, 4] });
|
|
45091
45099
|
*/
|
|
45092
|
-
function
|
|
45100
|
+
function mergeWith(target, source, merge) {
|
|
45093
45101
|
const sourceKeys = Object.keys(source);
|
|
45094
45102
|
for (let i = 0; i < sourceKeys.length; i++) {
|
|
45095
45103
|
const key = sourceKeys[i];
|
|
45096
45104
|
if (isUnsafeProperty(key)) continue;
|
|
45097
45105
|
const sourceValue = source[key];
|
|
45098
45106
|
const targetValue = target[key];
|
|
45099
|
-
|
|
45100
|
-
|
|
45101
|
-
else if (
|
|
45107
|
+
const merged = merge(targetValue, sourceValue, key, target, source);
|
|
45108
|
+
if (merged !== void 0) target[key] = merged;
|
|
45109
|
+
else if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
|
45110
|
+
else target[key] = mergeWith([], sourceValue, merge);
|
|
45111
|
+
else if (isPlainObject(sourceValue)) if (isPlainObject(targetValue)) target[key] = mergeWith(targetValue, sourceValue, merge);
|
|
45112
|
+
else target[key] = mergeWith({}, sourceValue, merge);
|
|
45102
45113
|
else if (targetValue === void 0 || sourceValue !== void 0) target[key] = sourceValue;
|
|
45103
45114
|
}
|
|
45104
45115
|
return target;
|
|
45105
45116
|
}
|
|
45106
|
-
function isMergeableValue(value) {
|
|
45107
|
-
return isPlainObject(value) || Array.isArray(value);
|
|
45108
|
-
}
|
|
45109
45117
|
//#endregion
|
|
45110
45118
|
//#region src/loadConfig.ts
|
|
45111
45119
|
var import_out = /* @__PURE__ */ __toESM(require_out(), 1);
|
|
@@ -45162,8 +45170,15 @@ const getDefaultConfig = () => {
|
|
|
45162
45170
|
plugins: []
|
|
45163
45171
|
};
|
|
45164
45172
|
};
|
|
45173
|
+
/**
|
|
45174
|
+
* An array in the config replaces the default one. A plain deep merge goes
|
|
45175
|
+
* index by index, so `infoPlistPaths: ["ios/App/Info.plist"]` over three
|
|
45176
|
+
* discovered Info.plist files only overwrote the first and kept the others.
|
|
45177
|
+
* The array is still copied deeply, as `merge` copied it.
|
|
45178
|
+
*/
|
|
45179
|
+
const replaceArrays = (_targetValue, sourceValue) => Array.isArray(sourceValue) ? mergeWith([], sourceValue, replaceArrays) : void 0;
|
|
45165
45180
|
const mergeConfigSources = (...sources) => {
|
|
45166
|
-
const mergedConfig = sources.reduceRight((mergedConfig, source) =>
|
|
45181
|
+
const mergedConfig = sources.reduceRight((mergedConfig, source) => mergeWith(mergedConfig, source ?? {}, replaceArrays), {});
|
|
45167
45182
|
const database = sources.find((source) => source?.database)?.database;
|
|
45168
45183
|
const plugins = sources.find((source) => source?.plugins)?.plugins;
|
|
45169
45184
|
const signing = sources.find((source) => source?.signing)?.signing;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/cli-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"oxc-parser": "0.141.0",
|
|
50
50
|
"oxc-transform": "0.141.0",
|
|
51
51
|
"unconfig": "7.5.0",
|
|
52
|
-
"@hot-updater/
|
|
53
|
-
"@hot-updater/
|
|
54
|
-
"@hot-updater/protocol": "1.0.
|
|
52
|
+
"@hot-updater/plugin-core": "1.0.3",
|
|
53
|
+
"@hot-updater/server": "1.0.3",
|
|
54
|
+
"@hot-updater/protocol": "1.0.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@clack/prompts": "1.7.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"tar": "^7.5.16",
|
|
66
66
|
"verkit": "0.4.0",
|
|
67
67
|
"workspace-tools": "^0.41.7",
|
|
68
|
-
"@hot-updater/test-utils": "1.0.
|
|
68
|
+
"@hot-updater/test-utils": "1.0.3"
|
|
69
69
|
},
|
|
70
70
|
"inlinedDependencies": {
|
|
71
71
|
"@babel/code-frame": "7.29.0",
|