ivaldi/source/helpers.ts
2026-09-18 02:13:11 +02:00

186 lines
4.1 KiB
TypeScript

/*
This file is part of »ivaldi«.
Copyright 2025 'Fenris Wolf' <fenris@folksprak.org>
»ivaldi« is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
»ivaldi« is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with »ivaldi«. If not, see <http://www.gnu.org/licenses/>.
*/
namespace _ivaldi
{
/**
*/
export function command_log(
content : string
) : string
{
return lib_plankton.string.coin(
"echo '-- {{content}}'",
{
"content": content,
}
)
}
/**
*/
export function command_delete(
path : string
) : string
{
return lib_plankton.string.coin(
"rm --recursive --force {{path}}",
{
"path": path,
}
)
}
/**
*/
export function command_mkdir(
path : string
) : string
{
return lib_plankton.string.coin(
"mkdir --parents {{path}}",
{
"path": path,
}
)
}
/**
*/
export function command_cat(
source_paths : Array<string>,
target_path : string,
{
"append": append = false,
}
:
{
append ?: boolean;
}
=
{
}
) : string
{
return lib_plankton.string.coin(
"cat {{source_paths}} {{operator}} {{target_path}}",
{
"source_paths": source_paths.join(" "),
"operator": (append ? ">>" : ">"),
"target_path": target_path,
}
)
}
/**
*/
export function command_copy(
source_path : string,
target_path : string
) : string
{
return lib_plankton.string.coin(
"cp -r -u {{source_path}} {{target_path}}",
{
"source_path": source_path,
"target_path": target_path,
}
)
}
/**
*/
export function command_ptk_bundle(
target : string,
modules : Array<string>
) : string
{
return lib_plankton.string.coin(
"ptk bundle {{target}} {{modules}}",
{
"target": target,
"modules": modules.join(" "),
}
)
}
/**
*/
export function command_npm_install(
modules : Array<string>
) : string
{
return lib_plankton.string.coin(
"npm install {{modules}}",
{
"modules": modules.join(" "),
}
)
}
/**
*/
export function command_tsc(
source_paths : Array<string>,
target_path : string,
{
"declaration": declaration = false,
"libs": libs = [],
}
:
{
declaration ?: boolean;
libs ?: Array<string>;
}
=
{
}
) : string
{
return lib_plankton.string.coin(
"tsc{{libs}} {{source_paths}} --outFile {{target_path}}{{declaration}}",
{
"libs": (
libs
.map(
name => lib_plankton.string.coin(
" --lib {{name}}",
{"name": name}
),
)
.join("")
),
"source_paths": source_paths.join(" "),
"target_path": target_path,
"declaration": (declaration ? " --declaration" : ""),
}
)
}
}