From 2a861cf6173db70a89424d41cbf2c5313e574ffe Mon Sep 17 00:00:00 2001 From: Johannes Faltermeier Date: Fri, 17 Jan 2025 11:15:18 +0100 Subject: [PATCH] Make plugins writeable #422 * make sure that files are writeable so that Mac may set/remove quarantine bits * also bump patch versions --- applications/browser/package.json | 4 +- applications/electron/package.json | 8 ++-- lerna.json | 2 +- package.json | 6 ++- scripts/make-files-writeable.ts | 62 ++++++++++++++++++++++++++ theia-extensions/launcher/package.json | 2 +- theia-extensions/product/package.json | 2 +- theia-extensions/updater/package.json | 2 +- 8 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 scripts/make-files-writeable.ts diff --git a/applications/browser/package.json b/applications/browser/package.json index adc98beeb..18457f8bd 100644 --- a/applications/browser/package.json +++ b/applications/browser/package.json @@ -3,7 +3,7 @@ "name": "theia-ide-browser-app", "description": "Eclipse Theia IDE browser product", "productName": "Theia IDE", - "version": "1.57.102", + "version": "1.57.103", "license": "MIT", "author": "Eclipse Theia ", "homepage": "https://github.com/eclipse-theia/theia-ide#readme", @@ -102,7 +102,7 @@ "@theia/vsx-registry": "1.57.1", "@theia/workspace": "1.57.1", "fs-extra": "^9.0.1", - "theia-ide-product-ext": "1.57.102" + "theia-ide-product-ext": "1.57.103" }, "devDependencies": { "@theia/cli": "1.57.1" diff --git a/applications/electron/package.json b/applications/electron/package.json index 11b509f70..468dabbe9 100644 --- a/applications/electron/package.json +++ b/applications/electron/package.json @@ -3,7 +3,7 @@ "name": "theia-ide-electron-app", "description": "Eclipse Theia IDE product", "productName": "Theia IDE", - "version": "1.57.102", + "version": "1.57.103", "main": "scripts/theia-electron-main.js", "license": "MIT", "author": "Eclipse Theia ", @@ -112,9 +112,9 @@ "@theia/vsx-registry": "1.57.1", "@theia/workspace": "1.57.1", "fs-extra": "^9.0.1", - "theia-ide-launcher-ext": "1.57.102", - "theia-ide-product-ext": "1.57.102", - "theia-ide-updater-ext": "1.57.102" + "theia-ide-launcher-ext": "1.57.103", + "theia-ide-product-ext": "1.57.103", + "theia-ide-updater-ext": "1.57.103" }, "devDependencies": { "@theia/cli": "1.57.1", diff --git a/lerna.json b/lerna.json index 93123aa38..83d18d018 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "lerna": "4.0.0", - "version": "1.57.102", + "version": "1.57.103", "useWorkspaces": true, "npmClient": "yarn", "command": { diff --git a/package.json b/package.json index 3542c9c2a..3c5db2215 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "1.57.102", + "version": "1.57.103", "license": "MIT", "author": "Rob Moran ", "homepage": "https://github.com/eclipse-theia/theia-ide#readme", @@ -18,6 +18,7 @@ "devDependencies": { "@eclipse-dash/nodejs-wrapper": "^0.0.1", "@theia/cli": "1.57.1", + "@types/yargs": "17.0.7", "@typescript-eslint/eslint-plugin": "^4.25.0", "@typescript-eslint/eslint-plugin-tslint": "^4.25.0", "@typescript-eslint/parser": "^4.25.0", @@ -40,10 +41,11 @@ "build:applications": "yarn build:extensions && lerna run --scope=\"theia-ide*app\" build:prod --concurrency 1", "build:applications:dev": "yarn build:extensions && lerna run --scope=\"theia-ide*app\" build --concurrency 1", "build:extensions": "lerna run --scope=\"theia-ide*ext\" build", - "download:plugins": "theia download:plugins --rate-limit=15 --parallel=false", + "download:plugins": "theia download:plugins --rate-limit=15 --parallel=false && yarn permissions:writeable", "package:applications": "lerna run --scope=\"theia-ide*app\" package --concurrency 1", "package:applications:preview": "lerna run --scope=\"theia-ide*app\" package:preview --concurrency 1", "package:applications:prod": "lerna run --scope=\"theia-ide*app\" package:prod --concurrency 1", + "permissions:writeable": "ts-node scripts/make-files-writeable.ts plugins", "watch": "lerna run --parallel watch", "test": "lerna run test", "electron": "yarn --cwd applications/electron", diff --git a/scripts/make-files-writeable.ts b/scripts/make-files-writeable.ts new file mode 100644 index 000000000..48b1aaffb --- /dev/null +++ b/scripts/make-files-writeable.ts @@ -0,0 +1,62 @@ +/******************************************************************************** + * Copyright (C) 2025 EclipseSource and others. + * + * This program and the accompanying materials are made available under the + * terms of the MIT License, which is available in the project root. + * + * SPDX-License-Identifier: MIT + ********************************************************************************/ + +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; +import * as fs from 'fs'; +import * as path from 'path'; + +const argv = yargs(hideBin(process.argv)) + .option('directory', { + alias: 'e', + type: 'string', + default: 'plugins', + description: 'The parent directory which contains the files we need to make writable', + }) + .version(false) + .wrap(120) + .parseSync(); + +execute(); + +async function execute(): Promise { + const directory = argv.directory; + console.log(`Input directory: ${directory}`); + + try { + makeWritable(directory); + } catch (error) { + console.error(`Failed to make files writable: ${error.message}`); + process.exit(1); + } +} + +function makeWritable(dir: string): void { + if (!fs.existsSync(dir)) { + throw new Error(`Directory '${dir}' does not exist.`); + } + + const entries = fs.readdirSync(dir, { withFileTypes: true }); + + for (const entry of entries) { + const fullPath = path.join(dir, entry.name); + if (entry.isDirectory()) { + makeWritable(fullPath); + } else if (entry.isFile()) { + const stats = fs.statSync(fullPath); + const isWritable = (stats.mode & 0o200) !== 0; + if (!isWritable) { + const isExecutable = (stats.mode & 0o111) !== 0; + const newMode = isExecutable ? 0o755 : 0o644; + console.log(`Making '${fullPath}' writable with mode '${isExecutable ? '0o755' : '0o644'}'`); + fs.chmodSync(fullPath, newMode); + } + } + } +} diff --git a/theia-extensions/launcher/package.json b/theia-extensions/launcher/package.json index 88999ff58..b68b22419 100644 --- a/theia-extensions/launcher/package.json +++ b/theia-extensions/launcher/package.json @@ -1,6 +1,6 @@ { "name": "theia-ide-launcher-ext", - "version": "1.57.102", + "version": "1.57.103", "keywords": [ "theia-extension" ], diff --git a/theia-extensions/product/package.json b/theia-extensions/product/package.json index 43965a33e..42a16e440 100644 --- a/theia-extensions/product/package.json +++ b/theia-extensions/product/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "theia-ide-product-ext", - "version": "1.57.102", + "version": "1.57.103", "description": "Eclipse Theia IDE Product Branding", "dependencies": { "@theia/core": "1.57.1", diff --git a/theia-extensions/updater/package.json b/theia-extensions/updater/package.json index 3b07078eb..685fcdbe3 100644 --- a/theia-extensions/updater/package.json +++ b/theia-extensions/updater/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "theia-ide-updater-ext", - "version": "1.57.102", + "version": "1.57.103", "description": "Eclipse Theia IDE Updater", "dependencies": { "@theia/core": "1.57.1",