@aramiworks/app-updates 0.0.0 → 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/package.json +1 -1
- package/build/cache.d.ts +0 -12
- package/build/cache.js +0 -104
- package/build/env.d.ts +0 -3
- package/build/env.js +0 -53
- package/build/index.d.ts +0 -8
- package/build/index.js +0 -13
- package/build/native.d.ts +0 -56
- package/build/native.js +0 -159
- package/build/openStore.d.ts +0 -20
- package/build/openStore.js +0 -49
- package/build/ota.d.ts +0 -33
- package/build/ota.js +0 -102
- package/build/sources/appStore.d.ts +0 -15
- package/build/sources/appStore.js +0 -26
- package/build/storeCheck.d.ts +0 -40
- package/build/storeCheck.js +0 -112
- package/build/tester.d.ts +0 -22
- package/build/tester.js +0 -78
- package/build/throttle.d.ts +0 -3
- package/build/throttle.js +0 -11
- package/build/types.d.ts +0 -7
- package/build/types.js +0 -2
- package/build/useAppUpdate.d.ts +0 -3
- package/build/useAppUpdate.js +0 -7
- package/build/useAppUpdateCore.d.ts +0 -43
- package/build/useAppUpdateCore.js +0 -209
- package/build/version.d.ts +0 -13
- package/build/version.js +0 -32
- package/plugin/build/gradle.d.ts +0 -16
- package/plugin/build/gradle.js +0 -172
- package/plugin/build/index.d.ts +0 -16
- package/plugin/build/index.js +0 -28
package/plugin/build/gradle.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Pure string transforms over the app-level `android/app/build.gradle` (Groovy).
|
|
4
|
-
* Kept free of Expo imports so they are trivially testable.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DEBUGGABLE_VARIANTS = exports.DISTRIBUTION_RESOURCE = exports.DISTRIBUTION_DIMENSION = exports.MARKER = void 0;
|
|
8
|
-
exports.addDistributionFlavors = addDistributionFlavors;
|
|
9
|
-
exports.addFirebaseDependency = addFirebaseDependency;
|
|
10
|
-
exports.setDebuggableVariants = setDebuggableVariants;
|
|
11
|
-
exports.MARKER = '// @aramiworks/app-updates';
|
|
12
|
-
exports.DISTRIBUTION_DIMENSION = 'distribution';
|
|
13
|
-
exports.DISTRIBUTION_RESOURCE = 'app_updates_distribution';
|
|
14
|
-
const FLAVORS = ['play', 'firebase'];
|
|
15
|
-
/**
|
|
16
|
-
* Finds direct-child `name { ... }` blocks of the range (depth 0 relative to `from`).
|
|
17
|
-
* Skips line/block comments and quoted strings so braces inside them do not count.
|
|
18
|
-
*/
|
|
19
|
-
function findChildBlock(src, name, from, to) {
|
|
20
|
-
const head = new RegExp(`^${name}\\s*\\{`);
|
|
21
|
-
let depth = 0;
|
|
22
|
-
let i = from;
|
|
23
|
-
let open = -1;
|
|
24
|
-
while (i < to) {
|
|
25
|
-
const ch = src[i];
|
|
26
|
-
const next = src[i + 1];
|
|
27
|
-
if (ch === '/' && next === '/') {
|
|
28
|
-
const nl = src.indexOf('\n', i);
|
|
29
|
-
i = nl === -1 ? to : nl;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (ch === '/' && next === '*') {
|
|
33
|
-
const end = src.indexOf('*/', i + 2);
|
|
34
|
-
i = end === -1 ? to : end + 2;
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (ch === '"' || ch === "'") {
|
|
38
|
-
i++;
|
|
39
|
-
while (i < to && src[i] !== ch) {
|
|
40
|
-
if (src[i] === '\\')
|
|
41
|
-
i++;
|
|
42
|
-
i++;
|
|
43
|
-
}
|
|
44
|
-
i++;
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (ch === '{') {
|
|
48
|
-
if (depth === 0) {
|
|
49
|
-
// `name {` start: look back for the identifier on this line.
|
|
50
|
-
const lineStart = src.lastIndexOf('\n', i) + 1;
|
|
51
|
-
const before = src.slice(Math.max(lineStart, from), i + 1).trim();
|
|
52
|
-
open = head.test(before) ? i : -1;
|
|
53
|
-
}
|
|
54
|
-
depth++;
|
|
55
|
-
}
|
|
56
|
-
else if (ch === '}') {
|
|
57
|
-
depth--;
|
|
58
|
-
if (depth === 0 && open !== -1)
|
|
59
|
-
return { open, close: i };
|
|
60
|
-
if (depth < 0)
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
i++;
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
/** Inserts `text` (newline-terminated lines) on its own lines just before the `}` at `close`. */
|
|
68
|
-
function insertBeforeClose(src, close, text) {
|
|
69
|
-
const lineStart = src.lastIndexOf('\n', close) + 1;
|
|
70
|
-
if (src.slice(lineStart, close).trim() === '') {
|
|
71
|
-
return src.slice(0, lineStart) + text + src.slice(lineStart);
|
|
72
|
-
}
|
|
73
|
-
return src.slice(0, close) + '\n' + text + src.slice(close);
|
|
74
|
-
}
|
|
75
|
-
function indentOf(src, pos) {
|
|
76
|
-
const lineStart = src.lastIndexOf('\n', pos) + 1;
|
|
77
|
-
return /^[ \t]*/.exec(src.slice(lineStart))[0];
|
|
78
|
-
}
|
|
79
|
-
function flavorBlock(name, indent) {
|
|
80
|
-
return (`${indent}${name} {\n` +
|
|
81
|
-
`${indent} dimension "${exports.DISTRIBUTION_DIMENSION}"\n` +
|
|
82
|
-
`${indent} resValue "string", "${exports.DISTRIBUTION_RESOURCE}", "${name}"\n` +
|
|
83
|
-
`${indent}}\n`);
|
|
84
|
-
}
|
|
85
|
-
function addDistributionFlavors(appBuildGradle) {
|
|
86
|
-
let src = appBuildGradle;
|
|
87
|
-
const android = findChildBlock(src, 'android', 0, src.length);
|
|
88
|
-
if (!android) {
|
|
89
|
-
throw new Error('@aramiworks/app-updates: no `android { }` block found in app/build.gradle');
|
|
90
|
-
}
|
|
91
|
-
// 1. flavorDimensions
|
|
92
|
-
const body = src.slice(android.open, android.close);
|
|
93
|
-
const dimsPresent = /^\s*flavorDimensions\b/m.test(body);
|
|
94
|
-
const hasDistribution = /flavorDimensions[^\n]*["']distribution["']/.test(body);
|
|
95
|
-
const baseIndent = indentOf(src, android.open) + ' ';
|
|
96
|
-
if (!hasDistribution) {
|
|
97
|
-
const stmt = dimsPresent
|
|
98
|
-
? `flavorDimensions += "${exports.DISTRIBUTION_DIMENSION}"`
|
|
99
|
-
: `flavorDimensions "${exports.DISTRIBUTION_DIMENSION}"`;
|
|
100
|
-
src = insertBeforeClose(src, android.close, `${baseIndent}${exports.MARKER}\n${baseIndent}${stmt}\n`);
|
|
101
|
-
}
|
|
102
|
-
// 2. productFlavors
|
|
103
|
-
let range = findChildBlock(src, 'android', 0, src.length);
|
|
104
|
-
let pf = findChildBlock(src, 'productFlavors', range.open + 1, range.close);
|
|
105
|
-
if (!pf) {
|
|
106
|
-
src = insertBeforeClose(src, range.close, `${baseIndent}${exports.MARKER}\n${baseIndent}productFlavors {\n${baseIndent}}\n`);
|
|
107
|
-
range = findChildBlock(src, 'android', 0, src.length);
|
|
108
|
-
pf = findChildBlock(src, 'productFlavors', range.open + 1, range.close);
|
|
109
|
-
}
|
|
110
|
-
const flavorIndent = indentOf(src, pf.open) + ' ';
|
|
111
|
-
for (const name of FLAVORS) {
|
|
112
|
-
const android2 = findChildBlock(src, 'android', 0, src.length);
|
|
113
|
-
const pf2 = findChildBlock(src, 'productFlavors', android2.open + 1, android2.close);
|
|
114
|
-
const flavor = findChildBlock(src, name, pf2.open + 1, pf2.close);
|
|
115
|
-
if (!flavor) {
|
|
116
|
-
src = insertBeforeClose(src, pf2.close, flavorBlock(name, flavorIndent));
|
|
117
|
-
}
|
|
118
|
-
else if (!new RegExp(`resValue\\s+["']string["']\\s*,\\s*["']${exports.DISTRIBUTION_RESOURCE}["']`).test(src.slice(flavor.open, flavor.close))) {
|
|
119
|
-
const ind = flavorIndent + ' ';
|
|
120
|
-
src = insertBeforeClose(src, flavor.close, `${ind}resValue "string", "${exports.DISTRIBUTION_RESOURCE}", "${name}"\n`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return src;
|
|
124
|
-
}
|
|
125
|
-
function addFirebaseDependency(appBuildGradle, version) {
|
|
126
|
-
const line = `firebaseImplementation "com.google.firebase:firebase-appdistribution:${version}"`;
|
|
127
|
-
const existing = /firebaseImplementation[ \t(]*["']com\.google\.firebase:firebase-appdistribution:[^"']*["']\)?/;
|
|
128
|
-
if (existing.test(appBuildGradle)) {
|
|
129
|
-
return appBuildGradle.replace(existing, line);
|
|
130
|
-
}
|
|
131
|
-
const deps = findChildBlock(appBuildGradle, 'dependencies', 0, appBuildGradle.length);
|
|
132
|
-
if (!deps) {
|
|
133
|
-
throw new Error('@aramiworks/app-updates: no `dependencies { }` block found in app/build.gradle');
|
|
134
|
-
}
|
|
135
|
-
const ind = indentOf(appBuildGradle, deps.open) + ' ';
|
|
136
|
-
return insertBeforeClose(appBuildGradle, deps.close, `\n${ind}${exports.MARKER}\n${ind}${line}\n`);
|
|
137
|
-
}
|
|
138
|
-
exports.DEBUGGABLE_VARIANTS = ['playDebug', 'firebaseDebug'];
|
|
139
|
-
/**
|
|
140
|
-
* With flavors the RN Gradle plugin's debug variants are `playDebug` / `firebaseDebug`;
|
|
141
|
-
* its default `debuggableVariants = ["debug"]` matches none of them (exact variant name,
|
|
142
|
-
* case-insensitive), so debug builds would bundle JS instead of loading from Metro.
|
|
143
|
-
*/
|
|
144
|
-
function setDebuggableVariants(appBuildGradle) {
|
|
145
|
-
const quoted = exports.DEBUGGABLE_VARIANTS.map((v) => `"${v}"`).join(', ');
|
|
146
|
-
const react = findChildBlock(appBuildGradle, 'react', 0, appBuildGradle.length);
|
|
147
|
-
if (!react) {
|
|
148
|
-
const sep = appBuildGradle.endsWith('\n') ? '' : '\n';
|
|
149
|
-
return `${appBuildGradle}${sep}\n${exports.MARKER}\nreact {\n debuggableVariants = [${quoted}]\n}\n`;
|
|
150
|
-
}
|
|
151
|
-
const body = appBuildGradle.slice(react.open + 1, react.close);
|
|
152
|
-
const active = /^([ \t]*debuggableVariants\s*=\s*\[)([^\]]*)(\])/m.exec(body);
|
|
153
|
-
if (active) {
|
|
154
|
-
const items = active[2]
|
|
155
|
-
.split(',')
|
|
156
|
-
.map((s) => s.trim())
|
|
157
|
-
.filter(Boolean);
|
|
158
|
-
const have = new Set(items.map((s) => s.replace(/^["']|["']$/g, '')));
|
|
159
|
-
const missing = exports.DEBUGGABLE_VARIANTS.filter((v) => !have.has(v));
|
|
160
|
-
if (missing.length === 0)
|
|
161
|
-
return appBuildGradle;
|
|
162
|
-
const merged = [...items, ...missing.map((v) => `"${v}"`)].join(', ');
|
|
163
|
-
const start = react.open + 1 + active.index;
|
|
164
|
-
return (appBuildGradle.slice(0, start) +
|
|
165
|
-
active[1] +
|
|
166
|
-
merged +
|
|
167
|
-
active[3] +
|
|
168
|
-
appBuildGradle.slice(start + active[0].length));
|
|
169
|
-
}
|
|
170
|
-
const ind = indentOf(appBuildGradle, react.open) + ' ';
|
|
171
|
-
return insertBeforeClose(appBuildGradle, react.close, `\n${ind}${exports.MARKER}\n${ind}debuggableVariants = [${quoted}]\n`);
|
|
172
|
-
}
|
package/plugin/build/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ConfigPlugin } from 'expo/config-plugins';
|
|
2
|
-
/** Same version line as the `firebase-appdistribution-api` artifact in android/build.gradle. */
|
|
3
|
-
export declare const DEFAULT_FIREBASE_APPDISTRIBUTION_VERSION = "16.0.0-beta21";
|
|
4
|
-
export type AppUpdatesPluginProps = {
|
|
5
|
-
/** Version of `com.google.firebase:firebase-appdistribution` added to the firebase flavor. */
|
|
6
|
-
firebaseVersion?: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Android: adds `play` / `firebase` product flavors (each writing the
|
|
10
|
-
* `app_updates_distribution` string resource) and the full Firebase App Distribution
|
|
11
|
-
* SDK for the firebase flavor only, and sets `react { debuggableVariants }` for the flavored
|
|
12
|
-
* debug variants. Build tasks are renamed, so set `android.gradleCommand` per EAS profile:
|
|
13
|
-
* `:app:bundlePlayRelease` (store .aab), `:app:assembleFirebaseRelease` (Firebase tester APK). iOS: nothing (D36, no iOS native setup).
|
|
14
|
-
*/
|
|
15
|
-
export declare const withAppUpdates: ConfigPlugin<AppUpdatesPluginProps | void>;
|
|
16
|
-
export default withAppUpdates;
|
package/plugin/build/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withAppUpdates = exports.DEFAULT_FIREBASE_APPDISTRIBUTION_VERSION = void 0;
|
|
4
|
-
const config_plugins_1 = require("expo/config-plugins");
|
|
5
|
-
const gradle_1 = require("./gradle");
|
|
6
|
-
/** Same version line as the `firebase-appdistribution-api` artifact in android/build.gradle. */
|
|
7
|
-
exports.DEFAULT_FIREBASE_APPDISTRIBUTION_VERSION = '16.0.0-beta21';
|
|
8
|
-
/**
|
|
9
|
-
* Android: adds `play` / `firebase` product flavors (each writing the
|
|
10
|
-
* `app_updates_distribution` string resource) and the full Firebase App Distribution
|
|
11
|
-
* SDK for the firebase flavor only, and sets `react { debuggableVariants }` for the flavored
|
|
12
|
-
* debug variants. Build tasks are renamed, so set `android.gradleCommand` per EAS profile:
|
|
13
|
-
* `:app:bundlePlayRelease` (store .aab), `:app:assembleFirebaseRelease` (Firebase tester APK). iOS: nothing (D36, no iOS native setup).
|
|
14
|
-
*/
|
|
15
|
-
const withAppUpdates = (config, props) => {
|
|
16
|
-
const firebaseVersion = props?.firebaseVersion ?? exports.DEFAULT_FIREBASE_APPDISTRIBUTION_VERSION;
|
|
17
|
-
return (0, config_plugins_1.withAppBuildGradle)(config, (cfg) => {
|
|
18
|
-
if (cfg.modResults.language !== 'groovy') {
|
|
19
|
-
throw new Error('@aramiworks/app-updates: only Groovy app/build.gradle is supported (found ' +
|
|
20
|
-
cfg.modResults.language +
|
|
21
|
-
').');
|
|
22
|
-
}
|
|
23
|
-
cfg.modResults.contents = (0, gradle_1.addFirebaseDependency)((0, gradle_1.setDebuggableVariants)((0, gradle_1.addDistributionFlavors)(cfg.modResults.contents)), firebaseVersion);
|
|
24
|
-
return cfg;
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
exports.withAppUpdates = withAppUpdates;
|
|
28
|
-
exports.default = exports.withAppUpdates;
|