@andre1502/react-utilities 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +340 -0
- package/dist/Config/Config.d.ts +28 -0
- package/dist/Config/Config.js +200 -0
- package/dist/Config/Config.js.map +1 -0
- package/dist/Config/GoogleAuth.d.ts +15 -0
- package/dist/Config/GoogleAuth.js +71 -0
- package/dist/Config/GoogleAuth.js.map +1 -0
- package/dist/Config/Locales.d.ts +18 -0
- package/dist/Config/Locales.js +62 -0
- package/dist/Config/Locales.js.map +1 -0
- package/dist/Config/Output.d.ts +10 -0
- package/dist/Config/Output.js +28 -0
- package/dist/Config/Output.js.map +1 -0
- package/dist/Config/Sitemap.d.ts +13 -0
- package/dist/Config/Sitemap.js +73 -0
- package/dist/Config/Sitemap.js.map +1 -0
- package/dist/Format/NumberFormat.d.ts +6 -0
- package/dist/Format/NumberFormat.js +77 -0
- package/dist/Format/NumberFormat.js.map +1 -0
- package/dist/Format/NumberParser.d.ts +9 -0
- package/dist/Format/NumberParser.js +51 -0
- package/dist/Format/NumberParser.js.map +1 -0
- package/dist/React-BaJ1KfGF.js +87 -0
- package/dist/React-BaJ1KfGF.js.map +1 -0
- package/dist/React-qUl0CBmE.js +109 -0
- package/dist/React-qUl0CBmE.js.map +1 -0
- package/dist/ReactNative-CqUrY2ZJ.js +3856 -0
- package/dist/ReactNative-CqUrY2ZJ.js.map +1 -0
- package/dist/ReactNative-mNnws-b5.js +3834 -0
- package/dist/ReactNative-mNnws-b5.js.map +1 -0
- package/dist/Sentry/Build.d.ts +9 -0
- package/dist/Sentry/Build.js +88 -0
- package/dist/Sentry/Build.js.map +1 -0
- package/dist/Sentry/React.d.ts +18 -0
- package/dist/Sentry/React.js +104 -0
- package/dist/Sentry/React.js.map +1 -0
- package/dist/Sentry/ReactNative.d.ts +18 -0
- package/dist/Sentry/ReactNative.js +114 -0
- package/dist/Sentry/ReactNative.js.map +1 -0
- package/dist/Sentry/Utils.d.ts +2 -0
- package/dist/Sentry/Utils.js +24 -0
- package/dist/Sentry/Utils.js.map +1 -0
- package/dist/Utils/Files.d.ts +7 -0
- package/dist/Utils/Files.js +52 -0
- package/dist/Utils/Files.js.map +1 -0
- package/dist/Utils-Cq948gfa.js +20 -0
- package/dist/Utils-Cq948gfa.js.map +1 -0
- package/dist/Utils-Dilye04y.js +22 -0
- package/dist/Utils-Dilye04y.js.map +1 -0
- package/dist/config-cli.cjs +471 -0
- package/dist/config-cli.cjs.map +1 -0
- package/dist/config-cli.d.ts +34 -0
- package/dist/config-cli.js +220 -0
- package/dist/config-cli.js.map +1 -0
- package/dist/config-cli.mjs +443 -0
- package/dist/config-cli.mjs.map +1 -0
- package/dist/enums/CurrencySymbolEnum.d.ts +5 -0
- package/dist/enums/CurrencySymbolEnum.js +13 -0
- package/dist/enums/CurrencySymbolEnum.js.map +1 -0
- package/dist/format.cjs +122 -0
- package/dist/format.cjs.map +1 -0
- package/dist/format.d.ts +3 -0
- package/dist/format.js +55 -0
- package/dist/format.js.map +1 -0
- package/dist/format.mjs +117 -0
- package/dist/format.mjs.map +1 -0
- package/dist/index-cli.cjs +24 -0
- package/dist/index-cli.cjs.map +1 -0
- package/dist/index-cli.d.ts +2 -0
- package/dist/index-cli.js +28 -0
- package/dist/index-cli.js.map +1 -0
- package/dist/index-cli.mjs +12 -0
- package/dist/index-cli.mjs.map +1 -0
- package/dist/index-fmt.cjs +16 -0
- package/dist/index-fmt.cjs.map +1 -0
- package/dist/index-fmt.d.ts +1 -0
- package/dist/index-fmt.js +17 -0
- package/dist/index-fmt.js.map +1 -0
- package/dist/index-fmt.mjs +3 -0
- package/dist/index-fmt.mjs.map +1 -0
- package/dist/index-rn.cjs +21 -0
- package/dist/index-rn.cjs.map +1 -0
- package/dist/index-rn.d.ts +2 -0
- package/dist/index-rn.js +28 -0
- package/dist/index-rn.js.map +1 -0
- package/dist/index-rn.mjs +6 -0
- package/dist/index-rn.mjs.map +1 -0
- package/dist/index.cjs +21 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/interfaces/Config/ConfigOptions.d.ts +8 -0
- package/dist/interfaces/Config/ConfigOptions.js +6 -0
- package/dist/interfaces/Config/ConfigOptions.js.map +1 -0
- package/dist/interfaces/Config/OutputMap.d.ts +3 -0
- package/dist/interfaces/Config/OutputMap.js +6 -0
- package/dist/interfaces/Config/OutputMap.js.map +1 -0
- package/dist/interfaces/Config/OutputOptions.d.ts +7 -0
- package/dist/interfaces/Config/OutputOptions.js +6 -0
- package/dist/interfaces/Config/OutputOptions.js.map +1 -0
- package/dist/interfaces/Config/SitemapMap.d.ts +5 -0
- package/dist/interfaces/Config/SitemapMap.js +6 -0
- package/dist/interfaces/Config/SitemapMap.js.map +1 -0
- package/dist/interfaces/Config/StringMap.d.ts +3 -0
- package/dist/interfaces/Config/StringMap.js +6 -0
- package/dist/interfaces/Config/StringMap.js.map +1 -0
- package/dist/interfaces/Format/FormatOptions.d.ts +14 -0
- package/dist/interfaces/Format/FormatOptions.js +6 -0
- package/dist/interfaces/Format/FormatOptions.js.map +1 -0
- package/dist/interfaces/Sentry/InitOptions.d.ts +20 -0
- package/dist/interfaces/Sentry/InitOptions.js +6 -0
- package/dist/interfaces/Sentry/InitOptions.js.map +1 -0
- package/dist/interfaces/Sentry/InitOptionsRN.d.ts +4 -0
- package/dist/interfaces/Sentry/InitOptionsRN.js +6 -0
- package/dist/interfaces/Sentry/InitOptionsRN.js.map +1 -0
- package/dist/interfaces/Sentry/SourceMapOptions.d.ts +7 -0
- package/dist/interfaces/Sentry/SourceMapOptions.js +6 -0
- package/dist/interfaces/Sentry/SourceMapOptions.js.map +1 -0
- package/dist/sentry-cli.cjs +119 -0
- package/dist/sentry-cli.cjs.map +1 -0
- package/dist/sentry-cli.d.ts +9 -0
- package/dist/sentry-cli.js +50 -0
- package/dist/sentry-cli.js.map +1 -0
- package/dist/sentry-cli.mjs +98 -0
- package/dist/sentry-cli.mjs.map +1 -0
- package/dist/sentry-rn.cjs +11 -0
- package/dist/sentry-rn.cjs.map +1 -0
- package/dist/sentry-rn.d.ts +2 -0
- package/dist/sentry-rn.js +28 -0
- package/dist/sentry-rn.js.map +1 -0
- package/dist/sentry-rn.mjs +4 -0
- package/dist/sentry-rn.mjs.map +1 -0
- package/dist/sentry.cjs +11 -0
- package/dist/sentry.cjs.map +1 -0
- package/dist/sentry.d.ts +2 -0
- package/dist/sentry.js +28 -0
- package/dist/sentry.js.map +1 -0
- package/dist/sentry.mjs +4 -0
- package/dist/sentry.mjs.map +1 -0
- package/dist/types/Config/OptionType.d.ts +2 -0
- package/dist/types/Config/OptionType.js +6 -0
- package/dist/types/Config/OptionType.js.map +1 -0
- package/dist/types/Format/OptionType.d.ts +3 -0
- package/dist/types/Format/OptionType.js +6 -0
- package/dist/types/Format/OptionType.js.map +1 -0
- package/dist/types/Sentry/OptionType.d.ts +1 -0
- package/dist/types/Sentry/OptionType.js +6 -0
- package/dist/types/Sentry/OptionType.js.map +1 -0
- package/package.json +139 -0
- package/src/Config/Config.ts +258 -0
- package/src/Config/GoogleAuth.ts +54 -0
- package/src/Config/Locales.ts +72 -0
- package/src/Config/Output.ts +29 -0
- package/src/Config/Sitemap.ts +67 -0
- package/src/Format/NumberFormat.ts +96 -0
- package/src/Format/NumberParser.ts +42 -0
- package/src/Sentry/Build.ts +67 -0
- package/src/Sentry/React.ts +127 -0
- package/src/Sentry/ReactNative.ts +133 -0
- package/src/Sentry/Utils.ts +26 -0
- package/src/Utils/Files.ts +51 -0
- package/src/config-cli.ts +152 -0
- package/src/enums/CurrencySymbolEnum.ts +5 -0
- package/src/format.ts +39 -0
- package/src/index-cli.ts +2 -0
- package/src/index-fmt.ts +1 -0
- package/src/index-rn.ts +2 -0
- package/src/index.ts +2 -0
- package/src/interfaces/Config/ConfigOptions.ts +9 -0
- package/src/interfaces/Config/OutputMap.ts +3 -0
- package/src/interfaces/Config/OutputOptions.ts +8 -0
- package/src/interfaces/Config/SitemapMap.ts +5 -0
- package/src/interfaces/Config/StringMap.ts +3 -0
- package/src/interfaces/Format/FormatOptions.ts +19 -0
- package/src/interfaces/Sentry/InitOptions.ts +23 -0
- package/src/interfaces/Sentry/InitOptionsRN.ts +5 -0
- package/src/interfaces/Sentry/SourceMapOptions.ts +7 -0
- package/src/sentry-cli.ts +16 -0
- package/src/sentry-rn.ts +2 -0
- package/src/sentry.ts +2 -0
- package/src/types/Config/OptionType.ts +2 -0
- package/src/types/Format/OptionType.ts +15 -0
- package/src/types/Sentry/OptionType.ts +1 -0
@@ -0,0 +1,443 @@
|
|
1
|
+
import * as lodash from 'lodash';
|
2
|
+
import { writeFile, existsSync } from 'fs';
|
3
|
+
import { GoogleAuth } from 'google-auth-library';
|
4
|
+
import { google } from 'googleapis';
|
5
|
+
import * as path from 'path';
|
6
|
+
import * as process from 'process';
|
7
|
+
import { SitemapStream, streamToPromise } from 'sitemap';
|
8
|
+
import { Readable } from 'stream';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Write content into target file
|
12
|
+
*
|
13
|
+
* @param {string} content
|
14
|
+
* @param {OutputOptions} options
|
15
|
+
* @return {void}
|
16
|
+
*/
|
17
|
+
const outputToFile = (content, options) => {
|
18
|
+
let filename = options.filename;
|
19
|
+
if (options.isFilenameLowercase) {
|
20
|
+
filename = filename.toLowerCase();
|
21
|
+
}
|
22
|
+
const filePath = `${options.folder}/${filename}`;
|
23
|
+
writeFile(filePath, content, 'utf8', function (err) {
|
24
|
+
if (err) {
|
25
|
+
throw err;
|
26
|
+
}
|
27
|
+
console.log(filePath, content);
|
28
|
+
});
|
29
|
+
};
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Process config data
|
33
|
+
*
|
34
|
+
* @param {any[][]} rows
|
35
|
+
* @return {OutputMap}
|
36
|
+
*/
|
37
|
+
const processConfig = rows => {
|
38
|
+
let versionConfig = {};
|
39
|
+
let params = rows[0].map(key => {
|
40
|
+
return key;
|
41
|
+
});
|
42
|
+
rows.forEach((row, index) => {
|
43
|
+
if (index === 0) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
versionConfig = processRow(row, params, versionConfig);
|
47
|
+
});
|
48
|
+
return versionConfig;
|
49
|
+
};
|
50
|
+
/**
|
51
|
+
* Process config item
|
52
|
+
*
|
53
|
+
* @param {string[]} data
|
54
|
+
* @param {string[]} params
|
55
|
+
* @param {OutputMap} versionConfig
|
56
|
+
* @return {OutputMap}
|
57
|
+
*/
|
58
|
+
const processRow = (data, params, versionConfig) => {
|
59
|
+
const versionName = data[0];
|
60
|
+
versionConfig[versionName] = {};
|
61
|
+
params.forEach((paramsName, index) => {
|
62
|
+
if (index === 0 || data[index] === undefined || data[index] === '') {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
versionConfig[versionName][paramsName] = paramsTypeHandler(data[index]);
|
66
|
+
});
|
67
|
+
return versionConfig;
|
68
|
+
};
|
69
|
+
/**
|
70
|
+
* Check is JSON value
|
71
|
+
*
|
72
|
+
* @param {string} str
|
73
|
+
* @return {boolean}
|
74
|
+
*/
|
75
|
+
const isJsonString = str => {
|
76
|
+
try {
|
77
|
+
JSON.parse(str);
|
78
|
+
} catch (e) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
return true;
|
82
|
+
};
|
83
|
+
/**
|
84
|
+
* Handling config value type
|
85
|
+
*
|
86
|
+
* @param {string} params
|
87
|
+
* @return {any}
|
88
|
+
*/
|
89
|
+
const paramsTypeHandler = params => {
|
90
|
+
const booleanText = ['TRUE', 'FALSE'];
|
91
|
+
if (booleanText.includes(params.toUpperCase())) {
|
92
|
+
return params === 'TRUE';
|
93
|
+
}
|
94
|
+
if (isJsonString(params)) {
|
95
|
+
return JSON.parse(params);
|
96
|
+
}
|
97
|
+
return params;
|
98
|
+
};
|
99
|
+
/**
|
100
|
+
* Export config data into js file
|
101
|
+
*
|
102
|
+
* @param {OutputMap} data
|
103
|
+
* @param {OutputOptions} options
|
104
|
+
* @return {void}
|
105
|
+
*/
|
106
|
+
const exportConfig = (data, options) => {
|
107
|
+
const config = {
|
108
|
+
params: data
|
109
|
+
};
|
110
|
+
const content = `module.exports = ${JSON.stringify(config, null, 2)}`;
|
111
|
+
outputToFile(content, options);
|
112
|
+
};
|
113
|
+
/**
|
114
|
+
* Handling env map value
|
115
|
+
*
|
116
|
+
* @param {string} env
|
117
|
+
* @return {string}
|
118
|
+
*/
|
119
|
+
const envMap = env => {
|
120
|
+
let result;
|
121
|
+
switch (env) {
|
122
|
+
case 'dev':
|
123
|
+
case 'develop':
|
124
|
+
case 'development':
|
125
|
+
result = 'dev';
|
126
|
+
break;
|
127
|
+
case 'stg':
|
128
|
+
case 'stag':
|
129
|
+
case 'staging':
|
130
|
+
result = 'staging';
|
131
|
+
break;
|
132
|
+
case 'prd':
|
133
|
+
case 'prod':
|
134
|
+
case 'production':
|
135
|
+
result = 'production';
|
136
|
+
break;
|
137
|
+
default:
|
138
|
+
throw new Error(`env ${env} not supported.`);
|
139
|
+
}
|
140
|
+
return result;
|
141
|
+
};
|
142
|
+
/**
|
143
|
+
* Mapping content to exportAs value
|
144
|
+
*
|
145
|
+
* @param {string} key
|
146
|
+
* @param {any} value
|
147
|
+
* @param {string} exportAs
|
148
|
+
* @return {string}
|
149
|
+
*/
|
150
|
+
const contentMap = (key, value, exportAs) => {
|
151
|
+
let content = '';
|
152
|
+
switch (exportAs) {
|
153
|
+
case 'ts':
|
154
|
+
if (lodash.isNull(value)) {
|
155
|
+
content += `export const ${key}: string | null = ${value};\n`;
|
156
|
+
} else if (typeof value === 'boolean') {
|
157
|
+
content += `export const ${key}: boolean = ${value};\n`;
|
158
|
+
} else {
|
159
|
+
content += `export const ${key} = '${value}';\n`;
|
160
|
+
}
|
161
|
+
break;
|
162
|
+
case 'js':
|
163
|
+
content += `export const ${key} = "${value}";\n`;
|
164
|
+
break;
|
165
|
+
case 'env':
|
166
|
+
content += `${key} = "${value}"\n`;
|
167
|
+
break;
|
168
|
+
default:
|
169
|
+
throw new Error(`exportAs ${exportAs} not supported.`);
|
170
|
+
}
|
171
|
+
return content;
|
172
|
+
};
|
173
|
+
/**
|
174
|
+
* Transform config
|
175
|
+
*
|
176
|
+
* @param {OutputMap} data
|
177
|
+
* @param {string} env
|
178
|
+
* @param {string} configKeyPrefix
|
179
|
+
* @param {OutputOptions} options
|
180
|
+
* @return {void}
|
181
|
+
*/
|
182
|
+
const transformConfig = (data, env, configKeyPrefix, options) => {
|
183
|
+
const envKey = configKeyPrefix ? `${configKeyPrefix}ENV` : 'ENV';
|
184
|
+
let content = contentMap(envKey, envMap(env), options.exportAs);
|
185
|
+
Object.keys(data).forEach(key => {
|
186
|
+
const newConfigKey = configKeyPrefix ? `${configKeyPrefix}${key}` : key;
|
187
|
+
if (key === 'BASE_PROJECT') {
|
188
|
+
const extensionFile = [`.${data[key]}.js`, `.${data[key]}.jsx`, `.${data[key]}.ts`, `.${data[key]}.tsx`, `.${data[key]}.css`, `.${data[key]}.json`, `.${data[key]}.scss`];
|
189
|
+
content += contentMap(newConfigKey, extensionFile.join(','), options.exportAs);
|
190
|
+
return;
|
191
|
+
}
|
192
|
+
if (key === 'SITEMAP') {
|
193
|
+
content += contentMap(newConfigKey, JSON.stringify(data[key]), options.exportAs);
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
if (Array.isArray(data[key])) {
|
197
|
+
content += contentMap(newConfigKey, data[key].join(','), options.exportAs);
|
198
|
+
return;
|
199
|
+
}
|
200
|
+
if (typeof data[key] === 'object') {
|
201
|
+
if (data[key].hasOwnProperty(env)) {
|
202
|
+
content += contentMap(newConfigKey, data[key][env], options.exportAs);
|
203
|
+
} else {
|
204
|
+
content += contentMap(newConfigKey, JSON.stringify(data[key]), options.exportAs);
|
205
|
+
}
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
content += contentMap(newConfigKey, data[key], options.exportAs);
|
209
|
+
});
|
210
|
+
outputToFile(content, options);
|
211
|
+
};
|
212
|
+
|
213
|
+
const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly'];
|
214
|
+
const GOOGLE_APPLICATION_CREDENTIALS_PATH = path.join(process.cwd(), '/google_application_credentials.json');
|
215
|
+
/**
|
216
|
+
* Authenticate using google console service account.
|
217
|
+
* @return {GoogleAuth<JSONClient>}
|
218
|
+
*/
|
219
|
+
const authorizeServiceAccount = () => {
|
220
|
+
const isExist = existsSync(GOOGLE_APPLICATION_CREDENTIALS_PATH);
|
221
|
+
const options = {
|
222
|
+
scopes: SCOPES
|
223
|
+
};
|
224
|
+
if (isExist) {
|
225
|
+
options.keyFile = GOOGLE_APPLICATION_CREDENTIALS_PATH;
|
226
|
+
}
|
227
|
+
return new GoogleAuth(options);
|
228
|
+
};
|
229
|
+
/**
|
230
|
+
* @param {GoogleAuth<JSONClient>} auth The authenticated Google OAuth client.
|
231
|
+
* @param {string} spreadsheetId
|
232
|
+
* @param {string} spreadsheetTab
|
233
|
+
* @return {Promise<any[][] | null | undefined>}
|
234
|
+
*/
|
235
|
+
const fetchGoogleSheet = async (auth, spreadsheetId, spreadsheetTab) => {
|
236
|
+
const sheets = google.sheets({
|
237
|
+
version: 'v4',
|
238
|
+
auth
|
239
|
+
});
|
240
|
+
const res = await sheets.spreadsheets.values.get({
|
241
|
+
spreadsheetId: spreadsheetId,
|
242
|
+
range: spreadsheetTab,
|
243
|
+
majorDimension: 'COLUMNS'
|
244
|
+
});
|
245
|
+
return res.data.values;
|
246
|
+
};
|
247
|
+
|
248
|
+
/**
|
249
|
+
* Process locales data
|
250
|
+
*
|
251
|
+
* @param {any[][]} rows
|
252
|
+
* @return {OutputMap}
|
253
|
+
*/
|
254
|
+
const processLocales = rows => {
|
255
|
+
let keys = rows[0].map(key => {
|
256
|
+
return key;
|
257
|
+
});
|
258
|
+
let data = {};
|
259
|
+
rows.forEach((lang, index) => {
|
260
|
+
if (index === 0) {
|
261
|
+
return;
|
262
|
+
}
|
263
|
+
let langData = {};
|
264
|
+
lang.forEach((data, dIndex) => {
|
265
|
+
if (dIndex === 0) {
|
266
|
+
return;
|
267
|
+
}
|
268
|
+
langData[keys[dIndex]] = data;
|
269
|
+
});
|
270
|
+
data[lang[0]] = langData;
|
271
|
+
});
|
272
|
+
return data;
|
273
|
+
};
|
274
|
+
/**
|
275
|
+
* Export locales data to file
|
276
|
+
*
|
277
|
+
* @param {OutputMap} data
|
278
|
+
* @param {OutputOptions} options
|
279
|
+
* @return {void}
|
280
|
+
*/
|
281
|
+
const exportLocales = (data, options) => {
|
282
|
+
Object.keys(data).forEach(key => {
|
283
|
+
options.filename = `${key}.${options.exportAs.toLowerCase()}`;
|
284
|
+
let content = '';
|
285
|
+
switch (options.exportAs) {
|
286
|
+
case 'ts':
|
287
|
+
content = 'export default ' + JSON.stringify(data[key], null, 2);
|
288
|
+
break;
|
289
|
+
case 'json':
|
290
|
+
content = JSON.stringify(data[key], null, 2);
|
291
|
+
break;
|
292
|
+
default:
|
293
|
+
throw new Error(`exportAs ${options.exportAs} not supported.`);
|
294
|
+
}
|
295
|
+
if (!content) {
|
296
|
+
throw new Error(`empty content, please check remote value.`);
|
297
|
+
}
|
298
|
+
outputToFile(content, options);
|
299
|
+
});
|
300
|
+
};
|
301
|
+
|
302
|
+
/**
|
303
|
+
* Generate Sitemap Robots
|
304
|
+
*
|
305
|
+
* @param {string} hostname
|
306
|
+
* @param {OutputOptions} options
|
307
|
+
* @return {void}
|
308
|
+
*/
|
309
|
+
const generateRobots = (hostname, options) => {
|
310
|
+
let content = ['# https://www.robotstxt.org/robotstxt.html', `Sitemap: ${hostname}/${options.filename}`, 'User-agent: *', 'Disallow:'];
|
311
|
+
options.filename = 'robots.txt';
|
312
|
+
outputToFile(content.join('\r\n'), options);
|
313
|
+
};
|
314
|
+
/**
|
315
|
+
* Transform Sitemap
|
316
|
+
*
|
317
|
+
* @param {string} hostname
|
318
|
+
* @param {SitemapMap[]} urls
|
319
|
+
* @param {boolean} includeRobots
|
320
|
+
* @param {OutputOptions} options
|
321
|
+
* @return {Promise<void>}
|
322
|
+
*/
|
323
|
+
const transformSitemap = async (hostname, urls, includeRobots, options) => {
|
324
|
+
const stream = new SitemapStream({
|
325
|
+
hostname: hostname,
|
326
|
+
lastmodDateOnly: false,
|
327
|
+
xmlns: {
|
328
|
+
news: false,
|
329
|
+
xhtml: false,
|
330
|
+
image: false,
|
331
|
+
video: false,
|
332
|
+
custom: ['xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"']
|
333
|
+
}
|
334
|
+
});
|
335
|
+
const content = await streamToPromise(Readable.from(urls).pipe(stream)).then(data => data.toString());
|
336
|
+
outputToFile(content, options);
|
337
|
+
if (includeRobots) {
|
338
|
+
generateRobots(hostname, options);
|
339
|
+
}
|
340
|
+
};
|
341
|
+
|
342
|
+
/**
|
343
|
+
* Private function to fetch locales
|
344
|
+
*
|
345
|
+
* @param {GoogleAuth<JSONClient>} auth
|
346
|
+
* @param {ConfigOption} options
|
347
|
+
* @return {Promise<void>}
|
348
|
+
*/
|
349
|
+
const innerFetchLocales = async (auth, options) => {
|
350
|
+
// console.log('auth', auth);
|
351
|
+
const values = await fetchGoogleSheet(auth, options.spreadsheetId, options.spreadsheetTab);
|
352
|
+
if (!values || values.length === 0) {
|
353
|
+
console.log('No data found.');
|
354
|
+
return;
|
355
|
+
}
|
356
|
+
// console.log('values,', values);
|
357
|
+
const data = processLocales(values);
|
358
|
+
exportLocales(data, options.output);
|
359
|
+
};
|
360
|
+
/**
|
361
|
+
* Private function to fetch config
|
362
|
+
*
|
363
|
+
* @param {GoogleAuth<JSONClient>} auth
|
364
|
+
* @param {ConfigOption} options
|
365
|
+
* @return {Promise<void>}
|
366
|
+
*/
|
367
|
+
const innerFetchConfig = async (auth, options) => {
|
368
|
+
// console.log('auth', auth);
|
369
|
+
const values = await fetchGoogleSheet(auth, options.spreadsheetId, options.spreadsheetTab);
|
370
|
+
if (!values || values.length === 0) {
|
371
|
+
console.log('No data found.');
|
372
|
+
return;
|
373
|
+
}
|
374
|
+
// console.log('values,', values);
|
375
|
+
const data = processConfig(values);
|
376
|
+
exportConfig(data, options.output);
|
377
|
+
};
|
378
|
+
/**
|
379
|
+
* Fetch locales
|
380
|
+
*
|
381
|
+
* @param {ConfigOptions} options
|
382
|
+
* @return {void}
|
383
|
+
*/
|
384
|
+
const fetchLocales = options => {
|
385
|
+
try {
|
386
|
+
const auth = authorizeServiceAccount();
|
387
|
+
innerFetchLocales(auth, options);
|
388
|
+
} catch (error) {
|
389
|
+
console.error(error);
|
390
|
+
}
|
391
|
+
};
|
392
|
+
/**
|
393
|
+
* Fetch config
|
394
|
+
*
|
395
|
+
* @param {ConfigOptions} options
|
396
|
+
* @return {void}
|
397
|
+
*/
|
398
|
+
const fetchConfig = options => {
|
399
|
+
try {
|
400
|
+
const auth = authorizeServiceAccount();
|
401
|
+
innerFetchConfig(auth, options);
|
402
|
+
} catch (error) {
|
403
|
+
console.error(error);
|
404
|
+
}
|
405
|
+
};
|
406
|
+
/**
|
407
|
+
* Fetch all format from array options
|
408
|
+
*
|
409
|
+
* @param {ConfigOptions[]} options
|
410
|
+
* @return {void}
|
411
|
+
*/
|
412
|
+
const fetchAll = options => {
|
413
|
+
try {
|
414
|
+
const auth = authorizeServiceAccount();
|
415
|
+
options.forEach(option => {
|
416
|
+
if (option.formatAs === 'locales') {
|
417
|
+
innerFetchLocales(auth, option);
|
418
|
+
} else if (option.formatAs === 'config') {
|
419
|
+
innerFetchConfig(auth, option);
|
420
|
+
}
|
421
|
+
});
|
422
|
+
} catch (error) {
|
423
|
+
console.error(error);
|
424
|
+
}
|
425
|
+
};
|
426
|
+
/**
|
427
|
+
* Fetch raw value
|
428
|
+
*
|
429
|
+
* @param {ConfigOptions} options
|
430
|
+
* @return {Promise<any[][] | null | undefined>}
|
431
|
+
*/
|
432
|
+
const fetchRawValue = async options => {
|
433
|
+
try {
|
434
|
+
const auth = authorizeServiceAccount();
|
435
|
+
return await fetchGoogleSheet(auth, options.spreadsheetId, options.spreadsheetTab);
|
436
|
+
} catch (error) {
|
437
|
+
console.error(error);
|
438
|
+
}
|
439
|
+
return null;
|
440
|
+
};
|
441
|
+
|
442
|
+
export { fetchAll, fetchConfig, fetchLocales, fetchRawValue, transformConfig, transformSitemap };
|
443
|
+
//# sourceMappingURL=config-cli.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"config-cli.mjs","sources":["../src/Config/Output.ts","../src/Config/Config.ts","../src/Config/GoogleAuth.ts","../src/Config/Locales.ts","../src/Config/Sitemap.ts","../src/config-cli.ts"],"sourcesContent":[null,null,null,null,null,null],"names":["outputToFile","content","options","filename","isFilenameLowercase","toLowerCase","filePath","folder","writeFile","err","console","log","processConfig","rows","versionConfig","params","map","key","forEach","row","index","processRow","data","versionName","paramsName","undefined","paramsTypeHandler","isJsonString","str","JSON","parse","e","booleanText","includes","toUpperCase","exportConfig","config","stringify","envMap","env","result","Error","contentMap","value","exportAs","lodash","isNull","transformConfig","configKeyPrefix","envKey","Object","keys","newConfigKey","extensionFile","join","Array","isArray","hasOwnProperty","SCOPES","GOOGLE_APPLICATION_CREDENTIALS_PATH","path","process","cwd","authorizeServiceAccount","isExist","existsSync","scopes","keyFile","GoogleAuth","fetchGoogleSheet","auth","spreadsheetId","spreadsheetTab","sheets","google","version","res","spreadsheets","values","get","range","majorDimension","processLocales","lang","langData","dIndex","exportLocales","generateRobots","hostname","transformSitemap","urls","includeRobots","stream","SitemapStream","lastmodDateOnly","xmlns","news","xhtml","image","video","custom","streamToPromise","Readable","from","pipe","then","toString","innerFetchLocales","length","output","innerFetchConfig","fetchLocales","error","fetchConfig","fetchAll","option","formatAs","fetchRawValue"],"mappings":";;;;;;;;;AAGA;;;;;;AAMG;AACH,MAAMA,YAAY,GAAGA,CAACC,OAAe,EAAEC,OAAsB,KAAU;AACrE,EAAA,IAAIC,QAAQ,GAAGD,OAAO,CAACC,QAAQ,CAAA;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A;AACb;;;;"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.CurrencySymbolEnum = void 0;
|
7
|
+
var CurrencySymbolEnum = exports.CurrencySymbolEnum = /*#__PURE__*/function (CurrencySymbolEnum) {
|
8
|
+
CurrencySymbolEnum["TWD"] = "NT$";
|
9
|
+
CurrencySymbolEnum["USD"] = "US$";
|
10
|
+
CurrencySymbolEnum["VND"] = "\u20AB";
|
11
|
+
return CurrencySymbolEnum;
|
12
|
+
}({}); // Vietnam
|
13
|
+
//# sourceMappingURL=CurrencySymbolEnum.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CurrencySymbolEnum.js","names":["CurrencySymbolEnum","exports"],"sources":["../../src/enums/CurrencySymbolEnum.ts"],"sourcesContent":["export enum CurrencySymbolEnum {\n TWD = 'NT$', // Taiwan\n USD = 'US$', // USA\n VND = '₫', // Vietnam\n}\n"],"mappings":";;;;;;IAAYA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA,OAGjB","ignoreList":[]}
|
package/dist/format.cjs
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var intlNumberformat = require('@formatjs/intl-numberformat');
|
4
|
+
|
5
|
+
exports.CurrencySymbolEnum = void 0;
|
6
|
+
(function (CurrencySymbolEnum) {
|
7
|
+
CurrencySymbolEnum["TWD"] = "NT$";
|
8
|
+
CurrencySymbolEnum["USD"] = "US$";
|
9
|
+
CurrencySymbolEnum["VND"] = "\u20AB";
|
10
|
+
})(exports.CurrencySymbolEnum || (exports.CurrencySymbolEnum = {}));
|
11
|
+
|
12
|
+
class NumberParser {
|
13
|
+
constructor(locale) {
|
14
|
+
const parts = new intlNumberformat.NumberFormat(locale).formatToParts(12345.6);
|
15
|
+
const numerals = [...new intlNumberformat.NumberFormat(locale, {
|
16
|
+
useGrouping: false
|
17
|
+
}).format(9876543210)].reverse();
|
18
|
+
const index = new Map(numerals.map((d, i) => [d, i]));
|
19
|
+
this._group = new RegExp(`[${parts.find(d => d.type === 'group')?.value}]`, 'g');
|
20
|
+
this._decimal = new RegExp(`[${parts.find(d => d.type === 'decimal')?.value}]`);
|
21
|
+
this._numeral = new RegExp(`[${numerals.join('')}]`, 'g');
|
22
|
+
this._index = d => index.get(d);
|
23
|
+
}
|
24
|
+
parse(value) {
|
25
|
+
value = value?.trim()?.replace(this._group, '')?.replace(this._decimal, '.')?.replace(this._numeral, this._index);
|
26
|
+
return value ? +value : NaN;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
const formatAccountNumber = function (accountNumber) {
|
31
|
+
let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' ';
|
32
|
+
return accountNumber?.replace(/\s?/g, '').replace(/(\d{4})/g, `$1${separator}`).trim();
|
33
|
+
};
|
34
|
+
const getCurrencySymbol = function (currency) {
|
35
|
+
let showCurrency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
36
|
+
let symbol;
|
37
|
+
switch (currency) {
|
38
|
+
case 'TWD':
|
39
|
+
symbol = exports.CurrencySymbolEnum.TWD;
|
40
|
+
break;
|
41
|
+
case 'USD':
|
42
|
+
symbol = exports.CurrencySymbolEnum.USD;
|
43
|
+
break;
|
44
|
+
case 'VND':
|
45
|
+
symbol = exports.CurrencySymbolEnum.VND;
|
46
|
+
break;
|
47
|
+
default:
|
48
|
+
symbol = '';
|
49
|
+
}
|
50
|
+
if (!showCurrency) {
|
51
|
+
symbol = '';
|
52
|
+
}
|
53
|
+
return symbol;
|
54
|
+
};
|
55
|
+
const formatNumber = options => {
|
56
|
+
options.value = options.value ?? 0;
|
57
|
+
options.styleCurrency = options.styleCurrency ?? 'currency';
|
58
|
+
options.currencyDisplay = options.currencyDisplay ?? 'code';
|
59
|
+
options.showValue = options.showValue ?? true;
|
60
|
+
options.showCurrency = options.showCurrency ?? true;
|
61
|
+
options.minimumFractionDigits = options.minimumFractionDigits ?? 0;
|
62
|
+
options.maximumFractionDigits = options.maximumFractionDigits ?? 0;
|
63
|
+
options.trailingZeroDisplay = options.trailingZeroDisplay ?? 'stripIfInteger';
|
64
|
+
// console.log(`options: ${JSON.stringify(options)}.`);
|
65
|
+
let formatOptions = {
|
66
|
+
style: options.styleCurrency,
|
67
|
+
currency: options.currency,
|
68
|
+
currencyDisplay: options.currencyDisplay,
|
69
|
+
minimumFractionDigits: options.minimumFractionDigits,
|
70
|
+
maximumFractionDigits: options.maximumFractionDigits,
|
71
|
+
trailingZeroDisplay: options.trailingZeroDisplay
|
72
|
+
};
|
73
|
+
if (options.options) {
|
74
|
+
formatOptions = {
|
75
|
+
...formatOptions,
|
76
|
+
...options.options
|
77
|
+
};
|
78
|
+
}
|
79
|
+
let localizedNumber = intlNumberformat.NumberFormat(options.lang, formatOptions).format(options.value).replace(/^([\d,.]+)(\s*)([A-Z]{3})$/, '$3$2$1').replace(/([\d,.]+)$/, options.showValue ? ' $1' : ' ********').replace(options.currency, getCurrencySymbol(options.currency, options.showCurrency)).trim();
|
80
|
+
// console.log(`localizedNumber: ${localizedNumber}.`);
|
81
|
+
return localizedNumber;
|
82
|
+
};
|
83
|
+
const parseFormatNumber = (lang, value) => {
|
84
|
+
if (!value) {
|
85
|
+
return null;
|
86
|
+
}
|
87
|
+
return new NumberParser(lang).parse(value);
|
88
|
+
};
|
89
|
+
|
90
|
+
require('@formatjs/intl-getcanonicallocales/polyfill');
|
91
|
+
require('@formatjs/intl-locale/polyfill');
|
92
|
+
require('@formatjs/intl-pluralrules/polyfill');
|
93
|
+
require('@formatjs/intl-pluralrules/locale-data/en');
|
94
|
+
require('@formatjs/intl-pluralrules/locale-data/vi');
|
95
|
+
require('@formatjs/intl-pluralrules/locale-data/zh');
|
96
|
+
require('@formatjs/intl-displaynames/polyfill');
|
97
|
+
require('@formatjs/intl-displaynames/locale-data/en');
|
98
|
+
require('@formatjs/intl-displaynames/locale-data/vi');
|
99
|
+
require('@formatjs/intl-displaynames/locale-data/zh');
|
100
|
+
require('@formatjs/intl-listformat/polyfill');
|
101
|
+
require('@formatjs/intl-listformat/locale-data/en');
|
102
|
+
require('@formatjs/intl-listformat/locale-data/vi');
|
103
|
+
require('@formatjs/intl-listformat/locale-data/zh');
|
104
|
+
require('@formatjs/intl-numberformat/polyfill');
|
105
|
+
require('@formatjs/intl-numberformat/locale-data/en');
|
106
|
+
require('@formatjs/intl-numberformat/locale-data/vi');
|
107
|
+
require('@formatjs/intl-numberformat/locale-data/zh');
|
108
|
+
require('@formatjs/intl-relativetimeformat/polyfill');
|
109
|
+
require('@formatjs/intl-relativetimeformat/locale-data/en');
|
110
|
+
require('@formatjs/intl-relativetimeformat/locale-data/vi');
|
111
|
+
require('@formatjs/intl-relativetimeformat/locale-data/zh');
|
112
|
+
require('@formatjs/intl-datetimeformat/polyfill');
|
113
|
+
require('@formatjs/intl-datetimeformat/locale-data/en');
|
114
|
+
require('@formatjs/intl-datetimeformat/locale-data/vi');
|
115
|
+
require('@formatjs/intl-datetimeformat/locale-data/zh');
|
116
|
+
require('@formatjs/intl-datetimeformat/add-golden-tz.js');
|
117
|
+
|
118
|
+
exports.formatAccountNumber = formatAccountNumber;
|
119
|
+
exports.formatNumber = formatNumber;
|
120
|
+
exports.getCurrencySymbol = getCurrencySymbol;
|
121
|
+
exports.parseFormatNumber = parseFormatNumber;
|
122
|
+
//# sourceMappingURL=format.cjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"format.cjs","sources":["../src/enums/CurrencySymbolEnum.ts","../src/Format/NumberParser.ts","../src/Format/NumberFormat.ts","../src/format.ts"],"sourcesContent":[null,null,null,null],"names":["CurrencySymbolEnum","NumberParser","constructor","locale","parts","NumberFormat","formatToParts","numerals","useGrouping","format","reverse","index","Map","map","d","i","_group","RegExp","find","type","value","_decimal","_numeral","join","_index","get","parse","trim","replace","NaN","formatAccountNumber","accountNumber","separator","arguments","length","undefined","getCurrencySymbol","currency","showCurrency","symbol","TWD","USD","VND","formatNumber","options","styleCurrency","currencyDisplay","showValue","minimumFractionDigits","maximumFractionDigits","trailingZeroDisplay","formatOptions","style","localizedNumber","lang","parseFormatNumber","require"],"mappings":";;;;AAAYA,oCAIX;AAJD,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACXA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACXA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,QAAS,CAAA;AACX,CAAC,EAJWA,0BAAkB,KAAlBA,0BAAkB,GAI7B,EAAA,CAAA,CAAA;;ACFD,MAAMC,YAAY,CAAA;EAMhBC,WAAAA,CAAYC,MAAc,EAAA;IACxB,MAAMC,KAAK,GAAG,IAAIC,6BAAY,CAACF,MAAM,CAAC,CAACG,aAAa,CAAC,OAAO,CAAC,CAAA;IAE7D,MAAMC,QAAQ,GAAG,CACf,GAAG,IAAIF,6BAAY,CAACF,MAAM,EAAE;AAAEK,MAAAA,WAAW,EAAE,KAAA;KAAO,CAAC,CAACC,MAAM,CAAC,UAAU,CAAC,CACvE,CAACC,OAAO,EAAE,CAAA;IAEX,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAACL,QAAQ,CAACM,GAAG,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK,CAACD,CAAC,EAAEC,CAAC,CAAC,CAAC,CAAC,CAAA;IAErD,IAAI,CAACC,MAAM,GAAG,IAAIC,MAAM,CACtB,CAAIb,CAAAA,EAAAA,KAAK,CAACc,IAAI,CAAEJ,CAAC,IAAKA,CAAC,CAACK,IAAI,KAAK,OAAO,CAAC,EAAEC,KAAK,CAAA,CAAA,CAAG,EACnD,GAAG,CACJ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