Skip to content

Commit dce514f

Browse files
committed
docs(gradle-api): don't recommend a peer dependency on the CLI
npm 7+ fails the install outright for apps with an older local CLI; plugins announce the requirement in their docs and fail clearly at build time instead.
1 parent 86f148f commit dce514f

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

‎gradle-api/README.md‎

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,7 @@ Pin the **lowest** version that has what you need, never a range or `+`. Every p
6464
the library to the same classpath and Gradle keeps the highest version, which is always backwards
6565
compatible.
6666

67-
**2. Declare the CLI requirement** in your `package.json`, so that apps find out when they install
68-
your plugin rather than when they build:
69-
70-
```json
71-
"peerDependencies": {
72-
"nativescript": ">=9.2.0-0"
73-
},
74-
"peerDependenciesMeta": {
75-
"nativescript": { "optional": true }
76-
}
77-
```
78-
79-
With this, npm 7+ refuses to install your plugin (`ERESOLVE`) into an app whose own `nativescript`
80-
dev dependency is older, until the app updates it or installs with `--legacy-peer-deps`.
81-
`optional` keeps npm from installing the CLI into apps that don't list it, which npm 7+ does for
82-
required peers. The `-0` lets 9.2.0's alphas and release candidates satisfy the range; prereleases
83-
of later versions, such as `9.3.0-rc.1`, still don't, as with any npm range.
84-
85-
**3. If you use `nativescript` in the app build**, apply the library at the top of
67+
**2. If you use `nativescript` in the app build**, apply the library at the top of
8668
`platforms/android/include.gradle`. The whole file runs in the app build, including its
8769
`repositories {}` and `dependencies {}` blocks; only code inside the `tempBuild` check of
8870
[the next section](#your-plugins-own-aar-build) is skipped there.
@@ -93,7 +75,10 @@ apply plugin: "org.nativescript.api"
9375

9476
Applying it again from several plugins is fine.
9577

96-
**4. Use `nativescript`** (see [API](#api) and [Recipes](#recipes)).
78+
**3. Use `nativescript`** (see [API](#api) and [Recipes](#recipes)).
79+
80+
Mention the CLI 9.2+ requirement in your plugin's README and changelog, and release it as a major
81+
version: apps on older CLIs find out at build time, from the check in the next section.
9782

9883
Never refer to the library's classes from `include.gradle` (`import org.nativescript.gradle...`,
9984
`NativeScript.of(project)`): Gradle compiles applied scripts with a class loader that can't see
@@ -300,8 +285,8 @@ future major version of the CLI.
300285

301286
## Rules for plugin authors
302287

303-
- Require NativeScript CLI 9.2+: declare it as an optional peer dependency, and start each copied
304-
block that uses `nativescript` with the [check](#your-plugins-own-aar-build).
288+
- Require NativeScript CLI 9.2+: say so in your README and changelog, and start each copied block
289+
that uses `nativescript` with the [check](#your-plugins-own-aar-build).
305290
- Pin the lowest library version you need; no ranges.
306291
- Everything in the version you pin is always there: an app may end up with a newer library, never
307292
an older one. To use something newer only when it's available, check `apiLevel` (or `has(...)`)

0 commit comments

Comments
 (0)