@capgo/capacitor-env 7.0.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/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "Env",
6
+ platforms: [.iOS(.v14)],
7
+ products: [
8
+ .library(
9
+ name: "Env",
10
+ targets: ["EnvPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "EnvPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/EnvPlugin"),
23
+ .testTarget(
24
+ name: "EnvPluginTests",
25
+ dependencies: ["EnvPlugin"],
26
+ path: "ios/Tests/EnvPluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # @capgo/capacitor-env
2
+ <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
3
+
4
+ <div align="center">
5
+ <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
7
+ </div>
8
+
9
+ Set Env var in Capacitor config and read them at runtime
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @capgo/capacitor-env
15
+ npx cap sync
16
+ ```
17
+
18
+ ## API
19
+
20
+ <docgen-index>
21
+
22
+ * [`getKey(...)`](#getkey)
23
+
24
+ </docgen-index>
25
+
26
+ <docgen-api>
27
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
28
+
29
+ ### getKey(...)
30
+
31
+ ```typescript
32
+ getKey(options: { key: string; }) => Promise<{ value: string; }>
33
+ ```
34
+
35
+ | Param | Type |
36
+ | ------------- | ----------------------------- |
37
+ | **`options`** | <code>{ key: string; }</code> |
38
+
39
+ **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
40
+
41
+ --------------------
42
+
43
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.7.2'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "app.capgo.plugins.env"
22
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_21
41
+ targetCompatibility JavaVersion.VERSION_21
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,20 @@
1
+ package app.capgo.plugins.env;
2
+
3
+ import com.getcapacitor.JSObject;
4
+ import com.getcapacitor.Plugin;
5
+ import com.getcapacitor.PluginCall;
6
+ import com.getcapacitor.PluginMethod;
7
+ import com.getcapacitor.annotation.CapacitorPlugin;
8
+
9
+ @CapacitorPlugin(name = "Env")
10
+ public class EnvPlugin extends Plugin {
11
+
12
+ @PluginMethod
13
+ public void getKey(PluginCall call) {
14
+ String key = call.getString("key");
15
+
16
+ JSObject ret = new JSObject();
17
+ ret.put("value", this.getConfig().getString("publicKey", ""));
18
+ call.resolve(ret);
19
+ }
20
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "api": {
3
+ "name": "EnvPlugin",
4
+ "slug": "envplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "getKey",
10
+ "signature": "(options: { key: string; }) => Promise<{ value: string; }>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "{ key: string; }"
16
+ }
17
+ ],
18
+ "returns": "Promise<{ value: string; }>",
19
+ "tags": [],
20
+ "docs": "",
21
+ "complexTypes": [],
22
+ "slug": "getkey"
23
+ }
24
+ ],
25
+ "properties": []
26
+ },
27
+ "interfaces": [],
28
+ "enums": [],
29
+ "typeAliases": [],
30
+ "pluginConfigs": []
31
+ }
@@ -0,0 +1,7 @@
1
+ export interface EnvPlugin {
2
+ getKey(options: {
3
+ key: string;
4
+ }): Promise<{
5
+ value: string;
6
+ }>;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface EnvPlugin {\n getKey(options: { key: string }): Promise<{ value: string }>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { EnvPlugin } from './definitions';
2
+ declare const Env: EnvPlugin;
3
+ export * from './definitions';
4
+ export { Env };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const Env = registerPlugin('Env', {
3
+ web: () => import('./web').then((m) => new m.EnvWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { Env };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,GAAG,GAAG,cAAc,CAAY,KAAK,EAAE;IAC3C,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;CACvD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { EnvPlugin } from './definitions';\n\nconst Env = registerPlugin<EnvPlugin>('Env', {\n web: () => import('./web').then((m) => new m.EnvWeb()),\n});\n\nexport * from './definitions';\nexport { Env };\n"]}
@@ -0,0 +1,9 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { EnvPlugin } from './definitions';
3
+ export declare class EnvWeb extends WebPlugin implements EnvPlugin {
4
+ getKey(options: {
5
+ key: string;
6
+ }): Promise<{
7
+ value: string;
8
+ }>;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class EnvWeb extends WebPlugin {
3
+ async getKey(options) {
4
+ console.log('GET_KEY', options);
5
+ return { value: '' };
6
+ }
7
+ }
8
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,MAAO,SAAQ,SAAS;IACnC,KAAK,CAAC,MAAM,CAAC,OAAwB;QACnC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { EnvPlugin } from './definitions';\n\nexport class EnvWeb extends WebPlugin implements EnvPlugin {\n async getKey(options: { key: string }): Promise<{ value: string }> {\n console.log('GET_KEY', options);\n return { value: '' };\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ const Env = core.registerPlugin('Env', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.EnvWeb()),
7
+ });
8
+
9
+ class EnvWeb extends core.WebPlugin {
10
+ async getKey(options) {
11
+ console.log('GET_KEY', options);
12
+ return { value: '' };
13
+ }
14
+ }
15
+
16
+ var web = /*#__PURE__*/Object.freeze({
17
+ __proto__: null,
18
+ EnvWeb: EnvWeb
19
+ });
20
+
21
+ exports.Env = Env;
22
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Env = registerPlugin('Env', {\n web: () => import('./web').then((m) => new m.EnvWeb()),\n});\nexport * from './definitions';\nexport { Env };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class EnvWeb extends WebPlugin {\n async getKey(options) {\n console.log('GET_KEY', options);\n return { value: '' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,GAAG,GAAGA,mBAAc,CAAC,KAAK,EAAE;AAClC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AAC1D,CAAC;;ACFM,MAAM,MAAM,SAASC,cAAS,CAAC;AACtC,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;AAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC;AACvC,QAAQ,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;AAC5B,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,25 @@
1
+ var capacitorEnv = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const Env = core.registerPlugin('Env', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.EnvWeb()),
6
+ });
7
+
8
+ class EnvWeb extends core.WebPlugin {
9
+ async getKey(options) {
10
+ console.log('GET_KEY', options);
11
+ return { value: '' };
12
+ }
13
+ }
14
+
15
+ var web = /*#__PURE__*/Object.freeze({
16
+ __proto__: null,
17
+ EnvWeb: EnvWeb
18
+ });
19
+
20
+ exports.Env = Env;
21
+
22
+ return exports;
23
+
24
+ })({}, capacitorExports);
25
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Env = registerPlugin('Env', {\n web: () => import('./web').then((m) => new m.EnvWeb()),\n});\nexport * from './definitions';\nexport { Env };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class EnvWeb extends WebPlugin {\n async getKey(options) {\n console.log('GET_KEY', options);\n return { value: '' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,GAAG,GAAGA,mBAAc,CAAC,KAAK,EAAE;IAClC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1D,CAAC;;ICFM,MAAM,MAAM,SAASC,cAAS,CAAC;IACtC,IAAI,MAAM,MAAM,CAAC,OAAO,EAAE;IAC1B,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC;IACvC,QAAQ,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5B,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,22 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(EnvPlugin)
9
+ public class EnvPlugin: CAPPlugin, CAPBridgedPlugin {
10
+ public let identifier = "EnvPlugin"
11
+ public let jsName = "Env"
12
+ public let pluginMethods: [CAPPluginMethod] = [
13
+ CAPPluginMethod(name: "getKey", returnType: CAPPluginReturnPromise)
14
+ ]
15
+
16
+ @objc func getKey(_ call: CAPPluginCall) {
17
+ let key = call.getString("key") ?? ""
18
+ call.resolve([
19
+ "value": getConfig().getString(key, "")
20
+ ])
21
+ }
22
+ }
@@ -0,0 +1,15 @@
1
+ import XCTest
2
+ @testable import EnvPlugin
3
+
4
+ class EnvTests: XCTestCase {
5
+ func testEcho() {
6
+ // This is an example of a functional test case for a plugin.
7
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
8
+
9
+ let implementation = Env()
10
+ let value = "Hello, World!"
11
+ let result = implementation.echo(value)
12
+
13
+ XCTAssertEqual(value, result)
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@capgo/capacitor-env",
3
+ "version": "7.0.0",
4
+ "description": "Set Env var in Capacitor config and read them at runtime",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Sources",
14
+ "ios/Tests",
15
+ "Package.swift",
16
+ "Env.podspec"
17
+ ],
18
+ "author": "Martin Donadieu <martin@capgo.app>",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Cap-go/capacitor-env.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/Cap-go/capacitor-env/issues"
26
+ },
27
+ "keywords": [
28
+ "capacitor",
29
+ "plugin",
30
+ "native",
31
+ "env",
32
+ "environment",
33
+ "variables",
34
+ "config"
35
+ ],
36
+ "scripts": {
37
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
38
+ "verify:ios": "xcodebuild -scheme Env -destination generic/platform=iOS",
39
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
40
+ "verify:web": "npm run build",
41
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
42
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
43
+ "eslint": "eslint . --ext ts",
44
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
45
+ "swiftlint": "node-swiftlint",
46
+ "docgen": "docgen --api EnvPlugin --output-readme README.md --output-json dist/docs.json",
47
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
48
+ "clean": "rimraf ./dist",
49
+ "watch": "tsc --watch",
50
+ "prepublishOnly": "npm run build"
51
+ },
52
+ "devDependencies": {
53
+ "@capacitor/android": "^7.0.0",
54
+ "@capacitor/core": "^7.0.0",
55
+ "@capacitor/docgen": "^0.3.0",
56
+ "@capacitor/ios": "^7.0.0",
57
+ "@ionic/eslint-config": "^0.4.0",
58
+ "@ionic/prettier-config": "^4.0.0",
59
+ "@ionic/swiftlint-config": "^2.0.0",
60
+ "eslint": "^8.57.0",
61
+ "prettier": "^3.4.2",
62
+ "prettier-plugin-java": "^2.6.6",
63
+ "rimraf": "^6.0.1",
64
+ "rollup": "^4.30.1",
65
+ "swiftlint": "^2.0.0",
66
+ "typescript": "~4.1.5"
67
+ },
68
+ "peerDependencies": {
69
+ "@capacitor/core": ">=7.0.0"
70
+ },
71
+ "prettier": "@ionic/prettier-config",
72
+ "swiftlint": "@ionic/swiftlint-config",
73
+ "eslintConfig": {
74
+ "extends": "@ionic/eslint-config/recommended"
75
+ },
76
+ "capacitor": {
77
+ "ios": {
78
+ "src": "ios"
79
+ },
80
+ "android": {
81
+ "src": "android"
82
+ }
83
+ }
84
+ }