oc 0.49.6 → 0.49.9
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 +26 -0
- package/README.md +2 -15
- package/dist/cli/commands.d.ts +163 -163
- package/dist/cli/commands.js +162 -162
- package/dist/cli/domain/clean.d.ts +2 -2
- package/dist/cli/domain/clean.js +24 -27
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +41 -48
- package/dist/cli/domain/get-mocked-plugins.d.ts +10 -10
- package/dist/cli/domain/get-mocked-plugins.js +89 -87
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js +16 -17
- package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +10 -10
- package/dist/cli/domain/handle-dependencies/get-compiler.js +28 -28
- package/dist/cli/domain/handle-dependencies/get-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/get-missing-dependencies.js +18 -18
- package/dist/cli/domain/handle-dependencies/index.d.ts +10 -9
- package/dist/cli/domain/handle-dependencies/index.js +70 -64
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +8 -8
- package/dist/cli/domain/handle-dependencies/install-compiler.js +54 -47
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +59 -55
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +32 -36
- package/dist/cli/domain/handle-dependencies/require-template.d.ts +17 -17
- package/dist/cli/domain/handle-dependencies/require-template.js +34 -34
- package/dist/cli/domain/init-template/index.d.ts +10 -10
- package/dist/cli/domain/init-template/index.js +40 -42
- package/dist/cli/domain/init-template/install-template.d.ts +11 -11
- package/dist/cli/domain/init-template/install-template.js +54 -53
- package/dist/cli/domain/init-template/scaffold.d.ts +11 -11
- package/dist/cli/domain/init-template/scaffold.js +30 -30
- package/dist/cli/domain/local.d.ts +2 -2
- package/dist/cli/domain/local.js +82 -81
- package/dist/cli/domain/mock.d.ts +5 -5
- package/dist/cli/domain/mock.js +33 -33
- package/dist/cli/domain/package-components.d.ts +9 -9
- package/dist/cli/domain/package-components.js +67 -70
- package/dist/cli/domain/registry.d.ts +6 -6
- package/dist/cli/domain/registry.js +136 -149
- package/dist/cli/domain/url-parser.d.ts +14 -14
- package/dist/cli/domain/url-parser.js +31 -31
- package/dist/cli/domain/watch.d.ts +1 -1
- package/dist/cli/domain/watch.js +29 -29
- package/dist/cli/facade/clean.d.ts +16 -10
- package/dist/cli/facade/clean.js +58 -48
- package/dist/cli/facade/dev.d.ts +114 -21
- package/dist/cli/facade/dev.js +176 -190
- package/dist/cli/facade/init.d.ts +18 -11
- package/dist/cli/facade/init.js +39 -37
- package/dist/cli/facade/mock.d.ts +18 -11
- package/dist/cli/facade/mock.js +12 -13
- package/dist/cli/facade/package.d.ts +18 -11
- package/dist/cli/facade/package.js +49 -51
- package/dist/cli/facade/preview.d.ts +14 -9
- package/dist/cli/facade/preview.js +20 -18
- package/dist/cli/facade/publish.d.ts +23 -14
- package/dist/cli/facade/publish.js +145 -165
- package/dist/cli/facade/registry-add.d.ts +14 -9
- package/dist/cli/facade/registry-add.js +18 -17
- package/dist/cli/facade/registry-ls.d.ts +10 -7
- package/dist/cli/facade/registry-ls.js +27 -25
- package/dist/cli/facade/registry-remove.d.ts +14 -9
- package/dist/cli/facade/registry-remove.js +18 -17
- package/dist/cli/facade/registry.d.ts +5 -2
- package/dist/cli/facade/registry.js +9 -6
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +91 -93
- package/dist/cli/logger.d.ts +8 -8
- package/dist/cli/logger.js +19 -19
- package/dist/cli/programmatic-api.d.ts +84 -84
- package/dist/cli/programmatic-api.js +66 -66
- package/dist/cli/validate-command.d.ts +2 -2
- package/dist/cli/validate-command.js +18 -18
- package/dist/components/oc-client/_package/package.json +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -12
- package/dist/oc-cli.d.ts +2 -2
- package/dist/oc-cli.js +3 -3
- package/dist/registry/app-start.d.ts +2 -2
- package/dist/registry/app-start.js +44 -44
- package/dist/registry/domain/authentication.d.ts +7 -8
- package/dist/registry/domain/authentication.js +53 -50
- package/dist/registry/domain/components-cache/components-list.d.ts +8 -7
- package/dist/registry/domain/components-cache/components-list.js +50 -64
- package/dist/registry/domain/components-cache/index.d.ts +7 -6
- package/dist/registry/domain/components-cache/index.js +76 -79
- package/dist/registry/domain/components-details.d.ts +6 -5
- package/dist/registry/domain/components-details.js +64 -75
- package/dist/registry/domain/events-handler.d.ts +40 -40
- package/dist/registry/domain/events-handler.js +37 -37
- package/dist/registry/domain/extract-package.d.ts +8 -8
- package/dist/registry/domain/extract-package.js +26 -29
- package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +2 -2
- package/dist/registry/domain/get-package-json-from-temp-dir.js +11 -11
- package/dist/registry/domain/nested-renderer.d.ts +14 -13
- package/dist/registry/domain/nested-renderer.js +59 -95
- package/dist/registry/domain/options-sanitiser.d.ts +6 -6
- package/dist/registry/domain/options-sanitiser.js +106 -104
- package/dist/registry/domain/plugins-initialiser.d.ts +3 -1
- package/dist/registry/domain/plugins-initialiser.js +95 -99
- package/dist/registry/domain/register-templates.d.ts +5 -5
- package/dist/registry/domain/register-templates.js +30 -30
- package/dist/registry/domain/repository.d.ts +2 -2
- package/dist/registry/domain/repository.js +237 -259
- package/dist/registry/domain/require-wrapper.d.ts +2 -2
- package/dist/registry/domain/require-wrapper.js +33 -34
- package/dist/registry/domain/sanitiser.d.ts +2 -2
- package/dist/registry/domain/sanitiser.js +52 -52
- package/dist/registry/domain/storage-adapter.d.ts +10 -0
- package/dist/registry/domain/storage-adapter.js +55 -0
- package/dist/registry/domain/url-builder.d.ts +10 -10
- package/dist/registry/domain/url-builder.js +60 -60
- package/dist/registry/domain/validators/component-parameters.d.ts +11 -11
- package/dist/registry/domain/validators/component-parameters.js +79 -79
- package/dist/registry/domain/validators/index.d.ts +16 -16
- package/dist/registry/domain/validators/index.js +29 -29
- package/dist/registry/domain/validators/node-version.d.ts +15 -15
- package/dist/registry/domain/validators/node-version.js +40 -40
- package/dist/registry/domain/validators/oc-cli-version.d.ts +15 -15
- package/dist/registry/domain/validators/oc-cli-version.js +34 -34
- package/dist/registry/domain/validators/package-json-validator.d.ts +13 -13
- package/dist/registry/domain/validators/package-json-validator.js +23 -23
- package/dist/registry/domain/validators/plugins-requirements.d.ts +9 -9
- package/dist/registry/domain/validators/plugins-requirements.js +22 -22
- package/dist/registry/domain/validators/registry-configuration.d.ts +9 -9
- package/dist/registry/domain/validators/registry-configuration.js +113 -113
- package/dist/registry/domain/validators/uploaded-package.d.ts +14 -14
- package/dist/registry/domain/validators/uploaded-package.js +25 -25
- package/dist/registry/domain/version-handler.d.ts +2 -2
- package/dist/registry/domain/version-handler.js +22 -22
- package/dist/registry/index.d.ts +48 -48
- package/dist/registry/index.js +107 -120
- package/dist/registry/middleware/base-url-handler.d.ts +2 -2
- package/dist/registry/middleware/base-url-handler.js +12 -12
- package/dist/registry/middleware/cors.d.ts +2 -2
- package/dist/registry/middleware/cors.js +11 -11
- package/dist/registry/middleware/discovery-handler.d.ts +2 -2
- package/dist/registry/middleware/discovery-handler.js +15 -15
- package/dist/registry/middleware/file-uploads.d.ts +2 -2
- package/dist/registry/middleware/file-uploads.js +23 -23
- package/dist/registry/middleware/index.d.ts +7 -3
- package/dist/registry/middleware/index.js +51 -47
- package/dist/registry/middleware/request-handler.d.ts +2 -2
- package/dist/registry/middleware/request-handler.js +30 -30
- package/dist/registry/router.d.ts +3 -3
- package/dist/registry/router.js +56 -58
- package/dist/registry/routes/component-info.d.ts +3 -3
- package/dist/registry/routes/component-info.js +90 -89
- package/dist/registry/routes/component-preview.d.ts +3 -3
- package/dist/registry/routes/component-preview.js +68 -67
- package/dist/registry/routes/component.d.ts +3 -3
- package/dist/registry/routes/component.js +43 -43
- package/dist/registry/routes/components.d.ts +3 -3
- package/dist/registry/routes/components.js +78 -78
- package/dist/registry/routes/dependencies.d.ts +3 -3
- package/dist/registry/routes/dependencies.js +28 -28
- package/dist/registry/routes/helpers/apply-default-values.d.ts +2 -2
- package/dist/registry/routes/helpers/apply-default-values.js +13 -13
- package/dist/registry/routes/helpers/get-available-dependencies.d.ts +8 -8
- package/dist/registry/routes/helpers/get-available-dependencies.js +24 -24
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +17 -22
- package/dist/registry/routes/helpers/get-component-fallback.js +91 -91
- package/dist/registry/routes/helpers/get-component-retrieving-info.d.ts +20 -20
- package/dist/registry/routes/helpers/get-component-retrieving-info.js +24 -24
- package/dist/registry/routes/helpers/get-component.d.ts +33 -33
- package/dist/registry/routes/helpers/get-component.js +406 -405
- package/dist/registry/routes/helpers/get-components-history.d.ts +8 -8
- package/dist/registry/routes/helpers/get-components-history.js +28 -28
- package/dist/registry/routes/helpers/is-url-discoverable.d.ts +3 -3
- package/dist/registry/routes/helpers/is-url-discoverable.js +22 -16
- package/dist/registry/routes/index.d.ts +3 -3
- package/dist/registry/routes/index.js +93 -92
- package/dist/registry/routes/plugins.d.ts +3 -3
- package/dist/registry/routes/plugins.js +17 -17
- package/dist/registry/routes/publish.d.ts +3 -3
- package/dist/registry/routes/publish.js +97 -96
- package/dist/registry/routes/static-redirector.d.ts +3 -3
- package/dist/registry/routes/static-redirector.js +63 -63
- package/dist/registry/views/index.d.ts +2 -2
- package/dist/registry/views/index.js +39 -39
- package/dist/registry/views/info.d.ts +16 -16
- package/dist/registry/views/info.js +44 -41
- package/dist/registry/views/partials/component-author.d.ts +8 -8
- package/dist/registry/views/partials/component-author.js +20 -20
- package/dist/registry/views/partials/component-parameters.d.ts +5 -5
- package/dist/registry/views/partials/component-parameters.js +24 -24
- package/dist/registry/views/partials/component-state.d.ts +5 -5
- package/dist/registry/views/partials/component-state.js +6 -6
- package/dist/registry/views/partials/component-versions.d.ts +5 -5
- package/dist/registry/views/partials/component-versions.js +9 -9
- package/dist/registry/views/partials/components-dependencies.d.ts +2 -2
- package/dist/registry/views/partials/components-dependencies.js +12 -12
- package/dist/registry/views/partials/components-history.d.ts +2 -2
- package/dist/registry/views/partials/components-history.js +10 -10
- package/dist/registry/views/partials/components-list.d.ts +2 -2
- package/dist/registry/views/partials/components-list.js +26 -26
- package/dist/registry/views/partials/components-plugins.d.ts +2 -2
- package/dist/registry/views/partials/components-plugins.js +8 -8
- package/dist/registry/views/partials/components-templates.d.ts +2 -2
- package/dist/registry/views/partials/components-templates.js +14 -14
- package/dist/registry/views/partials/layout.d.ts +8 -8
- package/dist/registry/views/partials/layout.js +11 -11
- package/dist/registry/views/partials/property.d.ts +2 -2
- package/dist/registry/views/partials/property.js +11 -11
- package/dist/registry/views/partials/selected-checkbox.d.ts +4 -4
- package/dist/registry/views/partials/selected-checkbox.js +7 -7
- package/dist/registry/views/preview.d.ts +8 -8
- package/dist/registry/views/preview.js +9 -9
- package/dist/registry/views/static/index.d.ts +2 -2
- package/dist/registry/views/static/index.js +3 -3
- package/dist/registry/views/static/info.d.ts +2 -2
- package/dist/registry/views/static/info.js +15 -4
- package/dist/registry/views/static/style.d.ts +2 -2
- package/dist/registry/views/static/style.js +3 -3
- package/dist/resources/index.d.ts +134 -134
- package/dist/resources/index.js +145 -145
- package/dist/resources/settings.d.ts +17 -17
- package/dist/resources/settings.js +18 -18
- package/dist/types.d.ts +287 -285
- package/dist/types.js +2 -2
- package/dist/utils/clean-require.d.ts +16 -16
- package/dist/utils/clean-require.js +18 -18
- package/dist/utils/date-stringify.d.ts +1 -1
- package/dist/utils/date-stringify.js +22 -22
- package/dist/utils/error-to-string.d.ts +1 -1
- package/dist/utils/error-to-string.js +15 -15
- package/dist/utils/is-template-legacy.d.ts +3 -3
- package/dist/utils/is-template-legacy.js +6 -6
- package/dist/utils/is-template-valid.d.ts +4 -4
- package/dist/utils/is-template-valid.js +12 -12
- package/dist/utils/module-exists.d.ts +1 -1
- package/dist/utils/module-exists.js +15 -15
- package/dist/utils/npm-utils.d.ts +20 -22
- package/dist/utils/npm-utils.js +74 -63
- package/dist/utils/put.d.ts +2 -1
- package/dist/utils/put.js +29 -48
- package/dist/utils/strip-version.d.ts +1 -1
- package/dist/utils/strip-version.js +11 -11
- 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/oc-cli.js +0 -0
- package/src/registry/app-start.ts +27 -31
- package/src/registry/domain/authentication.ts +5 -13
- 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/registry/views/info.ts +5 -2
- package/src/registry/views/static/info.ts +12 -1
- package/src/resources/settings.ts +1 -1
- package/src/types.ts +80 -141
- 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;
|
|
@@ -113,6 +123,22 @@ export interface VM {
|
|
|
113
123
|
type: 'oc-registry' | 'oc-registry-local';
|
|
114
124
|
}
|
|
115
125
|
|
|
126
|
+
export type Authentication<T = any> = {
|
|
127
|
+
validate: (config: T) => {
|
|
128
|
+
isValid: boolean;
|
|
129
|
+
message: string;
|
|
130
|
+
};
|
|
131
|
+
middleware: (config: T) => any;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type PublishAuthConfig =
|
|
135
|
+
| {
|
|
136
|
+
type: 'basic';
|
|
137
|
+
username: string;
|
|
138
|
+
password: string;
|
|
139
|
+
}
|
|
140
|
+
| ({ type: string | Authentication } & Record<string, any>);
|
|
141
|
+
|
|
116
142
|
export interface Config {
|
|
117
143
|
baseUrl: string;
|
|
118
144
|
baseUrlFunc?: (opts: { host?: string; secure: boolean }) => string;
|
|
@@ -135,11 +161,7 @@ export interface Config {
|
|
|
135
161
|
port: number | string;
|
|
136
162
|
postRequestPayloadSize?: number;
|
|
137
163
|
prefix: string;
|
|
138
|
-
publishAuth?:
|
|
139
|
-
type: string;
|
|
140
|
-
username: string;
|
|
141
|
-
password: string;
|
|
142
|
-
};
|
|
164
|
+
publishAuth?: PublishAuthConfig;
|
|
143
165
|
publishValidation: (data: unknown) =>
|
|
144
166
|
| {
|
|
145
167
|
isValid: boolean;
|
|
@@ -169,36 +191,6 @@ export interface Config {
|
|
|
169
191
|
verbosity: number;
|
|
170
192
|
}
|
|
171
193
|
|
|
172
|
-
export interface Cdn {
|
|
173
|
-
adapterType: string;
|
|
174
|
-
getFile: (
|
|
175
|
-
filePath: string,
|
|
176
|
-
cb: (err: Error | null, data: string) => void
|
|
177
|
-
) => void;
|
|
178
|
-
getJson<T>(
|
|
179
|
-
filePath: string,
|
|
180
|
-
force: boolean,
|
|
181
|
-
cb: (err: string | null, data: T) => void
|
|
182
|
-
): void;
|
|
183
|
-
getJson<T>(filePath: string, cb: (err: string | null, data: T) => void): void;
|
|
184
|
-
listSubDirectories: (
|
|
185
|
-
dir: string,
|
|
186
|
-
cb: (err: (Error & { code?: string }) | null, data: string[]) => void
|
|
187
|
-
) => void;
|
|
188
|
-
maxConcurrentRequests: number;
|
|
189
|
-
putDir: (
|
|
190
|
-
folderPath: string,
|
|
191
|
-
filePath: string,
|
|
192
|
-
cb: (err: Error | null) => void
|
|
193
|
-
) => void;
|
|
194
|
-
putFileContent: (
|
|
195
|
-
data: unknown,
|
|
196
|
-
path: string,
|
|
197
|
-
isPrivate: boolean,
|
|
198
|
-
callback: (err: string | null, data: unknown) => void
|
|
199
|
-
) => void;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
194
|
type CompiledTemplate = (model: unknown) => string;
|
|
203
195
|
|
|
204
196
|
interface CompilerOptions {
|
|
@@ -229,7 +221,7 @@ export interface Template {
|
|
|
229
221
|
}
|
|
230
222
|
|
|
231
223
|
export interface Plugin {
|
|
232
|
-
callback?: (
|
|
224
|
+
callback?: (error: unknown) => void;
|
|
233
225
|
description?: string;
|
|
234
226
|
name: string;
|
|
235
227
|
options?: any;
|
|
@@ -237,7 +229,7 @@ export interface Plugin {
|
|
|
237
229
|
register: (
|
|
238
230
|
options: unknown,
|
|
239
231
|
dependencies: unknown,
|
|
240
|
-
next: () => void
|
|
232
|
+
next: (error?: unknown) => void
|
|
241
233
|
) => void;
|
|
242
234
|
execute: (...args: unknown[]) => unknown;
|
|
243
235
|
dependencies?: string[];
|
|
@@ -245,120 +237,73 @@ export interface Plugin {
|
|
|
245
237
|
}
|
|
246
238
|
|
|
247
239
|
export interface RegistryCli {
|
|
248
|
-
add(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
):
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
callback: (err: Error | number | null, data: string) => void
|
|
260
|
-
): void;
|
|
261
|
-
putComponent(
|
|
262
|
-
options: {
|
|
263
|
-
username?: string;
|
|
264
|
-
password?: string;
|
|
265
|
-
route: string;
|
|
266
|
-
path: string;
|
|
267
|
-
},
|
|
268
|
-
callback: (err: string | null, data: unknown) => void
|
|
269
|
-
): void;
|
|
270
|
-
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>;
|
|
271
251
|
}
|
|
272
252
|
|
|
273
253
|
export interface Local {
|
|
274
254
|
clean: {
|
|
275
|
-
fetchList: (
|
|
276
|
-
|
|
277
|
-
callback: (err: Error | null, data: string[]) => void
|
|
278
|
-
) => void;
|
|
279
|
-
remove: (
|
|
280
|
-
list: string[],
|
|
281
|
-
callback: (err: Error | null, data: string) => void
|
|
282
|
-
) => void;
|
|
255
|
+
fetchList: (dirPath: string) => Promise<string[]>;
|
|
256
|
+
remove: (list: string[]) => Promise<void>;
|
|
283
257
|
};
|
|
284
|
-
cleanup: (
|
|
285
|
-
|
|
286
|
-
cb: (err: NodeJS.ErrnoException) => void
|
|
287
|
-
) => void;
|
|
288
|
-
compress: (
|
|
289
|
-
input: string,
|
|
290
|
-
output: string,
|
|
291
|
-
cb: (error: Error | string | null) => void
|
|
292
|
-
) => void;
|
|
258
|
+
cleanup: (compressedPackagePath: string) => Promise<void>;
|
|
259
|
+
compress: (input: string, output: string) => Promise<void>;
|
|
293
260
|
getComponentsByDir: (
|
|
294
261
|
componentsDir: string,
|
|
295
|
-
componentsToRun
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
minify?: boolean;
|
|
315
|
-
verbose?: boolean;
|
|
316
|
-
production?: boolean;
|
|
317
|
-
},
|
|
318
|
-
callback: (err: Error | null, data: Component) => void
|
|
319
|
-
) => 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>;
|
|
320
281
|
}
|
|
321
282
|
|
|
322
283
|
export interface Repository {
|
|
323
284
|
getCompiledView(
|
|
324
285
|
componentName: string,
|
|
325
|
-
componentVersion: string
|
|
326
|
-
|
|
327
|
-
): void;
|
|
286
|
+
componentVersion: string
|
|
287
|
+
): Promise<string>;
|
|
328
288
|
getComponent(
|
|
329
289
|
componentName: string,
|
|
330
|
-
componentVersion
|
|
331
|
-
|
|
332
|
-
): void;
|
|
333
|
-
getComponent(
|
|
334
|
-
componentName: string,
|
|
335
|
-
calllback: (err: string | null, data: Component) => void
|
|
336
|
-
): void;
|
|
290
|
+
componentVersion?: string
|
|
291
|
+
): Promise<Component>;
|
|
337
292
|
getComponentInfo(
|
|
338
293
|
componentName: string,
|
|
339
|
-
componentVersion: string
|
|
340
|
-
|
|
341
|
-
): void;
|
|
294
|
+
componentVersion: string
|
|
295
|
+
): Promise<Component>;
|
|
342
296
|
getComponentPath(componentName: string, componentVersion: string): void;
|
|
343
|
-
getComponents(
|
|
344
|
-
getComponentsDetails(
|
|
345
|
-
|
|
346
|
-
): void;
|
|
347
|
-
getComponentVersions(
|
|
348
|
-
componentName: string,
|
|
349
|
-
callback: (err: string | null, data: string[]) => void
|
|
350
|
-
): void;
|
|
297
|
+
getComponents(): Promise<string[]>;
|
|
298
|
+
getComponentsDetails(): Promise<ComponentsDetails>;
|
|
299
|
+
getComponentVersions(componentName: string): Promise<string[]>;
|
|
351
300
|
getDataProvider(
|
|
352
301
|
componentName: string,
|
|
353
|
-
componentVersion: string
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
filePath: string;
|
|
359
|
-
}
|
|
360
|
-
) => void
|
|
361
|
-
): void;
|
|
302
|
+
componentVersion: string
|
|
303
|
+
): Promise<{
|
|
304
|
+
content: string;
|
|
305
|
+
filePath: string;
|
|
306
|
+
}>;
|
|
362
307
|
getStaticClientMapPath: () => string;
|
|
363
308
|
getStaticClientPath: () => string;
|
|
364
309
|
getStaticFilePath: (
|
|
@@ -368,18 +313,12 @@ export interface Repository {
|
|
|
368
313
|
) => string;
|
|
369
314
|
getTemplate: (type: string) => Template;
|
|
370
315
|
getTemplatesInfo: () => TemplateInfo[];
|
|
371
|
-
init(
|
|
372
|
-
callback: (err: Error | null, data: ComponentsList | string) => void
|
|
373
|
-
): void;
|
|
316
|
+
init(): Promise<ComponentsList>;
|
|
374
317
|
publishComponent(
|
|
375
318
|
pkgDetails: any,
|
|
376
319
|
componentName: string,
|
|
377
|
-
componentVersion: string
|
|
378
|
-
|
|
379
|
-
err: { code: string; msg: string } | null,
|
|
380
|
-
data: ComponentsDetails
|
|
381
|
-
) => void
|
|
382
|
-
): void;
|
|
320
|
+
componentVersion: string
|
|
321
|
+
): Promise<ComponentsDetails>;
|
|
383
322
|
}
|
|
384
323
|
|
|
385
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;
|