itqan-cli 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/CHANGELOG.md +22 -0
  2. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/PKG-INFO +103 -5
  3. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/README.md +102 -4
  4. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/pyproject.toml +1 -1
  5. itqan_cli-0.3.0/src/itqan_cli/add.py +96 -0
  6. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/browse.py +3 -1
  7. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/client.py +17 -0
  8. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/init_template.py +39 -10
  9. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/main.py +283 -21
  10. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/manifest.py +5 -1
  11. itqan_cli-0.3.0/src/itqan_cli/updates.py +87 -0
  12. itqan_cli-0.3.0/tests/test_add.py +259 -0
  13. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_cli_integration.py +80 -0
  14. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_client.py +76 -0
  15. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_init.py +40 -4
  16. itqan_cli-0.3.0/tests/test_updates.py +226 -0
  17. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/.gitignore +0 -0
  18. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/LICENSE +0 -0
  19. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/RELEASING.md +0 -0
  20. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/.gitignore +0 -0
  21. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/README.md +0 -0
  22. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/analysis_options.yaml +0 -0
  23. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/bin/itqan.dart +0 -0
  24. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/lib/itqan_cli.dart +0 -0
  25. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/lib/src/launcher.dart +0 -0
  26. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/lib/src/version.dart +0 -0
  27. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/pubspec.yaml +0 -0
  28. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/dart/test/launcher_test.dart +0 -0
  29. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/npm/README.md +0 -0
  30. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/npm/bin/itqan.js +0 -0
  31. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/scripts/dart_package.py +0 -0
  32. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/scripts/homebrew_formula.py +0 -0
  33. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/scripts/npm_packages.py +0 -0
  34. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/__init__.py +0 -0
  35. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/__main__.py +0 -0
  36. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/credentials.py +0 -0
  37. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/downloader.py +0 -0
  38. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/exceptions.py +0 -0
  39. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/flutter.py +0 -0
  40. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/lockfile.py +0 -0
  41. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/src/itqan_cli/semver.py +0 -0
  42. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/__init__.py +0 -0
  43. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/conftest.py +0 -0
  44. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_access.py +0 -0
  45. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_assets_dir.py +0 -0
  46. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_browse.py +0 -0
  47. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_dart_package.py +0 -0
  48. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_downloader.py +0 -0
  49. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_entry_points.py +0 -0
  50. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_flutter.py +0 -0
  51. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_homebrew_formula.py +0 -0
  52. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_languages.py +0 -0
  53. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_lockfile.py +0 -0
  54. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_login.py +0 -0
  55. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_manifest.py +0 -0
  56. {itqan_cli-0.2.0 → itqan_cli-0.3.0}/tests/test_npm_packages.py +0 -0
@@ -1,3 +1,25 @@
1
+ ## v0.3.0 (2026-10-18)
2
+
3
+ ### Feat
4
+
5
+ - `itqan add ASSET[@RANGE]...` adds assets to `itqan-assets.yaml` (creating it if missing) and
6
+ installs them. Without a range it accepts the newest version (`^`); `--language` picks another
7
+ language and `--no-install` only edits the manifest. Unknown assets, assets you don't have access
8
+ to and unavailable languages fail before anything is written.
9
+ - `itqan install` says when your locked assets have newer versions, split into those your range
10
+ allows (`itqan install --force`) and those it doesn't. `ITQAN_NO_UPDATE_NOTICE=1` turns it off.
11
+ The new `itqan outdated` command lists them, or prints them as JSON with `--json`.
12
+ - warn when a locked version was withdrawn by its publisher: `itqan install` still installs it and
13
+ shows the publisher's reason and how to move off it. A version removed by an Itqan admin fails
14
+ with an explanation and suggests `itqan install --force`.
15
+ - **init**: `itqan init` writes the example assets commented out instead of installing them right
16
+ away, and suggests `itqan browse` to find assets.
17
+
18
+ ### Fix
19
+
20
+ - **cli**: `itqan --help` shows each command's full description instead of cutting it off with
21
+ `...`.
22
+
1
23
  ## v0.2.0 (2026-10-12)
2
24
 
3
25
  ### Feat
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: itqan-cli
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Itqan Quranic Asset Manager: install and pin Itqan Quranic assets in your project.
5
5
  Project-URL: Homepage, https://github.com/Itqan-community/itqan-cli
6
6
  Project-URL: Repository, https://github.com/Itqan-community/itqan-cli
@@ -31,6 +31,18 @@ Description-Content-Type: text/markdown
31
31
 
32
32
  # itqan-cli
33
33
 
34
+ [![CI](https://github.com/Itqan-community/itqan-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/Itqan-community/itqan-cli/actions/workflows/ci.yml)
35
+ [![Release](https://img.shields.io/github/v/release/Itqan-community/itqan-cli)](https://github.com/Itqan-community/itqan-cli/releases/latest)
36
+ [![PyPI](https://img.shields.io/pypi/v/itqan-cli)](https://pypi.org/project/itqan-cli/)
37
+ [![Python](https://img.shields.io/pypi/pyversions/itqan-cli)](https://pypi.org/project/itqan-cli/)
38
+ [![npm](https://img.shields.io/npm/v/itqan-cli)](https://www.npmjs.com/package/itqan-cli)
39
+ [![pub.dev](https://img.shields.io/pub/v/itqan_cli)](https://pub.dev/packages/itqan_cli)
40
+ [![Homebrew](https://img.shields.io/badge/homebrew-itqan--community%2Ftap-orange)](https://github.com/Itqan-community/homebrew-tap)
41
+ [![GitHub Action](https://img.shields.io/github/v/release/Itqan-community/setup-itqan?label=setup-itqan)](https://github.com/Itqan-community/setup-itqan)
42
+ [![npm downloads](https://img.shields.io/npm/dm/itqan-cli?label=npm%20downloads)](https://www.npmjs.com/package/itqan-cli)
43
+ [![PyPI downloads](https://img.shields.io/pypi/dm/itqan-cli?label=PyPI%20downloads)](https://pypi.org/project/itqan-cli/)
44
+ [![License: MIT](https://img.shields.io/github/license/Itqan-community/itqan-cli)](LICENSE)
45
+
34
46
  **Itqan Quranic Asset Manager**
35
47
 
36
48
  `itqan` adds [Itqan](https://cms.itqan.dev) Quranic data, such as mushafs, tafsirs,
@@ -146,8 +158,8 @@ a folder on your `PATH`.
146
158
  Run these in your project's folder:
147
159
 
148
160
  ```bash
149
- itqan init # 1. create itqan-assets.yaml, with a few real assets as examples
150
- itqan browse # 2. optional: search the catalog and add the assets you want
161
+ itqan init # 1. create itqan-assets.yaml, with commented-out example assets
162
+ itqan browse # 2. search the catalog and add the assets you want (or uncomment the examples)
151
163
  itqan install # 3. download them and write itqan-assets.lock
152
164
  ```
153
165
 
@@ -169,6 +181,18 @@ Commit `itqan-assets.yaml` and `itqan-assets.lock`. You can commit the `assets/`
169
181
  add it to `.gitignore` and run `itqan install` after cloning (and in CI), which downloads exactly
170
182
  the versions in the lockfile.
171
183
 
184
+ Already know the asset you want? `itqan add` puts it in the manifest and installs it in one step,
185
+ like `uv add` or `npm install <package>`:
186
+
187
+ ```bash
188
+ itqan add tafsir-jalalayn # the source language, accepting ^ the newest version
189
+ itqan add tafsir-jalalayn --language en # another language of the same asset
190
+ itqan add tafsir-jalalayn@~2.1 # your own version range
191
+ ```
192
+
193
+ The asset's name is the one `itqan browse` and each asset's page in the
194
+ [asset library](https://cms.itqan.dev) show. `--no-install` only edits the manifest.
195
+
172
196
  In `itqan browse`, type to filter the list, press Enter to add the highlighted asset, or press
173
197
  Space on several and then Enter. `itqan browse tafsir` starts with a search, and
174
198
  `itqan browse --category translation` shows one kind of asset.
@@ -239,7 +263,8 @@ the way your platform handles any other data file.
239
263
  ## The manifest
240
264
 
241
265
  `itqan-assets.yaml` lists the assets you want. `itqan init` writes one for you, with comments
242
- explaining each part. A fuller example:
266
+ explaining each part and a few real assets from the catalog as commented-out examples, one of
267
+ them with a `language:`. A fuller example:
243
268
 
244
269
  ```yaml
245
270
  schema_version: 1
@@ -281,11 +306,19 @@ The full format, including every rule and error, is specified in
281
306
 
282
307
  ## Updating assets
283
308
 
309
+ - **Add an asset:** `itqan add <asset>`, or `itqan browse` to search for one.
284
310
  - **Add or remove an asset, or change a `version:` range:** edit `itqan-assets.yaml` and run
285
311
  `itqan install`. It sees that the lockfile no longer matches the manifest, picks the newest
286
312
  versions the manifest allows, and rewrites the lockfile.
287
313
  - **Get newer versions within the ranges you already have:** `itqan install --force`.
288
314
  - **Install what the lockfile says, for example after cloning or in CI:** `itqan install`.
315
+ - **See which assets have newer versions:** `itqan outdated`. It lists each locked asset that has a
316
+ newer version, with the newest one your manifest's range allows ("In range", what
317
+ `itqan install --force` gets) and the newest one overall ("Latest", which needs a range change
318
+ when it's outside the range). `--json` prints the same list as JSON. It downloads nothing.
319
+
320
+ `itqan install` also ends with a line saying how many assets have newer versions, if any. Set
321
+ `ITQAN_NO_UPDATE_NOTICE=1` to turn it off.
289
322
 
290
323
  `itqan install` writes the lockfile only after every download succeeded, so a failed install
291
324
  never leaves a lockfile that doesn't match your files.
@@ -333,6 +366,57 @@ steps:
333
366
  Pass `install: true` to have the action run `itqan install` itself. The
334
367
  [action's README](https://github.com/Itqan-community/setup-itqan#readme) lists all its options.
335
368
 
369
+ ### Get a pull request when assets have new versions
370
+
371
+ Dependabot and similar tools don't read `itqan-assets.yaml`. To get the same kind of pull request,
372
+ add a workflow that runs `itqan install --force` on a schedule. It picks the newest versions your
373
+ manifest allows, and when that changes the lockfile, it opens a pull request (or updates the open
374
+ one):
375
+
376
+ ```yaml
377
+ # .github/workflows/update-itqan-assets.yml
378
+ name: Update Itqan assets
379
+
380
+ on:
381
+ schedule:
382
+ - cron: "0 6 * * 1" # every Monday at 06:00 UTC
383
+ workflow_dispatch: # and whenever you run it by hand
384
+
385
+ permissions:
386
+ contents: write
387
+ pull-requests: write
388
+
389
+ jobs:
390
+ update:
391
+ runs-on: ubuntu-latest
392
+ steps:
393
+ - uses: actions/checkout@v7
394
+ - uses: itqan-community/setup-itqan@v1
395
+ - run: itqan install --force
396
+ env:
397
+ ITQAN_API_KEY: ${{ secrets.ITQAN_API_KEY }} # only needed for assets that need access approval
398
+ - uses: peter-evans/create-pull-request@v8
399
+ with:
400
+ branch: itqan/update-assets
401
+ commit-message: "chore: update Itqan assets"
402
+ title: "Update Itqan assets"
403
+ body: "`itqan install --force` found newer versions allowed by `itqan-assets.yaml`."
404
+ ```
405
+
406
+ The pull request includes `itqan-assets.lock`, and the asset files too if you commit them. Add
407
+ `--flutter` to the install if you use [Flutter](#flutter), so `pubspec.yaml` stays in step.
408
+
409
+ Two GitHub settings to know about:
410
+
411
+ - Turn on **Settings > Actions > General > Allow GitHub Actions to create and approve pull
412
+ requests**, or the last step fails.
413
+ - Pull requests opened with the default `GITHUB_TOKEN` don't start your other workflows, so CI
414
+ won't run on them by itself. To have it run, give the step a `token:` from a GitHub App or a
415
+ personal access token, or close and reopen the pull request.
416
+
417
+ It only moves within the ranges in your manifest. To go to a new major version, change the
418
+ `version:` range yourself.
419
+
336
420
  ### Other CI systems
337
421
 
338
422
  Install `itqan` with whichever method from [Install](#install) suits your build image. For
@@ -343,10 +427,12 @@ example, `npm ci` for a project with `itqan-cli` in its `devDependencies`, or
343
427
 
344
428
  | Command | What it does |
345
429
  |---|---|
346
- | `itqan init` | Create `itqan-assets.yaml` with a few assets from the catalog, or commented examples when offline. `--assets-dir` sets where assets go; `--force` overwrites an existing manifest. |
430
+ | `itqan init` | Create `itqan-assets.yaml` with a few assets from the catalog as commented-out examples (placeholder examples when offline). `--assets-dir` sets where assets go; `--force` overwrites an existing manifest. |
347
431
  | `itqan browse [SEARCH]` | Search the catalog, pick assets, add them to `itqan-assets.yaml` (created if missing), and optionally install them. `--category` limits it to one kind of asset; `--no-interactive` prints a table (the default when not in a terminal); `--json` prints JSON. |
432
+ | `itqan add ASSET[@RANGE]...` | Add assets to `itqan-assets.yaml` (created if missing) and install them. Without `@RANGE` an entry accepts `^` the newest version; an asset already in the manifest gets the new range. `--language` picks a language other than the source; `--no-install` only edits the manifest. |
348
433
  | `itqan install` | Download the assets and write `itqan-assets.lock`. Uses the lockfile's exact versions while it matches the manifest. `--force` picks the newest allowed versions and downloads again. `--flutter` keeps `pubspec.yaml` up to date (see [Flutter](#flutter)). `--assets-dir` overrides the manifest's folder for one run. |
349
434
  | `itqan sync` | Same as `itqan install`. |
435
+ | `itqan outdated` | List the locked assets that have newer versions: the newest your range allows and the newest overall. `--json` prints JSON. |
350
436
  | `itqan login` | Save your API key for the registry, after checking it. `--api-key` passes the key without the prompt. |
351
437
  | `itqan logout` | Remove the saved key. |
352
438
  | `itqan --version` | Print the CLI version. |
@@ -360,6 +446,7 @@ Add `--help` to any command for all its options. `install` and `browse` read the
360
446
  |---|---|---|
361
447
  | `--api-key` | `ITQAN_API_KEY` | The key saved by `itqan login`, if any. |
362
448
  | `--registry-url` | `ITQAN_REGISTRY_URL` | `https://api.cms.itqan.dev`, the public registry. |
449
+ | | `ITQAN_NO_UPDATE_NOTICE` | Set to `1` to stop `itqan install` saying that newer versions exist. |
363
450
  | | `ITQAN_CONFIG_DIR` | Where `itqan login` saves keys: `~/.config/itqan` (`%APPDATA%\itqan` on Windows). |
364
451
  | | `ITQAN_CACHE_DIR` | Dart package only. Where the downloaded program is kept: `~/Library/Caches/itqan` (macOS), `~/.cache/itqan` (Linux), `%LOCALAPPDATA%\itqan` (Windows). |
365
452
  | | `ITQAN_CLI_DOWNLOAD_URL` | Dart package only. A folder (`https://` or `file://`) with a release's programs and `SHA256SUMS`, such as a mirror, used instead of the GitHub Release. |
@@ -389,6 +476,17 @@ listed under [Install](#install). Install with Python instead: `pipx install itq
389
476
  [Assets that need access approval](#assets-that-need-access-approval). In CI, check that
390
477
  `ITQAN_API_KEY` is set.
391
478
 
479
+ **"Warning: ... was withdrawn by its publisher".** Your lockfile pins a version the publisher
480
+ has since withdrawn by going back to an earlier version, usually because of a mistake in it; the
481
+ warning shows the reason they gave. It still installs, so your build
482
+ keeps working, but new installs no longer get it. Run `itqan install --force` to move to the
483
+ newest supported version in your range, or change the version in `itqan-assets.yaml` if you
484
+ pinned it there.
485
+
486
+ **"Version removed from the registry" (410).** Itqan removed that version, for example because
487
+ its licence was revoked, and it can't be downloaded any more. Run `itqan install --force` to
488
+ resolve another version, or change the version in `itqan-assets.yaml`.
489
+
392
490
  **Flutter: "Unable to load asset".** Make sure the manifest sits next to `pubspec.yaml`, run
393
491
  `itqan install --flutter`, and then restart the app fully. Hot reload doesn't pick up new assets.
394
492
 
@@ -1,5 +1,17 @@
1
1
  # itqan-cli
2
2
 
3
+ [![CI](https://github.com/Itqan-community/itqan-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/Itqan-community/itqan-cli/actions/workflows/ci.yml)
4
+ [![Release](https://img.shields.io/github/v/release/Itqan-community/itqan-cli)](https://github.com/Itqan-community/itqan-cli/releases/latest)
5
+ [![PyPI](https://img.shields.io/pypi/v/itqan-cli)](https://pypi.org/project/itqan-cli/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/itqan-cli)](https://pypi.org/project/itqan-cli/)
7
+ [![npm](https://img.shields.io/npm/v/itqan-cli)](https://www.npmjs.com/package/itqan-cli)
8
+ [![pub.dev](https://img.shields.io/pub/v/itqan_cli)](https://pub.dev/packages/itqan_cli)
9
+ [![Homebrew](https://img.shields.io/badge/homebrew-itqan--community%2Ftap-orange)](https://github.com/Itqan-community/homebrew-tap)
10
+ [![GitHub Action](https://img.shields.io/github/v/release/Itqan-community/setup-itqan?label=setup-itqan)](https://github.com/Itqan-community/setup-itqan)
11
+ [![npm downloads](https://img.shields.io/npm/dm/itqan-cli?label=npm%20downloads)](https://www.npmjs.com/package/itqan-cli)
12
+ [![PyPI downloads](https://img.shields.io/pypi/dm/itqan-cli?label=PyPI%20downloads)](https://pypi.org/project/itqan-cli/)
13
+ [![License: MIT](https://img.shields.io/github/license/Itqan-community/itqan-cli)](LICENSE)
14
+
3
15
  **Itqan Quranic Asset Manager**
4
16
 
5
17
  `itqan` adds [Itqan](https://cms.itqan.dev) Quranic data, such as mushafs, tafsirs,
@@ -115,8 +127,8 @@ a folder on your `PATH`.
115
127
  Run these in your project's folder:
116
128
 
117
129
  ```bash
118
- itqan init # 1. create itqan-assets.yaml, with a few real assets as examples
119
- itqan browse # 2. optional: search the catalog and add the assets you want
130
+ itqan init # 1. create itqan-assets.yaml, with commented-out example assets
131
+ itqan browse # 2. search the catalog and add the assets you want (or uncomment the examples)
120
132
  itqan install # 3. download them and write itqan-assets.lock
121
133
  ```
122
134
 
@@ -138,6 +150,18 @@ Commit `itqan-assets.yaml` and `itqan-assets.lock`. You can commit the `assets/`
138
150
  add it to `.gitignore` and run `itqan install` after cloning (and in CI), which downloads exactly
139
151
  the versions in the lockfile.
140
152
 
153
+ Already know the asset you want? `itqan add` puts it in the manifest and installs it in one step,
154
+ like `uv add` or `npm install <package>`:
155
+
156
+ ```bash
157
+ itqan add tafsir-jalalayn # the source language, accepting ^ the newest version
158
+ itqan add tafsir-jalalayn --language en # another language of the same asset
159
+ itqan add tafsir-jalalayn@~2.1 # your own version range
160
+ ```
161
+
162
+ The asset's name is the one `itqan browse` and each asset's page in the
163
+ [asset library](https://cms.itqan.dev) show. `--no-install` only edits the manifest.
164
+
141
165
  In `itqan browse`, type to filter the list, press Enter to add the highlighted asset, or press
142
166
  Space on several and then Enter. `itqan browse tafsir` starts with a search, and
143
167
  `itqan browse --category translation` shows one kind of asset.
@@ -208,7 +232,8 @@ the way your platform handles any other data file.
208
232
  ## The manifest
209
233
 
210
234
  `itqan-assets.yaml` lists the assets you want. `itqan init` writes one for you, with comments
211
- explaining each part. A fuller example:
235
+ explaining each part and a few real assets from the catalog as commented-out examples, one of
236
+ them with a `language:`. A fuller example:
212
237
 
213
238
  ```yaml
214
239
  schema_version: 1
@@ -250,11 +275,19 @@ The full format, including every rule and error, is specified in
250
275
 
251
276
  ## Updating assets
252
277
 
278
+ - **Add an asset:** `itqan add <asset>`, or `itqan browse` to search for one.
253
279
  - **Add or remove an asset, or change a `version:` range:** edit `itqan-assets.yaml` and run
254
280
  `itqan install`. It sees that the lockfile no longer matches the manifest, picks the newest
255
281
  versions the manifest allows, and rewrites the lockfile.
256
282
  - **Get newer versions within the ranges you already have:** `itqan install --force`.
257
283
  - **Install what the lockfile says, for example after cloning or in CI:** `itqan install`.
284
+ - **See which assets have newer versions:** `itqan outdated`. It lists each locked asset that has a
285
+ newer version, with the newest one your manifest's range allows ("In range", what
286
+ `itqan install --force` gets) and the newest one overall ("Latest", which needs a range change
287
+ when it's outside the range). `--json` prints the same list as JSON. It downloads nothing.
288
+
289
+ `itqan install` also ends with a line saying how many assets have newer versions, if any. Set
290
+ `ITQAN_NO_UPDATE_NOTICE=1` to turn it off.
258
291
 
259
292
  `itqan install` writes the lockfile only after every download succeeded, so a failed install
260
293
  never leaves a lockfile that doesn't match your files.
@@ -302,6 +335,57 @@ steps:
302
335
  Pass `install: true` to have the action run `itqan install` itself. The
303
336
  [action's README](https://github.com/Itqan-community/setup-itqan#readme) lists all its options.
304
337
 
338
+ ### Get a pull request when assets have new versions
339
+
340
+ Dependabot and similar tools don't read `itqan-assets.yaml`. To get the same kind of pull request,
341
+ add a workflow that runs `itqan install --force` on a schedule. It picks the newest versions your
342
+ manifest allows, and when that changes the lockfile, it opens a pull request (or updates the open
343
+ one):
344
+
345
+ ```yaml
346
+ # .github/workflows/update-itqan-assets.yml
347
+ name: Update Itqan assets
348
+
349
+ on:
350
+ schedule:
351
+ - cron: "0 6 * * 1" # every Monday at 06:00 UTC
352
+ workflow_dispatch: # and whenever you run it by hand
353
+
354
+ permissions:
355
+ contents: write
356
+ pull-requests: write
357
+
358
+ jobs:
359
+ update:
360
+ runs-on: ubuntu-latest
361
+ steps:
362
+ - uses: actions/checkout@v7
363
+ - uses: itqan-community/setup-itqan@v1
364
+ - run: itqan install --force
365
+ env:
366
+ ITQAN_API_KEY: ${{ secrets.ITQAN_API_KEY }} # only needed for assets that need access approval
367
+ - uses: peter-evans/create-pull-request@v8
368
+ with:
369
+ branch: itqan/update-assets
370
+ commit-message: "chore: update Itqan assets"
371
+ title: "Update Itqan assets"
372
+ body: "`itqan install --force` found newer versions allowed by `itqan-assets.yaml`."
373
+ ```
374
+
375
+ The pull request includes `itqan-assets.lock`, and the asset files too if you commit them. Add
376
+ `--flutter` to the install if you use [Flutter](#flutter), so `pubspec.yaml` stays in step.
377
+
378
+ Two GitHub settings to know about:
379
+
380
+ - Turn on **Settings > Actions > General > Allow GitHub Actions to create and approve pull
381
+ requests**, or the last step fails.
382
+ - Pull requests opened with the default `GITHUB_TOKEN` don't start your other workflows, so CI
383
+ won't run on them by itself. To have it run, give the step a `token:` from a GitHub App or a
384
+ personal access token, or close and reopen the pull request.
385
+
386
+ It only moves within the ranges in your manifest. To go to a new major version, change the
387
+ `version:` range yourself.
388
+
305
389
  ### Other CI systems
306
390
 
307
391
  Install `itqan` with whichever method from [Install](#install) suits your build image. For
@@ -312,10 +396,12 @@ example, `npm ci` for a project with `itqan-cli` in its `devDependencies`, or
312
396
 
313
397
  | Command | What it does |
314
398
  |---|---|
315
- | `itqan init` | Create `itqan-assets.yaml` with a few assets from the catalog, or commented examples when offline. `--assets-dir` sets where assets go; `--force` overwrites an existing manifest. |
399
+ | `itqan init` | Create `itqan-assets.yaml` with a few assets from the catalog as commented-out examples (placeholder examples when offline). `--assets-dir` sets where assets go; `--force` overwrites an existing manifest. |
316
400
  | `itqan browse [SEARCH]` | Search the catalog, pick assets, add them to `itqan-assets.yaml` (created if missing), and optionally install them. `--category` limits it to one kind of asset; `--no-interactive` prints a table (the default when not in a terminal); `--json` prints JSON. |
401
+ | `itqan add ASSET[@RANGE]...` | Add assets to `itqan-assets.yaml` (created if missing) and install them. Without `@RANGE` an entry accepts `^` the newest version; an asset already in the manifest gets the new range. `--language` picks a language other than the source; `--no-install` only edits the manifest. |
317
402
  | `itqan install` | Download the assets and write `itqan-assets.lock`. Uses the lockfile's exact versions while it matches the manifest. `--force` picks the newest allowed versions and downloads again. `--flutter` keeps `pubspec.yaml` up to date (see [Flutter](#flutter)). `--assets-dir` overrides the manifest's folder for one run. |
318
403
  | `itqan sync` | Same as `itqan install`. |
404
+ | `itqan outdated` | List the locked assets that have newer versions: the newest your range allows and the newest overall. `--json` prints JSON. |
319
405
  | `itqan login` | Save your API key for the registry, after checking it. `--api-key` passes the key without the prompt. |
320
406
  | `itqan logout` | Remove the saved key. |
321
407
  | `itqan --version` | Print the CLI version. |
@@ -329,6 +415,7 @@ Add `--help` to any command for all its options. `install` and `browse` read the
329
415
  |---|---|---|
330
416
  | `--api-key` | `ITQAN_API_KEY` | The key saved by `itqan login`, if any. |
331
417
  | `--registry-url` | `ITQAN_REGISTRY_URL` | `https://api.cms.itqan.dev`, the public registry. |
418
+ | | `ITQAN_NO_UPDATE_NOTICE` | Set to `1` to stop `itqan install` saying that newer versions exist. |
332
419
  | | `ITQAN_CONFIG_DIR` | Where `itqan login` saves keys: `~/.config/itqan` (`%APPDATA%\itqan` on Windows). |
333
420
  | | `ITQAN_CACHE_DIR` | Dart package only. Where the downloaded program is kept: `~/Library/Caches/itqan` (macOS), `~/.cache/itqan` (Linux), `%LOCALAPPDATA%\itqan` (Windows). |
334
421
  | | `ITQAN_CLI_DOWNLOAD_URL` | Dart package only. A folder (`https://` or `file://`) with a release's programs and `SHA256SUMS`, such as a mirror, used instead of the GitHub Release. |
@@ -358,6 +445,17 @@ listed under [Install](#install). Install with Python instead: `pipx install itq
358
445
  [Assets that need access approval](#assets-that-need-access-approval). In CI, check that
359
446
  `ITQAN_API_KEY` is set.
360
447
 
448
+ **"Warning: ... was withdrawn by its publisher".** Your lockfile pins a version the publisher
449
+ has since withdrawn by going back to an earlier version, usually because of a mistake in it; the
450
+ warning shows the reason they gave. It still installs, so your build
451
+ keeps working, but new installs no longer get it. Run `itqan install --force` to move to the
452
+ newest supported version in your range, or change the version in `itqan-assets.yaml` if you
453
+ pinned it there.
454
+
455
+ **"Version removed from the registry" (410).** Itqan removed that version, for example because
456
+ its licence was revoked, and it can't be downloaded any more. Run `itqan install --force` to
457
+ resolve another version, or change the version in `itqan-assets.yaml`.
458
+
361
459
  **Flutter: "Unable to load asset".** Make sure the manifest sits next to `pubspec.yaml`, run
362
460
  `itqan install --flutter`, and then restart the app fully. Hot reload doesn't pick up new assets.
363
461
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "itqan-cli"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Itqan Quranic Asset Manager: install and pin Itqan Quranic assets in your project."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -0,0 +1,96 @@
1
+ """`itqan add`: add assets to the manifest by name, like `uv add` or `npm install <pkg>`.
2
+
3
+ The pieces are plain functions; `main.add_command` does the I/O.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import re
9
+
10
+ from itqan_cli.client import CatalogLanguage, CatalogPackage
11
+ from itqan_cli.exceptions import ItqanCliError, ManifestError
12
+ from itqan_cli.manifest import AssetManifest, parse_manifest_content
13
+ from itqan_cli.semver import parse_constraint
14
+
15
+
16
+ def parse_spec(spec: str) -> tuple[str, str | None]:
17
+ """``slug`` or ``slug@range`` → (slug, range or None).
18
+
19
+ Raises:
20
+ ItqanCliError when the slug is empty or the range isn't valid.
21
+ """
22
+ slug, sep, constraint = spec.partition("@")
23
+ slug = slug.strip()
24
+ if not slug:
25
+ raise ItqanCliError(f"Missing asset name in {spec!r}.")
26
+ if not sep:
27
+ return slug, None
28
+ try:
29
+ parse_constraint(constraint)
30
+ except ValueError as exc:
31
+ raise ItqanCliError(f"Invalid version range in {spec!r}: {exc}.") from exc
32
+ return slug, constraint.strip()
33
+
34
+
35
+ def pick_language(package: CatalogPackage, language: str | None) -> CatalogLanguage:
36
+ """The rendition to add: ``language``, or the source language when None.
37
+
38
+ Raises:
39
+ ItqanCliError when the asset has no such language.
40
+ """
41
+ if language is None:
42
+ source = next((lang for lang in package.languages if lang.is_source), None)
43
+ if source is not None:
44
+ return source
45
+ if package.languages:
46
+ return package.languages[0]
47
+ else:
48
+ match = next((lang for lang in package.languages if lang.language == language), None)
49
+ if match is not None:
50
+ return match
51
+ available = ", ".join(lang.language or "source" for lang in package.languages) or "none"
52
+ raise ItqanCliError(f"{package.slug} is not available in {language or 'any language'}; it has: {available}.")
53
+
54
+
55
+ def existing_entry(manifest: AssetManifest | None, package: CatalogPackage, language: CatalogLanguage) -> str | None:
56
+ """The name of the manifest entry that already installs this language of the package."""
57
+ if manifest is None:
58
+ return None
59
+ for name, entry in manifest.assets.items():
60
+ if (entry.asset or entry.slug) != package.slug:
61
+ continue
62
+ if entry.language == language.language or (entry.language is None and language.is_source):
63
+ return name
64
+ return None
65
+
66
+
67
+ _VERSION_LINE = re.compile(r"^(?P<indent>[ \t]+)version[ \t]*:.*$")
68
+
69
+
70
+ def set_entry_version(content: str, name: str, constraint: str) -> str:
71
+ """``content`` with entry ``name``'s `version:` set to ``constraint``, leaving
72
+ every other line as it is.
73
+
74
+ Raises:
75
+ ManifestError when the entry can't be found or the result is invalid.
76
+ """
77
+ lines = content.splitlines()
78
+ key = re.compile(rf"^(?P<indent>[ \t]+)(\"{re.escape(name)}\"|'{re.escape(name)}'|{re.escape(name)})[ \t]*:")
79
+ start = next((i for i, line in enumerate(lines) if key.match(line)), None)
80
+ if start is None:
81
+ raise ManifestError(f"Could not find the {name!r} entry to update.")
82
+ key_indent = len(key.match(lines[start]).group("indent"))
83
+ for i in range(start + 1, len(lines)):
84
+ line = lines[i]
85
+ if not line.strip() or line.lstrip().startswith("#"):
86
+ continue
87
+ if len(line) - len(line.lstrip()) <= key_indent:
88
+ break # the next entry or key
89
+ match = _VERSION_LINE.match(line)
90
+ if match:
91
+ lines[i] = f'{match.group("indent")}version: "{constraint}"'
92
+ updated = "\n".join(lines) + "\n"
93
+ if parse_manifest_content(updated.encode("utf-8")).assets[name].version != constraint:
94
+ raise ManifestError(f"Could not update the {name!r} entry's version.")
95
+ return updated
96
+ raise ManifestError(f"The {name!r} entry has no `version:` line to update.")
@@ -30,16 +30,18 @@ class NewEntry:
30
30
  name: str
31
31
  package: CatalogPackage
32
32
  language: CatalogLanguage
33
+ constraint: str | None = None # None: ^ the language's latest version
33
34
 
34
35
  def lines(self, indent: str) -> list[str]:
35
36
  if self.language.is_source:
36
- return entry_lines(self.name, self.language.latest_version, indent=indent)
37
+ return entry_lines(self.name, self.language.latest_version, indent=indent, constraint=self.constraint)
37
38
  return entry_lines(
38
39
  self.name,
39
40
  self.language.latest_version,
40
41
  asset=self.package.slug,
41
42
  language=self.language.language,
42
43
  indent=indent,
44
+ constraint=self.constraint,
43
45
  )
44
46
 
45
47
 
@@ -21,6 +21,14 @@ class ResolvedAssetPayload:
21
21
  publisher_name: str | None = None
22
22
  name: str = ""
23
23
  language: str | None = None
24
+ # The publisher went back to an earlier version, withdrawing this one: only an exact
25
+ # (lockfile) pin still gets it. ``withdrawal_reason`` is the reason they gave.
26
+ withdrawn: bool = False
27
+ withdrawal_reason: str | None = None
28
+ # Newer versions the registry knows of: the newest overall, and the newest the
29
+ # manifest's range allows. None from a registry too old to report them.
30
+ latest_version: str | None = None
31
+ latest_in_range: str | None = None
24
32
 
25
33
  @property
26
34
  def entry_name(self) -> str:
@@ -295,6 +303,10 @@ class RegistryClient:
295
303
  publisher_name=item.get("publisher_name"),
296
304
  name=item.get("name") or item["slug"],
297
305
  language=item.get("language"),
306
+ withdrawn=bool(item.get("withdrawn", False)),
307
+ withdrawal_reason=item.get("withdrawal_reason"),
308
+ latest_version=item.get("latest_version"),
309
+ latest_in_range=item.get("latest_in_range"),
298
310
  )
299
311
  for item in results_raw
300
312
  ]
@@ -322,6 +334,11 @@ class RegistryClient:
322
334
  friendly_msg = f"Access denied for requested assets (approved access required): {message}"
323
335
  elif status_code == 404:
324
336
  friendly_msg = f"Asset or version not found in registry: {message}"
337
+ elif status_code == 410:
338
+ friendly_msg = (
339
+ f"Version removed from the registry: {message} "
340
+ "Run `itqan install --force` to resolve another version, or change it in your manifest."
341
+ )
325
342
  elif status_code == 422:
326
343
  friendly_msg = f"Cannot satisfy version constraints: {message}"
327
344
  else:
@@ -66,16 +66,23 @@ def _describe(language: CatalogLanguage) -> str:
66
66
 
67
67
 
68
68
  def entry_lines(
69
- name: str, version: str, *, asset: str | None = None, language: str | None = None, indent: str = " "
69
+ name: str,
70
+ version: str,
71
+ *,
72
+ asset: str | None = None,
73
+ language: str | None = None,
74
+ indent: str = " ",
75
+ constraint: str | None = None,
70
76
  ) -> list[str]:
71
- """One manifest entry under `assets:`, constrained to ``^version``; ``indent``
72
- is the entry key's indentation, and its fields go one level deeper."""
77
+ """One manifest entry under `assets:`, constrained to ``^version`` unless
78
+ ``constraint`` is given; ``indent`` is the entry key's indentation, and its
79
+ fields go one level deeper."""
73
80
  lines = [f"{indent}{_quote(name)}:"]
74
81
  if asset is not None:
75
82
  lines.append(f"{indent * 2}asset: {_quote(asset)}")
76
83
  if language is not None:
77
84
  lines.append(f"{indent * 2}language: {_quote(language)}")
78
- lines.append(f"{indent * 2}version: {_quote(_constraint(version))}")
85
+ lines.append(f"{indent * 2}version: {_quote(constraint or _constraint(version))}")
79
86
  return lines
80
87
 
81
88
 
@@ -93,25 +100,47 @@ def pick_samples(packages: list[CatalogPackage], count: int = SAMPLE_COUNT) -> l
93
100
  return ordered[:count]
94
101
 
95
102
 
103
+ _CATALOG_INTRO = """\
104
+ # Examples from the catalog, commented out so nothing is installed until you
105
+ # choose. Uncomment the ones you want, or run `itqan browse` to search the
106
+ # catalog and add assets here.
107
+ """
108
+
109
+
110
+ def _commented(lines: list[str], indent: str = " ") -> list[str]:
111
+ """``lines`` (entry lines at ``indent``) as YAML comments, keeping their nesting."""
112
+ return [f"{indent}# {line[len(indent):]}" for line in lines]
113
+
114
+
96
115
  def render_from_catalog(samples: list[CatalogPackage], assets_dir: str) -> str:
116
+ """The starter file with ``samples`` as commented-out entries. At least one
117
+ entry shows `language:`, even when no sample has a second language."""
97
118
  lines: list[str] = []
98
119
  names: set[str] = set()
120
+ shows_language = False
99
121
  for package in samples:
100
- if lines:
101
- lines.append("")
122
+ lines.append("")
102
123
  name = " ".join(package.name.split()) # one line, even if the name has newlines
103
124
  lines.append(f" # {name} — languages: {', '.join(_describe(lang) for lang in package.languages)}")
104
125
  source = next((lang for lang in package.languages if lang.is_source), None)
105
126
  first = source or package.languages[0]
106
- lines += entry_lines(package.slug, first.latest_version, language=None if source else first.language)
107
- names.add(package.slug)
108
127
  other = next((lang for lang in package.languages if lang is not first), None)
128
+ # Name the source language too when no other entry would show `language:`.
129
+ language = first.language if source is None or (other is None and not shows_language) else None
130
+ if not first.language: # a source language without a code can't be named
131
+ language = None
132
+ lines += _commented(entry_lines(package.slug, first.latest_version, language=language))
133
+ shows_language = shows_language or language is not None
134
+ names.add(package.slug)
109
135
  entry_name = f"{package.slug}-{other.language}" if other else None
110
136
  if other is not None and entry_name not in names:
111
137
  lines.append(f" # The same asset in another language ({other.language}):")
112
- lines += entry_lines(entry_name, other.latest_version, asset=package.slug, language=other.language)
138
+ lines += _commented(
139
+ entry_lines(entry_name, other.latest_version, asset=package.slug, language=other.language)
140
+ )
113
141
  names.add(entry_name)
114
- return render_header(assets_dir) + "\n".join(lines) + "\n"
142
+ shows_language = True
143
+ return render_header(assets_dir) + _CATALOG_INTRO + "\n".join(lines) + "\n"
115
144
 
116
145
 
117
146
  def render_fallback(assets_dir: str, reason: str) -> str: