Skip to content

Commit

Permalink
Chore/shared exports (#368)
Browse files Browse the repository at this point in the history
* chore(shared-exports): moved files to shared folder

* chore(shared-exports): import shared helpers

* chore(shared-exports): fixed imports

* chore(shared-exports): adjusted script to correctly generate and move files

Co-authored-by: Victor Batalha <[email protected]>
  • Loading branch information
victorcrbt and victorbatalha authored Oct 13, 2021
1 parent a35f3fa commit e448ba4
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 31 deletions.
20 changes: 11 additions & 9 deletions scripts/moveNativeDirectories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ const distModulesDirectory = `${__dirname}/../dist`;

const blackListRemove = [
'native',
'shared',
'web',
'index.js',
'index.js.map',
'index.esm.js',
'index.esm.js.map',
'index.d.ts',
];

async function removeAndMoveNewFiles() {
await rimraf(`${nativeModulesDirectory}/__tests__`);
await rimraf(`${nativeModulesDirectory}/tools`);
await rimraf(`${nativeModulesDirectory}/web`);
await rimraf(`${nativeFolder}/__tests__`);
const contents = await mz.readdir(nativeModulesDirectory);
await Promise.all(
Expand All @@ -25,16 +29,13 @@ async function removeAndMoveNewFiles() {
await mz.unlink(`${nativeModulesDirectory}/${filename}`);
}),
);
const nativeFolderContent = await mz.readdir(nativeFolder);
await Promise.all(
nativeFolderContent.map(async (filename) => {
await mz.rename(
`${nativeFolder}/${filename}`,
`${nativeModulesDirectory}/${filename}`,
);
}),
}

async function referenceTypeDefinitions() {
await mz.writeFile(
`${nativeModulesDirectory}/index.d.ts`,
`export * from './native';`,
);
await mz.rmdir(nativeFolder);
}

async function removeNativeFolderFromDist() {
Expand All @@ -44,4 +45,5 @@ async function removeNativeFolderFromDist() {
}

removeAndMoveNewFiles();
referenceTypeDefinitions();
removeNativeFolderFromDist();
2 changes: 1 addition & 1 deletion src/__tests__/base64.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatToBase64 } from '../base64';
import { formatToBase64 } from '../shared/base64';

describe('base64 helpers tests', () => {
it('should return a formatted string when no string sent', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/currencyParser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { currencyParser } from '../currencyParser';
import { currencyParser } from '../shared/currencyParser';

describe('currencyParser tests', () => {
describe('with string', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/currencyToNumber.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { currencyToNumber } from '../currencyToNumber';
import { currencyToNumber } from '../shared/currencyToNumber';

describe('currencyToNumber tests', () => {
it('should parse to thousands', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/getTheme.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getTheme } from '../getTheme';
import { getTheme } from '../shared/getTheme';

const theme = {
white: '#FFF',
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/ifStyle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ifStyle } from '../ifStyle';
import { ifStyle } from '../shared/ifStyle';

const style = {
fullWidth: 375,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/parseToThousands.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseToThousands } from '../parseToThousands';
import { parseToThousands } from '../shared/parseToThousands';

describe('parseToThousands tests', () => {
it('should parse to thousands', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/pixelToRem.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pxToRem } from '../pixelToRem';
import { pxToRem } from '../shared/pixelToRem';

describe('pixelToRem helpers tests', () => {
it('should return a formatted rem', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/removeWhiteSpaces.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { removeWhiteSpaces } from '../removeWhiteSpaces';
import { removeWhiteSpaces } from '../shared/removeWhiteSpaces';

describe('removeWhiteSpaces tests', () => {
it('should remove white empty spaces properly', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/switchStyle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { switchStyle } from '../switchStyle';
import { switchStyle } from '../shared/switchStyle';

describe('Switch Style tests', () => {
it('should switch style with invalid', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/toOnlyNumbers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toOnlyNumbers } from '../toOnlyNumbers';
import { toOnlyNumbers } from '../shared/toOnlyNumbers';

describe('toOnlyNumbers tests', () => {
it('should format to string empty properly', () => {
Expand Down
13 changes: 1 addition & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
export * from './currencyParser';
export * from './parseToThousands';
export * from './removeWhiteSpaces';
export * from './toOnlyNumbers';
export * from './getTheme';
export * from './ifStyle';
export * from './switchStyle';
export * from './base64';
export * from './pixelToRem';
export * from './currencyToNumber';
export * from './addMaskToCardNumber';
export * from './formatCardNumber';
export * from './web';
1 change: 1 addition & 0 deletions src/native/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { scale, verticalScale, moderateScale } from 'react-native-size-matters';
export * from './isIOS';
export * from './generateHaptic';
export * from '../shared';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export * from './currencyParser';
export * from './parseToThousands';
export * from './removeWhiteSpaces';
export * from './toOnlyNumbers';
export * from './getTheme';
export * from './ifStyle';
export * from './switchStyle';
export * from './base64';
export * from './pixelToRem';
export * from './currencyToNumber';
export * from './addMaskToCardNumber';
export * from './formatCardNumber';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/web/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../shared';

0 comments on commit e448ba4

Please sign in to comment.