@cyber-harbour/ui 2.2.36 → 3.0.0-fix-ci-double-publish.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/README.md +117 -202
- package/bin/switch-ui-lib.js +54 -26
- package/dist/Core/IconComponents/index.d.mts +165 -0
- package/dist/Core/IconComponents/index.d.ts +165 -0
- package/dist/Core/IconComponents/index.js +2 -0
- package/dist/Core/IconComponents/index.js.map +1 -0
- package/dist/Core/IconComponents/index.mjs +2 -0
- package/dist/Core/IconComponents/index.mjs.map +1 -0
- package/dist/Icons2/index.d.mts +396 -0
- package/dist/Icons2/index.d.ts +396 -0
- package/dist/Icons2/index.js +2 -0
- package/dist/Icons2/index.js.map +1 -0
- package/dist/Icons2/index.mjs +2 -0
- package/dist/Icons2/index.mjs.map +1 -0
- package/dist/PdfDriver-P5ADXPSY.mjs +2 -0
- package/dist/PdfDriver-P5ADXPSY.mjs.map +1 -0
- package/dist/PdfDriver-TMPVSYW4.js +2 -0
- package/dist/PdfDriver-TMPVSYW4.js.map +1 -0
- package/dist/chunk-2RPPHDGW.mjs +2 -0
- package/dist/chunk-2RPPHDGW.mjs.map +1 -0
- package/dist/chunk-3UCQYQQT.js +2 -0
- package/dist/chunk-3UCQYQQT.js.map +1 -0
- package/dist/chunk-6YUK4MG2.js +3 -0
- package/dist/chunk-6YUK4MG2.js.map +1 -0
- package/dist/chunk-7LHQWEWV.mjs +2 -0
- package/dist/chunk-7LHQWEWV.mjs.map +1 -0
- package/dist/chunk-AYDF3IFZ.js +2 -0
- package/dist/chunk-AYDF3IFZ.js.map +1 -0
- package/dist/chunk-EKYQRECJ.mjs +3 -0
- package/dist/chunk-EKYQRECJ.mjs.map +1 -0
- package/dist/chunk-HYLHDKBT.mjs +3 -0
- package/dist/chunk-HYLHDKBT.mjs.map +1 -0
- package/dist/chunk-IBAON32O.mjs +3 -0
- package/dist/chunk-IBAON32O.mjs.map +1 -0
- package/dist/chunk-JOQGNYHN.js +3 -0
- package/dist/chunk-JOQGNYHN.js.map +1 -0
- package/dist/chunk-NQZUCXJV.js +2 -0
- package/dist/chunk-NQZUCXJV.js.map +1 -0
- package/dist/chunk-QWPVIX2T.mjs +2 -0
- package/dist/chunk-QWPVIX2T.mjs.map +1 -0
- package/dist/chunk-RYHWWDCM.mjs +2 -0
- package/dist/chunk-RYHWWDCM.mjs.map +1 -0
- package/dist/chunk-SRPPNCDM.js +2 -0
- package/dist/chunk-SRPPNCDM.js.map +1 -0
- package/dist/chunk-XR7P7DQC.js +3 -0
- package/dist/chunk-XR7P7DQC.js.map +1 -0
- package/dist/index.d.mts +1804 -1881
- package/dist/index.d.ts +1804 -1881
- package/dist/index.js +7 -297
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -297
- package/dist/index.mjs.map +1 -1
- package/dist/styles/tailwind.css +587 -3
- package/dist/utils/index.d.mts +7 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +2 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils-BGHa_rUP.d.mts +26 -0
- package/dist/utils-BGHa_rUP.d.ts +26 -0
- package/package.json +69 -50
- package/dist/PdfDriver-IE6DT35L.js +0 -2
- package/dist/PdfDriver-IE6DT35L.js.map +0 -1
- package/dist/PdfDriver-RLN2RLDS.mjs +0 -2
- package/dist/PdfDriver-RLN2RLDS.mjs.map +0 -1
- package/dist/chunk-GKPBTQZ3.js +0 -1394
- package/dist/chunk-GKPBTQZ3.js.map +0 -1
- package/dist/chunk-I5ITYF6G.mjs +0 -1394
- package/dist/chunk-I5ITYF6G.mjs.map +0 -1
- package/dist/index.css +0 -3
- package/dist/index.css.map +0 -1
- package/dist/styles/tailwind.css.map +0 -1
- package/dist/styles/tailwind.d.mts +0 -2
- package/dist/styles/tailwind.d.ts +0 -2
package/README.md
CHANGED
|
@@ -1,301 +1,216 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Cyber Harbour UI Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React UI component library built with Tailwind CSS 4, class-variance-authority, and Lucide icons.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install
|
|
8
|
+
npm install @cyber-harbour/ui
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
###
|
|
12
|
-
|
|
13
|
-
Бібліотека збирається за допомогою tsup, що забезпечує оптимізовані збірки для форматів ESM та CommonJS.
|
|
11
|
+
### Peer dependencies
|
|
14
12
|
|
|
15
13
|
```bash
|
|
16
|
-
|
|
17
|
-
npm run dev
|
|
18
|
-
|
|
19
|
-
# Продакшн збірка
|
|
20
|
-
npm run build
|
|
21
|
-
|
|
22
|
-
# Збірка без мінімізації
|
|
23
|
-
npm run build:dev
|
|
24
|
-
|
|
25
|
-
# Перевірка типів без збірки
|
|
26
|
-
npm run type-check
|
|
14
|
+
npm install tailwindcss react-tiny-popover
|
|
27
15
|
```
|
|
28
16
|
|
|
29
|
-
|
|
17
|
+
FileViewer additionally requires: `react-pdf`, `d3`, `date-fns`, `@codemirror/lang-*`, `@uiw/react-codemirror`.
|
|
30
18
|
|
|
31
|
-
|
|
19
|
+
## Usage
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
- CommonJS модулі (`.js` файли)
|
|
35
|
-
- TypeScript файли декларацій (`.d.ts` та `.d.mts`)
|
|
36
|
-
- Source maps
|
|
21
|
+
### Import styles
|
|
37
22
|
|
|
38
|
-
|
|
23
|
+
The library exports source Tailwind CSS (with `@theme` tokens, not compiled output). Your project must have its own Tailwind CSS 4 pipeline to compile it.
|
|
39
24
|
|
|
40
|
-
|
|
25
|
+
See [Vite SPA](#vite-spa-react) or [Next.js](#nextjs) setup sections below for full configuration.
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
npm run storybook
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Для збірки Storybook:
|
|
27
|
+
### Import components
|
|
47
28
|
|
|
48
|
-
```
|
|
49
|
-
|
|
29
|
+
```tsx
|
|
30
|
+
import { Button, Alert, Box, Input } from '@cyber-harbour/ui';
|
|
31
|
+
import { SearchIcon, ChevronDownIcon } from '@cyber-harbour/ui/Icons';
|
|
32
|
+
import { cn, useEscapeLayer, useOutclickLayer } from '@cyber-harbour/ui/utils';
|
|
50
33
|
```
|
|
51
34
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- Мінімізація вихідних файлів
|
|
59
|
-
- Tree shaking для видалення невикористаного коду
|
|
60
|
-
- Видалення console logs
|
|
61
|
-
- Source maps для налагодження
|
|
62
|
-
|
|
63
|
-
### Режим розробки
|
|
64
|
-
|
|
65
|
-
- Режим відстеження для автоматичної перебудови при змінах
|
|
66
|
-
- Вбудовані source maps для легшого налагодження
|
|
67
|
-
- Без мінімізації для швидшої збірки
|
|
68
|
-
- Без генерації типів для швидкості
|
|
35
|
+
| Subpath | Contents |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `@cyber-harbour/ui` | Components |
|
|
38
|
+
| `@cyber-harbour/ui/Icons` | Icons (Lucide re-exports) |
|
|
39
|
+
| `@cyber-harbour/ui/utils` | `cn`, hooks, `getFilesFromDataTransfer` |
|
|
40
|
+
| `@cyber-harbour/ui/styles` | Source Tailwind CSS with custom theme (requires consumer Tailwind pipeline) |
|
|
69
41
|
|
|
70
|
-
##
|
|
42
|
+
## Development
|
|
71
43
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
### Використання
|
|
75
|
-
|
|
76
|
-
#### Варіант 1: Через npx (рекомендований)
|
|
44
|
+
### Setup
|
|
77
45
|
|
|
78
46
|
```bash
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### Варіант 2: Через npm скрипт
|
|
83
|
-
|
|
84
|
-
Додайте скрипт в package.json вашого проекту:
|
|
85
|
-
|
|
86
|
-
```json
|
|
87
|
-
{
|
|
88
|
-
"scripts": {
|
|
89
|
-
"switch-ui": "npx @cyber-harbour/ui switch-ui-lib"
|
|
90
|
-
}
|
|
91
|
-
}
|
|
47
|
+
npm install
|
|
92
48
|
```
|
|
93
49
|
|
|
94
|
-
|
|
50
|
+
### Scripts
|
|
95
51
|
|
|
96
52
|
```bash
|
|
97
|
-
npm run
|
|
53
|
+
npm run dev # Watch mode
|
|
54
|
+
npm run build # Production build
|
|
55
|
+
npm run build:dev # Dev build (no minification)
|
|
56
|
+
npm run type:check # Type check
|
|
57
|
+
npm run test # Run tests
|
|
58
|
+
npm run storybook # Start Storybook
|
|
59
|
+
npm run build-storybook
|
|
98
60
|
```
|
|
99
61
|
|
|
100
|
-
###
|
|
62
|
+
### Build output
|
|
101
63
|
|
|
102
|
-
|
|
64
|
+
The `dist` folder contains:
|
|
103
65
|
|
|
104
|
-
|
|
66
|
+
- ESM modules (`.mjs`)
|
|
67
|
+
- CommonJS modules (`.js`)
|
|
68
|
+
- TypeScript declarations (`.d.ts`, `.d.mts`)
|
|
69
|
+
- Source maps
|
|
105
70
|
|
|
106
|
-
|
|
107
|
-
UI_LIBRARY_PATH=/path/to/your/ui-kit
|
|
108
|
-
```
|
|
71
|
+
## Integration
|
|
109
72
|
|
|
110
|
-
|
|
73
|
+
The library uses **Tailwind CSS 4** with CSS-based configuration. Styles are shipped as a prebuilt CSS file with custom color palette, shadows, and z-index tokens.
|
|
111
74
|
|
|
112
|
-
|
|
75
|
+
### Dark mode
|
|
113
76
|
|
|
114
|
-
|
|
77
|
+
Dark mode uses the `dark` CSS class. Add `class="dark"` to a parent element:
|
|
115
78
|
|
|
79
|
+
```html
|
|
80
|
+
<html class="dark">
|
|
116
81
|
```
|
|
117
|
-
projects/
|
|
118
|
-
├── ui-kit/ # UI бібліотека
|
|
119
|
-
├── my-app/ # Ваш проект
|
|
120
|
-
└── another-app/ # Інший проект
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Що робить скрипт
|
|
124
|
-
|
|
125
|
-
#### Локальна версія
|
|
126
|
-
|
|
127
|
-
- Видаляє NPM версію пакету
|
|
128
|
-
- Створює npm link для React та React DOM
|
|
129
|
-
- Створює глобальний link для UI бібліотеки
|
|
130
|
-
- Підключає локальну версію через npm link
|
|
131
|
-
|
|
132
|
-
#### NPM версія
|
|
133
|
-
|
|
134
|
-
- Видаляє всі npm links
|
|
135
|
-
- Встановлює останню версію з NPM
|
|
136
|
-
|
|
137
|
-
### Залежності
|
|
138
82
|
|
|
139
|
-
|
|
83
|
+
Components automatically adapt to dark mode.
|
|
140
84
|
|
|
141
|
-
|
|
142
|
-
- `dotenv` - для читання змінних середовища (опційно)
|
|
85
|
+
### Vite SPA (React)
|
|
143
86
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
### Усунення несправностей
|
|
147
|
-
|
|
148
|
-
Відсутній лінк на бібліотеку після першого завантаження. Запустіть
|
|
87
|
+
1. Install dependencies:
|
|
149
88
|
|
|
150
89
|
```bash
|
|
151
|
-
npm
|
|
90
|
+
npm install @tailwindcss/vite tailwindcss
|
|
152
91
|
```
|
|
153
92
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
# 🔹 Інструкція інтеграції UI-kit у Next.js з Tailwind
|
|
93
|
+
2. Add the Tailwind plugin to `vite.config.ts`:
|
|
157
94
|
|
|
158
|
-
|
|
159
|
-
|
|
95
|
+
```ts
|
|
96
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
97
|
+
import { defineConfig } from 'vite';
|
|
98
|
+
import react from '@vitejs/plugin-react';
|
|
160
99
|
|
|
161
|
-
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
plugins: [react(), tailwindcss()],
|
|
102
|
+
});
|
|
103
|
+
```
|
|
162
104
|
|
|
163
|
-
|
|
105
|
+
3. Import library styles in your global CSS (`src/index.css`):
|
|
164
106
|
|
|
165
|
-
|
|
107
|
+
```css
|
|
108
|
+
@import 'tailwindcss';
|
|
109
|
+
@import '@cyber-harbour/ui/styles';
|
|
166
110
|
|
|
167
|
-
|
|
168
|
-
pnpm add tailwindcss postcss autoprefixer
|
|
111
|
+
@source "../node_modules/@cyber-harbour/ui/dist";
|
|
169
112
|
```
|
|
170
113
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
## 2. Створіть `tailwind.config.js` у Next.js
|
|
114
|
+
### Next.js
|
|
174
115
|
|
|
175
|
-
|
|
176
|
-
Ми будемо мерджити конфіги за допомогою `lodash.merge`:
|
|
116
|
+
1. Install dependencies:
|
|
177
117
|
|
|
178
118
|
```bash
|
|
179
|
-
|
|
119
|
+
npm install @tailwindcss/postcss tailwindcss
|
|
180
120
|
```
|
|
181
121
|
|
|
182
|
-
|
|
122
|
+
2. Configure PostCSS in `postcss.config.mjs`:
|
|
183
123
|
|
|
184
124
|
```js
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
module.exports = merge({}, uiKitConfig, {
|
|
189
|
-
content: [
|
|
190
|
-
'./pages/**/*.{js,ts,jsx,tsx}',
|
|
191
|
-
'./components/**/*.{js,ts,tsx}',
|
|
192
|
-
'./app/**/*.{js,ts,jsx,tsx}', // якщо використовуєте app router
|
|
193
|
-
'./node_modules/@cyber-harbour/ui/dist/**/*.{js,mjs', // важливо: UI-kit компоненти
|
|
194
|
-
],
|
|
195
|
-
theme: {
|
|
196
|
-
extend: {
|
|
197
|
-
colors: {
|
|
198
|
-
accent: '#f59e0b', // локальні кольори вашого проєкту
|
|
199
|
-
},
|
|
200
|
-
},
|
|
125
|
+
export default {
|
|
126
|
+
plugins: {
|
|
127
|
+
'@tailwindcss/postcss': {},
|
|
201
128
|
},
|
|
202
|
-
}
|
|
129
|
+
};
|
|
203
130
|
```
|
|
204
131
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
## 3. Підключіть Tailwind у глобальні стилі
|
|
208
|
-
|
|
209
|
-
У вашому Next.js проєкті додайте у `globals.css` (або `app/globals.css`):
|
|
132
|
+
3. Import library styles in your global CSS (`app/globals.css`):
|
|
210
133
|
|
|
211
134
|
```css
|
|
212
|
-
@
|
|
213
|
-
@
|
|
214
|
-
@tailwind utilities;
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
---
|
|
135
|
+
@import 'tailwindcss';
|
|
136
|
+
@import '@cyber-harbour/ui/styles';
|
|
218
137
|
|
|
219
|
-
|
|
138
|
+
@source "../node_modules/@cyber-harbour/ui/dist";
|
|
139
|
+
```
|
|
220
140
|
|
|
221
|
-
|
|
141
|
+
### Example
|
|
222
142
|
|
|
223
143
|
```tsx
|
|
224
|
-
import { Button } from 'ui
|
|
144
|
+
import { Button, Alert } from '@cyber-harbour/ui';
|
|
145
|
+
import { SearchIcon } from '@cyber-harbour/ui/Icons';
|
|
225
146
|
|
|
226
147
|
export default function Page() {
|
|
227
148
|
return (
|
|
228
149
|
<div className="p-6">
|
|
229
|
-
<
|
|
150
|
+
<Alert color="success">Operation completed</Alert>
|
|
151
|
+
<Button color="primary" icon={<SearchIcon />}>
|
|
152
|
+
Search
|
|
153
|
+
</Button>
|
|
230
154
|
</div>
|
|
231
155
|
);
|
|
232
156
|
}
|
|
233
157
|
```
|
|
234
158
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
## 5. Кастомізація теми
|
|
159
|
+
## FileViewer configuration
|
|
238
160
|
|
|
239
|
-
|
|
240
|
-
додавайте їх у секцію `theme.extend` вашого `tailwind.config.js`.
|
|
161
|
+
PDF preview requires copying the pdfjs-dist worker.
|
|
241
162
|
|
|
242
|
-
|
|
163
|
+
### Auto copy
|
|
243
164
|
|
|
244
|
-
|
|
165
|
+
Add the command to your `postinstall` script in `package.json` so the worker is copied automatically after every install:
|
|
245
166
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
@import '@cyber-harbour/ui/styles';
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"scripts": {
|
|
170
|
+
"postinstall": "npx @cyber-harbour/ui copy-pdfjs"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
253
173
|
```
|
|
254
174
|
|
|
255
|
-
|
|
175
|
+
Or run it manually:
|
|
256
176
|
|
|
257
|
-
```
|
|
258
|
-
|
|
177
|
+
```bash
|
|
178
|
+
npx @cyber-harbour/ui copy-pdfjs
|
|
259
179
|
```
|
|
260
180
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
## 7. FileViewer configuration
|
|
264
|
-
|
|
265
|
-
Для роботи перегляду PDF потрібно скопіювати worker pdfjs-dist
|
|
266
|
-
|
|
267
|
-
### Автоматичне копіювання
|
|
181
|
+
### Custom worker directory
|
|
268
182
|
|
|
269
183
|
```bash
|
|
270
|
-
npx @cyber-harbour/ui copy-pdfjs
|
|
184
|
+
UI_LIBRARY_WORKERS_DIR=public/assets npx @cyber-harbour/ui copy-pdfjs
|
|
271
185
|
```
|
|
272
186
|
|
|
273
|
-
|
|
187
|
+
## Switch UI library tool
|
|
188
|
+
|
|
189
|
+
Switch between local and NPM versions of the library during development.
|
|
274
190
|
|
|
275
191
|
```bash
|
|
276
|
-
|
|
192
|
+
npx @cyber-harbour/ui switch-ui-lib
|
|
277
193
|
```
|
|
278
194
|
|
|
279
|
-
###
|
|
195
|
+
### Setup
|
|
280
196
|
|
|
281
|
-
|
|
197
|
+
Set the path to your local UI kit via `.env` or `.env.local`:
|
|
282
198
|
|
|
283
|
-
|
|
199
|
+
```bash
|
|
200
|
+
UI_LIBRARY_PATH=/path/to/your/ui-kit
|
|
201
|
+
```
|
|
284
202
|
|
|
285
|
-
|
|
286
|
-
npm install pdfjs-dist
|
|
287
|
-
```
|
|
203
|
+
If not set, the script looks for `ui-kit` folder next to your project.
|
|
288
204
|
|
|
289
|
-
|
|
205
|
+
### Recommended project structure
|
|
290
206
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
207
|
+
```
|
|
208
|
+
projects/
|
|
209
|
+
ui-kit/ # This library
|
|
210
|
+
my-app/ # Your project
|
|
211
|
+
another-app/ # Another project
|
|
212
|
+
```
|
|
295
213
|
|
|
296
|
-
|
|
297
|
-
- `node_modules/pdfjs-dist/build/pdf.worker.min.mjs`
|
|
298
|
-
- `node_modules/@cyber-harbour/ui/node_modules/pdfjs-dist/build/pdf.worker.min.mjs`
|
|
299
|
-
- Інші можливі локації
|
|
214
|
+
## Migration
|
|
300
215
|
|
|
301
|
-
|
|
216
|
+
See [MIGRATION.md](MIGRATION.md) for breaking changes when upgrading from v1 to v3.
|
package/bin/switch-ui-lib.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const prompts = require('prompts');
|
|
4
|
-
const { execSync } = require('child_process');
|
|
4
|
+
const { execSync, execFileSync } = require('child_process');
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
|
|
@@ -57,15 +57,6 @@ function isUsingLocalVersion() {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function isUsingNpmVersion() {
|
|
61
|
-
try {
|
|
62
|
-
const realPath = fs.realpathSync(pkgPath);
|
|
63
|
-
return !realPath.includes('..') && realPath.includes('node_modules');
|
|
64
|
-
} catch {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
60
|
function checkLocalPathExists() {
|
|
70
61
|
if (!fs.existsSync(localPath)) {
|
|
71
62
|
console.log(`⚠️ Локальний шлях не знайдено: ${localPath}`);
|
|
@@ -148,29 +139,66 @@ async function main() {
|
|
|
148
139
|
}
|
|
149
140
|
|
|
150
141
|
if (mode === 'npm') {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
142
|
+
let distTags = {};
|
|
143
|
+
try {
|
|
144
|
+
const raw = execFileSync('npm', ['view', packageName, 'dist-tags', '--json'], {
|
|
145
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
146
|
+
}).toString();
|
|
147
|
+
distTags = JSON.parse(raw);
|
|
148
|
+
} catch {
|
|
149
|
+
console.log('⚠️ Не вдалося отримати список тегів з npm — буде запропоновано ручний ввід.');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const PRIMARY_TAGS = ['latest', 'next', 'next-gen', 'beta', 'alpha', 'dev'];
|
|
153
|
+
const tagEntries = Object.entries(distTags).sort(([a], [b]) => {
|
|
154
|
+
const ai = PRIMARY_TAGS.indexOf(a);
|
|
155
|
+
const bi = PRIMARY_TAGS.indexOf(b);
|
|
156
|
+
if (ai !== -1 || bi !== -1) return (ai === -1 ? Infinity : ai) - (bi === -1 ? Infinity : bi);
|
|
157
|
+
return a.localeCompare(b);
|
|
157
158
|
});
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
const tagChoices = tagEntries.map(([tag, version]) => ({
|
|
160
|
+
title: `${tag} (${version})`,
|
|
161
|
+
value: tag,
|
|
162
|
+
}));
|
|
163
|
+
|
|
164
|
+
const latestIdx = tagChoices.findIndex(c => c.value === 'latest');
|
|
165
|
+
|
|
166
|
+
const { selected } = await prompts({
|
|
167
|
+
type: 'select',
|
|
168
|
+
name: 'selected',
|
|
169
|
+
message: 'Оберіть тег або вкажіть власну версію:',
|
|
170
|
+
choices: [
|
|
171
|
+
...tagChoices,
|
|
172
|
+
{ title: '✏️ Ввести версію або тег вручну', value: '__custom__' },
|
|
173
|
+
],
|
|
174
|
+
initial: latestIdx >= 0 ? latestIdx : 0,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
if (!selected) {
|
|
160
178
|
console.log('❌ Операція скасована.');
|
|
161
179
|
return;
|
|
162
180
|
}
|
|
163
|
-
|
|
164
|
-
const version = versionResponse.version.startsWith('@')
|
|
165
|
-
? versionResponse.version.substring(1)
|
|
166
|
-
: versionResponse.version;
|
|
167
|
-
const packageToInstall = `${packageName}@${version}`;
|
|
168
181
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
182
|
+
let version = selected;
|
|
183
|
+
if (selected === '__custom__') {
|
|
184
|
+
const { custom } = await prompts({
|
|
185
|
+
type: 'text',
|
|
186
|
+
name: 'custom',
|
|
187
|
+
message: 'Введіть версію або тег:',
|
|
188
|
+
initial: 'latest',
|
|
189
|
+
validate: value => (value.length > 0 ? true : 'Версія не може бути пустою'),
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
if (!custom) {
|
|
193
|
+
console.log('❌ Операція скасована.');
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
version = custom.startsWith('@') ? custom.substring(1) : custom;
|
|
172
198
|
}
|
|
173
199
|
|
|
200
|
+
const packageToInstall = `${packageName}@${version}`;
|
|
201
|
+
|
|
174
202
|
try {
|
|
175
203
|
// Видаляємо лінк якщо він існує
|
|
176
204
|
console.log('🔄 Видаляємо лінки...');
|