oc 0.49.7 → 0.49.8
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.
- package/CHANGELOG.md +22 -0
- package/README.md +2 -15
- package/dist/cli/domain/clean.d.ts +2 -2
- package/dist/cli/domain/clean.js +10 -13
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +8 -15
- package/dist/cli/domain/get-mocked-plugins.js +8 -6
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js +4 -5
- package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/get-compiler.js +3 -3
- package/dist/cli/domain/handle-dependencies/index.d.ts +4 -3
- package/dist/cli/domain/handle-dependencies/index.js +40 -34
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/install-compiler.js +14 -7
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +13 -9
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +4 -8
- package/dist/cli/domain/init-template/index.d.ts +2 -2
- package/dist/cli/domain/init-template/index.js +6 -8
- package/dist/cli/domain/init-template/install-template.d.ts +2 -2
- package/dist/cli/domain/init-template/install-template.js +10 -9
- package/dist/cli/domain/init-template/scaffold.d.ts +2 -2
- package/dist/cli/domain/init-template/scaffold.js +7 -7
- package/dist/cli/domain/local.js +11 -10
- package/dist/cli/domain/mock.d.ts +1 -1
- package/dist/cli/domain/mock.js +21 -21
- package/dist/cli/domain/package-components.d.ts +1 -1
- package/dist/cli/domain/package-components.js +14 -17
- package/dist/cli/domain/registry.js +68 -81
- package/dist/cli/domain/watch.js +1 -1
- package/dist/cli/facade/clean.d.ts +10 -4
- package/dist/cli/facade/clean.js +38 -28
- package/dist/cli/facade/dev.d.ts +108 -15
- package/dist/cli/facade/dev.js +85 -99
- package/dist/cli/facade/init.d.ts +12 -5
- package/dist/cli/facade/init.js +22 -20
- package/dist/cli/facade/mock.d.ts +12 -5
- package/dist/cli/facade/mock.js +5 -6
- package/dist/cli/facade/package.d.ts +12 -5
- package/dist/cli/facade/package.js +30 -32
- package/dist/cli/facade/preview.d.ts +8 -3
- package/dist/cli/facade/preview.js +12 -10
- package/dist/cli/facade/publish.d.ts +16 -7
- package/dist/cli/facade/publish.js +94 -114
- package/dist/cli/facade/registry-add.d.ts +8 -3
- package/dist/cli/facade/registry-add.js +10 -9
- package/dist/cli/facade/registry-ls.d.ts +4 -1
- package/dist/cli/facade/registry-ls.js +19 -17
- package/dist/cli/facade/registry-remove.d.ts +8 -3
- package/dist/cli/facade/registry-remove.js +10 -9
- package/dist/cli/facade/registry.d.ts +4 -1
- package/dist/cli/facade/registry.js +6 -3
- package/dist/cli/index.js +3 -5
- package/dist/cli/programmatic-api.d.ts +1 -1
- package/dist/components/oc-client/_package/package.json +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/registry/app-start.d.ts +2 -2
- package/dist/registry/app-start.js +20 -20
- package/dist/registry/domain/components-cache/components-list.d.ts +7 -6
- package/dist/registry/domain/components-cache/components-list.js +31 -45
- package/dist/registry/domain/components-cache/index.d.ts +6 -5
- package/dist/registry/domain/components-cache/index.js +47 -50
- package/dist/registry/domain/components-details.d.ts +5 -4
- package/dist/registry/domain/components-details.js +27 -38
- package/dist/registry/domain/extract-package.d.ts +2 -2
- package/dist/registry/domain/extract-package.js +9 -12
- package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +1 -1
- package/dist/registry/domain/get-package-json-from-temp-dir.js +2 -2
- package/dist/registry/domain/nested-renderer.d.ts +7 -6
- package/dist/registry/domain/nested-renderer.js +36 -72
- package/dist/registry/domain/options-sanitiser.js +5 -3
- package/dist/registry/domain/plugins-initialiser.d.ts +3 -1
- package/dist/registry/domain/plugins-initialiser.js +29 -33
- package/dist/registry/domain/repository.js +78 -100
- package/dist/registry/domain/require-wrapper.js +1 -2
- package/dist/registry/domain/storage-adapter.d.ts +10 -0
- package/dist/registry/domain/storage-adapter.js +55 -0
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +15 -28
- package/dist/registry/middleware/index.d.ts +6 -2
- package/dist/registry/middleware/index.js +5 -1
- package/dist/registry/router.d.ts +2 -2
- package/dist/registry/router.js +0 -2
- package/dist/registry/routes/component-info.js +3 -2
- package/dist/registry/routes/component-preview.js +2 -1
- package/dist/registry/routes/components.js +1 -1
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +2 -7
- package/dist/registry/routes/helpers/get-component.d.ts +5 -5
- package/dist/registry/routes/helpers/get-component.js +6 -5
- package/dist/registry/routes/helpers/is-url-discoverable.d.ts +2 -2
- package/dist/registry/routes/helpers/is-url-discoverable.js +15 -9
- package/dist/registry/routes/index.js +4 -3
- package/dist/registry/routes/publish.d.ts +1 -1
- package/dist/registry/routes/publish.js +32 -31
- package/dist/resources/settings.js +1 -1
- package/dist/types.d.ts +35 -43
- package/dist/utils/npm-utils.d.ts +6 -8
- package/dist/utils/npm-utils.js +20 -9
- package/dist/utils/put.d.ts +2 -1
- package/dist/utils/put.js +10 -29
- package/logintervals.md +1 -1
- package/package.json +6 -1
- package/src/cli/domain/clean.ts +10 -20
- package/src/cli/domain/get-components-by-dir.ts +12 -26
- package/src/cli/domain/get-mocked-plugins.ts +32 -26
- package/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +8 -12
- package/src/cli/domain/handle-dependencies/get-compiler.ts +8 -11
- package/src/cli/domain/handle-dependencies/index.ts +55 -109
- package/src/cli/domain/handle-dependencies/install-compiler.ts +22 -15
- package/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +19 -13
- package/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +8 -16
- package/src/cli/domain/init-template/index.ts +13 -20
- package/src/cli/domain/init-template/install-template.ts +11 -12
- package/src/cli/domain/init-template/scaffold.ts +9 -12
- package/src/cli/domain/local.ts +19 -22
- package/src/cli/domain/mock.ts +32 -36
- package/src/cli/domain/package-components.ts +14 -25
- package/src/cli/domain/registry.ts +80 -116
- package/src/cli/domain/watch.ts +1 -1
- package/src/cli/facade/clean.ts +37 -37
- package/src/cli/facade/dev.ts +159 -182
- package/src/cli/facade/init.ts +36 -38
- package/src/cli/facade/mock.ts +11 -10
- package/src/cli/facade/package.ts +44 -49
- package/src/cli/facade/preview.ts +20 -18
- package/src/cli/facade/publish.ts +134 -172
- package/src/cli/facade/registry-add.ts +16 -15
- package/src/cli/facade/registry-ls.ts +27 -22
- package/src/cli/facade/registry-remove.ts +16 -15
- package/src/cli/facade/registry.ts +7 -5
- package/src/cli/index.ts +3 -5
- package/src/components/oc-client/_package/package.json +1 -1
- package/src/components/oc-client/package.json +1 -1
- package/src/globals.d.ts +38 -0
- package/src/registry/app-start.ts +27 -31
- package/src/registry/domain/components-cache/components-list.ts +45 -67
- package/src/registry/domain/components-cache/index.ts +55 -60
- package/src/registry/domain/components-details.ts +49 -75
- package/src/registry/domain/extract-package.ts +19 -27
- package/src/registry/domain/get-package-json-from-temp-dir.ts +3 -4
- package/src/registry/domain/nested-renderer.ts +64 -122
- package/src/registry/domain/options-sanitiser.ts +6 -3
- package/src/registry/domain/plugins-initialiser.ts +45 -49
- package/src/registry/domain/repository.ts +129 -235
- package/src/registry/domain/require-wrapper.ts +1 -2
- package/src/registry/domain/storage-adapter.ts +85 -0
- package/src/registry/index.ts +48 -79
- package/src/registry/middleware/index.ts +10 -2
- package/src/registry/router.ts +2 -10
- package/src/registry/routes/component-info.ts +4 -3
- package/src/registry/routes/component-preview.ts +3 -2
- package/src/registry/routes/components.ts +1 -1
- package/src/registry/routes/helpers/get-component-fallback.ts +3 -9
- package/src/registry/routes/helpers/get-component.ts +11 -9
- package/src/registry/routes/helpers/is-url-discoverable.ts +14 -15
- package/src/registry/routes/index.ts +18 -13
- package/src/registry/routes/publish.ts +31 -34
- package/src/resources/settings.ts +1 -1
- package/src/types.ts +63 -136
- package/src/utils/npm-utils.ts +38 -37
- package/src/utils/put.ts +15 -37
package/src/types.ts
CHANGED
|
@@ -44,6 +44,16 @@ export interface ComponentsList {
|
|
|
44
44
|
lastEdit: number;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export interface OcJsonConfig {
|
|
48
|
+
registries?: string[];
|
|
49
|
+
mocks?: {
|
|
50
|
+
plugins?: {
|
|
51
|
+
dynamic?: Record<string, string>;
|
|
52
|
+
static?: Record<string, string>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
export interface OcParameter {
|
|
48
58
|
default?: string | boolean | number;
|
|
49
59
|
description?: string;
|
|
@@ -181,36 +191,6 @@ export interface Config {
|
|
|
181
191
|
verbosity: number;
|
|
182
192
|
}
|
|
183
193
|
|
|
184
|
-
export interface Cdn {
|
|
185
|
-
adapterType: string;
|
|
186
|
-
getFile: (
|
|
187
|
-
filePath: string,
|
|
188
|
-
cb: (err: Error | null, data: string) => void
|
|
189
|
-
) => void;
|
|
190
|
-
getJson<T>(
|
|
191
|
-
filePath: string,
|
|
192
|
-
force: boolean,
|
|
193
|
-
cb: (err: string | null, data: T) => void
|
|
194
|
-
): void;
|
|
195
|
-
getJson<T>(filePath: string, cb: (err: string | null, data: T) => void): void;
|
|
196
|
-
listSubDirectories: (
|
|
197
|
-
dir: string,
|
|
198
|
-
cb: (err: (Error & { code?: string }) | null, data: string[]) => void
|
|
199
|
-
) => void;
|
|
200
|
-
maxConcurrentRequests: number;
|
|
201
|
-
putDir: (
|
|
202
|
-
folderPath: string,
|
|
203
|
-
filePath: string,
|
|
204
|
-
cb: (err: Error | null) => void
|
|
205
|
-
) => void;
|
|
206
|
-
putFileContent: (
|
|
207
|
-
data: unknown,
|
|
208
|
-
path: string,
|
|
209
|
-
isPrivate: boolean,
|
|
210
|
-
callback: (err: string | null, data: unknown) => void
|
|
211
|
-
) => void;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
194
|
type CompiledTemplate = (model: unknown) => string;
|
|
215
195
|
|
|
216
196
|
interface CompilerOptions {
|
|
@@ -241,7 +221,7 @@ export interface Template {
|
|
|
241
221
|
}
|
|
242
222
|
|
|
243
223
|
export interface Plugin {
|
|
244
|
-
callback?: (
|
|
224
|
+
callback?: (error: unknown) => void;
|
|
245
225
|
description?: string;
|
|
246
226
|
name: string;
|
|
247
227
|
options?: any;
|
|
@@ -249,7 +229,7 @@ export interface Plugin {
|
|
|
249
229
|
register: (
|
|
250
230
|
options: unknown,
|
|
251
231
|
dependencies: unknown,
|
|
252
|
-
next: () => void
|
|
232
|
+
next: (error?: unknown) => void
|
|
253
233
|
) => void;
|
|
254
234
|
execute: (...args: unknown[]) => unknown;
|
|
255
235
|
dependencies?: string[];
|
|
@@ -257,120 +237,73 @@ export interface Plugin {
|
|
|
257
237
|
}
|
|
258
238
|
|
|
259
239
|
export interface RegistryCli {
|
|
260
|
-
add(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
):
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
callback: (err: Error | number | null, data: string) => void
|
|
272
|
-
): void;
|
|
273
|
-
putComponent(
|
|
274
|
-
options: {
|
|
275
|
-
username?: string;
|
|
276
|
-
password?: string;
|
|
277
|
-
route: string;
|
|
278
|
-
path: string;
|
|
279
|
-
},
|
|
280
|
-
callback: (err: string | null, data: unknown) => void
|
|
281
|
-
): void;
|
|
282
|
-
remove(registry: string, callback: (err: Error | null) => void): void;
|
|
240
|
+
add(registry: string): Promise<void>;
|
|
241
|
+
get(): Promise<string[]>;
|
|
242
|
+
getApiComponentByHref(href: string): Promise<Component>;
|
|
243
|
+
getComponentPreviewUrlByUrl(componentHref: string): Promise<string>;
|
|
244
|
+
putComponent(options: {
|
|
245
|
+
username?: string;
|
|
246
|
+
password?: string;
|
|
247
|
+
route: string;
|
|
248
|
+
path: string;
|
|
249
|
+
}): Promise<void>;
|
|
250
|
+
remove(registry: string): Promise<void>;
|
|
283
251
|
}
|
|
284
252
|
|
|
285
253
|
export interface Local {
|
|
286
254
|
clean: {
|
|
287
|
-
fetchList: (
|
|
288
|
-
|
|
289
|
-
callback: (err: Error | null, data: string[]) => void
|
|
290
|
-
) => void;
|
|
291
|
-
remove: (
|
|
292
|
-
list: string[],
|
|
293
|
-
callback: (err: Error | null, data: string) => void
|
|
294
|
-
) => void;
|
|
255
|
+
fetchList: (dirPath: string) => Promise<string[]>;
|
|
256
|
+
remove: (list: string[]) => Promise<void>;
|
|
295
257
|
};
|
|
296
|
-
cleanup: (
|
|
297
|
-
|
|
298
|
-
cb: (err: NodeJS.ErrnoException) => void
|
|
299
|
-
) => void;
|
|
300
|
-
compress: (
|
|
301
|
-
input: string,
|
|
302
|
-
output: string,
|
|
303
|
-
cb: (error: Error | string | null) => void
|
|
304
|
-
) => void;
|
|
258
|
+
cleanup: (compressedPackagePath: string) => Promise<void>;
|
|
259
|
+
compress: (input: string, output: string) => Promise<void>;
|
|
305
260
|
getComponentsByDir: (
|
|
306
261
|
componentsDir: string,
|
|
307
|
-
componentsToRun
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
minify?: boolean;
|
|
327
|
-
verbose?: boolean;
|
|
328
|
-
production?: boolean;
|
|
329
|
-
},
|
|
330
|
-
callback: (err: Error | null, data: Component) => void
|
|
331
|
-
) => void;
|
|
262
|
+
componentsToRun?: string[]
|
|
263
|
+
) => Promise<string[]>;
|
|
264
|
+
init: (options: {
|
|
265
|
+
componentName: string;
|
|
266
|
+
logger: Logger;
|
|
267
|
+
componentPath: string;
|
|
268
|
+
templateType: string;
|
|
269
|
+
}) => Promise<void>;
|
|
270
|
+
mock: (params: {
|
|
271
|
+
targetType: string;
|
|
272
|
+
targetValue: string;
|
|
273
|
+
targetName: string;
|
|
274
|
+
}) => Promise<void>;
|
|
275
|
+
package: (options: {
|
|
276
|
+
componentPath: string;
|
|
277
|
+
minify?: boolean;
|
|
278
|
+
verbose?: boolean;
|
|
279
|
+
production?: boolean;
|
|
280
|
+
}) => Promise<Component>;
|
|
332
281
|
}
|
|
333
282
|
|
|
334
283
|
export interface Repository {
|
|
335
284
|
getCompiledView(
|
|
336
285
|
componentName: string,
|
|
337
|
-
componentVersion: string
|
|
338
|
-
|
|
339
|
-
): void;
|
|
286
|
+
componentVersion: string
|
|
287
|
+
): Promise<string>;
|
|
340
288
|
getComponent(
|
|
341
289
|
componentName: string,
|
|
342
|
-
componentVersion
|
|
343
|
-
|
|
344
|
-
): void;
|
|
345
|
-
getComponent(
|
|
346
|
-
componentName: string,
|
|
347
|
-
calllback: (err: string | null, data: Component) => void
|
|
348
|
-
): void;
|
|
290
|
+
componentVersion?: string
|
|
291
|
+
): Promise<Component>;
|
|
349
292
|
getComponentInfo(
|
|
350
293
|
componentName: string,
|
|
351
|
-
componentVersion: string
|
|
352
|
-
|
|
353
|
-
): void;
|
|
294
|
+
componentVersion: string
|
|
295
|
+
): Promise<Component>;
|
|
354
296
|
getComponentPath(componentName: string, componentVersion: string): void;
|
|
355
|
-
getComponents(
|
|
356
|
-
getComponentsDetails(
|
|
357
|
-
|
|
358
|
-
): void;
|
|
359
|
-
getComponentVersions(
|
|
360
|
-
componentName: string,
|
|
361
|
-
callback: (err: string | null, data: string[]) => void
|
|
362
|
-
): void;
|
|
297
|
+
getComponents(): Promise<string[]>;
|
|
298
|
+
getComponentsDetails(): Promise<ComponentsDetails>;
|
|
299
|
+
getComponentVersions(componentName: string): Promise<string[]>;
|
|
363
300
|
getDataProvider(
|
|
364
301
|
componentName: string,
|
|
365
|
-
componentVersion: string
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
filePath: string;
|
|
371
|
-
}
|
|
372
|
-
) => void
|
|
373
|
-
): void;
|
|
302
|
+
componentVersion: string
|
|
303
|
+
): Promise<{
|
|
304
|
+
content: string;
|
|
305
|
+
filePath: string;
|
|
306
|
+
}>;
|
|
374
307
|
getStaticClientMapPath: () => string;
|
|
375
308
|
getStaticClientPath: () => string;
|
|
376
309
|
getStaticFilePath: (
|
|
@@ -380,18 +313,12 @@ export interface Repository {
|
|
|
380
313
|
) => string;
|
|
381
314
|
getTemplate: (type: string) => Template;
|
|
382
315
|
getTemplatesInfo: () => TemplateInfo[];
|
|
383
|
-
init(
|
|
384
|
-
callback: (err: Error | null, data: ComponentsList | string) => void
|
|
385
|
-
): void;
|
|
316
|
+
init(): Promise<ComponentsList>;
|
|
386
317
|
publishComponent(
|
|
387
318
|
pkgDetails: any,
|
|
388
319
|
componentName: string,
|
|
389
|
-
componentVersion: string
|
|
390
|
-
|
|
391
|
-
err: { code: string; msg: string } | null,
|
|
392
|
-
data: ComponentsDetails
|
|
393
|
-
) => void
|
|
394
|
-
): void;
|
|
320
|
+
componentVersion: string
|
|
321
|
+
): Promise<ComponentsDetails>;
|
|
395
322
|
}
|
|
396
323
|
|
|
397
324
|
declare global {
|
package/src/utils/npm-utils.ts
CHANGED
|
@@ -2,8 +2,6 @@ import path from 'path';
|
|
|
2
2
|
import spawn from 'cross-spawn';
|
|
3
3
|
import stripVersion from './strip-version';
|
|
4
4
|
|
|
5
|
-
type NoParameterCallback<T = unknown> = (err: T) => void;
|
|
6
|
-
|
|
7
5
|
const buildInstallCommand = (options: {
|
|
8
6
|
installPath: string;
|
|
9
7
|
save?: boolean;
|
|
@@ -26,17 +24,26 @@ const buildInstallCommand = (options: {
|
|
|
26
24
|
return args;
|
|
27
25
|
};
|
|
28
26
|
|
|
29
|
-
const executeCommand = (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const executeCommand = (options: {
|
|
28
|
+
command: string[];
|
|
29
|
+
path: string;
|
|
30
|
+
silent?: boolean;
|
|
31
|
+
}) => {
|
|
33
32
|
const cmd = spawn('npm', [...options.command, '--no-package-lock'], {
|
|
34
33
|
cwd: options.path,
|
|
35
34
|
stdio: options.silent ? 'ignore' : 'inherit'
|
|
36
35
|
});
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
return new Promise<void>((res, rej) => {
|
|
38
|
+
cmd.on('error', () => rej(new Error('error')));
|
|
39
|
+
cmd.on('close', code => {
|
|
40
|
+
if (code !== 0) {
|
|
41
|
+
rej(code);
|
|
42
|
+
} else {
|
|
43
|
+
res();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
40
47
|
};
|
|
41
48
|
|
|
42
49
|
const getFullPath = ({
|
|
@@ -47,26 +54,23 @@ const getFullPath = ({
|
|
|
47
54
|
dependency: string;
|
|
48
55
|
}) => path.join(installPath, 'node_modules', stripVersion(dependency));
|
|
49
56
|
|
|
50
|
-
export const init = (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
): void => {
|
|
57
|
+
export const init = (options: {
|
|
58
|
+
initPath: string;
|
|
59
|
+
silent: boolean;
|
|
60
|
+
}): Promise<void> => {
|
|
54
61
|
const { initPath, silent } = options;
|
|
55
62
|
const npminit = ['init', '--yes'];
|
|
56
63
|
const cmdOptions = { path: initPath, command: npminit, silent };
|
|
57
64
|
|
|
58
|
-
executeCommand(cmdOptions
|
|
65
|
+
return executeCommand(cmdOptions);
|
|
59
66
|
};
|
|
60
67
|
|
|
61
|
-
export const installDependencies = (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
callback: (err: string | number | null, data: { dest: string }) => void
|
|
69
|
-
): void => {
|
|
68
|
+
export const installDependencies = async (options: {
|
|
69
|
+
dependencies: string[];
|
|
70
|
+
installPath: string;
|
|
71
|
+
silent: boolean;
|
|
72
|
+
usePrefix: boolean;
|
|
73
|
+
}): Promise<{ dest: string[] }> => {
|
|
70
74
|
const { dependencies, installPath, silent } = options;
|
|
71
75
|
const npmi = buildInstallCommand(options);
|
|
72
76
|
const cmdOptions = {
|
|
@@ -79,20 +83,17 @@ export const installDependencies = (
|
|
|
79
83
|
getFullPath({ installPath, dependency })
|
|
80
84
|
);
|
|
81
85
|
|
|
82
|
-
executeCommand(cmdOptions
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
await executeCommand(cmdOptions);
|
|
87
|
+
|
|
88
|
+
return { dest };
|
|
85
89
|
};
|
|
86
90
|
|
|
87
|
-
export const installDependency = (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
callback: (err: string | number | null, data: { dest: string }) => void
|
|
95
|
-
): void => {
|
|
91
|
+
export const installDependency = async (options: {
|
|
92
|
+
dependency: string;
|
|
93
|
+
installPath: string;
|
|
94
|
+
silent?: boolean;
|
|
95
|
+
usePrefix: boolean;
|
|
96
|
+
}): Promise<{ dest: string }> => {
|
|
96
97
|
const { dependency, installPath, silent } = options;
|
|
97
98
|
const npmi = buildInstallCommand(options);
|
|
98
99
|
const cmdOptions = {
|
|
@@ -102,7 +103,7 @@ export const installDependency = (
|
|
|
102
103
|
};
|
|
103
104
|
const dest = getFullPath({ installPath, dependency });
|
|
104
105
|
|
|
105
|
-
executeCommand(cmdOptions
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
await executeCommand(cmdOptions);
|
|
107
|
+
|
|
108
|
+
return { dest };
|
|
108
109
|
};
|
package/src/utils/put.ts
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import
|
|
4
|
+
import got from 'got';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
async function put(
|
|
7
7
|
urlPath: string,
|
|
8
8
|
files: string | string[],
|
|
9
|
-
headers:
|
|
10
|
-
|
|
11
|
-
| ((err: Error | string | null, data: any) => void),
|
|
12
|
-
callback: (err: Error | string | null, data: any) => void
|
|
13
|
-
): void {
|
|
14
|
-
if (typeof headers === 'function') {
|
|
15
|
-
callback = headers;
|
|
16
|
-
headers = {};
|
|
17
|
-
}
|
|
18
|
-
|
|
9
|
+
headers: Record<string, string | string[] | undefined>
|
|
10
|
+
): Promise<string> {
|
|
19
11
|
const form = new FormData();
|
|
20
|
-
const options = { ...url.parse(urlPath), method: 'PUT', headers: {} };
|
|
21
|
-
let body = '';
|
|
22
|
-
let callbackDone = false;
|
|
23
12
|
|
|
24
13
|
if (!Array.isArray(files)) {
|
|
25
14
|
files = [files];
|
|
@@ -30,28 +19,17 @@ export default function put(
|
|
|
30
19
|
form.append(fileName, fs.createReadStream(file));
|
|
31
20
|
});
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return callback(err, undefined as any);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
res.on('data', chunk => {
|
|
42
|
-
body += chunk;
|
|
43
|
-
});
|
|
22
|
+
const res = await got(urlPath, {
|
|
23
|
+
headers: { ...headers, ...form.getHeaders() },
|
|
24
|
+
method: 'PUT',
|
|
25
|
+
body: form
|
|
26
|
+
});
|
|
44
27
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
if (res.statusCode !== 200) {
|
|
29
|
+
throw res.body;
|
|
30
|
+
}
|
|
48
31
|
|
|
49
|
-
|
|
50
|
-
callback(body, undefined as any);
|
|
51
|
-
} else {
|
|
52
|
-
callback(null, body);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
32
|
+
return res.body;
|
|
57
33
|
}
|
|
34
|
+
|
|
35
|
+
export default put;
|