Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@backstage/config-loader

Package Overview
Dependencies
Maintainers
4
Versions
870
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/config-loader - npm Package Compare versions

Comparing version 0.0.0-nightly-20218921925 to 0.0.0-nightly-20219322159

19

CHANGELOG.md
# @backstage/config-loader
## 0.0.0-nightly-20218921925
## 0.0.0-nightly-20219322159
### Patch Changes
- 957e4b3351: Updated dependencies
## 0.6.9
### Patch Changes
- ee7a1a4b64: Add option to collect configuration schemas from explicit package paths in addition to by package name.
- e68bd978e2: Allow collection of configuration schemas from multiple versions of the same package.
## 0.6.8
### Patch Changes
- d1da88a19: Properly export all used types.
- Updated dependencies
- @backstage/cli-common@0.0.0-nightly-20218921925
- @backstage/config@0.0.0-nightly-20218921925
- @backstage/cli-common@0.1.3
- @backstage/config@0.1.9

@@ -12,0 +25,0 @@ ## 0.6.7

51

dist/index.cjs.js

@@ -312,22 +312,37 @@ 'use strict';

const req = typeof __non_webpack_require__ === "undefined" ? require : __non_webpack_require__;
async function collectConfigSchemas(packageNames) {
const visitedPackages = new Set();
const schemas = Array();
const tsSchemaPaths = Array();
async function collectConfigSchemas(packageNames, packagePaths) {
const schemas = new Array();
const tsSchemaPaths = new Array();
const visitedPackageVersions = new Map();
const currentDir = await fs__default['default'].realpath(process.cwd());
async function processItem({name, parentPath}) {
async function processItem(item) {
var _a, _b, _c, _d;
if (visitedPackages.has(name)) {
let pkgPath = item.packagePath;
if (pkgPath) {
const pkgExists = await fs__default['default'].pathExists(pkgPath);
if (!pkgExists) {
return;
}
} else if (item.name) {
const {name, parentPath} = item;
try {
pkgPath = req.resolve(`${name}/package.json`, parentPath && {
paths: [parentPath]
});
} catch {
}
}
if (!pkgPath) {
return;
}
visitedPackages.add(name);
let pkgPath;
try {
pkgPath = req.resolve(`${name}/package.json`, parentPath && {
paths: [parentPath]
});
} catch {
const pkg = await fs__default['default'].readJson(pkgPath);
let versions = visitedPackageVersions.get(pkg.name);
if (versions == null ? void 0 : versions.has(pkg.version)) {
return;
}
const pkg = await fs__default['default'].readJson(pkgPath);
if (!versions) {
versions = new Set();
visitedPackageVersions.set(pkg.name, versions);
}
versions.add(pkg.version);
const depNames = [

@@ -370,3 +385,6 @@ ...Object.keys((_a = pkg.dependencies) != null ? _a : {}),

}
await Promise.all(packageNames.map((name) => processItem({name, parentPath: currentDir})));
await Promise.all([
...packageNames.map((name) => processItem({name, parentPath: currentDir})),
...packagePaths.map((path) => processItem({name: path, packagePath: path}))
]);
const tsSchemas = compileTsSchemas(tsSchemaPaths);

@@ -468,5 +486,6 @@ return schemas.concat(tsSchemas);

async function loadConfigSchema(options) {
var _a;
let schemas;
if ("dependencies" in options) {
schemas = await collectConfigSchemas(options.dependencies);
schemas = await collectConfigSchemas(options.dependencies, (_a = options.packagePaths) != null ? _a : []);
} else {

@@ -473,0 +492,0 @@ const {serialized} = options;

@@ -91,2 +91,3 @@ import { AppConfig, JsonObject } from '@backstage/config';

dependencies: string[];
packagePaths?: string[];
} | {

@@ -93,0 +94,0 @@ serialized: JsonObject;

@@ -300,22 +300,37 @@ import yaml from 'yaml';

const req = typeof __non_webpack_require__ === "undefined" ? require : __non_webpack_require__;
async function collectConfigSchemas(packageNames) {
const visitedPackages = new Set();
const schemas = Array();
const tsSchemaPaths = Array();
async function collectConfigSchemas(packageNames, packagePaths) {
const schemas = new Array();
const tsSchemaPaths = new Array();
const visitedPackageVersions = new Map();
const currentDir = await fs.realpath(process.cwd());
async function processItem({name, parentPath}) {
async function processItem(item) {
var _a, _b, _c, _d;
if (visitedPackages.has(name)) {
let pkgPath = item.packagePath;
if (pkgPath) {
const pkgExists = await fs.pathExists(pkgPath);
if (!pkgExists) {
return;
}
} else if (item.name) {
const {name, parentPath} = item;
try {
pkgPath = req.resolve(`${name}/package.json`, parentPath && {
paths: [parentPath]
});
} catch {
}
}
if (!pkgPath) {
return;
}
visitedPackages.add(name);
let pkgPath;
try {
pkgPath = req.resolve(`${name}/package.json`, parentPath && {
paths: [parentPath]
});
} catch {
const pkg = await fs.readJson(pkgPath);
let versions = visitedPackageVersions.get(pkg.name);
if (versions == null ? void 0 : versions.has(pkg.version)) {
return;
}
const pkg = await fs.readJson(pkgPath);
if (!versions) {
versions = new Set();
visitedPackageVersions.set(pkg.name, versions);
}
versions.add(pkg.version);
const depNames = [

@@ -358,3 +373,6 @@ ...Object.keys((_a = pkg.dependencies) != null ? _a : {}),

}
await Promise.all(packageNames.map((name) => processItem({name, parentPath: currentDir})));
await Promise.all([
...packageNames.map((name) => processItem({name, parentPath: currentDir})),
...packagePaths.map((path) => processItem({name: path, packagePath: path}))
]);
const tsSchemas = compileTsSchemas(tsSchemaPaths);

@@ -456,5 +474,6 @@ return schemas.concat(tsSchemas);

async function loadConfigSchema(options) {
var _a;
let schemas;
if ("dependencies" in options) {
schemas = await collectConfigSchemas(options.dependencies);
schemas = await collectConfigSchemas(options.dependencies, (_a = options.packagePaths) != null ? _a : []);
} else {

@@ -461,0 +480,0 @@ const {serialized} = options;

{
"name": "@backstage/config-loader",
"description": "Config loading functionality used by Backstage backend, and CLI",
"version": "0.0.0-nightly-20218921925",
"version": "0.0.0-nightly-20219322159",
"private": false,

@@ -33,4 +33,4 @@ "publishConfig": {

"dependencies": {
"@backstage/cli-common": "^0.0.0-nightly-20218921925",
"@backstage/config": "^0.0.0-nightly-20218921925",
"@backstage/cli-common": "^0.1.3",
"@backstage/config": "^0.1.9",
"@types/json-schema": "^7.0.6",

@@ -44,3 +44,3 @@ "ajv": "^7.0.3",

"yaml": "^1.9.2",
"yup": "^0.29.3"
"yup": "^0.32.9"
},

@@ -52,4 +52,4 @@ "devDependencies": {

"@types/node": "^14.14.32",
"@types/yup": "^0.29.8",
"mock-fs": "^4.13.0"
"@types/yup": "^0.29.13",
"mock-fs": "^5.1.0"
},

@@ -56,0 +56,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc