@nitra/cursor 1.8.104 → 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.
- package/bin/auto-rules.md +45 -0
- package/bin/n-cursor.js +270 -149
- package/mdc/graphql.mdc +15 -1
- package/mdc/k8s.mdc +11 -10
- package/package.json +1 -1
- package/schemas/n-cursor.json +16 -0
- package/scripts/auto-rules.mjs +404 -0
- package/scripts/check-abie.mjs +558 -553
- package/scripts/check-bun.mjs +106 -82
- package/scripts/check-ga.mjs +151 -119
- package/scripts/check-graphql.mjs +112 -34
- package/scripts/check-js-lint.mjs +267 -186
- package/scripts/check-k8s.mjs +1148 -673
- package/scripts/check-nginx-default-tpl.mjs +125 -100
- package/scripts/check-npm-module.mjs +165 -118
- package/scripts/check-style-lint.mjs +74 -61
- package/scripts/check-text.mjs +288 -210
- package/scripts/check-vue.mjs +110 -69
- package/scripts/utils/docker-hadolint.mjs +9 -5
- package/scripts/utils/gha-workflow.mjs +92 -72
- package/scripts/utils/workspaces.mjs +39 -16
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Перевіряє правило graphql.mdc: наявність **`.graphqlrc.yml
|
|
2
|
+
* Перевіряє правило graphql.mdc: наявність **`.graphqlrc.yml`**, рекомендації
|
|
3
|
+
* **`graphql.vscode-graphql`** і скрипта **`dump-schema`** у кореневому
|
|
4
|
+
* **`package.json`**, якщо у дереві є **`gql\`…\``**.
|
|
3
5
|
*
|
|
4
6
|
* Обхід репозиторію — **`walkDir`** від **`process.cwd()`** (пропуски як у інших check). Кандидати — **`.vue`** та **`.js`/`.ts`/`.jsx`/`.tsx`** тощо; пропуск **`.d.ts`**, **auto-imports.d.ts** тощо — **`shouldSkipFileForGqlScan`**.
|
|
5
7
|
*
|
|
@@ -22,16 +24,16 @@ export const GRAPHQL_RC_FILENAME = '.graphqlrc.yml'
|
|
|
22
24
|
|
|
23
25
|
/** Розширення VS Code з graphql.mdc. */
|
|
24
26
|
export const REQUIRED_GRAPHQL_VSCODE_EXTENSION = 'graphql.vscode-graphql'
|
|
27
|
+
/** Команда dump-schema з graphql.mdc. */
|
|
28
|
+
export const REQUIRED_DUMP_SCHEMA_SCRIPT =
|
|
29
|
+
"bunx graphqurl http://localhost:4040/v1/graphql -H 'X-Hasura-Admin-Secret: secret' --introspect > schema.graphql"
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
32
|
+
* Збирає абсолютні шляхи source-файлів, які підлягають скануванню на gql templates.
|
|
33
|
+
* @param {string} root абсолютний шлях кореня
|
|
34
|
+
* @returns {Promise<string[]>} список кандидатів
|
|
29
35
|
*/
|
|
30
|
-
|
|
31
|
-
const reporter = createCheckReporter()
|
|
32
|
-
const { pass, fail } = reporter
|
|
33
|
-
|
|
34
|
-
const root = process.cwd()
|
|
36
|
+
async function collectScanCandidates(root) {
|
|
35
37
|
/** @type {string[]} */
|
|
36
38
|
const candidates = []
|
|
37
39
|
await walkDir(root, absPath => {
|
|
@@ -41,7 +43,16 @@ export async function check() {
|
|
|
41
43
|
}
|
|
42
44
|
candidates.push(absPath)
|
|
43
45
|
})
|
|
46
|
+
return candidates
|
|
47
|
+
}
|
|
44
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Повертає відносні шляхи файлів, де знайдено gql tagged template.
|
|
51
|
+
* @param {string} root абсолютний шлях кореня
|
|
52
|
+
* @param {string[]} candidates абсолютні шляхи файлів-кандидатів
|
|
53
|
+
* @returns {Promise<string[]>} відносні шляхи файлів зі збігами
|
|
54
|
+
*/
|
|
55
|
+
async function collectGqlHits(root, candidates) {
|
|
45
56
|
/** @type {string[]} */
|
|
46
57
|
const hits = []
|
|
47
58
|
for (const absPath of candidates) {
|
|
@@ -51,9 +62,99 @@ export async function check() {
|
|
|
51
62
|
hits.push(rel)
|
|
52
63
|
}
|
|
53
64
|
}
|
|
65
|
+
return hits
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Перевіряє `.vscode/extensions.json` на рекомендацію GraphQL extension.
|
|
70
|
+
* @param {(msg: string) => void} pass success-репортер
|
|
71
|
+
* @param {(msg: string) => void} fail fail-репортер
|
|
72
|
+
* @returns {Promise<void>}
|
|
73
|
+
*/
|
|
74
|
+
async function checkExtensionsRecommendation(pass, fail) {
|
|
75
|
+
if (!existsSync('.vscode/extensions.json')) {
|
|
76
|
+
fail(
|
|
77
|
+
'.vscode/extensions.json не існує — створи файл і додай у recommendations graphql.vscode-graphql (graphql.mdc)'
|
|
78
|
+
)
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let ext
|
|
83
|
+
try {
|
|
84
|
+
ext = JSON.parse(await readFile('.vscode/extensions.json', 'utf8'))
|
|
85
|
+
} catch {
|
|
86
|
+
fail('.vscode/extensions.json не є валідним JSON')
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const rec = ext.recommendations
|
|
91
|
+
if (!Array.isArray(rec)) {
|
|
92
|
+
fail('.vscode/extensions.json: поле recommendations має бути масивом')
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (rec.includes(REQUIRED_GRAPHQL_VSCODE_EXTENSION)) {
|
|
97
|
+
pass(`.vscode/extensions.json: є ${REQUIRED_GRAPHQL_VSCODE_EXTENSION}`)
|
|
98
|
+
} else {
|
|
99
|
+
fail(`.vscode/extensions.json: додай у recommendations "${REQUIRED_GRAPHQL_VSCODE_EXTENSION}" (graphql.mdc)`)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Перевіряє `package.json` і значення scripts.dump-schema.
|
|
105
|
+
* @param {(msg: string) => void} pass success-репортер
|
|
106
|
+
* @param {(msg: string) => void} fail fail-репортер
|
|
107
|
+
* @returns {Promise<void>}
|
|
108
|
+
*/
|
|
109
|
+
async function checkPackageDumpSchemaScript(pass, fail) {
|
|
110
|
+
if (!existsSync('package.json')) {
|
|
111
|
+
fail('Відсутній package.json у корені репозиторію')
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let pkg
|
|
116
|
+
try {
|
|
117
|
+
pkg = JSON.parse(await readFile('package.json', 'utf8'))
|
|
118
|
+
} catch {
|
|
119
|
+
fail('package.json не є валідним JSON')
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const scripts = pkg.scripts
|
|
124
|
+
if (!scripts || typeof scripts !== 'object' || Array.isArray(scripts)) {
|
|
125
|
+
fail('package.json: поле scripts має бути обʼєктом')
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!Object.hasOwn(scripts, 'dump-schema')) {
|
|
130
|
+
fail('package.json: відсутній scripts.dump-schema (graphql.mdc)')
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (scripts['dump-schema'] === REQUIRED_DUMP_SCHEMA_SCRIPT) {
|
|
135
|
+
pass('package.json: scripts.dump-schema відповідає graphql.mdc')
|
|
136
|
+
} else {
|
|
137
|
+
fail(`package.json: scripts.dump-schema має бути "${REQUIRED_DUMP_SCHEMA_SCRIPT}" (graphql.mdc)`)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Перевіряє graphql.mdc: умовна вимога .graphqlrc.yml, graphql.vscode-graphql
|
|
143
|
+
* і scripts.dump-schema за наявності gql tagged templates.
|
|
144
|
+
* @returns {Promise<number>} 0 — OK, 1 — порушення
|
|
145
|
+
*/
|
|
146
|
+
export async function check() {
|
|
147
|
+
const reporter = createCheckReporter()
|
|
148
|
+
const { pass, fail } = reporter
|
|
149
|
+
|
|
150
|
+
const root = process.cwd()
|
|
151
|
+
const candidates = await collectScanCandidates(root)
|
|
152
|
+
const hits = await collectGqlHits(root, candidates)
|
|
54
153
|
|
|
55
154
|
if (hits.length === 0) {
|
|
56
|
-
pass(
|
|
155
|
+
pass(
|
|
156
|
+
`Немає tagged template з тегом gql у .vue / JS / TS джерелах (переглянуто ${candidates.length} файлів) — .graphqlrc.yml не вимагається`
|
|
157
|
+
)
|
|
57
158
|
return reporter.getExitCode()
|
|
58
159
|
}
|
|
59
160
|
|
|
@@ -67,31 +168,8 @@ export async function check() {
|
|
|
67
168
|
)
|
|
68
169
|
}
|
|
69
170
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
ext = JSON.parse(await readFile('.vscode/extensions.json', 'utf8'))
|
|
74
|
-
} catch {
|
|
75
|
-
fail('.vscode/extensions.json не є валідним JSON')
|
|
76
|
-
ext = null
|
|
77
|
-
}
|
|
78
|
-
if (ext) {
|
|
79
|
-
const rec = ext.recommendations
|
|
80
|
-
if (!Array.isArray(rec)) {
|
|
81
|
-
fail('.vscode/extensions.json: поле recommendations має бути масивом')
|
|
82
|
-
} else if (rec.includes(REQUIRED_GRAPHQL_VSCODE_EXTENSION)) {
|
|
83
|
-
pass(`.vscode/extensions.json: є ${REQUIRED_GRAPHQL_VSCODE_EXTENSION}`)
|
|
84
|
-
} else {
|
|
85
|
-
fail(
|
|
86
|
-
`.vscode/extensions.json: додай у recommendations "${REQUIRED_GRAPHQL_VSCODE_EXTENSION}" (graphql.mdc)`
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
fail(
|
|
92
|
-
'.vscode/extensions.json не існує — створи файл і додай у recommendations graphql.vscode-graphql (graphql.mdc)'
|
|
93
|
-
)
|
|
94
|
-
}
|
|
171
|
+
await checkExtensionsRecommendation(pass, fail)
|
|
172
|
+
await checkPackageDumpSchemaScript(pass, fail)
|
|
95
173
|
|
|
96
174
|
return reporter.getExitCode()
|
|
97
175
|
}
|