diff --git a/Earthfile b/Earthfile index 6f2cd53e..86fddb6e 100644 --- a/Earthfile +++ b/Earthfile @@ -214,10 +214,19 @@ run.n: COPY .git .git COPY src src COPY hx3compat hx3compat - COPY client.hxml haxelib.json . + COPY client.hxml each.hxml haxelib.json . RUN haxe client.hxml SAVE ARTIFACT run.n AS LOCAL run.n +haxelib-binary: + FROM +devcontainer + COPY .git .git + COPY src src + COPY hx3compat hx3compat + COPY client_cpp.hxml each.hxml haxelib.json . + RUN haxe client_cpp.hxml + SAVE ARTIFACT haxelib AS LOCAL haxelib + package-haxelib: FROM +devcontainer-base COPY src src @@ -379,7 +388,7 @@ haxelib-server-builder: haxelib-server-legacy: FROM +haxelib-server-builder - COPY server_legacy.hxml server_each.hxml . + COPY server_legacy.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat COPY www/legacy www/legacy @@ -388,7 +397,7 @@ haxelib-server-legacy: haxelib-server-website: FROM +haxelib-server-builder - COPY server_website.hxml server_each.hxml . + COPY server_website.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat RUN haxe server_website.hxml @@ -402,7 +411,7 @@ haxelib-server-website-highlighter: haxelib-server-tasks: FROM +haxelib-server-builder - COPY server_tasks.hxml server_each.hxml . + COPY server_tasks.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat RUN haxe server_tasks.hxml @@ -410,7 +419,7 @@ haxelib-server-tasks: haxelib-server-api: FROM +haxelib-server-builder - COPY server_api.hxml server_each.hxml . + COPY server_api.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat RUN haxe server_api.hxml @@ -550,6 +559,7 @@ ci-tests: # for package.hxml COPY haxelib.json README.md . COPY +run.n/run.n . + COPY +haxelib-binary/haxelib . COPY +ci-runner/ci.n bin/ci.n ENV HAXELIB_SERVER=localhost diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..1ef5dc28 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2005-2024 Haxe Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/client.hxml b/client.hxml index e5a3ae3c..8339bdfd 100644 --- a/client.hxml +++ b/client.hxml @@ -1,6 +1,3 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +each.hxml -neko run.n -main haxelib.client.Main diff --git a/client_cpp.hxml b/client_cpp.hxml new file mode 100644 index 00000000..0873c881 --- /dev/null +++ b/client_cpp.hxml @@ -0,0 +1,6 @@ +each.hxml +--cpp bin/cpp +--main haxelib.client.Main +-D destination=../../haxelib{EXESUFFIX} +--dce full +-D analyzer-optimize diff --git a/client_legacy.hxml b/client_legacy.hxml index b35394fe..cea40579 100644 --- a/client_legacy.hxml +++ b/client_legacy.hxml @@ -1,6 +1,3 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +each.hxml -neko bin/legacyhaxelib.n -main legacyhaxelib.Main \ No newline at end of file diff --git a/client_tests.hxml b/client_tests.hxml index 38c61023..63d96aba 100644 --- a/client_tests.hxml +++ b/client_tests.hxml @@ -1,8 +1,5 @@ --p src +each.hxml -p test --p hx3compat/std --p hx4compat/std --p crypto/src --main HaxelibTests --debug --neko bin/test.n diff --git a/each.hxml b/each.hxml new file mode 100644 index 00000000..1442fc5a --- /dev/null +++ b/each.hxml @@ -0,0 +1,4 @@ +-cp src +-cp hx3compat/std +-cp hx4compat/std +-cp crypto/src diff --git a/integration_tests.hxml b/integration_tests.hxml index 364917a7..33f943c2 100644 --- a/integration_tests.hxml +++ b/integration_tests.hxml @@ -1,8 +1,5 @@ --cp src --cp test --cp hx4compat/std --cp crypto/src --lib hx3compat +each.hxml +-p test -lib record-macros -lib argon2 -main IntegrationTests diff --git a/libs.hxml b/libs.hxml index d93b2006..209d176f 100644 --- a/libs.hxml +++ b/libs.hxml @@ -29,5 +29,6 @@ -cmd curl -sSLk https://lib.haxe.org/files/3.0/ufront-2,0,0.zip -o haxelib_global/ufront.zip && neko run.n install --always --skip-dependencies haxelib_global/ufront.zip -cmd curl -sSLk https://lib.haxe.org/files/3.0/utest-1,9,6.zip -o haxelib_global/utest.zip && neko run.n install --always --skip-dependencies haxelib_global/utest.zip -cmd curl -sSLk https://lib.haxe.org/files/3.0/hxnodejs-12,1,0.zip -o haxelib_global/hxnodejs.zip && neko run.n install --always --skip-dependencies haxelib_global/hxnodejs.zip +-cmd curl -sSLk https://lib.haxe.org/files/3.0/hxcpp-4,3,2.zip -o haxelib_global/hxcpp.zip && neko run.n install --always --skip-dependencies haxelib_global/hxcpp.zip -cmd neko run.n dev record-macros lib/record-macros -cmd neko run.n dev argon2 lib/argon2 diff --git a/package.hxml b/package.hxml index 0531ad3e..1449485c 100755 --- a/package.hxml +++ b/package.hxml @@ -1,5 +1,2 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +-p src --run Package \ No newline at end of file diff --git a/run.n b/run.n index a469906f..2b281c0c 100644 Binary files a/run.n and b/run.n differ diff --git a/server_each.hxml b/server_each.hxml index d83028bb..e18d71d7 100644 --- a/server_each.hxml +++ b/server_each.hxml @@ -1,7 +1,4 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +each.hxml -lib ufront -lib ufront-mail:1.0.0-rc.4 -lib ufront-ufadmin diff --git a/server_gitrepo.hxml b/server_gitrepo.hxml index 8a93ca92..b3276ec0 100644 --- a/server_gitrepo.hxml +++ b/server_gitrepo.hxml @@ -1,9 +1,6 @@ ---class-path src +each.hxml --class-path lib/dts2hx-generated --class-path lib/node-sys-db ---class-path hx3compat/std ---class-path hx4compat/std ---class-path crypto/src --library hxnodejs --library record-macros --js gitrepo.js diff --git a/server_legacy.hxml b/server_legacy.hxml index 3e559317..f522ee63 100644 --- a/server_legacy.hxml +++ b/server_legacy.hxml @@ -1,5 +1,4 @@ server_each.hxml --cp src -neko www/legacy/index.n -main legacyhaxelib.Site -lib hx2compat diff --git a/src/Package.hx b/src/Package.hx index d5ddc229..bf843520 100644 --- a/src/Package.hx +++ b/src/Package.hx @@ -5,7 +5,6 @@ import haxe.zip.Tools; import sys.io.File; import sys.FileSystem; -import haxelib.client.Main.VERSION; import haxelib.Data.Infos; using StringTools; diff --git a/src/haxelib/api/GlobalScope.hx b/src/haxelib/api/GlobalScope.hx index cb0567b1..a4b95de0 100644 --- a/src/haxelib/api/GlobalScope.hx +++ b/src/haxelib/api/GlobalScope.hx @@ -47,7 +47,7 @@ class GlobalScope extends Scope { main: info.main }; - ScriptRunner.run(libraryRunData, resolveCompiler(), callData); + ScriptRunner.run(libraryRunData, callData, () -> haxeVersion); } public function getVersion(library:ProjectName):Version { diff --git a/src/haxelib/api/Installer.hx b/src/haxelib/api/Installer.hx index 18d21a96..d2e20428 100644 --- a/src/haxelib/api/Installer.hx +++ b/src/haxelib/api/Installer.hx @@ -263,6 +263,8 @@ class Installer { if (confirmHxmlInstall != null && !confirmHxmlInstall(libVersions)) return; + var hasFailures = false; + for (library in installData) { if (library.versionData.match(Haxelib(_)) && repository.isVersionInstalled(library.name, library.version)) { final version = SemVer.ofString(library.version); @@ -281,6 +283,7 @@ class Installer { try installFromVersionData(library.name, library.versionData) catch (e) { + hasFailures = true; userInterface.log(e.toString()); continue; } @@ -296,6 +299,8 @@ class Installer { handleDependenciesGeneral(libraryName, library.versionData); } + + if (hasFailures) throw "Some libraries could not be installed."; } /** @@ -762,7 +767,7 @@ class Installer { userInterface.log('Installing $library from $url' + (branch != null ? " branch: " + branch : "")); final tag = vcsData.tag; try { - vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug)); + vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug), userInterface.log.bind(_, Optional)); } catch (error:VcsError) { FsUtils.deleteRec(libPath); switch (error) { @@ -774,6 +779,8 @@ class Installer { throw 'Could not checkout branch, tag or path "$branch": ' + stderr; case CantCheckoutVersion(_, version, stderr): throw 'Could not checkout tag "$version": ' + stderr; + case SubmoduleError(_, repo, stderr): + throw 'Could not clone submodule(s) from $repo: ' + stderr; case CommandFailed(_, code, stdout, stderr): throw new VcsCommandFailed(id, code, stdout, stderr); }; diff --git a/src/haxelib/api/ScriptRunner.hx b/src/haxelib/api/ScriptRunner.hx index b0aef8f1..db966045 100644 --- a/src/haxelib/api/ScriptRunner.hx +++ b/src/haxelib/api/ScriptRunner.hx @@ -79,13 +79,13 @@ class ScriptRunner { /** Run `library`, with `callData`. - `compilerData` is used if it is an interpreted script. + `getCompilerVersion` is used if it is an interpreted script. **/ - public static function run(library:LibraryRunData, compilerData:LibraryData, callData:CallData):Void { + public static function run(library:LibraryRunData, callData:CallData, getCompilerVersion:()->SemVer):Void { final type = getType(library); final cmd = getCmd(type); - final args = generateArgs(type, callData, SemVer.ofString(compilerData.version)); + final args = generateArgs(type, callData, getCompilerVersion); final oldState = getState(); @@ -122,7 +122,7 @@ class ScriptRunner { } } - static function generateArgs(runType:RunType, callData:CallData, compilerVersion:SemVer):Array { + static function generateArgs(runType:RunType, callData:CallData, getCompilerVersion:() -> SemVer):Array { switch runType { case Neko(path): final callArgs = callData.args.copy(); @@ -130,7 +130,7 @@ class ScriptRunner { callArgs.push(callData.dir); return callArgs; case Script(main, name, version, dependencies): - final isHaxe4 = SemVer.compare(compilerVersion, SemVer.ofString('4.0.0')) >= 0; + final isHaxe4 = SemVer.compare(getCompilerVersion(), SemVer.ofString('4.0.0')) >= 0; final useGlobalRepo = isHaxe4 && callData.useGlobalRepo; final callArgs = generateScriptArgs(main, name, version, dependencies, useGlobalRepo); diff --git a/src/haxelib/api/Vcs.hx b/src/haxelib/api/Vcs.hx index 4ebfedb3..8fda1e35 100644 --- a/src/haxelib/api/Vcs.hx +++ b/src/haxelib/api/Vcs.hx @@ -48,7 +48,7 @@ interface IVcs { `debugLog` will be used to log executable output. **/ - function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void; + function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void; /** Updates repository in CWD or CWD/`Vcs.directory` to HEAD. @@ -74,6 +74,7 @@ enum VcsError { CantCheckoutBranch(vcs:Vcs, branch:String, stderr:String); CantCheckoutVersion(vcs:Vcs, version:String, stderr:String); CommandFailed(vcs:Vcs, code:Int, stdout:String, stderr:String); + SubmoduleError(vcs:Vcs, repo:String, stderr:String); } /** Exception thrown when a vcs update is cancelled. **/ @@ -230,7 +231,7 @@ abstract class Vcs implements IVcs { return ret; } - public abstract function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void; + public abstract function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void; public abstract function update(?confirm:() -> Bool, ?debugLog:(msg:String) -> Void, ?summaryLog:(msg:String) -> Void):Bool; @@ -320,13 +321,16 @@ class Git extends Vcs { return true; } - public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void { + public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void { final oldCwd = Sys.getCwd(); - final vcsArgs = ["clone", url, libPath]; + var vcsArgs = ["clone", url, libPath]; - if (!Vcs.flat) - vcsArgs.push('--recursive'); + inline function printOptional(msg) + if (optionalLog != null && msg != "") + optionalLog(msg); + + printOptional('Cloning ${name} from ${url}'); if (run(vcsArgs, debugLog).code != 0) throw VcsError.CantCloneRepo(this, url/*, ret.out*/); @@ -334,12 +338,16 @@ class Git extends Vcs { Sys.setCwd(libPath); if (version != null && version != "") { + printOptional('Checking out tag/version ${version} of ${name}'); + final ret = run(["checkout", "tags/" + version], debugLog); if (ret.code != 0) { Sys.setCwd(oldCwd); throw VcsError.CantCheckoutVersion(this, version, ret.out); } } else if (branch != null) { + printOptional('Checking out branch/commit ${branch} of ${libPath}'); + final ret = run(["checkout", branch], debugLog); if (ret.code != 0){ Sys.setCwd(oldCwd); @@ -347,6 +355,22 @@ class Git extends Vcs { } } + if (!Vcs.flat) + { + printOptional('Syncing submodules for ${name}'); + run(["submodule", "sync", "--recursive"], debugLog); + + var submoduleArgs = ["submodule", "update", "--init", "--recursive"]; + + printOptional('Downloading/updating submodules for ${name}'); + final ret = run(submoduleArgs, debugLog); + if (ret.code != 0) + { + Sys.setCwd(oldCwd); + throw VcsError.SubmoduleError(this, url, ret.out); + } + } + // return prev. cwd: Sys.setCwd(oldCwd); } @@ -421,7 +445,7 @@ class Mercurial extends Vcs { return changed; } - public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void { + public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void { final vcsArgs = ["clone", url, libPath]; if (branch != null && version != null) { diff --git a/src/haxelib/client/Main.hx b/src/haxelib/client/Main.hx index fc438511..eb943a8a 100644 --- a/src/haxelib/client/Main.hx +++ b/src/haxelib/client/Main.hx @@ -214,7 +214,7 @@ class Main { Version => create(version, 0), Help => create(usage, 0), - #if neko + #if !js Submit => create(submit, 3, true), #end Register => create(register, 5, true), @@ -227,7 +227,7 @@ class Main { DeleteRepo => create(deleteRepo, 0), ConvertXml => create(convertXml, 0), Run => create(run, null), - #if neko + #if !js Proxy => create(proxy, 5, true), #end FixRepo => create(fixRepo, 0), @@ -264,7 +264,7 @@ class Main { try { if (commandInfo.net) { - #if neko + #if !js loadProxy(); #end checkUpdate(); @@ -367,7 +367,7 @@ class Main { return encodedPassword; } - #if neko + #if !js function getContributor(contributors:Array): {name:String, password:String} { var user:String = contributors[0]; @@ -780,7 +780,7 @@ class Main { } } - #if neko + #if !js function proxy() { final rep = getRepositoryPath(); final host = getArgument("Proxy host"); diff --git a/test/IntegrationTests.hx b/test/IntegrationTests.hx index 69987a21..9352a04f 100644 --- a/test/IntegrationTests.hx +++ b/test/IntegrationTests.hx @@ -97,6 +97,8 @@ class IntegrationTests extends TestBase { function haxelib(args:Array, ?input:String):Process { final p = #if system_haxelib new Process("haxelib", ["-R", serverUrl].concat(args)); + #elseif haxelib_path + new Process(haxe.macro.Compiler.getDefine("haxelib_path"), ["-R", serverUrl].concat(args)); #else new Process("neko", [haxelibBin, "-R", serverUrl].concat(args)); #end diff --git a/test/RunCi.hx b/test/RunCi.hx index 268b178e..40c4dd0f 100644 --- a/test/RunCi.hx +++ b/test/RunCi.hx @@ -370,19 +370,6 @@ Listen 2000 } static function integrationTests():Void { - function test():Void { - switch (Sys.getEnv("TRAVIS_HAXE_VERSION")) { - case null, "development": - runCommand("haxe", ["integration_tests.hxml"]); - case "3.1.3": - runCommand("haxe", ["integration_tests.hxml", "-D", "system_haxelib"]); - case _: - runCommand("haxe", ["integration_tests.hxml"]); - runCommand("neko", ["bin/integration_tests.n"]); - runCommand("haxe", ["integration_tests.hxml", "-D", "system_haxelib"]); - } - runCommand("neko", ["bin/integration_tests.n"]); - } var dbConfigPath = Path.join(["www", "dbconfig.json"]); saveContent(dbConfigPath, Json.stringify({ user: Sys.getEnv("HAXELIB_DB_USER"), @@ -391,7 +378,14 @@ Listen 2000 port: Std.parseInt(Sys.getEnv("HAXELIB_DB_PORT")), database: Sys.getEnv("HAXELIB_DB_NAME"), }, "\t")); - test(); + runCommand("haxe", ["integration_tests.hxml"]); + runCommand("neko", ["bin/integration_tests.n"]); + runCommand("haxe", [ + "integration_tests.hxml", + "-D", + 'haxelib_path=${Path.join([Sys.getCwd(), "haxelib"])}' + ]); + runCommand("neko", ["bin/integration_tests.n"]); } static function deploy():Void {