diff --git a/.eslintrc b/.eslintrc index 65facbe7..33f3e738 100644 --- a/.eslintrc +++ b/.eslintrc @@ -58,14 +58,5 @@ }, "env": { "jest": true - }, - "globals": { - "__DEV__": true, - "SLACK_KEY": true, - "DEPLOYMENT": true, - "BASE_URL": true, - "SENTRY_DSN": true, - "afterAll": true, - "Sentry": true } } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5dc4ecba..5f61043c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,9 @@ WORKDIR $APP_PATH COPY . $APP_PATH RUN yarn install --pure-lockfile +RUN yarn build RUN cp -r /opt/outline/node_modules /opt/node_modules -CMD yarn build && yarn start +CMD yarn start EXPOSE 3000 diff --git a/app/components/Analytics.js b/app/components/Analytics.js index 284c203b..30cf0832 100644 --- a/app/components/Analytics.js +++ b/app/components/Analytics.js @@ -1,6 +1,7 @@ // @flow /* global ga */ import * as React from "react"; +import env from "env"; type Props = { children?: React.Node, @@ -8,7 +9,7 @@ type Props = { export default class Analytics extends React.Component { componentDidMount() { - if (!process.env.GOOGLE_ANALYTICS_ID) return; + if (!env.GOOGLE_ANALYTICS_ID) return; // standard Google Analytics script window.ga = @@ -20,7 +21,7 @@ export default class Analytics extends React.Component { // $FlowIssue ga.l = +new Date(); - ga("create", process.env.GOOGLE_ANALYTICS_ID, "auto"); + ga("create", env.GOOGLE_ANALYTICS_ID, "auto"); ga("set", { dimension1: "true" }); ga("send", "pageview"); diff --git a/app/components/Authenticated.js b/app/components/Authenticated.js index a4fc3fd4..b1dac2fb 100644 --- a/app/components/Authenticated.js +++ b/app/components/Authenticated.js @@ -5,6 +5,7 @@ import { Redirect } from "react-router-dom"; import AuthStore from "stores/AuthStore"; import LoadingIndicator from "components/LoadingIndicator"; import { isCustomSubdomain } from "shared/utils/domains"; +import env from "env"; type Props = { auth: AuthStore, @@ -23,7 +24,7 @@ const Authenticated = observer(({ auth, children }: Props) => { // If we're authenticated but viewing a subdomain that doesn't match the // currently authenticated team then kick the user to the teams subdomain. if ( - process.env.SUBDOMAINS_ENABLED && + env.SUBDOMAINS_ENABLED && team.subdomain && isCustomSubdomain(hostname) && !hostname.startsWith(`${team.subdomain}.`) diff --git a/app/components/CopyToClipboard.js b/app/components/CopyToClipboard.js index d6bb9784..5341d2ac 100644 --- a/app/components/CopyToClipboard.js +++ b/app/components/CopyToClipboard.js @@ -14,7 +14,7 @@ class CopyToClipboard extends React.PureComponent { const { text, onCopy, children } = this.props; const elem = React.Children.only(children); copy(text, { - debug: !!__DEV__, + debug: process.env.NODE_ENV !== "production", }); if (onCopy) onCopy(); diff --git a/app/components/ErrorBoundary.js b/app/components/ErrorBoundary.js index eb1b6062..77ba0613 100644 --- a/app/components/ErrorBoundary.js +++ b/app/components/ErrorBoundary.js @@ -23,7 +23,7 @@ class ErrorBoundary extends React.Component { console.error(error); if (window.Sentry) { - Sentry.captureException(error); + window.Sentry.captureException(error); } } diff --git a/app/components/Sidebar/Settings.js b/app/components/Sidebar/Settings.js index 09bf725f..94242fff 100644 --- a/app/components/Sidebar/Settings.js +++ b/app/components/Sidebar/Settings.js @@ -29,6 +29,7 @@ import HeaderBlock from "./components/HeaderBlock"; import Version from "./components/Version"; import PoliciesStore from "stores/PoliciesStore"; import AuthStore from "stores/AuthStore"; +import env from "env"; type Props = { history: RouterHistory, @@ -146,7 +147,7 @@ class SettingsSidebar extends React.Component { )} {can.update && - process.env.DEPLOYMENT !== "hosted" && ( + env.DEPLOYMENT !== "hosted" && (
Installation
diff --git a/app/components/SocketProvider.js b/app/components/SocketProvider.js index 5c69f9af..ceb19999 100644 --- a/app/components/SocketProvider.js +++ b/app/components/SocketProvider.js @@ -13,6 +13,7 @@ import PoliciesStore from "stores/PoliciesStore"; import ViewsStore from "stores/ViewsStore"; import AuthStore from "stores/AuthStore"; import UiStore from "stores/UiStore"; +import env from "env"; export const SocketContext: any = React.createContext(); @@ -34,7 +35,7 @@ class SocketProvider extends React.Component { @observable socket; componentDidMount() { - if (!process.env.WEBSOCKETS_ENABLED) return; + if (!env.WEBSOCKETS_ENABLED) return; this.socket = io(window.location.origin, { path: "/realtime", diff --git a/app/env.js b/app/env.js new file mode 100644 index 00000000..c4860403 --- /dev/null +++ b/app/env.js @@ -0,0 +1,3 @@ +// @flow +const env = window.env; +export default env; diff --git a/app/index.js b/app/index.js index 27a6b80a..d3f71020 100644 --- a/app/index.js +++ b/app/index.js @@ -10,9 +10,10 @@ import ScrollToTop from "components/ScrollToTop"; import Toasts from "components/Toasts"; import Theme from "components/Theme"; import Routes from "./routes"; +import env from "env"; let DevTools; -if (__DEV__) { +if (process.env.NODE_ENV !== "production") { DevTools = require("mobx-react-devtools").default; // eslint-disable-line global-require } @@ -44,7 +45,7 @@ if (element) { window.addEventListener("load", async () => { // installation does not use Google Analytics, or tracking is blocked on client // no point loading the rest of the analytics bundles - if (!process.env.GOOGLE_ANALYTICS_ID || !window.ga) return; + if (!env.GOOGLE_ANALYTICS_ID || !window.ga) return; // https://github.com/googleanalytics/autotrack/issues/137#issuecomment-305890099 await import("autotrack/autotrack.js"); diff --git a/app/scenes/Login/index.js b/app/scenes/Login/index.js index 5e7e0dc7..7d90c7b2 100644 --- a/app/scenes/Login/index.js +++ b/app/scenes/Login/index.js @@ -17,6 +17,7 @@ import Service from "./Service"; import Notices from "./Notices"; import AuthStore from "stores/AuthStore"; import getQueryVariable from "shared/utils/getQueryVariable"; +import env from "env"; type Props = { auth: AuthStore, @@ -62,7 +63,7 @@ class Login extends React.Component { ); const header = - process.env.DEPLOYMENT === "hosted" && + env.DEPLOYMENT === "hosted" && (config.hostname ? ( Back to home @@ -101,8 +102,8 @@ class Login extends React.Component { - {process.env.TEAM_LOGO && process.env.DEPLOYMENT !== "hosted" ? ( - + {env.TEAM_LOGO && env.DEPLOYMENT !== "hosted" ? ( + ) : ( )} diff --git a/app/scenes/Settings/Details.js b/app/scenes/Settings/Details.js index 9120049f..fdc63bd8 100644 --- a/app/scenes/Settings/Details.js +++ b/app/scenes/Settings/Details.js @@ -13,6 +13,7 @@ import CenteredContent from "components/CenteredContent"; import PageTitle from "components/PageTitle"; import HelpText from "components/HelpText"; import Flex from "components/Flex"; +import env from "env"; type Props = { auth: AuthStore, @@ -115,7 +116,7 @@ class Details extends React.Component { required short /> - {process.env.SUBDOMAINS_ENABLED && ( + {env.SUBDOMAINS_ENABLED && ( { /> {this.subdomain && ( - Your knowledgebase will be accessible at{" "} + Your knowledge base will be accessible at{" "} {this.subdomain}.getoutline.com )} diff --git a/app/scenes/Settings/Slack.js b/app/scenes/Settings/Slack.js index 81dbd715..4f2fe4d1 100644 --- a/app/scenes/Settings/Slack.js +++ b/app/scenes/Settings/Slack.js @@ -14,6 +14,7 @@ import IntegrationsStore from "stores/IntegrationsStore"; import AuthStore from "stores/AuthStore"; import Notice from "components/Notice"; import getQueryVariable from "shared/utils/getQueryVariable"; +import env from "env"; type Props = { collections: CollectionsStore, @@ -68,7 +69,7 @@ class Slack extends React.Component { ) : ( )} @@ -105,7 +106,7 @@ class Slack extends React.Component { {collection.name} diff --git a/app/scenes/Settings/components/SlackButton.js b/app/scenes/Settings/components/SlackButton.js index 7333b122..9e8c50aa 100644 --- a/app/scenes/Settings/components/SlackButton.js +++ b/app/scenes/Settings/components/SlackButton.js @@ -4,6 +4,7 @@ import styled from "styled-components"; import { slackAuth } from "shared/utils/routeHelpers"; import SlackLogo from "components/SlackLogo"; import Button from "components/Button"; +import env from "env"; type Props = { scopes?: string[], @@ -14,7 +15,12 @@ type Props = { function SlackButton({ state, scopes, redirectUri, label }: Props) { const handleClick = () => - (window.location.href = slackAuth(state, scopes, redirectUri)); + (window.location.href = slackAuth( + state, + scopes, + env.SLACK_KEY, + redirectUri + )); return (