feat(console): поле зависимостей для функций из кода (deps → zip)
- UI: textarea 'Зависимости' в формах создания и редактирования - плейсхолдер меняется по языку (requirements.txt / package.json / Gemfile / composer.json) - Python: если deps заполнен → zip(main.py + requirements.txt), иначе raw bytes - PHP: если deps → zip(main.php + composer.json) - Ruby: если deps → zip(handler.rb + Gemfile) - Node.js: пока без изменений (сложная структура package.json) - runtime: BuildPythonZip, BuildScriptZipWithDeps, buildZipTwo - model: Deps string в CreateFunctionRequest и UpdateCodeRequest - v1.3.89
This commit is contained in:
@@ -25,3 +25,28 @@ func buildZip(fileName string, content []byte) ([]byte, error) {
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// buildZipTwo создаёт zip-архив с двумя файлами.
|
||||
// Используется когда пользователь указал файл зависимостей (requirements.txt и т.д.).
|
||||
func buildZipTwo(file1, file2 string, content1, content2 []byte) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
zw := zip.NewWriter(&buf)
|
||||
|
||||
for _, f := range []struct {
|
||||
name string
|
||||
content []byte
|
||||
}{{file1, content1}, {file2, content2}} {
|
||||
fw, err := zw.Create(f.name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := fw.Write(f.content); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := zw.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user