Skip to content

Commit a6fff71

Browse files
fix: Prevent multiple versions of axios from being bundled in consumer projects (#201)
* fix: Prevent multiple versions of axios from being bundled in consumer projects Signed-off-by: Roman Nikitenko <[email protected]> * chore: resolve 'unknown' type from jsYaml.load with explicit cast Signed-off-by: Roman Nikitenko <[email protected]> --------- Signed-off-by: Roman Nikitenko <[email protected]>
1 parent cea86ea commit a6fff71

File tree

4 files changed

+14
-36
lines changed

4 files changed

+14
-36
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@
4141
"homepage": "https://github.com/eclipse-che/che-devfile-registry#readme",
4242
"dependencies": {
4343
"@devfile/api": "2.3.0-1747843475",
44-
"axios": "^1.8.3",
4544
"fs-extra": "^11.2.0",
4645
"inversify": "^7.1.0",
47-
"lodash": "^4.17.21",
4846
"js-yaml": "^4.0.0",
4947
"jsonc-parser": "^3.0.0",
5048
"jsonschema": "^1.4.1",
49+
"lodash": "^4.17.21",
5150
"reflect-metadata": "^0.2.2"
5251
},
5352
"devDependencies": {
5453
"@types/jest": "^29.5.14",
54+
"axios": "^1.8.3",
5555
"eslint": "^9.5.0",
5656
"if-env": "^1.0.4",
5757
"jest": "^29.7.0",
@@ -61,6 +61,9 @@
6161
"ts-jest": "^29.2.6",
6262
"typescript": "^5.6.2"
6363
},
64+
"peerDependencies": {
65+
"axios": "^1.8.3"
66+
},
6467
"prettier": {
6568
"printWidth": 120,
6669
"singleQuote": true,

src/generate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import * as fs from 'fs-extra';
2424
import { DevfileContext } from './api/devfile-context';
2525
import { DevContainerComponentFinder } from './devfile/dev-container-component-finder';
2626

27-
type DevfileLike = V230Devfile & {
27+
export type DevfileLike = V230Devfile & {
2828
metadata: V230DevfileMetadata & {
2929
generateName?: string;
3030
};
@@ -72,13 +72,13 @@ export class Generate {
7272
injectDefaultComponent?: string,
7373
defaultComponentImage?: string,
7474
): Promise<DevfileContext> {
75-
const devfile = jsYaml.load(devfileContent);
75+
const devfile = jsYaml.load(devfileContent) as DevfileLike;
7676

7777
// sets the suffix to the devfile name
7878
const suffix = devfile.metadata.name || '';
7979

8080
// devfile of the editor
81-
const editorDevfile = jsYaml.load(editorContent);
81+
const editorDevfile = jsYaml.load(editorContent) as DevfileLike;
8282

8383
// transform it into a devWorkspace template
8484
const metadata = this.createDevWorkspaceMetadata(editorDevfile);

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import * as axios from 'axios';
1212
import * as fs from 'fs-extra';
13-
import { Generate, DEVWORKSPACE_METADATA_ANNOTATION } from './generate';
13+
import { Generate, DEVWORKSPACE_METADATA_ANNOTATION, DevfileLike } from './generate';
1414
import { DevfileSchemaValidator } from './devfile-schema/devfile-schema-validator';
1515
import * as jsYaml from 'js-yaml';
1616
import { InversifyBinding } from './inversify/inversify-binding';
@@ -71,7 +71,7 @@ export class Main {
7171
devfileContent = await container.get(UrlFetcher).fetchText(url.getContentUrl('devfile.yaml'));
7272

7373
// load content
74-
const devfileParsed = jsYaml.load(devfileContent);
74+
const devfileParsed = jsYaml.load(devfileContent) as DevfileLike;
7575

7676
if (!devfileParsed.attributes) {
7777
devfileParsed.attributes = {};
@@ -106,7 +106,7 @@ export class Main {
106106
devfileContent = params.devfileContent;
107107
}
108108

109-
const jsYamlDevfileContent = jsYaml.load(devfileContent);
109+
const jsYamlDevfileContent = jsYaml.load(devfileContent) as DevfileLike;
110110
const schemaVersion = jsYamlDevfileContent.schemaVersion;
111111
if (!schemaVersion) {
112112
throw new Error(`Devfile is not valid, schemaVersion is required`);

yarn.lock

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,16 +3125,7 @@ string-length@^4.0.1:
31253125
char-regex "^1.0.2"
31263126
strip-ansi "^6.0.0"
31273127

3128-
"string-width-cjs@npm:string-width@^4.2.0":
3129-
version "4.2.3"
3130-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
3131-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
3132-
dependencies:
3133-
emoji-regex "^8.0.0"
3134-
is-fullwidth-code-point "^3.0.0"
3135-
strip-ansi "^6.0.1"
3136-
3137-
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
3128+
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
31383129
version "4.2.3"
31393130
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
31403131
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -3152,14 +3143,7 @@ string-width@^5.0.1, string-width@^5.1.2:
31523143
emoji-regex "^9.2.2"
31533144
strip-ansi "^7.0.1"
31543145

3155-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
3156-
version "6.0.1"
3157-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
3158-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
3159-
dependencies:
3160-
ansi-regex "^5.0.1"
3161-
3162-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
3146+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
31633147
version "6.0.1"
31643148
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
31653149
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -3381,16 +3365,7 @@ word-wrap@^1.2.5:
33813365
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
33823366
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
33833367

3384-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
3385-
version "7.0.0"
3386-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
3387-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
3388-
dependencies:
3389-
ansi-styles "^4.0.0"
3390-
string-width "^4.1.0"
3391-
strip-ansi "^6.0.0"
3392-
3393-
wrap-ansi@^7.0.0:
3368+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
33943369
version "7.0.0"
33953370
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
33963371
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

0 commit comments

Comments
 (0)