marilena
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -9,12 +9,20 @@ "use strict"; | ||
const const_1 = require("../const"); | ||
const node_color_log_1 = __importDefault(require("node-color-log")); | ||
function default_1(options) { | ||
const { inputFolder } = options.config; | ||
const locale = options.locale; | ||
let emailVariables = {}; | ||
let common = {}; | ||
try { | ||
emailVariables = JSON.parse(fs_1.default.readFileSync(path_1.default.join(inputFolder, options.emailName, options.locale, `${const_1.FILE_NAME_EMAIL_VARIABLES}.json` // in the future also yml file with yml-js | ||
common = JSON.parse(fs_1.default.readFileSync(path_1.default.join(inputFolder, `${const_1.FILE_NAME_COMMON_VARIABLES}-${locale}.json`), "utf-8")); | ||
} | ||
catch (e) { | ||
node_color_log_1.default.error(`cannot loading common variables for email ${options.emailName} ${options.locale}. Please create ${const_1.FILE_NAME_COMMON_VARIABLES}-${locale} file under ${inputFolder}`); | ||
} | ||
try { | ||
emailVariables = JSON.parse(fs_1.default.readFileSync(path_1.default.join(inputFolder, options.emailName, locale, `${const_1.FILE_NAME_EMAIL_VARIABLES}.json` // in the future also yml file with yml-js | ||
), "utf-8")); | ||
} | ||
catch (e) { | ||
console.error(`error loading emailVariables for email ${options.emailName} ${options.locale}`); | ||
node_color_log_1.default.error(`cannot loading variables for email ${options.emailName} ${options.locale}`); | ||
} | ||
@@ -21,0 +29,0 @@ return { |
@@ -14,20 +14,20 @@ "use strict"; | ||
return (0, node_watch_1.default)([path_1.default.join(inputFolder), const_1.CONFIG_FILE_NAME], { recursive: true, filter: regex }, function (evt, name) { | ||
// example input/buy/it/variables.json | ||
if (evt === "update") { | ||
const parts = name.split("/"); | ||
const emailName = parts[1]; | ||
const locale = parts[2]; | ||
if (name.endsWith(const_1.CONFIG_FILE_NAME)) { | ||
callbacks.handleEditConfig(emailName); | ||
} | ||
if (name.endsWith(`${const_1.FILE_NAME_EMAIL_VARIABLES}.json`)) { | ||
// chnged variables | ||
else if (name.endsWith(`${const_1.FILE_NAME_EMAIL_VARIABLES}.json`)) { | ||
// chnged email variables | ||
const locale = parts[2]; | ||
callbacks.handleEditVariables(emailName, locale); | ||
} | ||
if (name.endsWith(templateSuffix)) { | ||
else if (name.endsWith(templateSuffix)) { | ||
// changed email template | ||
callbacks.handleEmailChange(emailName); | ||
} | ||
if (name.endsWith(`${const_1.FILE_NAME_COMMON_VARIABLES}.json`)) { | ||
// TODO | ||
else if (name.startsWith(path_1.default.join(inputFolder, `${const_1.FILE_NAME_COMMON_VARIABLES}`))) { | ||
// changed common variables | ||
callbacks.handleEditVariables(emailName); | ||
} | ||
@@ -34,0 +34,0 @@ } |
@@ -33,3 +33,2 @@ "use strict"; | ||
websocket = connection.socket; | ||
console.log("Client connected"); | ||
connection.socket.on("message", (message) => { | ||
@@ -39,5 +38,3 @@ connection.socket.send("hi from server"); | ||
// Client disconnect | ||
connection.socket.on("close", () => { | ||
console.log("Client disconnected"); | ||
}); | ||
connection.socket.on("close", () => { }); | ||
}); | ||
@@ -44,0 +41,0 @@ }); |
{ | ||
"name": "marilena", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "a tool to build emails with cool tools like mjml and different template engine lime handlebars or eta.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -43,2 +43,4 @@ # Intro | ||
│ input | ||
│ └──common-en[variablesType] // common variables for all en emails | ||
│ └──common-xx[variablesType] // common variables for all xx emails | ||
│ └──buy // email name | ||
@@ -45,0 +47,0 @@ ││││││└─── index.html // index[templateSuffix] |
26691
473
139