react-native-persona 1.2.10 → 1.3.1

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/RNPersonaInquiry.podspec +1 -1
  3. package/android/README.md +14 -0
  4. package/android/build.gradle +21 -100
  5. package/bin/persona-tool +1 -2
  6. package/lib/commonjs/index.js +477 -0
  7. package/lib/commonjs/index.js.map +1 -0
  8. package/lib/commonjs/persona-tools/AndroidResourcePrinter.js +694 -0
  9. package/lib/commonjs/persona-tools/AndroidResourcePrinter.js.map +1 -0
  10. package/lib/commonjs/persona-tools/Config.js +95 -0
  11. package/lib/commonjs/persona-tools/Config.js.map +1 -0
  12. package/lib/commonjs/persona-tools/Theme.js +228 -0
  13. package/lib/commonjs/persona-tools/Theme.js.map +1 -0
  14. package/lib/commonjs/persona-tools/index.js +41 -0
  15. package/lib/commonjs/persona-tools/index.js.map +1 -0
  16. package/lib/commonjs/persona-tools/prompts.js +48 -0
  17. package/lib/commonjs/persona-tools/prompts.js.map +1 -0
  18. package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js +112 -0
  19. package/lib/commonjs/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
  20. package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js +50 -0
  21. package/lib/commonjs/persona-tools/tools/IosThemeInstructions.js.map +1 -0
  22. package/lib/commonjs/util.js +36 -0
  23. package/lib/commonjs/util.js.map +1 -0
  24. package/lib/module/index.js +452 -0
  25. package/lib/module/index.js.map +1 -0
  26. package/lib/module/persona-tools/AndroidResourcePrinter.js +686 -0
  27. package/lib/module/persona-tools/AndroidResourcePrinter.js.map +1 -0
  28. package/lib/module/persona-tools/Config.js +82 -0
  29. package/lib/module/persona-tools/Config.js.map +1 -0
  30. package/lib/module/persona-tools/Theme.js +212 -0
  31. package/lib/module/persona-tools/Theme.js.map +1 -0
  32. package/lib/module/persona-tools/index.js +33 -0
  33. package/lib/module/persona-tools/index.js.map +1 -0
  34. package/lib/module/persona-tools/prompts.js +31 -0
  35. package/lib/module/persona-tools/prompts.js.map +1 -0
  36. package/lib/module/persona-tools/tools/AndroidThemeGenerator.js +82 -0
  37. package/lib/module/persona-tools/tools/AndroidThemeGenerator.js.map +1 -0
  38. package/lib/module/persona-tools/tools/IosThemeInstructions.js +37 -0
  39. package/lib/module/persona-tools/tools/IosThemeInstructions.js.map +1 -0
  40. package/lib/module/util.js +29 -0
  41. package/lib/module/util.js.map +1 -0
  42. package/{generatedTypes → lib/typescript}/index.d.ts +67 -3
  43. package/lib/typescript/persona-tools/AndroidResourcePrinter.d.ts +40 -0
  44. package/lib/typescript/persona-tools/Config.d.ts +15 -0
  45. package/lib/typescript/persona-tools/Theme.d.ts +124 -0
  46. package/lib/typescript/persona-tools/index.d.ts +1 -0
  47. package/lib/typescript/persona-tools/prompts.d.ts +8 -0
  48. package/lib/typescript/persona-tools/tools/AndroidThemeGenerator.d.ts +5 -0
  49. package/lib/typescript/persona-tools/tools/IosThemeInstructions.d.ts +5 -0
  50. package/lib/typescript/util.d.ts +3 -0
  51. package/package.json +79 -22
  52. package/src/index.ts +17 -18
  53. package/{persona-tools/lib → src/persona-tools}/AndroidResourcePrinter.ts +314 -278
  54. package/{persona-tools/config.ts → src/persona-tools/Config.ts} +7 -7
  55. package/src/persona-tools/Theme.ts +262 -0
  56. package/src/persona-tools/index.ts +30 -0
  57. package/{persona-tools/lib → src/persona-tools}/prompts.ts +11 -11
  58. package/{persona-tools → src/persona-tools}/tools/AndroidThemeGenerator.ts +31 -32
  59. package/{persona-tools → src/persona-tools}/tools/IosThemeInstructions.ts +8 -8
  60. package/src/util.ts +3 -3
  61. package/jest.config.js +0 -10
  62. package/persona-tools/Theme.js +0 -213
  63. package/persona-tools/Theme.ts +0 -260
  64. package/persona-tools/config.js +0 -72
  65. package/persona-tools/index.js +0 -30
  66. package/persona-tools/index.ts +0 -30
  67. package/persona-tools/lib/AndroidResourcePrinter.js +0 -832
  68. package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -1135
  69. package/persona-tools/lib/AndroidResourcePrinter.spec.ts +0 -1229
  70. package/persona-tools/lib/prompts.js +0 -39
  71. package/persona-tools/tools/AndroidThemeGenerator.js +0 -59
  72. package/persona-tools/tools/IosThemeInstructions.js +0 -34
  73. package/src/index.js +0 -307
  74. package/src/util.js +0 -29
  75. package/src/util.spec.js +0 -15
  76. package/src/util.spec.ts +0 -16
  77. package/tsconfig.json +0 -29
@@ -1,6 +1,6 @@
1
- import { cosmiconfig } from "cosmiconfig";
2
- import chalk from "chalk";
3
- import { ANDROID_THEME_CONFIG_KEY, IOS_THEME_CONFIG_KEY } from "./Theme";
1
+ import { cosmiconfig } from 'cosmiconfig';
2
+ import chalk from 'chalk';
3
+ import { ANDROID_THEME_CONFIG_KEY, IOS_THEME_CONFIG_KEY } from './Theme';
4
4
 
5
5
  export interface ConfigObject {
6
6
  androidTheme: { [key: string]: string | null | undefined };
@@ -14,7 +14,7 @@ class Configuration {
14
14
  if (this.config) return this.config;
15
15
 
16
16
  try {
17
- const explorer = cosmiconfig("persona", { packageProp: "persona" });
17
+ const explorer = cosmiconfig('persona', { packageProp: 'persona' });
18
18
  const result = await explorer.search();
19
19
  if (result == null) {
20
20
  return null;
@@ -48,7 +48,7 @@ class Configuration {
48
48
  Missing configuration.
49
49
 
50
50
  In order to use this tool, it must be configured using a ${chalk.yellow(
51
- "persona"
51
+ 'persona'
52
52
  )} object within
53
53
  your package.json.
54
54
 
@@ -60,12 +60,12 @@ To get started, paste the following configuration into your package.json
60
60
  "persona": {
61
61
  "androidTheme": {
62
62
  ` +
63
- androidThemeLines.join(",\n") +
63
+ androidThemeLines.join(',\n') +
64
64
  `
65
65
  },
66
66
  "iosTheme": {
67
67
  ` +
68
- iosThemeLines.join(",\n") +
68
+ iosThemeLines.join(',\n') +
69
69
  `
70
70
  }
71
71
  }
@@ -0,0 +1,262 @@
1
+ import Table from 'cli-table';
2
+ import chalk from 'chalk';
3
+
4
+ import Config from './Config';
5
+
6
+ const COLOR_REGEX = /^[a-zA-Z0-9]{6}$/;
7
+
8
+ export enum ANDROID_THEME_CONFIG_KEY {
9
+ backgroundColor = 'backgroundColor',
10
+ primaryColor = 'primaryColor',
11
+ darkPrimaryColor = 'darkPrimaryColor',
12
+ accentColor = 'accentColor',
13
+
14
+ titleTextColor = 'titleTextColor',
15
+ titleTextFont = 'titleTextFont',
16
+ titleTextSize = 'titleTextSize',
17
+
18
+ bodyTextColor = 'bodyTextColor',
19
+ bodyTextFont = 'bodyTextFont',
20
+ bodyTextSize = 'bodyTextSize',
21
+
22
+ footnoteTextColor = 'footnoteTextColor',
23
+ footnoteTextFont = 'footnoteTextFont',
24
+ footnoteTextSize = 'footnoteTextSize',
25
+
26
+ cameraInstructionsTextColor = 'cameraInstructionsTextColor',
27
+ cameraInstructionsTextFont = 'cameraInstructionsTextFont',
28
+ cameraInstructionsTextSize = 'cameraInstructionsTextSize',
29
+
30
+ cameraHintTextColor = 'cameraHintTextColor',
31
+ cameraHintTextFont = 'cameraHintTextFont',
32
+ cameraHintTextSize = 'cameraHintTextSize',
33
+
34
+ cameraGuideHintTextColor = 'cameraGuideHintTextColor',
35
+ cameraGuideHintTextFont = 'cameraGuideHintTextFont',
36
+ cameraGuideHintTextSize = 'cameraGuideHintTextSize',
37
+
38
+ // formLabelTextColor = "formLabelTextColor",
39
+ // formLabelTextFont = "formLabelTextFont",
40
+
41
+ textFieldTextColor = 'textFieldTextColor',
42
+ textFieldTextFont = 'textFieldTextFont',
43
+
44
+ pickerTextColor = 'pickerTextColor',
45
+ pickerTextFont = 'pickerTextFont',
46
+
47
+ buttonBackgroundColor = 'buttonBackgroundColor',
48
+ buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',
49
+ buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',
50
+ buttonTextColor = 'buttonTextColor',
51
+ buttonDisabledTextColor = 'buttonDisabledTextColor',
52
+ // buttonTextAlignment = "buttonTextAlignment",
53
+ buttonCornerRadius = 'buttonCornerRadius',
54
+ buttonFont = 'buttonFont',
55
+ buttonTextSize = 'buttonTextSize',
56
+ progressColor = 'progressColor',
57
+ successAsset = 'successAsset',
58
+ failAsset = 'failAsset',
59
+ loadingAnimationAsset = 'loadingAnimationAsset',
60
+ loadingAnimationWidthPercent = 'loadingAnimationWidthPercent',
61
+ selfieAnimationAsset = 'selfieAnimationAsset',
62
+ selfieAnimationWidthPercent = 'selfieAnimationWidthPercent',
63
+ }
64
+
65
+ export enum IOS_THEME_CONFIG_KEY {
66
+ backgroundColor = 'backgroundColor',
67
+ primaryColor = 'primaryColor',
68
+ darkPrimaryColor = 'darkPrimaryColor',
69
+ accentColor = 'accentColor',
70
+ progressColor = 'progressColor',
71
+ overlayBackgroundColor = 'overlayBackgroundColor',
72
+ titleTextColor = 'titleTextColor',
73
+ titleTextFont = 'titleTextFont',
74
+ titleTextSize = 'titleTextSize',
75
+ titleTextAlignment = 'titleTextAlignment',
76
+ bodyTextColor = 'bodyTextColor',
77
+ bodyTextFont = 'bodyTextFont',
78
+ bodyTextSize = 'bodyTextSize',
79
+ bodyTextAlignment = 'bodyTextAlignment',
80
+ footnoteTextColor = 'footnoteTextColor',
81
+ footnoteTextFont = 'footnoteTextFont',
82
+ footnoteTextSize = 'footnoteTextSize',
83
+ formLabelTextColor = 'formLabelTextColor',
84
+ formLabelTextFont = 'formLabelTextFont',
85
+ textFieldTextColor = 'textFieldTextColor',
86
+ textFieldBackgroundColor = 'textFieldBackgroundColor',
87
+ textFieldBorderColor = 'textFieldBorderColor',
88
+ pickerTextColor = 'pickerTextColor',
89
+ pickerTextFont = 'pickerTextFont',
90
+ cameraInstructionsTextColor = 'cameraInstructionsTextColor',
91
+ cameraInstructionsTextFont = 'cameraInstructionsTextFont',
92
+ cameraInstructionsTextSize = 'cameraInstructionsTextFont',
93
+ cameraHintTextColor = 'cameraHintTextColor',
94
+ cameraHintTextFont = 'cameraHintTextFont',
95
+ cameraHintTextSize = 'cameraHintTextSize',
96
+ cameraGuideHintTextColor = 'cameraGuideHintTextColor',
97
+ cameraGuideHintTextFont = 'cameraGuideHintTextFont',
98
+ cameraGuideHintTextSize = 'cameraGuideHintTextSize',
99
+ buttonBackgroundColor = 'buttonBackgroundColor',
100
+ buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',
101
+ buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',
102
+ buttonImageTintColor = 'buttonImageTintColor',
103
+ buttonImageHidden = 'buttonImageHidden',
104
+ buttonCornerRadius = 'buttonCornerRadius',
105
+ buttonTextAlignment = 'buttonTextAlignment',
106
+ buttonDisabledTextColor = 'buttonDisabledTextColor',
107
+ buttonTextColor = 'buttonTextColor',
108
+ buttonFont = 'buttonFont',
109
+ buttonTextSize = 'buttonTextSize',
110
+ selectedCellBackgroundColor = 'selectedCellBackgroundColor',
111
+ closeButtonTintColor = 'closeButtonTintColor',
112
+ cancelButtonBackgroundColor = 'cancelButtonBackgroundColor',
113
+ cameraButtonBackgroundColor = 'cameraButtonBackgroundColor',
114
+ cameraGuideCornersColor = 'cameraGuideCornersColor',
115
+ successAssetName = 'successAssetName',
116
+ successAssetWidth = 'successAssetWidth',
117
+ successAssetHeight = 'successAssetHeight',
118
+ verificationFailAssetName = 'verificationFailAssetName',
119
+ verificationFailAssetWidth = 'verificationFailAssetWidth',
120
+ verificationFailAssetHeight = 'verificationFailAssetHeight',
121
+ failAssetName = 'failAssetName',
122
+ failAssetWidth = 'failAssetWidth',
123
+ failAssetHeight = 'failAssetHeight',
124
+ loadingAnimationAssetName = 'loadingAnimationAssetName',
125
+ loadingAnimationAssetWidth = 'loadingAnimationAssetWidth',
126
+ loadingAnimationAssetHeight = 'loadingAnimationAssetHeight',
127
+ processingAnimationAssetName = 'processingAnimationAssetName',
128
+ processingAnimationAssetWidth = 'processingAnimationAssetWidth',
129
+ processingAnimationAssetHeight = 'processingAnimationAssetHeight',
130
+ selfieAnimationAssetName = 'selfieAnimationAssetName',
131
+ selfieAnimationAssetWidth = 'selfieAnimationAssetWidth',
132
+ selfieAnimationAssetHeight = 'selfieAnimationAssetHeight',
133
+ }
134
+
135
+ export type AndroidThemeObject = {
136
+ [key in ANDROID_THEME_CONFIG_KEY]: string | null | undefined;
137
+ };
138
+
139
+ export type IosThemeObject = {
140
+ [key in IOS_THEME_CONFIG_KEY]: string | null | undefined;
141
+ };
142
+
143
+ export type ThemeObject = AndroidThemeObject | IosThemeObject;
144
+
145
+ class Theme {
146
+ async print(platform: string = 'android') {
147
+ const config = await Config.get();
148
+ const themeConfig =
149
+ platform === 'android' ? config.androidTheme : config.iosTheme;
150
+ let usesCustomFontAndroid = false;
151
+ let usesCustomFontIos = false;
152
+
153
+ const head =
154
+ platform === 'android'
155
+ ? ['Style Item', 'Value', 'Note']
156
+ : ['Style Item', 'Value', 'Note'];
157
+
158
+ const table = new Table({
159
+ head,
160
+ // prettier-ignore
161
+ chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
162
+ });
163
+
164
+ console.log('Specified theme values:');
165
+ const keyEnum =
166
+ platform === 'android' ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;
167
+ for (const key in keyEnum) {
168
+ let override =
169
+ themeConfig[key as ANDROID_THEME_CONFIG_KEY | IOS_THEME_CONFIG_KEY];
170
+ let colorOverride = key.includes('Color') || key.includes('color');
171
+
172
+ if (override) {
173
+ if (colorOverride) {
174
+ override = normalizeColor(override, key);
175
+ } else {
176
+ override = override.toString();
177
+ }
178
+ }
179
+
180
+ if (key.includes('Font')) {
181
+ if (platform == 'android') {
182
+ usesCustomFontAndroid = true;
183
+ } else {
184
+ usesCustomFontIos = true;
185
+ }
186
+ }
187
+
188
+ let row;
189
+
190
+ row = [
191
+ key,
192
+ override
193
+ ? valueColor(colorOverride, override)
194
+ : chalk.yellow('unspecified'),
195
+ key.includes('Font')
196
+ ? chalk.cyan('Fonts that are not built-in need to be installed.')
197
+ : '',
198
+ ];
199
+
200
+ table.push(row);
201
+ }
202
+
203
+ console.log(table.toString());
204
+
205
+ if (usesCustomFontAndroid) {
206
+ console.log(
207
+ chalk.yellow(' NOTE') +
208
+ ': A font customization was made. If the font is not built-in to the Android platform (https://github.com/react-native-training/react-native-fonts#android), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml'
209
+ );
210
+ }
211
+
212
+ if (usesCustomFontIos) {
213
+ console.log(
214
+ chalk.yellow(' NOTE') +
215
+ ': A font customization was made. If the font is not built-in iOS (https://github.com/react-native-training/react-native-ios), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app'
216
+ );
217
+ }
218
+
219
+ // Add newline for spacing
220
+ console.log('');
221
+ }
222
+ }
223
+
224
+ // set default print color for non-color overrides
225
+ function valueColor(isColorOverride: boolean, override: string) {
226
+ return isColorOverride
227
+ ? chalk.hex(override)(override)
228
+ : chalk.magentaBright(override);
229
+ }
230
+
231
+ function normalizeColor(colorHex: string, themeKey: string) {
232
+ let hex = colorHex;
233
+ if (colorHex[0] === '#') {
234
+ hex = colorHex.slice(1);
235
+ }
236
+
237
+ if (!COLOR_REGEX.test(hex)) {
238
+ if (themeKey) {
239
+ console.error(
240
+ `Received a color value of ${chalk.yellow(colorHex)} for ${chalk.red(
241
+ themeKey
242
+ )}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
243
+ .bgHex('#FFFFFF')
244
+ .hex('#7E66B7')('#290087')}`
245
+ );
246
+ } else {
247
+ console.error(
248
+ `Received a color value of ${chalk.yellow(
249
+ colorHex
250
+ )}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
251
+ .bgHex('#FFFFFF')
252
+ .hex('#7E66B7')('#290087')}`
253
+ );
254
+ }
255
+ console.log('');
256
+ process.exit(1);
257
+ }
258
+
259
+ return colorHex;
260
+ }
261
+
262
+ export default new Theme();
@@ -0,0 +1,30 @@
1
+ import Config from './Config';
2
+ import { TOOL_CHOICE, whatWouldYouLikePrompt } from './prompts';
3
+ import AndroidThemeGenerator from './tools/AndroidThemeGenerator';
4
+ import IosThemeInstructions from './tools/IosThemeInstructions';
5
+
6
+ console.log('');
7
+ console.log('============================================');
8
+ console.log('Persona React Native SDK customization tool.');
9
+ console.log('============================================');
10
+ console.log('');
11
+
12
+ const run = async () => {
13
+ // Run this once to print warning messages if it's not configured.
14
+ await Config.get();
15
+
16
+ const { choice } = await whatWouldYouLikePrompt();
17
+
18
+ switch (choice) {
19
+ case TOOL_CHOICE.AndroidTheme:
20
+ await AndroidThemeGenerator.run();
21
+ break;
22
+ case TOOL_CHOICE.iosTheme:
23
+ await IosThemeInstructions.run();
24
+ break;
25
+ default:
26
+ return;
27
+ }
28
+ };
29
+
30
+ run();
@@ -1,15 +1,15 @@
1
- import inquirer, { QuestionCollection } from "inquirer";
1
+ import inquirer, { QuestionCollection } from 'inquirer';
2
2
 
3
3
  export const TOOL_CHOICE = {
4
- AndroidTheme: "Update Android theme",
5
- iosTheme: "Update iOS theme",
4
+ AndroidTheme: 'Update Android theme',
5
+ iosTheme: 'Update iOS theme',
6
6
  };
7
7
  export async function whatWouldYouLikePrompt() {
8
8
  const questions = {
9
- name: "choice",
10
- type: "list",
9
+ name: 'choice',
10
+ type: 'list',
11
11
  choices: [TOOL_CHOICE.AndroidTheme, TOOL_CHOICE.iosTheme],
12
- message: "What would you like to do?",
12
+ message: 'What would you like to do?',
13
13
  } as QuestionCollection;
14
14
 
15
15
  return inquirer.prompt(questions);
@@ -17,9 +17,9 @@ export async function whatWouldYouLikePrompt() {
17
17
 
18
18
  export async function confirmThemeValues() {
19
19
  const questions = {
20
- name: "isConfirmed",
21
- type: "confirm",
22
- message: "Do these values look right?",
20
+ name: 'isConfirmed',
21
+ type: 'confirm',
22
+ message: 'Do these values look right?',
23
23
  } as QuestionCollection;
24
24
 
25
25
  return inquirer.prompt(questions);
@@ -27,8 +27,8 @@ export async function confirmThemeValues() {
27
27
 
28
28
  export async function confirmResourceFiles() {
29
29
  const questions = {
30
- name: "isConfirmed",
31
- type: "confirm",
30
+ name: 'isConfirmed',
31
+ type: 'confirm',
32
32
  message: `Continue?`,
33
33
  } as QuestionCollection;
34
34
 
@@ -1,20 +1,20 @@
1
- import fs from "fs";
2
- import chalk from "chalk";
3
- import path from "path";
1
+ import fs from 'fs';
2
+ import chalk from 'chalk';
3
+ import path from 'path';
4
4
 
5
- import Theme, { AndroidThemeObject } from "../Theme";
6
- import { confirmThemeValues, confirmResourceFiles } from "../lib/prompts";
7
- import AndroidResourcePrinter from "../lib/AndroidResourcePrinter";
8
- import Configuration from "../config";
5
+ import Theme, { AndroidThemeObject } from '../Theme';
6
+ import { confirmThemeValues, confirmResourceFiles } from '../prompts';
7
+ import AndroidResourcePrinter from '../AndroidResourcePrinter';
8
+ import Configuration from '../Config';
9
9
 
10
10
  const ANDROID_STYLES_RESOURCE_PATH =
11
- "./android/app/src/main/res/values/styles_persona.xml";
11
+ './android/app/src/main/res/values/styles_persona.xml';
12
12
  const ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH =
13
- "./android/app/src/main/res/drawable/rn_persona_button.xml";
13
+ './android/app/src/main/res/drawable/rn_persona_button.xml';
14
14
  const ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH =
15
- "./android/app/src/main/res/drawable/rn_persona_button_secondary.xml";
15
+ './android/app/src/main/res/drawable/rn_persona_button_secondary.xml';
16
16
  const ANDROID_BUTTON_COLOR_RESOURCE_PATH =
17
- "./android/app/src/main/res/color/rn_persona_button.xml";
17
+ './android/app/src/main/res/color/rn_persona_button.xml';
18
18
 
19
19
  class ThemeGenerator {
20
20
  async run() {
@@ -24,14 +24,14 @@ class ThemeGenerator {
24
24
 
25
25
  if (!themeValuesConfirmed) {
26
26
  console.log(
27
- chalk.yellow("\nPlease adjust the values in package.json.\n")
27
+ chalk.yellow('\nPlease adjust the values in package.json.\n')
28
28
  );
29
29
  return;
30
30
  }
31
31
 
32
32
  console.log(
33
33
  `\n${chalk.yellow(
34
- "Creating an Android Resource files for your project at:"
34
+ 'Creating an Android Resource files for your project at:'
35
35
  )}\n
36
36
  - ${ANDROID_STYLES_RESOURCE_PATH}
37
37
  - ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}
@@ -39,18 +39,14 @@ class ThemeGenerator {
39
39
  - ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}\n`
40
40
  );
41
41
  console.log(
42
- "Building your application with this resource file themes your Persona Inquiry flow.\n"
42
+ 'Building your application with this resource file themes your Persona Inquiry flow.\n'
43
43
  );
44
44
 
45
45
  const config = await Configuration.get();
46
- const theme = config["androidTheme"] as AndroidThemeObject;
46
+ const theme = config.androidTheme as AndroidThemeObject;
47
47
 
48
- const {
49
- style,
50
- buttonDrawable,
51
- buttonSecondaryDrawable,
52
- buttonColor
53
- } = new AndroidResourcePrinter(theme).process();
48
+ const { style, buttonDrawable, buttonSecondaryDrawable, buttonColor } =
49
+ new AndroidResourcePrinter(theme).process();
54
50
 
55
51
  let { isConfirmed: confirmed } = await confirmResourceFiles();
56
52
 
@@ -59,10 +55,10 @@ class ThemeGenerator {
59
55
  }
60
56
 
61
57
  // Add a line after confirmation
62
- console.log("");
58
+ console.log('');
63
59
 
64
60
  fs.mkdirSync(path.dirname(ANDROID_STYLES_RESOURCE_PATH), {
65
- recursive: true
61
+ recursive: true,
66
62
  });
67
63
  fs.writeFileSync(
68
64
  ANDROID_STYLES_RESOURCE_PATH,
@@ -71,12 +67,12 @@ class ThemeGenerator {
71
67
 
72
68
  console.log(
73
69
  `${chalk.green(
74
- "Saved an Android style file at path:"
70
+ 'Saved an Android style file at path:'
75
71
  )} ${ANDROID_STYLES_RESOURCE_PATH}.`
76
72
  );
77
73
 
78
74
  fs.mkdirSync(path.dirname(ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH), {
79
- recursive: true
75
+ recursive: true,
80
76
  });
81
77
  fs.writeFileSync(
82
78
  ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH,
@@ -84,25 +80,28 @@ class ThemeGenerator {
84
80
  );
85
81
  console.log(
86
82
  `${chalk.green(
87
- "Saved an Android drawable file at path:"
83
+ 'Saved an Android drawable file at path:'
88
84
  )} ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}.`
89
85
  );
90
86
 
91
- fs.mkdirSync(path.dirname(ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH), {
92
- recursive: true
93
- });
87
+ fs.mkdirSync(
88
+ path.dirname(ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH),
89
+ {
90
+ recursive: true,
91
+ }
92
+ );
94
93
  fs.writeFileSync(
95
94
  ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH,
96
95
  buttonSecondaryDrawable.end({ prettyPrint: true })
97
96
  );
98
97
  console.log(
99
98
  `${chalk.green(
100
- "Saved an Android drawable file at path:"
99
+ 'Saved an Android drawable file at path:'
101
100
  )} ${ANDROID_BUTTON_SECONDARY_DRAWABLE_RESOURCE_PATH}.`
102
101
  );
103
102
 
104
103
  fs.mkdirSync(path.dirname(ANDROID_BUTTON_COLOR_RESOURCE_PATH), {
105
- recursive: true
104
+ recursive: true,
106
105
  });
107
106
  fs.writeFileSync(
108
107
  ANDROID_BUTTON_COLOR_RESOURCE_PATH,
@@ -110,7 +109,7 @@ class ThemeGenerator {
110
109
  );
111
110
  console.log(
112
111
  `${chalk.green(
113
- "Saved an Android color file at path:"
112
+ 'Saved an Android color file at path:'
114
113
  )} ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}.`
115
114
  );
116
115
  }
@@ -1,25 +1,25 @@
1
- import Theme from "../Theme";
2
- import { confirmThemeValues } from "../lib/prompts";
3
- import chalk from "chalk";
1
+ import Theme from '../Theme';
2
+ import { confirmThemeValues } from '../prompts';
3
+ import chalk from 'chalk';
4
4
 
5
5
  class IosThemeInstructions {
6
6
  async run() {
7
- await Theme.print("ios");
7
+ await Theme.print('ios');
8
8
 
9
9
  const { isConfirmed: themeValuesConfirmed } = await confirmThemeValues();
10
10
 
11
11
  if (!themeValuesConfirmed) {
12
12
  console.log(
13
- chalk.yellow("\nPlease adjust the values in package.json.\n")
13
+ chalk.yellow('\nPlease adjust the values in package.json.\n')
14
14
  );
15
15
  return;
16
16
  }
17
17
 
18
18
  console.log(
19
- `\n${chalk.yellow("To theme the Persona Inquiry flow for iOS:")}`
19
+ `\n${chalk.yellow('To theme the Persona Inquiry flow for iOS:')}`
20
20
  );
21
21
  console.log(
22
- "Add the theme values to the Persona Inquiry SDK client by using the `.iosTheme` builder function"
22
+ 'Add the theme values to the Persona Inquiry SDK client by using the `.iosTheme` builder function'
23
23
  );
24
24
 
25
25
  console.log(`
@@ -30,7 +30,7 @@ class IosThemeInstructions {
30
30
  .onCancelled(handleCancelled)
31
31
  .onFailed(handleFailed)
32
32
  .onError(handleError)
33
- ${chalk.green("+ .iosTheme(persona.iosTheme)")}
33
+ ${chalk.green('+ .iosTheme(persona.iosTheme)')}
34
34
  .build()
35
35
  .start();
36
36
  ...
package/src/util.ts CHANGED
@@ -6,13 +6,13 @@ export function processThemeValues(themeObject: Object) {
6
6
  continue;
7
7
  }
8
8
 
9
- if (key.includes("Color")) {
9
+ if (key.includes('Color')) {
10
10
  let colorValue = value;
11
- if (value[0] === "#") {
11
+ if (value[0] === '#') {
12
12
  colorValue = value.slice(1);
13
13
  }
14
14
 
15
- if(HEX_REGEX.test(colorValue)) {
15
+ if (HEX_REGEX.test(colorValue)) {
16
16
  result[key] = `#${colorValue}`;
17
17
  } else {
18
18
  continue;
package/jest.config.js DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- preset: "ts-jest",
3
- testEnvironment: "node",
4
- testPathIgnorePatterns: [
5
- "<rootDir>/node_modules/",
6
- "<rootDir>/example/",
7
- ".js"
8
- ],
9
- moduleFileExtensions: ["ts", "tsx", "js", "json", "jsx", "node"]
10
- };