-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
import sys.FileSystem; | ||
using Lambda; | ||
using haxe.io.Path; | ||
|
||
/** Deletes all generated files. **/ | ||
function main() { | ||
["lib", "res"].filter(FileSystem.exists).iter(Tools.removeDirectory); | ||
Tools.cleanDirectory("var"); | ||
["lib", "res"].filter(FileSystem.exists).iter(removeDirectory); | ||
cleanDirectory("var"); | ||
} | ||
|
||
/** Recursively deletes all files in the specified `directory`. **/ | ||
function cleanDirectory(directory: String) for (entry in FileSystem.readDirectory(directory).filter(entry -> entry != ".gitkeep")) { | ||
final path = Path.join([directory, entry]); | ||
FileSystem.isDirectory(path) ? removeDirectory(path) : FileSystem.deleteFile(path); | ||
} | ||
|
||
/** Recursively deletes the specified `directory`. **/ | ||
function removeDirectory(directory: String) { | ||
cleanDirectory(directory); | ||
FileSystem.deleteDirectory(directory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,56 @@ | ||
//! --class-path src --library tink_core | ||
import free_mobile.Platform; | ||
import haxe.crypto.Crc32; | ||
import haxe.zip.Entry; | ||
import haxe.zip.Writer; | ||
import sys.FileSystem; | ||
import sys.io.File; | ||
using Lambda; | ||
using haxe.io.Path; | ||
using haxe.zip.Tools; | ||
|
||
/** Publishes the package. **/ | ||
function main() { | ||
Tools.compress(["CHANGELOG.md", "LICENSE.md", "README.md", "haxelib.json", "src"], "var/haxelib.zip"); | ||
compress(["CHANGELOG.md", "LICENSE.md", "README.md", "haxelib.json", "src"], "var/haxelib.zip"); | ||
Sys.command("haxelib submit var/haxelib.zip"); | ||
for (action in ["tag", "push origin"]) Sys.command('git $action v${Platform.packageVersion}'); | ||
} | ||
|
||
/** Creates a ZIP archive from the specified file system entities. **/ | ||
private function compress(sources: Array<String>, destination: String) { | ||
final output = File.write(destination); | ||
final writer = new Writer(output); | ||
|
||
var entries = []; | ||
for (source in sources) entries = entries.concat(FileSystem.isDirectory(source) ? compressDirectory(source) : [compressFile(source)]); | ||
writer.write(entries.list()); | ||
output.close(); | ||
} | ||
|
||
/** Compresses the content of the specified `directory` in ZIP format. **/ | ||
private function compressDirectory(directory: String) { | ||
var entries = []; | ||
for (entry in FileSystem.readDirectory(directory)) { | ||
final path = Path.join([directory, entry]); | ||
entries = entries.concat(FileSystem.isDirectory(path) ? compressDirectory(path) : [compressFile(path)]); | ||
} | ||
|
||
return entries; | ||
} | ||
|
||
/** Compresses the specified `file` in ZIP format. **/ | ||
private function compressFile(file: String) { | ||
final bytes = File.getBytes(file); | ||
final entry: Entry = { | ||
compressed: false, | ||
crc32: Crc32.make(bytes), | ||
data: bytes, | ||
dataSize: bytes.length, | ||
fileName: file, | ||
fileSize: bytes.length, | ||
fileTime: FileSystem.stat(file).mtime | ||
}; | ||
|
||
entry.compress(9); | ||
return entry; | ||
} |
This file was deleted.
Oops, something went wrong.