- Installation FVTT Windows Nodejs + module
- Passage à Git pour le module
- Travailler avec un éditeur de texte et git/gitlab
- Versionnage et déploiement automatique (A VENIR)
- Installer FoundryVTT sur PC Windows
- en mode nodejs
- avec conversion de module en YAML
Le code
D:\fvtt\node20\node.exe D:\fvtt\foundryvtt12\resources\app\main.js --dataPath=D:\fvtt\foundryvtt12donnees
ipconfig
cd D:\fvtt\foundryvtt12donnees\Data\modules\my-new-module
D:\fvtt\node20\npm init
set PATH=%PATH%;D:\fvtt\node20
D:\fvtt\node20\npm install @foundryvtt/foundryvtt-cli --save-dev
D:\fvtt\node20\npm run pushLDBtoYAML
package.json
{
"name": "mon-module-a-moi",
"version": "1.0.0",
"description": "Vive CSB !",
"main": "index.js",
"scripts": {
"pushLDBtoYAML": "D:/fvtt/node20/node D:/fvtt/foundryvtt12donnees/Data/modules/my-new-module/outils/pushLDBtoYAML.mjs",
"pullYAMLtoLDB": "D:/fvtt/node20/node D:/fvtt/foundryvtt12donnees/Data/modules/my-new-module/outils/pullYAMLtoLDB.mjs"
},
"author": "vonv",
"license": "MIT",
"devDependencies": {
"@foundryvtt/foundryvtt-cli": "^1.0.3"
}
}
pullYAMLtoLDB.mjs
import { compilePack } from '@foundryvtt/foundryvtt-cli';
import { promises as fs } from 'fs';
const MODULE_ID = process.cwd();
const yaml = true;
const packs = await fs.readdir('./src/packs');
for (const pack of packs) {
if (pack === '.gitattributes') continue;
console.log('Packing ' + pack);
await compilePack(
`${MODULE_ID}/src/packs/${pack}`,
`${MODULE_ID}/packs/${pack}`,
{ yaml }
);
}
pullLDBtoYAML.mjs
import { extractPack } from "@foundryvtt/foundryvtt-cli";
import { promises as fs } from "fs";
import path from "path";
const MODULE_ID = process.cwd();
const yaml = true;
const log = true;
const packs = await fs.readdir("./packs");
for (const pack of packs) {
if (pack === ".gitattributes") continue;
console.log("Unpacking " + pack);
const directory = `./src/packs/${pack}`;
try {
for (const file of await fs.readdir(directory)) {
await fs.unlink(path.join(directory, file));
}
} catch (error) {
if (error.code === "ENOENT") console.log("No files inside of " + pack);
else console.log(error);
}
await extractPack(
`${MODULE_ID}/packs/${pack}`,
`${MODULE_ID}/src/packs/${pack}`,
{
yaml,
transformName,
log
}
);
}
/**
* Prefaces the document with its type
* @param {object} doc - The document data
*/
function transformName(doc) {
const safeFileName = doc.name.replace(/[^a-zA-Z0-9А-я]/g, "_");
const type = doc._key.split("!")[1];
const prefix = ["actors", "items"].includes(type) ? doc.type : type;
return `${doc.name ? `${prefix}_${safeFileName}_${doc._id}` : doc._id}.${
yaml ? "yml" : "json"
}`;
}
- Installion de GitLab
- Initialisation
- Petit test de mise à jour
Le code:
ssh-keygen -t rsa -b 2048 -C "la cle de vonv"
cd D:\fvtt\foundryvtt12donnees\Data\modules\my-new-module
D:\fvtt\git\bin\git.exe init --initial-branch=main
D:\fvtt\git\bin\git.exe config --global user.name "moi"
D:\fvtt\git\bin\git.exe config --global user.email "[email protected]"
D:\fvtt\git\bin\git.exe remote add origin [email protected]:vonv/my-new-module.git
D:\fvtt\git\bin\git.exe add .
D:\fvtt\git\bin\git.exe commit -m "Initial commit"
D:\fvtt\git\bin\git.exe push --set-upstream origin main
D:\fvtt\git\bin\git.exe add .
D:\fvtt\git\bin\git.exe commit -m "Ajout du reademe"
D:\fvtt\git\bin\git.exe push