Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "expo-module build plugin",
"clean": "expo-module clean plugin",
"prepare": "yarn clean && yarn build"
"prep": "yarn clean && yarn build"
},
"homepage": "https://www.img.ly",
"keywords": [
Expand Down Expand Up @@ -39,9 +39,9 @@
"licenseFilename": "LICENSE.md",
"readmeFilename": "README.md",
"devDependencies": {
"expo-module-scripts": "^2.0.0"
"expo-module-scripts": "^3.4.1"
},
"dependencies": {
"@expo/config-plugins": "^4.0.9"
"@expo/config-plugins": "~7.2.0"
}
}
11 changes: 6 additions & 5 deletions plugin/build/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ export declare enum ConfigurationTag {
Modules = "MODULES",
Repos = "REPOS",
Maven = "MAVEN",
SDKVersions = "SDK_VERSIONS"
SDKVersions = "SDK_VERSIONS",
Dependencies = "DEPENDENCIES"
}
/** The default `buildToolsVersion`. */
export declare const defaultBuildToolsVersion = "31.0.0";
export declare const defaultBuildToolsVersion = "34.0.0";
/** The default `minSdkVersion`. */
export declare const defaultMinSdkVersion = "21";
export declare const defaultMinSdkVersion = "23";
/** The default `compileSdkVersion`. */
export declare const defaultCompileSdkVersion = "31";
export declare const defaultCompileSdkVersion = "34";
/** The default `targetSdkVersion`. */
export declare const defaultTargetSdkVersion = "30";
export declare const defaultTargetSdkVersion = "34";
/**
* Returns the replacement for a given `ConfigurationTag.`
* @param tag The `ConfigurationTag`.
Expand Down
41 changes: 27 additions & 14 deletions plugin/build/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -28,15 +32,16 @@ var ConfigurationTag;
ConfigurationTag["Repos"] = "REPOS";
ConfigurationTag["Maven"] = "MAVEN";
ConfigurationTag["SDKVersions"] = "SDK_VERSIONS";
})(ConfigurationTag = exports.ConfigurationTag || (exports.ConfigurationTag = {}));
ConfigurationTag["Dependencies"] = "DEPENDENCIES";
})(ConfigurationTag || (exports.ConfigurationTag = ConfigurationTag = {}));
/** The default `buildToolsVersion`. */
exports.defaultBuildToolsVersion = "31.0.0";
exports.defaultBuildToolsVersion = "34.0.0";
/** The default `minSdkVersion`. */
exports.defaultMinSdkVersion = "21";
exports.defaultMinSdkVersion = "23";
/** The default `compileSdkVersion`. */
exports.defaultCompileSdkVersion = "31";
exports.defaultCompileSdkVersion = "34";
/** The default `targetSdkVersion`. */
exports.defaultTargetSdkVersion = "30";
exports.defaultTargetSdkVersion = "34";
/**
* Returns the replacement for a given `ConfigurationTag.`
* @param tag The `ConfigurationTag`.
Expand All @@ -45,17 +50,18 @@ exports.defaultTargetSdkVersion = "30";
* @returns The replacement string.
*/
function replacementForTag(tag, configuration, content) {
var _a;
switch (tag) {
case ConfigurationTag.Maven:
return imgly_allprojects_block;
case ConfigurationTag.Modules:
return customizedModules(configuration);
case ConfigurationTag.Repos:
return imgly_repos_block(configuration);
case ConfigurationTag.Dependencies:
return imgly_dependencies_block();
case ConfigurationTag.SDKVersions:
if (content != null) {
return (_a = Helpers.parseSDKVersions(content, configuration)) !== null && _a !== void 0 ? _a : "";
return Helpers.parseSDKVersions(content, configuration) ?? "";
}
return "";
}
Expand All @@ -67,7 +73,7 @@ exports.replacementForTag = replacementForTag;
* @returns The parsed string.
*/
function customizedModules(configuration) {
if ((configuration === null || configuration === void 0 ? void 0 : configuration.modules) != null) {
if (configuration?.modules != null) {
var modules = configuration.modules.flatMap((module) => ` include '${module}'\n`);
var config = imgly_config_start.concat(...modules, imgly_config_end);
return config;
Expand All @@ -79,9 +85,9 @@ function customizedModules(configuration) {
/** The modules for the android/app/build.gradle. */
exports.imgly_config_regex = 'apply plugin: "com.android.application"';
/** The version of the native Android SDK that is needed for the plugins. */
const sdk_version = "10.4.1";
const sdk_version = "10.8.2";
/** The Kotlin version that is needed for the plugins. */
const default_kotlin_version = "1.5.32";
const default_kotlin_version = "1.8.0";
/** The start for the imgly configuration block. */
const imgly_config_start = `
apply plugin: 'ly.img.android.sdk'
Expand Down Expand Up @@ -147,15 +153,22 @@ allprojects {
`;
/** The repositories for the android/build.gradle. */
function imgly_repos_block(configuration) {
var _a, _b;
return `buildscript {
repositories {
maven { url "https://artifactory.img.ly/artifactory/imgly" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${(_a = configuration === null || configuration === void 0 ? void 0 : configuration.kotlinGradlePluginVersion) !== null && _a !== void 0 ? _a : default_kotlin_version}"
classpath 'ly.img.android.sdk:plugin:${(_b = configuration === null || configuration === void 0 ? void 0 : configuration.version) !== null && _b !== void 0 ? _b : sdk_version}'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${configuration?.kotlinGradlePluginVersion ?? default_kotlin_version}"
classpath 'ly.img.android.sdk:plugin:${configuration?.version ?? sdk_version}'
}
}
`;
}
/** The dependencies for the android/build.gradle. */
function imgly_dependencies_block() {
return `
dependencies {
implementation('androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0')
}
`;
}
17 changes: 11 additions & 6 deletions plugin/build/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down Expand Up @@ -63,17 +67,18 @@ exports.previousContent = previousContent;
* @returns The parsed content if any.
*/
function parseSDKVersions(content, configurationObject) {
var _a, _b, _c, _d;
let source = previousContent(constants_1.ConfigurationTag.SDKVersions, content);
if (source != null) {
const buildToolsRegEx = /\bbuildToolsVersion\s*=\s*"([0-9]*).([0-9]*).([0-9]*)"$/gm;
const minSdkVersionRegEx = /\bminSdkVersion\s*=\s*([0-9]*)$/gm;
const compileSdkVersionRegEx = /\bcompileSdkVersion\s*=\s*([0-9]*)$/gm;
const targetSdkVersionRegEx = /\btargetSdkVersion\s*=\s*([0-9]*)$/gm;
const newBuildTools = `buildToolsVersion = "${(_a = configurationObject === null || configurationObject === void 0 ? void 0 : configurationObject.buildToolsVersion) !== null && _a !== void 0 ? _a : Constants.defaultBuildToolsVersion}"`;
const newMinSdkVersion = `minSdkVersion = ${(_b = configurationObject === null || configurationObject === void 0 ? void 0 : configurationObject.minSdkVersion) !== null && _b !== void 0 ? _b : Constants.defaultMinSdkVersion}`;
const newCompileSdkVersion = `compileSdkVersion = ${(_c = configurationObject === null || configurationObject === void 0 ? void 0 : configurationObject.compileSdkVersion) !== null && _c !== void 0 ? _c : Constants.defaultCompileSdkVersion}`;
const newTargetSdkVersion = `targetSdkVersion = ${(_d = configurationObject === null || configurationObject === void 0 ? void 0 : configurationObject.targetSdkVersion) !== null && _d !== void 0 ? _d : Constants.defaultTargetSdkVersion}`;
const newBuildTools = `buildToolsVersion = "${configurationObject?.buildToolsVersion ??
Constants.defaultBuildToolsVersion}"`;
const newMinSdkVersion = `minSdkVersion = ${configurationObject?.minSdkVersion ?? Constants.defaultMinSdkVersion}`;
const newCompileSdkVersion = `compileSdkVersion = ${configurationObject?.compileSdkVersion ??
Constants.defaultCompileSdkVersion}`;
const newTargetSdkVersion = `targetSdkVersion = ${configurationObject?.targetSdkVersion ?? Constants.defaultTargetSdkVersion}`;
source = source.replace(buildToolsRegEx, newBuildTools);
source = source.replace(minSdkVersionRegEx, newMinSdkVersion);
source = source.replace(compileSdkVersionRegEx, newCompileSdkVersion);
Expand Down
26 changes: 15 additions & 11 deletions plugin/build/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -25,13 +29,13 @@ const Helpers = __importStar(require("./helpers"));
/** Applies all needed native configurations. */
const withReactNativeIMGLY = (config, { android } = {}) => {
const configuration = {
version: android === null || android === void 0 ? void 0 : android.version,
modules: android === null || android === void 0 ? void 0 : android.modules,
buildToolsVersion: android === null || android === void 0 ? void 0 : android.buildToolsVersion,
minSdkVersion: android === null || android === void 0 ? void 0 : android.minSdkVersion,
compileSdkVersion: android === null || android === void 0 ? void 0 : android.compileSdkVersion,
targetSdkVersion: android === null || android === void 0 ? void 0 : android.targetSdkVersion,
kotlinGradlePluginVersion: android === null || android === void 0 ? void 0 : android.kotlinGradlePluginVersion,
version: android?.version,
modules: android?.modules,
buildToolsVersion: android?.buildToolsVersion,
minSdkVersion: android?.minSdkVersion,
compileSdkVersion: android?.compileSdkVersion,
targetSdkVersion: android?.targetSdkVersion,
kotlinGradlePluginVersion: android?.kotlinGradlePluginVersion,
};
return (0, config_plugins_1.withPlugins)(config, [
[withIMGLYGradle, { configuration: configuration }],
Expand All @@ -54,7 +58,6 @@ const withIMGLYConfig = (config, { configuration }) => {
};
/** Adds the imgly repos in the `android/build.gradle`. */
function addIMGLYRepos(contents, configuration) {
var _a;
var modifiedContents = contents;
const repos_tag = Constants.ConfigurationTag.Repos;
const repos_replacement = Constants.replacementForTag(repos_tag, configuration);
Expand Down Expand Up @@ -87,7 +90,7 @@ function addIMGLYRepos(contents, configuration) {
modifiedContents = versions_tagged_replacement;
}
else {
const previousContent = (_a = Helpers.previousContent(sdk_versions_tag, contents)) === null || _a === void 0 ? void 0 : _a.replace(/^/gm, "//");
const previousContent = Helpers.previousContent(sdk_versions_tag, contents)?.replace(/^/gm, "//");
if (previousContent != null) {
const versions_tagged_replacement_block = Helpers.taggedReplacementBlock(sdk_versions_tag, versions_replacement, previousContent);
if (!contents.match(versions_tagged_replacement_block)) {
Expand All @@ -101,7 +104,8 @@ function addIMGLYRepos(contents, configuration) {
/** Adds the imgly modules in the `android/app/build.gradle`. */
function addIMGLYConfig(contents, configuration) {
const tag = Constants.ConfigurationTag.Modules;
const replacement = Constants.replacementForTag(tag, configuration);
const depTag = Constants.ConfigurationTag.Dependencies;
const replacement = Constants.replacementForTag(tag, configuration).concat(Constants.replacementForTag(depTag, configuration));
const taggedReplacement = Helpers.replaceTaggedConfiguration(contents, tag, replacement);
if (taggedReplacement != null) {
return taggedReplacement;
Expand Down
24 changes: 18 additions & 6 deletions plugin/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ export enum ConfigurationTag {
Repos = "REPOS",
Maven = "MAVEN",
SDKVersions = "SDK_VERSIONS",
Dependencies = "DEPENDENCIES",
}

/** The default `buildToolsVersion`. */
export const defaultBuildToolsVersion = "31.0.0";
export const defaultBuildToolsVersion = "34.0.0";

/** The default `minSdkVersion`. */
export const defaultMinSdkVersion = "21";
export const defaultMinSdkVersion = "23";

/** The default `compileSdkVersion`. */
export const defaultCompileSdkVersion = "31";
export const defaultCompileSdkVersion = "34";

/** The default `targetSdkVersion`. */
export const defaultTargetSdkVersion = "30";
export const defaultTargetSdkVersion = "34";

/**
* Returns the replacement for a given `ConfigurationTag.`
Expand All @@ -63,6 +64,8 @@ export function replacementForTag(
return customizedModules(configuration);
case ConfigurationTag.Repos:
return imgly_repos_block(configuration);
case ConfigurationTag.Dependencies:
return imgly_dependencies_block();
case ConfigurationTag.SDKVersions:
if (content != null) {
return Helpers.parseSDKVersions(content, configuration) ?? "";
Expand Down Expand Up @@ -92,10 +95,10 @@ function customizedModules(configuration?: AndroidConfigurationObject): string {
export const imgly_config_regex = 'apply plugin: "com.android.application"';

/** The version of the native Android SDK that is needed for the plugins. */
const sdk_version = "10.4.1";
const sdk_version = "10.8.2";

/** The Kotlin version that is needed for the plugins. */
const default_kotlin_version = "1.5.32";
const default_kotlin_version = "1.8.0";

/** The start for the imgly configuration block. */
const imgly_config_start = `
Expand Down Expand Up @@ -181,3 +184,12 @@ function imgly_repos_block(configuration?: AndroidConfigurationObject): string {
}
`;
}

/** The dependencies for the android/build.gradle. */
function imgly_dependencies_block(): string {
return `
dependencies {
implementation('androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0')
}
`;
}
6 changes: 5 additions & 1 deletion plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ function addIMGLYConfig(
configuration?: Constants.AndroidConfigurationObject
): string {
const tag = Constants.ConfigurationTag.Modules;
const replacement = Constants.replacementForTag(tag, configuration);
const depTag = Constants.ConfigurationTag.Dependencies;
const replacement = Constants.replacementForTag(tag, configuration).concat(
Constants.replacementForTag(depTag, configuration)
);

const taggedReplacement = Helpers.replaceTaggedConfiguration(
contents,
tag,
Expand Down
Loading