resourcepacker
Advanced tools
Comparing version 1.0.0 to 1.0.1
# Changelog | ||
## 1.0.1 | ||
*2020-08-08* | ||
- Added support for pack version 6 (*Minecraft* 1.16.2+). | ||
## 1.0.0 | ||
@@ -4,0 +8,0 @@ *2020-08-01* |
60
index.js
#!/usr/bin/env node | ||
const RPKR_VERSION = '1.0.0'; | ||
const RPKR_VERSION = '1.0.1'; | ||
@@ -7,2 +7,3 @@ const fs = require('fs'); | ||
const jsonformat = require('json-format'); | ||
const log = str => console.log('<resourcepacker> ' + str); | ||
@@ -13,4 +14,7 @@ | ||
name: process.cwd().split(/\/|\\/).slice(-1)[0], | ||
packver: '1.0.0', mcver: '1.16.x', mcsnap: null, | ||
description: null, languages: null, | ||
packver: 'v1', | ||
mcver: '1.16.x', | ||
mcsnap: null, | ||
description: null, | ||
languages: null, | ||
files: [ | ||
@@ -28,3 +32,10 @@ "pack.png", | ||
}; | ||
const PACK_FORMATS = { '1.6,1.7,1.8': 1, '1.9,1.10': 2, '1.11,1.12': 3, '1.13,1.14': 4, '1.15,1.16': 5 }; | ||
const PACK_FORMATS = { | ||
1: ['1.6.x', '1.7.x', '1.8.x'], | ||
2: ['1.9.x', '1.10.x'], | ||
3: ['1.11.x', '1.12.x'], | ||
4: ['1.13.x', '1.14.x'], | ||
5: ['1.15.x', '1.16', '1.16.1'], | ||
6: ['1.16.x'], | ||
}; | ||
@@ -47,6 +58,7 @@ function init() { | ||
copyfiles( | ||
[...files, outputFolder], {}, | ||
(err) => { | ||
const success = x => { | ||
log(`${x == null ? 'Uns' : 'S'}uccessfully packaged version ${packver} of '${name}' for Minecraft ${mcver}`); | ||
[...files, outputFolder], | ||
{}, | ||
err => { | ||
const success = success => { | ||
log(`${success ? 'S' : 'Uns'}uccessfully packaged version ${packver} of '${name}' for Minecraft ${mcver}`); | ||
} | ||
@@ -56,12 +68,15 @@ if (err) log('Error: ' + err), success(false); | ||
let packFormat = 0, mcverMajor = mcver.replace(/^(\d\.\d+).*/, '$1'); | ||
let packFormat = 0; | ||
for (let key in PACK_FORMATS) { | ||
if (key.includes(mcverMajor)) packFormat = PACK_FORMATS[key]; | ||
for (let val of PACK_FORMATS[key]) { | ||
const matchExact = mcver == val; | ||
const matchPartial = val.endsWith('.x') && val.replace('.x', '') == mcver.replace(/(^1\.\d+)\.\d+$/, '$1'); | ||
if (matchExact || matchPartial) packFormat = key; | ||
} | ||
} | ||
for (let item in config) { | ||
description = description.replace(/&(?=\w)/g, '§').replace(RegExp('<' + item + '>', 'g'), config[item]); | ||
description = description.replace(/&(?=[0-9a-fk-or])/g, '§').replace(RegExp(`<${item}>`, 'g'), config[item]); | ||
} | ||
let mcmetaContent = { "pack": { "pack_format": packFormat, "description": description } }; | ||
let mcmetaContent = { "pack": { "pack_format": parseInt(packFormat), "description": description } }; | ||
if (languages) { | ||
@@ -76,10 +91,13 @@ mcmetaContent.language = {}; | ||
fs.writeFile(outputFolder + '/pack.mcmeta', jsonformat(mcmetaContent, { type: 'space' }), err => { | ||
if (err) log("FSWriteError: Could not create automatic pack.mcmeta file"), success(false); | ||
else log("Created automatic pack.mcmeta file"), success(); | ||
}); | ||
fs.writeFile( | ||
outputFolder + '/pack.mcmeta', | ||
jsonformat(mcmetaContent, { type: 'space' }), | ||
err => { | ||
if (err) log("FSWriteError: Could not create automatic pack.mcmeta file"), success(false); | ||
else log("Created automatic pack.mcmeta file"), success(true); | ||
} | ||
); | ||
} | ||
else success(); | ||
} | ||
); | ||
else success(true); | ||
}); | ||
@@ -98,5 +116,5 @@ }); | ||
} | ||
else if (arg(1).includes('v')) log('Current version: ' + RPKR_VERSION); | ||
else if (arg(1).includes('v')) log('The current version of resourcepacker is ' + RPKR_VERSION); | ||
else if (arg(1) === 'init') init(); | ||
else if (arg(1) === 'pack') package(arg(2)); | ||
else log('Unknown command; type `rpkr help` for help'); |
{ | ||
"name": "resourcepacker", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Easily and cleanly packages Minecraft resource packs from a messy working directory", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,3 +0,3 @@ | ||
[![Latest version](https://img.shields.io/github/v/release/Nixinova/resourcepacker?label=latest&style=flat-square&logo=github)](https://github.com/Nixinova/resourcepacker/releases) | ||
[![npm downloads](https://img.shields.io/npm/dt/resourcepacker?style=flat-square&logo=npm)](https://www.npmjs.com/package/resourcepacker) | ||
[![Latest version](https://img.shields.io/github/v/release/Nixinova/resourcepacker?label=latest&style=flat-square)](https://github.com/Nixinova/resourcepacker/releases) | ||
[![npm downloads](https://img.shields.io/npm/dt/resourcepacker?style=flat-square)](https://www.npmjs.com/package/resourcepacker) | ||
[![Last updated](https://img.shields.io/github/release-date-pre/Nixinova/resourcepacker?label=updated&style=flat-square)](https://github.com/Nixinova/resourcepacker/releases) | ||
@@ -19,3 +19,3 @@ | ||
The `.rpkr.json` configuration file can be edited to fine tune the output of your resource pack. Comments can be added using a hash (`#`). | ||
The `.rpkr.json` configuration file can be edited to fine tune the output of your resource pack. Available parameters can be found below, with further explanations found in sub-sections. | ||
@@ -22,0 +22,0 @@ ### Parameters |
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
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
12261
101