Skip to content

Commit

Permalink
new update of dtcw
Browse files Browse the repository at this point in the history
  • Loading branch information
github-action committed Jan 10, 2024
1 parent ae33ae7 commit fc45c72
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 15 deletions.
20 changes: 15 additions & 5 deletions dtcw
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -o pipefail

# See https://github.com/docToolchain/docToolchain/releases for available versions.
# Set DTC_VERSION to "latest" to get the latest, yet unreleased version.
: "${DTC_VERSION:=3.2.0}"
: "${DTC_VERSION:=3.2.1}"

# The 'generateSite' and 'copyThemes' tasks support DTC_SITETHEME, an URL of a theme.
# export DTC_SITETHEME=https://....zip
Expand Down Expand Up @@ -41,7 +41,7 @@ GITHUB_PROJECT_URL=https://github.com/docToolchain/docToolchain
[email protected]:docToolchain/docToolchain

# Bump this version up if something is changed in the wrapper script
DTCW_VERSION=0.50
DTCW_VERSION=0.51
# Template replaced by the GitHub value upon releasing dtcw
DTCW_GIT_HASH=##DTCW_GIT_HASH##

Expand Down Expand Up @@ -88,15 +88,24 @@ main() {

# No install command, so forward call to docToolchain but first we check if
# everything is there.
docker_image_name=""
if [[ ${environment} != docker ]]; then
assert_doctoolchain_installed "${environment}" "${DTC_VERSION}"
assert_java_version_supported

# TODO: what if 'doctoolchain' found by $PATH does not match the one from the local environment?
# The version provided by $DTC_VERSION could be a different one.
else
docker_image_name="doctoolchain/doctoolchain"
if [ "${1}" = "image" ]; then
docker_image_name="${2-}"
shift 2
assert_argument_exists "$@"
fi
echo "Using docker image: ${docker_image_name}"
fi

command=$(build_command "${environment}" "${DTC_VERSION}" "$@")
command=$(build_command "${environment}" "${DTC_VERSION}" "${docker_image_name}" "$@")

[[ "${DTC_HEADLESS}" = true ]] && echo "Using headless mode since there is no (terminal) interaction possible"

Expand Down Expand Up @@ -585,7 +594,8 @@ how_to_install_doctoolchain() {
build_command() {
local env=${1}
local version=${2}
shift 2
local docker_image=${3}
shift 3
local cmd
if [ "${env}" = docker ]; then
# TODO: DTC_PROJECT_BRANCH is not passed into the docker environment
Expand All @@ -597,7 +607,7 @@ build_command() {

docker_args="run --rm -i --platform linux/amd64 -u $(id -u):$(id -g) --name ${container_name} \
-e DTC_HEADLESS=true -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} \
--entrypoint /bin/bash -v '${pwd}:/project' doctoolchain/doctoolchain:v${version}"
--entrypoint /bin/bash -v '${pwd}:/project' ${docker_image}:v${version}"

cmd="docker ${docker_args} -c \"doctoolchain . ${*} ${DTC_OPTS} && exit\""
else
Expand Down
22 changes: 17 additions & 5 deletions dtcw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ErrorActionPreference = "Stop"

# See https://github.com/docToolchain/docToolchain/releases for available versions.
# Set DTC_VERSION to "latest" to get the latest, yet unreleased version.
$DTC_VERSION = "3.2.0"
$DTC_VERSION = "3.2.1"
if ($env:DTC_VERSION) { $DTC_VERSION = $env:DTC_VERSION }

#here you can specify the URL of a theme to use with generateSite-task
Expand All @@ -45,7 +45,7 @@ $distribution_url = "https://github.com/docToolchain/docToolchain/releases/downl
$GITHUB_PROJECT_URL = "https://github.com/docToolchain/docToolchain"

# Bump this version up if something is changed in the wrapper script
$DTCW_VERSION = "0.52"
$DTCW_VERSION = "0.53"
# Template replaced by the GitHub value upon releasing dtcw
$DTCW_GIT_HASH = "##DTCW_GIT_HASH##"

Expand Down Expand Up @@ -100,17 +100,29 @@ function main($_args) {
}
# No install command, so forward call to docToolchain but first we check if
# everything is there.
$docker_image_name = ""
if ($environment -ne "docker")
{
assert_doctoolchain_installed "$environment" "$DTC_VERSION"
assert_java_version_supported
# TODO: what if 'doctoolchain' found by $PATH does not match the one from the local environment?
# The version provided by $DTC_VERSION could be a different one.
} else {
$docker_image_name = "doctoolchain/doctoolchain"
if ( $_args[0] -eq "install" ) {
# shift 1
$null, $_args = $_args
$docker_image_name = $_args[0]
# shift 1
$null, $_args = $_args
assert_argument_exists $_args
}
Write-Output "Using docker image: $docker_image_name"
}
# TODO: can generateDeck, bakePreview be used in combination with other commands?
# The code below assumes we have just one task.

$global:command = build_command "$environment" "$DTC_VERSION" $_args
$global:command = build_command "$environment" "$DTC_VERSION" "$docker_image_name" $_args

#TODO: implement HEADLESS mode
# [[ "${DTC_HEADLESS}" = true ]] && echo "Using headless mode since there is no (terminal) interaction possible"
Expand Down Expand Up @@ -550,7 +562,7 @@ Java runtime (major version 11, 14 or 17) installed on your host.
"@
}

function build_command($environment, $version, $_args) {
function build_command($environment, $version, $docker_image, $_args) {
$cmd = ""
if ( $environment -eq "docker") {
if (-not (Invoke-Expression "docker ps")) {
Expand All @@ -568,7 +580,7 @@ function build_command($environment, $version, $_args) {

# TODO: DTC_PROJECT_BRANCH is not passed into the docker environment
# See https://github.com/docToolchain/docToolchain/issues/1087
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} --entrypoint /bin/bash -v '${PWD}:/project' doctoolchain/doctoolchain:v${version}"
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} --entrypoint /bin/bash -v '${PWD}:/project' ${docker_image}:v${version}"
$cmd = "$docker_cmd ${docker_args} -c ""doctoolchain . $_args ${DTC_OPTS} && exit "" "

} else {
Expand Down
22 changes: 17 additions & 5 deletions dtcw.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ErrorActionPreference = "Stop"

# See https://github.com/docToolchain/docToolchain/releases for available versions.
# Set DTC_VERSION to "latest" to get the latest, yet unreleased version.
$DTC_VERSION = "3.2.0"
$DTC_VERSION = "3.2.1"
if ($env:DTC_VERSION) { $DTC_VERSION = $env:DTC_VERSION }

#here you can specify the URL of a theme to use with generateSite-task
Expand All @@ -36,7 +36,7 @@ $distribution_url = "https://github.com/docToolchain/docToolchain/releases/downl
$GITHUB_PROJECT_URL = "https://github.com/docToolchain/docToolchain"

# Bump this version up if something is changed in the wrapper script
$DTCW_VERSION = "0.52"
$DTCW_VERSION = "0.53"
# Template replaced by the GitHub value upon releasing dtcw
$DTCW_GIT_HASH = "##DTCW_GIT_HASH##"

Expand Down Expand Up @@ -91,17 +91,29 @@ function main($_args) {
}
# No install command, so forward call to docToolchain but first we check if
# everything is there.
$docker_image_name = ""
if ($environment -ne "docker")
{
assert_doctoolchain_installed "$environment" "$DTC_VERSION"
assert_java_version_supported
# TODO: what if 'doctoolchain' found by $PATH does not match the one from the local environment?
# The version provided by $DTC_VERSION could be a different one.
} else {
$docker_image_name = "doctoolchain/doctoolchain"
if ( $_args[0] -eq "install" ) {
# shift 1
$null, $_args = $_args
$docker_image_name = $_args[0]
# shift 1
$null, $_args = $_args
assert_argument_exists $_args
}
Write-Output "Using docker image: $docker_image_name"
}
# TODO: can generateDeck, bakePreview be used in combination with other commands?
# The code below assumes we have just one task.

$global:command = build_command "$environment" "$DTC_VERSION" $_args
$global:command = build_command "$environment" "$DTC_VERSION" "$docker_image_name" $_args

#TODO: implement HEADLESS mode
# [[ "${DTC_HEADLESS}" = true ]] && echo "Using headless mode since there is no (terminal) interaction possible"
Expand Down Expand Up @@ -541,7 +553,7 @@ Java runtime (major version 11, 14 or 17) installed on your host.
"@
}

function build_command($environment, $version, $_args) {
function build_command($environment, $version, $docker_image, $_args) {
$cmd = ""
if ( $environment -eq "docker") {
if (-not (Invoke-Expression "docker ps")) {
Expand All @@ -559,7 +571,7 @@ function build_command($environment, $version, $_args) {

# TODO: DTC_PROJECT_BRANCH is not passed into the docker environment
# See https://github.com/docToolchain/docToolchain/issues/1087
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} --entrypoint /bin/bash -v '${PWD}:/project' doctoolchain/doctoolchain:v${version}"
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} --entrypoint /bin/bash -v '${PWD}:/project' ${docker_image}:v${version}"
$cmd = "$docker_cmd ${docker_args} -c ""doctoolchain . $_args ${DTC_OPTS} && exit "" "

} else {
Expand Down

0 comments on commit fc45c72

Please sign in to comment.