@hot-updater/plugin-core 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Sungyu Kang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ getCwd: () => getCwd,
34
+ loadConfig: () => loadConfig,
35
+ log: () => log
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+
39
+ // src/log.ts
40
+ var import_picocolors = __toESM(require("picocolors"), 1);
41
+ var log = {
42
+ normal: (message) => console.log(message),
43
+ success: (message) => console.log(import_picocolors.default.green(message)),
44
+ info: (message) => console.log(import_picocolors.default.blue(message)),
45
+ error: (message) => console.log(import_picocolors.default.red(message)),
46
+ warn: (message) => console.log(import_picocolors.default.yellow(message)),
47
+ debug: (message) => console.log(import_picocolors.default.gray(message))
48
+ };
49
+
50
+ // src/cwd.ts
51
+ var import_workspace_tools = require("workspace-tools");
52
+ var getCwd = () => (0, import_workspace_tools.findPackageRoot)(process.cwd());
53
+
54
+ // src/loadConfig.ts
55
+ var import_cosmiconfig = require("cosmiconfig");
56
+ var import_cosmiconfig_typescript_loader = require("cosmiconfig-typescript-loader");
57
+ var loadConfig = async () => {
58
+ const result = await (0, import_cosmiconfig.cosmiconfig)("hot-updater", {
59
+ stopDir: getCwd(),
60
+ searchPlaces: [
61
+ "hot-updater.config.js",
62
+ "hot-updater.config.cjs",
63
+ "hot-updater.config.ts",
64
+ "hot-updater.config.cts",
65
+ "hot-updater.config.mjs",
66
+ "hot-updater.config.cjs"
67
+ ],
68
+ ignoreEmptySearchPlaces: false,
69
+ loaders: {
70
+ ".ts": (0, import_cosmiconfig_typescript_loader.TypeScriptLoader)(),
71
+ ".mts": (0, import_cosmiconfig_typescript_loader.TypeScriptLoader)(),
72
+ ".cts": (0, import_cosmiconfig_typescript_loader.TypeScriptLoader)()
73
+ }
74
+ }).search();
75
+ if (!result?.config) {
76
+ return null;
77
+ }
78
+ return result.config;
79
+ };
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ getCwd,
83
+ loadConfig,
84
+ log
85
+ });
@@ -0,0 +1,44 @@
1
+ import { Platform, UpdateSource } from '@hot-updater/utils';
2
+ export { Platform, UpdateSource } from '@hot-updater/utils';
3
+
4
+ declare const log: {
5
+ normal: (message: string | number | null | undefined) => void;
6
+ success: (message: string | number | null | undefined) => void;
7
+ info: (message: string | number | null | undefined) => void;
8
+ error: (message: string | number | null | undefined) => void;
9
+ warn: (message: string | number | null | undefined) => void;
10
+ debug: (message: string | number | null | undefined) => void;
11
+ };
12
+
13
+ declare const getCwd: () => string;
14
+
15
+ interface BasePluginArgs {
16
+ cwd: string;
17
+ }
18
+ interface BuildPluginArgs extends BasePluginArgs {
19
+ platform: Platform;
20
+ }
21
+ interface DeployPlugin {
22
+ getUpdateSources: (refresh?: boolean) => Promise<UpdateSource[]>;
23
+ updateUpdateSource: (targetBundleVersion: number, newSource: Partial<UpdateSource>) => Promise<void>;
24
+ setUpdateSources: (sources: UpdateSource[]) => Promise<void>;
25
+ appendUpdateSource: (source: UpdateSource) => Promise<void>;
26
+ commitUpdateSource: () => Promise<void>;
27
+ uploadBundle: (platform: Platform, bundleVersion: number, bundlePath: string) => Promise<{
28
+ file: string;
29
+ }>;
30
+ deleteBundle: (platform: Platform, bundleVersion: number) => Promise<string>;
31
+ }
32
+ type Config = {
33
+ server: string;
34
+ secretKey: string;
35
+ build: (args: BuildPluginArgs) => Promise<{
36
+ buildPath: string;
37
+ outputs: string[];
38
+ }>;
39
+ deploy: (args: BasePluginArgs) => DeployPlugin;
40
+ };
41
+
42
+ declare const loadConfig: () => Promise<Config | null>;
43
+
44
+ export { type BasePluginArgs, type BuildPluginArgs, type Config, type DeployPlugin, getCwd, loadConfig, log };
@@ -0,0 +1,44 @@
1
+ import { Platform, UpdateSource } from '@hot-updater/utils';
2
+ export { Platform, UpdateSource } from '@hot-updater/utils';
3
+
4
+ declare const log: {
5
+ normal: (message: string | number | null | undefined) => void;
6
+ success: (message: string | number | null | undefined) => void;
7
+ info: (message: string | number | null | undefined) => void;
8
+ error: (message: string | number | null | undefined) => void;
9
+ warn: (message: string | number | null | undefined) => void;
10
+ debug: (message: string | number | null | undefined) => void;
11
+ };
12
+
13
+ declare const getCwd: () => string;
14
+
15
+ interface BasePluginArgs {
16
+ cwd: string;
17
+ }
18
+ interface BuildPluginArgs extends BasePluginArgs {
19
+ platform: Platform;
20
+ }
21
+ interface DeployPlugin {
22
+ getUpdateSources: (refresh?: boolean) => Promise<UpdateSource[]>;
23
+ updateUpdateSource: (targetBundleVersion: number, newSource: Partial<UpdateSource>) => Promise<void>;
24
+ setUpdateSources: (sources: UpdateSource[]) => Promise<void>;
25
+ appendUpdateSource: (source: UpdateSource) => Promise<void>;
26
+ commitUpdateSource: () => Promise<void>;
27
+ uploadBundle: (platform: Platform, bundleVersion: number, bundlePath: string) => Promise<{
28
+ file: string;
29
+ }>;
30
+ deleteBundle: (platform: Platform, bundleVersion: number) => Promise<string>;
31
+ }
32
+ type Config = {
33
+ server: string;
34
+ secretKey: string;
35
+ build: (args: BuildPluginArgs) => Promise<{
36
+ buildPath: string;
37
+ outputs: string[];
38
+ }>;
39
+ deploy: (args: BasePluginArgs) => DeployPlugin;
40
+ };
41
+
42
+ declare const loadConfig: () => Promise<Config | null>;
43
+
44
+ export { type BasePluginArgs, type BuildPluginArgs, type Config, type DeployPlugin, getCwd, loadConfig, log };
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ // src/log.ts
2
+ import picocolors from "picocolors";
3
+ var log = {
4
+ normal: (message) => console.log(message),
5
+ success: (message) => console.log(picocolors.green(message)),
6
+ info: (message) => console.log(picocolors.blue(message)),
7
+ error: (message) => console.log(picocolors.red(message)),
8
+ warn: (message) => console.log(picocolors.yellow(message)),
9
+ debug: (message) => console.log(picocolors.gray(message))
10
+ };
11
+
12
+ // src/cwd.ts
13
+ import { findPackageRoot } from "workspace-tools";
14
+ var getCwd = () => findPackageRoot(process.cwd());
15
+
16
+ // src/loadConfig.ts
17
+ import { cosmiconfig } from "cosmiconfig";
18
+ import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
19
+ var loadConfig = async () => {
20
+ const result = await cosmiconfig("hot-updater", {
21
+ stopDir: getCwd(),
22
+ searchPlaces: [
23
+ "hot-updater.config.js",
24
+ "hot-updater.config.cjs",
25
+ "hot-updater.config.ts",
26
+ "hot-updater.config.cts",
27
+ "hot-updater.config.mjs",
28
+ "hot-updater.config.cjs"
29
+ ],
30
+ ignoreEmptySearchPlaces: false,
31
+ loaders: {
32
+ ".ts": TypeScriptLoader(),
33
+ ".mts": TypeScriptLoader(),
34
+ ".cts": TypeScriptLoader()
35
+ }
36
+ }).search();
37
+ if (!result?.config) {
38
+ return null;
39
+ }
40
+ return result.config;
41
+ };
42
+ export {
43
+ getCwd,
44
+ loadConfig,
45
+ log
46
+ };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@hot-updater/plugin-core",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "React Native OTA solution for self-hosted",
6
+ "sideEffects": false,
7
+ "main": "dist/index.cjs",
8
+ "module": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "package.json"
19
+ ],
20
+ "keywords": [
21
+ "react-native",
22
+ "react-native-code-push",
23
+ "code-push",
24
+ "eas",
25
+ "eas-update",
26
+ "expo",
27
+ "expo-update",
28
+ "self-hosted"
29
+ ],
30
+ "license": "MIT",
31
+ "repository": "https://github.com/gronxb/hot-updater",
32
+ "author": "gronxb <gron1gh1@gmail.com> (https://github.com/gronxb)",
33
+ "bugs": {
34
+ "url": "https://github.com/gronxb/hot-updater/issues"
35
+ },
36
+ "homepage": "https://github.com/gronxb/hot-updater#readme",
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "dependencies": {
41
+ "@hot-updater/utils": "0.1.0",
42
+ "cosmiconfig": "^9.0.0",
43
+ "cosmiconfig-typescript-loader": "^5.0.0",
44
+ "picocolors": "^1.0.0",
45
+ "workspace-tools": "^0.36.4"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.7.5"
49
+ },
50
+ "scripts": {
51
+ "build": "tsup src/index.ts --format cjs,esm --dts",
52
+ "test:type": "tsc --noEmit"
53
+ }
54
+ }