diff --git a/.pnp.js b/.pnp.js index a805ca07..52b9dc58 100755 --- a/.pnp.js +++ b/.pnp.js @@ -59,7 +59,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["cz-conventional-changelog", "npm:3.3.0"], ["eslint", "npm:7.15.0"], ["eslint-config-airbnb-typescript", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:12.0.0"], - ["eslint-config-prettier", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:6.15.0"], + ["eslint-config-prettier", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:7.0.0"], ["eslint-import-resolver-typescript", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:2.3.0"], ["eslint-plugin-import", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:2.22.1"], ["eslint-plugin-jest", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:24.1.3"], @@ -3525,7 +3525,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["cz-conventional-changelog", "npm:3.3.0"], ["eslint", "npm:7.15.0"], ["eslint-config-airbnb-typescript", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:12.0.0"], - ["eslint-config-prettier", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:6.15.0"], + ["eslint-config-prettier", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:7.0.0"], ["eslint-import-resolver-typescript", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:2.3.0"], ["eslint-plugin-import", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:2.22.1"], ["eslint-plugin-jest", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:24.1.3"], @@ -6186,13 +6186,12 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }] ]], ["eslint-config-prettier", [ - ["virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:6.15.0", { - "packageLocation": "./.yarn/$$virtual/eslint-config-prettier-virtual-34ed5be039/0/cache/eslint-config-prettier-npm-6.15.0-d2085588b4-a790bc6169.zip/node_modules/eslint-config-prettier/", + ["virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:7.0.0", { + "packageLocation": "./.yarn/$$virtual/eslint-config-prettier-virtual-cabed3fab1/0/cache/eslint-config-prettier-npm-7.0.0-bd988acc75-b7c543080e.zip/node_modules/eslint-config-prettier/", "packageDependencies": [ - ["eslint-config-prettier", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:6.15.0"], + ["eslint-config-prettier", "virtual:4bc879ee8766b5c64a944ba0314247e9ed208a36cde6f3dfba54d4d0d0819032f13bd0f310835cb3c506c634c8bd0ab2b4fed2c45686f55fb51dc017ab534de4#npm:7.0.0"], ["@types/eslint", null], - ["eslint", "npm:7.15.0"], - ["get-stdin", "npm:6.0.0"] + ["eslint", "npm:7.15.0"] ], "packagePeers": [ "@types/eslint", @@ -7268,13 +7267,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ], "linkType": "HARD", }], - ["npm:6.0.0", { - "packageLocation": "./.yarn/cache/get-stdin-npm-6.0.0-22ebabe125-b51d664838.zip/node_modules/get-stdin/", - "packageDependencies": [ - ["get-stdin", "npm:6.0.0"] - ], - "linkType": "HARD", - }], ["npm:8.0.0", { "packageLocation": "./.yarn/cache/get-stdin-npm-8.0.0-920f876bc2-009a4c4248.zip/node_modules/get-stdin/", "packageDependencies": [ diff --git a/package.json b/package.json index b787e61d..14027dfc 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,7 @@ "cz-conventional-changelog": "3.3.0", "eslint": "7.15.0", "eslint-config-airbnb-typescript": "12.0.0", - "eslint-config-prettier": "6.15.0", + "eslint-config-prettier": "7.0.0", "eslint-import-resolver-typescript": "2.3.0", "eslint-plugin-import": "2.22.1", "eslint-plugin-jest": "24.1.3", diff --git a/scripts/generate-ec2-info.ts b/scripts/generate-ec2-info.ts index 20cc97c4..b14348b3 100644 --- a/scripts/generate-ec2-info.ts +++ b/scripts/generate-ec2-info.ts @@ -9,9 +9,7 @@ import { getEc2Info } from '../src/lib/core'; (async () => { const res = ( await Promise.all(defaultRegions.map(async region => getEc2Info({ region, log: true }))) - ).reduce((rtn, cur) => { - return { ...rtn, ...cur }; - }, {} as { vCpu?: number; memoryGiB?: number }); + ).reduce((rtn, cur) => ({ ...rtn, ...cur }), {} as { vCpu?: number; memoryGiB?: number }); const sorted = Object.fromEntries(Object.entries(res).sort(([a], [b]) => -(a < b))); console.log(`found ${Object.keys(sorted).length} instance types`); diff --git a/scripts/generate-spot-prices-mock-data.ts b/scripts/generate-spot-prices-mock-data.ts index b532c996..6d19d67c 100644 --- a/scripts/generate-spot-prices-mock-data.ts +++ b/scripts/generate-spot-prices-mock-data.ts @@ -59,31 +59,35 @@ const { argv } = yargs() console.log('fetched total:', allPrices.length); // check for any duplicates - const unique = uniqWith(allPrices, (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => { - return ( + const unique = uniqWith( + allPrices, + (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => val1.AvailabilityZone === val2.AvailabilityZone && val1.InstanceType === val2.InstanceType && - val1.ProductDescription === val2.ProductDescription - ); - }); + val1.ProductDescription === val2.ProductDescription, + ); console.log('unique total:', unique.length); if (args.processDetail) { const uniqueProductDescription = uniqWith( allPrices, - (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => { - return val1.ProductDescription === val2.ProductDescription; - }, + (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => + val1.ProductDescription === val2.ProductDescription, + ); + const uniqueType = uniqWith( + allPrices, + (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => val1.InstanceType === val2.InstanceType, + ); + const uniqueFamily = uniqWith( + allPrices, + (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => + val1.InstanceType?.split('.').shift() === val2.InstanceType?.split('.').shift(), + ); + const uniqueSize = uniqWith( + allPrices, + (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => + val1.InstanceType?.split('.').pop() === val2.InstanceType?.split('.').pop(), ); - const uniqueType = uniqWith(allPrices, (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => { - return val1.InstanceType === val2.InstanceType; - }); - const uniqueFamily = uniqWith(allPrices, (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => { - return val1.InstanceType?.split('.').shift() === val2.InstanceType?.split('.').shift(); - }); - const uniqueSize = uniqWith(allPrices, (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => { - return val1.InstanceType?.split('.').pop() === val2.InstanceType?.split('.').pop(); - }); console.log('uniqueType total:', uniqueType.length); console.log('uniqueProductDescription total:', uniqueProductDescription.length); console.log('uniqueFamily total:', uniqueFamily.length); @@ -92,13 +96,14 @@ const { argv } = yargs() // compare with previous const prevList = JSON.parse(readFileSync(jsonPath).toString('utf8')); - const xor = xorWith(unique, prevList, (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => { - return ( + const xor = xorWith( + unique, + prevList, + (val1: EC2.SpotPrice, val2: EC2.SpotPrice) => val1.AvailabilityZone === val2.AvailabilityZone && val1.InstanceType === val2.InstanceType && - val1.ProductDescription === val2.ProductDescription - ); - }); + val1.ProductDescription === val2.ProductDescription, + ); console.log('xor total:', xor.length); const xorPrev: EC2.SpotPrice[] = []; const xorCur: EC2.SpotPrice[] = []; diff --git a/src/constants/platform.ts b/src/constants/platform.ts index 1993dc42..3ed5ceb2 100644 --- a/src/constants/platform.ts +++ b/src/constants/platform.ts @@ -20,6 +20,5 @@ export const platformWildcards = { export type PlatformsWildcards = keyof typeof platformWildcards; -export const instanceOfPlatforms = (pd: string): pd is Platform => { - return allPlatforms.includes(pd as Platform); -}; +export const instanceOfPlatforms = (pd: string): pd is Platform => + allPlatforms.includes(pd as Platform); diff --git a/src/lib/core.ts b/src/lib/core.ts index 85260e3d..95a4a5b1 100644 --- a/src/lib/core.ts +++ b/src/lib/core.ts @@ -403,8 +403,8 @@ export const getGlobalSpotPrices = async (options?: { }), ); }) - .then(results => { - return results + .then(results => + results .filter( // filter out info without region or price greater than priceLimit info => { @@ -431,8 +431,8 @@ export const getGlobalSpotPrices = async (options?: { return true; }, ) - .sort(sortSpotPriceExtended); - }); + .sort(sortSpotPriceExtended), + ); // limit output if (limit && rtn.length > limit) rtn.splice(limit); diff --git a/test/mock-ec2-endpoints.ts b/test/mock-ec2-endpoints.ts index 73d268b4..a0f3d059 100644 --- a/test/mock-ec2-endpoints.ts +++ b/test/mock-ec2-endpoints.ts @@ -16,9 +16,10 @@ const data = JSON.parse( type RegionalData = { [region in Region]: SpotPrice[] }; const regionalData: RegionalData = allRegions.reduce((list, region) => { - list[region] = filter(data, (o: SpotPrice) => { - return o.AvailabilityZone && o.AvailabilityZone.startsWith(region); - }); + list[region] = filter( + data, + (o: SpotPrice) => o.AvailabilityZone && o.AvailabilityZone.startsWith(region), + ); return list; }, {} as RegionalData); diff --git a/yarn.lock b/yarn.lock index 90d4247c..116ee386 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3128,7 +3128,7 @@ __metadata: cz-conventional-changelog: 3.3.0 eslint: 7.15.0 eslint-config-airbnb-typescript: 12.0.0 - eslint-config-prettier: 6.15.0 + eslint-config-prettier: 7.0.0 eslint-import-resolver-typescript: 2.3.0 eslint-plugin-import: 2.22.1 eslint-plugin-jest: 24.1.3 @@ -5470,16 +5470,14 @@ __metadata: languageName: node linkType: hard -"eslint-config-prettier@npm:6.15.0": - version: 6.15.0 - resolution: "eslint-config-prettier@npm:6.15.0" - dependencies: - get-stdin: ^6.0.0 +"eslint-config-prettier@npm:7.0.0": + version: 7.0.0 + resolution: "eslint-config-prettier@npm:7.0.0" peerDependencies: - eslint: ">=3.14.1" + eslint: ">=7.0.0" bin: - eslint-config-prettier-check: bin/cli.js - checksum: a790bc61699e43a2edc5453488576cd977fad3b3cf99c129c10760ce6970d422923fddf80b65b2b10a93c00af0180a854e4b7824cc268e5957826cbe5b969e90 + eslint-config-prettier: bin/cli.js + checksum: b7c543080e32829dba5f3db970c5f3c3b47f1de8df89b4226105afbecae561e026b6fe9f2cb16bf08ab1a6f1f544d9303c9c8c0919cbb51a9d2c8a640779624a languageName: node linkType: hard @@ -6566,13 +6564,6 @@ fsevents@^2.1.2: languageName: node linkType: hard -"get-stdin@npm:^6.0.0": - version: 6.0.0 - resolution: "get-stdin@npm:6.0.0" - checksum: b51d664838aef7f8353dc57371ce59cea54d8d584fec015a9d89d24561e95b97806d5b5ba120bc81574c9ed63cb3e210176ffa0ff9263c7e7ba4d56d0fe54913 - languageName: node - linkType: hard - "get-stream@npm:^3.0.0": version: 3.0.0 resolution: "get-stream@npm:3.0.0"