Skip to content

Commit

Permalink
chore: remove type mention and update image script accordingly (#346)
Browse files Browse the repository at this point in the history
* chore: remove type mention and update image script accordingly

* refactor: cleanup code

* refactor: update tsconfig for ts-node
  • Loading branch information
tsyirvo authored Oct 19, 2022
1 parent e9d9319 commit 449554e
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 122 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"Development Build"
],
"license": "ISC",
"type": "module",
"scripts": {
"start:dev": "APP_ENV=development expo start --dev-client",
"start:test": "APP_ENV=test expo start --dev-client --no-dev --minify",
Expand Down Expand Up @@ -49,7 +48,7 @@
"lint": "eslint ./ --ext .js,.ts,.tsx --fix --ignore-path .gitignore",
"prettify": "yarn prettier --write './**/*.{js,ts,tsx}'",
"//// UTILITIES ////": "",
"image:add": "ts-node-esm -T ./scripts/importImages/index.ts",
"image:add": "ts-node -T ./scripts/importImages/index.ts",
"generate:page": "npx hygen generators page && yarn lint && yarn prettify",
"generate:icons": "svgr --native --typescript --ignore-existing --svgo-config src/components/icons/svgs/config/svgo.json --index-template src/components/icons/svgs/config/index-template.js --template src/components/icons/svgs/config/icon-template.js --out-dir src/components/icons/components -- src/components/icons/svgs",
"//// VERSIONNING ////": "",
Expand Down Expand Up @@ -128,8 +127,8 @@
"expo-community-flipper": "46.0.1",
"fs-extra": "10.1.0",
"husky": "8.0.1",
"imagemin": "8.0.1",
"imagemin-mozjpeg": "10.0.0",
"imagemin": "7.0.1",
"imagemin-mozjpeg": "9.0.0",
"imagemin-pngquant": "9.0.2",
"is-image": "3.1.0",
"jest": "27.4.5",
Expand Down
4 changes: 2 additions & 2 deletions scripts/importImages/createFiles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ImageMetadata from './imageMetadata.js';
import { copyFile, print, showSpinner, TMP_DIR } from './utils.js';
import ImageMetadata from './imageMetadata';
import { copyFile, print, showSpinner, TMP_DIR } from './utils';

const getAssetPath = () => `${process.cwd()}/src/assets/images/`;

Expand Down
8 changes: 4 additions & 4 deletions scripts/importImages/generateImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import fs from 'fs';
import isImage from 'is-image';
import util from 'util';

import createFiles from './createFiles.js';
import createImageResolutions from './imageManipulations.js';
import ImageMetadata from './imageMetadata.js';
import { print } from './utils.js';
import createFiles from './createFiles';
import createImageResolutions from './imageManipulations';
import ImageMetadata from './imageMetadata';
import { print } from './utils';

const readDirAsync = util.promisify(fs.readdir);

Expand Down
4 changes: 2 additions & 2 deletions scripts/importImages/imageManipulations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import imageminPngquant from 'imagemin-pngquant';
import type { Sharp } from 'sharp';
import sharp from 'sharp';

import ImageMetadata from './imageMetadata.js';
import { print, showSpinner, TMP_DIR } from './utils.js';
import ImageMetadata from './imageMetadata';
import { print, showSpinner, TMP_DIR } from './utils';

/* ***** ***** Compress the generated images ***** ***** */

Expand Down
15 changes: 8 additions & 7 deletions scripts/importImages/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import generateImages from './generateImages.js';
import {
createTmpImageFolders,
deleteTmpImageFolders,
print,
} from './utils.js';
import generateImages from './generateImages';
import { createTmpImageFolders, deleteTmpImageFolders, print } from './utils';

const main = async () => {
const passedArgsIndex = 2;
Expand All @@ -24,4 +20,9 @@ const main = async () => {
deleteTmpImageFolders();
};

await main();
main().catch(() =>
print({
message: 'An error happened while importing the images',
type: 'error',
}),
);
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@
"*": ["*", "*.ios.tsx", "*.android.tsx"]
}
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
},
"exclude": ["node_modules", "__mocks__"]
}
Loading

0 comments on commit 449554e

Please sign in to comment.