@twilio/flex-dev-utils 5.0.1-beta.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 (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/dist/axios.d.ts +6 -0
  4. package/dist/axios.js +18 -0
  5. package/dist/axios.js.map +1 -0
  6. package/dist/credentials.d.ts +40 -0
  7. package/dist/credentials.js +241 -0
  8. package/dist/credentials.js.map +1 -0
  9. package/dist/env.d.ts +1 -0
  10. package/dist/env.js +13 -0
  11. package/dist/env.js.map +1 -0
  12. package/dist/errors/index.d.ts +6 -0
  13. package/dist/errors/index.js +19 -0
  14. package/dist/errors/index.js.map +1 -0
  15. package/dist/errors/lib/FlexPluginError.d.ts +7 -0
  16. package/dist/errors/lib/FlexPluginError.js +54 -0
  17. package/dist/errors/lib/FlexPluginError.js.map +1 -0
  18. package/dist/errors/lib/UserActionError.d.ts +5 -0
  19. package/dist/errors/lib/UserActionError.js +35 -0
  20. package/dist/errors/lib/UserActionError.js.map +1 -0
  21. package/dist/errors/lib/ValidationError.d.ts +3 -0
  22. package/dist/errors/lib/ValidationError.js +30 -0
  23. package/dist/errors/lib/ValidationError.js.map +1 -0
  24. package/dist/exit.d.ts +8 -0
  25. package/dist/exit.js +18 -0
  26. package/dist/exit.js.map +1 -0
  27. package/dist/fs.d.ts +318 -0
  28. package/dist/fs.js +797 -0
  29. package/dist/fs.js.map +1 -0
  30. package/dist/http/index.d.ts +1 -0
  31. package/dist/http/index.js +10 -0
  32. package/dist/http/index.js.map +1 -0
  33. package/dist/http/lib/http.d.ts +114 -0
  34. package/dist/http/lib/http.js +337 -0
  35. package/dist/http/lib/http.js.map +1 -0
  36. package/dist/index.d.ts +25 -0
  37. package/dist/index.js +93 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/keychain.d.ts +25 -0
  40. package/dist/keychain.js +84 -0
  41. package/dist/keychain.js.map +1 -0
  42. package/dist/lodash.d.ts +13 -0
  43. package/dist/lodash.js +30 -0
  44. package/dist/lodash.js.map +1 -0
  45. package/dist/logger/index.d.ts +13 -0
  46. package/dist/logger/index.js +52 -0
  47. package/dist/logger/index.js.map +1 -0
  48. package/dist/logger/lib/boxen.d.ts +38 -0
  49. package/dist/logger/lib/boxen.js +85 -0
  50. package/dist/logger/lib/boxen.js.map +1 -0
  51. package/dist/logger/lib/columnify.d.ts +2 -0
  52. package/dist/logger/lib/columnify.js +8 -0
  53. package/dist/logger/lib/columnify.js.map +1 -0
  54. package/dist/logger/lib/logger.d.ts +157 -0
  55. package/dist/logger/lib/logger.js +354 -0
  56. package/dist/logger/lib/logger.js.map +1 -0
  57. package/dist/logger/lib/strings.d.ts +16 -0
  58. package/dist/logger/lib/strings.js +33 -0
  59. package/dist/logger/lib/strings.js.map +1 -0
  60. package/dist/logger/lib/table.d.ts +25 -0
  61. package/dist/logger/lib/table.js +75 -0
  62. package/dist/logger/lib/table.js.map +1 -0
  63. package/dist/open.d.ts +2 -0
  64. package/dist/open.js +9 -0
  65. package/dist/open.js.map +1 -0
  66. package/dist/prints.d.ts +11 -0
  67. package/dist/prints.js +47 -0
  68. package/dist/prints.js.map +1 -0
  69. package/dist/progress/index.d.ts +1 -0
  70. package/dist/progress/index.js +9 -0
  71. package/dist/progress/index.js.map +1 -0
  72. package/dist/progress/lib/progress.d.ts +21 -0
  73. package/dist/progress/lib/progress.js +118 -0
  74. package/dist/progress/lib/progress.js.map +1 -0
  75. package/dist/questions/index.d.ts +1 -0
  76. package/dist/questions/index.js +12 -0
  77. package/dist/questions/index.js.map +1 -0
  78. package/dist/questions/lib/inquirer.d.ts +39 -0
  79. package/dist/questions/lib/inquirer.js +136 -0
  80. package/dist/questions/lib/inquirer.js.map +1 -0
  81. package/dist/random.d.ts +15 -0
  82. package/dist/random.js +28 -0
  83. package/dist/random.js.map +1 -0
  84. package/dist/runner.d.ts +8 -0
  85. package/dist/runner.js +98 -0
  86. package/dist/runner.js.map +1 -0
  87. package/dist/semver.d.ts +9 -0
  88. package/dist/semver.js +36 -0
  89. package/dist/semver.js.map +1 -0
  90. package/dist/sids.d.ts +48 -0
  91. package/dist/sids.js +50 -0
  92. package/dist/sids.js.map +1 -0
  93. package/dist/spawn/index.d.ts +4 -0
  94. package/dist/spawn/index.js +15 -0
  95. package/dist/spawn/index.js.map +1 -0
  96. package/dist/spawn/lib/node.d.ts +9 -0
  97. package/dist/spawn/lib/node.js +74 -0
  98. package/dist/spawn/lib/node.js.map +1 -0
  99. package/dist/spawn/lib/npm.d.ts +9 -0
  100. package/dist/spawn/lib/npm.js +74 -0
  101. package/dist/spawn/lib/npm.js.map +1 -0
  102. package/dist/spawn/lib/spawn.d.ts +22 -0
  103. package/dist/spawn/lib/spawn.js +111 -0
  104. package/dist/spawn/lib/spawn.js.map +1 -0
  105. package/dist/spawn/lib/yarn.d.ts +9 -0
  106. package/dist/spawn/lib/yarn.js +74 -0
  107. package/dist/spawn/lib/yarn.js.map +1 -0
  108. package/dist/updateNotifier.d.ts +6 -0
  109. package/dist/updateNotifier.js +20 -0
  110. package/dist/updateNotifier.js.map +1 -0
  111. package/dist/urls.d.ts +28 -0
  112. package/dist/urls.js +147 -0
  113. package/dist/urls.js.map +1 -0
  114. package/dist/validators.d.ts +42 -0
  115. package/dist/validators.js +78 -0
  116. package/dist/validators.js.map +1 -0
  117. package/package.json +86 -0
package/dist/fs.d.ts ADDED
@@ -0,0 +1,318 @@
1
+ import fs from 'fs';
2
+ import mkdirp from 'mkdirp';
3
+ import rimRaf from 'rimraf';
4
+ export interface PackageJson {
5
+ name: string;
6
+ version: string;
7
+ dependencies: Record<string, string>;
8
+ devDependencies: Record<string, string>;
9
+ peerDependencies?: Record<string, string>;
10
+ }
11
+ export interface AppPackageJson extends PackageJson {
12
+ dependencies: {
13
+ '@twilio/flex-plugin': string;
14
+ '@twilio/flex-plugin-scripts': string;
15
+ };
16
+ }
17
+ export interface FlexConfigurationPlugin {
18
+ name: string;
19
+ dir: string;
20
+ }
21
+ export interface CLIFlexConfiguration {
22
+ plugins: FlexConfigurationPlugin[];
23
+ }
24
+ export interface LocallyRunningPluginsConfiguration {
25
+ plugins: string[];
26
+ loadedPlugins: string[];
27
+ }
28
+ export declare type JsonObject<T> = {
29
+ [K in keyof T]: T[K];
30
+ };
31
+ export default fs;
32
+ /**
33
+ * This is an alias for require. Useful for mocking out in tests
34
+ * @param filePath the file to require
35
+ * @private
36
+ */
37
+ export declare const _require: (filePath: string) => any;
38
+ export declare const _setRequirePaths: (requirePath: string) => void;
39
+ /**
40
+ * Reads a JSON file
41
+ *
42
+ * @param filePath the file path to read
43
+ */
44
+ export declare const readPackageJson: (filePath: string) => PackageJson;
45
+ /**
46
+ * Returns the file size in bytes
47
+ * @param filePaths the path to the file
48
+ */
49
+ export declare const getSileSizeInBytes: (...filePaths: string[]) => number;
50
+ /**
51
+ * Returns the file size in MB
52
+ * @param filePaths the path to file
53
+ */
54
+ export declare const getFileSizeInMB: (...filePaths: string[]) => number;
55
+ /**
56
+ * Builds path relative to the given dir
57
+ * @param dir the dir
58
+ * @param paths the paths
59
+ */
60
+ export declare const resolveRelative: (dir: string, ...paths: string[]) => string;
61
+ /**
62
+ * Sets the working directory
63
+ * @param p the path to set
64
+ */
65
+ export declare const setCwd: (p: string) => void;
66
+ /**
67
+ * Returns the working directory
68
+ */
69
+ export declare const getCwd: () => string;
70
+ /**
71
+ * Sets the core working directory
72
+ * @param p the path to set
73
+ */
74
+ export declare const setCoreCwd: (p: string) => void;
75
+ /**
76
+ * The core cwd is the working directory of core packages such as flex-plugin-scripts and flex-plugin
77
+ */
78
+ export declare const getCoreCwd: () => string;
79
+ /**
80
+ * Reads the file
81
+ * @param filePaths the file paths
82
+ */
83
+ export declare const readFileSync: (...filePaths: string[]) => string;
84
+ /**
85
+ * Reads a JSON file (Templated)
86
+ *
87
+ * @param filePaths the file paths to read
88
+ */
89
+ export declare const readJsonFile: <T>(...filePaths: string[]) => T;
90
+ /**
91
+ * Gets the CLI paths. This is separated out from getPaths because create-flex-plugin also needs to read it,
92
+ * but that script will not have flex-plugin-scripts installed which would cause an exception to be thrown.
93
+ */
94
+ export declare const getCliPaths: () => {
95
+ dir: string;
96
+ nodeModulesDir: string;
97
+ flexDir: string;
98
+ pluginsJsonPath: string;
99
+ localPluginsJsonPath: string;
100
+ };
101
+ export declare const readPluginsJson: () => CLIFlexConfiguration;
102
+ export declare const readRunPluginsJson: () => LocallyRunningPluginsConfiguration;
103
+ /**
104
+ * Writes string to file
105
+ */
106
+ export declare const writeFile: (str: string, ...paths: string[]) => void;
107
+ /**
108
+ * Writes an object as a JSON string to the file
109
+ * @param obj the object to write
110
+ * @param paths the path to write to
111
+ */
112
+ export declare const writeJSONFile: <T>(obj: JsonObject<T>, ...paths: string[]) => void;
113
+ /**
114
+ * Checks the provided array of files exist
115
+ *
116
+ * @param files the files to check that they exist
117
+ */
118
+ export declare const checkFilesExist: (...files: string[]) => boolean;
119
+ /**
120
+ * Calculates the sha of a file
121
+ * @param paths
122
+ */
123
+ export declare const calculateSha256: (...paths: string[]) => Promise<string>;
124
+ /**
125
+ * Removes a file
126
+ * @param paths
127
+ */
128
+ export declare const removeFile: (...paths: string[]) => void;
129
+ /**
130
+ * Copies from from src to dest
131
+ * @param srcPaths
132
+ * @param destPaths
133
+ */
134
+ export declare const copyFile: (srcPaths: string[], destPaths: string[]) => void;
135
+ /**
136
+ * Checks the provided file exists
137
+ *
138
+ * @param paths the paths to the file
139
+ */
140
+ export declare const checkAFileExists: (...paths: string[]) => boolean;
141
+ /**
142
+ * Gets package.json path
143
+ */
144
+ export declare const getPackageJsonPath: () => string;
145
+ /**
146
+ * Reads app package.json from the rootDir.
147
+ */
148
+ export declare const readAppPackageJson: () => AppPackageJson;
149
+ /**
150
+ * Updates the package.json version field
151
+ *
152
+ * @param version the new version
153
+ */
154
+ export declare const updateAppVersion: (version: string) => void;
155
+ /**
156
+ * Finds the closest up file relative to dir
157
+ *
158
+ * @param dir the directory
159
+ * @param file the file to look for
160
+ */
161
+ export declare const findUp: (dir: string, file: string) => string;
162
+ /**
163
+ * mkdir -p wrapper
164
+ */
165
+ export declare const mkdirpSync: typeof mkdirp.sync;
166
+ /**
167
+ * Copies a template by applying the variables
168
+ *
169
+ * @param source the source
170
+ * @param target the target
171
+ * @param variables the variables
172
+ */
173
+ export declare const copyTemplateDir: (source: string, target: string, variables: object) => Promise<unknown>;
174
+ /**
175
+ * rm -rf sync script
176
+ */
177
+ export declare const rmRfSync: typeof rimRaf.sync;
178
+ /**
179
+ * Builds path relative to cwd
180
+ * @param paths the paths
181
+ */
182
+ export declare const resolveCwd: (...paths: string[]) => string;
183
+ /**
184
+ * Finds globs in any cwd directory
185
+ * @param dir the cwd to check for patterns
186
+ * @param patterns the patterns
187
+ */
188
+ export declare const findGlobsIn: (dir: string, ...patterns: string[]) => string[];
189
+ /**
190
+ * Finds globs in the src directory
191
+ * @param patterns the patterns
192
+ */
193
+ export declare const findGlobs: (...patterns: string[]) => string[];
194
+ /**
195
+ * Touch ~/.twilio-cli/flex/plugins.json if it does not exist
196
+ * Check if this plugin is in this config file. If not, add it.
197
+ * @param name the plugin name
198
+ * @param dir the plugin directory
199
+ * @param promptForOverwrite whether to prompt for overwrite
200
+ * @return whether the plugin-directory was overwritten
201
+ */
202
+ export declare const checkPluginConfigurationExists: (name: string, dir: string, promptForOverwrite?: boolean) => Promise<boolean>;
203
+ /**
204
+ * Touch ~/.twilio-cli/flex/locallyRunningPlugins.json if it does not exist,
205
+ * and if it does exist, clear the file so it is ready for a new run
206
+ */
207
+ export declare const checkRunPluginConfigurationExists: (localPlugins: string[]) => Promise<void>;
208
+ /**
209
+ * Adds the node_modules to the app module.
210
+ * This is needed because we spawn different scripts when running start/build/test and so we lose
211
+ * the original cwd directory
212
+ */
213
+ export declare const addCWDNodeModule: (...args: string[]) => void;
214
+ /**
215
+ * Returns the absolute path to the pkg if found
216
+ * @param pkg the package to lookup
217
+ */
218
+ export declare const resolveModulePath: (pkg: string, ...paths: string[]) => string | false;
219
+ /**
220
+ * Returns the path to flex-plugin-scripts
221
+ */
222
+ export declare const _getFlexPluginScripts: () => string;
223
+ /**
224
+ * Returns the path to flex-plugin-webpack
225
+ */
226
+ export declare const _getFlexPluginWebpackPath: (scriptsNodeModulesDir: string) => string;
227
+ /**
228
+ * Returns the paths to all modules and directories used in the plugin-builder
229
+ */
230
+ export declare const getPaths: () => {
231
+ cwd: string;
232
+ webpack: {
233
+ dir: string;
234
+ nodeModulesDir: string;
235
+ };
236
+ scripts: {
237
+ dir: string;
238
+ nodeModulesDir: string;
239
+ devAssetsDir: string;
240
+ indexHTMLPath: string;
241
+ tsConfigPath: string;
242
+ };
243
+ cli: {
244
+ dir: string;
245
+ nodeModulesDir: string;
246
+ flexDir: string;
247
+ pluginsJsonPath: string;
248
+ localPluginsJsonPath: string;
249
+ };
250
+ app: {
251
+ dir: string;
252
+ name: string;
253
+ version: string;
254
+ pkgPath: string;
255
+ jestConfigPath: string;
256
+ webpackConfigPath: string;
257
+ devServerConfigPath: string;
258
+ tsConfigPath: string;
259
+ isTSProject: () => boolean;
260
+ setupTestsPaths: string[];
261
+ envPath: string;
262
+ hasEnvFile: () => boolean;
263
+ envExamplePath: string;
264
+ hasEnvExampleFile: () => boolean;
265
+ envDefaultsPath: string;
266
+ hasEnvDefaultsPath: () => boolean;
267
+ buildDir: string;
268
+ bundlePath: string;
269
+ sourceMapPath: string;
270
+ srcDir: string;
271
+ entryPath: string;
272
+ nodeModulesDir: string;
273
+ flexUIDir: string;
274
+ flexUIPkgPath: string;
275
+ publicDir: string;
276
+ appConfig: string;
277
+ dependencies: {
278
+ react: {
279
+ version: string;
280
+ };
281
+ reactDom: {
282
+ version: string;
283
+ };
284
+ flexUI: {
285
+ version: string;
286
+ };
287
+ };
288
+ };
289
+ assetBaseUrlTemplate: string;
290
+ extensions: string[];
291
+ };
292
+ /**
293
+ * Returns the version of the dependency that is installed in node_modules
294
+ * @param pkgName the package name
295
+ * @return the version of the package installed
296
+ */
297
+ export declare const getDependencyVersion: (pkgName: string) => string;
298
+ /**
299
+ * Returns the package.json version field of the package
300
+ * @param name the package
301
+ */
302
+ export declare const getPackageVersion: (name: string) => string;
303
+ /**
304
+ * Determines whether the directory is plugin based on the package.json
305
+ * @param packageJson the package json
306
+ */
307
+ export declare const isPluginDir: (packageJson: PackageJson) => boolean;
308
+ /**
309
+ * Fetches the version corresponding to the dependency inside the given package
310
+ * @param pkg the package.json to check
311
+ * @param name the package to look for
312
+ */
313
+ export declare const packageDependencyVersion: (pkg: PackageJson, name: string) => string | null;
314
+ /**
315
+ * Fetches the version corresponding to the dependency inside the flex-ui package.json
316
+ * @param name the package to check
317
+ */
318
+ export declare const flexUIPackageDependencyVersion: (name: string) => string | null;