v1.3.54: лintер проверяет соответствие языка файлам в архиве
Если выбран Node.js но в архиве .py — сразу ошибка. Фронтенд передаёт выбранный язык (ca-lang / e-lang-hidden) в запрос лintера.
This commit is contained in:
@@ -52,7 +52,7 @@ spec:
|
|||||||
serviceAccountName: fission-console
|
serviceAccountName: fission-console
|
||||||
containers:
|
containers:
|
||||||
- name: console
|
- name: console
|
||||||
image: naeel/fission-console:v1.3.53
|
image: naeel/fission-console:v1.3.54
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8090
|
- containerPort: 8090
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// Опциональный entrypoint для проверки наличия файла в архиве (формат: "module.function")
|
// Опциональный entrypoint для проверки наличия файла в архиве (формат: "module.function")
|
||||||
entrypoint := strings.TrimSpace(r.FormValue("entrypoint"))
|
entrypoint := strings.TrimSpace(r.FormValue("entrypoint"))
|
||||||
|
// Опциональный язык для проверки соответствия файлов в архиве
|
||||||
|
selectedLang := strings.ToLower(strings.TrimSpace(r.FormValue("language")))
|
||||||
|
|
||||||
f, _, err := r.FormFile("archive")
|
f, _, err := r.FormFile("archive")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -199,6 +201,44 @@ func (s *Server) handleLintArchive(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Проверяем соответствие выбранного языка файлам в архиве
|
||||||
|
if selectedLang != "" {
|
||||||
|
langExt := map[string]string{
|
||||||
|
"python": ".py", "python3": ".py",
|
||||||
|
"node.js": ".js", "nodejs": ".js", "javascript": ".js", "node": ".js",
|
||||||
|
"ruby": ".rb",
|
||||||
|
"php": ".php",
|
||||||
|
"go": ".go",
|
||||||
|
"perl": ".pl",
|
||||||
|
}
|
||||||
|
expectedExt, known := langExt[selectedLang]
|
||||||
|
if known {
|
||||||
|
// Собираем расширения файлов в архиве
|
||||||
|
extCount := map[string]int{}
|
||||||
|
for _, zf := range zr.File {
|
||||||
|
if !zf.FileInfo().IsDir() {
|
||||||
|
ext := strings.ToLower(filepath.Ext(zf.Name))
|
||||||
|
if ext != "" {
|
||||||
|
extCount[ext]++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Если нет ни одного файла с ожидаемым расширением — предупреждение
|
||||||
|
if extCount[expectedExt] == 0 {
|
||||||
|
found := []string{}
|
||||||
|
for ext := range extCount {
|
||||||
|
found = append(found, ext)
|
||||||
|
}
|
||||||
|
results = append(results, lintResult{
|
||||||
|
File: "язык",
|
||||||
|
OK: false,
|
||||||
|
Output: fmt.Sprintf("выбран язык '%s' (ожидается %s), но в архиве таких файлов нет (найдено: %s)", selectedLang, expectedExt, strings.Join(found, ", ")),
|
||||||
|
})
|
||||||
|
hasError = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Проверяем entrypoint: формат "module.function" → файл "module.py" должен быть в архиве
|
// Проверяем entrypoint: формат "module.function" → файл "module.py" должен быть в архиве
|
||||||
if entrypoint != "" {
|
if entrypoint != "" {
|
||||||
parts := strings.SplitN(entrypoint, ".", 2)
|
parts := strings.SplitN(entrypoint, ".", 2)
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
<div class="nubes">NUBES</div>
|
<div class="nubes">NUBES</div>
|
||||||
<div class="product">FISSION CONSOLE</div>
|
<div class="product">FISSION CONSOLE</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.53</div>
|
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.54</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" style="margin:0;">
|
<div class="row" style="margin:0;">
|
||||||
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
||||||
@@ -462,7 +462,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions" style="justify-content:space-between; align-items:center;">
|
<div class="actions" style="justify-content:space-between; align-items:center;">
|
||||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.53</span>
|
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.54</span>
|
||||||
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
|
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ function lintArchiveFile(prefix) {
|
|||||||
if (entryEl && entryEl.value.trim()) {
|
if (entryEl && entryEl.value.trim()) {
|
||||||
fd.append('entrypoint', entryEl.value.trim());
|
fd.append('entrypoint', entryEl.value.trim());
|
||||||
}
|
}
|
||||||
|
// Передаём выбранный язык для проверки соответствия файлов
|
||||||
|
var langEl = document.getElementById(prefix + '-lang');
|
||||||
|
if (langEl && langEl.value) {
|
||||||
|
fd.append('language', langEl.value);
|
||||||
|
}
|
||||||
fetch(API_BASE + '/ai/lint-archive', {
|
fetch(API_BASE + '/ai/lint-archive', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: authHeaders(),
|
headers: authHeaders(),
|
||||||
|
|||||||
Reference in New Issue
Block a user