react-native-persona 2.9.2 → 2.9.4

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 (47) hide show
  1. package/README.md +0 -42
  2. package/RNPersonaInquiry2.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/package.json +7 -12
  5. package/bin/persona-tool +0 -3
  6. package/lib/commonjs/persona-tool/AndroidResourcePrinter.js +0 -462
  7. package/lib/commonjs/persona-tool/AndroidResourcePrinter.js.map +0 -1
  8. package/lib/commonjs/persona-tool/Config.js +0 -78
  9. package/lib/commonjs/persona-tool/Config.js.map +0 -1
  10. package/lib/commonjs/persona-tool/Theme.js +0 -188
  11. package/lib/commonjs/persona-tool/Theme.js.map +0 -1
  12. package/lib/commonjs/persona-tool/index.js +0 -31
  13. package/lib/commonjs/persona-tool/index.js.map +0 -1
  14. package/lib/commonjs/persona-tool/prompts.js +0 -42
  15. package/lib/commonjs/persona-tool/prompts.js.map +0 -1
  16. package/lib/commonjs/persona-tool/tools/AndroidThemeGenerator.js +0 -74
  17. package/lib/commonjs/persona-tool/tools/AndroidThemeGenerator.js.map +0 -1
  18. package/lib/commonjs/persona-tool/tools/IosThemeInstructions.js +0 -40
  19. package/lib/commonjs/persona-tool/tools/IosThemeInstructions.js.map +0 -1
  20. package/lib/module/persona-tool/AndroidResourcePrinter.js +0 -455
  21. package/lib/module/persona-tool/AndroidResourcePrinter.js.map +0 -1
  22. package/lib/module/persona-tool/Config.js +0 -70
  23. package/lib/module/persona-tool/Config.js.map +0 -1
  24. package/lib/module/persona-tool/Theme.js +0 -178
  25. package/lib/module/persona-tool/Theme.js.map +0 -1
  26. package/lib/module/persona-tool/index.js +0 -28
  27. package/lib/module/persona-tool/index.js.map +0 -1
  28. package/lib/module/persona-tool/prompts.js +0 -31
  29. package/lib/module/persona-tool/prompts.js.map +0 -1
  30. package/lib/module/persona-tool/tools/AndroidThemeGenerator.js +0 -66
  31. package/lib/module/persona-tool/tools/AndroidThemeGenerator.js.map +0 -1
  32. package/lib/module/persona-tool/tools/IosThemeInstructions.js +0 -32
  33. package/lib/module/persona-tool/tools/IosThemeInstructions.js.map +0 -1
  34. package/lib/typescript/persona-tool/AndroidResourcePrinter.d.ts +0 -35
  35. package/lib/typescript/persona-tool/Config.d.ts +0 -15
  36. package/lib/typescript/persona-tool/Theme.d.ts +0 -108
  37. package/lib/typescript/persona-tool/index.d.ts +0 -1
  38. package/lib/typescript/persona-tool/prompts.d.ts +0 -8
  39. package/lib/typescript/persona-tool/tools/AndroidThemeGenerator.d.ts +0 -5
  40. package/lib/typescript/persona-tool/tools/IosThemeInstructions.d.ts +0 -5
  41. package/src/persona-tool/AndroidResourcePrinter.ts +0 -652
  42. package/src/persona-tool/Config.ts +0 -86
  43. package/src/persona-tool/Theme.ts +0 -243
  44. package/src/persona-tool/index.ts +0 -30
  45. package/src/persona-tool/prompts.ts +0 -36
  46. package/src/persona-tool/tools/AndroidThemeGenerator.ts +0 -100
  47. package/src/persona-tool/tools/IosThemeInstructions.ts +0 -41
@@ -1,86 +0,0 @@
1
- import { cosmiconfig } from 'cosmiconfig';
2
- import chalk from 'chalk';
3
- import { ANDROID_THEME_CONFIG_KEY, IOS_THEME_CONFIG_KEY } from './Theme';
4
-
5
- export interface ConfigObject {
6
- androidTheme: { [key: string]: string | null | undefined };
7
- iosTheme: { [key: string]: string | null | undefined };
8
- }
9
-
10
- class Configuration {
11
- config?: ConfigObject | null;
12
-
13
- async loadConfig(): Promise<ConfigObject | null | undefined> {
14
- if (this.config) return this.config;
15
-
16
- try {
17
- const explorer = cosmiconfig('persona', { packageProp: 'persona' });
18
- const result = await explorer.search();
19
- if (result == null) {
20
- return null;
21
- }
22
-
23
- this.config = result.config;
24
-
25
- return this.config;
26
- } catch (e) {
27
- console.error(e);
28
- process.exit(1);
29
- }
30
- }
31
-
32
- async get(): Promise<ConfigObject> {
33
- let config = await this.loadConfig();
34
-
35
- const androidThemeLines = [];
36
- for (const key in ANDROID_THEME_CONFIG_KEY) {
37
- androidThemeLines.push(` "${key}": null`);
38
- }
39
-
40
- const iosThemeLines = [];
41
- for (const key in IOS_THEME_CONFIG_KEY) {
42
- iosThemeLines.push(` "${key}": null`);
43
- }
44
-
45
- if (config == null) {
46
- console.log(
47
- `
48
- Missing configuration.
49
-
50
- In order to use this tool, it must be configured using a ${chalk.yellow(
51
- 'persona'
52
- )} object within
53
- your package.json.
54
-
55
- To get started, paste the following configuration into your package.json
56
-
57
- {
58
- ...
59
-
60
- "persona": {
61
- "androidTheme": {
62
- ` +
63
- androidThemeLines.join(',\n') +
64
- `
65
- },
66
- "iosTheme": {
67
- ` +
68
- iosThemeLines.join(',\n') +
69
- `
70
- }
71
- }
72
-
73
- ...
74
- }
75
-
76
- and re-run this tool :).
77
- `
78
- );
79
- process.exit(1);
80
- }
81
-
82
- return config as ConfigObject;
83
- }
84
- }
85
-
86
- export default new Configuration();
@@ -1,243 +0,0 @@
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
-
17
- bodyTextColor = 'bodyTextColor',
18
- bodyTextFont = 'bodyTextFont',
19
-
20
- footnoteTextColor = 'footnoteTextColor',
21
- footnoteTextFont = 'footnoteTextFont',
22
-
23
- // formLabelTextColor = "formLabelTextColor",
24
- // formLabelTextFont = "formLabelTextFont",
25
-
26
- textFieldTextColor = 'textFieldTextColor',
27
- textFieldTextFont = 'textFieldTextFont',
28
-
29
- pickerTextColor = 'pickerTextColor',
30
- pickerTextFont = 'pickerTextFont',
31
-
32
- buttonBackgroundColor = 'buttonBackgroundColor',
33
- buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',
34
- buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',
35
- buttonTextColor = 'buttonTextColor',
36
- buttonDisabledTextColor = 'buttonDisabledTextColor',
37
- // buttonTextAlignment = "buttonTextAlignment",
38
- buttonCornerRadius = 'buttonCornerRadius',
39
- buttonFont = 'buttonFont',
40
- progressColor = 'progressColor',
41
- successAsset = 'successAsset',
42
- failAsset = 'failAsset',
43
- loadingAnimationAsset = 'loadingAnimationAsset',
44
- loadingAnimationWidthPercent = 'loadingAnimationWidthPercent',
45
- selfieAnimationAsset = 'selfieAnimationAsset',
46
- selfieAnimationWidthPercent = 'selfieAnimationWidthPercent',
47
- }
48
-
49
- export enum IOS_THEME_CONFIG_KEY {
50
- backgroundColor = 'backgroundColor',
51
- primaryColor = 'primaryColor',
52
- darkPrimaryColor = 'darkPrimaryColor',
53
- accentColor = 'accentColor',
54
- errorColor = 'errorColor',
55
- errorTextFont = 'errorTextFont',
56
- overlayBackgroundColor = 'overlayBackgroundColor',
57
- titleTextAlignment = 'titleTextAlignment',
58
- titleTextColor = 'titleTextColor',
59
- titleTextFont = 'titleTextFont',
60
- cardTitleTextFont = 'cardTitleTextFont',
61
- bodyTextAlignment = 'bodyTextAlignment',
62
- bodyTextColor = 'bodyTextColor',
63
- bodyTextFont = 'bodyTextFont',
64
- footnoteTextColor = 'footnoteTextColor',
65
- footnoteTextFont = 'footnoteTextFont',
66
- formLabelTextColor = 'formLabelTextColor',
67
- formLabelTextFont = 'formLabelTextFont',
68
- textFieldTextColor = 'textFieldTextColor',
69
- textFieldBackgroundColor = 'textFieldBackgroundColor',
70
- textFieldBorderColor = 'textFieldBorderColor',
71
- textFieldCornerRadius = 'textFieldCornerRadius',
72
- textFieldFont = 'textFieldFont',
73
- textFieldPlaceholderFont = 'textFieldPlaceholderFont',
74
- pickerTextColor = 'pickerTextColor',
75
- pickerTextFont = 'pickerTextFont',
76
- buttonBackgroundColor = 'buttonBackgroundColor',
77
- buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',
78
- buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',
79
- buttonTextColor = 'buttonTextColor',
80
- buttonDisabledTextColor = 'buttonDisabledTextColor',
81
- buttonTextAlignment = 'buttonTextAlignment',
82
- buttonImageTintColor = 'buttonImageTintColor',
83
- buttonCornerRadius = 'buttonCornerRadius',
84
- buttonBorderWidth = 'buttonBorderWidth',
85
- buttonBorderColor = 'buttonBorderColor',
86
- buttonFont = 'buttonFont',
87
- buttonSecondaryBackgroundColor = 'buttonSecondaryBackgroundColor',
88
- buttonSecondaryDisabledBackgroundColor = 'buttonSecondaryDisabledBackgroundColor',
89
- buttonSecondaryTouchedBackgroundColor = 'buttonSecondaryTouchedBackgroundColor',
90
- buttonSecondaryTextColor = 'buttonSecondaryTextColor',
91
- buttonSecondaryDisabledTextColor = 'buttonSecondaryDisabledTextColor',
92
- buttonSecondaryTextAlignment = 'buttonSecondaryTextAlignment',
93
- buttonSecondaryImageTintColor = 'buttonSecondaryImageTintColor',
94
- buttonSecondaryCornerRadius = 'buttonSecondaryCornerRadius',
95
- buttonSecondaryBorderWidth = 'buttonSecondaryBorderWidth',
96
- buttonSecondaryBorderColor = 'buttonSecondaryBorderColor',
97
- buttonSecondaryFont = 'buttonSecondaryFont',
98
- selectedCellBackgroundColor = 'selectedCellBackgroundColor',
99
- closeButtonTintColor = 'closeButtonTintColor',
100
- cancelButtonBackgroundColor = 'cancelButtonBackgroundColor',
101
- cancelButtonTextColor = 'cancelButtonTextColor',
102
- cancelButtonAlternateBackgroundColor = 'cancelButtonAlternateBackgroundColor',
103
- cancelButtonAlternateTextColor = 'cancelButtonAlternateTextColor',
104
- processingLabelsTextAlignment = 'processingLabelsTextAlignment',
105
- loadingAnimationAssetName = 'loadingAnimationAssetName',
106
- loadingAnimationAssetWidth = 'loadingAnimationAssetWidth',
107
- loadingAnimationAssetHeight = 'loadingAnimationAssetHeight',
108
- processingAnimationAssetName = 'processingAnimationAssetName',
109
- processingAnimationAssetWidth = 'processingAnimationAssetWidth',
110
- processingAnimationAssetHeight = 'processingAnimationAssetHeight',
111
- selfieAnimationAssetName = 'selfieAnimationAssetName',
112
- selfieAnimationAssetWidth = 'selfieAnimationAssetWidth',
113
- selfieAnimationAssetHeight = 'selfieAnimationAssetHeight',
114
- }
115
-
116
- export type AndroidThemeObject = {
117
- [key in ANDROID_THEME_CONFIG_KEY]: string | null | undefined;
118
- };
119
-
120
- export type IosThemeObject = {
121
- [key in IOS_THEME_CONFIG_KEY]: string | null | undefined;
122
- };
123
-
124
- export type ThemeObject = AndroidThemeObject | IosThemeObject;
125
-
126
- class Theme {
127
- async print(platform: string = 'android') {
128
- const config = await Config.get();
129
- const themeConfig =
130
- platform === 'android' ? config.androidTheme : config.iosTheme;
131
- let usesCustomFontAndroid = false;
132
- let usesCustomFontIos = false;
133
-
134
- const head =
135
- platform === 'android'
136
- ? ['Style Item', 'Value', 'Note']
137
- : ['Style Item', 'Value', 'Note'];
138
-
139
- const table = new Table({
140
- head,
141
- // prettier-ignore
142
- chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
143
- });
144
-
145
- console.log('Specified theme values:');
146
- const keyEnum =
147
- platform === 'android' ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;
148
- for (const key in keyEnum) {
149
- let override =
150
- themeConfig[key as ANDROID_THEME_CONFIG_KEY | IOS_THEME_CONFIG_KEY];
151
- let colorOverride = key.includes('Color') || key.includes('color');
152
-
153
- if (override) {
154
- if (colorOverride) {
155
- override = normalizeColor(override, key);
156
- } else {
157
- override = override.toString();
158
- }
159
- }
160
-
161
- if (key.includes('Font')) {
162
- if (platform == 'android') {
163
- usesCustomFontAndroid = true;
164
- } else {
165
- usesCustomFontIos = true;
166
- }
167
- }
168
-
169
- let row;
170
-
171
- row = [
172
- key,
173
- override
174
- ? valueColor(colorOverride, override)
175
- : chalk.yellow('unspecified'),
176
- key.includes('Font')
177
- ? chalk.cyan('Fonts that are not built-in need to be installed.')
178
- : '',
179
- ];
180
-
181
- table.push(row);
182
- }
183
-
184
- console.log(table.toString());
185
-
186
- if (usesCustomFontAndroid) {
187
- console.log(
188
- chalk.yellow(' NOTE') +
189
- ': 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'
190
- );
191
- }
192
-
193
- if (usesCustomFontIos) {
194
- console.log(
195
- chalk.yellow(' NOTE') +
196
- ': 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'
197
- );
198
- }
199
-
200
- // Add newline for spacing
201
- console.log('');
202
- }
203
- }
204
-
205
- // set default print color for non-color overrides
206
- function valueColor(isColorOverride: boolean, override: string) {
207
- return isColorOverride
208
- ? chalk.hex(override)(override)
209
- : chalk.magentaBright(override);
210
- }
211
-
212
- function normalizeColor(colorHex: string, themeKey: string) {
213
- let hex = colorHex;
214
- if (colorHex[0] === '#') {
215
- hex = colorHex.slice(1);
216
- }
217
-
218
- if (!COLOR_REGEX.test(hex)) {
219
- if (themeKey) {
220
- console.error(
221
- `Received a color value of ${chalk.yellow(colorHex)} for ${chalk.red(
222
- themeKey
223
- )}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
224
- .bgHex('#FFFFFF')
225
- .hex('#7E66B7')('#290087')}`
226
- );
227
- } else {
228
- console.error(
229
- `Received a color value of ${chalk.yellow(
230
- colorHex
231
- )}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk
232
- .bgHex('#FFFFFF')
233
- .hex('#7E66B7')('#290087')}`
234
- );
235
- }
236
- console.log('');
237
- process.exit(1);
238
- }
239
-
240
- return colorHex;
241
- }
242
-
243
- export default new Theme();
@@ -1,30 +0,0 @@
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,36 +0,0 @@
1
- import inquirer, { QuestionCollection } from 'inquirer';
2
-
3
- export const TOOL_CHOICE = {
4
- AndroidTheme: 'Update Android theme',
5
- iosTheme: 'Update iOS theme',
6
- };
7
- export async function whatWouldYouLikePrompt() {
8
- const questions = {
9
- name: 'choice',
10
- type: 'list',
11
- choices: [TOOL_CHOICE.AndroidTheme, TOOL_CHOICE.iosTheme],
12
- message: 'What would you like to do?',
13
- } as QuestionCollection;
14
-
15
- return inquirer.prompt(questions);
16
- }
17
-
18
- export async function confirmThemeValues() {
19
- const questions = {
20
- name: 'isConfirmed',
21
- type: 'confirm',
22
- message: 'Do these values look right?',
23
- } as QuestionCollection;
24
-
25
- return inquirer.prompt(questions);
26
- }
27
-
28
- export async function confirmResourceFiles() {
29
- const questions = {
30
- name: 'isConfirmed',
31
- type: 'confirm',
32
- message: `Continue?`,
33
- } as QuestionCollection;
34
-
35
- return inquirer.prompt(questions);
36
- }
@@ -1,100 +0,0 @@
1
- import fs from 'fs';
2
- import chalk from 'chalk';
3
- import path from 'path';
4
-
5
- import Theme, { AndroidThemeObject } from '../Theme';
6
- import { confirmThemeValues, confirmResourceFiles } from '../prompts';
7
- import AndroidResourcePrinter from '../AndroidResourcePrinter';
8
- import Configuration from '../Config';
9
-
10
- const ANDROID_STYLES_RESOURCE_PATH =
11
- './android/app/src/main/res/values/styles_persona.xml';
12
- const ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH =
13
- './android/app/src/main/res/drawable/rn_persona_button.xml';
14
- const ANDROID_BUTTON_COLOR_RESOURCE_PATH =
15
- './android/app/src/main/res/color/rn_persona_button.xml';
16
-
17
- class ThemeGenerator {
18
- async run() {
19
- await Theme.print();
20
-
21
- const { isConfirmed: themeValuesConfirmed } = await confirmThemeValues();
22
-
23
- if (!themeValuesConfirmed) {
24
- console.log(
25
- chalk.yellow('\nPlease adjust the values in package.json.\n')
26
- );
27
- return;
28
- }
29
-
30
- console.log(
31
- `\n${chalk.yellow(
32
- 'Creating an Android Resource files for your project at:'
33
- )}\n
34
- - ${ANDROID_STYLES_RESOURCE_PATH}
35
- - ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}
36
- - ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}\n`
37
- );
38
- console.log(
39
- 'Building your application with this resource file themes your Persona Inquiry flow.\n'
40
- );
41
-
42
- const config = await Configuration.get();
43
- const theme = config.androidTheme as AndroidThemeObject;
44
-
45
- const { style, buttonDrawable, buttonColor } = new AndroidResourcePrinter(
46
- theme
47
- ).process();
48
-
49
- let { isConfirmed: confirmed } = await confirmResourceFiles();
50
-
51
- if (!confirmed) {
52
- process.exit(1);
53
- }
54
-
55
- // Add a line after confirmation
56
- console.log('');
57
-
58
- fs.mkdirSync(path.dirname(ANDROID_STYLES_RESOURCE_PATH), {
59
- recursive: true,
60
- });
61
- fs.writeFileSync(
62
- ANDROID_STYLES_RESOURCE_PATH,
63
- style.end({ prettyPrint: true })
64
- );
65
-
66
- console.log(
67
- `${chalk.green(
68
- 'Saved an Android style file at path:'
69
- )} ${ANDROID_STYLES_RESOURCE_PATH}.`
70
- );
71
-
72
- fs.mkdirSync(path.dirname(ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH), {
73
- recursive: true,
74
- });
75
- fs.writeFileSync(
76
- ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH,
77
- buttonDrawable.end({ prettyPrint: true })
78
- );
79
- console.log(
80
- `${chalk.green(
81
- 'Saved an Android drawable file at path:'
82
- )} ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}.`
83
- );
84
-
85
- fs.mkdirSync(path.dirname(ANDROID_BUTTON_COLOR_RESOURCE_PATH), {
86
- recursive: true,
87
- });
88
- fs.writeFileSync(
89
- ANDROID_BUTTON_COLOR_RESOURCE_PATH,
90
- buttonColor.end({ prettyPrint: true })
91
- );
92
- console.log(
93
- `${chalk.green(
94
- 'Saved an Android color file at path:'
95
- )} ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}.`
96
- );
97
- }
98
- }
99
-
100
- export default new ThemeGenerator();
@@ -1,41 +0,0 @@
1
- import Theme from '../Theme';
2
- import { confirmThemeValues } from '../prompts';
3
- import chalk from 'chalk';
4
-
5
- class IosThemeInstructions {
6
- async run() {
7
- await Theme.print('ios');
8
-
9
- const { isConfirmed: themeValuesConfirmed } = await confirmThemeValues();
10
-
11
- if (!themeValuesConfirmed) {
12
- console.log(
13
- chalk.yellow('\nPlease adjust the values in package.json.\n')
14
- );
15
- return;
16
- }
17
-
18
- console.log(
19
- `\n${chalk.yellow('To theme the Persona Inquiry flow for iOS:')}`
20
- );
21
- console.log(
22
- 'Add the theme values to the Persona Inquiry SDK client by using the `.iosTheme` builder function'
23
- );
24
-
25
- console.log(`
26
- ${chalk.green(`+ import { persona } from '../package.json'`)}
27
- ...
28
- Inquiry.fromTemplate(selectedTemplateId)
29
- .onSuccess(handleSuccess)
30
- .onCanceled(handleCanceled)
31
- .onFailed(handleFailed)
32
- .onError(handleError)
33
- ${chalk.green('+ .iosTheme(persona.iosTheme)')}
34
- .build()
35
- .start();
36
- ...
37
- `);
38
- }
39
- }
40
-
41
- export default new IosThemeInstructions();