Skip to content

Commit

Permalink
CHANGELOG and haxelib script
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Oct 21, 2020
1 parent 7f21581 commit 246a126
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
markdown-openfl-textfield Change Log

1.0.0 (2020-10-21)

- Initial release
73 changes: 73 additions & 0 deletions haxelib/PackageHaxelib.hx
Original file line number Diff line number Diff line change
@@ -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<Entry>();
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<Entry>):Void {
addFileInternal(filePath, Path.directory(filePath), result);
}

private static function addDirectory(directoryPath:String, recursive:Bool, result:List<Entry>):Void {
addDirectoryInternal(directoryPath, Path.directory(directoryPath), recursive, result);
}

private static function addFileInternal(filePath:String, relativeToDirPath:String, result:List<Entry>):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<Entry>):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);
}
}
}
}
7 changes: 7 additions & 0 deletions haxelib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# markdown-openfl-textfield haxelib

To package a _.zip_ file for Haxelib, run the following command:

```sh
haxe ./haxelib.hxml
```
2 changes: 2 additions & 0 deletions haxelib/haxelib.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-main PackageHaxelib
--interp

0 comments on commit 246a126

Please sign in to comment.