@akinon/projectzero 1.14.0 → 1.15.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.
package/.gitattributes ADDED
@@ -0,0 +1,15 @@
1
+ *.js text eol=lf
2
+ *.jsx text eol=lf
3
+ *.ts text eol=lf
4
+ *.tsx text eol=lf
5
+ *.json text eol=lf
6
+ *.md text eol=lf
7
+
8
+ .eslintignore text eol=lf
9
+ .eslintrc text eol=lf
10
+ .gitignore text eol=lf
11
+ .prettierrc text eol=lf
12
+ .yarnrc text eol=lf
13
+
14
+ * text=auto
15
+
package/.prettierrc CHANGED
@@ -1,12 +1,12 @@
1
- {
2
- "bracketSameLine": false,
3
- "tabWidth": 2,
4
- "singleQuote": true,
5
- "bracketSpacing": true,
6
- "semi": true,
7
- "useTabs": false,
8
- "arrowParens": "always",
9
- "endOfLine": "lf",
10
- "proseWrap": "never",
11
- "trailingComma": "none"
12
- }
1
+ {
2
+ "bracketSameLine": false,
3
+ "tabWidth": 2,
4
+ "singleQuote": true,
5
+ "bracketSpacing": true,
6
+ "semi": true,
7
+ "useTabs": false,
8
+ "arrowParens": "always",
9
+ "endOfLine": "lf",
10
+ "proseWrap": "never",
11
+ "trailingComma": "none"
12
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @akinon/projectzero
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 96dd05f: ZERO-2373: Add credit payment
8
+ - 96dd05f: ZERO-2385: Add gitattributes file
9
+
10
+ ## 1.14.1
11
+
12
+ ### Patch Changes
13
+
14
+ - Change EOL
15
+
3
16
  ## 1.14.0
4
17
 
5
18
  ## 1.13.1
@@ -1,33 +1,33 @@
1
- import * as fs from 'fs';
2
- import path from 'path';
3
-
4
- const yargs = require('yargs/yargs');
5
- const { hideBin } = require('yargs/helpers');
6
- const args = yargs(hideBin(process.argv)).argv;
7
-
8
- export default () => {
9
- const workingDir = path.resolve(process.cwd());
10
- const settingsPath = path.resolve(workingDir, './src/settings.js');
11
-
12
- if (!fs.existsSync(settingsPath)) {
13
- return;
14
- }
15
-
16
- const settingsData = fs.readFileSync(settingsPath, {
17
- encoding: 'utf8',
18
- flag: 'r'
19
- });
20
-
21
- fs.writeFileSync(
22
- settingsPath,
23
- settingsData.replace(
24
- /commerceUrl: '.*'/,
25
- `commerceUrl: '${args.commerceUrl}'`
26
- )
27
- );
28
-
29
- console.log(
30
- '\x1b[32m%s\x1b[0m',
31
- `\n ✓ Commerce URL is set to ${args.commerceUrl}.\n\n`
32
- );
33
- };
1
+ import * as fs from 'fs';
2
+ import path from 'path';
3
+
4
+ const yargs = require('yargs/yargs');
5
+ const { hideBin } = require('yargs/helpers');
6
+ const args = yargs(hideBin(process.argv)).argv;
7
+
8
+ export default () => {
9
+ const workingDir = path.resolve(process.cwd());
10
+ const settingsPath = path.resolve(workingDir, './src/settings.js');
11
+
12
+ if (!fs.existsSync(settingsPath)) {
13
+ return;
14
+ }
15
+
16
+ const settingsData = fs.readFileSync(settingsPath, {
17
+ encoding: 'utf8',
18
+ flag: 'r'
19
+ });
20
+
21
+ fs.writeFileSync(
22
+ settingsPath,
23
+ settingsData.replace(
24
+ /commerceUrl: '.*'/,
25
+ `commerceUrl: '${args.commerceUrl}'`
26
+ )
27
+ );
28
+
29
+ console.log(
30
+ '\x1b[32m%s\x1b[0m',
31
+ `\n ✓ Commerce URL is set to ${args.commerceUrl}.\n\n`
32
+ );
33
+ };
@@ -1,235 +1,235 @@
1
- import path from 'path';
2
- import * as fs from 'fs';
3
- import * as readline from 'readline';
4
- import { slugify } from '../utils';
5
- import temp from 'temp';
6
-
7
- const exec = require('child_process').exec;
8
- const loadingSpinner = require('loading-spinner');
9
-
10
- temp.track();
11
-
12
- interface Question {
13
- text: string;
14
- optional: boolean;
15
- answerKey: string;
16
- hint?: string;
17
- }
18
-
19
- interface Answers {
20
- [key: string]: string;
21
- }
22
-
23
- const repositorySlug = 'projectzeropwa';
24
- const tempDirPath = temp.mkdirSync('pz-temp');
25
- const workingDir = path.resolve(process.cwd());
26
- const rl = readline.createInterface({
27
- input: process.stdin,
28
- output: process.stdout
29
- });
30
-
31
- const ANSWERS: Answers = {};
32
-
33
- const QUESTIONS: Array<Question> = [
34
- {
35
- text: 'Brand name',
36
- optional: false,
37
- answerKey: 'brandName',
38
- hint: 'eg. Project Zero'
39
- },
40
- {
41
- text: 'Project description',
42
- optional: true,
43
- answerKey: 'projectDescription'
44
- },
45
- {
46
- text: 'Commerce URL (SERVICE_BACKEND_URL)',
47
- optional: true,
48
- answerKey: 'commerceUrl',
49
- hint: 'Can be changed later'
50
- }
51
- ];
52
-
53
- const getAnswers = () => {
54
- return new Promise<Answers>((resolve) => {
55
- const question = QUESTIONS[Object.keys(ANSWERS).length];
56
-
57
- if (!question) {
58
- rl.close();
59
- resolve(ANSWERS);
60
- return;
61
- }
62
-
63
- let questionText = question.text;
64
-
65
- if (question.hint) {
66
- questionText += ` (${question.hint})`;
67
- }
68
-
69
- if (question.optional) {
70
- questionText += ` (optional)`;
71
- }
72
-
73
- rl.question(`${questionText}: `, (answer: string) => {
74
- if (!question.optional && !answer.length) {
75
- console.log('\x1b[31m%s\x1b[0m', `* This field is required\n`);
76
- resolve(getAnswers());
77
- } else {
78
- ANSWERS[question.answerKey] = answer;
79
- resolve(getAnswers());
80
- }
81
- });
82
- });
83
- };
84
-
85
- const cloneRepository = () =>
86
- new Promise<{ error?: Error }>((resolve) => {
87
- exec(
88
- `cd ${tempDirPath} && git clone git@bitbucket.org:akinonteam/${repositorySlug}.git`,
89
- function (err: any, stdout: any, stderr: any) {
90
- if (err != null) {
91
- resolve({ error: new Error(err) });
92
- } else if (typeof stderr != 'string') {
93
- resolve({ error: new Error(stderr) });
94
- } else {
95
- resolve({});
96
- }
97
- }
98
- );
99
- });
100
-
101
- const updatePackageJson = (brandName: string) => {
102
- const packageJsonPath = path.resolve(
103
- tempDirPath,
104
- `./${repositorySlug}/package.json`
105
- );
106
-
107
- const packageJsonData = fs.readFileSync(packageJsonPath, {
108
- encoding: 'utf8',
109
- flag: 'r'
110
- });
111
-
112
- fs.writeFileSync(
113
- packageJsonPath,
114
- packageJsonData.replace(/"name": ".*"/, `"name": "${slugify(brandName)}"`)
115
- );
116
- };
117
-
118
- const updateAkinonJson = (brandName: string, projectDescription: string) => {
119
- const akinonJsonPath = path.resolve(
120
- tempDirPath,
121
- `./${repositorySlug}/akinon.json`
122
- );
123
-
124
- const akinonJsonData = fs.readFileSync(akinonJsonPath, {
125
- encoding: 'utf8',
126
- flag: 'r'
127
- });
128
-
129
- let updatedData = akinonJsonData.replace(
130
- /"name": ".*"/,
131
- `"name": "${brandName}"`
132
- );
133
-
134
- if (projectDescription) {
135
- updatedData = updatedData.replace(
136
- /"description": ".*"/,
137
- `"description": "${projectDescription}"`
138
- );
139
- }
140
-
141
- fs.writeFileSync(akinonJsonPath, updatedData);
142
- };
143
-
144
- const copyEnv = (commerceUrl: string) => {
145
- const repositoryPath = path.resolve(tempDirPath, `./${repositorySlug}`);
146
-
147
- const envExamplePath = path.resolve(repositoryPath, `./.env.example`);
148
- const envPath = path.resolve(repositoryPath, `./.env`);
149
-
150
- const envData = fs.readFileSync(envExamplePath, {
151
- encoding: 'utf8',
152
- flag: 'r'
153
- });
154
-
155
- if (commerceUrl) {
156
- fs.writeFileSync(
157
- envExamplePath,
158
- envData.replace(
159
- /SERVICE_BACKEND_URL=.*/,
160
- `SERVICE_BACKEND_URL=${commerceUrl}`
161
- )
162
- );
163
- }
164
-
165
- fs.copyFileSync(envExamplePath, envPath);
166
- };
167
-
168
- const updatePlugins = () => {
169
- const pluginsPath = path.resolve(
170
- tempDirPath,
171
- `./${repositorySlug}/src/plugins.js`
172
- );
173
-
174
- fs.writeFileSync(pluginsPath, 'module.exports = [];');
175
- };
176
-
177
- export default async () => {
178
- const minNodeVersion = 18;
179
- const currentNodeVersion = parseInt(
180
- process.version.replace('v', '').split('.')[0]
181
- );
182
-
183
- if (currentNodeVersion < minNodeVersion) {
184
- console.log(
185
- '\x1b[31m%s\x1b[0m',
186
- `Node version must be ${minNodeVersion} or higher.\n`.concat(
187
- `Current version is ${currentNodeVersion}. Please update your Node version.`
188
- )
189
- );
190
-
191
- process.exit(1);
192
- }
193
-
194
- const answers = await getAnswers();
195
-
196
- const brandName =
197
- answers.brandName === '.'
198
- ? path.basename(process.cwd())
199
- : answers.brandName;
200
-
201
- loadingSpinner.start();
202
-
203
- await cloneRepository();
204
- updatePackageJson(brandName);
205
- updateAkinonJson(brandName, answers.projectDescription);
206
- copyEnv(answers.commerceUrl);
207
- updatePlugins();
208
-
209
- const slugifiedBrandName = slugify(answers.brandName);
210
-
211
- fs.rmSync(path.resolve(tempDirPath, `./${repositorySlug}/.git`), {
212
- recursive: true,
213
- force: true
214
- });
215
-
216
- fs.cpSync(
217
- path.resolve(tempDirPath, `./${repositorySlug}`),
218
- path.resolve(workingDir, `./${slugifiedBrandName}`),
219
- {
220
- recursive: true,
221
- force: true
222
- }
223
- );
224
-
225
- temp.cleanupSync();
226
-
227
- loadingSpinner.stop();
228
-
229
- console.log(
230
- '\x1b[32m%s\x1b[0m',
231
- `\n ✓ ${answers.brandName} project is ready.\n`
232
- );
233
-
234
- console.log('\x1b[33m%s\x1b[0m', 'Project Zero - Akinon\n');
235
- };
1
+ import path from 'path';
2
+ import * as fs from 'fs';
3
+ import * as readline from 'readline';
4
+ import { slugify } from '../utils';
5
+ import temp from 'temp';
6
+
7
+ const exec = require('child_process').exec;
8
+ const loadingSpinner = require('loading-spinner');
9
+
10
+ temp.track();
11
+
12
+ interface Question {
13
+ text: string;
14
+ optional: boolean;
15
+ answerKey: string;
16
+ hint?: string;
17
+ }
18
+
19
+ interface Answers {
20
+ [key: string]: string;
21
+ }
22
+
23
+ const repositorySlug = 'projectzeropwa';
24
+ const tempDirPath = temp.mkdirSync('pz-temp');
25
+ const workingDir = path.resolve(process.cwd());
26
+ const rl = readline.createInterface({
27
+ input: process.stdin,
28
+ output: process.stdout
29
+ });
30
+
31
+ const ANSWERS: Answers = {};
32
+
33
+ const QUESTIONS: Array<Question> = [
34
+ {
35
+ text: 'Brand name',
36
+ optional: false,
37
+ answerKey: 'brandName',
38
+ hint: 'eg. Project Zero'
39
+ },
40
+ {
41
+ text: 'Project description',
42
+ optional: true,
43
+ answerKey: 'projectDescription'
44
+ },
45
+ {
46
+ text: 'Commerce URL (SERVICE_BACKEND_URL)',
47
+ optional: true,
48
+ answerKey: 'commerceUrl',
49
+ hint: 'Can be changed later'
50
+ }
51
+ ];
52
+
53
+ const getAnswers = () => {
54
+ return new Promise<Answers>((resolve) => {
55
+ const question = QUESTIONS[Object.keys(ANSWERS).length];
56
+
57
+ if (!question) {
58
+ rl.close();
59
+ resolve(ANSWERS);
60
+ return;
61
+ }
62
+
63
+ let questionText = question.text;
64
+
65
+ if (question.hint) {
66
+ questionText += ` (${question.hint})`;
67
+ }
68
+
69
+ if (question.optional) {
70
+ questionText += ` (optional)`;
71
+ }
72
+
73
+ rl.question(`${questionText}: `, (answer: string) => {
74
+ if (!question.optional && !answer.length) {
75
+ console.log('\x1b[31m%s\x1b[0m', `* This field is required\n`);
76
+ resolve(getAnswers());
77
+ } else {
78
+ ANSWERS[question.answerKey] = answer;
79
+ resolve(getAnswers());
80
+ }
81
+ });
82
+ });
83
+ };
84
+
85
+ const cloneRepository = () =>
86
+ new Promise<{ error?: Error }>((resolve) => {
87
+ exec(
88
+ `cd ${tempDirPath} && git clone git@bitbucket.org:akinonteam/${repositorySlug}.git`,
89
+ function (err: any, stdout: any, stderr: any) {
90
+ if (err != null) {
91
+ resolve({ error: new Error(err) });
92
+ } else if (typeof stderr != 'string') {
93
+ resolve({ error: new Error(stderr) });
94
+ } else {
95
+ resolve({});
96
+ }
97
+ }
98
+ );
99
+ });
100
+
101
+ const updatePackageJson = (brandName: string) => {
102
+ const packageJsonPath = path.resolve(
103
+ tempDirPath,
104
+ `./${repositorySlug}/package.json`
105
+ );
106
+
107
+ const packageJsonData = fs.readFileSync(packageJsonPath, {
108
+ encoding: 'utf8',
109
+ flag: 'r'
110
+ });
111
+
112
+ fs.writeFileSync(
113
+ packageJsonPath,
114
+ packageJsonData.replace(/"name": ".*"/, `"name": "${slugify(brandName)}"`)
115
+ );
116
+ };
117
+
118
+ const updateAkinonJson = (brandName: string, projectDescription: string) => {
119
+ const akinonJsonPath = path.resolve(
120
+ tempDirPath,
121
+ `./${repositorySlug}/akinon.json`
122
+ );
123
+
124
+ const akinonJsonData = fs.readFileSync(akinonJsonPath, {
125
+ encoding: 'utf8',
126
+ flag: 'r'
127
+ });
128
+
129
+ let updatedData = akinonJsonData.replace(
130
+ /"name": ".*"/,
131
+ `"name": "${brandName}"`
132
+ );
133
+
134
+ if (projectDescription) {
135
+ updatedData = updatedData.replace(
136
+ /"description": ".*"/,
137
+ `"description": "${projectDescription}"`
138
+ );
139
+ }
140
+
141
+ fs.writeFileSync(akinonJsonPath, updatedData);
142
+ };
143
+
144
+ const copyEnv = (commerceUrl: string) => {
145
+ const repositoryPath = path.resolve(tempDirPath, `./${repositorySlug}`);
146
+
147
+ const envExamplePath = path.resolve(repositoryPath, `./.env.example`);
148
+ const envPath = path.resolve(repositoryPath, `./.env`);
149
+
150
+ const envData = fs.readFileSync(envExamplePath, {
151
+ encoding: 'utf8',
152
+ flag: 'r'
153
+ });
154
+
155
+ if (commerceUrl) {
156
+ fs.writeFileSync(
157
+ envExamplePath,
158
+ envData.replace(
159
+ /SERVICE_BACKEND_URL=.*/,
160
+ `SERVICE_BACKEND_URL=${commerceUrl}`
161
+ )
162
+ );
163
+ }
164
+
165
+ fs.copyFileSync(envExamplePath, envPath);
166
+ };
167
+
168
+ const updatePlugins = () => {
169
+ const pluginsPath = path.resolve(
170
+ tempDirPath,
171
+ `./${repositorySlug}/src/plugins.js`
172
+ );
173
+
174
+ fs.writeFileSync(pluginsPath, 'module.exports = [];');
175
+ };
176
+
177
+ export default async () => {
178
+ const minNodeVersion = 18;
179
+ const currentNodeVersion = parseInt(
180
+ process.version.replace('v', '').split('.')[0]
181
+ );
182
+
183
+ if (currentNodeVersion < minNodeVersion) {
184
+ console.log(
185
+ '\x1b[31m%s\x1b[0m',
186
+ `Node version must be ${minNodeVersion} or higher.\n`.concat(
187
+ `Current version is ${currentNodeVersion}. Please update your Node version.`
188
+ )
189
+ );
190
+
191
+ process.exit(1);
192
+ }
193
+
194
+ const answers = await getAnswers();
195
+
196
+ const brandName =
197
+ answers.brandName === '.'
198
+ ? path.basename(process.cwd())
199
+ : answers.brandName;
200
+
201
+ loadingSpinner.start();
202
+
203
+ await cloneRepository();
204
+ updatePackageJson(brandName);
205
+ updateAkinonJson(brandName, answers.projectDescription);
206
+ copyEnv(answers.commerceUrl);
207
+ updatePlugins();
208
+
209
+ const slugifiedBrandName = slugify(answers.brandName);
210
+
211
+ fs.rmSync(path.resolve(tempDirPath, `./${repositorySlug}/.git`), {
212
+ recursive: true,
213
+ force: true
214
+ });
215
+
216
+ fs.cpSync(
217
+ path.resolve(tempDirPath, `./${repositorySlug}`),
218
+ path.resolve(workingDir, `./${slugifiedBrandName}`),
219
+ {
220
+ recursive: true,
221
+ force: true
222
+ }
223
+ );
224
+
225
+ temp.cleanupSync();
226
+
227
+ loadingSpinner.stop();
228
+
229
+ console.log(
230
+ '\x1b[32m%s\x1b[0m',
231
+ `\n ✓ ${answers.brandName} project is ready.\n`
232
+ );
233
+
234
+ console.log('\x1b[33m%s\x1b[0m', 'Project Zero - Akinon\n');
235
+ };
package/commands/index.ts CHANGED
@@ -1,15 +1,15 @@
1
- import commerceUrl from './commerce-url';
2
- import create from './create';
3
- import addLanguage from './add-language';
4
- import removeLanguage from './remove-language';
5
- import defaultLanguage from './default-language';
6
- import plugins from './plugins';
7
-
8
- export default {
9
- commerceUrl,
10
- create,
11
- addLanguage,
12
- removeLanguage,
13
- defaultLanguage,
14
- plugins
15
- };
1
+ import commerceUrl from './commerce-url';
2
+ import create from './create';
3
+ import addLanguage from './add-language';
4
+ import removeLanguage from './remove-language';
5
+ import defaultLanguage from './default-language';
6
+ import plugins from './plugins';
7
+
8
+ export default {
9
+ commerceUrl,
10
+ create,
11
+ addLanguage,
12
+ removeLanguage,
13
+ defaultLanguage,
14
+ plugins
15
+ };
@@ -1,98 +1,102 @@
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
+ name: 'Credit Payment',
51
+ value: 'pz-credit-payment'
52
+ }
53
+ ];
54
+
55
+ export default async () => {
56
+ const prompt = new Prompt({
57
+ name: 'plugins',
58
+ message: 'Please check/uncheck plugins to install/uninstall.',
59
+ type: 'checkbox',
60
+ default: installedPlugins.map((p) =>
61
+ definedPlugins.findIndex((dp) => dp.value === p)
62
+ ),
63
+ choices: definedPlugins.map((p, index) => `${index + 1}) ${p.name}`)
64
+ });
65
+
66
+ prompt.ask(async (answers: Array<string>) => {
67
+ const formattedAnswers = answers.map((answer) =>
68
+ answer.replace(/\d\)\s/, '')
69
+ );
70
+
71
+ const values = formattedAnswers.map(
72
+ (answer) => definedPlugins.find((p) => p.name === answer)?.value
73
+ );
74
+
75
+ if (formattedAnswers.length) {
76
+ console.log(`\nInstalling ${formattedAnswers.join(', ')}.`);
77
+ } else {
78
+ console.log(`\nUninstalling all plugins.`);
79
+ }
80
+
81
+ console.log(`\nPlease wait...`);
82
+
83
+ fs.writeFileSync(
84
+ pluginsFilePath,
85
+ `module.exports = ${JSON.stringify(values)};\n`,
86
+ {
87
+ encoding: 'utf-8'
88
+ }
89
+ );
90
+
91
+ execSync('yarn install', { stdio: 'pipe' });
92
+
93
+ console.log(
94
+ '\x1b[32m%s\x1b[0m',
95
+ `\n ✓ ${
96
+ formattedAnswers.length
97
+ ? 'Installed selected plugins'
98
+ : 'Uninstalled all plugins'
99
+ }.\n`
100
+ );
101
+ });
102
+ };
@@ -78,6 +78,10 @@ const definedPlugins = [
78
78
  {
79
79
  name: 'BKM Express',
80
80
  value: 'pz-bkm'
81
+ },
82
+ {
83
+ name: 'Credit Payment',
84
+ value: 'pz-credit-payment'
81
85
  }
82
86
  ];
83
87
  exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
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.14.0",
3
+ "version": "1.15.0",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {