fix(dashboard,types,js-sdk): Locations & Shipping fixes and cleanup (#7715)

This commit is contained in:
Kasper Fabricius Kristensen
2024-06-17 16:10:39 +02:00
committed by GitHub
parent bc0c65c6b3
commit 2e8e7b27b6
116 changed files with 3512 additions and 3288 deletions

View File

@@ -1,44 +0,0 @@
async function generateCountries() {
const { countries } = await import("@medusajs/medusa/dist/utils/countries.js")
const fs = await import("fs")
const path = await import("path")
const arr = countries.map((c) => {
const iso_2 = c.alpha2.toLowerCase()
const iso_3 = c.alpha3.toLowerCase()
const num_code = parseInt(c.numeric, 10)
const name = c.name.toUpperCase()
const display_name = c.name
return {
iso_2,
iso_3,
num_code,
name,
display_name,
}
})
const json = JSON.stringify(arr, null, 2)
const dest = path.join(__dirname, "../src/lib/countries.ts")
const destDir = path.dirname(dest)
const fileContent = `/** This file is auto-generated. Do not modify it manually. */\nimport type { RegionCountryDTO } from "@medusajs/types"\n\nexport const countries: Omit<RegionCountryDTO, "id">[] = ${json}`
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true })
}
fs.writeFileSync(dest, fileContent)
}
;(async () => {
console.log("Generating countries")
try {
await generateCountries()
console.log("Countries generated")
} catch (e) {
console.error(e)
}
})()