diff --git a/package.json b/package.json index 29f089e..e4f7a2d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "license": "ISC", "scripts": { "build": "parcel build", - "download-targets-images": "ts-node ./scripts/downloadTargetsImages.ts", "generate-empty-targets": "ts-node ./scripts/generateEmptyTargets.ts", "generate-readme": "ts-node ./scripts/generateReadme.ts", "generate-targets-export": "ts-node ./scripts/generateTargetsExport.ts", diff --git a/scripts/downloadTargetsImages.ts b/scripts/downloadTargetsImages.ts deleted file mode 100644 index 0448963..0000000 --- a/scripts/downloadTargetsImages.ts +++ /dev/null @@ -1,45 +0,0 @@ -import * as fs from 'fs' -import axios from 'axios' - -import { createFolder } from 'scripts/utils/createFolder' -import { SHARED_FOLDER_PATH } from 'scripts/consts/sharedFolderPath' -import * as targets from 'shared/targetsInfo.json' - -const targetsImagesFolderPath = `${SHARED_FOLDER_PATH}/targetsImages` - -async function downloadTargetsImages() { - for (let index = 0; index < targets.length; index++) { - const target = targets[index] - const targetFileName = target.image.split('/')[2] - const targetFilePath = `${targetsImagesFolderPath}/${targetFileName}` - - if (fs.existsSync(targetFilePath)) { - console.log(`${targetFileName} already downloaded, skipping`) - - continue - } - - try { - console.log(`Downloading ${targetFileName}...`) - - const response = await axios.get( - `https://cssbattle.dev/targets/${targetFileName}`, - { responseType: 'arraybuffer' }, - ) - const image = Buffer.from(response.data, 'binary').toString('base64') - - fs.writeFileSync( - `${SHARED_FOLDER_PATH}/targetsImages/${targetFileName}`, - image, - 'base64', - ) - - console.log(`${targetFileName} downloaded`) - } catch (error) { - console.error(error) - } - } -} - -createFolder({ path: targetsImagesFolderPath, label: 'Images' }) -downloadTargetsImages() diff --git a/scripts/generateEmptyTargets.ts b/scripts/generateEmptyTargets.ts index f3c2446..11694e2 100644 --- a/scripts/generateEmptyTargets.ts +++ b/scripts/generateEmptyTargets.ts @@ -2,7 +2,7 @@ import * as fs from 'fs' import { createFolder } from './utils/createFolder' import * as targets from 'shared/targetsInfo.json' -import { SHARED_FOLDER_PATH } from 'scripts/consts/sharedFolderPath' +import { SHARED_FOLDER_PATH } from 'shared/consts/sharedFolderPath' export type TargetInfo = { id: number diff --git a/scripts/generateTargetsExport.ts b/scripts/generateTargetsExport.ts index 631379c..4fce322 100644 --- a/scripts/generateTargetsExport.ts +++ b/scripts/generateTargetsExport.ts @@ -1,5 +1,5 @@ import * as fs from 'fs' -import { SHARED_FOLDER_PATH } from 'scripts/consts/sharedFolderPath' +import { SHARED_FOLDER_PATH } from 'shared/consts/sharedFolderPath' const targetsFolderPath = `${SHARED_FOLDER_PATH}/targets` const targetsExportFilePath = `${targetsFolderPath}/index.ts` diff --git a/scripts/scrapeTargetsInformation.ts b/scripts/scrapeTargetsInformation.ts index 2eb0a0a..213ae08 100644 --- a/scripts/scrapeTargetsInformation.ts +++ b/scripts/scrapeTargetsInformation.ts @@ -1,6 +1,6 @@ import * as fs from 'fs' -import { SHARED_FOLDER_PATH } from 'scripts/consts/sharedFolderPath' +import { SHARED_FOLDER_PATH } from 'shared/consts/sharedFolderPath' type Target = { id: number diff --git a/scripts/consts/sharedFolderPath.ts b/shared/consts/sharedFolderPath.ts similarity index 100% rename from scripts/consts/sharedFolderPath.ts rename to shared/consts/sharedFolderPath.ts