@andre1502/react-utilities 0.9.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.
Files changed (186) hide show
  1. package/README.md +340 -0
  2. package/dist/Config/Config.d.ts +28 -0
  3. package/dist/Config/Config.js +200 -0
  4. package/dist/Config/Config.js.map +1 -0
  5. package/dist/Config/GoogleAuth.d.ts +15 -0
  6. package/dist/Config/GoogleAuth.js +71 -0
  7. package/dist/Config/GoogleAuth.js.map +1 -0
  8. package/dist/Config/Locales.d.ts +18 -0
  9. package/dist/Config/Locales.js +62 -0
  10. package/dist/Config/Locales.js.map +1 -0
  11. package/dist/Config/Output.d.ts +10 -0
  12. package/dist/Config/Output.js +28 -0
  13. package/dist/Config/Output.js.map +1 -0
  14. package/dist/Config/Sitemap.d.ts +13 -0
  15. package/dist/Config/Sitemap.js +73 -0
  16. package/dist/Config/Sitemap.js.map +1 -0
  17. package/dist/Format/NumberFormat.d.ts +6 -0
  18. package/dist/Format/NumberFormat.js +77 -0
  19. package/dist/Format/NumberFormat.js.map +1 -0
  20. package/dist/Format/NumberParser.d.ts +9 -0
  21. package/dist/Format/NumberParser.js +51 -0
  22. package/dist/Format/NumberParser.js.map +1 -0
  23. package/dist/React-BaJ1KfGF.js +87 -0
  24. package/dist/React-BaJ1KfGF.js.map +1 -0
  25. package/dist/React-qUl0CBmE.js +109 -0
  26. package/dist/React-qUl0CBmE.js.map +1 -0
  27. package/dist/ReactNative-CqUrY2ZJ.js +3856 -0
  28. package/dist/ReactNative-CqUrY2ZJ.js.map +1 -0
  29. package/dist/ReactNative-mNnws-b5.js +3834 -0
  30. package/dist/ReactNative-mNnws-b5.js.map +1 -0
  31. package/dist/Sentry/Build.d.ts +9 -0
  32. package/dist/Sentry/Build.js +88 -0
  33. package/dist/Sentry/Build.js.map +1 -0
  34. package/dist/Sentry/React.d.ts +18 -0
  35. package/dist/Sentry/React.js +104 -0
  36. package/dist/Sentry/React.js.map +1 -0
  37. package/dist/Sentry/ReactNative.d.ts +18 -0
  38. package/dist/Sentry/ReactNative.js +114 -0
  39. package/dist/Sentry/ReactNative.js.map +1 -0
  40. package/dist/Sentry/Utils.d.ts +2 -0
  41. package/dist/Sentry/Utils.js +24 -0
  42. package/dist/Sentry/Utils.js.map +1 -0
  43. package/dist/Utils/Files.d.ts +7 -0
  44. package/dist/Utils/Files.js +52 -0
  45. package/dist/Utils/Files.js.map +1 -0
  46. package/dist/Utils-Cq948gfa.js +20 -0
  47. package/dist/Utils-Cq948gfa.js.map +1 -0
  48. package/dist/Utils-Dilye04y.js +22 -0
  49. package/dist/Utils-Dilye04y.js.map +1 -0
  50. package/dist/config-cli.cjs +471 -0
  51. package/dist/config-cli.cjs.map +1 -0
  52. package/dist/config-cli.d.ts +34 -0
  53. package/dist/config-cli.js +220 -0
  54. package/dist/config-cli.js.map +1 -0
  55. package/dist/config-cli.mjs +443 -0
  56. package/dist/config-cli.mjs.map +1 -0
  57. package/dist/enums/CurrencySymbolEnum.d.ts +5 -0
  58. package/dist/enums/CurrencySymbolEnum.js +13 -0
  59. package/dist/enums/CurrencySymbolEnum.js.map +1 -0
  60. package/dist/format.cjs +122 -0
  61. package/dist/format.cjs.map +1 -0
  62. package/dist/format.d.ts +3 -0
  63. package/dist/format.js +55 -0
  64. package/dist/format.js.map +1 -0
  65. package/dist/format.mjs +117 -0
  66. package/dist/format.mjs.map +1 -0
  67. package/dist/index-cli.cjs +24 -0
  68. package/dist/index-cli.cjs.map +1 -0
  69. package/dist/index-cli.d.ts +2 -0
  70. package/dist/index-cli.js +28 -0
  71. package/dist/index-cli.js.map +1 -0
  72. package/dist/index-cli.mjs +12 -0
  73. package/dist/index-cli.mjs.map +1 -0
  74. package/dist/index-fmt.cjs +16 -0
  75. package/dist/index-fmt.cjs.map +1 -0
  76. package/dist/index-fmt.d.ts +1 -0
  77. package/dist/index-fmt.js +17 -0
  78. package/dist/index-fmt.js.map +1 -0
  79. package/dist/index-fmt.mjs +3 -0
  80. package/dist/index-fmt.mjs.map +1 -0
  81. package/dist/index-rn.cjs +21 -0
  82. package/dist/index-rn.cjs.map +1 -0
  83. package/dist/index-rn.d.ts +2 -0
  84. package/dist/index-rn.js +28 -0
  85. package/dist/index-rn.js.map +1 -0
  86. package/dist/index-rn.mjs +6 -0
  87. package/dist/index-rn.mjs.map +1 -0
  88. package/dist/index.cjs +21 -0
  89. package/dist/index.cjs.map +1 -0
  90. package/dist/index.d.ts +2 -0
  91. package/dist/index.js +28 -0
  92. package/dist/index.js.map +1 -0
  93. package/dist/index.mjs +6 -0
  94. package/dist/index.mjs.map +1 -0
  95. package/dist/interfaces/Config/ConfigOptions.d.ts +8 -0
  96. package/dist/interfaces/Config/ConfigOptions.js +6 -0
  97. package/dist/interfaces/Config/ConfigOptions.js.map +1 -0
  98. package/dist/interfaces/Config/OutputMap.d.ts +3 -0
  99. package/dist/interfaces/Config/OutputMap.js +6 -0
  100. package/dist/interfaces/Config/OutputMap.js.map +1 -0
  101. package/dist/interfaces/Config/OutputOptions.d.ts +7 -0
  102. package/dist/interfaces/Config/OutputOptions.js +6 -0
  103. package/dist/interfaces/Config/OutputOptions.js.map +1 -0
  104. package/dist/interfaces/Config/SitemapMap.d.ts +5 -0
  105. package/dist/interfaces/Config/SitemapMap.js +6 -0
  106. package/dist/interfaces/Config/SitemapMap.js.map +1 -0
  107. package/dist/interfaces/Config/StringMap.d.ts +3 -0
  108. package/dist/interfaces/Config/StringMap.js +6 -0
  109. package/dist/interfaces/Config/StringMap.js.map +1 -0
  110. package/dist/interfaces/Format/FormatOptions.d.ts +14 -0
  111. package/dist/interfaces/Format/FormatOptions.js +6 -0
  112. package/dist/interfaces/Format/FormatOptions.js.map +1 -0
  113. package/dist/interfaces/Sentry/InitOptions.d.ts +20 -0
  114. package/dist/interfaces/Sentry/InitOptions.js +6 -0
  115. package/dist/interfaces/Sentry/InitOptions.js.map +1 -0
  116. package/dist/interfaces/Sentry/InitOptionsRN.d.ts +4 -0
  117. package/dist/interfaces/Sentry/InitOptionsRN.js +6 -0
  118. package/dist/interfaces/Sentry/InitOptionsRN.js.map +1 -0
  119. package/dist/interfaces/Sentry/SourceMapOptions.d.ts +7 -0
  120. package/dist/interfaces/Sentry/SourceMapOptions.js +6 -0
  121. package/dist/interfaces/Sentry/SourceMapOptions.js.map +1 -0
  122. package/dist/sentry-cli.cjs +119 -0
  123. package/dist/sentry-cli.cjs.map +1 -0
  124. package/dist/sentry-cli.d.ts +9 -0
  125. package/dist/sentry-cli.js +50 -0
  126. package/dist/sentry-cli.js.map +1 -0
  127. package/dist/sentry-cli.mjs +98 -0
  128. package/dist/sentry-cli.mjs.map +1 -0
  129. package/dist/sentry-rn.cjs +11 -0
  130. package/dist/sentry-rn.cjs.map +1 -0
  131. package/dist/sentry-rn.d.ts +2 -0
  132. package/dist/sentry-rn.js +28 -0
  133. package/dist/sentry-rn.js.map +1 -0
  134. package/dist/sentry-rn.mjs +4 -0
  135. package/dist/sentry-rn.mjs.map +1 -0
  136. package/dist/sentry.cjs +11 -0
  137. package/dist/sentry.cjs.map +1 -0
  138. package/dist/sentry.d.ts +2 -0
  139. package/dist/sentry.js +28 -0
  140. package/dist/sentry.js.map +1 -0
  141. package/dist/sentry.mjs +4 -0
  142. package/dist/sentry.mjs.map +1 -0
  143. package/dist/types/Config/OptionType.d.ts +2 -0
  144. package/dist/types/Config/OptionType.js +6 -0
  145. package/dist/types/Config/OptionType.js.map +1 -0
  146. package/dist/types/Format/OptionType.d.ts +3 -0
  147. package/dist/types/Format/OptionType.js +6 -0
  148. package/dist/types/Format/OptionType.js.map +1 -0
  149. package/dist/types/Sentry/OptionType.d.ts +1 -0
  150. package/dist/types/Sentry/OptionType.js +6 -0
  151. package/dist/types/Sentry/OptionType.js.map +1 -0
  152. package/package.json +139 -0
  153. package/src/Config/Config.ts +258 -0
  154. package/src/Config/GoogleAuth.ts +54 -0
  155. package/src/Config/Locales.ts +72 -0
  156. package/src/Config/Output.ts +29 -0
  157. package/src/Config/Sitemap.ts +67 -0
  158. package/src/Format/NumberFormat.ts +96 -0
  159. package/src/Format/NumberParser.ts +42 -0
  160. package/src/Sentry/Build.ts +67 -0
  161. package/src/Sentry/React.ts +127 -0
  162. package/src/Sentry/ReactNative.ts +133 -0
  163. package/src/Sentry/Utils.ts +26 -0
  164. package/src/Utils/Files.ts +51 -0
  165. package/src/config-cli.ts +152 -0
  166. package/src/enums/CurrencySymbolEnum.ts +5 -0
  167. package/src/format.ts +39 -0
  168. package/src/index-cli.ts +2 -0
  169. package/src/index-fmt.ts +1 -0
  170. package/src/index-rn.ts +2 -0
  171. package/src/index.ts +2 -0
  172. package/src/interfaces/Config/ConfigOptions.ts +9 -0
  173. package/src/interfaces/Config/OutputMap.ts +3 -0
  174. package/src/interfaces/Config/OutputOptions.ts +8 -0
  175. package/src/interfaces/Config/SitemapMap.ts +5 -0
  176. package/src/interfaces/Config/StringMap.ts +3 -0
  177. package/src/interfaces/Format/FormatOptions.ts +19 -0
  178. package/src/interfaces/Sentry/InitOptions.ts +23 -0
  179. package/src/interfaces/Sentry/InitOptionsRN.ts +5 -0
  180. package/src/interfaces/Sentry/SourceMapOptions.ts +7 -0
  181. package/src/sentry-cli.ts +16 -0
  182. package/src/sentry-rn.ts +2 -0
  183. package/src/sentry.ts +2 -0
  184. package/src/types/Config/OptionType.ts +2 -0
  185. package/src/types/Format/OptionType.ts +15 -0
  186. package/src/types/Sentry/OptionType.ts +1 -0
package/README.md ADDED
@@ -0,0 +1,340 @@
1
+ # react-utilities
2
+
3
+ Library to combine common functions
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ yarn add @andre1502/react-utilities
9
+ ```
10
+
11
+ OR
12
+
13
+ ```sh
14
+ npm install @andre1502/react-utilities
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ## Config & Locales CLI
20
+
21
+ 1. Get Google service account credentials from https://console.cloud.google.com/apis/credentials.
22
+ 2. Add `GOOGLE_APPLICATION_CREDENTIALS` as system environment variable with value of Google service account file credentials location.
23
+
24
+ ### Fetch Locales
25
+
26
+ Filename will be auto defined by locales key (e.g. zh-TW, filename will be zh-tw.json).
27
+
28
+ ```js
29
+ const { fetchLocales } = require('@andre1502/react-utilities/cli');
30
+ // OR
31
+ const { fetchLocales } = require('@andre1502/react-utilities/config-cli');
32
+
33
+ https://docs.google.com/spreadsheets/d/<google-sheet-id>/edit
34
+ const optionLocales = {
35
+ spreadsheetId: '', // Google Sheet Id
36
+ spreadsheetTab: '', // Google Sheet Tab for locales
37
+ formatAs: 'locales',
38
+ output: {
39
+ folder: './src/locales', // locales folder location
40
+ isFilenameLowercase: true, // set if filename need to be lowercase
41
+ exportAs: 'ts', // export locales as 'ts' | 'json'
42
+ },
43
+ };
44
+
45
+ fetchLocales(optionLocales);
46
+ ```
47
+
48
+ ### Fetch Config
49
+
50
+ Config file only support export as js file, since you need to combine it with transform function.
51
+
52
+ ```js
53
+ const { fetchConfig } = require('@andre1502/@andre1502/react-utilities/cli');
54
+ // OR
55
+ const { fetchConfig } = require('@andre1502/@andre1502/react-utilities/config-cli');
56
+
57
+ https://docs.google.com/spreadsheets/d/<google-sheet-id>/edit
58
+ const optionConfig = {
59
+ spreadsheetId: '', // Google Sheet Id
60
+ spreadsheetTab: '', // Google Sheet Tab for config;
61
+ formatAs: 'config',
62
+ output: {
63
+ folder: '.', // config folder location
64
+ filename: 'versionConfig.js', // config filename
65
+ isFilenameLowercase: false, // set if filename need to be lowercase
66
+ },
67
+ };
68
+
69
+ fetchConfig(optionConfig);
70
+ ```
71
+
72
+ Config output example
73
+
74
+ ```js
75
+ module.exports = {
76
+ params: {
77
+ '<app-brand>': {
78
+ API_MAIN_URL: {
79
+ dev: '<api-dev>',
80
+ stag: '<api-staging>',
81
+ prod: '<api-production>',
82
+ },
83
+ },
84
+ },
85
+ };
86
+ ```
87
+
88
+ ### Fetch All
89
+
90
+ To fetch both locales and config.
91
+
92
+ ```js
93
+ const { fetchAll } = require('@andre1502/react-utilities/cli');
94
+ // OR
95
+ const { fetchAll } = require('@andre1502/react-utilities/config-cli');
96
+
97
+ https://docs.google.com/spreadsheets/d/<google-sheet-id>/edit
98
+ const spreadsheetId = ''; // Google Sheet Id
99
+ const spreadsheetLocalesTab = ''; // Google Sheet Tab for locales
100
+ const spreadsheetConfigTab = '' // Google Sheet Tab for config;
101
+
102
+ const optionLocales = {
103
+ spreadsheetId: spreadsheetId,
104
+ spreadsheetTab: spreadsheetLocalesTab,
105
+ formatAs: 'locales',
106
+ output: {
107
+ folder: './src/locales', // locales folder location
108
+ isFilenameLowercase: true, // set if filename need to be lowercase
109
+ exportAs: 'ts', // export locales as 'ts' | 'json'
110
+ },
111
+ };
112
+
113
+ const optionConfig = {
114
+ spreadsheetId: spreadsheetId,
115
+ spreadsheetTab: spreadsheetConfigTab,
116
+ formatAs: 'config',
117
+ output: {
118
+ folder: '.', // config folder location
119
+ filename: 'versionConfig.js', // config filename
120
+ isFilenameLowercase: false, // set if filename need to be lowercase
121
+ },
122
+ };
123
+
124
+ fetchAll([optionLocales, optionConfig]);
125
+ ```
126
+
127
+ ### Transform Config
128
+
129
+ ```js
130
+ const { transformConfig } = require('@andre1502/react-utilities/cli');
131
+ // OR
132
+ const { transformConfig } = require('@andre1502/react-utilities/config-cli');
133
+ const version = '<app-brand>';
134
+ const env = '<env-value>'; // support 'dev' | 'stag' | 'prod'
135
+
136
+ let { params } = require('./versionConfig');
137
+ const currentConfig = { ...params?.default, ...params[version] };
138
+
139
+ transformConfig(currentConfig, env, 'REACT_APP_', {
140
+ folder: '.', // transformed config folder location
141
+ filename: '.env', // transformed config filename
142
+ isFilenameLowercase: false, // set if filename need to be lowercase
143
+ exportAs: 'env', // export transformed config as 'ts' | 'js' | 'env'
144
+ });
145
+ ```
146
+
147
+ ### Transform Sitemap
148
+
149
+ ```js
150
+ const { transformSitemap } = require('@andre1502/react-utilities/cli');
151
+ // OR
152
+ const { transformSitemap } = require('@andre1502/react-utilities/config-cli');
153
+ const version = '<app-brand>';
154
+ const env = '<env-value>'; // support 'dev' | 'stag' | 'prod'
155
+
156
+ let { params } = require('./versionConfig');
157
+ const currentConfig = { ...params?.default, ...params[version] };
158
+ const hostname = currentConfig['MAIN_URL'][env];
159
+ const urls = currentConfig['SITEMAP'];
160
+
161
+ transformSitemap(hostname, urls, true, {
162
+ folder: './public', // transformed sitemap folder location
163
+ filename: 'sitemap.xml', // transformed sitemap filename
164
+ isFilenameLowercase: false, // set if filename need to be lowercase
165
+ });
166
+ ```
167
+
168
+ ## Sentry CLI
169
+
170
+ ### Release Sentry Source Map
171
+
172
+ Add `.sentryclirc` file in root project with these value
173
+
174
+ ```
175
+ [defaults]
176
+ url=https://<sentry_host_url>/
177
+ org=<organization>
178
+ project=<sentry_project_name>
179
+ ```
180
+
181
+ Update system environment variables with
182
+
183
+ ```sh
184
+ export SENTRY_AUTH_TOKEN=<sentry_auth_token>
185
+ ```
186
+
187
+ Add sentry file in root project with this code
188
+
189
+ ```js
190
+ const { releaseSentrySourceMap } = require('@andre1502/react-utilities/cli');
191
+ // OR
192
+ const { releaseSentrySourceMap } = require('@andre1502/react-utilities/sentry-cli');
193
+
194
+ releaseSentrySourceMap({
195
+ env: '',
196
+ release: '',
197
+ includeFolder: [''],
198
+ urlPrefix: '~',
199
+ requiredEnvForSourceMap: [''],
200
+ });
201
+ ```
202
+
203
+ ## Sentry
204
+
205
+ ### Init Sentry for React
206
+
207
+ ```js
208
+ import { initSentry } from '@andre1502/react-utilities';
209
+ // OR
210
+ import { initSentry } from '@andre1502/react-utilities/sentry';
211
+
212
+ initSentry({
213
+ env: '',
214
+ dsn: '',
215
+ debug: false,
216
+ release: '',
217
+ requiredEnvForSendToSentry: ['production'],
218
+ httpClientIntegrationOptions: {
219
+ failedRequestStatusCodes: [[400], [402, 499], [500, 599]],
220
+ failedRequestTargets: ['http://localhost'],
221
+ },
222
+ captureConsoleIntegrationOptions: {
223
+ levels: ['error'],
224
+ },
225
+ options: {
226
+ // other sentry options
227
+ // ...
228
+ integrations: [
229
+ // other sentry integrations
230
+ // ...
231
+ ],
232
+ },
233
+ });
234
+ ```
235
+
236
+ ### Init Sentry for React Native
237
+
238
+ ```js
239
+ import { initSentry } from '@andre1502/react-utilities';
240
+
241
+ initSentry({
242
+ env: '',
243
+ dsn: '',
244
+ debug: false,
245
+ requiredEnvForSendToSentry: ['production'],
246
+ httpClientIntegrationOptions: {
247
+ failedRequestStatusCodes: [[400], [402, 499], [500, 599]],
248
+ failedRequestTargets: ['http://localhost'],
249
+ },
250
+ captureConsoleIntegrationOptions: {
251
+ levels: ['error'],
252
+ },
253
+ options: {
254
+ // other sentry options
255
+ // ...
256
+ integrations: [
257
+ // other sentry integrations
258
+ // ...
259
+ ],
260
+ },
261
+ });
262
+ ```
263
+
264
+ ## Format Number
265
+
266
+ ### formatAccountNumber
267
+
268
+ ```js
269
+ import { formatAccountNumber } from '@andre1502/react-utilities';
270
+ // OR
271
+ import { formatAccountNumber } from '@andre1502/react-utilities/fmt';
272
+ // OR
273
+ import { formatAccountNumber } from '@andre1502/react-utilities/format';
274
+
275
+ const accountNumber = '1234567890123456';
276
+ const separator = ' ';
277
+ const result = formatAccountNumber(data, separator);
278
+
279
+ console.log(`result: ${result}`);
280
+ // output: 1234 5678 9012 3456
281
+ ```
282
+
283
+ ### formatNumber
284
+
285
+ ```js
286
+ import { formatNumber } from '@andre1502/react-utilities';
287
+ // OR
288
+ import { formatNumber } from '@andre1502/react-utilities/fmt';
289
+ // OR
290
+ import { formatNumber } from '@andre1502/react-utilities/format';
291
+
292
+ const result = formatNumber({
293
+ lang: 'zh-TW',
294
+ currency: 'TWD',
295
+ value: 1000,
296
+ showValue: true,
297
+ showCurrency: true,
298
+ });
299
+
300
+ console.log(`result: ${result}`);
301
+ // output showValue(true) showCurrency(true): 'NT$ 1,000'
302
+ // output showValue(true) showCurrency(false): '1,000'
303
+ // output showValue(false) showCurrency(true): 'NT$ ********'
304
+ // output showValue(false) showCurrency(false): '********'
305
+ ```
306
+
307
+ ### getCurrencySymbol
308
+
309
+ ```js
310
+ import { getCurrencySymbol } from '@andre1502/react-utilities';
311
+ // OR
312
+ import { getCurrencySymbol } from '@andre1502/react-utilities/fmt';
313
+ // OR
314
+ import { getCurrencySymbol } from '@andre1502/react-utilities/format';
315
+
316
+ const currency = 'TWD';
317
+ const showCurrency = true;
318
+ const result = getCurrencySymbol(currency, showCurrency);
319
+
320
+ console.log(`result: ${result}`);
321
+ // output showCurrency(true): 'NT$'
322
+ // output showCurrency(false): ''
323
+ ```
324
+
325
+ ### parseFormatNumber
326
+
327
+ ```js
328
+ import { parseFormatNumber } from '@andre1502/react-utilities';
329
+ // OR
330
+ import { parseFormatNumber } from '@andre1502/react-utilities/fmt';
331
+ // OR
332
+ import { parseFormatNumber } from '@andre1502/react-utilities/format';
333
+
334
+ const lang = 'zh-TW';
335
+ const value = '1,000';
336
+ const result = parseFormatNumber(lang, value);
337
+
338
+ console.log(`result: ${result}`);
339
+ // output: 1000
340
+ ```
@@ -0,0 +1,28 @@
1
+ import { OutputMap } from '../interfaces/Config/OutputMap';
2
+ import { OutputOptions } from '../interfaces/Config/OutputOptions';
3
+ /**
4
+ * Process config data
5
+ *
6
+ * @param {any[][]} rows
7
+ * @return {OutputMap}
8
+ */
9
+ declare const processConfig: (rows: any[][]) => OutputMap;
10
+ /**
11
+ * Export config data into js file
12
+ *
13
+ * @param {OutputMap} data
14
+ * @param {OutputOptions} options
15
+ * @return {void}
16
+ */
17
+ declare const exportConfig: (data: OutputMap, options: OutputOptions) => void;
18
+ /**
19
+ * Transform config
20
+ *
21
+ * @param {OutputMap} data
22
+ * @param {string} env
23
+ * @param {string} configKeyPrefix
24
+ * @param {OutputOptions} options
25
+ * @return {void}
26
+ */
27
+ declare const transformConfig: (data: OutputMap, env: string, configKeyPrefix: string, options: OutputOptions) => void;
28
+ export { exportConfig, processConfig, transformConfig };
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.transformConfig = exports.processConfig = exports.exportConfig = void 0;
7
+ var lodash = _interopRequireWildcard(require("lodash"));
8
+ var _Output = require("./Output");
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
11
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
+ /**
13
+ * Process config data
14
+ *
15
+ * @param {any[][]} rows
16
+ * @return {OutputMap}
17
+ */
18
+ var processConfig = exports.processConfig = function processConfig(rows) {
19
+ var versionConfig = {};
20
+ var params = rows[0].map(function (key) {
21
+ return key;
22
+ });
23
+ rows.forEach(function (row, index) {
24
+ if (index === 0) {
25
+ return;
26
+ }
27
+ versionConfig = processRow(row, params, versionConfig);
28
+ });
29
+ return versionConfig;
30
+ };
31
+
32
+ /**
33
+ * Process config item
34
+ *
35
+ * @param {string[]} data
36
+ * @param {string[]} params
37
+ * @param {OutputMap} versionConfig
38
+ * @return {OutputMap}
39
+ */
40
+ var processRow = function processRow(data, params, versionConfig) {
41
+ var versionName = data[0];
42
+ versionConfig[versionName] = {};
43
+ params.forEach(function (paramsName, index) {
44
+ if (index === 0 || data[index] === undefined || data[index] === '') {
45
+ return;
46
+ }
47
+ versionConfig[versionName][paramsName] = paramsTypeHandler(data[index]);
48
+ });
49
+ return versionConfig;
50
+ };
51
+
52
+ /**
53
+ * Check is JSON value
54
+ *
55
+ * @param {string} str
56
+ * @return {boolean}
57
+ */
58
+ var isJsonString = function isJsonString(str) {
59
+ try {
60
+ JSON.parse(str);
61
+ } catch (e) {
62
+ return false;
63
+ }
64
+ return true;
65
+ };
66
+
67
+ /**
68
+ * Handling config value type
69
+ *
70
+ * @param {string} params
71
+ * @return {any}
72
+ */
73
+ var paramsTypeHandler = function paramsTypeHandler(params) {
74
+ var booleanText = ['TRUE', 'FALSE'];
75
+ if (booleanText.includes(params.toUpperCase())) {
76
+ return params === 'TRUE';
77
+ }
78
+ if (isJsonString(params)) {
79
+ return JSON.parse(params);
80
+ }
81
+ return params;
82
+ };
83
+
84
+ /**
85
+ * Export config data into js file
86
+ *
87
+ * @param {OutputMap} data
88
+ * @param {OutputOptions} options
89
+ * @return {void}
90
+ */
91
+ var exportConfig = exports.exportConfig = function exportConfig(data, options) {
92
+ var config = {
93
+ params: data
94
+ };
95
+ var content = "module.exports = ".concat(JSON.stringify(config, null, 2));
96
+ (0, _Output.outputToFile)(content, options);
97
+ };
98
+
99
+ /**
100
+ * Handling env map value
101
+ *
102
+ * @param {string} env
103
+ * @return {string}
104
+ */
105
+ var envMap = function envMap(env) {
106
+ var result;
107
+ switch (env) {
108
+ case 'dev':
109
+ case 'develop':
110
+ case 'development':
111
+ result = 'dev';
112
+ break;
113
+ case 'stg':
114
+ case 'stag':
115
+ case 'staging':
116
+ result = 'staging';
117
+ break;
118
+ case 'prd':
119
+ case 'prod':
120
+ case 'production':
121
+ result = 'production';
122
+ break;
123
+ default:
124
+ throw new Error("env ".concat(env, " not supported."));
125
+ }
126
+ return result;
127
+ };
128
+
129
+ /**
130
+ * Mapping content to exportAs value
131
+ *
132
+ * @param {string} key
133
+ * @param {any} value
134
+ * @param {string} exportAs
135
+ * @return {string}
136
+ */
137
+ var contentMap = function contentMap(key, value, exportAs) {
138
+ var content = '';
139
+ switch (exportAs) {
140
+ case 'ts':
141
+ if (lodash.isNull(value)) {
142
+ content += "export const ".concat(key, ": string | null = ").concat(value, ";\n");
143
+ } else if (typeof value === 'boolean') {
144
+ content += "export const ".concat(key, ": boolean = ").concat(value, ";\n");
145
+ } else {
146
+ content += "export const ".concat(key, " = '").concat(value, "';\n");
147
+ }
148
+ break;
149
+ case 'js':
150
+ content += "export const ".concat(key, " = \"").concat(value, "\";\n");
151
+ break;
152
+ case 'env':
153
+ content += "".concat(key, " = \"").concat(value, "\"\n");
154
+ break;
155
+ default:
156
+ throw new Error("exportAs ".concat(exportAs, " not supported."));
157
+ }
158
+ return content;
159
+ };
160
+
161
+ /**
162
+ * Transform config
163
+ *
164
+ * @param {OutputMap} data
165
+ * @param {string} env
166
+ * @param {string} configKeyPrefix
167
+ * @param {OutputOptions} options
168
+ * @return {void}
169
+ */
170
+ var transformConfig = exports.transformConfig = function transformConfig(data, env, configKeyPrefix, options) {
171
+ var envKey = configKeyPrefix ? "".concat(configKeyPrefix, "ENV") : 'ENV';
172
+ var content = contentMap(envKey, envMap(env), options.exportAs);
173
+ Object.keys(data).forEach(function (key) {
174
+ var newConfigKey = configKeyPrefix ? "".concat(configKeyPrefix).concat(key) : key;
175
+ if (key === 'BASE_PROJECT') {
176
+ var extensionFile = [".".concat(data[key], ".js"), ".".concat(data[key], ".jsx"), ".".concat(data[key], ".ts"), ".".concat(data[key], ".tsx"), ".".concat(data[key], ".css"), ".".concat(data[key], ".json"), ".".concat(data[key], ".scss")];
177
+ content += contentMap(newConfigKey, extensionFile.join(','), options.exportAs);
178
+ return;
179
+ }
180
+ if (key === 'SITEMAP') {
181
+ content += contentMap(newConfigKey, JSON.stringify(data[key]), options.exportAs);
182
+ return;
183
+ }
184
+ if (Array.isArray(data[key])) {
185
+ content += contentMap(newConfigKey, data[key].join(','), options.exportAs);
186
+ return;
187
+ }
188
+ if (_typeof(data[key]) === 'object') {
189
+ if (data[key].hasOwnProperty(env)) {
190
+ content += contentMap(newConfigKey, data[key][env], options.exportAs);
191
+ } else {
192
+ content += contentMap(newConfigKey, JSON.stringify(data[key]), options.exportAs);
193
+ }
194
+ return;
195
+ }
196
+ content += contentMap(newConfigKey, data[key], options.exportAs);
197
+ });
198
+ (0, _Output.outputToFile)(content, options);
199
+ };
200
+ //# sourceMappingURL=Config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.js","names":["lodash","_interopRequireWildcard","require","_Output","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","o","Symbol","iterator","constructor","prototype","processConfig","exports","rows","versionConfig","params","map","key","forEach","row","index","processRow","data","versionName","paramsName","undefined","paramsTypeHandler","isJsonString","str","JSON","parse","booleanText","includes","toUpperCase","exportConfig","options","config","content","concat","stringify","outputToFile","envMap","env","result","Error","contentMap","value","exportAs","isNull","transformConfig","configKeyPrefix","envKey","keys","newConfigKey","extensionFile","join","Array","isArray"],"sources":["../../src/Config/Config.ts"],"sourcesContent":["import * as lodash from 'lodash';\nimport { OutputMap } from '../interfaces/Config/OutputMap';\nimport { OutputOptions } from '../interfaces/Config/OutputOptions';\nimport { outputToFile } from './Output';\n\n/**\n * Process config data\n *\n * @param {any[][]} rows\n * @return {OutputMap}\n */\nconst processConfig = (rows: any[][]): OutputMap => {\n let versionConfig: OutputMap = {};\n\n let params = rows[0].map((key) => {\n return key;\n });\n\n rows.forEach((row: string[], index: number) => {\n if (index === 0) {\n return;\n }\n\n versionConfig = processRow(row, params, versionConfig);\n });\n\n return versionConfig;\n};\n\n/**\n * Process config item\n *\n * @param {string[]} data\n * @param {string[]} params\n * @param {OutputMap} versionConfig\n * @return {OutputMap}\n */\nconst processRow = (\n data: string[],\n params: string[],\n versionConfig: OutputMap,\n): OutputMap => {\n const versionName = data[0];\n versionConfig[versionName] = {};\n\n params.forEach((paramsName, index) => {\n if (index === 0 || data[index] === undefined || data[index] === '') {\n return;\n }\n\n versionConfig[versionName][paramsName] = paramsTypeHandler(data[index]);\n });\n\n return versionConfig;\n};\n\n/**\n * Check is JSON value\n *\n * @param {string} str\n * @return {boolean}\n */\nconst isJsonString = (str: string): boolean => {\n try {\n JSON.parse(str);\n } catch (e) {\n return false;\n }\n\n return true;\n};\n\n/**\n * Handling config value type\n *\n * @param {string} params\n * @return {any}\n */\nconst paramsTypeHandler = (params: string): any => {\n const booleanText = ['TRUE', 'FALSE'];\n\n if (booleanText.includes(params.toUpperCase())) {\n return params === 'TRUE';\n }\n\n if (isJsonString(params)) {\n return JSON.parse(params);\n }\n\n return params;\n};\n\n/**\n * Export config data into js file\n *\n * @param {OutputMap} data\n * @param {OutputOptions} options\n * @return {void}\n */\nconst exportConfig = (data: OutputMap, options: OutputOptions): void => {\n const config = {\n params: data,\n };\n\n const content = `module.exports = ${JSON.stringify(config, null, 2)}`;\n\n outputToFile(content, options);\n};\n\n/**\n * Handling env map value\n *\n * @param {string} env\n * @return {string}\n */\nconst envMap = (env: string): string => {\n let result;\n\n switch (env) {\n case 'dev':\n case 'develop':\n case 'development':\n result = 'dev';\n break;\n case 'stg':\n case 'stag':\n case 'staging':\n result = 'staging';\n break;\n case 'prd':\n case 'prod':\n case 'production':\n result = 'production';\n break;\n default:\n throw new Error(`env ${env} not supported.`);\n }\n\n return result;\n};\n\n/**\n * Mapping content to exportAs value\n *\n * @param {string} key\n * @param {any} value\n * @param {string} exportAs\n * @return {string}\n */\nconst contentMap = (key: string, value: any, exportAs: string): string => {\n let content = '';\n\n switch (exportAs) {\n case 'ts':\n if (lodash.isNull(value)) {\n content += `export const ${key}: string | null = ${value};\\n`;\n } else if (typeof value === 'boolean') {\n content += `export const ${key}: boolean = ${value};\\n`;\n } else {\n content += `export const ${key} = '${value}';\\n`;\n }\n break;\n case 'js':\n content += `export const ${key} = \"${value}\";\\n`;\n break;\n case 'env':\n content += `${key} = \"${value}\"\\n`;\n break;\n default:\n throw new Error(`exportAs ${exportAs} not supported.`);\n }\n\n return content;\n};\n\n/**\n * Transform config\n *\n * @param {OutputMap} data\n * @param {string} env\n * @param {string} configKeyPrefix\n * @param {OutputOptions} options\n * @return {void}\n */\nconst transformConfig = (\n data: OutputMap,\n env: string,\n configKeyPrefix: string,\n options: OutputOptions,\n): void => {\n const envKey = configKeyPrefix ? `${configKeyPrefix}ENV` : 'ENV';\n\n let content = contentMap(envKey, envMap(env), options.exportAs!);\n\n Object.keys(data).forEach((key) => {\n const newConfigKey = configKeyPrefix ? `${configKeyPrefix}${key}` : key;\n\n if (key === 'BASE_PROJECT') {\n const extensionFile = [\n `.${data[key]}.js`,\n `.${data[key]}.jsx`,\n `.${data[key]}.ts`,\n `.${data[key]}.tsx`,\n `.${data[key]}.css`,\n `.${data[key]}.json`,\n `.${data[key]}.scss`,\n ];\n\n content += contentMap(\n newConfigKey,\n extensionFile.join(','),\n options.exportAs!,\n );\n\n return;\n }\n\n if (key === 'SITEMAP') {\n content += contentMap(\n newConfigKey,\n JSON.stringify(data[key]),\n options.exportAs!,\n );\n\n return;\n }\n\n if (Array.isArray(data[key])) {\n content += contentMap(\n newConfigKey,\n data[key].join(','),\n options.exportAs!,\n );\n\n return;\n }\n\n if (typeof data[key] === 'object') {\n if (data[key].hasOwnProperty(env)) {\n content += contentMap(newConfigKey, data[key][env], options.exportAs!);\n } else {\n content += contentMap(\n newConfigKey,\n JSON.stringify(data[key]),\n options.exportAs!,\n );\n }\n\n return;\n }\n\n content += contentMap(newConfigKey, data[key], options.exportAs!);\n });\n\n outputToFile(content, options);\n};\n\nexport { exportConfig, processConfig, transformConfig };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AAAwC,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAA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AA,CAAO8B,IAAI,CAACL,GAAG,CAAC,MAAK,QAAQ,EAAE;MACjC,IAAIK,IAAI,CAACL,GAAG,CAAC,CAACf,cAAc,CAACwC,GAAG,CAAC,EAAE;QACjCL,OAAO,IAAIQ,UAAU,CAACQ,YAAY,EAAE/B,IAAI,CAACL,GAAG,CAAC,CAACyB,GAAG,CAAC,EAAEP,OAAO,CAACY,QAAS,CAAC;MACxE,CAAC,MAAM;QACLV,OAAO,IAAIQ,UAAU,CACnBQ,YAAY,EACZxB,IAAI,CAACU,SAAS,CAACjB,IAAI,CAACL,GAAG,CAAC,CAAC,EACzBkB,OAAO,CAACY,QACV,CAAC;MACH;MAEA;IACF;IAEAV,OAAO,IAAIQ,UAAU,CAACQ,YAAY,EAAE/B,IAAI,CAACL,GAAG,CAAC,EAAEkB,OAAO,CAACY,QAAS,CAAC;EACnE,CAAC,CAAC;EAEF,IAAAP,oBAAY,EAACH,OAAO,EAAEF,OAAO,CAAC;AAChC,CAAC","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import { GoogleAuth } from 'google-auth-library';
2
+ import { JSONClient } from 'google-auth-library/build/src/auth/googleauth';
3
+ /**
4
+ * Authenticate using google console service account.
5
+ * @return {GoogleAuth<JSONClient>}
6
+ */
7
+ declare const authorizeServiceAccount: () => GoogleAuth<JSONClient>;
8
+ /**
9
+ * @param {GoogleAuth<JSONClient>} auth The authenticated Google OAuth client.
10
+ * @param {string} spreadsheetId
11
+ * @param {string} spreadsheetTab
12
+ * @return {Promise<any[][] | null | undefined>}
13
+ */
14
+ declare const fetchGoogleSheet: (auth: GoogleAuth<JSONClient>, spreadsheetId: string, spreadsheetTab: string) => Promise<any[][] | null | undefined>;
15
+ export { authorizeServiceAccount, fetchGoogleSheet };