Giter Site home page Giter Site logo

wolfe-labs / du-luac Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 14.0 2.18 MB

๐Ÿ‘จโ€๐Ÿ’ป Lua command-line utility for Dual Universe Lua projects

Home Page: https://www.npmjs.com/package/@wolfe-labs/du-luac

License: BSD 3-Clause "New" or "Revised" License

JavaScript 0.42% Lua 79.56% TypeScript 20.01%
cli command-line compiler dual-universe lua scripts utility

du-luac's People

Contributors

leniver avatar matpratta avatar permalmberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

du-luac's Issues

Install on Windows fail

Not sure if it is a problem with upgraded dependencies or with my local system

`npm i -g @wolfe-labs/du-luac
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm WARN deprecated [email protected]: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm ERR! code 1
npm ERR! path C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\nodegit
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node lifecycleScripts/preinstall && node lifecycleScripts/install
npm ERR! [nodegit] Running pre-install script
npm ERR! [nodegit] Running install script
npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\nodegit\build\Release\nodegit.node --module_name=nodegit --module_path=C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\nodegit\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
npm ERR! node-pre-gyp
npm ERR! info it worked if it ends with ok
npm ERR! node-pre-gyp
npm ERR! info using [email protected]
npm ERR! node-pre-gyp
npm ERR! info using [email protected] | win32 | x64
npm ERR! node-pre-gyp WARN
npm ERR! Using request for node-pre-gyp https download
npm ERR! node-pre-gyp
npm ERR! info check checked for "C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\nodegit\build\Release\nodegit.node" (not found)
npm ERR! node-pre-gyp
npm ERR! http GET https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
npm ERR! node-pre-gyp
npm ERR! http 404 https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(404): https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 404 status code downloading tarball https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
npm ERR! gyp
npm ERR!
npm ERR! info it worked if it ends with ok
npm ERR! gyp
npm ERR! info using [email protected]
npm ERR! gyp
npm ERR! info
npm ERR! using [email protected] | win32 | x64
npm ERR! gyp
npm ERR! info
npm ERR! ok
npm ERR! gyp
npm ERR!
npm ERR! info it worked if it ends with ok
npm ERR! gyp
npm ERR! info using
npm ERR! [email protected]
npm ERR! gyp
npm ERR! info using [email protected] | win32 | x64
npm ERR! gyp
npm ERR! info find Python using Python version 3.10.0 found at "C:\Users\tiramon\AppData\Local\Programs\Python\Python310\python.exe"
npm ERR! gyp
npm ERR! ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more detailsnpm ERR! gyp ERR!
npm ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp
npm ERR! ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp
npm ERR! ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR!
npm ERR! find VS
npm ERR! gyp
npm ERR! ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
npm ERR! gyp
npm ERR! ERR! stack at C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
npm ERR! gyp ERR! stack at C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
npm ERR! gyp ERR!
npm ERR! stack at C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
npm ERR! gyp ERR! stack at C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp
npm ERR! ERR! stack at ChildProcess.exithandler (node:child_process:404:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack
npm ERR! at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\Users\tiramon\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\node_modules\nodegit\build\Release\nodegit.node" "--module_name=nodegit" "--module_path=C:\Users\tiramon\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\node_modules\nodegit\build\Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
npm ERR! gyp ERR! cwd C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\nodegit
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack
npm ERR! Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\tiramon\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --mod\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\node --module_path=C:\Users\tiramon\AppData\Roaming\npm\git\build\Release\nodegit.node --module_name=nodegit --module_path=C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_mbel=node-v93' (1)odules\nodegit\build\Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1) dules\node-pre-gyp\lib\util\compile.js:83:29)
npm ERR! node-pre-gyp ERR! stack at ChildProcess. (C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:390:28)
npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
npm ERR! node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! node-pre-gyp ERR! System \du-luac\node_modules\node-pre-gyp\bin\node-pre-
npm ERR! Windows_NT 10.0.19042
npm ERR! node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\tiramon\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd C:\Users\tiramon\AppData\Roaming\npm\node_modules@wolfe-labs\du-luac\node_modules\nodegit
npm ERR! node-pre-gyp ERR! node -v v16.13.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.13.0
npm ERR! node-pre-gyp ERR! not ok
npm ERR! [nodegit] ERROR - Could not finish install
npm ERR! [nodegit] ERROR - finished with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tiramon\AppData\Local\npm-cache_logs\2021-11-29T13_58_20_349Z-debug.log`

Build target "env variables" and compiler-level conditionals

The idea here is to introduce compiler-level conditionals, which would allow pieces of the Lua source to be added or ignored, based on a set of "environment variables" set in the project.json file, more specifically under each build target.

For example, let's say we have the "development" build target, under which the following is added:

{
  "environment": {
    "debug": true,
    "test": "some value"
  }
}

Now, insider our code, we can have something like this:

--#IF debug
system.print('debug is enabled')
--#ENDIF

--#IF test "some value"
system.print('some value provided')
--#ENDIF

In the example above, whenever environment.debug exists and is true, the first block will be added to the source code, while for the second block, whenever environment.test matches "some value", the second block will be added to the source code.

Test folder addition

The ability to set a testPath
for test programs, that will be put the compiled test programs in the "out/testPath//" folders

embedFile(): use same file resolving method as require()

The compiler uses the LUA_PATH for resolving filenames for the require() command.
However, the embedFile() only seems to try to find the file in the same directory where called from.
It would be helpful and consistent if embedFile would use the same filename resolving mechanism as e.g. renderscripts could be located in their own location.

Looked in the source for it:
In src/compiler_functions.ts -> export default class LibraryEmbedFileFunction -> invoke
should equally use "getRequiredFileInfo()" method (in DULuaCompiler.ts)

Production minify created error code

I had 2 lines in my script that were valid lua, but got minified to an error

varb = vara - 1.
varc = something

got minified to (don't mind the variable names)

a=b-1.c=d

it is working fine when i use 1.0 it then becomes

a=b-1.0;c=d

Create improved documentation page

The idea is to migrate all relevant information to a separate page and remove it from README, maybe to a project wiki.

A "Getting Started" guide would be great. Pages detailing each feature would definitely be helpful, too.

Feature: Support embedding of compiled Lua files

We currently have library.embedFile which basically takes a file from the current directory and embeds it as a Lua literal, it's quite helpful to embed data like render scripts, but I'd like to take it a bit further.

The idea is to add something like library.embedLua (accepting name suggestions) where it would take a build by its name (or maybe any Lua file? what could go wrong?), do all the processing from du-lua build for that build and then embed its resulting Lua into the code.

This would make it possible to embed Lua render scripts that make use of require statements to import render script specific libraries, plus also allowing for code minification on embedded Lua files.

New autoconf generator to generate both JSON and YAML

Currently DU-LuaC has a dependency on wrap.lua and on the Lua environment being installed by the end-user.

In order to have more control of the output and also to drop the dependency on these, specially the Lua environment, ideally the tool should be able to create its own JSON and YAML files.

It shouldn't be very complex, as they are pretty much just objects defining the slots and both JSON and YAML are quite easy to export using JS, more a question of taking and implementing it.

Also if possible, move all the require codes into the "Library" section of the scripts. This is almost never used and would make scripts much cleaner for editing in-game too.

Feature: Add more element types to the linking command

The idea here is adding extra element types (possibly in a new category) to the script-link command.

While those aren't very useful for JSON/YAML outputs, it allows for automatic linking on CONF outputs.

Possible new elements:

  • Telemeter
  • Transponder
  • Engines (Atmo, Space, Adjustor)
  • Brakes
  • Airfoils (Wings, Ailerons, Stabilizers)
  • Vertical Boosters
  • Hover Engines

This might be useful: https://github.com/dual-universe/lua-examples/tree/main/api-mockup

Improve project.json files, standardize paths

Currently the project.json files are quite a mess and paths are pretty much unstandardized. On Windows they will use backwards slash while on Linux they will use normal slash, which becomes annoying and may cause bugs in the future.

Also, right now there's no entrypoint for libraries, which forces anyone developing with the CLI/compiler to add require('@namespace/project:main') to go into what should be the entrypoint. The :main part shouldn't be necessary.

Add config value to strip comments in non-minified builds

Introduce to project.json's targets an option "stripComments" that - if true - removes all lua comments from the source upon compile even if "minify" is false.
If there are only leading blanks in front of the comment, remove the whole line.
Single-line comments with "--" or "---" mainly, not multi-line comments as those may have special meaning.

Allow passing of build target name to build command

In the current setup, the compiler will always build all available build targets, which can be time consuming.

What this proposes is the addition of an optional parameter to the build command, with the build target, so something like this becomes possible: du-lua build development

Add support to sumneko's Lua extension

Might require some extra fiddling with the .vscode directory, most specifically to set Lua version, ignore directory, library (for Codex) and max preloads (to support over 500kb of the Codex):

{
    "Lua.runtime.version": "Lua 5.3",
    "Lua.workspace.ignoreDir": [
        ".vscode",
        "out"
    ],
    "Lua.workspace.library": [
        "util/Codex.lua"
    ],
    "Lua.workspace.preloadFileSize": 1000,
    "Lua.workspace.maxPreload": 10000
}

Chore: Improve codex generation

Initial suggestion from Leniver over Discord:

  • Libraries additional functions (getLinks,getLinksByClass,...) should be declared after default NQ Library is declared

  • And "Library" should be used instead of "library"

  • New function "clearAllEventHandlers" is missing in the codex

Main objective here is investigate the impact of those changes and possibly merge them into production.

no such file or directory, open 'XYZ\out\development\main.lua

If you set up a new project like described in the readme

du-lua create XYZ
du-lua script-add main
du-lua script-link main
du-lua target-add
du-lua build

the build crashs with

Lua CLI Utility for Dual Universe v0.6.0 by Wolfe Labs @ Node v14.17.0
No Lua tools found on your system. This will not affect builds.
You can download the binaries at: http://luabinaries.sourceforge.net/

Loading project file: XYZ\project.json
Loading project library: "XYZ"

Compiling build "main"...
Fetching project entry point: main
-> Building file: XYZ\src\main.lua
Building LUA AST and checking for syntax errors...
-> No syntax errors found!
Generating build files for target "development"...
-> Writing Lua output...
(node:71952) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'XYZ\out\development\main.lua'
    at Object.openSync (fs.js:498:3)
    at Object.writeFileSync (fs.js:1524:35)
    at C:\Users\USER\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\build.js:181:10
    at Array.map (<anonymous>)
    at C:\Users\USER\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\build.js:161:100
    at Array.map (<anonymous>)
    at module.exports (C:\Users\USER\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\build.js:138:95)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:71952) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:71952) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Problem is that the out/development folder is not created automatically
If the folders are created manually it build just fine

Bug: Strings and comments that contain a `require` statement also triggers parent `require`

With the current way require statements are handled by the CLI, any require('something') statement is matched as a require, no matter where it is on code. This brings up an issue when that statement is inside a comment or a string.

For example, in this piece of code:

local lib1 = require('lib-default')
local lib2 = require('lib-default-error')

--[[
  This is some comment where we add require('lib-comment') and require('lib-comment-error')
]]

local str1 = [[ require('lib-string') ]]
local str2 = [[ require('lib-string-error') ]]

We should only have 2 "real" requires, which are the ones on top. The ones inside the comment and string should not match, but on the current setup they do.

This issue's main objective is to fix that.

A possible solution would be migrating away from regex matching and using something such as luaparse for doing it, but the main issue would be depending on someone else's package, plus it doesn't seem to support Lua 5.4 yet.

Open for suggestions.

import github library

You wrote that importing a library with the git https clone url should work ...
Or is it a must that the imported lib is a du-lua project?

$ du-lua import https://github.com/EasternGamer/AR-Library.git
Lua CLI Utility for Dual Universe v0.6.3 by Wolfe Labs @ Node v10.16.0
Downloading library files from: "https://github.com/EasternGamer/AR-Library.git"
(node:324) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:125:11)
    at Object.join (path.js:427:7)
    at Function.getProjectInfo (C:\Users\tiramon\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\library.js:178:53)
    at Function.loadExternalLibrary (C:\Users\tiramon\AppData\Roaming\npm\node_modules\@wolfe-labs\du-luac\library.js:142:37)
(node:324) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not 
handled with .catch(). (rejection id: 2)
(node:324) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.   

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.