Skip to content

Commit 5b29d6e

Browse files
committed
Merge branch 'main' of github.com:NativeScript/nativescript-cli
# Conflicts: # lib/services/plugins-service.ts
2 parents 367b3b8 + 1bb41ca commit 5b29d6e

65 files changed

Lines changed: 2270 additions & 1156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# [8.7.0](https://github.com/NativeScript/nativescript-cli/compare/v8.6.5...v8.7.0) (2024-04-08)
2+
3+
4+
### Bug Fixes
5+
6+
* **autocomplete:** fix the generation of the autocomplete script and prevent duplication on enable/disable ([#5794](https://github.com/NativeScript/nativescript-cli/issues/5794)) ([7c87b49](https://github.com/NativeScript/nativescript-cli/commit/7c87b49bd3779ad4a43ebae044595e2bdac8b373))
7+
* **debug-ios:** don't explicitly bind ws to `localhost` ([#5788](https://github.com/NativeScript/nativescript-cli/issues/5788)) ([280b10d](https://github.com/NativeScript/nativescript-cli/commit/280b10d3410d9b5340e7dd7e532a11e4cdd7bca5))
8+
* **ios:** only allow IPHONEOS_DEPLOYMENT_TARGET to be explicitly set vs entire xcconfig ([ac8afcc](https://github.com/NativeScript/nativescript-cli/commit/ac8afcc70c68c8c8476278ec508265483635f105))
9+
* **ios:** skip package validation on xcodebuild ([#5782](https://github.com/NativeScript/nativescript-cli/issues/5782)) ([e47cff4](https://github.com/NativeScript/nativescript-cli/commit/e47cff471ab25f7608360c8c0c94463a83116788))
10+
* **plugins:** parse name issue with invalid plugins ([#5770](https://github.com/NativeScript/nativescript-cli/issues/5770)) ([f826248](https://github.com/NativeScript/nativescript-cli/commit/f82624892c1433ea1aefdbeb06b5bd53e954b8a1))
11+
* remove python six requirement ([#5785](https://github.com/NativeScript/nativescript-cli/issues/5785)) ([25ae1f0](https://github.com/NativeScript/nativescript-cli/commit/25ae1f0842469697826c0061b499f55b54f0987d))
12+
* tests ([13b0bdb](https://github.com/NativeScript/nativescript-cli/commit/13b0bdb808a4796ea0c68575fd41308db5ef840c))
13+
14+
15+
### Features
16+
17+
* add experimental bun package manager support ([#5791](https://github.com/NativeScript/nativescript-cli/issues/5791)) ([f758f6c](https://github.com/NativeScript/nativescript-cli/commit/f758f6cac3ed5e1ba6adeb9b68a683a21fdd0e07))
18+
* add open ios/android ([#5779](https://github.com/NativeScript/nativescript-cli/issues/5779)) ([81b32bc](https://github.com/NativeScript/nativescript-cli/commit/81b32bcaa125d2914c4e3ad41068d7da9671635d))
19+
* **ios:** ensure user defined xcconfig always takes priority ([#5784](https://github.com/NativeScript/nativescript-cli/issues/5784)) ([500d751](https://github.com/NativeScript/nativescript-cli/commit/500d75176cee0f5c5a5551ffcc1d4c00c7543b5a))
20+
* provide appId to webpack config ([#5778](https://github.com/NativeScript/nativescript-cli/issues/5778)) ([e3ef37d](https://github.com/NativeScript/nativescript-cli/commit/e3ef37dc648e99ff09844e22e11c917f7d727cdf))
21+
* support for solid/solidjs templates and migrations for 8.7 ([#5796](https://github.com/NativeScript/nativescript-cli/issues/5796)) ([cf788f0](https://github.com/NativeScript/nativescript-cli/commit/cf788f053fd976ee7dd62af2ac61bb1590498be0))
22+
* visionOS support ([#5783](https://github.com/NativeScript/nativescript-cli/issues/5783)) ([6a6a832](https://github.com/NativeScript/nativescript-cli/commit/6a6a8322655b1dedadda912d712cf26ee6d51f56))
23+
24+
25+
126
## [8.6.4](https://github.com/NativeScript/nativescript-cli/compare/v8.6.3...v8.6.4) (2024-01-17)
227

328

README.md

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<br>
99
</h1>
1010

11-
<h4 align="center">The NativeScript CLI lets you create, build, and deploy <a href="https://docs.nativescript.org/" target="_blank">NativeScript</a>-based apps on iOS and Android devices.</h4>
11+
<h4 align="center">The NativeScript CLI lets you create, build, and deploy <a href="https://docs.nativescript.org/" target="_blank">NativeScript</a> apps.</h4>
1212
</a>
1313
</h4>
1414

@@ -18,30 +18,51 @@
1818

1919
Get it using: `npm install -g nativescript`
2020

21-
* [What is NativeScript](#what-is-nativescript "Quick overview of NativeScript, the JavaScript framework for cross-platform development of native iOS and Android apps")
22-
* [How the NativeScript CLI works](#how-the-nativescript-cli-works "How the CLI works in more detail")
23-
* [Supported Platforms](#supported-platforms "The mobile platforms you can target with NativeScript")
24-
* [System Requirements](#system-requirements "The hardware and software requirements for setting up and working with the NativeScript CLI")
25-
* [Installation](#installation "How to configure and install the NativeScript CLI")
26-
* [Install the NativeScript CLI](#install-the-nativescript-cli)
27-
* [Configure Proxy Usage](#configure-proxy-settings)
28-
* [Quick Start](#quick-start "Get started with the NativeScript CLI")
29-
* [The Commands](#the-commands)
30-
* [Create Project](#create-project)
31-
* [Develop Your Project](#develop-your-project)
32-
* [Build Your Project](#build-your-project)
33-
* [Run Your Project](#run-your-project)
34-
* [Extending the CLI](#extending-the-cli)
35-
* [Troubleshooting](#troubleshooting)
36-
* [How to Contribute](#how-to-contribute)
37-
* [How to Build](#how-to-build)
38-
* [Get Help](#get-help)
39-
* [License](#license)
21+
- [What is NativeScript](#what-is-nativescript)
22+
- [How the NativeScript CLI works](#how-the-nativescript-cli-works)
23+
- [Supported Platforms](#supported-platforms)
24+
- [System Requirements](#system-requirements)
25+
- [Installation](#installation)
26+
- [Install the NativeScript CLI](#install-the-nativescript-cli)
27+
- [Configure Proxy Settings](#configure-proxy-settings)
28+
- [Set Proxy Settings](#set-proxy-settings)
29+
- [Attributes](#attributes)
30+
- [Options](#options)
31+
- [Limitations](#limitations)
32+
- [Display Current Proxy Settings](#display-current-proxy-settings)
33+
- [Clear Proxy Settings](#clear-proxy-settings)
34+
- [Quick Start](#quick-start)
35+
- [The Commands](#the-commands)
36+
- [Create Project](#create-project)
37+
- [Develop Your Project](#develop-your-project)
38+
- [Development with NativeScript](#development-with-nativescript)
39+
- [Development in `app`](#development-in-app)
40+
- [Development in `platforms`](#development-in-platforms)
41+
- [Modifying Configuration Files](#modifying-configuration-files)
42+
- [Modifying Entitlements File (iOS only)](#modifying-entitlements-file-ios-only)
43+
- [Build Your Project](#build-your-project)
44+
- [Run Your Project](#run-your-project)
45+
- [Extending the CLI](#extending-the-cli)
46+
- [Troubleshooting](#troubleshooting)
47+
- [How to Contribute](#how-to-contribute)
48+
- [How to Build](#how-to-build)
49+
- [Get Help](#get-help)
50+
- [License](#license)
4051

4152
What is NativeScript
4253
===
4354

44-
NativeScript is a cross-platform JavaScript framework that lets you develop native iOS and Android apps from a single code base. The framework provides JavaScript access to the native APIs, user interface, and rendering engines of iOS and Android. By using JavaScript or TypeScript, you can create one project that builds into an iOS or Android app with completely native user experience.
55+
NativeScript provides platform APIs directly to the JavaScript runtime (_with strong types_) for a rich TypeScript development experience.
56+
57+
Some popular use cases:
58+
59+
- Building Web, iOS, Android and Vision Pro apps with a shared codebase (aka, cross platform apps)
60+
- Building native platform apps with portable JavaScript skills
61+
- Augmenting JavaScript projects with platform API capabilities
62+
- AndroidTV and Watch development
63+
- watchOS development
64+
- Learning native platforms through JavaScript understanding
65+
- Exploring platform API documentation by trying APIs [directly from a web browser](https://preview.nativescript.org/) without requiring a platform development machine setup.
4566

4667
To learn more about NativeScript, you can check the following resources:
4768

lib/bootstrap.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,32 @@ injector.requireCommand("platform|update", "./commands/update-platform");
180180
injector.requireCommand("run|*all", "./commands/run");
181181
injector.requireCommand("run|ios", "./commands/run");
182182
injector.requireCommand("run|android", "./commands/run");
183+
injector.requireCommand("run|vision", "./commands/run");
184+
injector.requireCommand("run|visionos", "./commands/run");
183185
injector.requireCommand("typings", "./commands/typings");
184186

185187
injector.requireCommand("preview", "./commands/preview");
186188

187189
injector.requireCommand("debug|ios", "./commands/debug");
188190
injector.requireCommand("debug|android", "./commands/debug");
191+
injector.requireCommand("debug|vision", "./commands/debug");
192+
injector.requireCommand("debug|visionos", "./commands/debug");
189193
injector.requireCommand("fonts", "./commands/fonts");
190194

191195
injector.requireCommand("prepare", "./commands/prepare");
192196
injector.requireCommand("build|ios", "./commands/build");
193197
injector.requireCommand("build|android", "./commands/build");
198+
injector.requireCommand("build|vision", "./commands/build");
199+
injector.requireCommand("build|visionos", "./commands/build");
194200
injector.requireCommand("deploy", "./commands/deploy");
195201

196202
injector.require("testExecutionService", "./services/test-execution-service");
197203
injector.requireCommand("dev-test|android", "./commands/test");
198204
injector.requireCommand("dev-test|ios", "./commands/test");
199205
injector.requireCommand("test|android", "./commands/test");
200206
injector.requireCommand("test|ios", "./commands/test");
207+
// injector.requireCommand("test|vision", "./commands/test");
208+
// injector.requireCommand("test|visionos", "./commands/test");
201209
injector.requireCommand("test|init", "./commands/test-init");
202210
injector.requireCommand("dev-generate-help", "./commands/generate-help");
203211

@@ -217,6 +225,7 @@ injector.requirePublic("npm", "./node-package-manager");
217225
injector.requirePublic("yarn", "./yarn-package-manager");
218226
injector.requirePublic("yarn2", "./yarn2-package-manager");
219227
injector.requirePublic("pnpm", "./pnpm-package-manager");
228+
injector.requirePublic("bun", "./bun-package-manager");
220229
injector.requireCommand(
221230
"package-manager|*get",
222231
"./commands/package-manager-get"

lib/bun-package-manager.ts

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import * as path from "path";
2+
import { BasePackageManager } from "./base-package-manager";
3+
import { exported, cache } from "./common/decorators";
4+
import { CACACHE_DIRECTORY_NAME } from "./constants";
5+
import * as _ from "lodash";
6+
import {
7+
INodePackageManagerInstallOptions,
8+
INpmInstallResultInfo,
9+
INpmsResult,
10+
} from "./declarations";
11+
import {
12+
IChildProcess,
13+
IErrors,
14+
IFileSystem,
15+
IHostInfo,
16+
Server,
17+
} from "./common/declarations";
18+
import { injector } from "./common/yok";
19+
20+
export class BunPackageManager extends BasePackageManager {
21+
constructor(
22+
$childProcess: IChildProcess,
23+
private $errors: IErrors,
24+
$fs: IFileSystem,
25+
$hostInfo: IHostInfo,
26+
private $logger: ILogger,
27+
private $httpClient: Server.IHttpClient,
28+
$pacoteService: IPacoteService
29+
) {
30+
super($childProcess, $fs, $hostInfo, $pacoteService, "bun");
31+
}
32+
33+
@exported("bun")
34+
public async install(
35+
packageName: string,
36+
pathToSave: string,
37+
config: INodePackageManagerInstallOptions
38+
): Promise<INpmInstallResultInfo> {
39+
if (config.disableNpmInstall) {
40+
return;
41+
}
42+
if (config.ignoreScripts) {
43+
config["ignore-scripts"] = true;
44+
}
45+
46+
const packageJsonPath = path.join(pathToSave, "package.json");
47+
const jsonContentBefore = this.$fs.readJson(packageJsonPath);
48+
49+
const flags = this.getFlagsString(config, true);
50+
// TODO: Confirm desired behavior. The npm version uses --legacy-peer-deps
51+
// by default, we could use `--no-peer` for Bun if similar is needed; the
52+
// pnpm version uses `--shamefully-hoist`, but Bun has no similar flag.
53+
let params = ["install", "--legacy-peer-deps"];
54+
const isInstallingAllDependencies = packageName === pathToSave;
55+
if (!isInstallingAllDependencies) {
56+
params.push(packageName);
57+
}
58+
59+
params = params.concat(flags);
60+
const cwd = pathToSave;
61+
62+
try {
63+
const result = await this.processPackageManagerInstall(
64+
packageName,
65+
params,
66+
{ cwd, isInstallingAllDependencies }
67+
);
68+
return result;
69+
} catch (err) {
70+
// Revert package.json contents to preserve valid state
71+
this.$fs.writeJson(packageJsonPath, jsonContentBefore);
72+
throw err;
73+
}
74+
}
75+
76+
@exported("bun")
77+
public async uninstall(
78+
packageName: string,
79+
config?: any,
80+
cwd?: string
81+
): Promise<string> {
82+
const flags = this.getFlagsString(config, false);
83+
return this.$childProcess.exec(`bun remove ${packageName} ${flags}`, {
84+
cwd,
85+
});
86+
}
87+
88+
// Bun does not have a `view` command; use npm.
89+
@exported("bun")
90+
public async view(packageName: string, config: Object): Promise<any> {
91+
const wrappedConfig = _.extend({}, config, { json: true }); // always require view response as JSON
92+
93+
const flags = this.getFlagsString(wrappedConfig, false);
94+
let viewResult: any;
95+
try {
96+
viewResult = await this.$childProcess.exec(
97+
`npm view ${packageName} ${flags}`
98+
);
99+
} catch (e) {
100+
this.$errors.fail(e.message);
101+
}
102+
103+
try {
104+
return JSON.parse(viewResult);
105+
} catch (err) {
106+
return null;
107+
}
108+
}
109+
110+
// Bun does not have a `search` command; use npm.
111+
@exported("bun")
112+
public async search(filter: string[], config: any): Promise<string> {
113+
const flags = this.getFlagsString(config, false);
114+
return this.$childProcess.exec(`npm search ${filter.join(" ")} ${flags}`);
115+
}
116+
117+
public async searchNpms(keyword: string): Promise<INpmsResult> {
118+
// Bugs with npms.io:
119+
// 1. API returns no results when a valid package name contains @ or /
120+
// even if using encodeURIComponent().
121+
// 2. npms.io's API no longer returns updated results; see
122+
// https://github.com/npms-io/npms-api/issues/112. Better to switch to
123+
// https://registry.npmjs.org/<query>
124+
const httpRequestResult = await this.$httpClient.httpRequest(
125+
`https://api.npms.io/v2/search?q=keywords:${keyword}`
126+
);
127+
const result: INpmsResult = JSON.parse(httpRequestResult.body);
128+
return result;
129+
}
130+
131+
// Bun does not have a command analogous to `npm config get registry`; Bun
132+
// uses `bunfig.toml` to define custom registries.
133+
// - TODO: read `bunfig.toml`, if it exists, and return the registry URL.
134+
public async getRegistryPackageData(packageName: string): Promise<any> {
135+
const registry = await this.$childProcess.exec(`npm config get registry`);
136+
const url = registry.trim() + packageName;
137+
this.$logger.trace(
138+
`Trying to get data from npm registry for package ${packageName}, url is: ${url}`
139+
);
140+
const responseData = (await this.$httpClient.httpRequest(url)).body;
141+
this.$logger.trace(
142+
`Successfully received data from npm registry for package ${packageName}. Response data is: ${responseData}`
143+
);
144+
const jsonData = JSON.parse(responseData);
145+
this.$logger.trace(
146+
`Successfully parsed data from npm registry for package ${packageName}.`
147+
);
148+
return jsonData;
149+
}
150+
151+
@cache()
152+
public async getCachePath(): Promise<string> {
153+
const cachePath = await this.$childProcess.exec(`bun pm cache`);
154+
return path.join(cachePath.trim(), CACACHE_DIRECTORY_NAME);
155+
}
156+
}
157+
158+
injector.register("bun", BunPackageManager);

lib/commands/build.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
112112
$platformValidationService: IPlatformValidationService,
113113
$logger: ILogger,
114114
$buildDataService: IBuildDataService,
115-
private $migrateController: IMigrateController
115+
protected $migrateController: IMigrateController
116116
) {
117117
super(
118118
$options,
@@ -225,3 +225,41 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
225225
}
226226

227227
injector.registerCommand("build|android", BuildAndroidCommand);
228+
229+
export class BuildVisionOsCommand extends BuildIosCommand implements ICommand {
230+
constructor(
231+
protected $options: IOptions,
232+
$errors: IErrors,
233+
$projectData: IProjectData,
234+
$platformsDataService: IPlatformsDataService,
235+
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
236+
$buildController: IBuildController,
237+
$platformValidationService: IPlatformValidationService,
238+
$logger: ILogger,
239+
$buildDataService: IBuildDataService,
240+
protected $migrateController: IMigrateController
241+
) {
242+
super(
243+
$options,
244+
$errors,
245+
$projectData,
246+
$platformsDataService,
247+
$devicePlatformsConstants,
248+
$buildController,
249+
$platformValidationService,
250+
$logger,
251+
$buildDataService,
252+
$migrateController
253+
);
254+
}
255+
256+
public async canExecute(args: string[]): Promise<boolean> {
257+
this.$errors.fail(
258+
'Building for "visionOS" platform is not supported via the CLI. Please open the project in Xcode and build it from there.'
259+
);
260+
return false;
261+
}
262+
}
263+
264+
injector.registerCommand("build|vision", BuildVisionOsCommand);
265+
injector.registerCommand("build|visionos", BuildVisionOsCommand);

0 commit comments

Comments
 (0)