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

@backstage/cli-common

Package Overview
Dependencies
Maintainers
3
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/cli-common - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15-next.0

dist/isChildPath.cjs.js

6

CHANGELOG.md
# @backstage/cli-common
## 0.1.15-next.0
### Patch Changes
- 702f41d: Bumped dev dependencies `@types/node`
## 0.1.14

@@ -4,0 +10,0 @@

102

dist/index.cjs.js
'use strict';
var fs = require('fs');
var path = require('path');
var paths = require('./paths.cjs.js');
var isChildPath = require('./isChildPath.cjs.js');
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
var fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
function findRootPath(searchDir, filterFunc) {
let path$1 = searchDir;
for (let i = 0; i < 1e3; i++) {
const packagePath = path.resolve(path$1, "package.json");
const exists = fs__default.default.existsSync(packagePath);
if (exists && filterFunc(packagePath)) {
return path$1;
}
const newPath = path.dirname(path$1);
if (newPath === path$1) {
return void 0;
}
path$1 = newPath;
}
throw new Error(
`Iteration limit reached when searching for root package.json at ${searchDir}`
);
}
function findOwnDir(searchDir) {
const path = findRootPath(searchDir, () => true);
if (!path) {
throw new Error(
`No package.json found while searching for package root of ${searchDir}`
);
}
return path;
}
function findOwnRootDir(ownDir) {
const isLocal = fs__default.default.existsSync(path.resolve(ownDir, "src"));
if (!isLocal) {
throw new Error(
"Tried to access monorepo package root dir outside of Backstage repository"
);
}
return path.resolve(ownDir, "../..");
}
function findPaths(searchDir) {
const ownDir = findOwnDir(searchDir);
const targetDir = fs__default.default.realpathSync(process.cwd()).replace(/^[a-z]:/, (str) => str.toLocaleUpperCase("en-US"));
let ownRoot = "";
const getOwnRoot = () => {
if (!ownRoot) {
ownRoot = findOwnRootDir(ownDir);
}
return ownRoot;
};
let targetRoot = "";
const getTargetRoot = () => {
if (!targetRoot) {
targetRoot = findRootPath(targetDir, (path) => {
try {
const content = fs__default.default.readFileSync(path, "utf8");
const data = JSON.parse(content);
return Boolean(data.workspaces);
} catch (error) {
throw new Error(
`Failed to parse package.json file while searching for root, ${error}`
);
}
}) ?? targetDir;
}
return targetRoot;
};
return {
ownDir,
get ownRoot() {
return getOwnRoot();
},
targetDir,
get targetRoot() {
return getTargetRoot();
},
resolveOwn: (...paths) => path.resolve(ownDir, ...paths),
resolveOwnRoot: (...paths) => path.resolve(getOwnRoot(), ...paths),
resolveTarget: (...paths) => path.resolve(targetDir, ...paths),
resolveTargetRoot: (...paths) => path.resolve(getTargetRoot(), ...paths)
};
}
const BACKSTAGE_JSON = "backstage.json";
function isChildPath(base, path$1) {
const relativePath = path.relative(base, path$1);
if (relativePath === "") {
return true;
}
const outsideBase = relativePath.startsWith("..");
const differentDrive = path.isAbsolute(relativePath);
return !outsideBase && !differentDrive;
}
exports.BACKSTAGE_JSON = BACKSTAGE_JSON;
exports.findPaths = findPaths;
exports.isChildPath = isChildPath;
exports.BACKSTAGE_JSON = paths.BACKSTAGE_JSON;
exports.findPaths = paths.findPaths;
exports.isChildPath = isChildPath.isChildPath;
//# sourceMappingURL=index.cjs.js.map
{
"name": "@backstage/cli-common",
"version": "0.1.14",
"version": "0.1.15-next.0",
"description": "Common functionality used by cli, backend, and create-app",

@@ -38,5 +38,5 @@ "backstage": {

"devDependencies": {
"@backstage/cli": "^0.26.7",
"@types/node": "^18.17.8"
"@backstage/cli": "0.29.0-next.1",
"@types/node": "^20.16.0"
}
}

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