itqan-cli 0.1.1__tar.gz → 0.1.2__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 (39) hide show
  1. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/CHANGELOG.md +6 -0
  2. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/PKG-INFO +19 -1
  3. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/README.md +18 -0
  4. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/RELEASING.md +33 -2
  5. itqan_cli-0.1.2/npm/README.md +27 -0
  6. itqan_cli-0.1.2/npm/bin/itqan.js +44 -0
  7. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/pyproject.toml +1 -1
  8. itqan_cli-0.1.2/scripts/npm_packages.py +123 -0
  9. itqan_cli-0.1.2/tests/test_npm_packages.py +95 -0
  10. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/.gitignore +0 -0
  11. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/LICENSE +0 -0
  12. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/scripts/homebrew_formula.py +0 -0
  13. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/__init__.py +0 -0
  14. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/__main__.py +0 -0
  15. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/browse.py +0 -0
  16. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/client.py +0 -0
  17. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/credentials.py +0 -0
  18. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/downloader.py +0 -0
  19. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/exceptions.py +0 -0
  20. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/init_template.py +0 -0
  21. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/lockfile.py +0 -0
  22. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/main.py +0 -0
  23. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/manifest.py +0 -0
  24. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/src/itqan_cli/semver.py +0 -0
  25. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/__init__.py +0 -0
  26. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/conftest.py +0 -0
  27. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_access.py +0 -0
  28. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_assets_dir.py +0 -0
  29. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_browse.py +0 -0
  30. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_cli_integration.py +0 -0
  31. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_client.py +0 -0
  32. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_downloader.py +0 -0
  33. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_entry_points.py +0 -0
  34. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_homebrew_formula.py +0 -0
  35. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_init.py +0 -0
  36. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_languages.py +0 -0
  37. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_lockfile.py +0 -0
  38. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_login.py +0 -0
  39. {itqan_cli-0.1.1 → itqan_cli-0.1.2}/tests/test_manifest.py +0 -0
@@ -1,3 +1,9 @@
1
+ ## v0.1.2 (2026-10-11)
2
+
3
+ ### Feat
4
+
5
+ - publish to npm as itqan-cli
6
+
1
7
  ## v0.1.1 (2026-10-11)
2
8
 
3
9
  ### Feat
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: itqan-cli
3
- Version: 0.1.1
3
+ Version: 0.1.2
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
@@ -59,6 +59,24 @@ brew install itqan-community/tap/itqan
59
59
  brew upgrade itqan # later, to update
60
60
  ```
61
61
 
62
+ ### npm
63
+
64
+ For JavaScript and React Native projects, without Python:
65
+
66
+ ```bash
67
+ npx itqan-cli init
68
+ npx itqan-cli install
69
+ ```
70
+
71
+ Or add it to your project and run `itqan install` from your `package.json` scripts:
72
+
73
+ ```bash
74
+ npm install --save-dev itqan-cli
75
+ ```
76
+
77
+ It runs the standalone binary for your platform (macOS, Linux with glibc, Windows), installed as
78
+ an optional dependency, so don't install with `--omit=optional`.
79
+
62
80
  ### Without Python
63
81
 
64
82
  Each [GitHub Release](https://github.com/Itqan-community/itqan-cli/releases) has a standalone
@@ -28,6 +28,24 @@ brew install itqan-community/tap/itqan
28
28
  brew upgrade itqan # later, to update
29
29
  ```
30
30
 
31
+ ### npm
32
+
33
+ For JavaScript and React Native projects, without Python:
34
+
35
+ ```bash
36
+ npx itqan-cli init
37
+ npx itqan-cli install
38
+ ```
39
+
40
+ Or add it to your project and run `itqan install` from your `package.json` scripts:
41
+
42
+ ```bash
43
+ npm install --save-dev itqan-cli
44
+ ```
45
+
46
+ It runs the standalone binary for your platform (macOS, Linux with glibc, Windows), installed as
47
+ an optional dependency, so don't install with `--omit=optional`.
48
+
31
49
  ### Without Python
32
50
 
33
51
  Each [GitHub Release](https://github.com/Itqan-community/itqan-cli/releases) has a standalone
@@ -4,8 +4,10 @@ Releases are published by [`.github/workflows/release.yml`](.github/workflows/re
4
4
  version tag is pushed. It runs the tests, builds the package and the standalone binaries
5
5
  ([`binaries.yml`](.github/workflows/binaries.yml)), publishes the package to
6
6
  [PyPI](https://pypi.org/project/itqan-cli/) and creates the GitHub Release with the package, the
7
- binaries and a `SHA256SUMS` file. Nothing is published unless every binary builds and passes its
8
- smoke test (`--version`, `--help`, `init` and `install` against the public registry).
7
+ binaries and a `SHA256SUMS` file, then publishes the npm packages ([`npm.yml`](.github/workflows/npm.yml))
8
+ and updates the Homebrew tap. Nothing is published unless every binary builds and passes its
9
+ smoke test (`--version`, `--help`, `init` and `install` against the public registry), and the npm
10
+ packages install and run on every platform.
9
11
 
10
12
  ## Steps
11
13
 
@@ -64,3 +66,32 @@ itqan-cli` skips them unless asked for explicitly: `pipx install itqan-cli==0.2.
64
66
  ```
65
67
 
66
68
  If the job fails, the release is still out on PyPI and GitHub; fix the cause and re-run the job.
69
+ - **npm:** the `publish-npm` job publishes `itqan-cli` and the platform packages
70
+ `@itqan-community/cli-{darwin-arm64,darwin-x64,linux-arm64,linux-x64,win32-x64}` with
71
+ [trusted publishing](https://docs.npmjs.com/trusted-publishers), so no token is stored. npm only
72
+ lets you set that up for a package that already exists, so publish the first version by hand:
73
+ 1. Create the `itqan-community` organization on [npmjs.com](https://www.npmjs.com/org/create)
74
+ (free for public packages). You need two-factor authentication on your npm account.
75
+ 2. Build the packages from the latest release and publish them (platform packages first):
76
+
77
+ ```bash
78
+ v=0.1.1 # the latest release
79
+ gh release download "v$v" --pattern "itqan-$v-*" --dir /tmp/itqan-bin
80
+ python3 scripts/npm_packages.py "$v" /tmp/itqan-bin /tmp/itqan-npm
81
+ npm login
82
+ for p in /tmp/itqan-npm/cli-* /tmp/itqan-npm/itqan-cli; do npm publish "$p" --access public; done
83
+ ```
84
+
85
+ 3. Trust this repository's release workflow for each package (npm 11.10+):
86
+
87
+ ```bash
88
+ for p in itqan-cli @itqan-community/cli-{darwin-arm64,darwin-x64,linux-arm64,linux-x64,win32-x64}; do
89
+ npm trust github "$p" --repo Itqan-community/itqan-cli --file release.yml --env npm --yes
90
+ sleep 2
91
+ done
92
+ ```
93
+
94
+ 4. Create an environment named `npm` under *Settings → Environments*.
95
+
96
+ If the job fails, the release is still out on PyPI and GitHub; fix the cause and re-run the job.
97
+ It skips packages already published at that version.
@@ -0,0 +1,27 @@
1
+ # itqan-cli
2
+
3
+ Install and pin [Itqan](https://github.com/Itqan-community) Quranic assets in your project.
4
+
5
+ ```bash
6
+ npx itqan-cli init # create itqan-assets.yaml
7
+ npx itqan-cli install # download the assets it declares
8
+ ```
9
+
10
+ Or add it to your project and call `itqan` from `package.json` scripts:
11
+
12
+ ```bash
13
+ npm install --save-dev itqan-cli
14
+ ```
15
+
16
+ ```json
17
+ {
18
+ "scripts": {
19
+ "assets": "itqan install"
20
+ }
21
+ }
22
+ ```
23
+
24
+ This package runs the standalone `itqan` binary for your platform (macOS arm64/x64, Linux
25
+ arm64/x64 with glibc, Windows x64), so Python isn't needed. See the
26
+ [itqan-cli README](https://github.com/Itqan-community/itqan-cli#readme) for the commands and the
27
+ manifest format.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // The `itqan` command of the itqan-cli npm package. npm installs only the platform package that
5
+ // matches this machine (an optional dependency limited by `os`/`cpu`); this runs its standalone
6
+ // binary. Packages are built by scripts/npm_packages.py.
7
+
8
+ const { spawnSync } = require("node:child_process");
9
+
10
+ const PACKAGES = {
11
+ "darwin-arm64": "@itqan-community/cli-darwin-arm64",
12
+ "darwin-x64": "@itqan-community/cli-darwin-x64",
13
+ "linux-arm64": "@itqan-community/cli-linux-arm64",
14
+ "linux-x64": "@itqan-community/cli-linux-x64",
15
+ "win32-x64": "@itqan-community/cli-win32-x64",
16
+ };
17
+
18
+ const platform = `${process.platform}-${process.arch}`;
19
+ const pkg = PACKAGES[platform];
20
+ if (!pkg) {
21
+ console.error(`itqan: no prebuilt binary for ${platform}. Install with Python instead: pipx install itqan-cli`);
22
+ process.exit(1);
23
+ }
24
+
25
+ let binary;
26
+ try {
27
+ binary = require.resolve(`${pkg}/bin/itqan${process.platform === "win32" ? ".exe" : ""}`);
28
+ } catch {
29
+ console.error(
30
+ `itqan: ${pkg} is not installed. It's an optional dependency of itqan-cli, so reinstall ` +
31
+ "without --omit=optional (or --no-optional).",
32
+ );
33
+ process.exit(1);
34
+ }
35
+
36
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
37
+ if (result.error) {
38
+ console.error(`itqan: could not run ${binary}: ${result.error.message}`);
39
+ process.exit(1);
40
+ }
41
+ if (result.signal) {
42
+ process.kill(process.pid, result.signal);
43
+ }
44
+ process.exit(result.status ?? 1);
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "itqan-cli"
3
- version = "0.1.1"
3
+ version = "0.1.2"
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,123 @@
1
+ """Build the npm packages for a release from its standalone binaries.
2
+
3
+ python scripts/npm_packages.py 0.2.0 bin/ npm-dist/
4
+
5
+ Writes one package per platform, holding that platform's binary (`@itqan-community/cli-<os>-<cpu>`,
6
+ limited by `os`/`cpu` so npm installs only the matching one), and the main `itqan-cli` package with
7
+ the `itqan` shim from npm/ and the platform packages as optional dependencies. Prints the package
8
+ folders in publishing order: platform packages first, `itqan-cli` last. release.yml runs this.
9
+ """
10
+
11
+ import json
12
+ from pathlib import Path
13
+ import re
14
+ import shutil
15
+ import sys
16
+
17
+ ROOT = Path(__file__).resolve().parents[1]
18
+ SHIM_DIR = ROOT / "npm"
19
+ SCOPE = "@itqan-community"
20
+ REPOSITORY = {"type": "git", "url": "git+https://github.com/Itqan-community/itqan-cli.git"}
21
+
22
+ # npm (os, cpu) -> the binary's os-arch suffix (binaries.yml) and a readable name.
23
+ PLATFORMS = {
24
+ ("darwin", "arm64"): ("macos-arm64", "macOS arm64"),
25
+ ("darwin", "x64"): ("macos-x86_64", "macOS x86_64"),
26
+ ("linux", "arm64"): ("linux-arm64", "Linux arm64"),
27
+ ("linux", "x64"): ("linux-x86_64", "Linux x86_64"),
28
+ ("win32", "x64"): ("windows-x86_64", "Windows x86_64"),
29
+ }
30
+
31
+ _PRERELEASE = {"a": "alpha", "b": "beta", "rc": "rc"}
32
+
33
+
34
+ def npm_version(version: str) -> str:
35
+ """PEP 440 -> semver: `0.2.0` stays, `0.2.0rc1` becomes `0.2.0-rc.1`."""
36
+ match = re.fullmatch(r"(\d+\.\d+\.\d+)(?:(a|b|rc)(\d+))?", version)
37
+ if not match:
38
+ raise ValueError(f"can't publish version {version!r} to npm")
39
+ release, kind, number = match.groups()
40
+ return f"{release}-{_PRERELEASE[kind]}.{number}" if kind else release
41
+
42
+
43
+ def platform_package_name(os: str, cpu: str) -> str:
44
+ return f"{SCOPE}/cli-{os}-{cpu}"
45
+
46
+
47
+ def _write_json(path: Path, data: dict) -> None:
48
+ path.write_text(json.dumps(data, indent=2) + "\n")
49
+
50
+
51
+ def build(version: str, binaries: Path, out: Path) -> list[Path]:
52
+ semver = npm_version(version)
53
+ common = {
54
+ "version": semver,
55
+ "license": "MIT",
56
+ "homepage": "https://github.com/Itqan-community/itqan-cli",
57
+ "repository": REPOSITORY,
58
+ }
59
+ folders = []
60
+
61
+ for (os, cpu), (suffix, label) in PLATFORMS.items():
62
+ ext = ".exe" if os == "win32" else ""
63
+ source = binaries / f"itqan-{version}-{suffix}{ext}"
64
+ if not source.is_file():
65
+ raise FileNotFoundError(f"{source} is missing")
66
+ folder = out / f"cli-{os}-{cpu}"
67
+ (folder / "bin").mkdir(parents=True)
68
+ binary = folder / "bin" / f"itqan{ext}"
69
+ shutil.copyfile(source, binary)
70
+ binary.chmod(0o755)
71
+ package = {
72
+ "name": platform_package_name(os, cpu),
73
+ "description": f"The itqan-cli binary for {label}.",
74
+ **common,
75
+ "os": [os],
76
+ "cpu": [cpu],
77
+ "files": ["bin"],
78
+ "preferUnplugged": True,
79
+ }
80
+ if os == "linux":
81
+ # Built against glibc (ubuntu-22.04), so it doesn't run on musl (Alpine).
82
+ package["libc"] = ["glibc"]
83
+ _write_json(folder / "package.json", package)
84
+ shutil.copyfile(ROOT / "LICENSE", folder / "LICENSE")
85
+ (folder / "README.md").write_text(
86
+ f"# {package['name']}\n\nThe standalone `itqan` binary for {label}. Install "
87
+ "[`itqan-cli`](https://www.npmjs.com/package/itqan-cli) instead, which picks the right one.\n"
88
+ )
89
+ folders.append(folder)
90
+
91
+ main = out / "itqan-cli"
92
+ shutil.copytree(SHIM_DIR, main)
93
+ shutil.copyfile(ROOT / "LICENSE", main / "LICENSE")
94
+ (main / "bin" / "itqan.js").chmod(0o755)
95
+ _write_json(
96
+ main / "package.json",
97
+ {
98
+ "name": "itqan-cli",
99
+ "description": "Itqan Quranic Asset Manager: install and pin Itqan Quranic assets in your project.",
100
+ **common,
101
+ "keywords": ["itqan", "quran", "quranic", "tafsir", "mushaf", "assets", "cli"],
102
+ "bin": {"itqan": "bin/itqan.js", "itqan-cli": "bin/itqan.js"},
103
+ "files": ["bin"],
104
+ "engines": {"node": ">=18"},
105
+ "optionalDependencies": {platform_package_name(os, cpu): semver for os, cpu in PLATFORMS},
106
+ },
107
+ )
108
+ folders.append(main)
109
+ return folders
110
+
111
+
112
+ def main(argv: list[str]) -> int:
113
+ if len(argv) != 3:
114
+ print(__doc__, file=sys.stderr)
115
+ return 2
116
+ version, binaries, out = argv
117
+ for folder in build(version, Path(binaries), Path(out)):
118
+ print(folder)
119
+ return 0
120
+
121
+
122
+ if __name__ == "__main__":
123
+ sys.exit(main(sys.argv[1:]))
@@ -0,0 +1,95 @@
1
+ """Tests for scripts/npm_packages.py, which builds the npm packages on each release."""
2
+
3
+ import importlib.util
4
+ import json
5
+ from pathlib import Path
6
+ import re
7
+
8
+ import pytest
9
+
10
+ _SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "npm_packages.py"
11
+ _spec = importlib.util.spec_from_file_location("npm_packages", _SCRIPT)
12
+ npm_packages = importlib.util.module_from_spec(_spec)
13
+ _spec.loader.exec_module(npm_packages)
14
+
15
+ BINARIES = [
16
+ "itqan-0.2.0rc1-macos-arm64",
17
+ "itqan-0.2.0rc1-macos-x86_64",
18
+ "itqan-0.2.0rc1-linux-arm64",
19
+ "itqan-0.2.0rc1-linux-x86_64",
20
+ "itqan-0.2.0rc1-windows-x86_64.exe",
21
+ ]
22
+
23
+
24
+ @pytest.fixture
25
+ def binaries(tmp_path: Path) -> Path:
26
+ folder = tmp_path / "bin"
27
+ folder.mkdir()
28
+ for name in BINARIES:
29
+ (folder / name).write_bytes(name.encode())
30
+ return folder
31
+
32
+
33
+ @pytest.mark.parametrize(
34
+ ("version", "expected"),
35
+ [("0.2.0", "0.2.0"), ("0.2.0a1", "0.2.0-alpha.1"), ("0.2.0b2", "0.2.0-beta.2"), ("1.0.0rc10", "1.0.0-rc.10")],
36
+ )
37
+ def test_npm_version_where_pep440_should_return_semver(version, expected):
38
+ assert npm_packages.npm_version(version) == expected
39
+
40
+
41
+ def test_npm_version_where_unsupported_should_refuse():
42
+ with pytest.raises(ValueError):
43
+ npm_packages.npm_version("0.2.0.dev1")
44
+
45
+
46
+ def test_build_where_all_binaries_present_should_write_platform_packages_then_main(binaries: Path, tmp_path: Path):
47
+ # Act
48
+ folders = npm_packages.build("0.2.0rc1", binaries, tmp_path / "out")
49
+
50
+ # Assert
51
+ assert [folder.name for folder in folders] == [
52
+ "cli-darwin-arm64",
53
+ "cli-darwin-x64",
54
+ "cli-linux-arm64",
55
+ "cli-linux-x64",
56
+ "cli-win32-x64",
57
+ "itqan-cli",
58
+ ]
59
+ linux = json.loads((folders[3] / "package.json").read_text())
60
+ assert linux["name"] == "@itqan-community/cli-linux-x64"
61
+ assert linux["version"] == "0.2.0-rc.1"
62
+ assert (linux["os"], linux["cpu"], linux["libc"]) == (["linux"], ["x64"], ["glibc"])
63
+ binary = folders[3] / "bin" / "itqan"
64
+ assert binary.read_bytes() == b"itqan-0.2.0rc1-linux-x86_64"
65
+ assert binary.stat().st_mode & 0o111
66
+ assert (folders[4] / "bin" / "itqan.exe").read_bytes() == b"itqan-0.2.0rc1-windows-x86_64.exe"
67
+
68
+ main = json.loads((folders[5] / "package.json").read_text())
69
+ assert main["bin"] == {"itqan": "bin/itqan.js", "itqan-cli": "bin/itqan.js"}
70
+ assert main["optionalDependencies"] == {
71
+ f"@itqan-community/cli-{platform}": "0.2.0-rc.1"
72
+ for platform in ["darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64", "win32-x64"]
73
+ }
74
+ assert (folders[5] / "bin" / "itqan.js").is_file()
75
+ assert all((folder / "LICENSE").is_file() for folder in folders)
76
+
77
+
78
+ def test_build_where_binary_missing_should_refuse(binaries: Path, tmp_path: Path):
79
+ # Arrange
80
+ (binaries / "itqan-0.2.0rc1-linux-arm64").unlink()
81
+
82
+ # Act / Assert
83
+ with pytest.raises(FileNotFoundError, match="itqan-0.2.0rc1-linux-arm64"):
84
+ npm_packages.build("0.2.0rc1", binaries, tmp_path / "out")
85
+
86
+
87
+ def test_shim_where_compared_with_script_should_name_the_same_platform_packages():
88
+ # Arrange
89
+ shim = (npm_packages.SHIM_DIR / "bin" / "itqan.js").read_text()
90
+
91
+ # Act
92
+ in_shim = dict(re.findall(r'"([a-z0-9]+-[a-z0-9]+)": "(@itqan-community/cli-[a-z0-9-]+)"', shim))
93
+
94
+ # Assert
95
+ assert in_shim == {f"{os}-{cpu}": npm_packages.platform_package_name(os, cpu) for os, cpu in npm_packages.PLATFORMS}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes