Skip to content

Commit b703e93

Browse files
committed
chore: update testing in Theia
- update testing section in Publishing.md - offer a script to copy the built extensions to the theia plugins folder Contributed on behalf of STMicroelectronics
1 parent f27551d commit b703e93

File tree

4 files changed

+130
-27
lines changed

4 files changed

+130
-27
lines changed

doc/Publishing.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,43 +59,24 @@ Building and packaging the built-ins is described in [Building.md](./Building.md
5959
## Testing
6060

6161
This section assumes you have a local clone of the [main Theia repo](https://github.com/eclipse-theia/theia). Please refer to the Theia documentation for instructions on how to build and
62-
run Theia. Some built-ins may refuse to run if the VS Code API version reported by Theia is lower that what they require. If Theia's default API verison has not been updated yet, you can
62+
run Theia. Some built-ins may refuse to run if the VS Code API version reported by Theia is lower that what they require. If Theia's default API version has not been updated yet, you can
6363
force a newer version by either setting the `VSCODE_API_VERSION` environment variable or by passing the option `--vscode-api-version <major>.<minor>.<patch>`
6464

65-
If already present, delete folder `plugins` in your local Theia repo folder. We will instead use the built-ins we previously built
65+
The following script will unzip the packaged .vsix extensions, rename them and copy them to your plugins folder (e.g., could be `~/git/theia/theia/plugins/`).
66+
Theia does not extract .vsix files on startup anymore, this is handled bei de plugin download currently.
6667

67-
```bash
68-
rm -rf plugins
69-
mkdir plugins
70-
```
68+
npm run theia:testing <YOUR THEIA PLUGINS FOLDER>
7169

72-
Copy the builtin extension `*.vsix` files built above to Theia's `extensions` folder (typically `~/.theia/extensions`)
73-
74-
```bash
75-
cp -a dist/* ~/.theia/extensions # adjust according to where your .theia folder resides
76-
```
77-
78-
Get rid of a few builtins that will interfere with testing (note: we keep these extensions where they were generated, but remove them from our test Theia application):
79-
80-
```bash
81-
cd theia # back to theia repo
82-
rm -rf plugins/ipynb-*
83-
rm -rf plugins/extension-editing-*
84-
```
85-
86-
To test vscode builtin git, we need to remove the Theia-specific git extension from the example application, for this, remove the line referring to
87-
`"@theia/git": "<Theia version>"` from the `package.json` of the Theia example you use for testing.
70+
_Note:_ The ones that are currently excluded by theia via `theiaPluginsExcludeIds`, like `github-authentication`, are skipped in this script as well.
8871

8972
Rebuild the example and start Theia:
9073

91-
```bash
9274
npm ci && npm run build
9375
npm run start:browser OR npm run start:electron
94-
```
9576

9677
Note that startup will take a bit longer than usual while Theia unzips the *.vsix files to `~/.theia/deployedPlugins`.
9778

98-
- [ ] Connect to `localhost:3000` with a browser
79+
- [ ] In case of browser example: Connect to `localhost:3000` with a browser
9980
- [ ] Observe backend log for new exceptions, specially during activation of builtin extensions
10081
- [ ] quick TypeScript test
10182
- [ ] quick JSON test

package-lock.json

Lines changed: 49 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"ip-check:builtin": "node ./src/check-dependencies.js --dir vscode/extensions",
1717
"ip-check:external": "node ./src/check-dependencies.js --dir external-builtins",
1818
"archive:builtin": "node ./src/archive-source.js --mode builtin",
19-
"archive:external": "node ./src/archive-source.js --mode external"
19+
"archive:external": "node ./src/archive-source.js --mode external",
20+
"theia:testing": "node ./src/theia-testing.js"
2021
},
2122
"devDependencies": {
2223
"@types/archiver": "^3.0.0",
@@ -29,6 +30,7 @@
2930
"colors": "^1.4.0",
3031
"cross-env": "^7.0.3",
3132
"execa": "^8.0.1",
33+
"extract-zip": "^2.0.1",
3234
"fs-extra": "^10.0.0",
3335
"glob": "^7.2.3",
3436
"node-fetch": "^2.6.0",

src/theia-testing.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Usage: node process-archives.js <targetPluginFolder> <prefix>
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
const { execSync } = require("child_process");
6+
7+
const [,, targetFolderArg] = process.argv;
8+
if (!targetFolderArg) {
9+
console.error("Usage: node process-archives.js <targetPluginFolder>");
10+
process.exit(1);
11+
}
12+
13+
const distFolderPath = path.resolve(path.join(__dirname, '..', 'dist'));
14+
const targetFolder = path.resolve(targetFolderArg);
15+
16+
// clean result folder just in case
17+
fs.rmSync(path.join(distFolderPath, 'result'), { recursive: true, force: true });
18+
19+
// get all .vsix files
20+
const vsixs = fs.readdirSync(distFolderPath).filter(f => f.endsWith(".vsix"));
21+
22+
for (const vsix of vsixs) {
23+
const base = path.basename(vsix, ".vsix");
24+
const outDir = path.join(distFolderPath, 'result', base);
25+
26+
console.log(`Extracting ${vsix} -> ${outDir}`);
27+
fs.mkdirSync(outDir, { recursive: true });
28+
// use system unzip (already available on Ubuntu)
29+
execSync(`unzip -o "${path.join(distFolderPath, vsix)}" -d "${outDir}"`);
30+
31+
// rename the extracted folder itself
32+
let newName = base;
33+
34+
// remove version suffix if present
35+
const versionPos = newName.lastIndexOf('-');
36+
if (newName.lastIndexOf('-') > 0) {
37+
newName = newName.slice(0, versionPos);
38+
}
39+
40+
// add prefix if not already there
41+
const prefix = newName.startsWith("builtin-extension-pack") ? "eclipse-theia.": "vscode.";
42+
if (!newName.startsWith(prefix)) {
43+
newName = prefix + newName;
44+
}
45+
46+
let finalPath = outDir;
47+
if (newName !== base) {
48+
finalPath = path.join(distFolderPath, 'result', newName);
49+
fs.renameSync(outDir, finalPath);
50+
console.log(`Renamed folder: "${base}" -> "${newName}"`);
51+
}
52+
// Define blacklist for extensions that should not be copied, taken from theia's 'theiaPluginsExcludeIds'
53+
const blacklist = [
54+
"extension-editing",
55+
"github",
56+
"github-authentication",
57+
"microsoft-authentication"
58+
];
59+
60+
// after you determine newName
61+
let skip = blacklist.some(suffix => newName.endsWith(suffix));
62+
63+
if (skip) {
64+
console.log(`Skipping blacklisted folder: "${newName}"`);
65+
continue; // don’t copy this one
66+
}
67+
// copy to target folder (force override)
68+
console.log(`Copying "${finalPath}" -> "${targetFolder}"`);
69+
execSync(`cp -r -f "${finalPath}" "${targetFolder}/"`);
70+
}
71+
72+
console.log("\nDone.");

0 commit comments

Comments
 (0)