From 8230d8198079434ebf35c68ccf4efc9235a8e8f5 Mon Sep 17 00:00:00 2001 From: Ivan S Glazunov Date: Mon, 9 Sep 2024 14:01:44 +0300 Subject: [PATCH] 0.0.465 --- call.mjs | 17 +++++++++++++---- package.json | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/call.mjs b/call.mjs index abe83a01..fb3826cc 100755 --- a/call.mjs +++ b/call.mjs @@ -11,6 +11,11 @@ import fs from 'fs'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; import axios from 'axios'; +import { promisify } from 'util'; + +const isGitpod = !!process?.env?.GITPOD_WORKSPACE_ID; + +const execP = promisify(exec); // const __filename = fileURLToPath(import.meta.url); // const __dirname = dirname(__filename); @@ -24,6 +29,10 @@ async function getPublicIP() { return (await axios.get('https://api.ipify.org'))?.data; } +async function gitpodUrl(port) { + const r = await execP(`echo $(gp url ${port})`); + return r.stdout.replace('\n','') +} // const DEEPLINKS_CALL_OPTIONS = process.env.DEEPLINKS_CALL_OPTIONS || '{ "operation": "run" }'; const DEEPLINKS_CALL_OPTIONS = process.env.DEEPLINKS_CALL_OPTIONS; @@ -63,11 +72,11 @@ if (options.generate) { const generated = { "operation": "run", "envs": { - "DEEPLINKS_PUBLIC_URL": `${deeplinks}`, - "NEXT_PUBLIC_DEEPLINKS_URL": `${deeplinks}`, - "NEXT_PUBLIC_GQL_PATH": `${deeplinks}/gql`, + "DEEPLINKS_PUBLIC_URL": isGidpod ? gitpodUrl(3006) : `${deeplinks}`, + "NEXT_PUBLIC_DEEPLINKS_URL": isGidpod ? gitpodUrl(3006) : `${deeplinks}`, + "NEXT_PUBLIC_GQL_PATH": isGidpod ? gitpodUrl(3006)+'/gql' : `${deeplinks}/gql`, "NEXT_PUBLIC_GQL_SSL": "0", - "NEXT_PUBLIC_DEEPLINKS_SERVER": `${deepcase}`, + "NEXT_PUBLIC_DEEPLINKS_SERVER": isGidpod ? gitpodUrl(3007) : `${deepcase}`, "NEXT_PUBLIC_ENGINES_ROUTE": "0", "NEXT_PUBLIC_DISABLE_CONNECTOR": "1", "JWT_SECRET": jwtSecret, diff --git a/package.json b/package.json index fe7052f2..8ed347d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@deep-foundation/deeplinks", - "version": "0.0.464", + "version": "0.0.465", "license": "Unlicense", "type": "module", "scripts": {