| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2040a5e commit b88f7c2
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,3 +87,5 @@ lib/common/test-reports.xml | |||
| 87 | 87 | !lib/common/test-scripts/** | |
| 88 | 88 | !lib/common/scripts/** | |
| 89 | 89 | config/test-deps-versions-generated.json | |
| 90 | + !scripts/get-next-version.js | ||
| 91 | + !scripts/get-npm-tag.js | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,6 @@ | |||
| 1 | 1 | ||
| 2 | 2 | <h1 id="nativescript-command-line-interface" align="center"> | |
| 3 | - <br> | ||
| 4 | - <a href="https://www.npmjs.com/package/nativescript"><img src="https://art.nativescript.org/logo/export/NativeScript_Logo_Wide_White_Blue_Rounded_Blue.svg" alt="Nativescript Logo" width="200"></a> | ||
| 5 | - <br> | ||
| 6 | - <br> | ||
| 7 | - NativeScript Command-Line Interface | ||
| 8 | - <br> | ||
| 3 | + <a href="https://www.npmjs.com/package/nativescript"><img src="https://raw.githubusercontent.com/NativeScript/artwork/main/logo/export/NativeScript_Logo_Dark_Transparent.png" alt="Nativescript Logo" width="200"></a> | ||
| 9 | 4 | </h1> | |
| 10 | 5 | ||
| 11 | 6 | <h4 align="center">The NativeScript CLI lets you create, build, and deploy <a href="https://docs.nativescript.org/" target="_blank">NativeScript</a> apps.</h4> | |
@@ -14,7 +9,11 @@ | |||
| 14 | 9 | ||
| 15 | 10 | --- | |
| 16 | 11 | ||
| 17 | - [](https://github.com/NativeScript/nativescript-cli/actions/workflows/npm_release_cli.yml) | ||
| 12 | + <p align="center"> | ||
| 13 | + <a href="https://www.npmjs.com/package/nativescript"><img src="https://img.shields.io/npm/v/nativescript.svg" alt="npm version"></a> | ||
| 14 | + <a href="https://github.com/NativeScript/NativeScript/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license"></a> | ||
| 15 | + <a href="https://www.npmjs.com/package/nativescript"><img src="https://img.shields.io/npm/dm/nativescript.svg" alt="downloads"></a> | ||
| 16 | + </p> | ||
| 18 | 17 | ||
| 19 | 18 | Get it using: `npm install -g nativescript` | |
| 20 | 19 | ||
@@ -67,10 +66,7 @@ Some popular use cases: | |||
| 67 | 66 | To learn more about NativeScript, you can check the following resources: | |
| 68 | 67 | ||
| 69 | 68 | * [The NativeScript web page][2] | |
| 70 | - * [NativeScript - a Technical Overview][7] | ||
| 71 | - * [Announcing NativeScript - cross-platform framework for building native mobile applications][8] | ||
| 72 | - * The NativeScript [Documentation repo][3] and [Documentation portal][4] | ||
| 73 | - * [The NativeScript FAQ][6] | ||
| 69 | + * The NativeScript [Documentation][4] and contributing to [docs via the repo](https://github.com/NativeScript/docs) | ||
| 74 | 70 | ||
| 75 | 71 | [Back to Top][1] | |
| 76 | 72 | ||
@@ -104,9 +100,9 @@ System Requirements | |||
| 104 | 100 | ||
| 105 | 101 | You can install and run the NativeScript CLI on Windows, macOS or Linux. | |
| 106 | 102 | ||
| 107 | - * [Windows](https://docs.nativescript.org/start/ns-setup-win) | ||
| 108 | - * [macOS](https://docs.nativescript.org/start/ns-setup-os-x) | ||
| 109 | - * [Linux](https://docs.nativescript.org/start/ns-setup-linux) | ||
| 103 | + * [Windows](https://docs.nativescript.org/setup/windows) | ||
| 104 | + * [macOS](https://docs.nativescript.org/setup/macos) | ||
| 105 | + * [Linux](https://docs.nativescript.org/setup/linux) | ||
| 110 | 106 | ||
| 111 | 107 | Installation | |
| 112 | 108 | === | |
@@ -224,14 +220,14 @@ The CLI places the project in a new directory in the current directory. The newl | |||
| 224 | 220 | ||
| 225 | 221 | ``` | |
| 226 | 222 | MyApp/ | |
| 227 | - ├── app | ||
| 228 | - │ ├── App_Resources | ||
| 223 | + ├── App_Resources | ||
| 224 | + ├── src | ||
| 229 | 225 | │ └── ... | |
| 230 | 226 | └── platforms | |
| 231 | 227 | └── ... | |
| 232 | 228 | ``` | |
| 233 | 229 | ||
| 234 | - * The `app` directory is the **development space for your application**. You should modify all common and platform-specific code within this directory. When you run `prepare <Platform>`, the NativeScript CLI prepares relevant content to the platform-specific folders for each target platform. | ||
| 230 | + * The `src` directory (or sometimes `app` folder) is the **development space for your application**. You should modify all common and platform-specific code within this directory. When you run `prepare <Platform>`, the NativeScript CLI prepares relevant content to the platform-specific folders for each target platform. | ||
| 235 | 231 | * The `platforms` directory is created empty. When you add a target platform to your project, the NativeScript CLI creates a new subdirectory with the platform name. The subdirectory contains the ready-to-build resources of your app. When you run `prepare <Platform>`, the NativeScript CLI prepares relevant content from the `app` directory to the platform-specific subdirectory for each target platform. | |
| 236 | 232 | ||
| 237 | 233 | [Back to Top][1] | |
@@ -263,13 +259,13 @@ You can develop shared functionality or design in common files. To indicate that | |||
| 263 | 259 | ||
| 264 | 260 | ### Modifying Configuration Files | |
| 265 | 261 | ||
| 266 | - The NativeScript CLI respects any platform configuration files placed inside `app/App_Resources`. | ||
| 262 | + The NativeScript CLI respects any platform configuration files placed inside `App_Resources`. | ||
| 267 | 263 | ||
| 268 | 264 | ### Modifying Entitlements File (iOS only) | |
| 269 | 265 | ||
| 270 | - To specify which capabilities are required by your App - Maps, Push Notifications, Wallet etc. you can add or edit the `app.entitlements` file placed inside `app/App_Resources/iOS`. When building the project, the default `app/App_Resources/iOS/app.entitlements` file gets merged with all Plugins entitlement files and a new `yourAppName.entitlements` is created in the platforms directory. The path would be `app/platforms/ios/<application name>/<application name>.entitlements` and will be linked in the `build.xcconfig` file. | ||
| 266 | + To specify which capabilities are required by your App - Maps, Push Notifications, Wallet etc. you can add or edit the `app.entitlements` file placed inside `App_Resources/iOS`. When building the project, the default `App_Resources/iOS/app.entitlements` file gets merged with all Plugins entitlement files and a new `yourAppName.entitlements` is created in the platforms directory. The path would be `platforms/ios/<application name>/<application name>.entitlements` and will be linked in the `build.xcconfig` file. | ||
| 271 | 267 | ||
| 272 | - You can always override the generated entitlements file, by pointing to your own entitlements file by setting the `CODE_SIGN_ENTITLEMENTS` property in the `app/App_Resources/iOS/build.xcconfig` file. | ||
| 268 | + You can always override the generated entitlements file, by pointing to your own entitlements file by setting the `CODE_SIGN_ENTITLEMENTS` property in the `App_Resources/iOS/build.xcconfig` file. | ||
| 273 | 269 | ||
| 274 | 270 | [Back to Top][1] | |
| 275 | 271 | ||
@@ -314,11 +310,11 @@ ns run ios | |||
| 314 | 310 | Extending the CLI | |
| 315 | 311 | === | |
| 316 | 312 | ||
| 317 | - The NativeScript CLI lets you extend its behavior and customize it to fit your needs by using [hooks](https://en.wikipedia.org/wiki/Hooking). | ||
| 313 | + The NativeScript CLI lets you extend its behavior and customize it to fit your needs by using [hooks](https://docs.nativescript.org/guide/hooks). | ||
| 318 | 314 | ||
| 319 | 315 | When you run one of the extendable commands (for example, `ns build`), the CLI checks for hooks and executes them. Plugins can also use hooks to control the compilation of the application package. | |
| 320 | 316 | ||
| 321 | - For more information, see the [Extending the CLI document](https://github.com/NativeScript/nativescript-cli/blob/master/extending-cli.md) | ||
| 317 | + For more information, see the [Extending the CLI document](https://github.com/NativeScript/nativescript-cli/blob/main/extending-cli.md) | ||
| 322 | 318 | ||
| 323 | 319 | [Back to Top][1] | |
| 324 | 320 | ||
@@ -354,6 +350,7 @@ How to Build | |||
| 354 | 350 | git clone https://github.com/NativeScript/nativescript-cli | |
| 355 | 351 | cd nativescript-cli | |
| 356 | 352 | npm run setup | |
| 353 | + npm run build | ||
| 357 | 354 | ``` | |
| 358 | 355 | ||
| 359 | 356 | To use the locally built CLI instead of `ns` you can call `PATH_TO_CLI_FOLDER/bin/ns`. For example: | |
@@ -379,7 +376,4 @@ This software is licensed under the Apache 2.0 license, quoted <a href="LICENSE" | |||
| 379 | 376 | [2]: https://nativescript.org | |
| 380 | 377 | [3]: https://github.com/nativescript/docs | |
| 381 | 378 | [4]: https://docs.nativescript.org/ | |
| 382 | - [5]: https://docs.nativescript.org/api-reference | ||
| 383 | - [6]: https://www.nativescript.org/faq | ||
| 384 | - [7]: https://docs.nativescript.org/core-concepts/technical-overview | ||
| 385 | - [8]: https://www.telerik.com/blogs/announcing-nativescript---cross-platform-framework-for-building-native-mobile-applications | ||
| 379 | + [5]: https://docs.nativescript.org/api/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,57 @@ | |||
| 1 | + const semver = require("semver"); | ||
| 2 | + const child_process = require("child_process"); | ||
| 3 | + const dayjs = require("dayjs"); | ||
| 4 | + const fs = require("fs"); | ||
| 5 | + | ||
| 6 | + const currentVersion = | ||
| 7 | + process.env.NPM_VERSION || require("../package.json").version; | ||
| 8 | + | ||
| 9 | + if (!currentVersion) { | ||
| 10 | + throw new Error("Invalid current version"); | ||
| 11 | + } | ||
| 12 | + const currentTag = process.env.NPM_TAG || "next"; | ||
| 13 | + const runID = process.env.GITHUB_RUN_ID || 0; | ||
| 14 | + | ||
| 15 | + let prPrerelease = ""; | ||
| 16 | + | ||
| 17 | + if (currentTag === "pr" && process.env.GITHUB_EVENT_PATH) { | ||
| 18 | + try { | ||
| 19 | + const ev = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")); | ||
| 20 | + const prNum = ev.pull_request.number; | ||
| 21 | + // add extra PR number to version-pr.PRNUM-.... | ||
| 22 | + prPrerelease = `${prNum}-`; | ||
| 23 | + } catch (e) { | ||
| 24 | + // don't add pr prerelease | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + const preRelease = `${currentTag}.${prPrerelease}${dayjs().format("YYYY-MM-DD")}-${runID}`; | ||
| 29 | + | ||
| 30 | + let lastTagVersion = ( | ||
| 31 | + process.env.LAST_TAGGED_VERSION || | ||
| 32 | + child_process | ||
| 33 | + .spawnSync("git", ["describe", "--tags", "--abbrev=0", "--match=v*"]) | ||
| 34 | + .stdout.toString() | ||
| 35 | + ) | ||
| 36 | + .trim() | ||
| 37 | + .substring(1); | ||
| 38 | + if (!semver.parse(lastTagVersion)) { | ||
| 39 | + throw new Error("Invalid last tag version"); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + function setPreRelease(version) { | ||
| 43 | + const parsed = semver.parse(version); | ||
| 44 | + return semver.parse( | ||
| 45 | + `${parsed.major}.${parsed.minor}.${parsed.patch}-${preRelease}` | ||
| 46 | + ); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + let nextVersion = setPreRelease(currentVersion); | ||
| 50 | + | ||
| 51 | + // bump patch if the current version is lower or equal to the last tagged version | ||
| 52 | + if (semver.lte(nextVersion, lastTagVersion)) { | ||
| 53 | + nextVersion = semver.inc(lastTagVersion, "patch"); | ||
| 54 | + nextVersion = setPreRelease(nextVersion); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + console.log(nextVersion.version); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + const semver = require("semver"); | ||
| 2 | + | ||
| 3 | + const currentVersion = | ||
| 4 | + process.env.NPM_VERSION || require("../package.json").version; | ||
| 5 | + | ||
| 6 | + function validateNpmTag(version) { | ||
| 7 | + const parsed = semver.parse(version); | ||
| 8 | + return ( | ||
| 9 | + parsed.prerelease.length === 0 || /^[a-zA-Z]+$/.test(parsed.prerelease[0]) | ||
| 10 | + ); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + function getNpmTag(version) { | ||
| 14 | + if (!validateNpmTag(version)) throw new Error("Invalid npm tag"); | ||
| 15 | + const parsed = semver.parse(version); | ||
| 16 | + return parsed.prerelease[0] || "latest"; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + console.log(getNpmTag(currentVersion)); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments