Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fileignoreconfig:
ignore_detectors:
- filecontent
- filename: package-lock.json
checksum: d55fde89f42bf080e243915bc5c3fd1d0302e1d11c0b14deb62fef3574c5ba56
checksum: 54777ceb615ca49bc21baf255b1ee9781da7e2868ff3d4292a6715bcbed33196
- filename: src/entry-editable.ts
checksum: 3ba7af9ed1c1adef2e2bd5610099716562bebb8ba750d4b41ddda99fc9eaf115
- filename: .husky/pre-commit
Expand Down
174 changes: 74 additions & 100 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
"test": "npm run clear:reports && jest --ci --json --coverage --testLocationInResults --outputFile=./reports/report.json",
"test:badges": "npm run clear:badges && npm run test && jest-coverage-badges --input ./reports/coverage/coverage-summary.json --output ./badges",
"test:debug": "jest --watchAll --runInBand",
"prebuild": "rimraf dist && mkdir -p dist/lib && curl -s --max-time 30 --fail https://artifacts.contentstack.com/regions.json -o dist/lib/regions.json || echo 'Warning: Failed to download regions.json'",
"prebuild": "rimraf dist && mkdir -p dist/lib && npm run download-regions",
"download-regions": "curl -s --max-time 30 --fail https://artifacts.contentstack.com/regions.json -o dist/lib/regions.json || echo 'Warning: Failed to download regions.json'",
"build": "tsc && rollup -c",
"format": "prettier --write \"src/**/*.ts\"",
"prepare": "husky install && npm run build",
"prepublishOnly": "npm test",
"pre-commit": "husky install && husky && chmod +x .husky/pre-commit && ./.husky/pre-commit",
"version": "npm run format && git add -A src",
"postversion": "git push && git push --tags",
"postinstall": "curl -s --max-time 30 --fail https://artifacts.contentstack.com/regions.json -o dist/lib/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 dist/lib/regions.json || echo 'Warning: Failed to download regions.json, using existing file if available'"
"postinstall": "npm run download-regions",
"postupdate": "npm run download-regions"
},
"author": "Contentstack",
"license": "MIT",
Expand Down
8 changes: 2 additions & 6 deletions src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import * as path from 'path';
import * as fs from 'fs';

// Type declarations for CommonJS runtime (rollup outputs CommonJS format)
declare const __dirname: string;

export interface ContentstackEndpoints {
[key: string]: string | ContentstackEndpoints;
}
Expand All @@ -25,9 +22,8 @@ export interface RegionsResponse {

// Load regions.json at runtime from the dist/lib directory
function loadRegions(): RegionsResponse {
// The bundled file is at dist/index.es.js, regions.json is at dist/lib/regions.json
// So __dirname will be 'dist/' and we need to go to 'dist/lib/regions.json'
const regionsPath = path.join(__dirname, 'lib', 'regions.json');
// Only look for regions.json in dist/lib directory
const regionsPath = path.join(process.cwd(), 'dist', 'lib', 'regions.json');

if (fs.existsSync(regionsPath)) {
try {
Expand Down
Loading