From 246a1261f8eb35572837fafb53db365ecabc674b Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Wed, 21 Oct 2020 11:59:53 -0700 Subject: [PATCH] CHANGELOG and haxelib script --- CHANGELOG.md | 5 +++ haxelib/PackageHaxelib.hx | 73 +++++++++++++++++++++++++++++++++++++++ haxelib/README.md | 7 ++++ haxelib/haxelib.hxml | 2 ++ 4 files changed, 87 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 haxelib/PackageHaxelib.hx create mode 100644 haxelib/README.md create mode 100644 haxelib/haxelib.hxml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2be9f4b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +markdown-openfl-textfield Change Log + +1.0.0 (2020-10-21) + +- Initial release diff --git a/haxelib/PackageHaxelib.hx b/haxelib/PackageHaxelib.hx new file mode 100644 index 0000000..533ac47 --- /dev/null +++ b/haxelib/PackageHaxelib.hx @@ -0,0 +1,73 @@ + +import haxe.Json; +import haxe.crypto.Crc32; +import haxe.io.Bytes; +import haxe.io.Path; +import haxe.zip.Entry; +import haxe.zip.Writer; +import sys.FileSystem; +import sys.io.File; + +class PackageHaxelib { + public static function main():Void { + var entries = new List(); + addFile(FileSystem.absolutePath("../haxelib.json"), entries); + addFile(FileSystem.absolutePath("../README.md"), entries); + addFile(FileSystem.absolutePath("../CHANGELOG.md"), entries); + addFile(FileSystem.absolutePath("../LICENSE"), entries); + addDirectory(FileSystem.absolutePath("../src"), true, entries); + + var jsonContent = File.getContent("../haxelib.json"); + var json = Json.parse(jsonContent); + var packageName = Std.string(json.name); + var packageVersion = Std.string(json.version); + var releaseNote = Std.string(json.releasenote); + var packageFileName = '${packageName}-${packageVersion}-haxelib.zip'; + var outputFolderPath = FileSystem.absolutePath("../bin/"); + FileSystem.createDirectory(outputFolderPath); + var zipFilePath = Path.join([outputFolderPath, packageFileName]); + Sys.println('haxelib: ${packageName}'); + Sys.println('version: ${packageVersion}'); + Sys.println('releasenote: ${releaseNote}'); + Sys.println('file: ${zipFilePath}'); + + var zipFileOutput = File.write(zipFilePath, true); + var zip = new Writer(zipFileOutput); + zip.write(entries); + } + + private static function addFile(filePath:String, result:List):Void { + addFileInternal(filePath, Path.directory(filePath), result); + } + + private static function addDirectory(directoryPath:String, recursive:Bool, result:List):Void { + addDirectoryInternal(directoryPath, Path.directory(directoryPath), recursive, result); + } + + private static function addFileInternal(filePath:String, relativeToDirPath:String, result:List):Void { + var fileName = StringTools.replace(filePath, relativeToDirPath + "/", ""); + var bytes = Bytes.ofData(File.getBytes(filePath).getData()); + result.add({ + fileName: fileName, + fileSize: bytes.length, + fileTime: Date.now(), + compressed: false, + dataSize: 0, + data: bytes, + crc32: Crc32.make(bytes) + }); + } + + private static function addDirectoryInternal(directoryPath:String, relativeTo:String, recursive:Bool, result:List):Void { + for (fileName in FileSystem.readDirectory(directoryPath)) { + var filePath = Path.join([directoryPath, fileName]); + if (FileSystem.isDirectory(filePath)) { + if (recursive) { + addDirectoryInternal(filePath, relativeTo, true, result); + } + } else { + addFileInternal(filePath, relativeTo, result); + } + } + } +} diff --git a/haxelib/README.md b/haxelib/README.md new file mode 100644 index 0000000..b374918 --- /dev/null +++ b/haxelib/README.md @@ -0,0 +1,7 @@ +# markdown-openfl-textfield haxelib + +To package a _.zip_ file for Haxelib, run the following command: + +```sh +haxe ./haxelib.hxml +``` diff --git a/haxelib/haxelib.hxml b/haxelib/haxelib.hxml new file mode 100644 index 0000000..a6b5968 --- /dev/null +++ b/haxelib/haxelib.hxml @@ -0,0 +1,2 @@ +-main PackageHaxelib +--interp \ No newline at end of file