@backstage-community/plugin-npm-backend 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,32 @@
|
|
|
1
1
|
# @backstage-community/plugin-npm-backend
|
|
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
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [9df5e2a]
|
|
12
|
+
- @backstage-community/plugin-npm-common@1.9.0
|
|
13
|
+
|
|
14
|
+
## 1.8.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 4bfc2ec: Backstage version bump to v1.40.1
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [4bfc2ec]
|
|
23
|
+
- @backstage-community/plugin-npm-common@1.8.0
|
|
24
|
+
|
|
3
25
|
## 1.7.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
6
28
|
|
|
7
|
-
- c42ca51: Backstage version bump to v1.39.
|
|
29
|
+
- c42ca51: Backstage version bump to v1.39.1
|
|
8
30
|
|
|
9
31
|
### Patch Changes
|
|
10
32
|
|
package/config.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ export interface Config {
|
|
|
38
38
|
* @visibility secret
|
|
39
39
|
*/
|
|
40
40
|
token?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Extra registry headers for non-standard authentification tokens.
|
|
43
|
+
* @deepVisibility secret
|
|
44
|
+
*/
|
|
45
|
+
extraRequestHeaders?: {
|
|
46
|
+
[key: string]: string;
|
|
47
|
+
};
|
|
41
48
|
}[];
|
|
42
49
|
};
|
|
43
50
|
}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
-
var
|
|
4
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
5
5
|
var router = require('./router.cjs.js');
|
|
6
6
|
var NpmRegistryServiceImpl = require('./services/NpmRegistryServiceImpl.cjs.js');
|
|
7
7
|
|
|
@@ -11,16 +11,14 @@ const npmPlugin = backendPluginApi.createBackendPlugin({
|
|
|
11
11
|
env.registerInit({
|
|
12
12
|
deps: {
|
|
13
13
|
logger: backendPluginApi.coreServices.logger,
|
|
14
|
-
auth: backendPluginApi.coreServices.auth,
|
|
15
14
|
config: backendPluginApi.coreServices.rootConfig,
|
|
16
15
|
httpAuth: backendPluginApi.coreServices.httpAuth,
|
|
17
16
|
httpRouter: backendPluginApi.coreServices.httpRouter,
|
|
18
|
-
catalog:
|
|
17
|
+
catalog: pluginCatalogNode.catalogServiceRef
|
|
19
18
|
},
|
|
20
|
-
async init({ logger,
|
|
19
|
+
async init({ logger, config, httpAuth, httpRouter, catalog }) {
|
|
21
20
|
const npmRegistryService = new NpmRegistryServiceImpl.NpmRegistryServiceImpl({
|
|
22
21
|
logger,
|
|
23
|
-
auth,
|
|
24
22
|
config,
|
|
25
23
|
catalog
|
|
26
24
|
});
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.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 {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.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 {\n coreServices,\n createBackendPlugin,\n} from '@backstage/backend-plugin-api';\nimport { catalogServiceRef } from '@backstage/plugin-catalog-node';\n\nimport { createRouter } from './router';\nimport { NpmRegistryServiceImpl } from './services/NpmRegistryServiceImpl';\n\n/**\n * npmPlugin backend plugin\n *\n * @public\n */\nexport const npmPlugin = createBackendPlugin({\n pluginId: 'npm',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.rootConfig,\n httpAuth: coreServices.httpAuth,\n httpRouter: coreServices.httpRouter,\n catalog: catalogServiceRef,\n },\n async init({ logger, config, httpAuth, httpRouter, catalog }) {\n const npmRegistryService = new NpmRegistryServiceImpl({\n logger,\n config,\n catalog,\n });\n\n httpRouter.use(\n await createRouter({\n httpAuth,\n npmRegistryService,\n }),\n );\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","catalogServiceRef","NpmRegistryServiceImpl","createRouter"],"mappings":";;;;;;;AA6BO,MAAM,YAAYA,oCAAoB,CAAA;AAAA,EAC3C,QAAU,EAAA,KAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,MAAA;AAAA,QACrB,QAAQA,6BAAa,CAAA,UAAA;AAAA,QACrB,UAAUA,6BAAa,CAAA,QAAA;AAAA,QACvB,YAAYA,6BAAa,CAAA,UAAA;AAAA,QACzB,OAAS,EAAAC;AAAA,OACX;AAAA,MACA,MAAM,KAAK,EAAE,MAAA,EAAQ,QAAQ,QAAU,EAAA,UAAA,EAAY,SAAW,EAAA;AAC5D,QAAM,MAAA,kBAAA,GAAqB,IAAIC,6CAAuB,CAAA;AAAA,UACpD,MAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA,SACD,CAAA;AAED,QAAW,UAAA,CAAA,GAAA;AAAA,UACT,MAAMC,mBAAa,CAAA;AAAA,YACjB,QAAA;AAAA,YACA;AAAA,WACD;AAAA,SACH;AAAA;AACF,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -5,23 +5,15 @@ var pluginNpmCommon = require('@backstage-community/plugin-npm-common');
|
|
|
5
5
|
|
|
6
6
|
class NpmRegistryServiceImpl {
|
|
7
7
|
logger;
|
|
8
|
-
auth;
|
|
9
8
|
config;
|
|
10
9
|
catalog;
|
|
11
10
|
constructor(options) {
|
|
12
11
|
this.logger = options.logger;
|
|
13
|
-
this.auth = options.auth;
|
|
14
12
|
this.config = options.config;
|
|
15
13
|
this.catalog = options.catalog;
|
|
16
14
|
}
|
|
17
15
|
async getPackageInfo(entityRef, options) {
|
|
18
|
-
const
|
|
19
|
-
onBehalfOf: options.credentials,
|
|
20
|
-
targetPluginId: "catalog"
|
|
21
|
-
});
|
|
22
|
-
const entity = await this.catalog.getEntityByRef(entityRef, {
|
|
23
|
-
token
|
|
24
|
-
});
|
|
16
|
+
const entity = await this.catalog.getEntityByRef(entityRef, options);
|
|
25
17
|
if (!entity) {
|
|
26
18
|
throw new errors.NotFoundError(`No entity found for ref '${entityRef}'`);
|
|
27
19
|
}
|
|
@@ -49,7 +41,8 @@ class NpmRegistryServiceImpl {
|
|
|
49
41
|
const client = new pluginNpmCommon.NpmRegistryClient({
|
|
50
42
|
// TODO pass apiFetch.fetch
|
|
51
43
|
baseUrl: registry?.url,
|
|
52
|
-
token: registry?.token
|
|
44
|
+
token: registry?.token,
|
|
45
|
+
extraRequestHeaders: registry?.extraRequestHeaders
|
|
53
46
|
});
|
|
54
47
|
const packageInfo = await client.getPackageInfo(packageName);
|
|
55
48
|
return packageInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NpmRegistryServiceImpl.cjs.js","sources":["../../src/services/NpmRegistryServiceImpl.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 {\n
|
|
1
|
+
{"version":3,"file":"NpmRegistryServiceImpl.cjs.js","sources":["../../src/services/NpmRegistryServiceImpl.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 {\n BackstageCredentials,\n BackstageUserPrincipal,\n LoggerService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport { NotFoundError } from '@backstage/errors';\nimport { CatalogService } from '@backstage/plugin-catalog-node';\n\nimport {\n NpmAnnotation,\n NpmRegistryClient,\n NpmRegistryPackageInfo,\n} from '@backstage-community/plugin-npm-common';\n\nimport { NpmRegistryService } from './NpmRegistryService';\nimport { Config } from '../../config';\n\nexport type Options = {\n logger: LoggerService;\n config: RootConfigService;\n catalog: CatalogService;\n};\n\nexport class NpmRegistryServiceImpl implements NpmRegistryService {\n private readonly logger: LoggerService;\n private readonly config: RootConfigService;\n private readonly catalog: CatalogService;\n\n constructor(options: Options) {\n this.logger = options.logger;\n this.config = options.config;\n this.catalog = options.catalog;\n }\n\n async getPackageInfo(\n entityRef: string,\n options: { credentials: BackstageCredentials<BackstageUserPrincipal> },\n ): Promise<NpmRegistryPackageInfo> {\n const entity = await this.catalog.getEntityByRef(entityRef, options);\n if (!entity) {\n throw new NotFoundError(`No entity found for ref '${entityRef}'`);\n }\n\n const config = this.config.getOptional<Config['npm']>('npm');\n const defaultRegistry = config?.defaultRegistry;\n\n const packageName =\n entity.metadata.annotations?.[NpmAnnotation.PACKAGE_NAME];\n const registryName =\n entity.metadata.annotations?.[NpmAnnotation.REGISTRY_NAME] ||\n defaultRegistry;\n if (!packageName) {\n throw new NotFoundError(\n `Npm package name not defined at entity '${entityRef}'`,\n );\n }\n\n const registry = config?.registries?.find(r => r.name === registryName);\n if (!registry && registryName !== 'default' && registryName !== 'npmjs') {\n throw new NotFoundError(\n `Npm registry config '${registryName}' not found as defined in entity '${entityRef}'`,\n );\n }\n\n this.logger.info('Will use npmjs package info:', {\n entityRef,\n packageName,\n registryUrl: registry?.url,\n registryToken: registry?.token ? 'yes' : 'no',\n });\n\n const client = new NpmRegistryClient({\n // TODO pass apiFetch.fetch\n baseUrl: registry?.url,\n token: registry?.token,\n extraRequestHeaders: registry?.extraRequestHeaders,\n });\n const packageInfo = await client.getPackageInfo(packageName);\n return packageInfo;\n }\n}\n"],"names":["NotFoundError","NpmAnnotation","NpmRegistryClient"],"mappings":";;;;;AAuCO,MAAM,sBAAqD,CAAA;AAAA,EAC/C,MAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EAEjB,YAAY,OAAkB,EAAA;AAC5B,IAA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SAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAa,QAAU,EAAA,GAAA;AAAA,MACvB,aAAA,EAAe,QAAU,EAAA,KAAA,GAAQ,KAAQ,GAAA;AAAA,KAC1C,CAAA;AAED,IAAM,MAAA,MAAA,GAAS,IAAIE,iCAAkB,CAAA;AAAA;AAAA,MAEnC,SAAS,QAAU,EAAA,GAAA;AAAA,MACnB,OAAO,QAAU,EAAA,KAAA;AAAA,MACjB,qBAAqB,QAAU,EAAA;AAAA,KAChC,CAAA;AACD,IAAA,MAAM,WAAc,GAAA,MAAM,MAAO,CAAA,cAAA,CAAe,WAAW,CAAA;AAC3D,IAAO,OAAA,WAAA;AAAA;AAEX;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-npm-backend",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"postpack": "backstage-cli package postpack"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage-community/plugin-npm-common": "^1.
|
|
37
|
-
"@backstage/backend-defaults": "^0.
|
|
38
|
-
"@backstage/backend-plugin-api": "^1.
|
|
39
|
-
"@backstage/catalog-client": "^1.10.
|
|
36
|
+
"@backstage-community/plugin-npm-common": "^1.9.0",
|
|
37
|
+
"@backstage/backend-defaults": "^0.11.0",
|
|
38
|
+
"@backstage/backend-plugin-api": "^1.4.0",
|
|
39
|
+
"@backstage/catalog-client": "^1.10.1",
|
|
40
40
|
"@backstage/errors": "^1.2.7",
|
|
41
|
-
"@backstage/plugin-catalog-node": "^1.17.
|
|
41
|
+
"@backstage/plugin-catalog-node": "^1.17.1",
|
|
42
42
|
"express": "^4.17.1",
|
|
43
43
|
"express-promise-router": "^4.1.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@backstage/backend-test-utils": "^1.
|
|
47
|
-
"@backstage/cli": "^0.
|
|
46
|
+
"@backstage/backend-test-utils": "^1.6.0",
|
|
47
|
+
"@backstage/cli": "^0.33.0",
|
|
48
48
|
"@types/express": "*",
|
|
49
49
|
"@types/supertest": "^2.0.12",
|
|
50
50
|
"supertest": "^6.2.4"
|