Coder Social home page Coder Social logo

README.md suggestion about modernuo HOT 6 CLOSED

nerun avatar nerun commented on June 28, 2024
README.md suggestion

from modernuo.

Comments (6)

kamronbatman avatar kamronbatman commented on June 28, 2024 1

Ohhh I like this, where you actually go from publish.cmd -> publish.sh so that way you get the shebang.

Do you want to make a PR for this, or should I?

from modernuo.

kamronbatman avatar kamronbatman commented on June 28, 2024

I think this is still valid since zsh throws errors with publish.cmd directly. Workaround is to use publish.sh, or maybe someone can help update publish.cmd to be more broadly usable.

from modernuo.

nerun avatar nerun commented on June 28, 2024

Ok, errors with CMD file:

$ ./publish.cmd release linux x64
./publish.cmd: 10: [[: not found
./publish.cmd: 12: [[: not found
./publish.cmd: 19: Syntax error: redirection unexpected

There should be an issue with if [[ ... ]], maybe if [ ... ] should be used. To be POSIX compliant, change:

if [[ -n $os ]]; then
  os="-r $os"
elif [[ $(uname) = "Darwin" ]]; then
  os="-r osx"

To:

if [ -n $os ]; then
  os="-r $os"
elif [ $(uname) = "Darwin" ]; then
  os="-r osx"

Or to:

if [ -n $os ]; then
  os="-r $os"
elif [[ $(uname) == "Darwin" ]]; then
  os="-r osx"

The last one:

config="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}"

I don't know what it is supposed to do, but i can't see the end of the command $(command here). Don't know what to do here.

But with the two fixes above:

$ ./publish.cmd release linux x64
./publish.cmd: 19: Syntax error: redirection unexpected

And it still works with publish.sh. Check if it works on Windows.

from modernuo.

nerun avatar nerun commented on June 28, 2024

Uh ok, i got it: Stack Overflow - uppercase first character in a variable with bash

config="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}" is to uppercase 1st letter

from modernuo.

nerun avatar nerun commented on June 28, 2024

One way is to move the entire ::SHELLSCRIPT (up to exit $? inclusive) to publish.sh. It worked for me, i run publish.cmd successfully in ZSH / Linux Mint.

publish.cmd

:<<"::SHELLSCRIPT"
@ECHO OFF
GOTO :CMDSCRIPT

::SHELLSCRIPT
path=$(dirname "$0")
cd $path
./publish.sh
exit 1

:CMDSCRIPT

IF "%~1" == "" (
  SET config=-c Release
) ELSE (
  IF "%~1" == "release" (
    SET config=-c Release
  ) ELSE (
    SET config=-c Debug
  )
)

IF "%~2" == "" (
  SET os=-r win
) ELSE (
  SET os=-r %~2
)

IF "%~3" == "" (
  SET arch=x64
) ELSE (
  SET arch=%~3
)

echo dotnet tool restore
dotnet tool restore

echo dotnet clean --verbosity quiet
dotnet clean --verbosity quiet
echo dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json
dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json

echo dotnet publish %config% %os%-%arch% --no-restore --self-contained=false -o Distribution\Assemblies Projects\UOContent\UOContent.csproj
dotnet publish %config% %os%-%arch% --no-restore --self-contained=false -o Distribution\Assemblies Projects\UOContent\UOContent.csproj

echo Generating serialization migration schema...
dotnet tool run ModernUOSchemaGenerator -- ModernUO.sln

publish.sh

#!/bin/bash
config=$1
os=$2
arch=${3:-$(uname -m)}

if [[ -n $os ]]; then
  os="-r $os"
elif [[ $(uname) = "Darwin" ]]; then
  os="-r osx"
else
  os="-r linux"
fi

if [[ $config ]]; then
  config="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}"
  config="-c $config"
else
  config="-c Release"
fi

if [[ $arch == *'aarch'* || $arch == *'arm'* ]]; then
  arch="arm64"
else
  arch="x64"
fi

if [[ $os == *'centos'* || $os == *'rhel'* ]]; then
  export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
fi

echo dotnet tool restore
dotnet tool restore

echo dotnet clean --verbosity quiet
dotnet clean --verbosity quiet
echo dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json
dotnet restore --force-evaluate --source https://api.nuget.org/v3/index.json

echo dotnet publish ${config} ${os}-${arch} --no-restore --self-contained=false -o Distribution/Assemblies Projects/UOContent/UOContent.csproj
dotnet publish ${config} ${os}-${arch} --no-restore --self-contained=false -o Distribution/Assemblies Projects/UOContent/UOContent.csproj

echo Generating serialization migration schema...
dotnet tool run ModernUOSchemaGenerator -- ModernUO.sln

exit $?

from modernuo.

nerun avatar nerun commented on June 28, 2024

Yes, i dit it.

ERRATA

In publish.cmd, this:

::SHELLSCRIPT
./publish.sh
exit 1

Would be better to be:

::SHELLSCRIPT
path=$(dirname "$0")
cd $path
./publish.sh
exit 1

Just in case you call publish.cmd from another directory.

from modernuo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.