diff --git a/packages/docs/docs/development.md b/packages/docs/docs/development.md index aa78f45f3..e41a1bf6f 100644 --- a/packages/docs/docs/development.md +++ b/packages/docs/docs/development.md @@ -36,23 +36,17 @@ npm install ### 3. Prepare simulator server build Simulator server repository is not open sourced but we have a pre-build binaries published on the GitHub releases page. -First, you need to navigate to the [releases page on GitHub](https://github.com/software-mansion/radon-ide/releases), open the recent release, and download the sim-server file from "Assets" section (the filename contains a git hash for build consistency): - -download-sim-server - -Next, place the downloaded file under `packages/vscode-extension/dist`. - -Finally, run the following script inside `packages/vscode-extension` directory: +There's a script that fetches the latest version of the binaries from the [releases page on GitHub](https://github.com/software-mansion/radon-ide/releases) – you can run it using the following command: ```bash npm run build:sim-server-debug ``` -In case of any errors, please read the output of this command before proceeding. +Note that some changes in the extension may depend on changes made to the simulator server, so you occasionally may need to re-run this script, for example when switching git branches. ### 4. Open extension project in Visual Studio Code -It is necessary that you open that exact folder rather than the whole repository, as it contains project specific run configuration for launching the extension in development mode. +It is necessary that you open exactly the main extension folder rather than the whole repository, as it contains project specific run configuration for launching the extension in development mode. You can do it by opening new window in Visual Studio Code and using `File > Open Folder` option, then select `packages/vscode-extension`, or if you have vscode's command line tool installed you can open it using command: ```sh @@ -97,7 +91,7 @@ depend on `expo-router` and `expo-icons`. To use them in the app: 1. Add npm command in test app package.json - - for expo-router apps: `"copy-shared": "../shared/copy.sh expo-router ./shared"`. + - for expo-router apps: `"copy-shared": "../shared/copy.sh expo-router ./shared"`. - for RN apps: `"copy-shared": "../shared/copy.sh bare ./shared"`. 2. Run it: `npm run copy-shared`. This copies shared components to `./shared`. 3. For RN apps, replace `App.tsx` with the `./shared/MainScreen.tsx` component. @@ -124,9 +118,9 @@ To use them in the app: You can also use other components in `shared` (e.g. `Text`, `Button`, `useScheme`) to theme the app. - + After updating shared components you need to copy them again by running - `npm run copy-shared` in every test app. + `npm run copy-shared` in every test app. `shared/copy.sh bare|expo-router DEST` script works by copying shared directory to `DEST` and removing `navigation` directory if `bare` argument is used. diff --git a/packages/docs/static/img/docs/download_sim_server.png b/packages/docs/static/img/docs/download_sim_server.png deleted file mode 100644 index 7700a568e..000000000 Binary files a/packages/docs/static/img/docs/download_sim_server.png and /dev/null differ diff --git a/packages/simulator-server b/packages/simulator-server index 5536faa13..6d2b2b6f0 160000 --- a/packages/simulator-server +++ b/packages/simulator-server @@ -1 +1 @@ -Subproject commit 5536faa13fad6663e3c08f164361b64cfa3b4c54 +Subproject commit 6d2b2b6f0656d1cccc5f8b706ab2710b93cc1961 diff --git a/packages/vscode-extension/package.json b/packages/vscode-extension/package.json index c3f6188eb..dfd6e4942 100644 --- a/packages/vscode-extension/package.json +++ b/packages/vscode-extension/package.json @@ -432,7 +432,7 @@ "build:extension-code": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --minify && cp ./node_modules/source-map/lib/mappings.wasm dist/.", "build:expo-fingerprint": "esbuild ./node_modules/@expo/fingerprint/build/sourcer/ExpoConfigLoader.js --bundle --format=cjs --outfile=dist/ExpoConfigLoader.js --platform=node --minify", "build:webview": "vite build --mode production && cp ./node_modules/@vscode/codicons/dist/codicon.* dist/.", - "build:sim-server-debug": "bash ./scripts/build-sim-server.sh dist Debug", + "build:sim-server-debug": "bash ./scripts/build-sim-server-debug.sh dist", "build:sim-server": "bash ./scripts/install-sim-server-release-build.sh dist", "build:debug": "npm run build:extension-debug && npm run build:sim-server-debug", "build:dist": "npm run build:extension && npm run build:sim-server && npm run build:webview", diff --git a/packages/vscode-extension/scripts/build-sim-server.sh b/packages/vscode-extension/scripts/build-sim-server-debug.sh similarity index 51% rename from packages/vscode-extension/scripts/build-sim-server.sh rename to packages/vscode-extension/scripts/build-sim-server-debug.sh index 7ce56f267..fa4c17522 100755 --- a/packages/vscode-extension/scripts/build-sim-server.sh +++ b/packages/vscode-extension/scripts/build-sim-server-debug.sh @@ -6,36 +6,42 @@ cd "$(dirname "$0")/.." # take output directory from first argument or default to out - relative to the vscode-extension package location output_dir="${1:-out}" -# take configuration from second argument or default to Debug -configuration=${2:-Debug} - submodule_status=$(git submodule status ../simulator-server) + if [[ $submodule_status == -* ]]; then # submodule is not initialized -submodule_hash=$(git ls-tree HEAD ../simulator-server | awk '{print $3}') +# get version of npm module +latest_tag=$(git describe --tags --abbrev=0) +download_base_url="https://github.com/software-mansion/radon-ide/releases/download/${latest_tag}/" + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then - product_path="$output_dir/sim-server-Release-${submodule_hash}.exe" + product_path="$output_dir/simulator-server-${latest_tag}-windows.exe" + download_url="${download_base_url}simulator-server-windows.exe" +elif [[ "$OSTYPE" == "darwin"* ]]; then + product_path="$output_dir/simulator-server-${latest_tag}-macos" + download_url="${download_base_url}simulator-server-macos" else - product_path="$output_dir/sim-server-Release-${submodule_hash}" + product_path="$output_dir/simulator-server-${latest_tag}-linux" + download_url="${download_base_url}simulator-server-linux" fi -# if the binary is not present, print instructions to download it from releases page: +# if the binary is not present, download it from Radon IDE releases page if [[ ! -f "$product_path" ]]; then echo "Simulator server binary not found: $product_path" echo "" - echo "Make sure to follow development setup instructions: https://ide.swmansion.com/docs/development" - echo "You can download the binary from the releases page on GitHub: https://github.com/software-mansion/radon-ide/releases" + echo "Downloading the binary from the Radon IDE releases page..." + echo "" + curl -L "$download_url" -o "$product_path" -f -# --create-dirs +fi + +if [[ ! -f "$product_path" ]]; then + echo "Failed to download the binary. Aborting." exit 1 fi else # submodule is initialized -# For release builds we always make sure that submodule is up to date -if [[ $configuration == "Release" ]]; then - git submodule update --init -- ../simulator-server -fi - if [[ $submodule_status == +* ]]; then # submodule is not up-to-date echo "Submodule has changes. Continue? [y/n]" # read answer or abort if no input is provided in 5 seconds @@ -47,7 +53,7 @@ fi # execute the build from the simulator-server package # the build product location is printed by the build script as the very last line -product_path=$("../simulator-server/scripts/build.sh" "$configuration" | tail -n 1) +product_path=$("../simulator-server/scripts/build-extension-dev.sh" | tail -n 1) # Check if the build was successful if [[ $? -ne 0 ]]; then @@ -60,17 +66,17 @@ fi # submodule check # Create the target directory if it doesn't exist mkdir -p "$output_dir" -target_location="$output_dir/sim-server" - -if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then # rename to *.exe on Windows - mv "$product_path" "$target_location-executable.exe" - exit 0 +if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then + target_location="$output_dir/simulator-server-windows.exe" +elif [[ "$OSTYPE" == "darwin"* ]]; then + target_location="$output_dir/simulator-server-macos" +else + target_location="$output_dir/simulator-server-linux" fi # Check if a file was found and copy it if [[ -n $product_path ]]; then - # copy it using dd to avoid permission issues - dd if="$product_path" of="$target_location" 2> /dev/null + cp "$product_path" "$target_location" # add execution permissions chmod +x "$target_location" else diff --git a/packages/vscode-extension/scripts/install-sim-server-release-build.sh b/packages/vscode-extension/scripts/install-sim-server-release-build.sh index 4c48101fc..cb5ca7fe8 100755 --- a/packages/vscode-extension/scripts/install-sim-server-release-build.sh +++ b/packages/vscode-extension/scripts/install-sim-server-release-build.sh @@ -34,13 +34,8 @@ mkdir -p "$output_dir" # Get tag of simulator-server submodule sim_server_tag=$(git -C ../simulator-server describe --tags) -echo "Downloading sim-server binaries for tag $sim_server_tag" +echo "Downloading simulator-server binaries for tag $sim_server_tag" -# Download Mac and Windows binaries using gh CLI and place them in the correcto location -mac_binary_path="$output_dir/sim-server" -gh release download $sim_server_tag -R software-mansion-labs/simulator-server -p simulator-server -O "$mac_binary_path" -chmod +x "$mac_binary_path" - -win_binary_path="$output_dir/sim-server-executable.exe" -gh release download $sim_server_tag -R software-mansion-labs/simulator-server -p simulator-server.exe -O "$win_binary_path" -chmod +x "$win_binary_path" +# Download simulator-server binaries using gh CLI and place them in the output directory with correct file mode +gh release download $sim_server_tag -R software-mansion-labs/simulator-server -p "simulator-server*" -D "$output_dir" +chmod +x "$output_dir"/simulator-server* diff --git a/packages/vscode-extension/src/devices/preview.ts b/packages/vscode-extension/src/devices/preview.ts index 7f7945d88..9aea2d7cc 100644 --- a/packages/vscode-extension/src/devices/preview.ts +++ b/packages/vscode-extension/src/devices/preview.ts @@ -26,7 +26,7 @@ export class Preview implements Disposable { const simControllerBinary = path.join( extensionContext.extensionPath, "dist", - Platform.select({ macos: "sim-server-executable", windows: "sim-server-executable.exe" }) + Platform.select({ macos: "simulator-server-macos", windows: "simulator-server-windows.exe" }) ); Logger.debug(`Launch preview ${simControllerBinary} ${this.args}`); diff --git a/packages/vscode-extension/src/extension.ts b/packages/vscode-extension/src/extension.ts index 6ade670ce..988c4fd9e 100644 --- a/packages/vscode-extension/src/extension.ts +++ b/packages/vscode-extension/src/extension.ts @@ -24,7 +24,7 @@ import { setAppRootFolder, setExtensionContext, } from "./utilities/extensionContext"; -import { command, setupPathEnv } from "./utilities/subprocess"; +import { setupPathEnv } from "./utilities/subprocess"; import { SidePanelViewProvider } from "./panels/SidepanelViewProvider"; import { PanelLocation } from "./common/WorkspaceConfig"; import { getLaunchConfiguration } from "./utilities/launchConfiguration"; @@ -75,14 +75,6 @@ export async function activate(context: ExtensionContext) { migrateOldConfiguration(); - if (Platform.OS === "macos") { - try { - await fixMacosBinary(context); - } catch (error) { - Logger.error("Error when processing simulator-server binaries", error); - // we let the activation continue, as otherwise the diagnostics command would fail - } - } commands.executeCommand("setContext", "RNIDE.sidePanelIsClosed", false); async function showIDEPanel(fileName?: string, lineNumber?: number) { @@ -461,24 +453,3 @@ function migrateOldConfiguration() { Logger.error("Error when migrating old configuration", e); } } - -async function fixMacosBinary(context: ExtensionContext) { - // MacOS prevents binary files from being executed when downloaded from the internet. - // It requires notarization ticket to be available in the package where the binary was distributed - // with. Apparently Apple does not allow for individual binary files to be notarized and only .app/.pkg and .dmg - // files are allowed. To prevent the binary from being quarantined, we clone using byte-copy (with dd). This way the - // quarantine attribute is removed. We try to do it only when the binary has been modified or for the new installation, - // we detect that based on the modification date of the binary file. - const buildBinPath = Uri.file(context.asAbsolutePath("dist/sim-server")); - const exeBinPath = Uri.file(context.asAbsolutePath("dist/sim-server-executable")); - - // if build and exe binaries don't match, we need to clone the build binary – we always want the exe one to the exact - // copy of the build binary: - try { - await command(`diff -q ${buildBinPath.fsPath} ${exeBinPath.fsPath}`); - } catch (error) { - // if binaries are different, diff will return non-zero code and we will land in catch clouse - await command(`dd if=${buildBinPath.fsPath} of=${exeBinPath.fsPath}`); - } - await fs.promises.chmod(exeBinPath.fsPath, 0o755); -}