@backstage-community/plugin-npm-common 1.7.0 → 1.9.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
# @backstage-community/plugin-npm-common
|
|
2
2
|
|
|
3
|
+
## 1.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9df5e2a: Add new npm registry option `extraRequestHeaders` to pass for example non-standard authentification headers.
|
|
8
|
+
|
|
9
|
+
## 1.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 4bfc2ec: Backstage version bump to v1.40.1
|
|
14
|
+
|
|
3
15
|
## 1.7.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
6
18
|
|
|
7
|
-
- c42ca51: Backstage version bump to v1.39.
|
|
19
|
+
- c42ca51: Backstage version bump to v1.39.1
|
|
8
20
|
|
|
9
21
|
## 1.6.0
|
|
10
22
|
|
|
@@ -6,10 +6,12 @@ class NpmRegistryClient {
|
|
|
6
6
|
fetch;
|
|
7
7
|
baseUrl;
|
|
8
8
|
token;
|
|
9
|
+
extraRequestHeaders;
|
|
9
10
|
constructor(options) {
|
|
10
11
|
this.fetch = options?.fetch || global.fetch.bind(global);
|
|
11
12
|
this.baseUrl = options.baseUrl || "https://registry.npmjs.com";
|
|
12
13
|
this.token = options.token;
|
|
14
|
+
this.extraRequestHeaders = options.extraRequestHeaders;
|
|
13
15
|
}
|
|
14
16
|
async getPackageInfo(packageName) {
|
|
15
17
|
if (!packageName) {
|
|
@@ -17,7 +19,10 @@ class NpmRegistryClient {
|
|
|
17
19
|
}
|
|
18
20
|
const url = `${this.baseUrl}/${encodeURIComponent(packageName)}`;
|
|
19
21
|
const response = await this.fetch(url, {
|
|
20
|
-
headers:
|
|
22
|
+
headers: {
|
|
23
|
+
...this.extraRequestHeaders,
|
|
24
|
+
...this.token ? { Authorization: this.token } : undefined
|
|
25
|
+
}
|
|
21
26
|
});
|
|
22
27
|
if (!response.ok) {
|
|
23
28
|
throw await errors.ResponseError.fromResponse(response);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NpmRegistryClient.cjs.js","sources":["../src/NpmRegistryClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ResponseError } from '@backstage/errors';\n\nimport { NpmRegistryPackageInfo } from './types';\n\n/**\n * @public\n */\nexport class NpmRegistryClient {\n private readonly fetch: typeof fetch;\n private readonly baseUrl: string;\n private readonly token?: string;\n\n constructor(options: {\n fetch?: typeof fetch;\n baseUrl?: string;\n token?: string;\n }) {\n this.fetch = options?.fetch || global.fetch.bind(global);\n this.baseUrl = options.baseUrl || 'https://registry.npmjs.com';\n this.token = options.token;\n }\n\n async getPackageInfo(packageName: string): Promise<NpmRegistryPackageInfo> {\n if (!packageName) {\n throw new Error('No package name provided');\n }\n\n const url = `${this.baseUrl}/${encodeURIComponent(packageName)}`;\n\n const response = await this.fetch(url, {\n headers: this.token ? { Authorization: this.token } : undefined,\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n return response.json();\n }\n}\n"],"names":["ResponseError"],"mappings":";;;;AAsBO,MAAM,iBAAkB,CAAA;AAAA,EACZ,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EAEjB,YAAY,
|
|
1
|
+
{"version":3,"file":"NpmRegistryClient.cjs.js","sources":["../src/NpmRegistryClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ResponseError } from '@backstage/errors';\n\nimport { NpmRegistryPackageInfo } from './types';\n\n/**\n * @public\n */\nexport class NpmRegistryClient {\n private readonly fetch: typeof fetch;\n private readonly baseUrl: string;\n private readonly token?: string;\n private readonly extraRequestHeaders?: Record<string, string>;\n\n constructor(options: {\n fetch?: typeof fetch;\n baseUrl?: string;\n token?: string;\n extraRequestHeaders?: Record<string, string>;\n }) {\n this.fetch = options?.fetch || global.fetch.bind(global);\n this.baseUrl = options.baseUrl || 'https://registry.npmjs.com';\n this.token = options.token;\n this.extraRequestHeaders = options.extraRequestHeaders;\n }\n\n async getPackageInfo(packageName: string): Promise<NpmRegistryPackageInfo> {\n if (!packageName) {\n throw new Error('No package name provided');\n }\n\n const url = `${this.baseUrl}/${encodeURIComponent(packageName)}`;\n\n const response = await this.fetch(url, {\n headers: {\n ...this.extraRequestHeaders,\n ...(this.token ? { Authorization: this.token } : undefined),\n },\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n return response.json();\n }\n}\n"],"names":["ResponseError"],"mappings":";;;;AAsBO,MAAM,iBAAkB,CAAA;AAAA,EACZ,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,mBAAA;AAAA,EAEjB,YAAY,OAKT,EAAA;AACD,IAAA,IAAA,CAAK,QAAQ,OAAS,EAAA,KAAA,IAAS,MAAO,CAAA,KAAA,CAAM,KAAK,MAAM,CAAA;AACvD,IAAK,IAAA,CAAA,OAAA,GAAU,QAAQ,OAAW,IAAA,4BAAA;AAClC,IAAA,IAAA,CAAK,QAAQ,OAAQ,CAAA,KAAA;AACrB,IAAA,IAAA,CAAK,sBAAsB,OAAQ,CAAA,mBAAA;AAAA;AACrC,EAEA,MAAM,eAAe,WAAsD,EAAA;AACzE,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA;AAAA;AAG5C,IAAA,MAAM,MAAM,CAAG,EAAA,IAAA,CAAK,OAAO,CAAI,CAAA,EAAA,kBAAA,CAAmB,WAAW,CAAC,CAAA,CAAA;AAE9D,IAAA,MAAM,QAAW,GAAA,MAAM,IAAK,CAAA,KAAA,CAAM,GAAK,EAAA;AAAA,MACrC,OAAS,EAAA;AAAA,QACP,GAAG,IAAK,CAAA,mBAAA;AAAA,QACR,GAAI,IAAK,CAAA,KAAA,GAAQ,EAAE,aAAe,EAAA,IAAA,CAAK,OAAU,GAAA;AAAA;AACnD,KACD,CAAA;AAED,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAM,MAAA,MAAMA,oBAAc,CAAA,YAAA,CAAa,QAAQ,CAAA;AAAA;AAEjD,IAAA,OAAO,SAAS,IAAK,EAAA;AAAA;AAEzB;;;;"}
|
|
@@ -4,10 +4,12 @@ class NpmRegistryClient {
|
|
|
4
4
|
fetch;
|
|
5
5
|
baseUrl;
|
|
6
6
|
token;
|
|
7
|
+
extraRequestHeaders;
|
|
7
8
|
constructor(options) {
|
|
8
9
|
this.fetch = options?.fetch || global.fetch.bind(global);
|
|
9
10
|
this.baseUrl = options.baseUrl || "https://registry.npmjs.com";
|
|
10
11
|
this.token = options.token;
|
|
12
|
+
this.extraRequestHeaders = options.extraRequestHeaders;
|
|
11
13
|
}
|
|
12
14
|
async getPackageInfo(packageName) {
|
|
13
15
|
if (!packageName) {
|
|
@@ -15,7 +17,10 @@ class NpmRegistryClient {
|
|
|
15
17
|
}
|
|
16
18
|
const url = `${this.baseUrl}/${encodeURIComponent(packageName)}`;
|
|
17
19
|
const response = await this.fetch(url, {
|
|
18
|
-
headers:
|
|
20
|
+
headers: {
|
|
21
|
+
...this.extraRequestHeaders,
|
|
22
|
+
...this.token ? { Authorization: this.token } : undefined
|
|
23
|
+
}
|
|
19
24
|
});
|
|
20
25
|
if (!response.ok) {
|
|
21
26
|
throw await ResponseError.fromResponse(response);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NpmRegistryClient.esm.js","sources":["../src/NpmRegistryClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ResponseError } from '@backstage/errors';\n\nimport { NpmRegistryPackageInfo } from './types';\n\n/**\n * @public\n */\nexport class NpmRegistryClient {\n private readonly fetch: typeof fetch;\n private readonly baseUrl: string;\n private readonly token?: string;\n\n constructor(options: {\n fetch?: typeof fetch;\n baseUrl?: string;\n token?: string;\n }) {\n this.fetch = options?.fetch || global.fetch.bind(global);\n this.baseUrl = options.baseUrl || 'https://registry.npmjs.com';\n this.token = options.token;\n }\n\n async getPackageInfo(packageName: string): Promise<NpmRegistryPackageInfo> {\n if (!packageName) {\n throw new Error('No package name provided');\n }\n\n const url = `${this.baseUrl}/${encodeURIComponent(packageName)}`;\n\n const response = await this.fetch(url, {\n headers: this.token ? { Authorization: this.token } : undefined,\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n return response.json();\n }\n}\n"],"names":[],"mappings":";;AAsBO,MAAM,iBAAkB,CAAA;AAAA,EACZ,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EAEjB,YAAY,
|
|
1
|
+
{"version":3,"file":"NpmRegistryClient.esm.js","sources":["../src/NpmRegistryClient.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ResponseError } from '@backstage/errors';\n\nimport { NpmRegistryPackageInfo } from './types';\n\n/**\n * @public\n */\nexport class NpmRegistryClient {\n private readonly fetch: typeof fetch;\n private readonly baseUrl: string;\n private readonly token?: string;\n private readonly extraRequestHeaders?: Record<string, string>;\n\n constructor(options: {\n fetch?: typeof fetch;\n baseUrl?: string;\n token?: string;\n extraRequestHeaders?: Record<string, string>;\n }) {\n this.fetch = options?.fetch || global.fetch.bind(global);\n this.baseUrl = options.baseUrl || 'https://registry.npmjs.com';\n this.token = options.token;\n this.extraRequestHeaders = options.extraRequestHeaders;\n }\n\n async getPackageInfo(packageName: string): Promise<NpmRegistryPackageInfo> {\n if (!packageName) {\n throw new Error('No package name provided');\n }\n\n const url = `${this.baseUrl}/${encodeURIComponent(packageName)}`;\n\n const response = await this.fetch(url, {\n headers: {\n ...this.extraRequestHeaders,\n ...(this.token ? { Authorization: this.token } : undefined),\n },\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n return response.json();\n }\n}\n"],"names":[],"mappings":";;AAsBO,MAAM,iBAAkB,CAAA;AAAA,EACZ,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,mBAAA;AAAA,EAEjB,YAAY,OAKT,EAAA;AACD,IAAA,IAAA,CAAK,QAAQ,OAAS,EAAA,KAAA,IAAS,MAAO,CAAA,KAAA,CAAM,KAAK,MAAM,CAAA;AACvD,IAAK,IAAA,CAAA,OAAA,GAAU,QAAQ,OAAW,IAAA,4BAAA;AAClC,IAAA,IAAA,CAAK,QAAQ,OAAQ,CAAA,KAAA;AACrB,IAAA,IAAA,CAAK,sBAAsB,OAAQ,CAAA,mBAAA;AAAA;AACrC,EAEA,MAAM,eAAe,WAAsD,EAAA;AACzE,IAAA,IAAI,CAAC,WAAa,EAAA;AAChB,MAAM,MAAA,IAAI,MAAM,0BAA0B,CAAA;AAAA;AAG5C,IAAA,MAAM,MAAM,CAAG,EAAA,IAAA,CAAK,OAAO,CAAI,CAAA,EAAA,kBAAA,CAAmB,WAAW,CAAC,CAAA,CAAA;AAE9D,IAAA,MAAM,QAAW,GAAA,MAAM,IAAK,CAAA,KAAA,CAAM,GAAK,EAAA;AAAA,MACrC,OAAS,EAAA;AAAA,QACP,GAAG,IAAK,CAAA,mBAAA;AAAA,QACR,GAAI,IAAK,CAAA,KAAA,GAAQ,EAAE,aAAe,EAAA,IAAA,CAAK,OAAU,GAAA;AAAA;AACnD,KACD,CAAA;AAED,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAM,MAAA,MAAM,aAAc,CAAA,YAAA,CAAa,QAAQ,CAAA;AAAA;AAEjD,IAAA,OAAO,SAAS,IAAK,EAAA;AAAA;AAEzB;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -74,10 +74,12 @@ declare class NpmRegistryClient {
|
|
|
74
74
|
private readonly fetch;
|
|
75
75
|
private readonly baseUrl;
|
|
76
76
|
private readonly token?;
|
|
77
|
+
private readonly extraRequestHeaders?;
|
|
77
78
|
constructor(options: {
|
|
78
79
|
fetch?: typeof fetch;
|
|
79
80
|
baseUrl?: string;
|
|
80
81
|
token?: string;
|
|
82
|
+
extraRequestHeaders?: Record<string, string>;
|
|
81
83
|
});
|
|
82
84
|
getPackageInfo(packageName: string): Promise<NpmRegistryPackageInfo>;
|
|
83
85
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-npm-common",
|
|
3
3
|
"description": "Common functionalities for the npm plugin",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@backstage/errors": "^1.2.7"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@backstage/cli": "^0.
|
|
42
|
+
"@backstage/cli": "^0.33.0"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
|
45
45
|
"dist"
|