@azerion/h5-texture-unpacker
Advanced tools
Comparing version 0.0.1 to 0.0.2
# Changelog | ||
## [0.0.2] - 2019-11-04 | ||
### Added | ||
- Winston logging with a verbose check | ||
- check to see if img exists | ||
- Can now read img file from json config | ||
### Fixed | ||
- error reporting image size equals zero is nog caught | ||
- cleaned up dist folder | ||
## [0.0.1] - 2019-11-01 | ||
### Added | ||
- Initial setup and release |
#!/usr/bin/env node | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Sharp = require('sharp'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var yargs = require('yargs'); | ||
var basePath = path.join(__dirname, '../'); | ||
var argv = yargs | ||
.usage('Usage: $0 [imageFile] [jsonFile] [outputDir]') | ||
.option('imageFile', { | ||
alias: 'i', | ||
demandOption: true, | ||
describe: 'The input texture image', | ||
type: 'string' | ||
}) | ||
.option('jsonFile', { | ||
alias: 'j', | ||
demandOption: true, | ||
describe: 'The input JSON configuration', | ||
type: 'string' | ||
}) | ||
.option('outputDir', { | ||
alias: 'o', | ||
demandOption: true, | ||
describe: 'The output folder', | ||
type: 'string' | ||
}) | ||
.help('h') | ||
.alias('h', 'help') | ||
.epilog('copyright Azerion 2019') | ||
.argv; | ||
var imgUrl = path.join(argv.i); | ||
var jsonUrl = path.join(argv.j); | ||
var outputDir = path.join(argv.o, '/'); | ||
var json = JSON.parse(fs.readFileSync(jsonUrl)); | ||
if (!fs.existsSync(outputDir)) { | ||
fs.mkdirSync(outputDir); | ||
} | ||
json.frames.forEach(function (source) { | ||
Sharp(imgUrl).extract({ | ||
width: source.frame.w, | ||
height: source.frame.h, | ||
left: source.frame.x, | ||
top: source.frame.y | ||
}).toFile(path.join(outputDir, '/', source.filename + '.png')).then(function (fileInfo) { | ||
console.log('File: ', source.filename, ' written'); | ||
}).catch(function (err) { | ||
console.log('Unable to write file ', source.filename, ':', err); | ||
}); | ||
}); | ||
var e=require("sharp"),i=require("path"),t=require("fs"),r=require("yargs"),n=require("winston"),o=(new Date).toISOString(),a=n.format.printf((function(e){return o+"-"+e.level+": "+JSON.stringify(e.message,null,4)+"\n"})),s=n.createLogger({transports:[new n.transports.Console({format:n.format.combine(n.format.colorize(),a)})]}),l=(i.join(__dirname,"../"),r.usage("Usage: $0 -j [jsonFile] -o [outputDir]").option("imageFile",{alias:"i",demandOption:!1,default:"",describe:"The input texture image",type:"string"}).option("jsonFile",{alias:"j",demandOption:!0,describe:"The input JSON configuration",type:"string"}).option("outputDir",{alias:"o",demandOption:!0,describe:"The output folder",type:"string"}).option("verbose",{alias:"v",default:!1,describe:"Show log messages",type:"boolean"}).help("h").alias("h","help").epilog("copyright Azerion 2019").argv),f=i.join(l.i),p=i.join(l.j),m=i.join(l.o,"/"),u=JSON.parse(t.readFileSync(p));s.level=!0===l.verbose?"info":"warn",""===l.i&&(f=i.join(i.parse(p).dir,u.meta.image)),t.existsSync(f)||(s.error("Could not find image at specified path!"),process.exit(1)),t.existsSync(m)||t.mkdirSync(m),u.frames.forEach((function(t){0!==t.frame.w&&0!==t.frame.h?e(f).extract({width:t.frame.w,height:t.frame.h,left:t.frame.x,top:t.frame.y}).toFile(i.join(m,"/",t.filename+".png")).then((function(e){s.info("File: "+t.filename+" written")})).catch((function(e){s.info("Unable to write file , "+t.filename+":, "+e)})):s.warn("Unable to write file , "+t.filename+": Source width/height is 0")})); |
{ | ||
"name": "@azerion/h5-texture-unpacker", | ||
"author": "Azerion", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Simple CLI tool that allows you to unpack your existing Texture atlasses provided that you have the JSON file available", | ||
@@ -30,3 +30,3 @@ "contributors": [ | ||
"prebuild": "rimraf dist", | ||
"build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src", | ||
"build": "rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src", | ||
"start": "rollup -c rollup.config.ts -w", | ||
@@ -90,3 +90,4 @@ "test": "jest --coverage", | ||
"@types/jest": "^23.3.2", | ||
"@types/node": "^10.17.2", | ||
"@types/node": "^10.17.3", | ||
"@types/sharp": "^0.23.0", | ||
"@types/yargs": "^13.0.3", | ||
@@ -108,2 +109,3 @@ "colors": "^1.4.0", | ||
"rollup": "^0.67.0", | ||
"rollup-plugin-add-shebang": "^0.3.1", | ||
"rollup-plugin-commonjs": "^9.3.4", | ||
@@ -125,6 +127,6 @@ "rollup-plugin-node-resolve": "^3.4.0", | ||
"dependencies": { | ||
"@types/sharp": "^0.23.0", | ||
"sharp": "^0.23.2", | ||
"winston": "^3.2.1", | ||
"yargs": "^14.2.0" | ||
} | ||
} |
@@ -15,3 +15,3 @@ [![npm version](https://badge.fury.io/js/%40azerion%2Fh5-texture-unpacker.svg)](https://badge.fury.io/js/%40azerion%2Fh5-texture-unpacker) | ||
ale@computer:~$ unpack | ||
Usage: unpack [imageFile] [jsonFile] [outputDir] | ||
Usage: unpack -j [jsonFile] -o [outputDir] | ||
``` | ||
@@ -22,14 +22,14 @@ | ||
``` | ||
ale@NL0NTB032:/media/ale/dev/tools/h5-texture-unpacker$ unpack | ||
Usage: unpack [imageFile] [jsonFile] [outputDir] | ||
ale@computer:~$ unpack | ||
Usage: unpack -j [jsonFile] -o [outputDir] | ||
Options: | ||
--version Show version number [boolean] | ||
--imageFile, -i The input texture image [string] [required] | ||
--imageFile, -i The input texture image [string] [default: ""] | ||
--jsonFile, -j The input JSON configuration [string] [required] | ||
--outputDir, -o The output folder [string] [required] | ||
--verbose, -v Show log messages [boolean] [default: false] | ||
-h, --help Show help [boolean] | ||
copyright Azerion 2019 | ||
``` | ||
@@ -36,0 +36,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
8803
36
5
7
3
1
+ Addedwinston@^3.2.1
+ Added@colors/colors@1.6.0(transitive)
+ Added@dabh/diagnostics@2.0.3(transitive)
+ Added@types/triple-beam@1.3.5(transitive)
+ Addedasync@3.2.6(transitive)
+ Addedcolorspace@1.1.4(transitive)
+ Addedenabled@2.0.0(transitive)
+ Addedfecha@4.2.3(transitive)
+ Addedfn.name@1.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedkuler@2.0.0(transitive)
+ Addedlogform@2.7.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedone-time@1.0.0(transitive)
+ Addedsafe-stable-stringify@2.5.0(transitive)
+ Addedstack-trace@0.0.10(transitive)
+ Addedtext-hex@1.0.0(transitive)
+ Addedtriple-beam@1.4.1(transitive)
+ Addedwinston@3.17.0(transitive)
+ Addedwinston-transport@4.9.0(transitive)
- Removed@types/sharp@^0.23.0
- Removed@types/node@22.9.0(transitive)
- Removed@types/sharp@0.23.1(transitive)
- Removedundici-types@6.19.8(transitive)