Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

Commit 6a93b29

Browse files
author
Yann Leflour
authored
Merge pull request #27 from bamlab/various-fixes
Various fixes
2 parents c6e078f + 856b2aa commit 6a93b29

7 files changed

Lines changed: 25 additions & 56 deletions

File tree

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ src
33
.prettierrc
44
tsconfig.json
55
.vscode
6+
yarn.lock

src/logo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
import 'colors';
12
export const logo = '❱m'.bgRed.bold + 'ake'.bgRed;

src/modules/setIcon/ios/service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { config } from './config';
22
import { addIosImageSetContents } from '../../../services/ios/service';
3-
import { checkImageIsSquare, generateResizedAssets } from '../../../services/image.processing';
3+
import {
4+
checkImageIsSquare,
5+
generateResizedAssetsWithoutAlpha,
6+
} from '../../../services/image.processing';
47

58
export const addIosIcon = async (iconSource: string) => {
69
try {
@@ -17,7 +20,7 @@ const generateIosIcons = (iconSource: string, iosIconFolder: string) =>
1720
config.iosIconSizes.map(size =>
1821
Promise.all(
1922
size.multipliers.map(multiplier =>
20-
generateResizedAssets(
23+
generateResizedAssetsWithoutAlpha(
2124
iconSource,
2225
`${iosIconFolder}/icon-${size.size}@${multiplier}x.png`,
2326
size.size * multiplier

src/rn-compatibility-layer.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/rn-plugin.config.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
import { UserDependencyConfig } from '@react-native-community/cli';
2-
import 'colors';
32
import { setIconCommand, setSplashScreenCommand } from './modules';
4-
import { resolve } from 'path';
5-
import { createBackwardCompatibleConfig } from './rn-compatibility-layer';
6-
7-
function getRNCliPackageFile() {
8-
try {
9-
// Yarn module resolution
10-
return require(resolve('.', 'node_modules/@react-native-community/cli/package.json'));
11-
} catch {
12-
// NPM module resolution
13-
return require(resolve(
14-
'.',
15-
'node_modules/react-native/node_modules/@react-native-community/cli/package.json'
16-
));
17-
}
18-
}
193

204
const v2Config: UserDependencyConfig = {
215
commands: [setIconCommand, setSplashScreenCommand],
226
};
237

24-
const rnCliVersion = getRNCliPackageFile();
25-
26-
const isUsingV1 = !!rnCliVersion.version.match(/^[0-1]\./);
27-
28-
export const rnPluginConfig: any = isUsingV1 ? createBackwardCompatibleConfig(v2Config) : v2Config;
8+
export const rnPluginConfig: any = v2Config;

src/services/image.processing.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ export const generateResizedAssets = async (
1717
.toFile(destinationPath);
1818
};
1919

20+
export const generateResizedAssetsWithoutAlpha = async (
21+
sourcePath: string,
22+
destinationPath: string,
23+
width: number,
24+
height: number = width,
25+
options: ResizeOptions = {
26+
fit: 'contain',
27+
}
28+
) => {
29+
createDirectoryIfNotExists(destinationPath);
30+
return sharp(normalize(sourcePath))
31+
.resize(width, height, options)
32+
.removeAlpha()
33+
.toFile(destinationPath);
34+
};
35+
2036
export const checkImageIsSquare = async (sourcePath: string) => {
2137
const { width, height } = await sharp(normalize(sourcePath)).metadata();
2238
if (width !== height) {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es2019",
3+
"target": "es2017",
44
"module": "commonjs",
55
"moduleResolution": "node",
66
"esModuleInterop": true,

0 commit comments

Comments
 (0)