> ## Documentation Index
> Fetch the complete documentation index at: https://docs.plato.ae/llms.txt
> Use this file to discover all available pages before exploring further.

# بناء وإطلاق

> قم بإنشاء برنامج تشغيل الطابعة للكمبيوتر الشخصي وتعبئته واختباره وتحريره.

# بناء وإطلاق

الحزمة الحالية هي `@plato/pc-printer`.

## البرامج النصية

| البرنامج النصي | يأمر                                                                                           | غاية                                                            |
| -------------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `clean`        | `node scripts/clean.js`                                                                        | يزيل عناصر البناء والإخراج والسجلات والرمز البريدي و`dump.rdb`. |
| `build`        | `esbuild src/index.ts src/scripts/*.ts --bundle --platform=node --target=node12 --outdir=dist` | حزم رمز وقت التشغيل.                                            |
| `start`        | `node dist/index.js`                                                                           | يبدأ برنامج التشغيل المدمج.                                     |
| `pkg`          | `pkg dist/index.js -t node12-win-x64 -o output/plato-printer.exe --config package.json`        | يخلق ويندوز قابل للتنفيذ.                                       |
| `bundle`       | نتوء الإصدار، البناء، Redis الإعدادية، pkg، الرمز البريدي                                      | تنتج `plato-printer.zip`.                                       |
| `stress`       | `node scripts/stress-test.js`                                                                  | تشغيل اختبار تحميل الطابعة الوهمية.                             |

## بناء محليا

```sh theme={null}
pnpm --filter @plato/pc-printer clean
pnpm --filter @plato/pc-printer build
pnpm --filter @plato/pc-printer start
```

## إنشاء الإصدار المضغوط

```sh theme={null}
pnpm --filter @plato/pc-printer bundle
```

البرنامج النصي للحزمة:

1. الزيادات `src/version.ts`.
2. يبني السائق في `dist`.
3. يقوم بإعداد Windows Redis الثنائي الذي تم تكوينه.
4. يبني `output/plato-printer.exe`.
5. نسخ `config.json`.
6. نسخ أصول العلبة.
7. نسخ الشهادات.
8. نسخ `redis-binaries/<redis.version>`.
9. يخلق `plato-printer.zip`.

## محتويات الإصدار

```txt theme={null}
plato-printer.exe
config.json
assets/
  caddy/
  certs/
redis-binaries/
```

## الإصدار

`src/version.ts` يحتوي على:

```ts theme={null}
export const BUILD_VERSION = 66;
```

يتم إرجاع إصدار البنية بواسطة `GET /health` وطباعته في شعار بدء التشغيل. لا تقم بتحرير هذا الملف يدوياً؛ يقوم `scripts/increment-version.js` بتحديثه أثناء `pnpm bundle`.

## تحضير العلبة

تم تثبيت العلبة على `2.6.4`.

لتنزيل Caddy إلى `assets/caddy` قبل التجميع:

```sh theme={null}
pnpm --filter @plato/pc-printer exec node scripts/download-caddy.js
```

في حالة وجود `assets/caddy/caddy.exe`، يمكن لإعداد وقت التشغيل نسخه بدلاً من تنزيل Caddy على جهاز العميل.

## إعداد ثنائي Redis

يقرأ `scripts/prepare-redis-binaries.js` `config.json` ويقوم بتنزيل إصدار Windows Redis الذي تم تكوينه إذا كان مفقودًا.

المسار المتوقع هو :

```txt theme={null}
redis-binaries/<version>/Redis-<version>-Windows-x64-msys2/redis-server.exe
```

## اختبار الإجهاد

يبدأ اختبار التحمل في تشغيل طابعات TCP وهمية ويرسل العديد من طلبات `/print`.

```sh theme={null}
pnpm --filter @plato/pc-printer stress
```

خيارات مفيدة:

```sh theme={null}
node scripts/stress-test.js \
  --host http://127.0.0.1:8080 \
  --printers 5 \
  --jobs 100 \
  --base-port 9200 \
  --poll-ms 500 \
  --timeout-ms 60000
```

ينجح الاختبار عندما يتم استنزاف جميع قوائم الانتظار المستهدفة.

## قائمة مراجعة الإصدار

1. تأكد من صحة `config.json` للإصدار.
2. تأكد من وجود أصول العلبة إذا كان من المفترض أن يعمل HTTPS دون اتصال بالإنترنت.
3. قم بتشغيل `pnpm --filter @plato/pc-printer clean`.
4. قم بتشغيل `pnpm --filter @plato/pc-printer bundle`.
5. قم بتشغيل الملف القابل للتنفيذ من `output/`.
6. تحقق من `GET /health`.
7. قم بإجراء طباعة اختبارية حقيقية.
8. تحقق من أن `plato-printer.zip` يحتوي على الملفات المتوقعة.
