diff --git a/.github/workflows/build-images.yaml b/.github/workflows/build-images.yaml index 2f61d6059ee..ea0c0b63a88 100644 --- a/.github/workflows/build-images.yaml +++ b/.github/workflows/build-images.yaml @@ -24,9 +24,8 @@ jobs: secrets: inherit with: package: server - run-cmd: build:staging + run-cmd: build:prod tags: -t nangohq/nango-server:staging-${{ github.event.pull_request.head.sha || github.sha }} - nango-server-prod: if: github.ref == 'refs/heads/master' uses: ./.github/workflows/push-container.yaml @@ -49,5 +48,5 @@ jobs: secrets: inherit with: package: server - run-cmd: build:enterprise + run-cmd: build:prod tags: -t nangohq/nango-server:enterprise -t nangohq/nango-server:enterprise-${{ github.event.pull_request.head.sha || github.sha }} diff --git a/Dockerfile b/Dockerfile index 3ae834be5b3..6ff513db415 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,10 +54,6 @@ RUN true \ # /!\ Do not set NODE_ENV=production before building, it will break some modules # ENV NODE_ENV=production -ARG image_env - -# TODO: remove this, it's only needed for the frontend -ENV REACT_APP_ENV $image_env # Build the frontend RUN true \ @@ -99,12 +95,10 @@ WORKDIR /app/nango # COPY --from=build --chown=node:node /app/tmp /app/nango COPY --from=build /app/tmp /app/nango -ARG image_env ARG git_hash ENV PORT=8080 ENV NODE_ENV=production -ENV IMAGE_ENV $image_env ENV GIT_HASH $git_hash ENV SERVER_RUN_MODE=DOCKERIZED diff --git a/package.json b/package.json index 099cdf94f34..58978f704a6 100644 --- a/package.json +++ b/package.json @@ -17,21 +17,16 @@ "ts-build:docker": "tsc -b tsconfig.docker.json", "ts-clean": "npx rimraf packages/*/tsconfig.tsbuildinfo packages/*/dist", "docker-build": "docker build -f packages/server/Dockerfile -t nango-server:latest .", - "webapp-build:hosted": "cd ./packages/webapp && npm run build:hosted && cd ../..", - "webapp-build:staging": "cd ./packages/webapp && npm run build:staging && cd ../..", - "webapp-build:prod": "cd ./packages/webapp && npm run build:prod && cd ../..", - "webapp-build:enterprise": "cd ./packages/webapp && npm run build:enterprise && cd ../..", + "webapp-build": "cd ./packages/webapp && npm run build && cd ../..", "webapp-build:watch": "tsc -b -w packages/webapp/tsconfig.json", "docker-build:unified": "./scripts/build_docker.sh", - "build:hosted": "npm ci && npm run ts-build && npm run webapp-build:hosted && npm run connect-ui:build", - "build:staging": "npm ci && npm run ts-build && npm run webapp-build:staging", - "build:prod": "npm ci && npm run ts-build && npm run webapp-build:prod", - "build:enterprise": "npm ci && npm run ts-build && npm run webapp-build:enterprise", + "build:hosted": "npm ci && npm run ts-build && npm run webapp-build && npm run connect-ui:build", + "build:prod": "npm ci && npm run ts-build && npm run webapp-build", "server:dev:watch": "cd ./packages/server && npm run dev", "jobs:dev:watch": "npm run dev -w @nangohq/nango-jobs", "persist:dev:watch": "npm run dev -w @nangohq/nango-persist", "orchestrator:dev:watch": "npm run dev -w @nangohq/nango-orchestrator", - "webapp:dev:watch": "cd ./packages/webapp && npm run start:local", + "webapp:dev:watch": "cd ./packages/webapp && npm run start", "connect-ui:dev:watch": "cd ./packages/connect-ui && npm run dev", "connect-ui:build": "npm run -w @nangohq/connect-ui build", "prepare": "husky install", diff --git a/packages/server/lib/controllers/v1/getEnvJs.ts b/packages/server/lib/controllers/v1/getEnvJs.ts index e0260619c5d..9ad1f85bb4e 100644 --- a/packages/server/lib/controllers/v1/getEnvJs.ts +++ b/packages/server/lib/controllers/v1/getEnvJs.ts @@ -1,4 +1,4 @@ -import { basePublicUrl, baseUrl, connectUrl, flagHasAuth, flagHasManagedAuth, flagHasScripts, isCloud } from '@nangohq/utils'; +import { basePublicUrl, baseUrl, connectUrl, flagHasAuth, flagHasManagedAuth, flagHasScripts, flagHasSlack, isCloud } from '@nangohq/utils'; import { asyncWrapper } from '../../utils/asyncWrapper.js'; import type { WindowEnv } from '@nangohq/types'; import { envs } from '@nangohq/logs'; @@ -20,7 +20,8 @@ export const getEnvJs = asyncWrapper((_, res) => { scripts: flagHasScripts, auth: flagHasAuth, managedAuth: flagHasManagedAuth, - gettingStarted: true + gettingStarted: true, + slack: flagHasSlack } }; res.setHeader('content-type', 'text/javascript'); diff --git a/packages/types/lib/web/env.ts b/packages/types/lib/web/env.ts index 253463c6501..ba8ce8c603f 100644 --- a/packages/types/lib/web/env.ts +++ b/packages/types/lib/web/env.ts @@ -15,5 +15,6 @@ export interface WindowEnv { auth: boolean; managedAuth: boolean; gettingStarted: boolean; + slack: boolean; }; } diff --git a/packages/utils/lib/environment/detection.ts b/packages/utils/lib/environment/detection.ts index e47553384c3..fe3e6d063ba 100644 --- a/packages/utils/lib/environment/detection.ts +++ b/packages/utils/lib/environment/detection.ts @@ -25,3 +25,4 @@ export const flagHasManagedAuth = process.env['FLAG_MANAGED_AUTH_ENABLED'] === 'true' && Boolean(process.env['WORKOS_API_KEY'] && process.env['WORKOS_CLIENT_ID']); export const flagHasAPIRateLimit = process.env['FLAG_API_RATE_LIMIT_ENABLED'] !== 'false'; export const flagHasBigQuery = process.env['FLAG_BIG_QUERY_EXPORT_ENABLED'] === 'true'; +export const flagHasSlack = !isHosted; diff --git a/packages/webapp/.env.enterprise b/packages/webapp/.env.enterprise deleted file mode 100644 index a6d9e96c690..00000000000 --- a/packages/webapp/.env.enterprise +++ /dev/null @@ -1,2 +0,0 @@ -REACT_APP_ENV=enterprise - diff --git a/packages/webapp/.env.hosted b/packages/webapp/.env.hosted deleted file mode 100644 index 620eefa84c1..00000000000 --- a/packages/webapp/.env.hosted +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_ENV=hosted \ No newline at end of file diff --git a/packages/webapp/.env.local b/packages/webapp/.env.local deleted file mode 100644 index 42da5216624..00000000000 --- a/packages/webapp/.env.local +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_ENV=local diff --git a/packages/webapp/.env.prod b/packages/webapp/.env.prod deleted file mode 100644 index 0c0b842cc8f..00000000000 --- a/packages/webapp/.env.prod +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_ENV=production diff --git a/packages/webapp/.env.staging b/packages/webapp/.env.staging deleted file mode 100644 index 24c0243e885..00000000000 --- a/packages/webapp/.env.staging +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_ENV=staging diff --git a/packages/webapp/package.json b/packages/webapp/package.json index 901a1b4e718..e8efcc50e91 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -6,16 +6,7 @@ "start": "DISABLE_ESLINT_PLUGIN=true react-scripts start", "build": "DISABLE_ESLINT_PLUGIN=true react-scripts build", "test": "DISABLE_ESLINT_PLUGIN=true react-scripts test", - "eject": "DISABLE_ESLINT_PLUGIN=true react-scripts eject", - "start:hosted": "env-cmd -f .env.hosted npm run start", - "start:local": "env-cmd -f .env.local npm run start", - "start:staging": "env-cmd -f .env.staging npm run start", - "start:prod": "env-cmd -f .env.prod npm run start", - "build:hosted": "env-cmd -f .env.hosted npm run build", - "build:local": "env-cmd -f .env.local npm run build", - "build:enterprise": "env-cmd -f .env.enterprise npm run build", - "build:staging": "env-cmd -f .env.staging npm run build", - "build:prod": "env-cmd -f .env.prod npm run build" + "eject": "DISABLE_ESLINT_PLUGIN=true react-scripts eject" }, "browserslist": { "production": [ diff --git a/packages/webapp/src/env.d.ts b/packages/webapp/src/env.d.ts index 04e6ae3dde3..d6b405de728 100644 --- a/packages/webapp/src/env.d.ts +++ b/packages/webapp/src/env.d.ts @@ -6,7 +6,6 @@ declare global { namespace NodeJS { interface ProcessEnv { PORT: string; - REACT_APP_ENV: 'development' | 'staging' | 'production' | 'hosted' | 'enterprise'; } } } diff --git a/packages/webapp/src/pages/Connection/CreateLegacy.tsx b/packages/webapp/src/pages/Connection/CreateLegacy.tsx index 39d67436419..2afd965a36a 100644 --- a/packages/webapp/src/pages/Connection/CreateLegacy.tsx +++ b/packages/webapp/src/pages/Connection/CreateLegacy.tsx @@ -9,7 +9,7 @@ import { Tooltip } from '@geist-ui/core'; import type { Integration } from '@nangohq/server'; import useSet from '../../hooks/useSet'; -import { isHosted, isStaging, baseUrl } from '../../utils/utils'; +import { isCloudProd } from '../../utils/utils'; import { useGetIntegrationListAPI, useGetHmacAPI } from '../../utils/api'; import { useAnalyticsTrack } from '../../utils/analytics'; import DashboardLayout from '../../layout/DashboardLayout'; @@ -22,6 +22,7 @@ import type { AuthModeType } from '@nangohq/types'; import { useEnvironment } from '../../hooks/useEnvironment'; import { Helmet } from 'react-helmet'; import { useSearchParam } from 'react-use'; +import { globalEnv } from '../../utils/env'; export const ConnectionCreateLegacy: React.FC = () => { const { mutate } = useSWRConfig(); @@ -108,7 +109,7 @@ export const ConnectionCreateLegacy: React.FC = () => { if (environmentAndAccount) { const { environment, host } = environmentAndAccount; setPublicKey(environment.public_key); - setHostUrl(host || baseUrl()); + setHostUrl(host || globalEnv.apiUrl); setWebsocketsPath(environment.websockets_path || ''); setIsHmacEnabled(Boolean(environment.hmac_key)); } @@ -336,7 +337,7 @@ export const ConnectionCreateLegacy: React.FC = () => { const snippet = () => { const args = []; - if (isStaging() || isHosted()) { + if (!isCloudProd()) { args.push(`host: '${hostUrl}'`); if (websocketsPath && websocketsPath !== '/') { args.push(`websocketsPath: '${websocketsPath}'`); diff --git a/packages/webapp/src/pages/Connection/Show.tsx b/packages/webapp/src/pages/Connection/Show.tsx index e00ca5f36e8..08f9b434aa2 100644 --- a/packages/webapp/src/pages/Connection/Show.tsx +++ b/packages/webapp/src/pages/Connection/Show.tsx @@ -14,7 +14,6 @@ import { Button } from '../../components/ui/button/Button'; import { useEnvironment } from '../../hooks/useEnvironment'; import { Syncs } from './Syncs'; import { Authorization } from './Authorization'; -import { isHosted } from '../../utils/utils'; import { connectSlack } from '../../utils/slack-connection'; import { useStore } from '../../store'; @@ -29,6 +28,7 @@ import { useToast } from '../../hooks/useToast'; import { useListIntegration } from '../../hooks/useIntegration'; import { EndUserProfile } from './components/EndUserProfile'; import { getConnectionDisplayName } from '../../utils/endUser'; +import { globalEnv } from '../../utils/env'; export enum Tabs { Syncs, @@ -68,7 +68,7 @@ export const ConnectionShow: React.FC = () => { if (location.hash === '#models' || location.hash === '#syncs') { setActiveTab(Tabs.Syncs); } - if (location.hash === '#authorization' || isHosted()) { + if (location.hash === '#authorization' || !globalEnv.features.scripts) { setActiveTab(Tabs.Authorization); } }, [location]); @@ -237,7 +237,7 @@ export const ConnectionShow: React.FC = () => { - {!slackIsConnected && !isHosted() && showSlackBanner && ( + {!slackIsConnected && globalEnv.features.slack && showSlackBanner && ( setShowSlackBanner(false)} diff --git a/packages/webapp/src/pages/Environment/Settings.tsx b/packages/webapp/src/pages/Environment/Settings.tsx index 9603935b29e..1b1ac57d290 100644 --- a/packages/webapp/src/pages/Environment/Settings.tsx +++ b/packages/webapp/src/pages/Environment/Settings.tsx @@ -16,7 +16,7 @@ import { apiFetch } from '../../utils/api'; import IntegrationLogo from '../../components/ui/IntegrationLogo'; -import { isHosted, defaultCallback } from '../../utils/utils'; +import { defaultCallback } from '../../utils/utils'; import DashboardLayout from '../../layout/DashboardLayout'; import { LeftNavBarItems } from '../../components/LeftNavBar'; import SecretInput from '../../components/ui/input/SecretInput'; @@ -691,10 +691,10 @@ export const EnvironmentSettings: React.FC = () => { )} - {!isHosted() && ( + {globalEnv.features.slack && (
-