@hot-updater/plugin-core 0.16.5 → 0.16.7-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/dist/ConfigBuilder.d.ts +40 -0
- package/dist/ConfigBuilder.spec.d.ts +1 -0
- package/dist/index.cjs +133 -47
- package/dist/index.d.ts +1 -0
- package/dist/index.js +131 -48
- package/package.json +2 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type BuildType = "bare" | "rnef" | "expo";
|
|
2
|
+
export type ImportInfo = {
|
|
3
|
+
pkg: string;
|
|
4
|
+
named?: string[];
|
|
5
|
+
defaultOrNamespace?: string;
|
|
6
|
+
sideEffect?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ProviderConfig = {
|
|
9
|
+
imports: ImportInfo[];
|
|
10
|
+
configString: string;
|
|
11
|
+
};
|
|
12
|
+
export interface IConfigBuilder {
|
|
13
|
+
/** Sets the build type ('bare' or 'rnef' or 'expo') and adds necessary build imports. */
|
|
14
|
+
setBuildType(buildType: BuildType): this;
|
|
15
|
+
/** Sets the storage configuration and adds its required imports. */
|
|
16
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
17
|
+
/** Sets the database configuration and adds its required imports. */
|
|
18
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
19
|
+
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
20
|
+
setIntermediateCode(code: string): this;
|
|
21
|
+
/** Assembles and returns the final configuration string. */
|
|
22
|
+
getResult(): string;
|
|
23
|
+
}
|
|
24
|
+
export declare class ConfigBuilder implements IConfigBuilder {
|
|
25
|
+
private buildType;
|
|
26
|
+
private storageInfo;
|
|
27
|
+
private databaseInfo;
|
|
28
|
+
private intermediateCode;
|
|
29
|
+
private collectedImports;
|
|
30
|
+
constructor();
|
|
31
|
+
addImport(info: ImportInfo): this;
|
|
32
|
+
private addImports;
|
|
33
|
+
private generateImportStatements;
|
|
34
|
+
private generateBuildConfigString;
|
|
35
|
+
setBuildType(buildType: BuildType): this;
|
|
36
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
37
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
38
|
+
setIntermediateCode(code: string): this;
|
|
39
|
+
getResult(): string;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -22571,51 +22571,6 @@ var __webpack_modules__ = {
|
|
|
22571
22571
|
parseUrl.MAX_INPUT_LENGTH = 2048;
|
|
22572
22572
|
module.exports = parseUrl;
|
|
22573
22573
|
},
|
|
22574
|
-
"../../node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
22575
|
-
let tty = __webpack_require__("tty");
|
|
22576
|
-
let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || "win32" === process.platform || tty.isatty(1) && "dumb" !== process.env.TERM || "CI" in process.env);
|
|
22577
|
-
let formatter = (open, close, replace = open)=>(input)=>{
|
|
22578
|
-
let string = "" + input;
|
|
22579
|
-
let index = string.indexOf(close, open.length);
|
|
22580
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
22581
|
-
};
|
|
22582
|
-
let replaceClose = (string, close, replace, index)=>{
|
|
22583
|
-
let start = string.substring(0, index) + replace;
|
|
22584
|
-
let end = string.substring(index + close.length);
|
|
22585
|
-
let nextIndex = end.indexOf(close);
|
|
22586
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
|
|
22587
|
-
};
|
|
22588
|
-
let createColors = (enabled = isColorSupported)=>({
|
|
22589
|
-
isColorSupported: enabled,
|
|
22590
|
-
reset: enabled ? (s)=>`\x1b[0m${s}\x1b[0m` : String,
|
|
22591
|
-
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
22592
|
-
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
22593
|
-
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
22594
|
-
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
22595
|
-
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
22596
|
-
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
22597
|
-
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
22598
|
-
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
22599
|
-
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
22600
|
-
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
22601
|
-
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
22602
|
-
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
22603
|
-
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
22604
|
-
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
22605
|
-
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
22606
|
-
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
22607
|
-
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
22608
|
-
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
22609
|
-
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
22610
|
-
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
22611
|
-
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
22612
|
-
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
22613
|
-
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
22614
|
-
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String
|
|
22615
|
-
});
|
|
22616
|
-
module.exports = createColors();
|
|
22617
|
-
module.exports.createColors = createColors;
|
|
22618
|
-
},
|
|
22619
22574
|
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js": function(module) {
|
|
22620
22575
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
22621
22576
|
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
|
|
@@ -83686,12 +83641,13 @@ var __webpack_exports__ = {};
|
|
|
83686
83641
|
printBanner: ()=>printBanner,
|
|
83687
83642
|
link: ()=>banner_link,
|
|
83688
83643
|
createBlobDatabasePlugin: ()=>createBlobDatabasePlugin,
|
|
83644
|
+
ConfigBuilder: ()=>ConfigBuilder,
|
|
83689
83645
|
createZip: ()=>createZip,
|
|
83690
83646
|
getCwd: ()=>getCwd,
|
|
83691
83647
|
transformTsEnv: ()=>transformTsEnv,
|
|
83692
83648
|
loadConfigSync: ()=>loadConfigSync
|
|
83693
83649
|
});
|
|
83694
|
-
var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.
|
|
83650
|
+
var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
83695
83651
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
83696
83652
|
const log = {
|
|
83697
83653
|
normal: (message)=>console.log(message),
|
|
@@ -83838,7 +83794,11 @@ var __webpack_exports__ = {};
|
|
|
83838
83794
|
}
|
|
83839
83795
|
const external_node_process_namespaceObject = require("node:process");
|
|
83840
83796
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
83841
|
-
const
|
|
83797
|
+
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
83798
|
+
const pattern = [
|
|
83799
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
83800
|
+
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
|
|
83801
|
+
].join('|');
|
|
83842
83802
|
return new RegExp(pattern, onlyFirst ? void 0 : 'g');
|
|
83843
83803
|
}
|
|
83844
83804
|
const regex = ansiRegex();
|
|
@@ -85607,7 +85567,132 @@ var __webpack_exports__ = {};
|
|
|
85607
85567
|
}
|
|
85608
85568
|
}, hooks);
|
|
85609
85569
|
};
|
|
85570
|
+
class ConfigBuilder {
|
|
85571
|
+
buildType = null;
|
|
85572
|
+
storageInfo = null;
|
|
85573
|
+
databaseInfo = null;
|
|
85574
|
+
intermediateCode = "";
|
|
85575
|
+
collectedImports = new Map();
|
|
85576
|
+
constructor(){
|
|
85577
|
+
this.addImport({
|
|
85578
|
+
pkg: "dotenv/config",
|
|
85579
|
+
sideEffect: true
|
|
85580
|
+
});
|
|
85581
|
+
this.addImport({
|
|
85582
|
+
pkg: "hot-updater",
|
|
85583
|
+
named: [
|
|
85584
|
+
"defineConfig"
|
|
85585
|
+
]
|
|
85586
|
+
});
|
|
85587
|
+
}
|
|
85588
|
+
addImport(info) {
|
|
85589
|
+
const pkg = info.pkg;
|
|
85590
|
+
const existing = this.collectedImports.get(pkg);
|
|
85591
|
+
if (existing) {
|
|
85592
|
+
if (info.named) for (const n of info.named)existing.named.add(n);
|
|
85593
|
+
if (info.defaultOrNamespace && !existing.defaultOrNamespace) existing.defaultOrNamespace = info.defaultOrNamespace;
|
|
85594
|
+
if (info.sideEffect && !existing.sideEffect) existing.sideEffect = true;
|
|
85595
|
+
} else this.collectedImports.set(pkg, {
|
|
85596
|
+
named: new Set(info.named ?? []),
|
|
85597
|
+
defaultOrNamespace: info.defaultOrNamespace,
|
|
85598
|
+
sideEffect: info.sideEffect ?? false
|
|
85599
|
+
});
|
|
85600
|
+
return this;
|
|
85601
|
+
}
|
|
85602
|
+
addImports(imports) {
|
|
85603
|
+
for (const imp of imports)this.addImport(imp);
|
|
85604
|
+
}
|
|
85605
|
+
generateImportStatements() {
|
|
85606
|
+
const importLines = [];
|
|
85607
|
+
const sortedPackages = Array.from(this.collectedImports.keys()).sort((a, b)=>{
|
|
85608
|
+
const isABuild = a.startsWith("@hot-updater/");
|
|
85609
|
+
const isBBuild = b.startsWith("@hot-updater/");
|
|
85610
|
+
if (isABuild !== isBBuild) return isABuild ? -1 : 1;
|
|
85611
|
+
if ("dotenv/config" === a) return -1;
|
|
85612
|
+
if ("dotenv/config" === b) return 1;
|
|
85613
|
+
const isAdminA = "firebase-admin" === a;
|
|
85614
|
+
const isAdminB = "firebase-admin" === b;
|
|
85615
|
+
if (isAdminA !== isAdminB) return isAdminA ? -1 : 1;
|
|
85616
|
+
return a.localeCompare(b);
|
|
85617
|
+
});
|
|
85618
|
+
for (const pkg of sortedPackages){
|
|
85619
|
+
const info = this.collectedImports.get(pkg);
|
|
85620
|
+
if (info.sideEffect) importLines.push(`import "${pkg}";`);
|
|
85621
|
+
else if (info.defaultOrNamespace) if ("firebase-admin" === pkg && info.named.size > 0) importLines.push(`import ${info.defaultOrNamespace}, { ${Array.from(info.named).sort().join(", ")} } from "${pkg}";`);
|
|
85622
|
+
else importLines.push(`import ${info.defaultOrNamespace} from "${pkg}";`);
|
|
85623
|
+
else if (info.named.size > 0) {
|
|
85624
|
+
const namedPart = Array.from(info.named).sort().join(", ");
|
|
85625
|
+
importLines.push(`import { ${namedPart} } from "${pkg}";`);
|
|
85626
|
+
}
|
|
85627
|
+
}
|
|
85628
|
+
return importLines.join("\n");
|
|
85629
|
+
}
|
|
85630
|
+
generateBuildConfigString() {
|
|
85631
|
+
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
85632
|
+
switch(this.buildType){
|
|
85633
|
+
case "bare":
|
|
85634
|
+
return "bare({ enableHermes: true })";
|
|
85635
|
+
case "rnef":
|
|
85636
|
+
return "rnef()";
|
|
85637
|
+
case "expo":
|
|
85638
|
+
return "expo()";
|
|
85639
|
+
default:
|
|
85640
|
+
throw new Error(`Invalid build type: ${this.buildType}`);
|
|
85641
|
+
}
|
|
85642
|
+
}
|
|
85643
|
+
setBuildType(buildType) {
|
|
85644
|
+
if (this.buildType) console.warn("Build type is being set multiple times. Overwriting previous value.");
|
|
85645
|
+
this.buildType = buildType;
|
|
85646
|
+
this.addImport({
|
|
85647
|
+
pkg: `@hot-updater/${buildType}`,
|
|
85648
|
+
named: [
|
|
85649
|
+
buildType
|
|
85650
|
+
]
|
|
85651
|
+
});
|
|
85652
|
+
return this;
|
|
85653
|
+
}
|
|
85654
|
+
setStorage(storageConfig) {
|
|
85655
|
+
this.storageInfo = storageConfig;
|
|
85656
|
+
this.addImports(storageConfig.imports);
|
|
85657
|
+
if (storageConfig.imports.some((imp)=>imp.pkg.includes("firebase"))) this.addImport({
|
|
85658
|
+
pkg: "firebase-admin",
|
|
85659
|
+
defaultOrNamespace: "* as admin"
|
|
85660
|
+
});
|
|
85661
|
+
return this;
|
|
85662
|
+
}
|
|
85663
|
+
setDatabase(databaseConfig) {
|
|
85664
|
+
this.databaseInfo = databaseConfig;
|
|
85665
|
+
this.addImports(databaseConfig.imports);
|
|
85666
|
+
if (databaseConfig.imports.some((imp)=>imp.pkg.includes("firebase"))) this.addImport({
|
|
85667
|
+
pkg: "firebase-admin",
|
|
85668
|
+
defaultOrNamespace: "* as admin"
|
|
85669
|
+
});
|
|
85670
|
+
return this;
|
|
85671
|
+
}
|
|
85672
|
+
setIntermediateCode(code) {
|
|
85673
|
+
this.intermediateCode = code.trim();
|
|
85674
|
+
return this;
|
|
85675
|
+
}
|
|
85676
|
+
getResult() {
|
|
85677
|
+
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
85678
|
+
if (!this.storageInfo) throw new Error("Storage config must be set using .setStorage()");
|
|
85679
|
+
if (!this.databaseInfo) throw new Error("Database config must be set using .setDatabase()");
|
|
85680
|
+
const importStatements = this.generateImportStatements();
|
|
85681
|
+
const buildConfigString = this.generateBuildConfigString();
|
|
85682
|
+
return `
|
|
85683
|
+
${importStatements}
|
|
85684
|
+
|
|
85685
|
+
${this.intermediateCode ? `${this.intermediateCode}\n` : ""}
|
|
85686
|
+
export default defineConfig({
|
|
85687
|
+
build: ${buildConfigString},
|
|
85688
|
+
storage: ${this.storageInfo.configString},
|
|
85689
|
+
database: ${this.databaseInfo.configString},
|
|
85690
|
+
});
|
|
85691
|
+
`.trim();
|
|
85692
|
+
}
|
|
85693
|
+
}
|
|
85610
85694
|
})();
|
|
85695
|
+
exports.ConfigBuilder = __webpack_exports__.ConfigBuilder;
|
|
85611
85696
|
exports.banner = __webpack_exports__.banner;
|
|
85612
85697
|
exports.copyDirToTmp = __webpack_exports__.copyDirToTmp;
|
|
85613
85698
|
exports.createBlobDatabasePlugin = __webpack_exports__.createBlobDatabasePlugin;
|
|
@@ -85625,6 +85710,7 @@ exports.transformEnv = __webpack_exports__.transformEnv;
|
|
|
85625
85710
|
exports.transformTemplate = __webpack_exports__.transformTemplate;
|
|
85626
85711
|
exports.transformTsEnv = __webpack_exports__.transformTsEnv;
|
|
85627
85712
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
85713
|
+
"ConfigBuilder",
|
|
85628
85714
|
"banner",
|
|
85629
85715
|
"copyDirToTmp",
|
|
85630
85716
|
"createBlobDatabasePlugin",
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -22429,51 +22429,6 @@ var __webpack_modules__ = {
|
|
|
22429
22429
|
parseUrl.MAX_INPUT_LENGTH = 2048;
|
|
22430
22430
|
module.exports = parseUrl;
|
|
22431
22431
|
},
|
|
22432
|
-
"../../node_modules/.pnpm/picocolors@1.0.0/node_modules/picocolors/picocolors.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
22433
|
-
let tty = __webpack_require__("tty");
|
|
22434
|
-
let isColorSupported = !("NO_COLOR" in process.env || process.argv.includes("--no-color")) && ("FORCE_COLOR" in process.env || process.argv.includes("--color") || "win32" === process.platform || tty.isatty(1) && "dumb" !== process.env.TERM || "CI" in process.env);
|
|
22435
|
-
let formatter = (open, close, replace = open)=>(input)=>{
|
|
22436
|
-
let string = "" + input;
|
|
22437
|
-
let index = string.indexOf(close, open.length);
|
|
22438
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
22439
|
-
};
|
|
22440
|
-
let replaceClose = (string, close, replace, index)=>{
|
|
22441
|
-
let start = string.substring(0, index) + replace;
|
|
22442
|
-
let end = string.substring(index + close.length);
|
|
22443
|
-
let nextIndex = end.indexOf(close);
|
|
22444
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
|
|
22445
|
-
};
|
|
22446
|
-
let createColors = (enabled = isColorSupported)=>({
|
|
22447
|
-
isColorSupported: enabled,
|
|
22448
|
-
reset: enabled ? (s)=>`\x1b[0m${s}\x1b[0m` : String,
|
|
22449
|
-
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
|
|
22450
|
-
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
|
|
22451
|
-
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
|
|
22452
|
-
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
|
|
22453
|
-
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
|
|
22454
|
-
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
|
|
22455
|
-
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
|
|
22456
|
-
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
|
|
22457
|
-
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
|
|
22458
|
-
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
|
|
22459
|
-
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
|
|
22460
|
-
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
|
|
22461
|
-
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
|
|
22462
|
-
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
|
|
22463
|
-
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
|
|
22464
|
-
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
|
|
22465
|
-
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
|
|
22466
|
-
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
|
|
22467
|
-
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
|
|
22468
|
-
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
|
|
22469
|
-
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
|
|
22470
|
-
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
|
|
22471
|
-
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
|
|
22472
|
-
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String
|
|
22473
|
-
});
|
|
22474
|
-
module.exports = createColors();
|
|
22475
|
-
module.exports.createColors = createColors;
|
|
22476
|
-
},
|
|
22477
22432
|
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js": function(module) {
|
|
22478
22433
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
22479
22434
|
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
|
|
@@ -83203,7 +83158,7 @@ function __webpack_require__(moduleId) {
|
|
|
83203
83158
|
(()=>{
|
|
83204
83159
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
83205
83160
|
})();
|
|
83206
|
-
var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.
|
|
83161
|
+
var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
83207
83162
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
83208
83163
|
const log = {
|
|
83209
83164
|
normal: (message)=>console.log(message),
|
|
@@ -83345,7 +83300,11 @@ function createDatabasePlugin(name, abstractPlugin, hooks) {
|
|
|
83345
83300
|
});
|
|
83346
83301
|
}
|
|
83347
83302
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
83348
|
-
const
|
|
83303
|
+
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
83304
|
+
const pattern = [
|
|
83305
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
83306
|
+
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))'
|
|
83307
|
+
].join('|');
|
|
83349
83308
|
return new RegExp(pattern, onlyFirst ? void 0 : 'g');
|
|
83350
83309
|
}
|
|
83351
83310
|
const regex = ansiRegex();
|
|
@@ -85111,4 +85070,128 @@ const createBlobDatabasePlugin = ({ name, listObjects, loadObject, uploadObject,
|
|
|
85111
85070
|
}
|
|
85112
85071
|
}, hooks);
|
|
85113
85072
|
};
|
|
85114
|
-
|
|
85073
|
+
class ConfigBuilder {
|
|
85074
|
+
buildType = null;
|
|
85075
|
+
storageInfo = null;
|
|
85076
|
+
databaseInfo = null;
|
|
85077
|
+
intermediateCode = "";
|
|
85078
|
+
collectedImports = new Map();
|
|
85079
|
+
constructor(){
|
|
85080
|
+
this.addImport({
|
|
85081
|
+
pkg: "dotenv/config",
|
|
85082
|
+
sideEffect: true
|
|
85083
|
+
});
|
|
85084
|
+
this.addImport({
|
|
85085
|
+
pkg: "hot-updater",
|
|
85086
|
+
named: [
|
|
85087
|
+
"defineConfig"
|
|
85088
|
+
]
|
|
85089
|
+
});
|
|
85090
|
+
}
|
|
85091
|
+
addImport(info) {
|
|
85092
|
+
const pkg = info.pkg;
|
|
85093
|
+
const existing = this.collectedImports.get(pkg);
|
|
85094
|
+
if (existing) {
|
|
85095
|
+
if (info.named) for (const n of info.named)existing.named.add(n);
|
|
85096
|
+
if (info.defaultOrNamespace && !existing.defaultOrNamespace) existing.defaultOrNamespace = info.defaultOrNamespace;
|
|
85097
|
+
if (info.sideEffect && !existing.sideEffect) existing.sideEffect = true;
|
|
85098
|
+
} else this.collectedImports.set(pkg, {
|
|
85099
|
+
named: new Set(info.named ?? []),
|
|
85100
|
+
defaultOrNamespace: info.defaultOrNamespace,
|
|
85101
|
+
sideEffect: info.sideEffect ?? false
|
|
85102
|
+
});
|
|
85103
|
+
return this;
|
|
85104
|
+
}
|
|
85105
|
+
addImports(imports) {
|
|
85106
|
+
for (const imp of imports)this.addImport(imp);
|
|
85107
|
+
}
|
|
85108
|
+
generateImportStatements() {
|
|
85109
|
+
const importLines = [];
|
|
85110
|
+
const sortedPackages = Array.from(this.collectedImports.keys()).sort((a, b)=>{
|
|
85111
|
+
const isABuild = a.startsWith("@hot-updater/");
|
|
85112
|
+
const isBBuild = b.startsWith("@hot-updater/");
|
|
85113
|
+
if (isABuild !== isBBuild) return isABuild ? -1 : 1;
|
|
85114
|
+
if ("dotenv/config" === a) return -1;
|
|
85115
|
+
if ("dotenv/config" === b) return 1;
|
|
85116
|
+
const isAdminA = "firebase-admin" === a;
|
|
85117
|
+
const isAdminB = "firebase-admin" === b;
|
|
85118
|
+
if (isAdminA !== isAdminB) return isAdminA ? -1 : 1;
|
|
85119
|
+
return a.localeCompare(b);
|
|
85120
|
+
});
|
|
85121
|
+
for (const pkg of sortedPackages){
|
|
85122
|
+
const info = this.collectedImports.get(pkg);
|
|
85123
|
+
if (info.sideEffect) importLines.push(`import "${pkg}";`);
|
|
85124
|
+
else if (info.defaultOrNamespace) if ("firebase-admin" === pkg && info.named.size > 0) importLines.push(`import ${info.defaultOrNamespace}, { ${Array.from(info.named).sort().join(", ")} } from "${pkg}";`);
|
|
85125
|
+
else importLines.push(`import ${info.defaultOrNamespace} from "${pkg}";`);
|
|
85126
|
+
else if (info.named.size > 0) {
|
|
85127
|
+
const namedPart = Array.from(info.named).sort().join(", ");
|
|
85128
|
+
importLines.push(`import { ${namedPart} } from "${pkg}";`);
|
|
85129
|
+
}
|
|
85130
|
+
}
|
|
85131
|
+
return importLines.join("\n");
|
|
85132
|
+
}
|
|
85133
|
+
generateBuildConfigString() {
|
|
85134
|
+
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
85135
|
+
switch(this.buildType){
|
|
85136
|
+
case "bare":
|
|
85137
|
+
return "bare({ enableHermes: true })";
|
|
85138
|
+
case "rnef":
|
|
85139
|
+
return "rnef()";
|
|
85140
|
+
case "expo":
|
|
85141
|
+
return "expo()";
|
|
85142
|
+
default:
|
|
85143
|
+
throw new Error(`Invalid build type: ${this.buildType}`);
|
|
85144
|
+
}
|
|
85145
|
+
}
|
|
85146
|
+
setBuildType(buildType) {
|
|
85147
|
+
if (this.buildType) console.warn("Build type is being set multiple times. Overwriting previous value.");
|
|
85148
|
+
this.buildType = buildType;
|
|
85149
|
+
this.addImport({
|
|
85150
|
+
pkg: `@hot-updater/${buildType}`,
|
|
85151
|
+
named: [
|
|
85152
|
+
buildType
|
|
85153
|
+
]
|
|
85154
|
+
});
|
|
85155
|
+
return this;
|
|
85156
|
+
}
|
|
85157
|
+
setStorage(storageConfig) {
|
|
85158
|
+
this.storageInfo = storageConfig;
|
|
85159
|
+
this.addImports(storageConfig.imports);
|
|
85160
|
+
if (storageConfig.imports.some((imp)=>imp.pkg.includes("firebase"))) this.addImport({
|
|
85161
|
+
pkg: "firebase-admin",
|
|
85162
|
+
defaultOrNamespace: "* as admin"
|
|
85163
|
+
});
|
|
85164
|
+
return this;
|
|
85165
|
+
}
|
|
85166
|
+
setDatabase(databaseConfig) {
|
|
85167
|
+
this.databaseInfo = databaseConfig;
|
|
85168
|
+
this.addImports(databaseConfig.imports);
|
|
85169
|
+
if (databaseConfig.imports.some((imp)=>imp.pkg.includes("firebase"))) this.addImport({
|
|
85170
|
+
pkg: "firebase-admin",
|
|
85171
|
+
defaultOrNamespace: "* as admin"
|
|
85172
|
+
});
|
|
85173
|
+
return this;
|
|
85174
|
+
}
|
|
85175
|
+
setIntermediateCode(code) {
|
|
85176
|
+
this.intermediateCode = code.trim();
|
|
85177
|
+
return this;
|
|
85178
|
+
}
|
|
85179
|
+
getResult() {
|
|
85180
|
+
if (!this.buildType) throw new Error("Build type must be set using .setBuildType()");
|
|
85181
|
+
if (!this.storageInfo) throw new Error("Storage config must be set using .setStorage()");
|
|
85182
|
+
if (!this.databaseInfo) throw new Error("Database config must be set using .setDatabase()");
|
|
85183
|
+
const importStatements = this.generateImportStatements();
|
|
85184
|
+
const buildConfigString = this.generateBuildConfigString();
|
|
85185
|
+
return `
|
|
85186
|
+
${importStatements}
|
|
85187
|
+
|
|
85188
|
+
${this.intermediateCode ? `${this.intermediateCode}\n` : ""}
|
|
85189
|
+
export default defineConfig({
|
|
85190
|
+
build: ${buildConfigString},
|
|
85191
|
+
storage: ${this.storageInfo.configString},
|
|
85192
|
+
database: ${this.databaseInfo.configString},
|
|
85193
|
+
});
|
|
85194
|
+
`.trim();
|
|
85195
|
+
}
|
|
85196
|
+
}
|
|
85197
|
+
export { ConfigBuilder, banner, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createZip, createZipTargetFiles, getCwd, banner_link as link, loadConfig, loadConfigSync, log, makeEnv, printBanner, transformEnv, transformTemplate, transformTsEnv };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/plugin-core",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.7-0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"cosmiconfig": "9.0.0",
|
|
42
42
|
"cosmiconfig-typescript-loader": "5.0.0",
|
|
43
43
|
"ts-morph": "25.0.1",
|
|
44
|
-
"@hot-updater/core": "0.16.
|
|
44
|
+
"@hot-updater/core": "0.16.7-0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@babel/core": "7.26.0",
|