Skip to content
Draft
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
36 changes: 36 additions & 0 deletions docs/man_pages/project/testing/build-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<% if (isJekyll) { %>---
title: ns build linux
position: 12
---<% } %>

# ns build linux

### Description

Builds the project for Linux. The output is a folder with the runtime executable (named after the project), its metadata and the bundled app; `--release` also packs it as a `.tar.gz`.

<% if(isConsole && (isWindows || isMacOS)) { %>WARNING: You can run this command only on Linux systems. To view the complete help for this command, run `$ ns help build linux`<% } %>

### Commands

Usage | Synopsis
---|---
Build for Linux | `$ ns build linux [--release] [--arch <x64|arm64>] [--env.*]`

### Options

* `--release` - If set, produces a release build in `platforms/linux/<Project>/dist`. Otherwise, produces a debug build in `platforms/linux/<Project>/bin`.
* `--arch` - The runtime architecture to package, `x64` or `arm64`. Defaults to the host architecture.
* `--env.*` - Specifies additional flags that the bundler may process. Can be passed multiple times.
* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed.

<% if(isHtml) { %>

### Related Commands

Command | Description
----------|----------
[run linux](run-linux.html) | Runs your project on the local Linux machine.
[debug linux](debug-linux.html) | Debugs your project on the local Linux machine.
[build](build.html) | Builds the project for the selected target platform.
<% } %>
4 changes: 3 additions & 1 deletion docs/man_pages/project/testing/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Usage | Synopsis
`<Platform>` is the target platform for which you want to build your project. You can set the following target platforms.
* `android` - Build the project for Android and produces an `APK` that you can manually deploy on a device or in the native emulator.
* `ios` - Build the project for iOS and produces an `APP` or `IPA` that you can manually deploy in the iOS Simulator or on a device.
* `windows` - Build the project for Windows. Release builds produce an `MSIX` package (Windows only).<% } %>
* `windows` - Build the project for Windows. Release builds produce an `MSIX` package (Windows only).
* `linux` - Build the project for Linux. Release builds produce a `.tar.gz` (Linux only).<% } %>

### Options

Expand Down Expand Up @@ -55,6 +56,7 @@ Command | Description
[build android](build-android.html) | Builds the project for Android and produces an APK that you can manually deploy on device or in the native emulator.
[build ios](build-ios.html) | Builds the project for iOS and produces an APP or IPA that you can manually deploy in the iOS Simulator or on device, respectively.
[build windows](build-windows.html) | Builds the project for Windows.
[build linux](build-linux.html) | Builds the project for Linux.
[debug android](debug-android.html) | Debugs your project on a connected Android device or in a native emulator.
[debug ios](debug-ios.html) | Debugs your project on a connected iOS device or in a native emulator.
[debug](debug.html) | Debugs your project on a connected device or in a native emulator.
Expand Down
37 changes: 37 additions & 0 deletions docs/man_pages/project/testing/debug-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<% if (isJekyll) { %>---
title: ns debug linux
position: 12
---<% } %>

# ns debug linux

### Description

Runs your project on the local Linux machine with the Chrome DevTools inspector enabled (port 9229, or `$NS_LINUX_INSPECTOR_PORT`) and prints the DevTools URL.

<% if(isConsole && (isWindows || isMacOS)) { %>WARNING: You can run this command only on Linux systems. To view the complete help for this command, run `$ ns help debug linux`<% } %>

### Commands

Usage | Synopsis
---|---
Debug on the local Linux machine | `$ ns debug linux [--debug-brk] [--start] [--timeout <seconds>] [--env.*]`

### Options

* `--debug-brk` - Stops on the first line of the app until DevTools attaches.
* `--start` - Attaches to the already running app instead of starting it.
* `--timeout` - Seconds to wait for the inspector. Defaults to 90.
* `--no-hmr` - Disables Hot Module Replacement (HMR).
* `--env.*` - Specifies additional flags that the bundler may process. Can be passed multiple times.

<% if(isHtml) { %>

### Related Commands

Command | Description
----------|----------
[run linux](run-linux.html) | Runs your project on the local Linux machine.
[build linux](build-linux.html) | Builds the project for Linux.
[debug](debug.html) | Debugs your project on a connected device or in a native emulator.
<% } %>
4 changes: 3 additions & 1 deletion docs/man_pages/project/testing/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Usage | Synopsis
`<Platform>` is the target platform for which you want to debug your project. You can set the following target platforms:
* `android` - Start a debugging session for your project on a connected Android device or Android emulator.
* `ios` - Start a debugging session for your project on a connected iOS device or in the native iOS simulator.
* `windows` - Start a debugging session on the local Windows machine via the Chrome DevTools Protocol on port 43000 (Windows only).<% } %>
* `windows` - Start a debugging session on the local Windows machine via the Chrome DevTools Protocol on port 43000 (Windows only).
* `linux` - Start a debugging session on the local Linux machine via the Chrome DevTools Protocol on port 9229 (Linux only).<% } %>

<% if(isHtml) { %>

Expand All @@ -60,6 +61,7 @@ Command | Description
[debug android](debug-android.html) | Debugs your project on a connected Android device or in a native emulator.
[debug ios](debug-ios.html) | Debugs your project on a connected iOS device or in a native emulator.
[debug windows](debug-windows.html) | Debugs your project on the local Windows machine.
[debug linux](debug-linux.html) | Debugs your project on the local Linux machine.
[deploy](deploy.html) | Builds and deploys the project to a connected physical or virtual device.
[run android](run-android.html) | Runs your project on a connected Android device or in a native Android emulator, if configured.
[run ios](run-ios.html) | Runs your project on a connected iOS device or in the iOS Simulator, if configured.
Expand Down
49 changes: 49 additions & 0 deletions docs/man_pages/project/testing/run-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<% if (isJekyll) { %>---
title: ns run linux
position: 12
---<% } %>

# ns run linux

### Description

Runs your project on the local Linux machine. This is shorthand for prepare, build, deploy and launch. While your app is running, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with the running application.

<% if(isConsole && (isWindows || isMacOS)) { %>WARNING: You can run this command only on Linux systems. To view the complete help for this command, run `$ ns help run linux`<% } %>
<% if((isConsole && isLinux) || isHtml) { %>
The app runs as a child process of the CLI. To start it with the Chrome DevTools inspector enabled, use `$ ns debug linux`.
<% } %>

### Commands

Usage | Synopsis
---|---
Run on the local Linux machine | `$ ns run linux [--release] [--justlaunch] [--arch <x64|arm64>] [--env.*]`

### Options

* `--justlaunch` - If set, does not print the application output in the console.
* `--release` - If set, produces a release build. Otherwise, produces a debug build.
* `--arch` - The runtime architecture to package, `x64` or `arm64`. Defaults to the host architecture.
* `--no-hmr` - Disables Hot Module Replacement (HMR). When a change in the code is applied, CLI will transfer the modified files and restart the application.
* `--env.*` - Specifies additional flags that the bundler may process. Can be passed multiple times.
* `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed.

<% if(isHtml) { %>

### Prerequisites

* A Linux distribution with GTK 4 installed (for example `sudo apt install libgtk-4-1` or `sudo dnf install gtk4`).

### Command Limitations

* You can run `$ ns run linux` only on Linux systems.

### Related Commands

Command | Description
----------|----------
[build linux](build-linux.html) | Builds the project for Linux.
[debug linux](debug-linux.html) | Debugs your project on the local Linux machine.
[run](run.html) | Runs your project on a connected device or in the native emulator for the selected platform.
<% } %>
2 changes: 2 additions & 0 deletions docs/man_pages/project/testing/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Run on a selected connected device or running emulator. Will start emulator with
* `android` - Run your project on all Android devices and emulators.
* `ios` - Run your project on all iOS devices and simulators.
* `windows` - Run your project on the local Windows machine (Windows only).
* `linux` - Run your project on the local Linux machine (Linux only).

<% } %>

Expand Down Expand Up @@ -89,6 +90,7 @@ Command | Description
[run android](run-android.html) | Runs your project on a connected Android device or in a native Android emulator, if configured.
[run ios](run-ios.html) | Runs your project on a connected iOS device or in the iOS Simulator, if configured.
[run windows](run-windows.html) | Runs your project on the local Windows machine.
[run linux](run-linux.html) | Runs your project on the local Linux machine.
[test init](test-init.html) | Configures your project for unit testing with a selected framework.
[test android](test-android.html) | Runs the tests in your project on Android devices or native emulators.
[test ios](test-ios.html) | Runs the tests in your project on iOS devices or the iOS Simulator.
Expand Down
2 changes: 2 additions & 0 deletions docs/man_pages/project/testing/typings.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Usage | Synopsis
---|---
Generate typings to Android | `$ ns typings android [--jar <Jar1> --jar <Jar2>] [--aar <Aar1>] [--copy-to <Path>]`
Generate typings to iOS | `$ ns typings ios [--filter <Filter>] [--copy-to <Path>]`
Generate typings for Linux native code | `$ ns typings linux [--copy-to <Path>]`

### Options

Expand All @@ -28,6 +29,7 @@ Generate typings to iOS | `$ ns typings ios [--filter <Filter>] [--copy-to <Path
`<Platform>` is the target mobile platform for which you want to generate typings. You can set the following target platforms:
* `android` - Generate typings for android.
* `ios` - Generate typings for iOS.
* `linux` - Generate typings for the C code in `App_Resources/Linux` and plugins' `platforms/linux` into `typings/linux`. Later builds keep them up to date.



Expand Down
12 changes: 12 additions & 0 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ injector.require("iOSExtensionsService", "./services/ios-extensions-service");
injector.require("iOSWatchAppService", "./services/ios-watch-app-service");
injector.require("iOSProjectService", "./services/ios-project-service");
injector.require("windowsProjectService", "./services/windows-project-service");
injector.require("linuxProjectService", "./services/linux-project-service");
injector.require("iOSProvisionService", "./services/ios-provision-service");
injector.require("xcconfigService", "./services/xcconfig-service");
injector.require("iOSSigningService", "./services/ios/ios-signing-service");
Expand Down Expand Up @@ -157,6 +158,10 @@ injector.require(
"windowsDeviceDebugService",
"./services/windows-device-debug-service",
);
injector.require(
"linuxDeviceDebugService",
"./services/linux-device-debug-service",
);

injector.require(
"timelineProfilerService",
Expand Down Expand Up @@ -189,6 +194,7 @@ injector.requireCommand("run|android", "./commands/run");
injector.requireCommand("run|vision", "./commands/run");
injector.requireCommand("run|visionos", "./commands/run");
injector.requireCommand("run|windows", "./commands/run");
injector.requireCommand("run|linux", "./commands/run");
injector.requireCommand("typings", "./commands/typings");

injector.requireCommand("preview", "./commands/preview");
Expand All @@ -198,6 +204,7 @@ injector.requireCommand("debug|android", "./commands/debug");
injector.requireCommand("debug|vision", "./commands/debug");
injector.requireCommand("debug|visionos", "./commands/debug");
injector.requireCommand("debug|windows", "./commands/debug");
injector.requireCommand("debug|linux", "./commands/debug");
injector.requireCommand("fonts", "./commands/fonts");

injector.requireCommand("prepare", "./commands/prepare");
Expand All @@ -206,6 +213,7 @@ injector.requireCommand("build|android", "./commands/build");
injector.requireCommand("build|vision", "./commands/build");
injector.requireCommand("build|visionos", "./commands/build");
injector.requireCommand("build|windows", "./commands/build");
injector.requireCommand("build|linux", "./commands/build");
injector.requireCommand("deploy", "./commands/deploy");

injector.requireCommand("embed", "./commands/embedding/embed");
Expand Down Expand Up @@ -334,6 +342,10 @@ injector.require(
"windowsLiveSyncService",
"./services/livesync/windows-livesync-service",
);
injector.require(
"linuxLiveSyncService",
"./services/livesync/linux-livesync-service",
);
injector.require("usbLiveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript
injector.requirePublic("sysInfo", "./sys-info");

Expand Down
51 changes: 51 additions & 0 deletions lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,54 @@ export class BuildWindowsCommand extends BuildCommandBase implements ICommand {
}

injector.registerCommand("build|windows", BuildWindowsCommand);

export class BuildLinuxCommand extends BuildCommandBase implements ICommand {
public allowedParameters: ICommandParameter[] = [];

constructor(
protected $options: IOptions,
$errors: IErrors,
$projectData: IProjectData,
$platformsDataService: IPlatformsDataService,
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
$buildDataService: IBuildDataService,
protected $logger: ILogger,
private $migrateController: IMigrateController,
) {
super(
$options,
$errors,
$projectData,
$platformsDataService,
$devicePlatformsConstants,
$buildController,
$platformValidationService,
$buildDataService,
$logger,
);
}

public async execute(_args: string[]): Promise<void> {
await this.executeCore([
this.$devicePlatformsConstants.Linux.toLowerCase(),
]);
}

public async canExecute(args: string[]): Promise<boolean> {
const platform = this.$devicePlatformsConstants.Linux;
if (!this.$options.force) {
await this.$migrateController.validate({
projectDir: this.$projectData.projectDir,
platforms: [platform],
});
}
return (
(await super.canExecuteCommandBase(platform)) &&
super.validateArgs(args, platform)
);
}
}

injector.registerCommand("build|linux", BuildLinuxCommand);
32 changes: 32 additions & 0 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,35 @@ export class DebugWindowsCommand implements ICommand {
}

injector.registerCommand("debug|windows", DebugWindowsCommand);

export class DebugLinuxCommand implements ICommand {
@cache()
private get debugPlatformCommand(): DebugPlatformCommand {
return this.$injector.resolve<DebugPlatformCommand>(DebugPlatformCommand, {
platform: this.$devicePlatformsConstants.Linux,
});
}

public allowedParameters: ICommandParameter[] = [];

constructor(
protected $errors: IErrors,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $injector: IInjector,
private $projectData: IProjectData,
) {
this.$projectData.initializeProjectData();
}

public async execute(args: string[]): Promise<void> {
return this.debugPlatformCommand.execute(args);
}

public async canExecute(args: string[]): Promise<boolean> {
return this.debugPlatformCommand.canExecute(args);
}

public platform = this.$devicePlatformsConstants.Linux;
}

injector.registerCommand("debug|linux", DebugLinuxCommand);
49 changes: 49 additions & 0 deletions lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,52 @@ export class RunWindowsCommand implements ICommand {
}

injector.registerCommand("run|windows", RunWindowsCommand);

export class RunLinuxCommand implements ICommand {
@cache()
private get runCommand(): RunCommandBase {
const runCommand = this.$injector.resolve<RunCommandBase>(RunCommandBase);
runCommand.platform = this.platform;
return runCommand;
}

public allowedParameters: ICommandParameter[] = [];
public get platform(): string {
return this.$devicePlatformsConstants.Linux;
}

constructor(
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $errors: IErrors,
private $injector: IInjector,
private $options: IOptions,
private $platformValidationService: IPlatformValidationService,
private $projectData: IProjectData,
) {}

public async execute(args: string[]): Promise<void> {
return this.runCommand.execute(args);
}

public async canExecute(args: string[]): Promise<boolean> {
await this.runCommand.canExecute(args);
if (
!this.$platformValidationService.isPlatformSupportedForOS(
this.platform,
this.$projectData,
)
) {
this.$errors.fail(
`Applications for platform ${this.platform} can not be built on this OS`,
);
}
return this.$platformValidationService.validateOptions(
this.$options.provision,
this.$options.teamId,
this.$projectData,
this.platform.toLowerCase(),
);
}
}

injector.registerCommand("run|linux", RunLinuxCommand);
Loading
Loading