glamaholic-to-collections
Advanced tools
Comparing version 1.0.3 to 1.1.0
11
index.js
@@ -9,3 +9,3 @@ #!/usr/bin/env node | ||
.usage( | ||
"Usage: $0 --collectionsConfig <collectionsConfig> --glamaholicConfig <glamaholicConfig>", | ||
"Usage: $0 --collectionsConfig <collectionsConfig> --glamaholicConfig <glamaholicConfig> --outputFile <outputFile>", | ||
) | ||
@@ -26,2 +26,9 @@ .option("collectionsConfig", { | ||
}) | ||
.option("outputFile", { | ||
alias: "o", | ||
describe: "Path to where you want to save the new collections.json file", | ||
type: "string", | ||
demandOption: false, | ||
default: `${process.env.APPDATA}/XIVLauncher/pluginConfigs/Collections.json`, | ||
}) | ||
.help().argv; | ||
@@ -36,2 +43,2 @@ | ||
writeCollectionsConfig(collectionsConfig, glamaholicConfig); | ||
writeCollectionsConfig(collectionsConfig, glamaholicConfig, argv.outputFile); |
21
lib.js
@@ -92,14 +92,19 @@ import * as fs from "node:fs"; | ||
export const writeCollectionsConfig = (collectionsConfig, glamaholicConfig) => { | ||
export const writeCollectionsConfig = ( | ||
collectionsConfig, | ||
glamaholicConfig, | ||
outputFile, | ||
) => { | ||
const newCollectionsConfig = mergePlates(collectionsConfig, glamaholicConfig); | ||
fs.writeFileSync( | ||
"collections.json", | ||
JSON.stringify(newCollectionsConfig, null, 2), | ||
); | ||
// If file already exists, create a backup with timestamp | ||
if (fs.existsSync(outputFile)) { | ||
const timestamp = new Date().toISOString().replace(/:/g, ""); | ||
fs.copyFileSync(outputFile, `${outputFile}.${timestamp}.bak`); | ||
} | ||
fs.writeFileSync(outputFile, JSON.stringify(newCollectionsConfig, null, 2)); | ||
// Log a success message with the full path to the collections.json file | ||
console.log( | ||
`collections.json has been written to ${process.cwd()}/collections.json`, | ||
); | ||
console.log(`collections.json has been written to ${outputFile}`); | ||
}; |
{ | ||
"name": "glamaholic-to-collections", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Convert Glamaholic data to Collections", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,22 +7,16 @@ # Glamaholic-To-Collections | ||
## Installation | ||
1. Make sure nodejs is installed on your computer: https://nodejs.org/en/download/package-manager | ||
2. Open a terminal (Win+R, type `cmd`, hit enter) | ||
3. In the window, enter the following command | ||
```bash | ||
npm install glamaholic-to-collections | ||
npm install -g glamaholic-to-collections | ||
``` | ||
## Usage | ||
To get an overview: | ||
```bash | ||
glamaholic-importer help | ||
``` | ||
1. Open a terminal (see above) | ||
2. Enter `glamaholic-importer` | ||
To convert your glamaholic plates into collections: | ||
```bash | ||
glamaholic-importer | ||
``` | ||
This will automatically take the Glamaholic and Collections configs from the default installation location of XIVLauncher (`%APPDATA%/XIVLauncher/pluginConfigs`), create a backup of your Collections.json and replace it with a new version that has your Glamaholic plates added to it in a folder called `Imported from Glamaholic` | ||
You can pass custom paths to the glamaholic and collections config files like this: | ||
```bash | ||
glamaholic-importer --cc path/to/collections.json --gc path/to/glamaholic.json | ||
``` | ||
The new configuration will be saved in your current directory as `collections.json` | ||
### Nonstandard installation locations | ||
Run `glamaholic-importer help` to see a list of commands you can pass to it to change the import and export file paths. |
6198
133
22
4