Skip to content

Commit ab3ce6f

Browse files
pjlittlewbreza
authored andcommitted
feat: exclude desktop functionality from browser target (microsoft#713)
Remove electron functionality from browser builds. Some updates to CI scripts, based on things found in the last release.
1 parent 74f5237 commit ab3ce6f

File tree

11 files changed

+67
-61
lines changed

11 files changed

+67
-61
lines changed

azure-pipelines/linux/artifact-build-linux.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ steps:
88
inputs:
99
versionSpec: 10.x
1010

11-
- bash: |
11+
- bash: |
1212
set -ex
13-
13+
1414
# clean install
1515
npm ci
16-
npm run release
17-
16+
npm run release-ci
17+
1818
mkdir -p linux
1919
cp releases/vott*.snap linux/
2020
displayName: Build

azure-pipelines/mac/artifact-build-mac.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ steps:
44
inputs:
55
versionSpec: 10.x
66

7-
- bash: |
7+
- bash: |
88
set -ex
9-
9+
1010
# clean install
1111
npm ci
12-
npm run release
13-
12+
npm run release-ci
13+
1414
mkdir -p mac
1515
cp releases/vott*.dmg mac/
1616
displayName: Build

azure-pipelines/windows/artifact-build-windows.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ steps:
44
inputs:
55
versionSpec: 10.x
66

7-
- bash: |
7+
- bash: |
88
set -ex
9-
9+
1010
# clean install
1111
npm ci
12-
npm run release
13-
12+
npm run release-ci
13+
1414
mkdir -p windows
1515
cp releases/vott*.exe windows/
16-
16+
1717
displayName: Build
1818
1919
- task: PublishBuildArtifacts@1

package-lock.json

+11-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"eject": "react-scripts eject",
6666
"release-pr": "./scripts/release-pr.sh",
6767
"release-web": "npm run build && npm run webpack:prod",
68+
"release-ci": "./scripts/build.sh",
6869
"release": "npm run build && npm run webpack:prod && electron-builder",
6970
"pretest": "./node_modules/.bin/tslint 'src/**/*.ts*'",
7071
"lintfix": "./node_modules/.bin/tslint 'src/**/*.ts*' --fix",

public/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
work correctly both with client-side routing and a non-root public URL.
2020
Learn how to configure a non-root public URL by running `npm run build`.
2121
-->
22-
<title>Visual Object Tagging Tool (VoTT)</title>
22+
<title>Visual Object Tagging Tool (VoTT) v%REACT_APP_VERSION%</title>
2323
</head>
2424
<body>
2525
<noscript>
2626
You need to enable JavaScript to run this app.
2727
</noscript>
2828
<div id="root"></div>
29-
<div id="appInfo">VoTT v%REACT_APP_VERSION%, commit=%REACT_APP_COMMIT_SHA%</div>
29+
<div style="display: none;">VoTT v%REACT_APP_VERSION%, commit=%REACT_APP_COMMIT_SHA%</div>
3030
<!--
3131
This HTML file is a template.
3232
If you open it directly in the browser, you will see an empty page.

scripts/build.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# NOTE: this script should be ran from the root of the repository; the CWD should reflect this
5+
VERSION=$(node -pe "require('./package.json').version")
6+
COMMIT_SHA=$(git rev-parse --short HEAD)
7+
NPM_BIN_DIR=$(npm bin)
8+
9+
echo "cwd=$(pwd)"
10+
echo "version=${VERSION}"
11+
echo "commit=${COMMIT_SHA}"
12+
13+
export REACT_APP_VERSION=${VERSION}
14+
export REACT_APP_COMMIT_SHA=${COMMIT_SHA}
15+
16+
npx react-scripts build
17+
npx webpack -p --config ./config/webpack.prod.js
18+
npx electron-builder

scripts/release-pr.sh

+2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ then
4949
git tag -a ${NEW_VERSION} -m "VoTT v${NEW_VERSION}"
5050
# update package.json version and the changelog
5151
npm install json --no-save
52+
# NOTE: at some point, we need to move to `npm version` and do all of this via build system
5253
./node_modules/.bin/json -I -f package.json -4 -e "this.version=\"${NEW_VERSION}\""
54+
./node_modules/.bin/json -I -f package-lock.json -4 -e "this.version=\"${NEW_VERSION}\""
5355
${BASEDIR}/generate-changelog.sh --from ${PREVIOUS_VERSION} --to ${NEW_VERSION}
5456
git commit -am "ci: update package version and changelog for ${NEW_VERSION} release"
5557
git push -u origin ${RELEASE_BRANCH}

src/index.scss

-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ body {
88
overflow: hidden;
99
}
1010

11-
#appInfo {
12-
display: none;
13-
}
14-
1511
input[type=file] {
1612
display: none;
1713
}

src/react/components/pages/appSettings/appSettingsPage.tsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AppSettingsForm } from "./appSettingsForm";
99
import { RouteComponentProps } from "react-router-dom";
1010
import { toast } from "react-toastify";
1111
import { appInfo } from "../../../../common/appInfo";
12+
import { isElectron } from "../../../../common/hostProcess";
1213

1314
/**
1415
* Props for App Settings Page
@@ -67,18 +68,22 @@ export default class AppSettingsPage extends React.Component<IAppSettingsProps>
6768
<div className="my-3">
6869
<p>{`${strings.appSettings.commit}: `} {process.env.REACT_APP_COMMIT_SHA}</p>
6970
</div>
70-
<div className="my-3">
71-
<p>{strings.appSettings.devTools.description}</p>
72-
<button id="toggleDevTools" className="btn btn-primary btn-sm"
73-
onClick={this.toggleDevTools}>{strings.appSettings.devTools.button}
74-
</button>
75-
</div>
76-
<div className="my-3">
77-
<p>{strings.appSettings.reload.description}</p>
78-
<button id="refreshApp" className="btn btn-primary btn-sm"
79-
onClick={this.reloadApp}>{strings.appSettings.reload.button}
80-
</button>
81-
</div>
71+
{ isElectron() &&
72+
<span>
73+
<div className="my-3">
74+
<p>{strings.appSettings.devTools.description}</p>
75+
<button id="toggleDevTools" className="btn btn-primary btn-sm"
76+
onClick={this.toggleDevTools}>{strings.appSettings.devTools.button}
77+
</button>
78+
</div>
79+
<div className="my-3">
80+
<p>{strings.appSettings.reload.description}</p>
81+
<button id="refreshApp" className="btn btn-primary btn-sm"
82+
onClick={this.reloadApp}>{strings.appSettings.reload.button}
83+
</button>
84+
</div>
85+
</span>
86+
}
8287
</div>
8388
</div>
8489
);

src/react/components/pages/homepage/homePage.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import ImportService from "../../../../services/importService";
2020
import { IAssetMetadata } from "../../../../models/applicationState";
2121
import { toast } from "react-toastify";
2222
import MessageBox from "../../common/messageBox/messageBox";
23+
import { isElectron } from "../../../../common/hostProcess";
2324

2425
export interface IHomePageProps extends RouteComponentProps, React.Props<HomePage> {
2526
recentProjects: IProject[];
@@ -71,6 +72,7 @@ export default class HomePage extends React.Component<IHomePageProps, IHomePageS
7172
<h6>{strings.homePage.newProject}</h6>
7273
</a>
7374
</li>
75+
{ isElectron() &&
7476
<li>
7577
<a href="#" onClick={() => this.filePicker.current.upload()} className="p-5 file-upload">
7678
<i className="fas fa-folder-open fa-9x"></i>
@@ -80,6 +82,7 @@ export default class HomePage extends React.Component<IHomePageProps, IHomePageS
8082
onChange={this.onProjectFileUpload}
8183
onError={this.onProjectFileUploadError} />
8284
</li>
85+
}
8386
<li>
8487
{/*Open Cloud Project*/}
8588
<a href="#" onClick={this.handleOpenCloudProjectClick} className="p-5 cloud-open-project">

0 commit comments

Comments
 (0)