@backstage/cli-common
Advanced tools
Comparing version 0.1.14 to 0.1.15-next.0
# @backstage/cli-common | ||
## 0.1.15-next.0 | ||
### Patch Changes | ||
- 702f41d: Bumped dev dependencies `@types/node` | ||
## 0.1.14 | ||
@@ -4,0 +10,0 @@ |
'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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
18267
10
155
2
1