@nitra/cursor 1.8.105 → 1.8.106

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.
@@ -52,99 +52,94 @@ function ukFilesCountPhrase(n) {
52
52
  }
53
53
 
54
54
  /**
55
- * Перевіряє залежності та vite.config одного Vue-пакета.
56
- * @param {string} rootDir відносний шлях до пакета
57
- * @param {(msg: string) => void} fail функція зворотного виклику для реєстрації помилки перевірки
58
- * @param {(msg: string) => void} passFn успішне повідомлення (як у check-reporter)
59
- * @returns {Promise<void>} завершується після перевірок залежностей, `vite.config` і сканування джерел на імпорти з `vue`
55
+ * Перевіряє наявність залежності в об'єкті deps.
56
+ * @param {Record<string,string>} deps об'єкт залежностей
57
+ * @param {string} name ім'я пакета
58
+ * @param {string} prefix префікс повідомлення
59
+ * @param {(msg: string) => void} passFn callback при успішній перевірці
60
+ * @param {(msg: string) => void} fail callback при помилці
61
+ * @param {string} hint підказка при відсутності
60
62
  */
61
- async function checkVuePackage(rootDir, fail, passFn) {
62
- const label = packageLabel(rootDir)
63
- const prefix = `[${label}] `
64
-
65
- const pkgPath = join(rootDir, 'package.json')
66
- const pkg = JSON.parse(await readFile(pkgPath, 'utf8'))
67
- const deps = pkg.dependencies || {}
68
- const devDeps = pkg.devDependencies || {}
69
- const allDeps = { ...deps, ...devDeps }
70
-
71
- if (deps.vue) {
72
- passFn(`${prefix}vue в dependencies: ${deps.vue}`)
63
+ function checkRequiredDep(deps, name, prefix, passFn, fail, hint = `${name} відсутній`) {
64
+ if (deps[name]) {
65
+ passFn(`${prefix}${name}: ${deps[name]}`)
73
66
  } else {
74
- fail(`${prefix}vue відсутній в dependencies`)
67
+ fail(`${prefix}${hint}`)
75
68
  }
69
+ }
76
70
 
77
- if (devDeps.vite) {
78
- const match = devDeps.vite.match(MAJOR_VERSION_RE)
79
- if (match && Number(match[1]) >= 8) {
80
- passFn(`${prefix}vite >= 8: ${devDeps.vite}`)
81
- } else {
82
- fail(`${prefix}vite має бути >= 8, знайдено: ${devDeps.vite}`)
83
- }
84
- } else {
71
+ /**
72
+ * Перевіряє версію vite у devDependencies.
73
+ * @param {Record<string,string>} devDeps devDependencies з package.json
74
+ * @param {string} prefix параметр prefix
75
+ * @param {(msg: string) => void} passFn callback при успішній перевірці
76
+ * @param {(msg: string) => void} fail callback при помилці
77
+ */
78
+ function checkViteVersion(devDeps, prefix, passFn, fail) {
79
+ const v = devDeps.vite
80
+ if (!v) {
85
81
  fail(`${prefix}vite відсутній в devDependencies`)
82
+ return
86
83
  }
87
-
88
- if (devDeps['@vitejs/plugin-vue']) {
89
- passFn(`${prefix}@vitejs/plugin-vue: ${devDeps['@vitejs/plugin-vue']}`)
90
- } else {
91
- fail(`${prefix}@vitejs/plugin-vue відсутній в devDependencies`)
92
- }
93
-
94
- if (allDeps['vue-macros']) {
95
- passFn(`${prefix}vue-macros: ${allDeps['vue-macros']}`)
96
- } else {
97
- fail(`${prefix}vue-macros відсутній — bun add -d vue-macros`)
98
- }
99
-
100
- if (allDeps['unplugin-auto-import']) {
101
- passFn(`${prefix}unplugin-auto-import присутній`)
102
- } else {
103
- fail(`${prefix}unplugin-auto-import відсутній — bun add -d unplugin-auto-import`)
104
- }
105
-
106
- if (allDeps['vite-plugin-vue-layouts-next']) {
107
- passFn(`${prefix}vite-plugin-vue-layouts-next присутній`)
84
+ const match = v.match(MAJOR_VERSION_RE)
85
+ if (match && Number(match[1]) >= 8) {
86
+ passFn(`${prefix}vite >= 8: ${v}`)
108
87
  } else {
109
- fail(`${prefix}vite-plugin-vue-layouts-next відсутній bun add -d vite-plugin-vue-layouts-next`)
88
+ fail(`${prefix}vite має бути >= 8, знайдено: ${v}`)
110
89
  }
90
+ }
111
91
 
92
+ /**
93
+ * Перевіряє vite.config на наявність VueMacros і AutoImport.
94
+ * @param {string} rootDir параметр rootDir
95
+ * @param {string} prefix параметр prefix
96
+ * @param {(msg: string) => void} passFn callback при успішній перевірці
97
+ * @param {(msg: string) => void} fail callback при помилці
98
+ */
99
+ async function checkViteConfig(rootDir, prefix, passFn, fail) {
112
100
  const configFiles = ['vite.config.js', 'vite.config.ts', 'vite.config.mjs']
113
101
  const viteConfig = configFiles.find(f => existsSync(join(rootDir, f)))
114
- if (viteConfig) {
115
- const relConfig = join(rootDir, viteConfig)
116
- const content = await readFile(relConfig, 'utf8')
117
- if (content.includes('VueMacros')) {
118
- passFn(`${prefix}${viteConfig} використовує VueMacros`)
119
- } else {
120
- fail(`${prefix}${viteConfig} не містить VueMacros`)
121
- }
122
- if (content.includes('AutoImport')) {
123
- passFn(`${prefix}${viteConfig} використовує AutoImport`)
102
+ if (!viteConfig) {
103
+ fail(`${prefix}немає vite.config.js|ts|mjs у каталозі пакета`)
104
+ return
105
+ }
106
+ const content = await readFile(join(rootDir, viteConfig), 'utf8')
107
+ const checks = [
108
+ { token: 'VueMacros', ok: `${viteConfig} використовує VueMacros`, err: `${viteConfig} не містить VueMacros` },
109
+ { token: 'AutoImport', ok: `${viteConfig} використовує AutoImport`, err: `${viteConfig} не містить AutoImport` }
110
+ ]
111
+ for (const { token, ok, err } of checks) {
112
+ if (content.includes(token)) {
113
+ passFn(`${prefix}${ok}`)
124
114
  } else {
125
- fail(`${prefix}${viteConfig} не містить AutoImport`)
115
+ fail(`${prefix}${err}`)
126
116
  }
127
- } else {
128
- fail(`${prefix}немає vite.config.js|ts|mjs у каталозі пакета`)
129
117
  }
118
+ }
130
119
 
131
- const absPackageRoot = join(process.cwd(), rootDir)
120
+ /**
121
+ * Сканує джерела пакета на заборонені value-імпорти з vue.
122
+ * @param {string} rootDir параметр rootDir
123
+ * @param {string} absPackageRoot параметр absPackageRoot
124
+ * @param {string} prefix параметр prefix
125
+ * @param {(msg: string) => void} passFn callback при успішній перевірці
126
+ * @param {(msg: string) => void} fail callback при помилці
127
+ */
128
+ async function checkVueImportViolations(rootDir, absPackageRoot, prefix, passFn, fail) {
132
129
  /** @type {string[]} */
133
130
  const sourcePaths = []
134
131
  await walkDir(absPackageRoot, absPath => {
135
132
  const rel = relative(absPackageRoot, absPath).split('\\').join('/')
136
- if (shouldSkipFileForVueImportScan(rel) || !isVueImportScanSourceFile(rel)) {
137
- return
133
+ if (!shouldSkipFileForVueImportScan(rel) && isVueImportScanSourceFile(rel)) {
134
+ sourcePaths.push(absPath)
138
135
  }
139
- sourcePaths.push(absPath)
140
136
  })
141
137
 
142
138
  let importViolations = 0
143
139
  for (const absPath of sourcePaths) {
144
140
  const rel = relative(absPackageRoot, absPath).split('\\').join('/')
145
141
  const content = await readFile(absPath, 'utf8')
146
- const hits = findForbiddenVueImportsInSourceFile(content, rel)
147
- for (const v of hits) {
142
+ for (const v of findForbiddenVueImportsInSourceFile(content, rel)) {
148
143
  importViolations++
149
144
  fail(`${prefix}${rel}:${v.line} — прибери явний value-імпорт з 'vue' (unplugin-auto-import): ${v.snippet}`)
150
145
  }
@@ -156,6 +151,52 @@ async function checkVuePackage(rootDir, fail, passFn) {
156
151
  }
157
152
  }
158
153
 
154
+ /**
155
+ * Перевіряє залежності та vite.config одного Vue-пакета.
156
+ * @param {string} rootDir відносний шлях до пакета
157
+ * @param {(msg: string) => void} fail функція зворотного виклику для реєстрації помилки перевірки
158
+ * @param {(msg: string) => void} passFn успішне повідомлення (як у check-reporter)
159
+ * @returns {Promise<void>} завершується після перевірок залежностей, `vite.config` і сканування джерел на імпорти з `vue`
160
+ */
161
+ async function checkVuePackage(rootDir, fail, passFn) {
162
+ const prefix = `[${packageLabel(rootDir)}] `
163
+ const pkg = JSON.parse(await readFile(join(rootDir, 'package.json'), 'utf8'))
164
+ const deps = pkg.dependencies || {}
165
+ const devDeps = pkg.devDependencies || {}
166
+ const allDeps = { ...deps, ...devDeps }
167
+
168
+ checkRequiredDep(deps, 'vue', prefix, passFn, fail, 'vue відсутній в dependencies')
169
+ checkViteVersion(devDeps, prefix, passFn, fail)
170
+ checkRequiredDep(
171
+ devDeps,
172
+ '@vitejs/plugin-vue',
173
+ prefix,
174
+ passFn,
175
+ fail,
176
+ '@vitejs/plugin-vue відсутній в devDependencies'
177
+ )
178
+ checkRequiredDep(allDeps, 'vue-macros', prefix, passFn, fail, 'vue-macros відсутній — bun add -d vue-macros')
179
+ checkRequiredDep(
180
+ allDeps,
181
+ 'unplugin-auto-import',
182
+ prefix,
183
+ passFn,
184
+ fail,
185
+ 'unplugin-auto-import відсутній — bun add -d unplugin-auto-import'
186
+ )
187
+ checkRequiredDep(
188
+ allDeps,
189
+ 'vite-plugin-vue-layouts-next',
190
+ prefix,
191
+ passFn,
192
+ fail,
193
+ 'vite-plugin-vue-layouts-next відсутній — bun add -d vite-plugin-vue-layouts-next'
194
+ )
195
+
196
+ await checkViteConfig(rootDir, prefix, passFn, fail)
197
+ await checkVueImportViolations(rootDir, join(process.cwd(), rootDir), prefix, passFn, fail)
198
+ }
199
+
159
200
  /**
160
201
  * Перевіряє відповідність проєкту правилам vue.mdc (корінь і всі workspace-пакети з `vue` у dependencies).
161
202
  * @returns {Promise<number>} 0 — все OK, 1 — є проблеми
@@ -324,7 +324,9 @@ function workflowJobSteps(job) {
324
324
  if (!Array.isArray(steps)) {
325
325
  return []
326
326
  }
327
- return steps.flatMap(step => (step && typeof step === 'object' ? [/** @type {Record<string, unknown>} */ (step)] : []))
327
+ return steps.flatMap(step =>
328
+ step && typeof step === 'object' ? [/** @type {Record<string, unknown>} */ (step)] : []
329
+ )
328
330
  }
329
331
 
330
332
  /**