diff --git a/CHANGELOG.md b/CHANGELOG.md index 28dd7eb..8f08b87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,141 +1,137 @@ -## [2.4.3](https://github.com/stallion-tech/stallion-cli/compare/v2.4.2...v2.4.3) (2026-02-13) +# [2.5.0-alpha.1](https://github.com/stallion-tech/stallion-cli/compare/v2.4.3...v2.5.0-alpha.1) (2026-06-06) ### Bug Fixes -* added Custom Bundle Path Option ([#40](https://github.com/stallion-tech/stallion-cli/issues/40)) ([d0ece26](https://github.com/stallion-tech/stallion-cli/commit/d0ece2668284eb011379244382aa5159ec6f2e82)) +* multi region support ([#41](https://github.com/stallion-tech/stallion-cli/issues/41)) ([22bc951](https://github.com/stallion-tech/stallion-cli/commit/22bc951527c60451e8056431f0f80e0054b035b8)) -## [2.4.2](https://github.com/stallion-tech/stallion-cli/compare/v2.4.1...v2.4.2) (2026-01-19) +### Features + +* refactor CLI and added support for bundle signing ([#27](https://github.com/stallion-tech/stallion-cli/issues/27)) ([f3ffcbd](https://github.com/stallion-tech/stallion-cli/commit/f3ffcbdb3800a9043250f625662c757667f4a8ea)) +* windows RN executable Fix ([#28](https://github.com/stallion-tech/stallion-cli/issues/28)) ([65f9760](https://github.com/stallion-tech/stallion-cli/commit/65f9760cebbf0c84fcbfeafac02997bbd671fee3)) + +## [2.4.3](https://github.com/stallion-tech/stallion-cli/compare/v2.4.2...v2.4.3) (2026-02-13) ### Bug Fixes -* download progress ([f5c7802](https://github.com/stallion-tech/stallion-cli/commit/f5c78024f442ae34a67a1c258b5aa30f0f928b48)) +- added Custom Bundle Path Option ([#40](https://github.com/stallion-tech/stallion-cli/issues/40)) ([d0ece26](https://github.com/stallion-tech/stallion-cli/commit/d0ece2668284eb011379244382aa5159ec6f2e82)) -## [2.4.1](https://github.com/stallion-tech/stallion-cli/compare/v2.4.0...v2.4.1) (2026-01-13) +## [2.4.2](https://github.com/stallion-tech/stallion-cli/compare/v2.4.1...v2.4.2) (2026-01-19) + +### Bug Fixes +- download progress ([f5c7802](https://github.com/stallion-tech/stallion-cli/commit/f5c78024f442ae34a67a1c258b5aa30f0f928b48)) + +## [2.4.1](https://github.com/stallion-tech/stallion-cli/compare/v2.4.0...v2.4.1) (2026-01-13) ### Bug Fixes -* fixed Assets Issue ([#38](https://github.com/stallion-tech/stallion-cli/issues/38)) ([ce564a5](https://github.com/stallion-tech/stallion-cli/commit/ce564a5d00cdb151e8a577e012c685649f50ea3b)) +- fixed Assets Issue ([#38](https://github.com/stallion-tech/stallion-cli/issues/38)) ([ce564a5](https://github.com/stallion-tech/stallion-cli/commit/ce564a5d00cdb151e8a577e012c685649f50ea3b)) # [2.4.0](https://github.com/stallion-tech/stallion-cli/compare/v2.3.1...v2.4.0) (2026-01-09) - ### Features -* sourcemaps export, hermes path fix ([b563b44](https://github.com/stallion-tech/stallion-cli/commit/b563b445e01cd6ff91ed02113e9c41028322112b)) +- refactor CLI and added support for bundle signing ([#27](https://github.com/stallion-tech/stallion-cli/issues/27)) ([f3ffcbd](https://github.com/stallion-tech/stallion-cli/commit/f3ffcbdb3800a9043250f625662c757667f4a8ea)) +- windows RN executable Fix ([#28](https://github.com/stallion-tech/stallion-cli/issues/28)) ([65f9760](https://github.com/stallion-tech/stallion-cli/commit/65f9760cebbf0c84fcbfeafac02997bbd671fee3)) +- sourcemaps export, hermes path fix ([b563b44](https://github.com/stallion-tech/stallion-cli/commit/b563b445e01cd6ff91ed02113e9c41028322112b)) -## [2.3.1](https://github.com/stallion-tech/stallion-cli/compare/v2.3.0...v2.3.1) (2025-06-27) +# [2.4.0-alpha.1](https://github.com/stallion-tech/stallion-cli/compare/v2.3.0...v2.4.0-alpha.1) (2025-06-26) +## [2.3.1](https://github.com/stallion-tech/stallion-cli/compare/v2.3.0...v2.3.1) (2025-06-27) ### Bug Fixes -* skip user validation when CI token is provided ([#33](https://github.com/stallion-tech/stallion-cli/issues/33)) ([901eab9](https://github.com/stallion-tech/stallion-cli/commit/901eab97c08629d4c7aac8ec3e9f7ebba952ff4b)) +- skip user validation when CI token is provided ([#33](https://github.com/stallion-tech/stallion-cli/issues/33)) ([901eab9](https://github.com/stallion-tech/stallion-cli/commit/901eab97c08629d4c7aac8ec3e9f7ebba952ff4b)) # [2.3.0](https://github.com/stallion-tech/stallion-cli/compare/v2.2.0...v2.3.0) (2025-06-22) - ### Features -* Stallion CI Support ([#30](https://github.com/stallion-tech/stallion-cli/issues/30)) ([f9a0523](https://github.com/stallion-tech/stallion-cli/commit/f9a0523c8082a82e662fe71c46c9c7bc75963cae)) +- Stallion CI Support ([#30](https://github.com/stallion-tech/stallion-cli/issues/30)) ([f9a0523](https://github.com/stallion-tech/stallion-cli/commit/f9a0523c8082a82e662fe71c46c9c7bc75963cae)) # [2.2.0](https://github.com/stallion-tech/stallion-cli/compare/v2.1.0...v2.2.0) (2025-06-19) - ### Features -* Alpha Release with windows bundle command fix ([1880d0e](https://github.com/stallion-tech/stallion-cli/commit/1880d0ef8c039a3a0b8710540a80b89667b2292a)), closes [#21](https://github.com/stallion-tech/stallion-cli/issues/21) [#26](https://github.com/stallion-tech/stallion-cli/issues/26) [#27](https://github.com/stallion-tech/stallion-cli/issues/27) [#28](https://github.com/stallion-tech/stallion-cli/issues/28) +- Alpha Release with windows bundle command fix ([1880d0e](https://github.com/stallion-tech/stallion-cli/commit/1880d0ef8c039a3a0b8710540a80b89667b2292a)), closes [#21](https://github.com/stallion-tech/stallion-cli/issues/21) [#26](https://github.com/stallion-tech/stallion-cli/issues/26) [#27](https://github.com/stallion-tech/stallion-cli/issues/27) [#28](https://github.com/stallion-tech/stallion-cli/issues/28) # [2.1.0-alpha.2](https://github.com/stallion-tech/stallion-cli/compare/v2.1.0-alpha.1...v2.1.0-alpha.2) (2025-06-11) - ### Features -* windows RN executable Fix ([#28](https://github.com/stallion-tech/stallion-cli/issues/28)) ([65f9760](https://github.com/stallion-tech/stallion-cli/commit/65f9760cebbf0c84fcbfeafac02997bbd671fee3)) +- windows RN executable Fix ([#28](https://github.com/stallion-tech/stallion-cli/issues/28)) ([65f9760](https://github.com/stallion-tech/stallion-cli/commit/65f9760cebbf0c84fcbfeafac02997bbd671fee3)) # [2.1.0-alpha.1](https://github.com/stallion-tech/stallion-cli/compare/v2.0.2...v2.1.0-alpha.1) (2025-05-23) - ### Features -* refactor CLI and added support for bundle signing ([#27](https://github.com/stallion-tech/stallion-cli/issues/27)) ([f3ffcbd](https://github.com/stallion-tech/stallion-cli/commit/f3ffcbdb3800a9043250f625662c757667f4a8ea)) +- refactor CLI and added support for bundle signing ([#27](https://github.com/stallion-tech/stallion-cli/issues/27)) ([f3ffcbd](https://github.com/stallion-tech/stallion-cli/commit/f3ffcbdb3800a9043250f625662c757667f4a8ea)) ## [2.0.2](https://github.com/stallion-tech/stallion-cli/compare/v2.0.1...v2.0.2) (2025-02-11) - ### Bug Fixes -* improved hermes logging ([4094aa6](https://github.com/stallion-tech/stallion-cli/commit/4094aa6bbf927f1f87b2f51f57b17db0f3e5f7df)) +- improved hermes logging ([4094aa6](https://github.com/stallion-tech/stallion-cli/commit/4094aa6bbf927f1f87b2f51f57b17db0f3e5f7df)) ## [2.0.1](https://github.com/stallion-tech/stallion-cli/compare/v2.0.0...v2.0.1) (2025-02-01) - ### Bug Fixes -* hermes enabled by default ([6770a74](https://github.com/stallion-tech/stallion-cli/commit/6770a746a190ca1778c9f59957a1c38ccdda0c44)) +- hermes enabled by default ([6770a74](https://github.com/stallion-tech/stallion-cli/commit/6770a746a190ca1778c9f59957a1c38ccdda0c44)) # [2.0.0](https://github.com/stallion-tech/stallion-cli/compare/v1.1.4...v2.0.0) (2024-11-04) - ### Features -* added Stallion 2.0 changes ([#17](https://github.com/stallion-tech/stallion-cli/issues/17)) ([6bfe630](https://github.com/stallion-tech/stallion-cli/commit/6bfe630483dd15073ae02c111748c4e8f85e6a38)) - +- added Stallion 2.0 changes ([#17](https://github.com/stallion-tech/stallion-cli/issues/17)) ([6bfe630](https://github.com/stallion-tech/stallion-cli/commit/6bfe630483dd15073ae02c111748c4e8f85e6a38)) ### BREAKING CHANGES -* Stallion 2.0 update +- Stallion 2.0 update ## [1.1.4](https://github.com/stallion-tech/stallion-cli/compare/v1.1.3...v1.1.4) (2024-11-04) - ### Reverts -* Revert "feat!: stallion 2.0 cli update (#15)" (#16) ([c685692](https://github.com/stallion-tech/stallion-cli/commit/c6856929ebd20da9af198b7cb819e11d60a212ff)), closes [#15](https://github.com/stallion-tech/stallion-cli/issues/15) [#16](https://github.com/stallion-tech/stallion-cli/issues/16) +- Revert "feat!: stallion 2.0 cli update (#15)" (#16) ([c685692](https://github.com/stallion-tech/stallion-cli/commit/c6856929ebd20da9af198b7cb819e11d60a212ff)), closes [#15](https://github.com/stallion-tech/stallion-cli/issues/15) [#16](https://github.com/stallion-tech/stallion-cli/issues/16) ## [1.1.3](https://github.com/stallion-tech/stallion-cli/compare/v1.1.2...v1.1.3) (2024-04-11) - ### Bug Fixes -* removed check for stallion.config.js ([#14](https://github.com/stallion-tech/stallion-cli/issues/14)) ([08fa8bf](https://github.com/stallion-tech/stallion-cli/commit/08fa8bf480d098970ae3a388decc8ad38d19fa9c)) +- removed check for stallion.config.js ([#14](https://github.com/stallion-tech/stallion-cli/issues/14)) ([08fa8bf](https://github.com/stallion-tech/stallion-cli/commit/08fa8bf480d098970ae3a388decc8ad38d19fa9c)) ## [1.1.2](https://github.com/stallion-tech/stallion-cli/compare/v1.1.1...v1.1.2) (2024-01-15) - ### Bug Fixes -* optimized upload and added ci token support ([caf665d](https://github.com/stallion-tech/stallion-cli/commit/caf665d1a5161e0474603ef80e208cfb2eb63b05)) +- optimized upload and added ci token support ([caf665d](https://github.com/stallion-tech/stallion-cli/commit/caf665d1a5161e0474603ef80e208cfb2eb63b05)) ## [1.1.1](https://github.com/stallion-tech/stallion-cli/compare/v1.1.0...v1.1.1) (2023-09-13) - ### Bug Fixes -* updated domain redirect and errors ([#12](https://github.com/stallion-tech/stallion-cli/issues/12)) ([aa5c648](https://github.com/stallion-tech/stallion-cli/commit/aa5c648fefe105754ee1e3518a06cc2282301495)) +- updated domain redirect and errors ([#12](https://github.com/stallion-tech/stallion-cli/issues/12)) ([aa5c648](https://github.com/stallion-tech/stallion-cli/commit/aa5c648fefe105754ee1e3518a06cc2282301495)) # [1.1.0](https://github.com/redhorse-tech/stallion-cli/compare/v1.0.0...v1.1.0) (2023-09-08) - ### Bug Fixes -* updated node version to 14 ([cf9cef8](https://github.com/redhorse-tech/stallion-cli/commit/cf9cef8ff3e885b4e413f25f9a9853f189125f89)) - +- updated node version to 14 ([cf9cef8](https://github.com/redhorse-tech/stallion-cli/commit/cf9cef8ff3e885b4e413f25f9a9853f189125f89)) ### Features -* updated min node version to 10 ([90718b9](https://github.com/redhorse-tech/stallion-cli/commit/90718b95bbbee084d94af7a931984fe97a424972)) +- updated min node version to 10 ([90718b9](https://github.com/redhorse-tech/stallion-cli/commit/90718b95bbbee084d94af7a931984fe97a424972)) # 1.0.0 (2023-09-08) - ### Bug Fixes -* exec and util function ([5da81dc](https://github.com/redhorse-tech/stallion-cli/commit/5da81dcacd724cd2052f5f1bea5b42a5b10f7734)) -* wrong base url ([408680f](https://github.com/redhorse-tech/stallion-cli/commit/408680f1a190d0ddc66e68644d4dc1ded2cf6b0f)) - +- exec and util function ([5da81dc](https://github.com/redhorse-tech/stallion-cli/commit/5da81dcacd724cd2052f5f1bea5b42a5b10f7734)) +- wrong base url ([408680f](https://github.com/redhorse-tech/stallion-cli/commit/408680f1a190d0ddc66e68644d4dc1ded2cf6b0f)) ### Features -* added semantic release ([#7](https://github.com/redhorse-tech/stallion-cli/issues/7)) ([0b89da4](https://github.com/redhorse-tech/stallion-cli/commit/0b89da433060316502a033d604381957f65be201)) +- added semantic release ([#7](https://github.com/redhorse-tech/stallion-cli/issues/7)) ([0b89da4](https://github.com/redhorse-tech/stallion-cli/commit/0b89da433060316502a033d604381957f65be201)) diff --git a/package.json b/package.json index e3a2ba9..acc9e49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stallion-cli", - "version": "2.4.2", + "version": "2.5.0", "description": "A powerful CLI tool for managing your Stallion deployments", "main": "index.js", "bin": { diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index c6eec78..024839f 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -11,4 +11,7 @@ export const ENDPOINTS = { PROMOTE_BUNDLE: "/cli/ci/promote", UPDATE_RELEASE: "/cli/ci/update-release", }, + ORG: { + GET_ORG_REGION: "/cli/org/get-region", + }, } as const; diff --git a/src/commands/publish-bundle.command.ts b/src/commands/publish-bundle.command.ts index 6f45de1..4b1d394 100644 --- a/src/commands/publish-bundle.command.ts +++ b/src/commands/publish-bundle.command.ts @@ -16,10 +16,11 @@ import { progress } from "@/utils/progress"; import { ApiClient } from "@/api/api-client"; import { calculateSHA2565Hash, signBundle } from "@/utils/hash-utils"; import { ENDPOINTS } from "@/api/endpoints"; -import { CONFIG } from "@/api/config"; import { createDefaultTokenStore } from "@/utils/token-store"; import { createZip } from "@/utils/archive"; import { keepArtifacts as saveArtifacts } from "@/utils/copy"; +import { getApiBaseUrl } from "@/utils/common"; +import { resolveRegion } from "@/utils/region"; const expectedOptions: CommandOption[] = [ { @@ -203,7 +204,17 @@ export class PublishBundleCommand extends BaseCommand { const stats = await fs.stat(zipPath); logger.info(`Bundle size: ${(stats.size / 1024 / 1024).toFixed(2)} MB`); - const client = new ApiClient(CONFIG.API.BASE_URL); + const tokenStore = createDefaultTokenStore(); + const tokenData = await tokenStore.get("cli"); + const accessToken = tokenData?.accessToken?.token; + + const region = await resolveRegion({ + uploadPath, + ciToken, + accessToken, + }); + + const client = new ApiClient(getApiBaseUrl(region)); const hash = await progress( chalk.white("Publishing bundle"), (updateProgress) => diff --git a/src/commands/release-bundle.command.ts b/src/commands/release-bundle.command.ts index 6246bcf..2b12b9d 100644 --- a/src/commands/release-bundle.command.ts +++ b/src/commands/release-bundle.command.ts @@ -6,7 +6,8 @@ import chalk from "chalk"; import { progress } from "@/utils/progress"; import { ApiClient } from "@/api/api-client"; import { ENDPOINTS } from "@/api/endpoints"; -import { CONFIG } from "@/api/config"; +import { getApiBaseUrl } from "@/utils/common"; +import { parseTokenRegion } from "@/utils/region"; const expectedOptions: CommandOption[] = [ { @@ -83,7 +84,8 @@ export class ReleaseBundleCommand extends BaseCommand { isPaused, }; - const client = new ApiClient(CONFIG.API.BASE_URL); + const region = parseTokenRegion(ciToken) ?? "ap"; + const client = new ApiClient(getApiBaseUrl(region)); await progress( chalk.cyanBright("Releasing bundle"), diff --git a/src/commands/update-release.command.ts b/src/commands/update-release.command.ts index cc3d132..1be6dcc 100644 --- a/src/commands/update-release.command.ts +++ b/src/commands/update-release.command.ts @@ -6,7 +6,8 @@ import chalk from "chalk"; import { progress } from "@/utils/progress"; import { ApiClient } from "@/api/api-client"; import { ENDPOINTS } from "@/api/endpoints"; -import { CONFIG } from "@/api/config"; +import { getApiBaseUrl } from "@/utils/common"; +import { parseTokenRegion } from "@/utils/region"; const expectedOptions: CommandOption[] = [ { @@ -90,7 +91,8 @@ export class UpdateReleaseCommand extends BaseCommand { rolloutPercent: rolloutPercent ? Number(rolloutPercent) : undefined, }; - const client = new ApiClient(CONFIG.API.BASE_URL); + const region = parseTokenRegion(ciToken) ?? "ap"; + const client = new ApiClient(getApiBaseUrl(region)); try { await progress(chalk.white("Updating release"), () => diff --git a/src/utils/common.ts b/src/utils/common.ts new file mode 100644 index 0000000..d205f33 --- /dev/null +++ b/src/utils/common.ts @@ -0,0 +1,9 @@ +import { CONFIG } from "@/api/config"; + +export function getApiBaseUrl(region: string): string { + if (!region) { + return CONFIG.API.BASE_URL; + } + + return `https://api-${region}.stalliontech.io/api/v1`; +} diff --git a/src/utils/region.ts b/src/utils/region.ts new file mode 100644 index 0000000..562ecfa --- /dev/null +++ b/src/utils/region.ts @@ -0,0 +1,39 @@ +import { ApiClient } from "@/api/api-client"; +import { CONFIG } from "@/api/config"; +import { ENDPOINTS } from "@/api/endpoints"; + +const REGIONS = ["ap", "us"] as const; + +export function parseTokenRegion(token: string): string | null { + if (!token) return null; + if (token.startsWith("stl_") && token.length === 43 && token[6] === "_") { + const code = token.substring(4, 6); + return (REGIONS as readonly string[]).includes(code) ? code : null; + } + return null; +} + +export async function resolveRegion(opts: { + uploadPath: string; + ciToken?: string; + accessToken?: string; +}): Promise { + try { + if (opts.ciToken) { + return parseTokenRegion(opts.ciToken) ?? "ap"; + } + + const client = new ApiClient(CONFIG.API.BASE_URL); + if (opts.accessToken) { + client.setToken(opts.accessToken); + } + + const { data } = await client.post<{ data: { region: string } }>( + ENDPOINTS.ORG.GET_ORG_REGION, + { uploadPath: opts.uploadPath } + ); + return data?.region ?? "ap"; + } catch (error) { + throw new Error("Something went wrong"); + } +}