mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
* oom(01): A1-shared-readers — reintroduce #10179 subset Files: 18 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(02): A2-shared-image-media — reintroduce #10179 subset Files: 7 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(03): A3-shared-fs-listing — reintroduce #10179 subset Files: 21 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(04): A4-shared-remote-relay — reintroduce #10179 subset Files: 8 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(05): A5-shared-misc — reintroduce #10179 subset Files: 28 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> * oom(06): B-shared-wiring — reintroduce #10179 subset Files: 81 applied, 0 deleted (from6eb70d8370) Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import {
|
|
isSetupScriptImportFieldWithinLimit,
|
|
SETUP_SCRIPT_IMPORT_MAX_COMMAND_PARTS,
|
|
SETUP_SCRIPT_IMPORT_MAX_FIELD_CODE_UNITS,
|
|
SETUP_SCRIPT_IMPORT_MAX_UNSUPPORTED_FIELDS
|
|
} from './setup-script-import-limits'
|
|
|
|
export function normalizeSetupScriptImportCommand(value: unknown): string {
|
|
if (typeof value === 'string') {
|
|
return normalizeCommandString(value)
|
|
}
|
|
if (!Array.isArray(value) || value.length > SETUP_SCRIPT_IMPORT_MAX_COMMAND_PARTS) {
|
|
return ''
|
|
}
|
|
const commands: string[] = []
|
|
for (const item of value) {
|
|
const command = typeof item === 'string' ? normalizeCommandString(item) : ''
|
|
if (command) {
|
|
commands.push(command)
|
|
}
|
|
}
|
|
return joinSetupScriptImportCommands(commands)
|
|
}
|
|
|
|
export function joinSetupScriptImportCommands(parts: string[]): string {
|
|
let command = ''
|
|
for (const part of parts) {
|
|
const next = command ? `${command}\n${part}` : part
|
|
if (!isSetupScriptImportFieldWithinLimit(next)) {
|
|
return ''
|
|
}
|
|
command = next
|
|
}
|
|
return command
|
|
}
|
|
|
|
export function pushSetupScriptImportUnsupportedField(fields: string[], value: string): void {
|
|
if (fields.length < SETUP_SCRIPT_IMPORT_MAX_UNSUPPORTED_FIELDS) {
|
|
fields.push(value)
|
|
}
|
|
}
|
|
|
|
function normalizeCommandString(value: string): string {
|
|
if (value.length > SETUP_SCRIPT_IMPORT_MAX_FIELD_CODE_UNITS) {
|
|
return ''
|
|
}
|
|
const trimmed = value.trim()
|
|
return trimmed && isSetupScriptImportFieldWithinLimit(trimmed) ? trimmed : ''
|
|
}
|