@pushizo/cli 0.0.0-stage → 0.2.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pushizo contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,92 @@
1
- # Temporary Holding Version
1
+ <!-- pushizo:header -->
2
+ <p align="center">
3
+ <a href="https://pushizo.com"><img src="https://raw.githubusercontent.com/pushizo/.github/main/profile/assets/mark.svg" alt="Pushizo" width="56" height="56"></a>
4
+ </p>
5
+ <p align="center">
6
+ <a href="https://docs.pushizo.com/docs/integrations/cli-sdks"><img src="https://img.shields.io/badge/docs-docs.pushizo.com-5b4bdb" alt="Docs"></a>
7
+ <a href="https://docs.pushizo.com/docs/api"><img src="https://img.shields.io/badge/API-reference-b44fc4" alt="API reference"></a>
8
+ <a href="https://github.com/pushizo/pushizo-cli/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-16130f" alt="License: MIT"></a>
9
+ </p>
10
+ <p align="center"><a href="#english">English</a> · <a href="#türkçe">Türkçe</a></p>
2
11
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
12
+ ## English
13
+
14
+ **Pushizo CLI** — The `pushizo` command for scripts and terminals. Lists apps, segments and templates as JSON and sends a notification to subscribed users. Reads PUSHIZO_API_KEY, PUSHIZO_APP_ID and PUSHIZO_API_URL from the environment; the key is never printed. Node.js 20+, no dependencies.
15
+
16
+ ```bash
17
+ npm install -g @pushizo/cli
18
+ pushizo --help
19
+ ```
20
+
21
+ The detailed guide below is in Turkish; code samples are language-neutral. Full documentation:
22
+ [docs.pushizo.com/docs/integrations/cli-sdks](https://docs.pushizo.com/docs/integrations/cli-sdks) · API reference: [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api).
23
+
24
+ ## Türkçe
25
+ <!-- /pushizo:header -->
26
+
27
+ # Pushizo CLI
28
+
29
+ Betikler ve terminal için `pushizo` komutu. App, segment ve şablonları JSON olarak listeler; abone kullanıcılara
30
+ bildirim gönderir. Node.js 20+; bağımlılığı yoktur.
31
+
32
+ ## Kurulum
33
+
34
+ ```bash
35
+ npm install -g @pushizo/cli
36
+ pushizo --help
37
+ ```
38
+
39
+ Kurmadan çalıştırmak için: `npx @pushizo/cli --help`.
40
+
41
+ ## Ortam değişkenleri
42
+
43
+ | Değişken | Açıklama |
44
+ |----------|----------|
45
+ | `PUSHIZO_API_KEY` | App veya organizasyon API anahtarı (zorunlu). Çıktıya ve hata mesajlarına yazılmaz. |
46
+ | `PUSHIZO_APP_ID` | `segments`, `templates` ve `send` için app kimliği |
47
+ | `PUSHIZO_API_URL` | API adresi (varsayılan `https://api.pushizo.com`; yerelde `http://localhost:4000`) |
48
+
49
+ Anahtarı komut satırı argümanı olarak vermeyin; kabuk geçmişine düşer. Ortam değişkeni veya gizli bilgi yöneticisi
50
+ kullanın.
51
+
52
+ ## Komutlar
53
+
54
+ ```bash
55
+ pushizo apps # app listesi
56
+ pushizo segments # PUSHIZO_APP_ID segmentleri
57
+ pushizo templates # PUSHIZO_APP_ID şablonları
58
+ pushizo send "Başlık" "Gövde metni" # "Subscribed Users" segmentine bildirim (en + tr aynı metin)
59
+ pushizo --version
60
+ ```
61
+
62
+ Çıktı biçimlendirilmiş JSON'dur; `jq` ile işlenebilir:
63
+
64
+ ```bash
65
+ pushizo segments | jq -r '.data[].name'
66
+ ```
67
+
68
+ Çıkış kodu başarıda `0`, eksik ayar, ağ veya HTTP hatasında `1`'dir; hata ayrıntısı standart hataya yazılır.
69
+
70
+ Daha geniş kullanım (kullanıcılar, kampanyalar, analitik) için sunucu SDK'larını veya REST API'yi kullanın:
71
+ [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api).
72
+
73
+ <!-- pushizo:footer -->
74
+ ---
75
+
76
+ ## Support · Destek
77
+
78
+ - **Guide · Rehber:** [docs.pushizo.com/docs/integrations/cli-sdks](https://docs.pushizo.com/docs/integrations/cli-sdks)
79
+ - **API reference & OpenAPI · API referansı ve OpenAPI:** [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api) ·
80
+ [pushizo-openapi](https://github.com/pushizo/pushizo-openapi)
81
+ - **Bugs & ideas · Hata ve öneri:** [Issues](https://github.com/pushizo/pushizo-cli/issues)
82
+ - **Security · Güvenlik:** please do not open public issues; email [security@pushizo.com](mailto:security@pushizo.com) ·
83
+ herkese açık issue açmayın, bu adrese yazın.
84
+ - **Help · Destek:** [support@pushizo.com](mailto:support@pushizo.com)
85
+
86
+ This repository is mirrored automatically from the Pushizo main repository on every release. Please open an issue
87
+ instead of a pull request; fixes land in the main repository and ship with the next release.
88
+ Bu depo her sürümde Pushizo ana deposundan otomatik yansıtılır. Pull request yerine issue açın; düzeltmeler ana depoda
89
+ yapılır ve bir sonraki sürümle buraya gelir.
90
+
91
+ Released under the MIT License · MIT lisanslıdır — [LICENSE](https://github.com/pushizo/pushizo-cli/blob/main/LICENSE).
92
+ <!-- /pushizo:footer -->
package/dist/cli.js ADDED
@@ -0,0 +1,109 @@
1
+ /**
2
+ * `pushizo` komutunun gövdesi: argümanları yorumlar, public API'yi çağırır, JSON yazdırır ve çıkış kodu döner.
3
+ * Giriş noktası (`index.ts`) yalnızca süreç bağlamını verir; bu ayrım birim testlerini sürece dokunmadan mümkün kılar.
4
+ * API anahtarı hiçbir çıktıya yazılmaz.
5
+ */
6
+ import { readFileSync } from 'node:fs';
7
+ export const DEFAULT_API_URL = 'https://api.pushizo.com';
8
+ export const VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
9
+ export const HELP = `Pushizo CLI ${VERSION}
10
+
11
+ Usage:
12
+ pushizo apps List apps
13
+ pushizo segments List segments of PUSHIZO_APP_ID
14
+ pushizo templates List templates of PUSHIZO_APP_ID
15
+ pushizo send "<title>" "<body>" Send a notification to subscribed users of PUSHIZO_APP_ID
16
+ pushizo --help | --version
17
+
18
+ Environment:
19
+ PUSHIZO_API_KEY App or organization API key (required; never printed)
20
+ PUSHIZO_APP_ID App id for segments, templates and send
21
+ PUSHIZO_API_URL API base URL (default ${DEFAULT_API_URL})
22
+
23
+ Türkçe: komutlar aynıdır. apps → app listesi, segments → segmentler, templates → şablonlar,
24
+ send "<başlık>" "<gövde>" → abone kullanıcılara bildirim. Ortam değişkenleri yukarıdaki gibidir; anahtar çıktıya yazılmaz.
25
+
26
+ Docs: https://docs.pushizo.com/docs/integrations/cli-sdks
27
+ `;
28
+ class CliError extends Error {
29
+ }
30
+ export async function run(argv, env, io) {
31
+ const [command, ...rest] = argv;
32
+ if (!command || command === 'help' || command === '--help' || command === '-h') {
33
+ io.out(HELP);
34
+ return command ? 0 : 1;
35
+ }
36
+ if (command === 'version' || command === '--version' || command === '-v') {
37
+ io.out(`${VERSION}\n`);
38
+ return 0;
39
+ }
40
+ const apiUrl = (env.PUSHIZO_API_URL || DEFAULT_API_URL).replace(/\/+$/, '');
41
+ const key = env.PUSHIZO_API_KEY ?? '';
42
+ const appId = env.PUSHIZO_APP_ID ?? '';
43
+ const needApp = () => {
44
+ if (!appId)
45
+ throw new CliError('PUSHIZO_APP_ID is required · PUSHIZO_APP_ID gerekli.');
46
+ return appId;
47
+ };
48
+ const call = async (method, path, body) => {
49
+ if (!key)
50
+ throw new CliError('PUSHIZO_API_KEY is required · PUSHIZO_API_KEY gerekli.');
51
+ let res;
52
+ try {
53
+ res = await io.fetch(`${apiUrl}${path}`, {
54
+ method,
55
+ headers: {
56
+ authorization: `Bearer ${key}`,
57
+ accept: 'application/json',
58
+ 'user-agent': `pushizo-cli/${VERSION}`,
59
+ ...(body ? { 'content-type': 'application/json' } : {}),
60
+ },
61
+ ...(body ? { body: JSON.stringify(body) } : {}),
62
+ });
63
+ }
64
+ catch (error) {
65
+ throw new CliError(`Network error · Ağ hatası: ${error instanceof Error ? error.message : String(error)}`);
66
+ }
67
+ const text = await res.text();
68
+ if (!res.ok)
69
+ throw new CliError(`HTTP ${res.status}: ${text.slice(0, 500)}`);
70
+ return text ? JSON.parse(text) : {};
71
+ };
72
+ const print = (value) => io.out(`${JSON.stringify(value, null, 2)}\n`);
73
+ try {
74
+ switch (command) {
75
+ case 'apps':
76
+ print(await call('GET', '/v1/apps'));
77
+ return 0;
78
+ case 'segments':
79
+ print(await call('GET', `/v1/apps/${encodeURIComponent(needApp())}/segments`));
80
+ return 0;
81
+ case 'templates':
82
+ print(await call('GET', `/v1/apps/${encodeURIComponent(needApp())}/templates`));
83
+ return 0;
84
+ case 'send': {
85
+ const title = rest[0];
86
+ const text = rest.slice(1).join(' ');
87
+ if (!title || !text)
88
+ throw new CliError('Usage · Kullanım: pushizo send "<title>" "<body>"');
89
+ print(await call('POST', '/v1/notifications', {
90
+ app_id: needApp(),
91
+ target: { included_segments: ['Subscribed Users'] },
92
+ headings: { en: title, tr: title },
93
+ contents: { en: text, tr: text },
94
+ }));
95
+ return 0;
96
+ }
97
+ default:
98
+ io.err(`Unknown command · Bilinmeyen komut: ${command}\n\n${HELP}`);
99
+ return 1;
100
+ }
101
+ }
102
+ catch (error) {
103
+ if (error instanceof CliError) {
104
+ io.err(`${error.message}\n`);
105
+ return 1;
106
+ }
107
+ throw error;
108
+ }
109
+ }
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * pushizo apps | segments | templates | send | --help | --version
4
+ * Ortam: PUSHIZO_API_KEY, PUSHIZO_APP_ID, PUSHIZO_API_URL (varsayılan https://api.pushizo.com)
5
+ */
6
+ import { run } from './cli.js';
7
+ process.exitCode = await run(process.argv.slice(2), process.env, {
8
+ out: (text) => void process.stdout.write(text),
9
+ err: (text) => void process.stderr.write(text),
10
+ fetch: globalThis.fetch,
11
+ });
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@pushizo/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Pushizo command-line tool: list apps, segments and templates, send notifications",
5
+ "license": "MIT",
6
+ "homepage": "https://docs.pushizo.com/docs/integrations/cli-sdks",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/pushizo/pushizo-cli.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/pushizo/pushizo-cli/issues",
13
+ "email": "support@pushizo.com"
14
+ },
15
+ "keywords": [
16
+ "pushizo",
17
+ "cli",
18
+ "push",
19
+ "notifications",
20
+ "command-line"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "provenance": true
25
+ },
26
+ "type": "module",
27
+ "bin": {
28
+ "pushizo": "./dist/index.js"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "scripts": {
36
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
37
+ "typecheck": "tsc -p tsconfig.json --noEmit"
38
+ },
39
+ "engines": {
40
+ "node": ">=20"
41
+ }
42
+ }