@appdirect/sfb-theme-plaza 0.0.82 → 0.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appdirect/sfb-theme-plaza",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "description": "A modern theme built with react components that can be customized with Storefront Builder.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,58 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const yaml = require('js-yaml');
4
- const properties = require('properties');
5
-
6
- const translationbasePath = "./../translations";
7
- // Convert properties to YAML
8
- function propsToYaml(propsPath, destPath) {
9
- const propsContent = fs.readFileSync(`${translationbasePath}/${propsPath}`, 'utf8');
10
- const options = { pathSeparator: '.', namespaces: true, includeAllProperties: true };
11
- properties.parse(propsContent, options, (error, data) => {
12
- if (error) throw error;
13
-
14
- // Custom function to flatten the object structure
15
- function flattenObject(ob) {
16
- var toReturn = {};
17
- for (var i in ob) {
18
- if (!ob.hasOwnProperty(i)) continue;
19
- if ((typeof ob[i]) == 'object' && !Array.isArray(ob[i])) {
20
- var flatObject = flattenObject(ob[i]);
21
- for (var x in flatObject) {
22
- if (!flatObject.hasOwnProperty(x)) continue;
23
- toReturn[i.replace(/---/g, ":") + '.' + x.replace(/---/g, ":")] = flatObject[x];
24
- }
25
- } else {
26
- toReturn[i.replace(/---/g, ":")] = ob[i];
27
- }
28
- }
29
- return toReturn;
30
- }
31
-
32
- const flatData = flattenObject(data)
33
- propsContent.split('\n').forEach(line => {
34
- const [key] = line.split('=');
35
- const yamlKey = key.replace(/---/g, ":");
36
- if (yamlKey && flatData[yamlKey] === undefined) {
37
- flatData[yamlKey] = "";
38
- }
39
- });
40
- const ymlString = yaml.dump(flatData, { noCompatMode: false });
41
- fs.writeFileSync(`${translationbasePath}/${destPath}`, ymlString);
42
- });
43
- }
44
-
45
- const files = fs.readdirSync(translationbasePath);
46
-
47
- for (const file of files) {
48
- if (path.extname(file) === '.properties') {
49
- const baseName = path.basename(file, '.properties');
50
- const locale = baseName.replace('sfb-theme-mp2_', '').replace("_", "-"); // Removing the prefix
51
- propsToYaml(file, `${locale}.yml`);
52
- fs.unlinkSync(`${translationbasePath}/${file}`);
53
- }
54
- }
55
-
56
- module.exports = {
57
- propsToYaml: propsToYaml
58
- };