Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename win-shortcuts module to windows-utils #7843

Merged
merged 2 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Line wrap the file at 100 chars. Th
* **Security**: in case of vulnerabilities.

## [Unreleased]
### Changed
#### Windows
- Rename `win-shortcuts` native module to `windows-utils`.

### Removed
- Remove "Any" option for tunnel protocol. The default is now WireGuard.

Expand Down
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resolver = "2"
members = [
"android/translations-converter",
"desktop/packages/nseventforwarder",
"desktop/packages/win-shortcuts",
"desktop/packages/windows-utils",
"mullvad-api",
"mullvad-cli",
"mullvad-daemon",
Expand Down
14 changes: 7 additions & 7 deletions desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop/packages/mullvad-vpn/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ task(
'clean',
'set-dev-env',
scripts.buildNseventforwarder,
scripts.buildWinShortcuts,
scripts.buildWindowsUtils,
watch.start,
),
);
Expand Down
2 changes: 1 addition & 1 deletion desktop/packages/mullvad-vpn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"simple-plist": "^1.3.1",
"sprintf-js": "^1.1.2",
"styled-components": "^6.1.13",
"win-shortcuts": "0.0.0"
"windows-utils": "0.0.0"
},
"devDependencies": {
"@playwright/test": "^1.41.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { app } from 'electron';
import fs from 'fs';
import path from 'path';
import { readShortcut } from 'win-shortcuts';
import { readShortcut } from 'windows-utils';

import {
ISplitTunnelingApplication,
Expand Down
6 changes: 3 additions & 3 deletions desktop/packages/mullvad-vpn/tasks/distribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function newConfig() {
'!node_modules/grpc-tools',
'!node_modules/@types',
'!node_modules/nseventforwarder/debug',
'!node_modules/win-shortcuts/debug',
'!node_modules/windows-utils/debug',
],

// Make sure that all files declared in "extraResources" exists and abort if they don't.
Expand Down Expand Up @@ -291,15 +291,15 @@ async function packWin() {
process.env.TARGET_SUBDIR = 'x86_64-pc-windows-msvc';
process.env.DIST_SUBDIR = '';

execFileSync('npm', ['-w', 'win-shortcuts', 'run', 'build-x86'], { shell: true });
execFileSync('npm', ['-w', 'windows-utils', 'run', 'build-x86'], { shell: true });
break;
case 'arm64':
process.env.TARGET_TRIPLE = 'aarch64-pc-windows-msvc';
process.env.SETUP_SUBDIR = 'aarch64-pc-windows-msvc';
process.env.TARGET_SUBDIR = 'aarch64-pc-windows-msvc';
process.env.DIST_SUBDIR = 'aarch64-pc-windows-msvc';

execFileSync('npm', ['-w', 'win-shortcuts', 'run', 'build-arm'], { shell: true });
execFileSync('npm', ['-w', 'windows-utils', 'run', 'build-arm'], { shell: true });
break;
default:
throw new Error('Invalid or unknown target (only one may be specified)');
Expand Down
8 changes: 4 additions & 4 deletions desktop/packages/mullvad-vpn/tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ function buildNseventforwarder(callback) {
}
}

function buildWinShortcuts(callback) {
function buildWindowsUtils(callback) {
if (process.platform === 'win32') {
exec('npm -w win-shortcuts run build-debug', (err) => callback(err));
exec('npm -w windows-utils run build-debug', (err) => callback(err));
} else {
callback();
}
}

compileScripts.displayName = 'compile-scripts';
buildNseventforwarder.displayName = 'build-nseventforwarder';
buildWinShortcuts.displayName = 'build-win-shortcuts';
buildWindowsUtils.displayName = 'build-windows-utils';

exports.build = series(
compileScripts,
parallel(makeBrowserifyPreload(false), makeBrowserifyRenderer(false)),
);
exports.buildNseventforwarder = buildNseventforwarder;
exports.buildWinShortcuts = buildWinShortcuts;
exports.buildWindowsUtils = buildWindowsUtils;
exports.makeWatchCompiler = makeWatchCompiler;
4 changes: 2 additions & 2 deletions desktop/packages/mullvad-vpn/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const viteConfig = defineConfig({
// Packages in workspace which exports common js
/management-interface/,
/nseventforwarder/,
/win-shortcuts/,
/windows-utils/,
// External dependencies which exports common js
/node_modules/,
],
Expand All @@ -87,7 +87,7 @@ const viteConfig = defineConfig({
},
external: [
// Packages in workspace which can not be bundled
'win-shortcuts',
'windows-utils',
// External dependencies
'@grpc/grpc-js',
'google-protobuf',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "win-shortcuts"
name = "windows-utils"
description = ""
authors.workspace = true
repository.workspace = true
Expand All @@ -13,7 +13,7 @@ workspace = true

[lib]
crate-type = ["cdylib"]
path = "win-shortcuts-rs/lib.rs"
path = "windows-utils-rs/lib.rs"

[target.'cfg(target_os = "windows")'.dependencies]
neon = "1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# win-shortcuts
# windows-utils

## Building win-shortcuts
## Building windows-utils

Building win-shortcuts requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support).
Building windows-utils requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support).

To run the build, run:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "win-shortcuts",
"name": "windows-utils",
"version": "0.0.0",
"author": "Mullvad VPN",
"license": "GPL-3.0",
"description": "",
"main": "./lib/index.cjs",
"scripts": {
"cargo-build": "npm run build-typescript && cargo build",
"build-debug": "npm run cargo-build && (test -d debug || mkdir debug) && cp ../../../target/debug/win_shortcuts.dll debug/index.node",
"build-arm": "npm run cargo-build -- --release --target aarch64-pc-windows-msvc && (test -d dist || mkdir dist) && (test -d dist/win32-arm64-msvc || mkdir \"dist/win32-arm64-msvc\") && cp ../../../target/aarch64-pc-windows-msvc/release/win_shortcuts.dll dist/win32-arm64-msvc/index.node",
"build-debug": "npm run cargo-build && (test -d debug || mkdir debug) && cp ../../../target/debug/windows_utils.dll debug/index.node",
"build-arm": "npm run cargo-build -- --release --target aarch64-pc-windows-msvc && (test -d dist || mkdir dist) && (test -d dist/win32-arm64-msvc || mkdir \"dist/win32-arm64-msvc\") && cp ../../../target/aarch64-pc-windows-msvc/release/windows_utils.dll dist/win32-arm64-msvc/index.node",
"build-typescript": "tsc",
"build-x86": "npm run cargo-build -- --release --target x86_64-pc-windows-msvc && (test -d dist || mkdir dist) && (test -d dist/win32-x64-msvc || mkdir \"dist/win32-x64-msvc\") && cp ../../../target/x86_64-pc-windows-msvc/release/win_shortcuts.dll dist/win32-x64-msvc/index.node",
"build-x86": "npm run cargo-build -- --release --target x86_64-pc-windows-msvc && (test -d dist || mkdir dist) && (test -d dist/win32-x64-msvc || mkdir \"dist/win32-x64-msvc\") && cp ../../../target/x86_64-pc-windows-msvc/release/windows_utils.dll dist/win32-x64-msvc/index.node",
"clean": "rm -rf debug; rm -rf dist",
"lint": "eslint .",
"lint-fix": "eslint --fix .",
Expand Down
12 changes: 12 additions & 0 deletions desktop/packages/windows-utils/windows-utils-rs/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![cfg(target_os = "windows")]

use neon::{prelude::ModuleContext, result::NeonResult};

mod shortcut;

#[neon::main]
fn main(mut cx: ModuleContext<'_>) -> NeonResult<()> {
cx.export_function("readShortcut", shortcut::read_shortcut)?;

Ok(())
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![cfg(target_os = "windows")]

use std::marker::PhantomData;
use std::string::FromUtf16Error;
use std::sync::{mpsc, OnceLock};
Expand Down Expand Up @@ -51,14 +49,7 @@ enum Error {
/// 32 KiB: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
const MAX_PATH_LEN: usize = 0x7fff;

#[neon::main]
fn main(mut cx: ModuleContext<'_>) -> NeonResult<()> {
cx.export_function("readShortcut", read_shortcut)?;

Ok(())
}

fn read_shortcut(mut cx: FunctionContext<'_>) -> JsResult<'_, JsValue> {
pub fn read_shortcut(mut cx: FunctionContext<'_>) -> JsResult<'_, JsValue> {
let link_path = cx.argument::<JsString>(0)?.value(&mut cx);

match read_shortcut_inner(link_path) {
Expand Down
Loading