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 <marc.dumais@ericsson.com>
  • Loading branch information
marcdumais-work committed Jun 19, 2023
1 parent 5fe2d30 commit a924593
Show file tree
Hide file tree
Showing 52 changed files with 130 additions and 84 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
shell: bash
run: |
yarn --skip-integrity-check --network-timeout 100000
yarn electron package
yarn build
yarn electron package:preview
env:
NODE_OPTIONS: --max_old_space_size=4096
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9
Expand All @@ -62,7 +63,7 @@ jobs:
shell: bash
run: |
yarn electron test
- name: Test (macOS)
if: matrix.tests != 'skip' && runner.os == 'macOS'
shell: bash
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
File renamed without changes.
33 changes: 8 additions & 25 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",
"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 ../..",
"start": "yarn -s rebuild && theia start --plugins=local-dir:./plugins",
"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"
]
}
}
5 changes: 4 additions & 1 deletion applications/browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
},
"references": [
{
"path": "../../theia-extensions/theia-blueprint-product"
"path": "../../theia-extensions/launcher"
},
{
"path": "../../theia-extensions/product"
}
]
}
File renamed without changes.
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
37 changes: 11 additions & 26 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",
"rebuild": "theia rebuild:electron",
"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 --cacheRoot ../..",
"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",
"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"
"blueprint-electron-app"
);
case "win32":
return path.join(
Expand Down
18 changes: 18 additions & 0 deletions applications/electron/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "../../configs/base.tsconfig",
"include": [],
"compilerOptions": {
"composite": true
},
"references": [
{
"path": "../../theia-extensions/launcher"
},
{
"path": "../../theia-extensions/product"
},
{
"path": "../../theia-extensions/updater"
}
]
}
7 changes: 4 additions & 3 deletions browser.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ COPY . .
# Download plugins and build application production mode
# Use yarn autoclean to remove unnecessary files from package dependencies
RUN yarn --pure-lockfile && \
yarn browser download:plugins && \
yarn download:plugins && \
yarn browser build && \
yarn --production && \
yarn autoclean --init && \
echo *.ts >> .yarnclean && \
echo *.ts.map >> .yarnclean && \
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 Expand Up @@ -54,7 +55,7 @@ EXPOSE 3000

# Specify default shell for Theia and the Built-In plugins directory
ENV SHELL=/bin/bash \
THEIA_DEFAULT_PLUGINS=local-dir:/home/theia/applications/browser/plugins
THEIA_DEFAULT_PLUGINS=local-dir:/home/theia/plugins

# Use installed git instead of dugite
ENV USE_LOCAL_GIT true
Expand Down
22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,32 @@
"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 --ignore-errors",
"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,9 +26,8 @@
"typescript": "^4.5.5"
},
"scripts": {
"prepare": "yarn run clean && yarn run build",
"clean": "rimraf lib *.tsbuildinfo",
"build": "tsc",
"build": "tsc -b",
"watch": "tsc -w",
"update:next": "ts-node ../../scripts/update-theia-to-next.ts"
},
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions theia-extensions/product/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: [
'../../configs/build.eslintrc.json'
],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.json'
}
};
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"private": true,
"name": "theia-blueprint-product",
"name": "blueprint-product-ext",
"version": "1.38.0",
"description": "Eclipse Theia Blueprint Product Branding",
"dependencies": {
"@theia/core": "1.38.0",
"@theia/getting-started": "1.38.0",
"@theia/vsx-registry": "1.38.0",
"@theia/workspace": "1.38.0",
"inversify": "^5.1.1"
"@theia/workspace": "1.38.0"
},
"devDependencies": {
"rimraf": "^2.7.1",
Expand Down Expand Up @@ -39,7 +38,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.
10 changes: 10 additions & 0 deletions theia-extensions/updater/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: [
'../../configs/build.eslintrc.json'
],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.json'
}
};
Loading

0 comments on commit a924593

Please sign in to comment.