From 1d6fe87801bf8f5d635abeab9607b2b72221505f Mon Sep 17 00:00:00 2001 From: Nadeem <110535104+nadeem-cs@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:19:31 +0530 Subject: [PATCH] =?UTF-8?q?Revert=20"feat:=20implement=20download=20script?= =?UTF-8?q?=20for=20regions.json=20and=20update=20postinsta=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 ++-- scripts/download-regions.cjs | 47 ------------------------------------ scripts/download-regions.js | 1 - 3 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 scripts/download-regions.cjs delete mode 100644 scripts/download-regions.js diff --git a/package.json b/package.json index 7a59809..893eba3 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,8 @@ "build:esm": "node tools/cleanup esm && tsc -p config/tsconfig.esm.json", "build:types": "node tools/cleanup types && tsc -p config/tsconfig.types.json", "husky-check": "npm run build && husky && chmod +x .husky/pre-commit", - "postinstall": "node scripts/download-regions.cjs", - "postupdate": "node scripts/download-regions.cjs" + "postinstall": "curl -s --max-time 30 --fail https://artifacts.contentstack.com/regions.json -o src/assets/regions.json || echo 'Warning: Failed to download regions.json, using existing file if available'", + "postupdate": "curl -s --max-time 30 --fail https://artifacts.contentstack.com/regions.json -o src/assets/regions.json || echo 'Warning: Failed to download regions.json, using existing file if available'" }, "dependencies": { "@contentstack/core": "^1.3.1", @@ -44,7 +44,6 @@ }, "files": [ "dist", - "scripts/download-regions.cjs", "package.json", "README.md", "src/assets/regions.json" diff --git a/scripts/download-regions.cjs b/scripts/download-regions.cjs deleted file mode 100644 index db8bacb..0000000 --- a/scripts/download-regions.cjs +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env node -const fs = require('fs'); -const https = require('https'); -const path = require('path'); - -const targetFiles = [ - 'src/assets/regions.json', - 'dist/modern/assets/regions.json', - 'dist/legacy/assets/regions.json' -]; - -function downloadRegions(targetFile) { - const targetDir = path.dirname(targetFile); - - // Ensure directory exists - if (!fs.existsSync(targetDir)) { - fs.mkdirSync(targetDir, { recursive: true }); - } - - const url = 'https://artifacts.contentstack.com/regions.json'; - - https.get(url, { timeout: 30000 }, (response) => { - if (response.statusCode === 200) { - const fileStream = fs.createWriteStream(targetFile); - response.pipe(fileStream); - - fileStream.on('close', () => { - console.log(`✓ Updated ${targetFile}`); - }); - - fileStream.on('error', (err) => { - console.log(`Warning: Failed to write ${targetFile}, using bundled version`); - }); - } else { - console.log(`Warning: HTTP ${response.statusCode}, using bundled regions.json`); - } - }).on('error', (err) => { - console.log(`Warning: Failed to download regions.json (${err.message}), using bundled version`); - }).setTimeout(30000, function() { - this.destroy(); - console.log('Warning: Download timeout, using bundled regions.json'); - }); -} - -// Download to all target locations -targetFiles.forEach(downloadRegions); - diff --git a/scripts/download-regions.js b/scripts/download-regions.js deleted file mode 100644 index 0519ecb..0000000 --- a/scripts/download-regions.js +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file