anl 1.7.6 → 1.7.8
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/README.ar.md +36 -5
- package/README.es.md +36 -5
- package/README.fr.md +36 -5
- package/README.jp.md +36 -5
- package/README.md +42 -10
- package/README.ru.md +36 -5
- package/README.zh.md +42 -10
- package/lib/package.json.js +1 -1
- package/lib/src/build-type/core/components.js +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/standard/const.js +1 -1
- package/lib/src/standard/install-commitlint.js +1 -1
- package/lib/src/standard/install-eslint.js +1 -1
- package/lib/src/standard/install-stylelint.js +1 -0
- package/lib/src/standard/lint-init.js +1 -1
- package/lib/src/standard/prettier.js +1 -1
- package/lib/src/standard/vscode.js +1 -1
- package/package.json +1 -1
package/README.ar.md
CHANGED
|
@@ -158,7 +158,6 @@ project/
|
|
|
158
158
|
│ │ ├── models/ # جميع ملفات تعريف الأنواع (باستثناء أنواع التعداد) غير مُتحكم به
|
|
159
159
|
│ │ ├── connectors/ # تعريفات نوع API (ملفات تعريف الواجهة) غير مُتحكم به
|
|
160
160
|
│ └── api/ # ملف الطلب: محدد بواسطة عنصر التكوين saveApiListFolderPath
|
|
161
|
-
│ │ ├── fetch.ts # تنفيذ طريقة الطلب غير مُتحكم به
|
|
162
161
|
│ │ └── index.ts # قائمة دوال طلبات API غير مُتحكم به
|
|
163
162
|
│ │ └── api-type.d.ts # ملف تعريف نوع الطلب غير مُتحكم به
|
|
164
163
|
│ │ └── config.ts # الطلب، اعتراض الاستجابة، تكوين الطلب غير مُتحكم به
|
|
@@ -335,16 +334,36 @@ export const uploadFile = (params: UploadFile.Body) =>
|
|
|
335
334
|
$ anl lint
|
|
336
335
|
```
|
|
337
336
|
|
|
337
|
+
بعد تنفيذ الأمر، ستظهر واجهة اختيار متعدد تفاعلية، يمكنك اختيار الأدوات التي تحتاج إلى تثبيتها:
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
? Select the linting tools to install (multi-select):
|
|
341
|
+
❯◯ ESLint - JavaScript/TypeScript linter
|
|
342
|
+
◯ Stylelint - CSS/SCSS/Less linter
|
|
343
|
+
◯ Commitlint - Git commit message linter
|
|
344
|
+
◯ Prettier - Code formatter
|
|
345
|
+
◯ VSCode - Editor settings
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
استخدم **مفتاح المسافة** للاختيار/إلغاء الاختيار، **مفتاح Enter** للتأكيد.
|
|
349
|
+
|
|
338
350
|
### تفاصيل التكوين
|
|
339
351
|
|
|
340
352
|
#### 1. تكوين ESLint
|
|
341
353
|
|
|
342
354
|
- تثبيت التبعيات المطلوبة تلقائيًا
|
|
343
|
-
- يدعم إطارات React/Vue
|
|
355
|
+
- يدعم إطارات React/Vue (سيُطلب منك اختيار إطار عمل إذا تم تحديده)
|
|
344
356
|
- توليد `.eslintrc.js` و `.eslintignore` تلقائيًا
|
|
345
357
|
- دمج دعم TypeScript
|
|
346
358
|
|
|
347
|
-
#### 2. تكوين
|
|
359
|
+
#### 2. تكوين Stylelint
|
|
360
|
+
|
|
361
|
+
- تثبيت التبعيات المتعلقة بـ stylelint تلقائيًا
|
|
362
|
+
- يدعم معالجات Less/Sass المسبقة (سيُطلب منك اختيار معالج مسبق إذا تم تحديده)
|
|
363
|
+
- توليد ملف تكوين `.stylelintrc.js`
|
|
364
|
+
- دمج دعم Prettier
|
|
365
|
+
|
|
366
|
+
#### 3. تكوين Prettier
|
|
348
367
|
|
|
349
368
|
- تثبيت التبعيات ذات الصلة بـ prettier تلقائيًا
|
|
350
369
|
- توليد ملف تكوين `.prettierrc.js`
|
|
@@ -355,20 +374,32 @@ $ anl lint
|
|
|
355
374
|
- أقواس دالة السهم
|
|
356
375
|
- معايير نمط الكود الأخرى
|
|
357
376
|
|
|
358
|
-
####
|
|
377
|
+
#### 4. تكوين CommitLint
|
|
359
378
|
|
|
360
379
|
- تثبيت التبعيات ذات الصلة بـ commitlint
|
|
361
380
|
- تكوين husky git hooks
|
|
362
381
|
- توليد `commitlint.config.js`
|
|
363
382
|
- توحيد رسالة git commit
|
|
364
383
|
|
|
365
|
-
####
|
|
384
|
+
#### 5. تكوين VSCode
|
|
366
385
|
|
|
367
386
|
- إنشاء `.vscode/settings.json`
|
|
368
387
|
- تكوين التنسيق التلقائي للمحرر
|
|
369
388
|
- تعيين أداة التنسيق الافتراضية
|
|
370
389
|
- يدعم تحديث ملفات التكوين الموجودة
|
|
371
390
|
|
|
391
|
+
### أمثلة الاستخدام
|
|
392
|
+
|
|
393
|
+
1. **تثبيت ESLint و Prettier فقط**
|
|
394
|
+
- اختر ESLint و Prettier
|
|
395
|
+
- إذا تم اختيار ESLint، سيُطلب منك اختيار إطار عمل (React/Vue)
|
|
396
|
+
- بعد التثبيت، سيحتوي مشروعك على `.eslintrc.js` و `.prettierrc.js`
|
|
397
|
+
|
|
398
|
+
2. **التكوين الكامل**
|
|
399
|
+
- اختر جميع الخيارات
|
|
400
|
+
- أكمل اختيار إطار العمل والمعالج المسبق
|
|
401
|
+
- سيتم تكوين نظام كامل لمعايير الكود في مشروعك
|
|
402
|
+
|
|
372
403
|
# أمر `anl git`
|
|
373
404
|
|
|
374
405
|
### نظرة عامة على الوظائف
|
package/README.es.md
CHANGED
|
@@ -156,7 +156,6 @@ project/
|
|
|
156
156
|
│ │ ├── models/ # Todos los archivos de definición de tipos (sin incluir tipos enum) no controlado
|
|
157
157
|
│ │ ├── connectors/ # Definiciones de tipos API (archivos de definición de interfaz) no controlado
|
|
158
158
|
│ └── api/ # Archivos de solicitud: especificado por el elemento de configuración saveApiListFolderPath
|
|
159
|
-
│ │ ├── fetch.ts # Implementación de métodos de solicitud no controlado
|
|
160
159
|
│ │ └── index.ts # Lista de funciones de solicitud API no controlado
|
|
161
160
|
│ │ └── api-type.d.ts # Archivo de definición de tipos de solicitud no controlado
|
|
162
161
|
│ │ └── config.ts # Solicitud, interceptor de respuesta, configuración de solicitud no controlado
|
|
@@ -333,16 +332,36 @@ Nota: `includeInterface` y `excludeInterface` no se pueden usar simultáneamente
|
|
|
333
332
|
$ anl lint
|
|
334
333
|
```
|
|
335
334
|
|
|
335
|
+
Después de ejecutar el comando, aparecerá una interfaz de selección múltiple interactiva donde puedes elegir las herramientas a instalar:
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
? Select the linting tools to install (multi-select):
|
|
339
|
+
❯◯ ESLint - JavaScript/TypeScript linter
|
|
340
|
+
◯ Stylelint - CSS/SCSS/Less linter
|
|
341
|
+
◯ Commitlint - Git commit message linter
|
|
342
|
+
◯ Prettier - Code formatter
|
|
343
|
+
◯ VSCode - Editor settings
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Usa la **barra espaciadora** para seleccionar/deseleccionar, **Enter** para confirmar.
|
|
347
|
+
|
|
336
348
|
### Detalles de Configuración
|
|
337
349
|
|
|
338
350
|
#### 1. Configuración ESLint
|
|
339
351
|
|
|
340
352
|
- Instalación automática de dependencias necesarias
|
|
341
|
-
- Soporte para frameworks React/Vue
|
|
353
|
+
- Soporte para frameworks React/Vue (se te pedirá que elijas un framework si se selecciona)
|
|
342
354
|
- Generación automática de `.eslintrc.js` y `.eslintignore`
|
|
343
355
|
- Integración de soporte TypeScript
|
|
344
356
|
|
|
345
|
-
#### 2. Configuración
|
|
357
|
+
#### 2. Configuración Stylelint
|
|
358
|
+
|
|
359
|
+
- Instalación automática de dependencias relacionadas con stylelint
|
|
360
|
+
- Soporte para preprocesadores Less/Sass (se te pedirá que elijas un preprocesador si se selecciona)
|
|
361
|
+
- Generación del archivo de configuración `.stylelintrc.js`
|
|
362
|
+
- Integración de soporte Prettier
|
|
363
|
+
|
|
364
|
+
#### 3. Configuración Prettier
|
|
346
365
|
|
|
347
366
|
- Instalación automática de dependencias relacionadas con prettier
|
|
348
367
|
- Generación del archivo de configuración `.prettierrc.js`
|
|
@@ -353,20 +372,32 @@ $ anl lint
|
|
|
353
372
|
- Paréntesis en funciones flecha
|
|
354
373
|
- Otras especificaciones de estilo de código
|
|
355
374
|
|
|
356
|
-
####
|
|
375
|
+
#### 4. Configuración CommitLint
|
|
357
376
|
|
|
358
377
|
- Instalación de dependencias relacionadas con commitlint
|
|
359
378
|
- Configuración de git hooks de husky
|
|
360
379
|
- Generación de `commitlint.config.js`
|
|
361
380
|
- Estandarización de mensajes git commit
|
|
362
381
|
|
|
363
|
-
####
|
|
382
|
+
#### 5. Configuración VSCode
|
|
364
383
|
|
|
365
384
|
- Creación de `.vscode/settings.json`
|
|
366
385
|
- Configuración de formateo automático del editor
|
|
367
386
|
- Configuración de herramienta de formateo predeterminada
|
|
368
387
|
- Soporte para actualización de archivos de configuración existentes
|
|
369
388
|
|
|
389
|
+
### Ejemplos de Uso
|
|
390
|
+
|
|
391
|
+
1. **Instalar solo ESLint y Prettier**
|
|
392
|
+
- Selecciona ESLint y Prettier
|
|
393
|
+
- Si se selecciona ESLint, se te pedirá que elijas un framework (React/Vue)
|
|
394
|
+
- Después de la instalación, tu proyecto tendrá `.eslintrc.js` y `.prettierrc.js`
|
|
395
|
+
|
|
396
|
+
2. **Configuración Completa**
|
|
397
|
+
- Selecciona todas las opciones
|
|
398
|
+
- Completa las selecciones de framework y preprocesador
|
|
399
|
+
- Tu proyecto tendrá un sistema completo de estándares de código configurado
|
|
400
|
+
|
|
370
401
|
# Comando `anl git`
|
|
371
402
|
|
|
372
403
|
### Descripción General de Funciones
|
package/README.fr.md
CHANGED
|
@@ -158,7 +158,6 @@ project/
|
|
|
158
158
|
│ │ ├── models/ # Tous les fichiers de définition de types (excluant les types enum) non contrôlé
|
|
159
159
|
│ │ ├── connectors/ # Définitions de types API (fichiers de définition d'interface) non contrôlé
|
|
160
160
|
│ └── api/ # Fichiers de requête : Spécifié par l'élément de configuration saveApiListFolderPath
|
|
161
|
-
│ │ ├── fetch.ts # Implémentation des méthodes de requête non contrôlé
|
|
162
161
|
│ │ └── index.ts # Liste des fonctions de requête API non contrôlé
|
|
163
162
|
│ │ └── api-type.d.ts # Fichier de définition de types de requête non contrôlé
|
|
164
163
|
│ │ └── config.ts # Configuration de requête, interception de requête/réponse non contrôlé
|
|
@@ -335,16 +334,36 @@ Note : `includeInterface` et `excludeInterface` ne peuvent pas être utilisés s
|
|
|
335
334
|
$ anl lint
|
|
336
335
|
```
|
|
337
336
|
|
|
337
|
+
Après l'exécution de la commande, une interface de sélection multiple interactive apparaîtra où vous pourrez choisir les outils à installer :
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
? Select the linting tools to install (multi-select):
|
|
341
|
+
❯◯ ESLint - JavaScript/TypeScript linter
|
|
342
|
+
◯ Stylelint - CSS/SCSS/Less linter
|
|
343
|
+
◯ Commitlint - Git commit message linter
|
|
344
|
+
◯ Prettier - Code formatter
|
|
345
|
+
◯ VSCode - Editor settings
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Utilisez la **barre d'espace** pour sélectionner/désélectionner, **Entrée** pour confirmer.
|
|
349
|
+
|
|
338
350
|
### Détails de configuration
|
|
339
351
|
|
|
340
352
|
#### 1. Configuration ESLint
|
|
341
353
|
|
|
342
354
|
- Installation automatique des dépendances nécessaires
|
|
343
|
-
- Support des frameworks React/Vue
|
|
355
|
+
- Support des frameworks React/Vue (vous serez invité à choisir un framework si sélectionné)
|
|
344
356
|
- Génération automatique de `.eslintrc.js` et `.eslintignore`
|
|
345
357
|
- Support TypeScript intégré
|
|
346
358
|
|
|
347
|
-
#### 2. Configuration
|
|
359
|
+
#### 2. Configuration Stylelint
|
|
360
|
+
|
|
361
|
+
- Installation automatique des dépendances liées à stylelint
|
|
362
|
+
- Support des préprocesseurs Less/Sass (vous serez invité à choisir un préprocesseur si sélectionné)
|
|
363
|
+
- Génération du fichier de configuration `.stylelintrc.js`
|
|
364
|
+
- Support Prettier intégré
|
|
365
|
+
|
|
366
|
+
#### 3. Configuration Prettier
|
|
348
367
|
|
|
349
368
|
- Installation automatique des dépendances prettier associées
|
|
350
369
|
- Génération du fichier de configuration `.prettierrc.js`
|
|
@@ -355,20 +374,32 @@ $ anl lint
|
|
|
355
374
|
- Parenthèses des fonctions fléchées
|
|
356
375
|
- Autres normes de style de code
|
|
357
376
|
|
|
358
|
-
####
|
|
377
|
+
#### 4. Configuration CommitLint
|
|
359
378
|
|
|
360
379
|
- Installation des dépendances commitlint associées
|
|
361
380
|
- Configuration des hooks git husky
|
|
362
381
|
- Génération de `commitlint.config.js`
|
|
363
382
|
- Normalisation des messages git commit
|
|
364
383
|
|
|
365
|
-
####
|
|
384
|
+
#### 5. Configuration VSCode
|
|
366
385
|
|
|
367
386
|
- Création de `.vscode/settings.json`
|
|
368
387
|
- Configuration du formatage automatique de l'éditeur
|
|
369
388
|
- Définition de l'outil de formatage par défaut
|
|
370
389
|
- Support de la mise à jour des fichiers de configuration existants
|
|
371
390
|
|
|
391
|
+
### Exemples d'utilisation
|
|
392
|
+
|
|
393
|
+
1. **Installer uniquement ESLint et Prettier**
|
|
394
|
+
- Sélectionnez ESLint et Prettier
|
|
395
|
+
- Si ESLint est sélectionné, vous serez invité à choisir un framework (React/Vue)
|
|
396
|
+
- Après l'installation, votre projet aura `.eslintrc.js` et `.prettierrc.js`
|
|
397
|
+
|
|
398
|
+
2. **Configuration complète**
|
|
399
|
+
- Sélectionnez toutes les options
|
|
400
|
+
- Complétez les sélections de framework et de préprocesseur
|
|
401
|
+
- Votre projet aura un système complet de normes de code configuré
|
|
402
|
+
|
|
372
403
|
# Commande `anl git`
|
|
373
404
|
|
|
374
405
|
### Aperçu des fonctionnalités
|
package/README.jp.md
CHANGED
|
@@ -158,7 +158,6 @@ project/
|
|
|
158
158
|
│ │ ├── models/ # すべての型定義ファイル(列挙型を除く)制御外
|
|
159
159
|
│ │ ├── connectors/ # API 型定義(インターフェース定義ファイル)制御外
|
|
160
160
|
│ └── api/ # リクエストファイル:saveApiListFolderPath 設定項目で指定
|
|
161
|
-
│ │ ├── fetch.ts # リクエストメソッド実装 制御外
|
|
162
161
|
│ │ └── index.ts # API リクエスト関数リスト 制御外
|
|
163
162
|
│ │ └── api-type.d.ts # リクエスト型定義ファイル 制御外
|
|
164
163
|
│ │ └── config.ts # リクエスト、レスポンスインターセプター、リクエスト設定 制御外
|
|
@@ -335,16 +334,36 @@ export const uploadFile = (params: UploadFile.Body) =>
|
|
|
335
334
|
$ anl lint
|
|
336
335
|
```
|
|
337
336
|
|
|
337
|
+
コマンドを実行すると、インタラクティブな複数選択インターフェースが表示され、インストールするツールを選択できます:
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
? Select the linting tools to install (multi-select):
|
|
341
|
+
❯◯ ESLint - JavaScript/TypeScript linter
|
|
342
|
+
◯ Stylelint - CSS/SCSS/Less linter
|
|
343
|
+
◯ Commitlint - Git commit message linter
|
|
344
|
+
◯ Prettier - Code formatter
|
|
345
|
+
◯ VSCode - Editor settings
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**スペースキー**で選択/選択解除、**Enter**で確認します。
|
|
349
|
+
|
|
338
350
|
### 設定の詳細
|
|
339
351
|
|
|
340
352
|
#### 1. ESLint 設定
|
|
341
353
|
|
|
342
354
|
- 必要な依存関係を自動インストール
|
|
343
|
-
- React/Vue
|
|
355
|
+
- React/Vue フレームワークをサポート(選択時にフレームワークの選択を求められます)
|
|
344
356
|
- `.eslintrc.js` と `.eslintignore` を自動生成
|
|
345
357
|
- TypeScript サポートを統合
|
|
346
358
|
|
|
347
|
-
#### 2.
|
|
359
|
+
#### 2. Stylelint 設定
|
|
360
|
+
|
|
361
|
+
- stylelint 関連の依存関係を自動インストール
|
|
362
|
+
- Less/Sass プリプロセッサをサポート(選択時にプリプロセッサの選択を求められます)
|
|
363
|
+
- `.stylelintrc.js` 設定ファイルを生成
|
|
364
|
+
- Prettier サポートを統合
|
|
365
|
+
|
|
366
|
+
#### 3. Prettier 設定
|
|
348
367
|
|
|
349
368
|
- prettier 関連の依存関係を自動インストール
|
|
350
369
|
- `.prettierrc.js` 設定ファイルを生成
|
|
@@ -355,20 +374,32 @@ $ anl lint
|
|
|
355
374
|
- アロー関数の括弧
|
|
356
375
|
- その他のコードスタイル規約
|
|
357
376
|
|
|
358
|
-
####
|
|
377
|
+
#### 4. CommitLint 設定
|
|
359
378
|
|
|
360
379
|
- commitlint 関連の依存関係をインストール
|
|
361
380
|
- husky git hooks を設定
|
|
362
381
|
- `commitlint.config.js` を生成
|
|
363
382
|
- git commit メッセージを標準化
|
|
364
383
|
|
|
365
|
-
####
|
|
384
|
+
#### 5. VSCode 設定
|
|
366
385
|
|
|
367
386
|
- `.vscode/settings.json` を作成
|
|
368
387
|
- エディタの自動フォーマットを設定
|
|
369
388
|
- デフォルトのフォーマットツールを設定
|
|
370
389
|
- 既存の設定ファイルの更新をサポート
|
|
371
390
|
|
|
391
|
+
### 使用例
|
|
392
|
+
|
|
393
|
+
1. **ESLint と Prettier のみをインストール**
|
|
394
|
+
- ESLint と Prettier を選択
|
|
395
|
+
- ESLint を選択した場合、フレームワーク(React/Vue)の選択を求められます
|
|
396
|
+
- インストール後、プロジェクトに `.eslintrc.js` と `.prettierrc.js` が作成されます
|
|
397
|
+
|
|
398
|
+
2. **完全な設定**
|
|
399
|
+
- すべてのオプションを選択
|
|
400
|
+
- フレームワークとプリプロセッサの選択を完了
|
|
401
|
+
- プロジェクトに完全なコード規約システムが設定されます
|
|
402
|
+
|
|
372
403
|
# `anl git` コマンド
|
|
373
404
|
|
|
374
405
|
### 機能概要
|
package/README.md
CHANGED
|
@@ -156,7 +156,6 @@ project/
|
|
|
156
156
|
│ │ ├── models/ # All type definition files (excluding enum types) uncontrolled
|
|
157
157
|
│ │ ├── connectors/ # API type definitions (interface definition files) uncontrolled
|
|
158
158
|
│ └── api/ # Request files: Specified by saveApiListFolderPath configuration item
|
|
159
|
-
│ │ ├── fetch.ts # Request method implementation uncontrolled
|
|
160
159
|
│ │ └── index.ts # API request function list uncontrolled
|
|
161
160
|
│ │ └── api-type.d.ts # Request type definition file uncontrolled
|
|
162
161
|
│ │ └── config.ts # Request, response interceptor, request configuration uncontrolled
|
|
@@ -320,12 +319,13 @@ Note: `includeInterface` and `excludeInterface` cannot be used simultaneously. I
|
|
|
320
319
|
|
|
321
320
|
# `anl lint` Command Usage
|
|
322
321
|
|
|
323
|
-
> Provides
|
|
322
|
+
> Provides **interactive multi-select** configuration for various lint tools in frontend projects, including:
|
|
324
323
|
>
|
|
325
|
-
> - ESLint code
|
|
326
|
-
> -
|
|
327
|
-
> -
|
|
328
|
-
> -
|
|
324
|
+
> - ESLint - JavaScript/TypeScript code linting
|
|
325
|
+
> - Stylelint - CSS/SCSS/Less style linting
|
|
326
|
+
> - Prettier - Code formatting
|
|
327
|
+
> - CommitLint - Git commit message standards
|
|
328
|
+
> - VSCode - Editor configuration
|
|
329
329
|
|
|
330
330
|
### Usage Method
|
|
331
331
|
|
|
@@ -333,16 +333,36 @@ Note: `includeInterface` and `excludeInterface` cannot be used simultaneously. I
|
|
|
333
333
|
$ anl lint
|
|
334
334
|
```
|
|
335
335
|
|
|
336
|
+
After executing the command, an interactive multi-select interface will appear where you can choose the tools to install:
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
? Select the linting tools to install (multi-select):
|
|
340
|
+
❯◯ ESLint - JavaScript/TypeScript linter
|
|
341
|
+
◯ Stylelint - CSS/SCSS/Less linter
|
|
342
|
+
◯ Commitlint - Git commit message linter
|
|
343
|
+
◯ Prettier - Code formatter
|
|
344
|
+
◯ VSCode - Editor settings
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Use **spacebar** to select/deselect, **Enter** to confirm.
|
|
348
|
+
|
|
336
349
|
### Configuration Details
|
|
337
350
|
|
|
338
351
|
#### 1. ESLint Configuration
|
|
339
352
|
|
|
340
353
|
- Automatically installs required dependencies
|
|
341
|
-
- Supports React/Vue frameworks
|
|
354
|
+
- Supports React/Vue frameworks (you'll be prompted to choose a framework if selected)
|
|
342
355
|
- Automatically generates `.eslintrc.js` and `.eslintignore`
|
|
343
356
|
- Integrates TypeScript support
|
|
344
357
|
|
|
345
|
-
#### 2.
|
|
358
|
+
#### 2. Stylelint Configuration
|
|
359
|
+
|
|
360
|
+
- Automatically installs stylelint related dependencies
|
|
361
|
+
- Supports Less/Sass preprocessors (you'll be prompted to choose a preprocessor if selected)
|
|
362
|
+
- Generates `.stylelintrc.js` configuration file
|
|
363
|
+
- Integrates Prettier support
|
|
364
|
+
|
|
365
|
+
#### 3. Prettier Configuration
|
|
346
366
|
|
|
347
367
|
- Automatically installs prettier related dependencies
|
|
348
368
|
- Generates `.prettierrc.js` configuration file
|
|
@@ -353,20 +373,32 @@ $ anl lint
|
|
|
353
373
|
- Arrow function parentheses
|
|
354
374
|
- Other code style standards
|
|
355
375
|
|
|
356
|
-
####
|
|
376
|
+
#### 4. CommitLint Configuration
|
|
357
377
|
|
|
358
378
|
- Installs commitlint related dependencies
|
|
359
379
|
- Configures husky git hooks
|
|
360
380
|
- Generates `commitlint.config.js`
|
|
361
381
|
- Standardizes git commit messages
|
|
362
382
|
|
|
363
|
-
####
|
|
383
|
+
#### 5. VSCode Configuration
|
|
364
384
|
|
|
365
385
|
- Creates `.vscode/settings.json`
|
|
366
386
|
- Configures editor auto-formatting
|
|
367
387
|
- Sets default formatting tools
|
|
368
388
|
- Supports updating existing configuration files
|
|
369
389
|
|
|
390
|
+
### Usage Examples
|
|
391
|
+
|
|
392
|
+
1. **Install ESLint and Prettier Only**
|
|
393
|
+
- Select ESLint and Prettier
|
|
394
|
+
- If ESLint is selected, you'll be prompted to choose a framework (React/Vue)
|
|
395
|
+
- After installation, your project will have `.eslintrc.js` and `.prettierrc.js`
|
|
396
|
+
|
|
397
|
+
2. **Full Configuration**
|
|
398
|
+
- Select all options
|
|
399
|
+
- Complete the framework and preprocessor selection prompts
|
|
400
|
+
- Your project will have a complete code standards system configured
|
|
401
|
+
|
|
370
402
|
# `anl git` Command
|
|
371
403
|
|
|
372
404
|
### Feature Overview
|
package/README.ru.md
CHANGED
|
@@ -158,7 +158,6 @@ project/
|
|
|
158
158
|
│ │ ├── models/ # Все файлы определений типов (не включая типы enum) неконтролируемые
|
|
159
159
|
│ │ ├── connectors/ # Определения типов API (файлы определений интерфейсов) неконтролируемые
|
|
160
160
|
│ └── api/ # Файлы запросов: указывается элементом конфигурации saveApiListFolderPath
|
|
161
|
-
│ │ ├── fetch.ts # Реализация методов запросов неконтролируемая
|
|
162
161
|
│ │ └── index.ts # Список функций API-запросов неконтролируемый
|
|
163
162
|
│ │ └── api-type.d.ts # Файл определений типов запросов неконтролируемый
|
|
164
163
|
│ │ └── config.ts # Конфигурация запросов, перехватчиков ответов, конфигурация запросов неконтролируемая
|
|
@@ -335,16 +334,36 @@ export const uploadFile = (params: UploadFile.Body) =>
|
|
|
335
334
|
$ anl lint
|
|
336
335
|
```
|
|
337
336
|
|
|
337
|
+
После выполнения команды появится интерактивный интерфейс множественного выбора, где вы можете выбрать инструменты для установки:
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
? Select the linting tools to install (multi-select):
|
|
341
|
+
❯◯ ESLint - JavaScript/TypeScript linter
|
|
342
|
+
◯ Stylelint - CSS/SCSS/Less linter
|
|
343
|
+
◯ Commitlint - Git commit message linter
|
|
344
|
+
◯ Prettier - Code formatter
|
|
345
|
+
◯ VSCode - Editor settings
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Используйте **пробел** для выбора/отмены выбора, **Enter** для подтверждения.
|
|
349
|
+
|
|
338
350
|
### Детали конфигурации
|
|
339
351
|
|
|
340
352
|
#### 1. Конфигурация ESLint
|
|
341
353
|
|
|
342
354
|
- Автоматическая установка необходимых зависимостей
|
|
343
|
-
- Поддержка фреймворков React/Vue
|
|
355
|
+
- Поддержка фреймворков React/Vue (вам будет предложено выбрать фреймворк при выборе)
|
|
344
356
|
- Автоматическая генерация `.eslintrc.js` и `.eslintignore`
|
|
345
357
|
- Интеграция поддержки TypeScript
|
|
346
358
|
|
|
347
|
-
#### 2. Конфигурация
|
|
359
|
+
#### 2. Конфигурация Stylelint
|
|
360
|
+
|
|
361
|
+
- Автоматическая установка зависимостей stylelint
|
|
362
|
+
- Поддержка препроцессоров Less/Sass (вам будет предложено выбрать препроцессор при выборе)
|
|
363
|
+
- Генерация файла конфигурации `.stylelintrc.js`
|
|
364
|
+
- Интеграция поддержки Prettier
|
|
365
|
+
|
|
366
|
+
#### 3. Конфигурация Prettier
|
|
348
367
|
|
|
349
368
|
- Автоматическая установка зависимостей prettier
|
|
350
369
|
- Генерация файла конфигурации `.prettierrc.js`
|
|
@@ -355,20 +374,32 @@ $ anl lint
|
|
|
355
374
|
- Скобки стрелочных функций
|
|
356
375
|
- Другие стандарты стиля кода
|
|
357
376
|
|
|
358
|
-
####
|
|
377
|
+
#### 4. Конфигурация CommitLint
|
|
359
378
|
|
|
360
379
|
- Установка зависимостей commitlint
|
|
361
380
|
- Настройка git hooks husky
|
|
362
381
|
- Генерация `commitlint.config.js`
|
|
363
382
|
- Стандартизация сообщений git commit
|
|
364
383
|
|
|
365
|
-
####
|
|
384
|
+
#### 5. Конфигурация VSCode
|
|
366
385
|
|
|
367
386
|
- Создание `.vscode/settings.json`
|
|
368
387
|
- Конфигурация автоматического форматирования редактора
|
|
369
388
|
- Настройка инструмента форматирования по умолчанию
|
|
370
389
|
- Поддержка обновления существующих файлов конфигурации
|
|
371
390
|
|
|
391
|
+
### Примеры использования
|
|
392
|
+
|
|
393
|
+
1. **Установить только ESLint и Prettier**
|
|
394
|
+
- Выберите ESLint и Prettier
|
|
395
|
+
- Если выбран ESLint, вам будет предложено выбрать фреймворк (React/Vue)
|
|
396
|
+
- После установки в вашем проекте будут `.eslintrc.js` и `.prettierrc.js`
|
|
397
|
+
|
|
398
|
+
2. **Полная конфигурация**
|
|
399
|
+
- Выберите все опции
|
|
400
|
+
- Завершите выбор фреймворка и препроцессора
|
|
401
|
+
- В вашем проекте будет настроена полная система стандартов кода
|
|
402
|
+
|
|
372
403
|
# Команда `anl git`
|
|
373
404
|
|
|
374
405
|
### Обзор функций
|
package/README.zh.md
CHANGED
|
@@ -158,7 +158,6 @@ project/
|
|
|
158
158
|
│ │ ├── models/ # 所有类型定义文件(不包含枚举类型) 不受控
|
|
159
159
|
│ │ ├── connectors/ # API 类型定义(接口定义文件)不受控
|
|
160
160
|
│ └── api/ # 请求文件:由 saveApiListFolderPath 配置项指定
|
|
161
|
-
│ │ ├── fetch.ts # 请求方法实现 不受控
|
|
162
161
|
│ │ └── index.ts # API 请求函数列表 不受控
|
|
163
162
|
│ │ └── api-type.d.ts # 请求类型定义文件 不受控
|
|
164
163
|
│ │ └── config.ts # 请求、响应拦截、请求配置 不受控
|
|
@@ -322,12 +321,13 @@ export const uploadFile = (params: UploadFile.Body) =>
|
|
|
322
321
|
|
|
323
322
|
# `anl lint` 命令使用说明
|
|
324
323
|
|
|
325
|
-
>
|
|
324
|
+
> 提供**交互式多选**配置前端项目各种 lint 工具的功能,包括:
|
|
326
325
|
>
|
|
327
|
-
> - ESLint 代码检查
|
|
328
|
-
> -
|
|
329
|
-
> -
|
|
330
|
-
> -
|
|
326
|
+
> - ESLint - JavaScript/TypeScript 代码检查
|
|
327
|
+
> - Stylelint - CSS/SCSS/Less 样式检查
|
|
328
|
+
> - Prettier - 代码格式化
|
|
329
|
+
> - CommitLint - Git 提交信息规范
|
|
330
|
+
> - VSCode - 编辑器配置
|
|
331
331
|
|
|
332
332
|
### 使用方法
|
|
333
333
|
|
|
@@ -335,16 +335,36 @@ export const uploadFile = (params: UploadFile.Body) =>
|
|
|
335
335
|
$ anl lint
|
|
336
336
|
```
|
|
337
337
|
|
|
338
|
+
执行命令后,会出现交互式多选界面,你可以选择需要安装的工具:
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
? Select the linting tools to install (multi-select):
|
|
342
|
+
❯◯ ESLint - JavaScript/TypeScript linter
|
|
343
|
+
◯ Stylelint - CSS/SCSS/Less linter
|
|
344
|
+
◯ Commitlint - Git commit message linter
|
|
345
|
+
◯ Prettier - Code formatter
|
|
346
|
+
◯ VSCode - Editor settings
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
使用 **空格键** 选择/取消选择,**回车键** 确认。
|
|
350
|
+
|
|
338
351
|
### 配置详情
|
|
339
352
|
|
|
340
353
|
#### 1. ESLint 配置
|
|
341
354
|
|
|
342
355
|
- 自动安装所需依赖
|
|
343
|
-
- 支持 React/Vue
|
|
356
|
+
- 支持 React/Vue 框架(选择后会提示选择框架)
|
|
344
357
|
- 自动生成 `.eslintrc.js` 和 `.eslintignore`
|
|
345
358
|
- 集成 TypeScript 支持
|
|
346
359
|
|
|
347
|
-
#### 2.
|
|
360
|
+
#### 2. Stylelint 配置
|
|
361
|
+
|
|
362
|
+
- 自动安装 stylelint 相关依赖
|
|
363
|
+
- 支持 Less/Sass 预处理器(选择后会提示选择预处理器)
|
|
364
|
+
- 生成 `.stylelintrc.js` 配置文件
|
|
365
|
+
- 集成 Prettier 支持
|
|
366
|
+
|
|
367
|
+
#### 3. Prettier 配置
|
|
348
368
|
|
|
349
369
|
- 自动安装 prettier 相关依赖
|
|
350
370
|
- 生成 `.prettierrc.js` 配置文件
|
|
@@ -355,20 +375,32 @@ $ anl lint
|
|
|
355
375
|
- 箭头函数括号
|
|
356
376
|
- 其他代码风格规范
|
|
357
377
|
|
|
358
|
-
####
|
|
378
|
+
#### 4. CommitLint 配置
|
|
359
379
|
|
|
360
380
|
- 安装 commitlint 相关依赖
|
|
361
381
|
- 配置 husky git hooks
|
|
362
382
|
- 生成 `commitlint.config.js`
|
|
363
383
|
- 规范化 git commit message
|
|
364
384
|
|
|
365
|
-
####
|
|
385
|
+
#### 5. VSCode 配置
|
|
366
386
|
|
|
367
387
|
- 创建 `.vscode/settings.json`
|
|
368
388
|
- 配置编辑器自动格式化
|
|
369
389
|
- 设置默认格式化工具
|
|
370
390
|
- 支持已有配置文件更新
|
|
371
391
|
|
|
392
|
+
### 使用示例
|
|
393
|
+
|
|
394
|
+
1. **只安装 ESLint 和 Prettier**
|
|
395
|
+
- 选择 ESLint 和 Prettier
|
|
396
|
+
- 如果选择了 ESLint,会提示选择框架(React/Vue)
|
|
397
|
+
- 安装完成后项目中会有 `.eslintrc.js` 和 `.prettierrc.js`
|
|
398
|
+
|
|
399
|
+
2. **完整配置**
|
|
400
|
+
- 选择所有选项
|
|
401
|
+
- 依次完成框架和预处理器的选择
|
|
402
|
+
- 项目将配置完整的代码规范体系
|
|
403
|
+
|
|
372
404
|
# `anl git` 命令
|
|
373
405
|
|
|
374
406
|
### 功能概述
|
package/lib/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="1.7.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="1.7.8",i="FE command line tool",s="bin/an-cli.js",p={dev:"rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript -w",build:"rimraf lib && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",pub:"bash publish.sh",ts:"tsc ./src/int.ts --noEmit --watch",blink:"npm run build && npm link","sync-docs":"node scripts/sync-docs.js"},l={anl:"bin/an-cli.js"},o="Gleason <bianliuzhu@gmail.com>",t={"@commitlint/cli":"^17.4.3","@commitlint/config-conventional":"^17.4.3","@rollup/plugin-commonjs":"^21.0.1","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^13.1.3","@rollup/plugin-typescript":"^8.3.0","@types/inquirer":"^9.0.7","@types/shelljs":"^0.8.11","@typescript-eslint/eslint-plugin":"^5.52.0","@typescript-eslint/parser":"^5.52.0","cross-env":"^7.0.3",eslint:"^8.7.0",husky:"^8.0.3","openapi-types":"^12.1.3",prettier:"^3.3.2",rimraf:"^5.0.7",rollup:"^2.64.0","rollup-plugin-cleandir":"^2.0.0","rollup-plugin-copy":"^3.5.0","rollup-plugin-terser":"^7.0.2",typescript:"^4.5.4"},r={"app-root-path":"^3.1.0",cac:"^6.7.12",chalk:"4.*","clear-console":"^1.1.0",commander:"14.0.1",figures:"^6.1.0",inquirer:"^10.1.8","log-symbols":"^5.1.0",ora:"5.*","progress-estimator":"^0.3.0",shelljs:"^0.8.5"},n=["typescript","cli","typescript 脚手架","ts 脚手架","ts-cli","脚手架"],c=["package.json","README.md","lib","template"],u={type:"git",url:"https://github.com/bianliuzhu/an-cli.git"},a="commonjs",m={name:"anl",version:e,description:i,main:s,scripts:p,bin:l,author:o,license:"ISC",devDependencies:t,dependencies:r,keywords:n,files:c,repository:u,type:a};exports.author=o,exports.bin=l,exports.default=m,exports.dependencies=r,exports.description=i,exports.devDependencies=t,exports.files=c,exports.keywords=n,exports.license="ISC",exports.main=s,exports.name="anl",exports.repository=u,exports.scripts=p,exports.type=a,exports.version=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../utils/index.js");const t="\t";exports.default=class{config;schemas={};enumsMap=new Map;schemasMap=new Map;defaultReturn={headerRef:"",renderStr:"",comment:"",typeName:""};requiredFieldS=[];constructor(e,t){this.schemas=e,this.config=t}nullable(e){return""+(e?" | null":"")}getEnumTypeName(e){return this.config.erasableSyntaxOnly?`${e}Type`:e}fieldComment(e){const{description:t}=e;if(t){return["\t","/**","\n",`\t * ${t}`,"\n","\t */"].join("")}return""}typeNameToFileName(e){return e.replace(/_/g,"-").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase().replace(/-+/g,"-")}nameTheHumpCenterStroke(e){const t=e.replace("#/components/schemas/",""),n={typeName:t,fileName:this.typeNameToFileName(t),dataType:""};if(this.schemas){const e=this.schemas[t];e.enum?n.dataType="enum":n.dataType=e.type}return n}parseRef(e){if(!e?.trim())return{headerRefStr:"",typeName:"",dataType:""};const{fileName:t,typeName:n,dataType:r=""}=this.nameTheHumpCenterStroke(e);let s;if("enum"===r){s=`import type { ${this.getEnumTypeName(n)} } from '${this.config.importEnumPath}';`}else s=`import type { ${n} } from './${t}';`;return{headerRefStr:s,typeName:n,dataType:r}}parseObject(e,n){let r="",s="";if("object"===e.type){const i=e;if("object"==typeof i.additionalProperties){const e=this.parseArray(i.additionalProperties,n)??this.defaultReturn;r=e?.headerRef??"",s=e?.renderStr??""}else s=`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: ${e.type}${this.nullable(e.nullable)};`}return{headerRef:r,renderStr:s}}parseArray(n,r){const s=n,{items:i={},nullable:a,example:o}=s,u=i?.$ref;if(u){const{headerRefStr:n,typeName:s,dataType:i}=this.parseRef(u);if("enum"===i&&e.isValidJSON(o)){const e=this.typeNameToFileName(s),t=this.convertJsonToEnumString(o,s);this.enumsMap.set(e,{fileName:e,content:t})}const l="enum"===i?this.getEnumTypeName(s):s;return{headerRef:n,renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: Array<${l}>${this.nullable(a)};`,typeName:l}}const l=i?.type,p="integer"===l?"number":l;return{headerRef:"",renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: Array<${p}>${this.nullable(a)};`,typeName:p}}parseBoolean(e,n){return"boolean"===e.type?`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: boolean${this.nullable(e.nullable)};`:""}parseEnum(e,n){if(!Array.isArray(e.enum))return null;if(this.config.erasableSyntaxOnly){if("integer"===e.type){return{headerRef:"",renderStr:[`export const ${n} = {`,...e.enum.map(e=>`${t}NUMBER_${e}: ${e},`),"} as const;","",`export type ${this.getEnumTypeName(n)} = typeof ${n}[keyof typeof ${n}];`].join("\n")}}if("string"===e.type){const r=e.enum.every(e=>!isNaN(Number(e)));return{headerRef:"",renderStr:[`export const ${n} = {`,...e.enum.map(e=>r?`${t}NUMBER_${e}: '${e}',`:`${t}${e.toUpperCase()}: '${e}',`),"} as const;","",`export type ${this.getEnumTypeName(n)} = typeof ${n}[keyof typeof ${n}];`].join("\n")}}}else{if("integer"===e.type){return{headerRef:"",renderStr:[`export enum ${n} {`,...e.enum.map(e=>`${t}NUMBER_${e} = ${e},`),"}"].join("\n")}}if("string"===e.type){const r=e.enum.every(e=>!isNaN(Number(e)));return{headerRef:"",renderStr:[`export enum ${n} {`,...e.enum.map(e=>r?`${t}NUMBER_${e} = '${e}',`:`${t}${e.toUpperCase()} = '${e}',`),"}"].join("\n")}}}return null}parseInteger(e,n){if(Array.isArray(e.enum)){const t=n.charAt(0).toUpperCase()+n.slice(1);return this.parseEnum(e,t)?.renderStr??""}return`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: number${this.nullable(e.nullable)};`}parseNumber(e,n){return"number"===e.type?`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: number${this.nullable(e.nullable)};`:""}convertJsonToEnumString(e,n){try{const r=JSON.parse(e);if(this.config.erasableSyntaxOnly){return`export const ${n} = {\n${Object.entries(r).map(([e,n])=>`${t}${e}: '${n}'`).join(",\n")}\n} as const;\n\nexport type ${this.getEnumTypeName(n)} = typeof ${n}[keyof typeof ${n}];`}return`export enum ${n} {\n${Object.entries(r).map(([e,n])=>`${t}${e} = '${n}'`).join(",\n")}\n}`}catch(e){return console.error("JSON 解析失败:",e),""}}parseString(n,r){if("string"===n.type){if(n.enum){const s=r.charAt(0).toUpperCase()+r.slice(1);if(e.isValidJSON(n.example)){const e=this.convertJsonToEnumString(n.example,s),i=this.getEnumTypeName(s);return{headerRef:"",renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: ${i}${this.nullable(n.nullable)};`,comment:e}}{const e=this.typeNameToFileName(s),t=this.parseEnum(n,s);if(t&&!this.enumsMap.has(e))return this.enumsMap.set(e,{fileName:e,content:t.renderStr}),{headerRef:"",renderStr:""}}}return{headerRef:"",renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: string${this.nullable(n.nullable)};`}}return null}parseProperties(n,r){const s=[],i=[];for(const a in n){const o=n[a];if(o?.$ref){const{headerRefStr:n,typeName:r,dataType:u}=this.parseRef(o.$ref);i.includes(n)||i.push(n);const l="enum"===u?this.getEnumTypeName(r):r;s.push(`${t}${a}${this.requiredFieldS.includes(a)?"":"?"}: ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../utils/index.js");const t="\t";exports.default=class{config;schemas={};enumsMap=new Map;schemasMap=new Map;defaultReturn={headerRef:"",renderStr:"",comment:"",typeName:""};requiredFieldS=[];constructor(e,t){this.schemas=e,this.config=t}nullable(e){return""+(e?" | null":"")}getEnumTypeName(e){return this.config.erasableSyntaxOnly?`${e}Type`:e}fieldComment(e){const{description:t}=e;if(t){return["\t","/**","\n",`\t * ${t}`,"\n","\t */"].join("")}return""}typeNameToFileName(e){return e.replace(/_/g,"-").replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase().replace(/-+/g,"-")}nameTheHumpCenterStroke(e){const t=e.replace("#/components/schemas/",""),n={typeName:t,fileName:this.typeNameToFileName(t),dataType:""};if(this.schemas){const e=this.schemas[t];e.enum?n.dataType="enum":n.dataType=e.type}return n}parseRef(e){if(!e?.trim())return{headerRefStr:"",typeName:"",dataType:""};const{fileName:t,typeName:n,dataType:r=""}=this.nameTheHumpCenterStroke(e);let s;if("enum"===r){s=`import type { ${this.getEnumTypeName(n)} } from '${this.config.importEnumPath}';`}else s=`import type { ${n} } from './${t}';`;return{headerRefStr:s,typeName:n,dataType:r}}parseObject(e,n){let r="",s="";if("object"===e.type){const i=e;if("object"==typeof i.additionalProperties){const e=this.parseArray(i.additionalProperties,n)??this.defaultReturn;r=e?.headerRef??"",s=e?.renderStr??""}else s=`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: ${e.type}${this.nullable(e.nullable)};`}return{headerRef:r,renderStr:s}}parseArray(n,r){const s=n,{items:i={},nullable:a,example:o}=s,u=i?.$ref;if(u){const{headerRefStr:n,typeName:s,dataType:i}=this.parseRef(u);if("enum"===i&&e.isValidJSON(o)){const e=this.typeNameToFileName(s),t=this.convertJsonToEnumString(o,s);this.enumsMap.set(e,{fileName:e,content:t})}const l="enum"===i?this.getEnumTypeName(s):s;return{headerRef:n,renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: Array<${l}>${this.nullable(a)};`,typeName:l}}const l=i?.type,p="integer"===l?"number":l;return{headerRef:"",renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: Array<${p}>${this.nullable(a)};`,typeName:p}}parseBoolean(e,n){return"boolean"===e.type?`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: boolean${this.nullable(e.nullable)};`:""}parseEnum(e,n){if(!Array.isArray(e.enum))return null;if(this.config.erasableSyntaxOnly){if("integer"===e.type){return{headerRef:"",renderStr:[`export const ${n} = {`,...e.enum.map(e=>`${t}NUMBER_${e}: ${e},`),"} as const;","",`export type ${this.getEnumTypeName(n)} = typeof ${n}[keyof typeof ${n}];`].join("\n")}}if("string"===e.type){const r=e.enum.every(e=>!isNaN(Number(e)));return{headerRef:"",renderStr:[`export const ${n} = {`,...e.enum.map(e=>r?`${t}NUMBER_${e}: '${e}',`:`${t}${e.toUpperCase()}: '${e}',`),"} as const;","",`export type ${this.getEnumTypeName(n)} = typeof ${n}[keyof typeof ${n}];`].join("\n")}}}else{if("integer"===e.type){return{headerRef:"",renderStr:[`export enum ${n} {`,...e.enum.map(e=>`${t}NUMBER_${e} = ${e},`),"}"].join("\n")}}if("string"===e.type){const r=e.enum.every(e=>!isNaN(Number(e)));return{headerRef:"",renderStr:[`export enum ${n} {`,...e.enum.map(e=>r?`${t}NUMBER_${e} = '${e}',`:`${t}${e.toUpperCase()} = '${e}',`),"}"].join("\n")}}}return null}parseInteger(e,n){if(Array.isArray(e.enum)){const t=n.charAt(0).toUpperCase()+n.slice(1);return this.parseEnum(e,t)?.renderStr??""}return`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: number${this.nullable(e.nullable)};`}parseNumber(e,n){return"number"===e.type?`${t}${n}${this.requiredFieldS.includes(n)?"":"?"}: number${this.nullable(e.nullable)};`:""}convertJsonToEnumString(e,n){try{const r=JSON.parse(e);if(this.config.erasableSyntaxOnly){return`export const ${n} = {\n${Object.entries(r).map(([e,n])=>`${t}${e}: '${n}'`).join(",\n")}\n} as const;\n\nexport type ${this.getEnumTypeName(n)} = typeof ${n}[keyof typeof ${n}];`}return`export enum ${n} {\n${Object.entries(r).map(([e,n])=>`${t}${e} = '${n}'`).join(",\n")}\n}`}catch(e){return console.error("JSON 解析失败:",e),""}}parseString(n,r){if("string"===n.type){if(n.enum){const s=r.charAt(0).toUpperCase()+r.slice(1);if(e.isValidJSON(n.example)){const e=this.convertJsonToEnumString(n.example,s),i=this.getEnumTypeName(s);return{headerRef:"",renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: ${i}${this.nullable(n.nullable)};`,comment:e}}{const e=this.typeNameToFileName(s),t=this.parseEnum(n,s);if(t&&!this.enumsMap.has(e))return this.enumsMap.set(e,{fileName:e,content:t.renderStr}),{headerRef:"",renderStr:""}}}return{headerRef:"",renderStr:`${t}${r}${this.requiredFieldS.includes(r)?"":"?"}: string${this.nullable(n.nullable)};`}}return null}parseProperties(n,r){const s=[],i=[];for(const a in n){const o=n[a];if(o?.$ref){const{headerRefStr:n,typeName:r,dataType:u}=this.parseRef(o.$ref);i.includes(n)||i.push(n);const l=o,p=this.fieldComment(l);""!==p&&s.push(p);const c="enum"===u?this.getEnumTypeName(r):r;s.push(`${t}${a}${this.requiredFieldS.includes(a)?"":"?"}: ${c};`);const h=o.example;if("enum"===u&&h&&e.isValidJSON(h)){const e=this.typeNameToFileName(r),t=this.convertJsonToEnumString(h,r);this.enumsMap.set(e,{fileName:e,content:t})}continue}if("allOf"in o){const e=o.allOf?.[0];if(e?.$ref){const{headerRefStr:n,typeName:r}=this.parseRef(e.$ref);i.includes(n)||i.push(n);const u=o,l=this.fieldComment(u);""!==l&&s.push(l),s.push(`${t}${a}${this.requiredFieldS.includes(a)?"":"?"}: ${r}${this.nullable(o.nullable)};`);continue}}const u=o,l=this.fieldComment(u);switch(""!==l&&s.push(l),u.type){case"array":{const e=this.parseArray(u,a)??this.defaultReturn;s.push(e?.renderStr??""),i.includes(e.headerRef)||r===e.typeName||i.push(e.headerRef)}break;case"boolean":s.push(this.parseBoolean(u,a));break;case"integer":s.push(this.parseInteger(u,a));break;case"number":s.push(this.parseNumber(u,a));break;case"string":if(u.enum){const n=a.charAt(0).toUpperCase()+a.slice(1);if(u.example&&e.isValidJSON(u.example)){const e=this.getEnumTypeName(n),r=`import type { ${e} } from '${this.config.importEnumPath}';`;i.includes(r)||i.push(r);const o=this.typeNameToFileName(n);if(!this.enumsMap.has(o)){const e=this.convertJsonToEnumString(u.example,n);this.enumsMap.set(o,{fileName:o,content:e})}s.push(`${t}${a}${this.requiredFieldS.includes(a)?"":"?"}: ${e}${this.nullable(u.nullable)};`)}else{const e=this.parseEnum(u,n);if(e?.renderStr){const r=this.getEnumTypeName(n),o=`import type { ${r} } from '${this.config.importEnumPath}';`;i.includes(o)||i.push(o);const l=this.typeNameToFileName(n);this.enumsMap.has(l)||this.enumsMap.set(l,{fileName:l,content:e.renderStr}),s.push(`${t}${a}${this.requiredFieldS.includes(a)?"":"?"}: ${r}${this.nullable(u.nullable)};`)}}}else s.push(this.parseString(u,a)?.renderStr??"");break;case"object":{const{headerRef:e,renderStr:t}=this.parseObject(u,a)??this.defaultReturn;s.push(t),i.includes(e)||i.push(e)}}}const a=[`export interface ${r} {`,...s,"}"];if(i.length>0){const e=i.filter(e=>""!==e);e.length>0&&e.push(""),a.unshift(...e)}const o=a.join("\n");return{headerRef:i.join("\n"),renderStr:o}}async generateContent(e,t){if("items"in e)return console.warn(`数组类型未处理: ${t}`,e.items),"";switch(e.type){case"boolean":return this.parseBoolean(e,t);case"integer":return this.parseInteger(e,t);case"number":return this.parseNumber(e,t);case"object":{const n=this.parseProperties(e.properties,t);return n?.renderStr??""}case"string":{const n=this.parseString(e,t);return n?.renderStr??""}default:return""}}async parseData(){try{if(!this.schemas)return void console.warn("schemas 为空");for(const[e,t]of Object.entries(this.schemas)){if("$ref"in t){console.warn(`跳过 ReferenceObject: ${e}`);continue}const n="type"in t?t:null;if(!n?.type){console.warn(`无效的 schema 对象: ${e}`);continue}this.requiredFieldS=t.required??[];const r=this.typeNameToFileName(e),s=await this.generateContent(n,e);if(s){(s.includes("export enum ")||s.includes("export const ")&&s.includes("as const"))&&!this.enumsMap.has(r)?this.enumsMap.set(r,{fileName:r,content:s}):this.schemasMap.set(e,{fileName:r,content:s})}}}catch(e){throw console.error("解析过程出错:",e),e}}async writeEnums(){const t=[],n=[];for(const[,r]of this.enumsMap){const s=async({fileName:t,content:r})=>{n.push(`export * from './${t}';`);const s=`${this.config.saveEnumFolderPath}/${t}.ts`;await e.writeFileRecursive(s,r),e.log.info(`${s.padEnd(80)} - Write done!`)};t.push(s(r))}await Promise.all(t),await e.writeFileRecursive(`${this.config.saveEnumFolderPath}/index.ts`,n.join("\n")),e.log.success("Enums write done!")}async writeFile(){const t=[],n=[],r=`${this.config.saveTypeFolderPath}/models/`;for(const[,s]of this.schemasMap){const i=async({fileName:t,content:s})=>{n.push(`export * from './${t}';`);const i=`${r}${t}.ts`;await e.writeFileRecursive(i,s),e.log.info(`${i.padEnd(80)} - Write done!`)};t.push(i(s))}await Promise.all(t),await e.writeFileRecursive(`${r}index.ts`,n.join("\n")),e.log.success("Component parse & write done!")}async handle(){await this.parseData(),await this.writeFile(),await this.writeEnums()}};
|
package/lib/src/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../node_modules/commander/esm.mjs.js"),i=require("../package.json.js"),t=require("./build-type/index.js"),a=require("./standard/lint-init.js"),n=require("./git-local-config/index.js"),o=require("../node_modules/inquirer/dist/esm/index.mjs.js");e.program.version(`${i.default.version}`,"-v --version").usage("<command> [options]"),e.program.command("type").description("auto interface").action(()=>{(new t.Main).initialize()}),e.program.command("lint").description("install eslint, prettier, commitlint").action(()=>a.lintHandle()),e.program.command("git").description("config git Local custom command").action(async()=>{const{features:e}=await o.default.prompt([{type:"checkbox",name:"features",message:"Select the required Git features (multi-select):",choices:[{name:"gitflow standard branch creation",value:"gitflow"},{name:"automatically set commit subject",value:"commitSubject"},{name:"custom git command",value:"customGitCommand"}],pageSize:10}]);n.gitHandle(e)}),e.program.parse(process.argv);
|
|
1
|
+
"use strict";var e=require("../node_modules/commander/esm.mjs.js"),i=require("../package.json.js"),t=require("./build-type/index.js"),a=require("./standard/lint-init.js"),n=require("./git-local-config/index.js"),o=require("../node_modules/inquirer/dist/esm/index.mjs.js");e.program.version(`${i.default.version}`,"-v --version").usage("<command> [options]"),e.program.command("type").description("auto interface").action(()=>{(new t.Main).initialize()}),e.program.command("lint").description("install linting tools (eslint, stylelint, prettier, commitlint, vscode)").action(()=>a.lintHandle()),e.program.command("git").description("config git Local custom command").action(async()=>{const{features:e}=await o.default.prompt([{type:"checkbox",name:"features",message:"Select the required Git features (multi-select):",choices:[{name:"gitflow standard branch creation",value:"gitflow"},{name:"automatically set commit subject",value:"commitSubject"},{name:"custom git command",value:"customGitCommand"}],pageSize:10}]);n.gitHandle(e)}),e.program.parse(process.argv);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.ADD_COMMIT_MSG="npx husky add .husky/commit-msg 'npx --no-install commitlint --edit \"$1\"'",exports.COMMIT_CONFIG_CONTENT="\nmodule.exports = {\n\textends: ['@commitlint/config-conventional']\n}",exports.COMMIT_VERIFY="npm install --save-dev @commitlint/cli @commitlint/config-conventional",exports.HUSKY_INSTALL="npx husky install",exports.NPM_HUSK="npm install husky --save-dev",exports.Prettier="npm install --save-dev --save-exact prettier eslint-config-prettier",exports.REACT_ESLINT="npm i eslint eslint-plugin-react@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest -D",exports.VUE_ESLINT="npm i eslint-plugin-vue@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest eslint@latest -D";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.ADD_COMMIT_MSG="npx husky add .husky/commit-msg 'npx --no-install commitlint --edit \"$1\"'",exports.COMMIT_CONFIG_CONTENT="\nmodule.exports = {\n\textends: ['@commitlint/config-conventional']\n}",exports.COMMIT_VERIFY="npm install --save-dev @commitlint/cli @commitlint/config-conventional",exports.HUSKY_INSTALL="npx husky install",exports.NPM_HUSK="npm install husky --save-dev",exports.Prettier="npm install --save-dev --save-exact prettier eslint-config-prettier",exports.REACT_ESLINT="npm i eslint eslint-plugin-react@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest -D",exports.StyleLint=(t="less")=>`npm i stylelint@^16.0.0 stylelint-${t}@latest stylelint-config-standard@latest stylelint-prettier@^5.0.0 -D`,exports.VUE_ESLINT="npm i eslint-plugin-vue@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest eslint@latest -D";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("path"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("path"),t=require("progress-estimator"),i=require("./const.js"),s=require("fs"),r=require("shelljs"),n=require("../utils/index.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const c=o(t).default({storagePath:e.join(__dirname,".progress-estimator")});exports.commitlintHanlde=async()=>{r.which("git")||(n.log.warning("Sorry, this script requires git"),r.exit(1));const e=new Promise((e,t)=>{try{r.exec(i.COMMIT_VERIFY,{silent:!0}),e({success:!0})}catch(e){t(e)}}),t=!0,o=new Promise((e,o)=>{try{r.exec(i.NPM_HUSK,{silent:t}),r.exec(i.HUSKY_INSTALL,{silent:t}),r.exec(i.ADD_COMMIT_MSG,{silent:t}),s.writeFileSync(`${process.cwd()}/commitlint.config.js`,i.COMMIT_CONFIG_CONTENT),e({success:!0})}catch(e){n.spinner.error("Commitlint installation failed!"),o(e)}});try{await c(e,"Install Commitlint",{estimate:1e4}),await c(o,"Setup Commitlint hooks and config")}catch(e){console.log("commitlintHanlde=====>",e)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("child_process"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("child_process"),r=require("fs"),s=require("path"),t=require("progress-estimator"),i=require("../utils/index.js"),n=require("./const.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=o(r);const l=o(t).default({storagePath:s.join(__dirname,".progress-estimator")}),a={env:{browser:!0,es2021:!0},extends:["eslint:recommended","plugin:react/recommended","plugin:@typescript-eslint/recommended","prettier"],overrides:[],parser:"@typescript-eslint/parser",parserOptions:{ecmaVersion:"latest",sourceType:"module"},plugins:["react","@typescript-eslint"],rules:{}},p={env:{browser:!0,es2021:!0},extends:["eslint:recommended","plugin:vue/vue3-essential","plugin:@typescript-eslint/recommended","prettier"],overrides:[],parser:"@typescript-eslint/parser",parserOptions:{ecmaVersion:"latest",sourceType:"module"},plugins:["vue","@typescript-eslint"],rules:{}};exports.eslintHandle=async r=>{const s="vue"===r?n.VUE_ESLINT:n.REACT_ESLINT,t="vue"===r?p:a,o=new Promise((r,t)=>{const n=e.exec(s,e=>{e&&(i.spinner.error(e.message),t(e))});n.stdout?.on("data",()=>{r({success:!0})}),n.stderr?.on("data",()=>{i.spinner.error("ESLint installation failed!"),t({success:!1})})}),u=new Promise((e,r)=>{try{const r=[".eslintrc.js",".prettierrc.js","commitlint.config.js"].join("\n");c.default.writeFileSync(`${process.cwd()}/.eslintignore`,r),c.default.writeFileSync(`${process.cwd()}/.eslintrc.js`,`module.exports = ${JSON.stringify(t,null,2)}`),e({success:!0})}catch(e){i.spinner.error(".eslintrc file creation failed!"),r(e)}});try{await l(o,"Install ESLint",{estimate:3e4}),await l(u,"Create ESLint config files")}catch(e){console.error("eslintHandle=====>",e)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),t=require("path"),r=require("child_process"),s=require("../utils/index.js"),n=require("./const.js"),i=require("progress-estimator");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=l(e);const a=l(i).default({storagePath:t.join(__dirname,".progress-estimator")});exports.styleLintHandle=async e=>{const t=new Promise((t,i)=>{const l=n.StyleLint(e),o=r.exec(l,e=>{e&&(s.spinner.error(`Stylelint installation failed: ${e.message}`),i(e))});o.stdout?.on("data",function(){t({success:!0})}),o.stderr?.on("data",function(e){s.spinner.error(e),i({success:!1})})}),i=new Promise((t,r)=>{const n=`module.exports = {\n\tplugins: ['stylelint-${e}', 'stylelint-prettier'],\n\textends: ['stylelint-config-standard', 'stylelint-prettier/recommended'],\n\trules: {\n\t\t'prettier/prettier': [true, { singleQuote: true, tabWidth: 2 }],\n\t\t'custom-property-pattern': null,\n\t},\n};`;o.default.writeFile(`${process.cwd()}/.stylelintrc.js`,n,e=>{if(e)return s.spinner.error(`.stylelintrc file creation failed: ${e.message}`),void r(e);t({success:!0})})});try{await a(t,"Install Stylelint",{estimate:1e4}),await a(i,"Create .stylelintrc file")}catch(e){console.error("styleLintHandle======>",e)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/inquirer/dist/esm/index.mjs.js"),t=require("./install-eslint.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/inquirer/dist/esm/index.mjs.js"),t=require("chalk"),i=require("./install-eslint.js"),s=require("./prettier.js"),l=require("./install-commitlint.js"),n=require("./vscode.js"),a=require("./install-stylelint.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(t);exports.lintHandle=function(){e.default.prompt([{type:"checkbox",name:"features",message:"Select the linting tools to install (multi-select):",choices:[{name:"ESLint - JavaScript/TypeScript linter",value:"eslint"},{name:"Stylelint - CSS/SCSS/Less linter",value:"stylelint"},{name:"Commitlint - Git commit message linter",value:"commitlint"},{name:"Prettier - Code formatter",value:"prettier"},{name:"VSCode - Editor settings",value:"vscode"}],pageSize:10}]).then(async t=>{const{features:r}=t;if(0===r.length)return void console.log("No tools selected. Exiting...");let c,u;if(r.includes("eslint")){c=(await e.default.prompt([{type:"list",message:"Choose the framework to use:",name:"framework",choices:["React","Vue"],filter:e=>e.toLowerCase()}])).framework}if(r.includes("stylelint")){u=(await e.default.prompt([{type:"list",message:"Choose the CSS preprocessor:",name:"css",choices:["Less","Sass"],filter:e=>e.toLowerCase()}])).css}r.includes("commitlint")&&await l.commitlintHanlde(),r.includes("prettier")&&await s.prettierHanlde(),r.includes("vscode")&&await n.default(),r.includes("eslint")&&c&&await i.eslintHandle(c),r.includes("stylelint")&&u&&await a.styleLintHandle(u),console.log(o.default.green("\n🎉 All selected tools have been installed successfully!\n"))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("child_process"),r=require("fs"),t=require("path"),s=require("progress-estimator"),i=require("../utils/index.js"),n=require("./const.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("child_process"),r=require("fs"),t=require("path"),s=require("progress-estimator"),i=require("../utils/index.js"),n=require("./const.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=a(s).default({storagePath:t.join(__dirname,".progress-estimator")});exports.prettierHanlde=async()=>{const s=new Promise((r,t)=>{const s=e.exec(n.Prettier,e=>{e&&(i.spinner.error(e.message),t(e))});s.stdout?.on("data",function(){r({success:!0})}),s.stderr?.on("data",function(e){i.spinner.error(e),t({success:!1})})}),a=new Promise((e,s)=>{try{const s=["module.exports = {","printWidth: 80,","tabWidth: 2,","useTabs: true,","semi: true,","singleQuote: true,",'quoteProps: "as-needed",','trailingComma: "none",',"bracketSpacing: true,",'arrowParens: "always",',"rangeStart: 0,",'proseWrap: "preserve",','htmlWhitespaceSensitivity: "css"',"};"],i=t.join(process.cwd(),".prettierrc.js");r.writeFileSync(i,s.join("\n"),"utf8"),e({success:!0})}catch(e){i.spinner.error(".prettierrc file write failed!"),s(e)}});try{await o(s,"Install Prettier",{estimate:1e4}),await o(a,"Create .prettierrc file")}catch(e){console.error("prettierHanlde======>",e)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),t=require("../utils/index.js");const s={"editor.formatOnSave":!0,"[javascript]":{"editor.defaultFormatter":"vscode.typescript-language-features"},"[typescript]":{"editor.defaultFormatter":"esbenp.prettier-vscode"},"[json]":{"editor.quickSuggestions":{strings:!0},"editor.suggest.insertMode":"replace","gitlens.codeLens.scopes":["document"],"editor.defaultFormatter":"esbenp.prettier-vscode"}};exports.default=async()=>{const r=`${process.cwd()}/.vscode/settings.json`;if(e.existsSync(r)){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),t=require("../utils/index.js");const s={"editor.formatOnSave":!0,"[javascript]":{"editor.defaultFormatter":"vscode.typescript-language-features"},"[typescript]":{"editor.defaultFormatter":"esbenp.prettier-vscode"},"[json]":{"editor.quickSuggestions":{strings:!0},"editor.suggest.insertMode":"replace","gitlens.codeLens.scopes":["document"],"editor.defaultFormatter":"esbenp.prettier-vscode"}};exports.default=async()=>{const r=`${process.cwd()}/.vscode/settings.json`;try{if(e.existsSync(r)){const s=e.readFileSync(r,"utf-8"),i=JSON.parse(s);i["editor.formatOnSave"]=!0,i["editor.defaultFormatter"]="esbenp.prettier-vscode";const o=JSON.stringify(i,null,"\t");e.writeFileSync(r,o),t.spinner.success("VSCode settings updated!")}else{const r=`${process.cwd()}/.vscode`;e.mkdirSync(r),e.writeFileSync(`${r}/settings.json`,JSON.stringify(s,null,"\t")),t.spinner.success("VSCode settings file created!")}}catch(e){t.spinner.error("VSCode settings file creation failed!"),console.error(e)}};
|