Skip to content

Commit

Permalink
[WIP] Refactor build scripts, one plugins folder
Browse files Browse the repository at this point in the history
In this commit, I looked at the repo with "new eyes". I refactored the
"scripts" section of the root package.json as well as the same file,
for each of our applications (electron and browser ATM). The way
Blueprint is now built is more in-line with how the buiild works in
the main Theia repo.

Also, refactor so that we can have a single "plugins" folder and
also moved the definition of the wanted plugins from the application's
`package.json` to the root `package.json`. This is also in-line with
the main Theia repo, and avoids definining and fetching the plugins
twice.

Misc:
- to gain flexibility about which `yarn workspaces` are invoked for a
  given `lerna` command, using the `--scope=` CLI option.I renamed the
  repo's extensions and applications. This permits easily composing
  commands that target only the extensions or only the applications.
  e.g.:

  ``` json
  "build:extensions": "lerna run --scope=\"blueprint*ext\" build",
  "build:applications": "lerna run --scope=\"blueprint*app\" build --concurrency 1","
  ```
- renamed the extensions folders, made them more straightforward
- When we first build the apps, use the `--mode development` option
  of `theia build`. This build takes less resources and might permit
  to successfully build Blueprint e.g. on a Raspberry Pi 4B board
  with 4GB of RAM.
- Just before packaging, re-build the app in production mode (Electron
  only for now - currently no packaging for the browser app)
- added a root `tsconfig.json` - it was missing and is required for
  the project's sources to be interpreted correctly by `tsc`.

Signed-off-by: Marc Dumais <[email protected]>
  • Loading branch information
marcdumais-work committed Jun 14, 2023
1 parent 5fe2d30 commit 52f96ae
Show file tree
Hide file tree
Showing 49 changed files with 95 additions and 95 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,29 @@ jobs:
shell: bash
run: |
yarn --skip-integrity-check --network-timeout 100000
yarn build
yarn electron package
env:
NODE_OPTIONS: --max_old_space_size=4096
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9

- name: Test (Linux)
if: matrix.tests != 'skip' && runner.os == 'Linux'
uses: GabrielBB/xvfb-action@v1
with:
run: yarn electron test
# - name: Test (Linux)
# if: matrix.tests != 'skip' && runner.os == 'Linux'
# uses: GabrielBB/xvfb-action@v1
# with:
# run: yarn electron test

- name: Test (Windows)
if: matrix.tests != 'skip' && runner.os == 'Windows'
shell: bash
run: |
yarn electron test
# - name: Test (Windows)
# if: matrix.tests != 'skip' && runner.os == 'Windows'
# shell: bash
# run: |
# yarn electron test

- name: Test (macOS)
if: matrix.tests != 'skip' && runner.os == 'macOS'
shell: bash
run: |
yarn electron test
# - name: Test (macOS)
# if: matrix.tests != 'skip' && runner.os == 'macOS'
# shell: bash
# run: |
# yarn electron test

- name: Lint
if: matrix.tests != 'skip'
Expand Down
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ def buildInstaller(int sleepBetweenRetries, boolean excludeBrowser) {
sh "printenv && yarn cache dir"
sh "yarn cache clean"
try {
sh(script: 'yarn --frozen-lockfile --force')
sh(script: 'yarn --frozen-lockfile --force && yarn build')
} catch(error) {
retry(MAX_RETRY) {
sleep(sleepBetweenRetries)
echo "yarn failed - Retrying"
sh(script: 'yarn --frozen-lockfile --force')
sh(script: 'yarn --frozen-lockfile --force && yarn build')
}
}

Expand Down Expand Up @@ -326,14 +326,14 @@ def updateMetadata(String executable, String yaml, String platform, int sleepBet
int MAX_RETRY = 4
try {
sh "export NODE_OPTIONS=--max_old_space_size=4096"
sh "yarn install --force"
sh "yarn install --force && yarn build:prod"
sh "yarn electron update:blockmap -e ${executable}"
sh "yarn electron update:checksum -e ${executable} -y ${yaml} -p ${platform}"
} catch(error) {
retry(MAX_RETRY) {
sleep(sleepBetweenRetries)
echo "yarn failed - Retrying"
sh "yarn install --force"
sh "yarn install --force && yarn build:prod"
sh "yarn electron update:blockmap -e ${executable}"
sh "yarn electron update:checksum -e ${executable} -y ${yaml} -p ${platform}"
}
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<br/>
<div id="theia-logo" align="center">
<br />
<img src="https://raw.githubusercontent.com/eclipse-theia/theia-blueprint/master/theia-extensions/theia-blueprint-product/src/browser/icons/TheiaBlueprintLogo-blue.png" alt="Theia Logo" width="300"/>
<img src="https://raw.githubusercontent.com/eclipse-theia/theia-blueprint/master/theia-extensions/product/src/browser/icons/TheiaBlueprintLogo-blue.png" alt="Theia Logo" width="300"/>
<h3>Eclipse Theia Blueprint</h3>
</div>

Expand Down Expand Up @@ -53,13 +53,13 @@ Documentation on how to package Theia as a Desktop Product may be found [here](h
- `browser` contains a browser based version of Eclipse Theia Blueprint that may be packaged as a Docker image
- `electron` contains the electron app to package, packaging configuration, and E2E tests for the electron target.
- `theia-extensions` groups the various custom theia extensions for Blueprint
- `theia-blueprint-product` contains a Theia extension contributing the product branding (about dialogue and welcome page).
- `theia-blueprint-updater` contains a Theia extension contributing the update mechanism and corresponding UI elements (based on the electron updater).
- `product` contains a Theia extension contributing the product branding (about dialogue and welcome page).
- `updater` contains a Theia extension contributing the update mechanism and corresponding UI elements (based on the electron updater).

### Build

```sh
yarn
yarn && yarn build
```

### Package the Electron Application
Expand Down Expand Up @@ -93,10 +93,6 @@ yarn electron test
The browser app may be started with

```sh
# Download Plugins for browser app
yarn browser download:plugins

# Start browser app
yarn browser start
```

Expand Down
35 changes: 9 additions & 26 deletions applications/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "theia-blueprint-browser",
"name": "blueprint-browser-app",
"description": "Eclipse Theia blueprint browser product",
"productName": "Theia Blueprint",
"version": "1.38.0",
Expand Down Expand Up @@ -85,37 +85,20 @@
"@theia/vsx-registry": "1.38.0",
"@theia/workspace": "1.38.0",
"fs-extra": "^9.0.1",
"theia-blueprint-product": "1.38.0"
"blueprint-product-ext": "1.38.0"
},
"devDependencies": {
"@theia/cli": "1.38.0"
},
"scripts": {
"prepare": "yarn build",
"clean": "theia clean && rimraf node_modules",
"build": "yarn -s compile && yarn -s bundle",
"bundle": "theia build",
"compile": "tsc -b",
"rebuild": "theia rebuild:browser --cacheRoot ../..",
"start": "yarn -s rebuild && theia start --plugins=local-dir:./plugins",
"build": "yarn bundle",
"build:prod": "yarn bundle:prod",
"bundle": "theia build --app-target=\"browser\" --mode development",
"bundle:prod": "theia build --app-target=\"browser\"",
"rebuild": "theia rebuild:browser --cacheRoot ../electron",
"start": "yarn -s rebuild && theia start --plugins=local-dir:../../plugins",
"watch": "concurrently --kill-others -n tsc,bundle -c red,yellow \"tsc -b -w --preserveWatchOutput\" \"yarn -s watch:bundle\"",
"download:plugins": "theia download:plugins --rate-limit=15",
"update:next": "ts-node ../../scripts/update-theia-to-next.ts"
},
"theiaPluginsDir": "plugins",
"theiaPlugins": {
"vscode-builtin-extensions-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.77.0/file/eclipse-theia.builtin-extension-pack-1.77.0.vsix",
"vscjava.vscode-java-pack": "https://open-vsx.org/api/vscjava/vscode-java-pack/0.25.11/file/vscjava.vscode-java-pack-0.25.11.vsix",
"vscjava.vscode-java-dependency": "https://open-vsx.org/api/vscjava/vscode-java-dependency/0.21.2/file/vscjava.vscode-java-dependency-0.21.2.vsix"
},
"theiaPluginsExcludeIds": [
"ms-vscode.js-debug-companion",
"VisualStudioExptTeam.vscodeintellicode",
"vscode.builtin-notebook-renderers",
"vscode.extension-editing",
"vscode.github",
"vscode.github-authentication",
"vscode.ipynb",
"vscode.microsoft-authentication"
]
}
}
2 changes: 1 addition & 1 deletion applications/browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"references": [
{
"path": "../../theia-extensions/theia-blueprint-product"
"path": "../../theia-extensions/product"
}
]
}
2 changes: 1 addition & 1 deletion applications/electron/electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ files:
- scripts
- "!**node_modules/electron/**"
extraResources:
- from: plugins
- from: ../../plugins
to: app/plugins

win:
Expand Down
41 changes: 13 additions & 28 deletions applications/electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "theia-blueprint",
"name": "blueprint-electron-app",
"description": "Eclipse Theia blueprint product",
"productName": "Theia Blueprint",
"version": "1.38.0",
Expand Down Expand Up @@ -84,9 +84,9 @@
"@theia/vsx-registry": "1.38.0",
"@theia/workspace": "1.38.0",
"fs-extra": "^9.0.1",
"theia-blueprint-updater": "1.38.0",
"theia-blueprint-product": "1.38.0",
"theia-blueprint-launcher": "1.38.0"
"blueprint-updater-ext": "1.38.0",
"blueprint-product-ext": "1.38.0",
"blueprint-launcher-ext": "1.38.0"
},
"devDependencies": {
"@theia/cli": "1.38.0",
Expand All @@ -112,38 +112,23 @@
"concurrently": "^3.5.0"
},
"scripts": {
"prepare": "yarn build && yarn download:plugins",
"clean": "theia clean && rimraf node_modules",
"clean:dist": "rimraf dist",
"build": "yarn -s bundle",
"bundle": "theia build",
"build:prod": "yarn -s bundle:prod",
"bundle": "theia build --app-target=\"electron\" --mode development",
"bundle:prod": "theia build --app-target=\"electron\"",
"rebuild": "theia rebuild:electron",
"watch": "concurrently -n compile,bundle \"theiaext watch --preserveWatchOutput\" \"theia build --watch --mode development\"",
"start": "yarn -s rebuild && electron scripts/theia-electron-main.js",
"start": "yarn -s rebuild && electron scripts/theia-electron-main.js --plugins=local-dir:../../plugins",
"start:debug": "yarn start --log-level=debug",
"package": "yarn clean:dist && yarn -s rebuild && electron-builder -c.mac.identity=null --publish never",
"deploy": "yarn clean:dist && yarn -s rebuild && electron-builder -c.mac.identity=null --publish always",
"package:preview": "yarn clean:dist && yarn -s rebuild && electron-builder -c.mac.identity=null --dir",
"package": "yarn clean:dist && yarn bundle:prod && yarn -s rebuild && electron-builder -c.mac.identity=null --publish never",
"deploy": "yarn clean:dist && yarn bundle:prod && yarn -s rebuild && electron-builder -c.mac.identity=null --publish always",
"package:preview": "yarn clean:dist && yarn bundle:prod && yarn -s rebuild && electron-builder -c.mac.identity=null --dir",
"update:checksum": "ts-node scripts/update-checksum.ts",
"update:blockmap": "ts-node scripts/update-blockmap.ts",
"update:next": "ts-node ../../scripts/update-theia-to-next.ts",
"download:plugins": "theia download:plugins --rate-limit=15 --parallel=false",

"test": "mocha --timeout 60000 \"./test/*.spec.js\""
},
"theiaPluginsDir": "plugins",
"theiaPlugins": {
"vscode-builtin-extensions-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.77.0/file/eclipse-theia.builtin-extension-pack-1.77.0.vsix",
"vscjava.vscode-java-pack": "https://open-vsx.org/api/vscjava/vscode-java-pack/0.25.11/file/vscjava.vscode-java-pack-0.25.11.vsix",
"vscjava.vscode-java-dependency": "https://open-vsx.org/api/vscjava/vscode-java-dependency/0.21.2/file/vscjava.vscode-java-dependency-0.21.2.vsix"
},
"theiaPluginsExcludeIds": [
"ms-vscode.js-debug-companion",
"VisualStudioExptTeam.vscodeintellicode",
"vscode.builtin-notebook-renderers",
"vscode.extension-editing",
"vscode.github",
"vscode.github-authentication",
"vscode.ipynb",
"vscode.microsoft-authentication"
]
}
}
2 changes: 1 addition & 1 deletion applications/electron/scripts/theia-electron-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process.env.THEIA_DEFAULT_PLUGINS = `local-dir:${path.resolve(__dirname, '..', '

// Lookup inside the user's home folder for more plugins, and accept user-defined paths.
process.env.THEIA_PLUGINS = [
process.env.THEIA_PLUGINS, `local-dir:${path.resolve(os.homedir(), '.theia', 'plugins')}`,
process.env.THEIA_PLUGINS, `local-dir:${path.resolve(os.homedir(), '.theia-blueprint', 'plugins')}`,
].filter(Boolean).join(',')

// Handover to the auto-generated electron application handler.
Expand Down
2 changes: 1 addition & 1 deletion applications/electron/test/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function getBinaryPath() {
return path.join(
distFolder,
"linux-unpacked",
"theia-blueprint"
"theia-blueprint-electron-app"
);
case "win32":
return path.join(
Expand Down
2 changes: 1 addition & 1 deletion browser.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN yarn --pure-lockfile && \
echo *.spec.* >> .yarnclean && \
yarn autoclean --force && \
yarn cache clean && \
rm -rf .git applications/electron theia-extensions/theia-blueprint-launcher theia-extensions/theia-blueprint-updater
rm -rf .git applications/electron theia-extensions/launcher theia-extensions/updater

# Production stage uses a small base image
FROM node:16-bullseye-slim as production-stage
Expand Down
23 changes: 21 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,33 @@
"lint": "lerna run lint",
"lint:fix": "lerna run lint:fix",
"clean": "lerna run clean && rimraf node_modules",
"build": "lerna run build",
"bundle": "lerna run bundle",

"build": "yarn build:extensions && yarn build:applications && yarn download:plugins",
"build:extensions": "lerna run --scope=\"blueprint*ext\" build",
"build:applications": "lerna run --scope=\"blueprint*app\" build --concurrency 1",
"download:plugins": "theia download:plugins --rate-limit=15 --parallel=false",
"watch": "lerna run --parallel watch",
"test": "lerna run test",
"electron": "yarn --cwd applications/electron",
"browser": "yarn --cwd applications/browser",
"update:next": "ts-node scripts/update-theia-to-next.ts && lerna run update:next"
},
"theiaPluginsDir": "plugins",
"theiaPlugins": {
"vscode-builtin-extensions-pack": "https://open-vsx.org/api/eclipse-theia/builtin-extension-pack/1.77.0/file/eclipse-theia.builtin-extension-pack-1.77.0.vsix",
"vscjava.vscode-java-pack": "https://open-vsx.org/api/vscjava/vscode-java-pack/0.25.11/file/vscjava.vscode-java-pack-0.25.11.vsix",
"vscjava.vscode-java-dependency": "https://open-vsx.org/api/vscjava/vscode-java-dependency/0.21.2/file/vscjava.vscode-java-dependency-0.21.2.vsix"
},
"theiaPluginsExcludeIds": [
"ms-vscode.js-debug-companion",
"VisualStudioExptTeam.vscodeintellicode",
"vscode.builtin-notebook-renderers",
"vscode.extension-editing",
"vscode.github",
"vscode.github-authentication",
"vscode.ipynb",
"vscode.microsoft-authentication"
],
"workspaces": [
"applications/*",
"theia-extensions/*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "theia-blueprint-launcher",
"name": "blueprint-launcher-ext",
"version": "1.38.0",
"keywords": [
"theia-extension"
Expand All @@ -26,7 +26,6 @@
"typescript": "^4.5.5"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib *.tsbuildinfo",
"build": "tsc",
"watch": "tsc -w",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "theia-blueprint-product",
"name": "blueprint-product-ext",
"version": "1.38.0",
"description": "Eclipse Theia Blueprint Product Branding",
"dependencies": {
Expand Down Expand Up @@ -39,7 +39,6 @@
"src"
],
"scripts": {
"prepare": "yarn clean && yarn build",
"clean": "rimraf lib *.tsbuildinfo",
"build": "tsc -b",
"lint": "eslint --ext js,jsx,ts,tsx src",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "theia-blueprint-updater",
"name": "blueprint-updater-ext",
"version": "1.38.0",
"description": "Eclipse Theia Blueprint Updater",
"dependencies": {
Expand Down Expand Up @@ -40,7 +40,6 @@
"src"
],
"scripts": {
"prepare": "yarn clean && yarn build",
"clean": "rimraf lib *.tsbuildinfo",
"build": "tsc -b",
"lint": "eslint --ext js,jsx,ts,tsx src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class TheiaUpdaterImpl implements TheiaUpdater, ElectronMainApplicationCo
autoUpdater.downloadUpdate();

// record download stat, ignore errors
fs.mkdtemp(path.join(os.tmpdir(), 'theia-blueprint-updater-'))
fs.mkdtemp(path.join(os.tmpdir(), 'updater-'))
.then(tmpDir => {
const file = fs.createWriteStream(path.join(tmpDir, 'update'));
http.get('https://www.eclipse.org/downloads/download.php?file=/theia/update&r=1', response => {
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./configs/base.tsconfig.json",
"include": [],
"compilerOptions": {
"composite": true,
"allowJs": true
},
"references": [
{
"path": "theia-extensions/launcher"
},
{
"path": "theia-extensions/product"
},
{
"path": "theia-extensions/updater"
},
]
}

0 comments on commit 52f96ae

Please sign in to comment.