@akinon/projectzero 1.14.1 → 1.16.0

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.
@@ -1,75 +1,75 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const fs = require("fs");
5
- const path = require("path");
6
- const argv = require("yargs").argv;
7
- exports.default = () => {
8
- /**
9
- * @param {string} src The path to the thing to copy.
10
- * @param {string} dest The path to the new copy.
11
- * @param {string} lng Get Language
12
- */
13
- const addLanguage = (src, dest, lng) => {
14
- const exists = fs.existsSync(src);
15
- const stats = exists && fs.statSync(src);
16
- const isDirectory = exists && stats.isDirectory();
17
- if (isDirectory) {
18
- fs.mkdirSync(dest);
19
- fs.readdirSync(src).forEach((childItemName) => {
20
- addLanguage(path.join(src, childItemName), path.join(dest, childItemName), lng);
21
- });
22
- console.log("\x1b[32m%s\x1b[0m", `\n✓ Added language option ${lng.toUpperCase()}.\nDon't forget to translate '${lng.toUpperCase()}' translation files inside 'public/locales/${lng.toUpperCase()}'\n`);
23
- console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
24
- }
25
- else {
26
- fs.copyFileSync(src, dest);
27
- }
28
- };
29
- const i18nDocumentUpdate = (lng) => {
30
- /* next-i18next.config.js */
31
- const workingDir = path.resolve(process.cwd());
32
- const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
33
- if (!fs.existsSync(i18nPath)) {
34
- return;
35
- }
36
- const i18nData = fs.readFileSync(i18nPath, {
37
- encoding: "utf8",
38
- flag: "r",
39
- });
40
- fs.writeFileSync(i18nPath, i18nData.replace(/locales: '*.'/, `locales: ['${lng}', '`));
41
- /* settings.js */
42
- const settingsPath = path.resolve(workingDir, "src/settings.js");
43
- if (!fs.existsSync(settingsPath)) {
44
- return;
45
- }
46
- const settingsData = fs.readFileSync(settingsPath, {
47
- encoding: "utf8",
48
- flag: "r",
49
- });
50
- const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${argv.addLanguage}' }`;
51
- const changes = "languages: [";
52
- fs.writeFileSync(settingsPath, settingsData.replace(changes, `languages: [\n\t\t${data},`));
53
- };
54
- const init = () => {
55
- if (!argv.addLanguage)
56
- return;
57
- let lng = argv.addLanguage;
58
- lng = lng.split("-")[0];
59
- const dest = `public/locales/${lng}`;
60
- const exists = fs.existsSync(dest);
61
- try {
62
- if (exists)
63
- throw new Error(`${lng.toUpperCase()} has already been added`);
64
- addLanguage("public/locales/en", `public/locales/${lng}`, lng);
65
- i18nDocumentUpdate(lng);
66
- }
67
- catch (err) {
68
- const typedError = err;
69
- console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
70
- ? typedError.message + "\n"
71
- : "Something went wrong.\n"}`);
72
- }
73
- };
74
- init();
75
- };
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const argv = require("yargs").argv;
7
+ exports.default = () => {
8
+ /**
9
+ * @param {string} src The path to the thing to copy.
10
+ * @param {string} dest The path to the new copy.
11
+ * @param {string} lng Get Language
12
+ */
13
+ const addLanguage = (src, dest, lng) => {
14
+ const exists = fs.existsSync(src);
15
+ const stats = exists && fs.statSync(src);
16
+ const isDirectory = exists && stats.isDirectory();
17
+ if (isDirectory) {
18
+ fs.mkdirSync(dest);
19
+ fs.readdirSync(src).forEach((childItemName) => {
20
+ addLanguage(path.join(src, childItemName), path.join(dest, childItemName), lng);
21
+ });
22
+ console.log("\x1b[32m%s\x1b[0m", `\n✓ Added language option ${lng.toUpperCase()}.\nDon't forget to translate '${lng.toUpperCase()}' translation files inside 'public/locales/${lng.toUpperCase()}'\n`);
23
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
24
+ }
25
+ else {
26
+ fs.copyFileSync(src, dest);
27
+ }
28
+ };
29
+ const i18nDocumentUpdate = (lng) => {
30
+ /* next-i18next.config.js */
31
+ const workingDir = path.resolve(process.cwd());
32
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
33
+ if (!fs.existsSync(i18nPath)) {
34
+ return;
35
+ }
36
+ const i18nData = fs.readFileSync(i18nPath, {
37
+ encoding: "utf8",
38
+ flag: "r",
39
+ });
40
+ fs.writeFileSync(i18nPath, i18nData.replace(/locales: '*.'/, `locales: ['${lng}', '`));
41
+ /* settings.js */
42
+ const settingsPath = path.resolve(workingDir, "src/settings.js");
43
+ if (!fs.existsSync(settingsPath)) {
44
+ return;
45
+ }
46
+ const settingsData = fs.readFileSync(settingsPath, {
47
+ encoding: "utf8",
48
+ flag: "r",
49
+ });
50
+ const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${argv.addLanguage}' }`;
51
+ const changes = "languages: [";
52
+ fs.writeFileSync(settingsPath, settingsData.replace(changes, `languages: [\n\t\t${data},`));
53
+ };
54
+ const init = () => {
55
+ if (!argv.addLanguage)
56
+ return;
57
+ let lng = argv.addLanguage;
58
+ lng = lng.split("-")[0];
59
+ const dest = `public/locales/${lng}`;
60
+ const exists = fs.existsSync(dest);
61
+ try {
62
+ if (exists)
63
+ throw new Error(`${lng.toUpperCase()} has already been added`);
64
+ addLanguage("public/locales/en", `public/locales/${lng}`, lng);
65
+ i18nDocumentUpdate(lng);
66
+ }
67
+ catch (err) {
68
+ const typedError = err;
69
+ console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
70
+ ? typedError.message + "\n"
71
+ : "Something went wrong.\n"}`);
72
+ }
73
+ };
74
+ init();
75
+ };
@@ -1,45 +1,45 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const fs = require("fs");
5
- const path = require("path");
6
- const argv = require("yargs").argv;
7
- exports.default = () => {
8
- const i18nDocumentUpdate = (lng) => {
9
- /* next-i18next.config.js */
10
- const workingDir = path.resolve(process.cwd());
11
- const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
12
- if (!fs.existsSync(i18nPath)) {
13
- return;
14
- }
15
- const i18nData = fs.readFileSync(i18nPath, {
16
- encoding: "utf8",
17
- flag: "r",
18
- });
19
- const regExpLiteral = "locales:(.+)+";
20
- const result = i18nData.match(regExpLiteral);
21
- if (result[1].search(lng) < 0) {
22
- throw new Error(`${lng.toUpperCase()} not available`);
23
- }
24
- let updatedData = i18nData.replace(/defaultLocale: '.*'/, `defaultLocale: '${lng}'`);
25
- updatedData = updatedData.replace(/fallbackLng: '.*'/, `fallbackLng: '${lng}'`);
26
- fs.writeFileSync(i18nPath, updatedData);
27
- };
28
- const init = () => {
29
- if (!argv.defaultLanguage)
30
- return;
31
- let lng = argv.defaultLanguage;
32
- try {
33
- i18nDocumentUpdate(lng);
34
- console.log("\x1b[32m%s\x1b[0m", `\n✓ Set as the default language option ${lng.toUpperCase()}.\n`);
35
- console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
36
- }
37
- catch (err) {
38
- const typedError = err;
39
- console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
40
- ? typedError.message + "\n"
41
- : "Something went wrong.\n"}`);
42
- }
43
- };
44
- init();
45
- };
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const argv = require("yargs").argv;
7
+ exports.default = () => {
8
+ const i18nDocumentUpdate = (lng) => {
9
+ /* next-i18next.config.js */
10
+ const workingDir = path.resolve(process.cwd());
11
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
12
+ if (!fs.existsSync(i18nPath)) {
13
+ return;
14
+ }
15
+ const i18nData = fs.readFileSync(i18nPath, {
16
+ encoding: "utf8",
17
+ flag: "r",
18
+ });
19
+ const regExpLiteral = "locales:(.+)+";
20
+ const result = i18nData.match(regExpLiteral);
21
+ if (result[1].search(lng) < 0) {
22
+ throw new Error(`${lng.toUpperCase()} not available`);
23
+ }
24
+ let updatedData = i18nData.replace(/defaultLocale: '.*'/, `defaultLocale: '${lng}'`);
25
+ updatedData = updatedData.replace(/fallbackLng: '.*'/, `fallbackLng: '${lng}'`);
26
+ fs.writeFileSync(i18nPath, updatedData);
27
+ };
28
+ const init = () => {
29
+ if (!argv.defaultLanguage)
30
+ return;
31
+ let lng = argv.defaultLanguage;
32
+ try {
33
+ i18nDocumentUpdate(lng);
34
+ console.log("\x1b[32m%s\x1b[0m", `\n✓ Set as the default language option ${lng.toUpperCase()}.\n`);
35
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
36
+ }
37
+ catch (err) {
38
+ const typedError = err;
39
+ console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
40
+ ? typedError.message + "\n"
41
+ : "Something went wrong.\n"}`);
42
+ }
43
+ };
44
+ init();
45
+ };
@@ -47,38 +47,42 @@ try {
47
47
  }
48
48
  catch (error) { }
49
49
  const definedPlugins = [
50
- {
51
- name: 'Basket Gift Pack',
52
- value: 'pz-basket-gift-pack'
53
- },
54
- {
55
- name: 'Click & Collect',
56
- value: 'pz-click-collect'
57
- },
58
- {
59
- name: 'Checkout Gift Pack',
60
- value: 'pz-checkout-gift-pack'
61
- },
62
- {
63
- name: 'One Click Checkout',
64
- value: 'pz-one-click-checkout'
65
- },
50
+ // {
51
+ // name: 'Basket Gift Pack',
52
+ // value: 'pz-basket-gift-pack'
53
+ // },
54
+ // {
55
+ // name: 'Click & Collect',
56
+ // value: 'pz-click-collect'
57
+ // },
58
+ // {
59
+ // name: 'Checkout Gift Pack',
60
+ // value: 'pz-checkout-gift-pack'
61
+ // },
62
+ // {
63
+ // name: 'One Click Checkout',
64
+ // value: 'pz-one-click-checkout'
65
+ // },
66
66
  {
67
67
  name: 'Garanti Pay',
68
68
  value: 'pz-gpay'
69
69
  },
70
+ // {
71
+ // name: 'Pay On Delivery',
72
+ // value: 'pz-pay-on-delivery'
73
+ // },
70
74
  {
71
- name: 'Pay On Delivery',
72
- value: 'pz-pay-on-delivery'
73
- },
74
- {
75
- name: 'Otp',
75
+ name: 'OTP',
76
76
  value: 'pz-otp'
77
- },
78
- {
79
- name: 'BKM Express',
80
- value: 'pz-bkm'
81
77
  }
78
+ // {
79
+ // name: 'BKM Express',
80
+ // value: 'pz-bkm'
81
+ // },
82
+ // {
83
+ // name: 'Credit Payment',
84
+ // value: 'pz-credit-payment'
85
+ // }
82
86
  ];
83
87
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
84
88
  const prompt = new Prompt({
@@ -1,65 +1,65 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const fs = require("fs");
5
- const path = require("path");
6
- const argv = require("yargs").argv;
7
- exports.default = () => {
8
- /**
9
- * @param {string} lng Get Language
10
- */
11
- const removeLanguage = (lng) => {
12
- const workingDir = path.resolve(process.cwd());
13
- try {
14
- fs.rm(`public/locales/${lng}`, { recursive: true }, (err) => {
15
- if (err) {
16
- console.error(err);
17
- return;
18
- }
19
- });
20
- }
21
- catch (error) {
22
- console.log("error", error);
23
- }
24
- /* settings.js */
25
- const settingsPath = path.resolve(workingDir, "src/settings.js");
26
- if (!fs.existsSync(settingsPath)) {
27
- return;
28
- }
29
- const settingsData = fs.readFileSync(settingsPath, {
30
- encoding: "utf8",
31
- flag: "r",
32
- });
33
- const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${lng.toLowerCase()}-${lng.toLowerCase()}' },`;
34
- let updatedData = settingsData.replace(data.toString(), "");
35
- updatedData = updatedData.replace(/^\s*$(?:\r\n?|\n)/gm, "");
36
- fs.writeFileSync(settingsPath, updatedData);
37
- /* next-i18next.config.js */
38
- const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
39
- if (!fs.existsSync(i18nPath)) {
40
- return;
41
- }
42
- const i18nData = fs.readFileSync(i18nPath, {
43
- encoding: "utf8",
44
- flag: "r",
45
- });
46
- fs.writeFileSync(i18nPath, i18nData.replace(`'${lng}',\u0020`, ""));
47
- console.log("\x1b[32m%s\x1b[0m", `\n✓ Remove language option ${lng.toUpperCase()}.\n`);
48
- console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
49
- };
50
- const init = () => {
51
- if (!argv.removeLanguage)
52
- return;
53
- let lng = argv.removeLanguage;
54
- try {
55
- removeLanguage(lng);
56
- }
57
- catch (err) {
58
- const typedError = err;
59
- console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
60
- ? typedError.message + "\n"
61
- : "Something went wrong.\n"}`);
62
- }
63
- };
64
- init();
65
- };
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const argv = require("yargs").argv;
7
+ exports.default = () => {
8
+ /**
9
+ * @param {string} lng Get Language
10
+ */
11
+ const removeLanguage = (lng) => {
12
+ const workingDir = path.resolve(process.cwd());
13
+ try {
14
+ fs.rm(`public/locales/${lng}`, { recursive: true }, (err) => {
15
+ if (err) {
16
+ console.error(err);
17
+ return;
18
+ }
19
+ });
20
+ }
21
+ catch (error) {
22
+ console.log("error", error);
23
+ }
24
+ /* settings.js */
25
+ const settingsPath = path.resolve(workingDir, "src/settings.js");
26
+ if (!fs.existsSync(settingsPath)) {
27
+ return;
28
+ }
29
+ const settingsData = fs.readFileSync(settingsPath, {
30
+ encoding: "utf8",
31
+ flag: "r",
32
+ });
33
+ const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${lng.toLowerCase()}-${lng.toLowerCase()}' },`;
34
+ let updatedData = settingsData.replace(data.toString(), "");
35
+ updatedData = updatedData.replace(/^\s*$(?:\r\n?|\n)/gm, "");
36
+ fs.writeFileSync(settingsPath, updatedData);
37
+ /* next-i18next.config.js */
38
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
39
+ if (!fs.existsSync(i18nPath)) {
40
+ return;
41
+ }
42
+ const i18nData = fs.readFileSync(i18nPath, {
43
+ encoding: "utf8",
44
+ flag: "r",
45
+ });
46
+ fs.writeFileSync(i18nPath, i18nData.replace(`'${lng}',\u0020`, ""));
47
+ console.log("\x1b[32m%s\x1b[0m", `\n✓ Remove language option ${lng.toUpperCase()}.\n`);
48
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
49
+ };
50
+ const init = () => {
51
+ if (!argv.removeLanguage)
52
+ return;
53
+ let lng = argv.removeLanguage;
54
+ try {
55
+ removeLanguage(lng);
56
+ }
57
+ catch (err) {
58
+ const typedError = err;
59
+ console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
60
+ ? typedError.message + "\n"
61
+ : "Something went wrong.\n"}`);
62
+ }
63
+ };
64
+ init();
65
+ };
package/dist/utils.js CHANGED
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.slugify = void 0;
4
- const slugify = (text) => {
5
- text = text.replace(/^[A-Z]/g, (letter) => letter.toLowerCase());
6
- text = text.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
7
- return text
8
- .toLowerCase()
9
- .replace(/[\s_]+/g, "-")
10
- .replace(/[^a-z0-9-_]/g, "");
11
- };
12
- exports.slugify = slugify;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.slugify = void 0;
4
+ const slugify = (text) => {
5
+ text = text.replace(/^[A-Z]/g, (letter) => letter.toLowerCase());
6
+ text = text.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
7
+ return text
8
+ .toLowerCase()
9
+ .replace(/[\s_]+/g, "-")
10
+ .replace(/[^a-z0-9-_]/g, "");
11
+ };
12
+ exports.slugify = slugify;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "1.14.1",
3
+ "version": "1.16.0",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {