@akinon/projectzero 1.13.1 → 1.14.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,98 +1,98 @@
1
- import * as fs from 'fs';
2
- import path from 'path';
3
- import { execSync } from 'child_process';
4
-
5
- const Prompt = require('prompt-checkbox');
6
-
7
- const rootDir = path.resolve(process.cwd());
8
- const pluginsFilePath = path.resolve(rootDir, './src/plugins.js');
9
-
10
- let installedPlugins: Array<string> = [];
11
-
12
- try {
13
- installedPlugins = require(path.resolve(rootDir, './src/plugins.js'));
14
- } catch (error) {}
15
-
16
- const definedPlugins = [
17
- {
18
- name: 'Basket Gift Pack',
19
- value: 'pz-basket-gift-pack'
20
- },
21
- {
22
- name: 'Click & Collect',
23
- value: 'pz-click-collect'
24
- },
25
- {
26
- name: 'Checkout Gift Pack',
27
- value: 'pz-checkout-gift-pack'
28
- },
29
- {
30
- name: 'One Click Checkout',
31
- value: 'pz-one-click-checkout'
32
- },
33
- {
34
- name: 'Garanti Pay',
35
- value: 'pz-gpay'
36
- },
37
- {
38
- name: 'Pay On Delivery',
39
- value: 'pz-pay-on-delivery'
40
- },
41
- {
42
- name: 'Otp',
43
- value: 'pz-otp'
44
- },
45
- {
46
- name: 'BKM Express',
47
- value: 'pz-bkm'
48
- }
49
- ];
50
-
51
- export default async () => {
52
- const prompt = new Prompt({
53
- name: 'plugins',
54
- message: 'Please check/uncheck plugins to install/uninstall.',
55
- type: 'checkbox',
56
- default: installedPlugins.map((p) =>
57
- definedPlugins.findIndex((dp) => dp.value === p)
58
- ),
59
- choices: definedPlugins.map((p, index) => `${index + 1}) ${p.name}`)
60
- });
61
-
62
- prompt.ask(async (answers: Array<string>) => {
63
- const formattedAnswers = answers.map((answer) =>
64
- answer.replace(/\d\)\s/, '')
65
- );
66
-
67
- const values = formattedAnswers.map(
68
- (answer) => definedPlugins.find((p) => p.name === answer)?.value
69
- );
70
-
71
- if (formattedAnswers.length) {
72
- console.log(`\nInstalling ${formattedAnswers.join(', ')}.`);
73
- } else {
74
- console.log(`\nUninstalling all plugins.`);
75
- }
76
-
77
- console.log(`\nPlease wait...`);
78
-
79
- fs.writeFileSync(
80
- pluginsFilePath,
81
- `module.exports = ${JSON.stringify(values)};\n`,
82
- {
83
- encoding: 'utf-8'
84
- }
85
- );
86
-
87
- execSync('yarn install', { stdio: 'pipe' });
88
-
89
- console.log(
90
- '\x1b[32m%s\x1b[0m',
91
- `\n ✓ ${
92
- formattedAnswers.length
93
- ? 'Installed selected plugins'
94
- : 'Uninstalled all plugins'
95
- }.\n`
96
- );
97
- });
98
- };
1
+ import * as fs from 'fs';
2
+ import path from 'path';
3
+ import { execSync } from 'child_process';
4
+
5
+ const Prompt = require('prompt-checkbox');
6
+
7
+ const rootDir = path.resolve(process.cwd());
8
+ const pluginsFilePath = path.resolve(rootDir, './src/plugins.js');
9
+
10
+ let installedPlugins: Array<string> = [];
11
+
12
+ try {
13
+ installedPlugins = require(path.resolve(rootDir, './src/plugins.js'));
14
+ } catch (error) {}
15
+
16
+ const definedPlugins = [
17
+ {
18
+ name: 'Basket Gift Pack',
19
+ value: 'pz-basket-gift-pack'
20
+ },
21
+ {
22
+ name: 'Click & Collect',
23
+ value: 'pz-click-collect'
24
+ },
25
+ {
26
+ name: 'Checkout Gift Pack',
27
+ value: 'pz-checkout-gift-pack'
28
+ },
29
+ {
30
+ name: 'One Click Checkout',
31
+ value: 'pz-one-click-checkout'
32
+ },
33
+ {
34
+ name: 'Garanti Pay',
35
+ value: 'pz-gpay'
36
+ },
37
+ {
38
+ name: 'Pay On Delivery',
39
+ value: 'pz-pay-on-delivery'
40
+ },
41
+ {
42
+ name: 'Otp',
43
+ value: 'pz-otp'
44
+ },
45
+ {
46
+ name: 'BKM Express',
47
+ value: 'pz-bkm'
48
+ }
49
+ ];
50
+
51
+ export default async () => {
52
+ const prompt = new Prompt({
53
+ name: 'plugins',
54
+ message: 'Please check/uncheck plugins to install/uninstall.',
55
+ type: 'checkbox',
56
+ default: installedPlugins.map((p) =>
57
+ definedPlugins.findIndex((dp) => dp.value === p)
58
+ ),
59
+ choices: definedPlugins.map((p, index) => `${index + 1}) ${p.name}`)
60
+ });
61
+
62
+ prompt.ask(async (answers: Array<string>) => {
63
+ const formattedAnswers = answers.map((answer) =>
64
+ answer.replace(/\d\)\s/, '')
65
+ );
66
+
67
+ const values = formattedAnswers.map(
68
+ (answer) => definedPlugins.find((p) => p.name === answer)?.value
69
+ );
70
+
71
+ if (formattedAnswers.length) {
72
+ console.log(`\nInstalling ${formattedAnswers.join(', ')}.`);
73
+ } else {
74
+ console.log(`\nUninstalling all plugins.`);
75
+ }
76
+
77
+ console.log(`\nPlease wait...`);
78
+
79
+ fs.writeFileSync(
80
+ pluginsFilePath,
81
+ `module.exports = ${JSON.stringify(values)};\n`,
82
+ {
83
+ encoding: 'utf-8'
84
+ }
85
+ );
86
+
87
+ execSync('yarn install', { stdio: 'pipe' });
88
+
89
+ console.log(
90
+ '\x1b[32m%s\x1b[0m',
91
+ `\n ✓ ${
92
+ formattedAnswers.length
93
+ ? 'Installed selected plugins'
94
+ : 'Uninstalled all plugins'
95
+ }.\n`
96
+ );
97
+ });
98
+ };
@@ -1,91 +1,91 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const argv = require("yargs").argv;
6
-
7
- export default () => {
8
- /**
9
- * @param {string} lng Get Language
10
- */
11
-
12
- const removeLanguage = (lng: string) => {
13
- const workingDir = path.resolve(process.cwd());
14
-
15
- try {
16
- fs.rm(`public/locales/${lng}`, { recursive: true }, (err: any) => {
17
- if (err) {
18
- console.error(err);
19
- return;
20
- }
21
- });
22
- } catch (error) {
23
- console.log("error", error);
24
- }
25
-
26
- /* settings.js */
27
-
28
- const settingsPath = path.resolve(workingDir, "src/settings.js");
29
-
30
- if (!fs.existsSync(settingsPath)) {
31
- return;
32
- }
33
-
34
- const settingsData = fs.readFileSync(settingsPath, {
35
- encoding: "utf8",
36
- flag: "r",
37
- });
38
-
39
- const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${lng.toLowerCase()}-${lng.toLowerCase()}' },`;
40
-
41
- let updatedData = settingsData.replace(data.toString(), "");
42
-
43
- updatedData = updatedData.replace(/^\s*$(?:\r\n?|\n)/gm, "");
44
-
45
- fs.writeFileSync(settingsPath, updatedData);
46
-
47
- /* next-i18next.config.js */
48
-
49
- const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
50
-
51
- if (!fs.existsSync(i18nPath)) {
52
- return;
53
- }
54
-
55
- const i18nData = fs.readFileSync(i18nPath, {
56
- encoding: "utf8",
57
- flag: "r",
58
- });
59
-
60
- fs.writeFileSync(i18nPath, i18nData.replace(`'${lng}',\u0020`, ""));
61
-
62
- console.log(
63
- "\x1b[32m%s\x1b[0m",
64
- `\n✓ Remove language option ${lng.toUpperCase()}.\n`
65
- );
66
-
67
- console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
68
- };
69
-
70
- const init = () => {
71
- if (!argv.removeLanguage) return;
72
- let lng = argv.removeLanguage;
73
-
74
- try {
75
- removeLanguage(lng);
76
- } catch (err) {
77
- const typedError = err as Error;
78
-
79
- console.log(
80
- "\n\x1b[31m%s\x1b[0m",
81
- `${
82
- typedError.message
83
- ? typedError.message + "\n"
84
- : "Something went wrong.\n"
85
- }`
86
- );
87
- }
88
- };
89
-
90
- init();
91
- };
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const argv = require("yargs").argv;
6
+
7
+ export default () => {
8
+ /**
9
+ * @param {string} lng Get Language
10
+ */
11
+
12
+ const removeLanguage = (lng: string) => {
13
+ const workingDir = path.resolve(process.cwd());
14
+
15
+ try {
16
+ fs.rm(`public/locales/${lng}`, { recursive: true }, (err: any) => {
17
+ if (err) {
18
+ console.error(err);
19
+ return;
20
+ }
21
+ });
22
+ } catch (error) {
23
+ console.log("error", error);
24
+ }
25
+
26
+ /* settings.js */
27
+
28
+ const settingsPath = path.resolve(workingDir, "src/settings.js");
29
+
30
+ if (!fs.existsSync(settingsPath)) {
31
+ return;
32
+ }
33
+
34
+ const settingsData = fs.readFileSync(settingsPath, {
35
+ encoding: "utf8",
36
+ flag: "r",
37
+ });
38
+
39
+ const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${lng.toLowerCase()}-${lng.toLowerCase()}' },`;
40
+
41
+ let updatedData = settingsData.replace(data.toString(), "");
42
+
43
+ updatedData = updatedData.replace(/^\s*$(?:\r\n?|\n)/gm, "");
44
+
45
+ fs.writeFileSync(settingsPath, updatedData);
46
+
47
+ /* next-i18next.config.js */
48
+
49
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
50
+
51
+ if (!fs.existsSync(i18nPath)) {
52
+ return;
53
+ }
54
+
55
+ const i18nData = fs.readFileSync(i18nPath, {
56
+ encoding: "utf8",
57
+ flag: "r",
58
+ });
59
+
60
+ fs.writeFileSync(i18nPath, i18nData.replace(`'${lng}',\u0020`, ""));
61
+
62
+ console.log(
63
+ "\x1b[32m%s\x1b[0m",
64
+ `\n✓ Remove language option ${lng.toUpperCase()}.\n`
65
+ );
66
+
67
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
68
+ };
69
+
70
+ const init = () => {
71
+ if (!argv.removeLanguage) return;
72
+ let lng = argv.removeLanguage;
73
+
74
+ try {
75
+ removeLanguage(lng);
76
+ } catch (err) {
77
+ const typedError = err as Error;
78
+
79
+ console.log(
80
+ "\n\x1b[31m%s\x1b[0m",
81
+ `${
82
+ typedError.message
83
+ ? typedError.message + "\n"
84
+ : "Something went wrong.\n"
85
+ }`
86
+ );
87
+ }
88
+ };
89
+
90
+ init();
91
+ };
package/dist/index.js CHANGED
File without changes
package/index.ts CHANGED
@@ -1,15 +1,15 @@
1
- #! /usr/bin/env node
2
-
3
- import commands from './commands';
4
-
5
- const yargs = require('yargs/yargs');
6
- const { hideBin } = require('yargs/helpers');
7
- const args = yargs(hideBin(process.argv)).argv;
8
-
9
- (() => {
10
- Object.keys(args)
11
- .filter((arg) => (commands as any)[arg])
12
- .forEach((arg) => {
13
- (commands as any)[arg]();
14
- });
15
- })();
1
+ #! /usr/bin/env node
2
+
3
+ import commands from './commands';
4
+
5
+ const yargs = require('yargs/yargs');
6
+ const { hideBin } = require('yargs/helpers');
7
+ const args = yargs(hideBin(process.argv)).argv;
8
+
9
+ (() => {
10
+ Object.keys(args)
11
+ .filter((arg) => (commands as any)[arg])
12
+ .forEach((arg) => {
13
+ (commands as any)[arg]();
14
+ });
15
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {