Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36632,6 +36632,23 @@ var { VERSION, YAML, argv, dotenv, echo, expBackoff, fetch, fs, glob, globby, mi
//#endregion
//#region src/index.ts
$.verbose = true;
function parseOptions(input) {
if (input.trim() === "") return {};
try {
return JSON.parse(input);
} catch {
const options = {};
for (const line of input.split("\n")) {
const trimmed = line.trim();
if (trimmed === "" || trimmed.startsWith("#")) continue;
const match = trimmed.match(/^([^:#]+):\s*(.*)$/);
if (match === null) throw new Error("Invalid options format");
const [, key, value] = match;
options[key.trim()] = value.trim().replace(/^['"]|['"]$/g, "");
}
return options;
}
}
(async function main() {
try {
await ssh();
Expand Down Expand Up @@ -36712,16 +36729,21 @@ async function dep() {
const recipeInput = getInput("recipe");
if (recipeInput !== "") recipeArgs.push(`--file=${recipeInput}`);
const ansi = getBooleanInput("ansi") ? "--ansi" : "--no-ansi";
const verbosityArgs = [];
const verbosityInput = getInput("verbosity");
if (verbosityInput !== "") verbosityArgs.push(verbosityInput);
const options = [];
let verbosityInput = getInput("verbosity");
try {
const optionsArg = getInput("options");
if (optionsArg !== "") for (const [key, value] of Object.entries(JSON.parse(optionsArg))) options.push("-o", `${key}=${value}`);
const parsedOptions = parseOptions(getInput("options"));
if (parsedOptions.verbosity !== void 0) {
verbosityInput = parsedOptions.verbosity;
delete parsedOptions.verbosity;
}
for (const [key, value] of Object.entries(parsedOptions)) options.push("-o", `${key}=${value}`);
} catch (e) {
console.error("Invalid JSON in options");
setFailed("Invalid options format. Use JSON or key: value lines.");
return;
}
const verbosityArgs = [];
if (verbosityInput !== "") verbosityArgs.push(verbosityInput);
let phpBin = "php";
const phpBinArg = getInput("php-binary");
if (phpBinArg !== "") phpBin = phpBinArg;
Expand Down
52 changes: 42 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ interface DeployerManifestEntry {
url: string
}

type ParsedOptions = Record<string, string>

function parseOptions(input: string): ParsedOptions {
if (input.trim() === '') {
return {}
}

try {
return JSON.parse(input) as ParsedOptions
} catch {
const options: ParsedOptions = {}
for (const line of input.split('\n')) {
const trimmed = line.trim()
if (trimmed === '' || trimmed.startsWith('#')) {
continue
}
const match = trimmed.match(/^([^:#]+):\s*(.*)$/)
if (match === null) {
throw new Error('Invalid options format')
}
const [, key, value] = match
options[key.trim()] = value.trim().replace(/^['"]|['"]$/g, '')
}
return options
}
}

void (async function main(): Promise<void> {
try {
await ssh()
Expand Down Expand Up @@ -138,21 +165,26 @@ async function dep(): Promise<void> {
}

const ansi = core.getBooleanInput('ansi') ? '--ansi' : '--no-ansi'
const verbosityArgs: string[] = []
const verbosityInput = core.getInput('verbosity')
if (verbosityInput !== '') {
verbosityArgs.push(verbosityInput)
}
const options: string[] = []
let verbosityInput = core.getInput('verbosity')
try {
const optionsArg = core.getInput('options')
if (optionsArg !== '') {
for (const [key, value] of Object.entries(JSON.parse(optionsArg))) {
options.push('-o', `${key}=${value}`)
}
const parsedOptions = parseOptions(optionsArg)
if (parsedOptions.verbosity !== undefined) {
verbosityInput = parsedOptions.verbosity
delete parsedOptions.verbosity
}
for (const [key, value] of Object.entries(parsedOptions)) {
options.push('-o', `${key}=${value}`)
}
} catch (e) {
console.error('Invalid JSON in options')
core.setFailed('Invalid options format. Use JSON or key: value lines.')
return
}

const verbosityArgs: string[] = []
if (verbosityInput !== '') {
verbosityArgs.push(verbosityInput)
}

let phpBin = 'php'
Expand Down