@backstage/cli-common
Advanced tools
| 'use strict'; | ||
| var node_path = require('node:path'); | ||
| var paths = require('./paths.cjs.js'); | ||
| function overrideTargetPaths(dirOrOptions) { | ||
| const { dir, rootDir } = typeof dirOrOptions === "string" ? { dir: dirOrOptions, rootDir: dirOrOptions } : { | ||
| dir: dirOrOptions.dir, | ||
| rootDir: dirOrOptions.rootDir ?? dirOrOptions.dir | ||
| }; | ||
| paths.setTargetPathsOverride({ | ||
| dir, | ||
| rootDir, | ||
| resolve: (...paths) => node_path.resolve(dir, ...paths), | ||
| resolveRoot: (...paths) => node_path.resolve(rootDir, ...paths) | ||
| }); | ||
| return { | ||
| restore() { | ||
| paths.setTargetPathsOverride(void 0); | ||
| } | ||
| }; | ||
| } | ||
| exports.overrideTargetPaths = overrideTargetPaths; | ||
| //# sourceMappingURL=testUtils.cjs.js.map |
| {"version":3,"file":"testUtils.cjs.js","sources":["../src/testUtils.ts"],"sourcesContent":["/*\n * Copyright 2025 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 */\n\nimport { resolve as resolvePath } from 'node:path';\nimport { setTargetPathsOverride } from './paths';\n\n/**\n * Options for {@link overrideTargetPaths}.\n *\n * @public\n */\nexport interface OverrideTargetPathsOptions {\n /** The target package directory. */\n dir: string;\n /** The target monorepo root directory. Defaults to `dir` if not provided. */\n rootDir?: string;\n}\n\n/**\n * Return value of {@link overrideTargetPaths}.\n *\n * @public\n */\nexport interface TargetPathsOverride {\n /** Restores `targetPaths` to its normal behavior. */\n restore(): void;\n}\n\n/**\n * Overrides the `targetPaths` singleton to resolve from the given directory\n * instead of `process.cwd()`.\n *\n * When called with a string, that value is used as both `dir` and `rootDir`.\n * Pass an options object to set them independently.\n *\n * Calling `restore()` on the return value reverts to normal behavior.\n * Restoration is only needed if you want to change the override within a\n * test file; each Jest worker starts with a clean module state.\n *\n * @public\n */\nexport function overrideTargetPaths(\n dirOrOptions: string | OverrideTargetPathsOptions,\n): TargetPathsOverride {\n const { dir, rootDir } =\n typeof dirOrOptions === 'string'\n ? { dir: dirOrOptions, rootDir: dirOrOptions }\n : {\n dir: dirOrOptions.dir,\n rootDir: dirOrOptions.rootDir ?? dirOrOptions.dir,\n };\n\n setTargetPathsOverride({\n dir,\n rootDir,\n resolve: (...paths: string[]) => resolvePath(dir, ...paths),\n resolveRoot: (...paths: string[]) => resolvePath(rootDir, ...paths),\n });\n\n return {\n restore() {\n setTargetPathsOverride(undefined);\n },\n };\n}\n"],"names":["setTargetPathsOverride","resolvePath"],"mappings":";;;;;AAsDO,SAAS,oBACd,YAAA,EACqB;AACrB,EAAA,MAAM,EAAE,GAAA,EAAK,OAAA,EAAQ,GACnB,OAAO,YAAA,KAAiB,QAAA,GACpB,EAAE,GAAA,EAAK,YAAA,EAAc,OAAA,EAAS,YAAA,EAAa,GAC3C;AAAA,IACE,KAAK,YAAA,CAAa,GAAA;AAAA,IAClB,OAAA,EAAS,YAAA,CAAa,OAAA,IAAW,YAAA,CAAa;AAAA,GAChD;AAEN,EAAAA,4BAAA,CAAuB;AAAA,IACrB,GAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAS,CAAA,GAAI,KAAA,KAAoBC,iBAAA,CAAY,GAAA,EAAK,GAAG,KAAK,CAAA;AAAA,IAC1D,aAAa,CAAA,GAAI,KAAA,KAAoBA,iBAAA,CAAY,OAAA,EAAS,GAAG,KAAK;AAAA,GACnE,CAAA;AAED,EAAA,OAAO;AAAA,IACL,OAAA,GAAU;AACR,MAAAD,4BAAA,CAAuB,MAAS,CAAA;AAAA,IAClC;AAAA,GACF;AACF;;;;"} |
| /** | ||
| * Options for {@link overrideTargetPaths}. | ||
| * | ||
| * @public | ||
| */ | ||
| interface OverrideTargetPathsOptions { | ||
| /** The target package directory. */ | ||
| dir: string; | ||
| /** The target monorepo root directory. Defaults to `dir` if not provided. */ | ||
| rootDir?: string; | ||
| } | ||
| /** | ||
| * Return value of {@link overrideTargetPaths}. | ||
| * | ||
| * @public | ||
| */ | ||
| interface TargetPathsOverride { | ||
| /** Restores `targetPaths` to its normal behavior. */ | ||
| restore(): void; | ||
| } | ||
| /** | ||
| * Overrides the `targetPaths` singleton to resolve from the given directory | ||
| * instead of `process.cwd()`. | ||
| * | ||
| * When called with a string, that value is used as both `dir` and `rootDir`. | ||
| * Pass an options object to set them independently. | ||
| * | ||
| * Calling `restore()` on the return value reverts to normal behavior. | ||
| * Restoration is only needed if you want to change the override within a | ||
| * test file; each Jest worker starts with a clean module state. | ||
| * | ||
| * @public | ||
| */ | ||
| declare function overrideTargetPaths(dirOrOptions: string | OverrideTargetPathsOptions): TargetPathsOverride; | ||
| export { overrideTargetPaths }; | ||
| export type { OverrideTargetPathsOptions, TargetPathsOverride }; |
+34
-0
| # @backstage/cli-common | ||
| ## 0.2.0-next.0 | ||
| ### Minor Changes | ||
| - 56bd494: Added `targetPaths` and `findOwnPaths` as replacements for `findPaths`, with a cleaner separation between target project paths and package-relative paths. | ||
| To migrate existing `findPaths` usage: | ||
| ```ts | ||
| // Before | ||
| import { findPaths } from '@backstage/cli-common'; | ||
| const paths = findPaths(__dirname); | ||
| // After — for target project paths (cwd-based): | ||
| import { targetPaths } from '@backstage/cli-common'; | ||
| // paths.targetDir → targetPaths.dir | ||
| // paths.targetRoot → targetPaths.rootDir | ||
| // paths.resolveTarget('src') → targetPaths.resolve('src') | ||
| // paths.resolveTargetRoot('yarn.lock') → targetPaths.resolveRoot('yarn.lock') | ||
| // After — for package-relative paths: | ||
| import { findOwnPaths } from '@backstage/cli-common'; | ||
| const own = findOwnPaths(__dirname); | ||
| // paths.ownDir → own.dir | ||
| // paths.ownRoot → own.rootDir | ||
| // paths.resolveOwn('config/jest.js') → own.resolve('config/jest.js') | ||
| // paths.resolveOwnRoot('tsconfig.json') → own.resolveRoot('tsconfig.json') | ||
| ``` | ||
| ### Patch Changes | ||
| - Updated dependencies | ||
| - @backstage/errors@1.2.7 | ||
| ## 0.1.18 | ||
@@ -4,0 +38,0 @@ |
@@ -6,2 +6,3 @@ 'use strict'; | ||
| class ExitCodeError extends errors.CustomErrorBase { | ||
| /** The exit code of the child process. */ | ||
| code; | ||
@@ -8,0 +9,0 @@ constructor(code, command) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"errors.cjs.js","sources":["../src/errors.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { CustomErrorBase } from '@backstage/errors';\n\n/**\n * Error thrown when a child process exits with a non-zero code.\n * @public\n */\nexport class ExitCodeError extends CustomErrorBase {\n readonly code: number;\n\n constructor(code: number, command?: string) {\n super(\n command\n ? `Command '${command}' exited with code ${code}`\n : `Child exited with code ${code}`,\n );\n this.code = code;\n }\n}\n"],"names":["CustomErrorBase"],"mappings":";;;;AAsBO,MAAM,sBAAsBA,sBAAA,CAAgB;AAAA,EACxC,IAAA;AAAA,EAET,WAAA,CAAY,MAAc,OAAA,EAAkB;AAC1C,IAAA,KAAA;AAAA,MACE,UACI,CAAA,SAAA,EAAY,OAAO,sBAAsB,IAAI,CAAA,CAAA,GAC7C,0BAA0B,IAAI,CAAA;AAAA,KACpC;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AACF;;;;"} | ||
| {"version":3,"file":"errors.cjs.js","sources":["../src/errors.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport { CustomErrorBase } from '@backstage/errors';\n\n/**\n * Error thrown when a child process exits with a non-zero code.\n * @public\n */\nexport class ExitCodeError extends CustomErrorBase {\n /** The exit code of the child process. */\n readonly code: number;\n\n constructor(code: number, command?: string) {\n super(\n command\n ? `Command '${command}' exited with code ${code}`\n : `Child exited with code ${code}`,\n );\n this.code = code;\n }\n}\n"],"names":["CustomErrorBase"],"mappings":";;;;AAsBO,MAAM,sBAAsBA,sBAAA,CAAgB;AAAA;AAAA,EAExC,IAAA;AAAA,EAET,WAAA,CAAY,MAAc,OAAA,EAAkB;AAC1C,IAAA,KAAA;AAAA,MACE,UACI,CAAA,SAAA,EAAY,OAAO,sBAAsB,IAAI,CAAA,CAAA,GAC7C,0BAA0B,IAAI,CAAA;AAAA,KACpC;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EACd;AACF;;;;"} |
@@ -12,3 +12,5 @@ 'use strict'; | ||
| exports.BACKSTAGE_JSON = paths.BACKSTAGE_JSON; | ||
| exports.findOwnPaths = paths.findOwnPaths; | ||
| exports.findPaths = paths.findPaths; | ||
| exports.targetPaths = paths.targetPaths; | ||
| exports.isChildPath = isChildPath.isChildPath; | ||
@@ -15,0 +17,0 @@ exports.bootstrapEnvProxyAgents = proxyBootstrap.bootstrapEnvProxyAgents; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"} |
+56
-2
@@ -12,2 +12,34 @@ import { SpawnOptions, ChildProcess } from 'node:child_process'; | ||
| /** | ||
| * Resolved paths relative to the target project, based on `process.cwd()`. | ||
| * Lazily initialized on first property access. Re-resolves automatically | ||
| * when `process.cwd()` changes. | ||
| * | ||
| * @public | ||
| */ | ||
| type TargetPaths = { | ||
| /** The target package directory. */ | ||
| dir: string; | ||
| /** The target monorepo root directory. */ | ||
| rootDir: string; | ||
| /** Resolve a path relative to the target package directory. */ | ||
| resolve: ResolveFunc; | ||
| /** Resolve a path relative to the target repo root. */ | ||
| resolveRoot: ResolveFunc; | ||
| }; | ||
| /** | ||
| * Resolved paths relative to a specific package in the repository. | ||
| * | ||
| * @public | ||
| */ | ||
| type OwnPaths = { | ||
| /** The package root directory. */ | ||
| dir: string; | ||
| /** The monorepo root directory containing the package. */ | ||
| rootDir: string; | ||
| /** Resolve a path relative to the package root. */ | ||
| resolve: ResolveFunc; | ||
| /** Resolve a path relative to the monorepo root containing the package. */ | ||
| resolveRoot: ResolveFunc; | ||
| }; | ||
| /** | ||
| * Common paths and resolve functions used by the cli. | ||
@@ -17,2 +49,3 @@ * Currently assumes it is being executed within a monorepo. | ||
| * @public | ||
| * @deprecated Use {@link targetPaths} and {@link findOwnPaths} instead. | ||
| */ | ||
@@ -30,5 +63,25 @@ type Paths = { | ||
| /** | ||
| * Lazily resolved paths relative to the target project. Import this directly | ||
| * for cwd-based path resolution without needing `__dirname`. | ||
| * | ||
| * @public | ||
| */ | ||
| declare const targetPaths: TargetPaths; | ||
| /** | ||
| * Find paths relative to the package that the calling code lives in. | ||
| * | ||
| * Results are cached per package root, and the package root lookup uses a | ||
| * hierarchical directory cache so that multiple calls from different | ||
| * subdirectories within the same package share work. | ||
| * | ||
| * @public | ||
| */ | ||
| declare function findOwnPaths(searchDir: string): OwnPaths; | ||
| /** | ||
| * Find paths related to a package and its execution context. | ||
| * | ||
| * @public | ||
| * @deprecated Use {@link targetPaths} for cwd-based paths and | ||
| * {@link findOwnPaths} for package-relative paths instead. | ||
| * | ||
| * @example | ||
@@ -132,2 +185,3 @@ * | ||
| declare class ExitCodeError extends CustomErrorBase { | ||
| /** The exit code of the child process. */ | ||
| readonly code: number; | ||
@@ -137,3 +191,3 @@ constructor(code: number, command?: string); | ||
| export { BACKSTAGE_JSON, ExitCodeError, bootstrapEnvProxyAgents, findPaths, isChildPath, run, runCheck, runOutput }; | ||
| export type { Paths, ResolveFunc, RunChildProcess, RunOnOutput, RunOptions }; | ||
| export { BACKSTAGE_JSON, ExitCodeError, bootstrapEnvProxyAgents, findOwnPaths, findPaths, isChildPath, run, runCheck, runOutput, targetPaths }; | ||
| export type { OwnPaths, Paths, ResolveFunc, RunChildProcess, RunOnOutput, RunOptions, TargetPaths }; |
+131
-41
@@ -28,11 +28,2 @@ 'use strict'; | ||
| } | ||
| 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) { | ||
@@ -47,42 +38,139 @@ const isLocal = fs__default.default.existsSync(node_path.resolve(ownDir, "src")); | ||
| } | ||
| 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); | ||
| const dirCache = /* @__PURE__ */ new Map(); | ||
| class OwnPathsImpl { | ||
| static #instanceCache = /* @__PURE__ */ new Map(); | ||
| static find(searchDir) { | ||
| const dir = OwnPathsImpl.findDir(searchDir); | ||
| let instance = OwnPathsImpl.#instanceCache.get(dir); | ||
| if (!instance) { | ||
| instance = new OwnPathsImpl(dir); | ||
| OwnPathsImpl.#instanceCache.set(dir, instance); | ||
| } | ||
| 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}` | ||
| ); | ||
| return instance; | ||
| } | ||
| static findDir(searchDir) { | ||
| const visited = []; | ||
| let dir = searchDir; | ||
| for (let i = 0; i < 1e3; i++) { | ||
| const cached = dirCache.get(dir); | ||
| if (cached !== void 0) { | ||
| for (const d of visited) { | ||
| dirCache.set(d, cached); | ||
| } | ||
| }) ?? targetDir; | ||
| return cached; | ||
| } | ||
| visited.push(dir); | ||
| if (fs__default.default.existsSync(node_path.resolve(dir, "package.json"))) { | ||
| for (const d of visited) { | ||
| dirCache.set(d, dir); | ||
| } | ||
| return dir; | ||
| } | ||
| const newDir = node_path.dirname(dir); | ||
| if (newDir === dir) { | ||
| break; | ||
| } | ||
| dir = newDir; | ||
| } | ||
| return targetRoot; | ||
| throw new Error( | ||
| `No package.json found while searching for package root of ${searchDir}` | ||
| ); | ||
| } | ||
| #dir; | ||
| #rootDir; | ||
| constructor(dir) { | ||
| this.#dir = dir; | ||
| } | ||
| get dir() { | ||
| return this.#dir; | ||
| } | ||
| get rootDir() { | ||
| this.#rootDir ??= findOwnRootDir(this.#dir); | ||
| return this.#rootDir; | ||
| } | ||
| resolve = (...paths) => { | ||
| return node_path.resolve(this.#dir, ...paths); | ||
| }; | ||
| resolveRoot = (...paths) => { | ||
| return node_path.resolve(this.rootDir, ...paths); | ||
| }; | ||
| } | ||
| exports.targetPathsOverride = void 0; | ||
| function setTargetPathsOverride(override) { | ||
| exports.targetPathsOverride = override; | ||
| } | ||
| class TargetPathsImpl { | ||
| #cwd; | ||
| #dir; | ||
| #rootDir; | ||
| get dir() { | ||
| if (exports.targetPathsOverride) { | ||
| return exports.targetPathsOverride.dir; | ||
| } | ||
| const cwd = process.cwd(); | ||
| if (this.#dir !== void 0 && this.#cwd === cwd) { | ||
| return this.#dir; | ||
| } | ||
| this.#cwd = cwd; | ||
| this.#rootDir = void 0; | ||
| this.#dir = fs__default.default.realpathSync(cwd).replace(/^[a-z]:/, (str) => str.toLocaleUpperCase("en-US")); | ||
| return this.#dir; | ||
| } | ||
| get rootDir() { | ||
| if (exports.targetPathsOverride) { | ||
| return exports.targetPathsOverride.rootDir; | ||
| } | ||
| const dir = this.dir; | ||
| if (this.#rootDir !== void 0) { | ||
| return this.#rootDir; | ||
| } | ||
| this.#rootDir = findRootPath(dir, (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}` | ||
| ); | ||
| } | ||
| }) ?? dir; | ||
| return this.#rootDir; | ||
| } | ||
| resolve = (...paths) => { | ||
| if (exports.targetPathsOverride) { | ||
| return exports.targetPathsOverride.resolve(...paths); | ||
| } | ||
| return node_path.resolve(this.dir, ...paths); | ||
| }; | ||
| resolveRoot = (...paths) => { | ||
| if (exports.targetPathsOverride) { | ||
| return exports.targetPathsOverride.resolveRoot(...paths); | ||
| } | ||
| return node_path.resolve(this.rootDir, ...paths); | ||
| }; | ||
| } | ||
| const targetPaths = new TargetPathsImpl(); | ||
| function findOwnPaths(searchDir) { | ||
| return OwnPathsImpl.find(searchDir); | ||
| } | ||
| function findPaths(searchDir) { | ||
| const own = findOwnPaths(searchDir); | ||
| return { | ||
| ownDir, | ||
| get ownDir() { | ||
| return own.dir; | ||
| }, | ||
| get ownRoot() { | ||
| return getOwnRoot(); | ||
| return own.rootDir; | ||
| }, | ||
| targetDir, | ||
| get targetDir() { | ||
| return targetPaths.dir; | ||
| }, | ||
| get targetRoot() { | ||
| return getTargetRoot(); | ||
| return targetPaths.rootDir; | ||
| }, | ||
| resolveOwn: (...paths) => node_path.resolve(ownDir, ...paths), | ||
| resolveOwnRoot: (...paths) => node_path.resolve(getOwnRoot(), ...paths), | ||
| resolveTarget: (...paths) => node_path.resolve(targetDir, ...paths), | ||
| resolveTargetRoot: (...paths) => node_path.resolve(getTargetRoot(), ...paths) | ||
| resolveOwn: own.resolve, | ||
| resolveOwnRoot: own.resolveRoot, | ||
| resolveTarget: targetPaths.resolve, | ||
| resolveTargetRoot: targetPaths.resolveRoot | ||
| }; | ||
@@ -93,6 +181,8 @@ } | ||
| exports.BACKSTAGE_JSON = BACKSTAGE_JSON; | ||
| exports.findOwnDir = findOwnDir; | ||
| exports.findOwnPaths = findOwnPaths; | ||
| exports.findOwnRootDir = findOwnRootDir; | ||
| exports.findPaths = findPaths; | ||
| exports.findRootPath = findRootPath; | ||
| exports.setTargetPathsOverride = setTargetPathsOverride; | ||
| exports.targetPaths = targetPaths; | ||
| //# sourceMappingURL=paths.cjs.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"paths.cjs.js","sources":["../src/paths.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport fs from 'node:fs';\nimport { dirname, resolve as resolvePath } from 'node:path';\n\n/**\n * A function that takes a set of path fragments and resolves them into a\n * single complete path, relative to some root.\n *\n * @public\n */\nexport type ResolveFunc = (...paths: string[]) => string;\n\n/**\n * Common paths and resolve functions used by the cli.\n * Currently assumes it is being executed within a monorepo.\n *\n * @public\n */\nexport type Paths = {\n // Root dir of the cli itself, containing package.json\n ownDir: string;\n\n // Monorepo root dir of the cli itself. Only accessible when running inside Backstage repo.\n ownRoot: string;\n\n // The location of the app that the cli is being executed in\n targetDir: string;\n\n // The monorepo root package of the app that the cli is being executed in.\n targetRoot: string;\n\n // Resolve a path relative to own repo\n resolveOwn: ResolveFunc;\n\n // Resolve a path relative to own monorepo root. Only accessible when running inside Backstage repo.\n resolveOwnRoot: ResolveFunc;\n\n // Resolve a path relative to the app\n resolveTarget: ResolveFunc;\n\n // Resolve a path relative to the app repo root\n resolveTargetRoot: ResolveFunc;\n};\n\n// Looks for a package.json with a workspace config to identify the root of the monorepo\nexport function findRootPath(\n searchDir: string,\n filterFunc: (pkgJsonPath: string) => boolean,\n): string | undefined {\n let path = searchDir;\n\n // Some confidence check to avoid infinite loop\n for (let i = 0; i < 1000; i++) {\n const packagePath = resolvePath(path, 'package.json');\n const exists = fs.existsSync(packagePath);\n if (exists && filterFunc(packagePath)) {\n return path;\n }\n\n const newPath = dirname(path);\n if (newPath === path) {\n return undefined;\n }\n path = newPath;\n }\n\n throw new Error(\n `Iteration limit reached when searching for root package.json at ${searchDir}`,\n );\n}\n\n// Finds the root of a given package\nexport function findOwnDir(searchDir: string) {\n const path = findRootPath(searchDir, () => true);\n if (!path) {\n throw new Error(\n `No package.json found while searching for package root of ${searchDir}`,\n );\n }\n return path;\n}\n\n// Finds the root of the monorepo that the package exists in. Only accessible when running inside Backstage repo.\nexport function findOwnRootDir(ownDir: string) {\n const isLocal = fs.existsSync(resolvePath(ownDir, 'src'));\n if (!isLocal) {\n throw new Error(\n 'Tried to access monorepo package root dir outside of Backstage repository',\n );\n }\n\n return resolvePath(ownDir, '../..');\n}\n\n/**\n * Find paths related to a package and its execution context.\n *\n * @public\n * @example\n *\n * const paths = findPaths(__dirname)\n */\nexport function findPaths(searchDir: string): Paths {\n const ownDir = findOwnDir(searchDir);\n // Drive letter can end up being lowercased here on Windows, bring back to uppercase for consistency\n const targetDir = fs\n .realpathSync(process.cwd())\n .replace(/^[a-z]:/, str => str.toLocaleUpperCase('en-US'));\n\n // Lazy load this as it will throw an error if we're not inside the Backstage repo.\n let ownRoot = '';\n const getOwnRoot = () => {\n if (!ownRoot) {\n ownRoot = findOwnRootDir(ownDir);\n }\n return ownRoot;\n };\n\n // We're not always running in a monorepo, so we lazy init this to only crash commands\n // that require a monorepo when we're not in one.\n let targetRoot = '';\n const getTargetRoot = () => {\n if (!targetRoot) {\n targetRoot =\n findRootPath(targetDir, path => {\n try {\n const content = fs.readFileSync(path, 'utf8');\n const data = JSON.parse(content);\n return Boolean(data.workspaces);\n } catch (error) {\n throw new Error(\n `Failed to parse package.json file while searching for root, ${error}`,\n );\n }\n }) ?? targetDir; // We didn't find any root package.json, assume we're not in a monorepo\n }\n return targetRoot;\n };\n\n return {\n ownDir,\n get ownRoot() {\n return getOwnRoot();\n },\n targetDir,\n get targetRoot() {\n return getTargetRoot();\n },\n resolveOwn: (...paths) => resolvePath(ownDir, ...paths),\n resolveOwnRoot: (...paths) => resolvePath(getOwnRoot(), ...paths),\n resolveTarget: (...paths) => resolvePath(targetDir, ...paths),\n resolveTargetRoot: (...paths) => resolvePath(getTargetRoot(), ...paths),\n };\n}\n\n/**\n * The name of the backstage's config file\n *\n * @public\n */\nexport const BACKSTAGE_JSON = 'backstage.json';\n"],"names":["resolvePath","fs","dirname"],"mappings":";;;;;;;;;AA4DO,SAAS,YAAA,CACd,WACA,UAAA,EACoB;AACpB,EAAA,IAAI,IAAA,GAAO,SAAA;AAGX,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,GAAA,EAAM,CAAA,EAAA,EAAK;AAC7B,IAAA,MAAM,WAAA,GAAcA,iBAAA,CAAY,IAAA,EAAM,cAAc,CAAA;AACpD,IAAA,MAAM,MAAA,GAASC,mBAAA,CAAG,UAAA,CAAW,WAAW,CAAA;AACxC,IAAA,IAAI,MAAA,IA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AM,cAAA,GAAiB;;;;;;;;"} | ||
| {"version":3,"file":"paths.cjs.js","sources":["../src/paths.ts"],"sourcesContent":["/*\n * Copyright 2020 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 */\n\nimport fs from 'node:fs';\nimport { dirname, resolve as resolvePath } from 'node:path';\n\n/**\n * A function that takes a set of path fragments and resolves them into a\n * single complete path, relative to some root.\n *\n * @public\n */\nexport type ResolveFunc = (...paths: string[]) => string;\n\n/**\n * Resolved paths relative to the target project, based on `process.cwd()`.\n * Lazily initialized on first property access. Re-resolves automatically\n * when `process.cwd()` changes.\n *\n * @public\n */\nexport type TargetPaths = {\n /** The target package directory. */\n dir: string;\n\n /** The target monorepo root directory. */\n rootDir: string;\n\n /** Resolve a path relative to the target package directory. */\n resolve: ResolveFunc;\n\n /** Resolve a path relative to the target repo root. */\n resolveRoot: ResolveFunc;\n};\n\n/**\n * Resolved paths relative to a specific package in the repository.\n *\n * @public\n */\nexport type OwnPaths = {\n /** The package root directory. */\n dir: string;\n\n /** The monorepo root directory containing the package. */\n rootDir: string;\n\n /** Resolve a path relative to the package root. */\n resolve: ResolveFunc;\n\n /** Resolve a path relative to the monorepo root containing the package. */\n resolveRoot: ResolveFunc;\n};\n\n/**\n * Common paths and resolve functions used by the cli.\n * Currently assumes it is being executed within a monorepo.\n *\n * @public\n * @deprecated Use {@link targetPaths} and {@link findOwnPaths} instead.\n */\nexport type Paths = {\n ownDir: string;\n ownRoot: string;\n targetDir: string;\n targetRoot: string;\n resolveOwn: ResolveFunc;\n resolveOwnRoot: ResolveFunc;\n resolveTarget: ResolveFunc;\n resolveTargetRoot: ResolveFunc;\n};\n\n// Looks for a package.json with a workspace config to identify the root of the monorepo\nexport function findRootPath(\n searchDir: string,\n filterFunc: (pkgJsonPath: string) => boolean,\n): string | undefined {\n let path = searchDir;\n\n // Some confidence check to avoid infinite loop\n for (let i = 0; i < 1000; i++) {\n const packagePath = resolvePath(path, 'package.json');\n const exists = fs.existsSync(packagePath);\n if (exists && filterFunc(packagePath)) {\n return path;\n }\n\n const newPath = dirname(path);\n if (newPath === path) {\n return undefined;\n }\n path = newPath;\n }\n\n throw new Error(\n `Iteration limit reached when searching for root package.json at ${searchDir}`,\n );\n}\n\n// Finds the root of the monorepo that the package exists in.\nexport function findOwnRootDir(ownDir: string) {\n const isLocal = fs.existsSync(resolvePath(ownDir, 'src'));\n if (!isLocal) {\n throw new Error(\n 'Tried to access monorepo package root dir outside of Backstage repository',\n );\n }\n\n return resolvePath(ownDir, '../..');\n}\n\n// Hierarchical directory cache shared across all OwnPathsImpl instances.\n// When we resolve a searchDir to its package root, we also cache every\n// intermediate directory, so sibling directories share work.\nconst dirCache = new Map<string, string>();\n\nclass OwnPathsImpl implements OwnPaths {\n static #instanceCache = new Map<string, OwnPathsImpl>();\n\n static find(searchDir: string): OwnPathsImpl {\n const dir = OwnPathsImpl.findDir(searchDir);\n let instance = OwnPathsImpl.#instanceCache.get(dir);\n if (!instance) {\n instance = new OwnPathsImpl(dir);\n OwnPathsImpl.#instanceCache.set(dir, instance);\n }\n return instance;\n }\n\n static findDir(searchDir: string): string {\n const visited: string[] = [];\n let dir = searchDir;\n\n for (let i = 0; i < 1000; i++) {\n const cached = dirCache.get(dir);\n if (cached !== undefined) {\n for (const d of visited) {\n dirCache.set(d, cached);\n }\n return cached;\n }\n\n visited.push(dir);\n\n if (fs.existsSync(resolvePath(dir, 'package.json'))) {\n for (const d of visited) {\n dirCache.set(d, dir);\n }\n return dir;\n }\n\n const newDir = dirname(dir);\n if (newDir === dir) {\n break;\n }\n dir = newDir;\n }\n\n throw new Error(\n `No package.json found while searching for package root of ${searchDir}`,\n );\n }\n\n #dir: string;\n #rootDir: string | undefined;\n\n private constructor(dir: string) {\n this.#dir = dir;\n }\n\n get dir(): string {\n return this.#dir;\n }\n\n get rootDir(): string {\n this.#rootDir ??= findOwnRootDir(this.#dir);\n return this.#rootDir;\n }\n\n resolve = (...paths: string[]): string => {\n return resolvePath(this.#dir, ...paths);\n };\n\n resolveRoot = (...paths: string[]): string => {\n return resolvePath(this.rootDir, ...paths);\n };\n}\n\n// Finds the root of a given package\nexport function findOwnDir(searchDir: string) {\n return OwnPathsImpl.findDir(searchDir);\n}\n\n// Used by the test utility in testUtils.ts to override targetPaths\nexport let targetPathsOverride: TargetPaths | undefined;\n\n/** @internal */\nexport function setTargetPathsOverride(override: TargetPaths | undefined) {\n targetPathsOverride = override;\n}\n\nclass TargetPathsImpl implements TargetPaths {\n #cwd: string | undefined;\n #dir: string | undefined;\n #rootDir: string | undefined;\n\n get dir(): string {\n if (targetPathsOverride) {\n return targetPathsOverride.dir;\n }\n const cwd = process.cwd();\n if (this.#dir !== undefined && this.#cwd === cwd) {\n return this.#dir;\n }\n this.#cwd = cwd;\n this.#rootDir = undefined;\n // Drive letter can end up being lowercased here on Windows, bring back to uppercase for consistency\n this.#dir = fs\n .realpathSync(cwd)\n .replace(/^[a-z]:/, str => str.toLocaleUpperCase('en-US'));\n return this.#dir;\n }\n\n get rootDir(): string {\n if (targetPathsOverride) {\n return targetPathsOverride.rootDir;\n }\n // Access dir first to ensure cwd is fresh, which also invalidates rootDir on cwd change\n const dir = this.dir;\n if (this.#rootDir !== undefined) {\n return this.#rootDir;\n }\n // Lazy init to only crash commands that require a monorepo when we're not in one\n this.#rootDir =\n findRootPath(dir, path => {\n try {\n const content = fs.readFileSync(path, 'utf8');\n const data = JSON.parse(content);\n return Boolean(data.workspaces);\n } catch (error) {\n throw new Error(\n `Failed to parse package.json file while searching for root, ${error}`,\n );\n }\n }) ?? dir;\n return this.#rootDir;\n }\n\n resolve = (...paths: string[]): string => {\n if (targetPathsOverride) {\n return targetPathsOverride.resolve(...paths);\n }\n return resolvePath(this.dir, ...paths);\n };\n\n resolveRoot = (...paths: string[]): string => {\n if (targetPathsOverride) {\n return targetPathsOverride.resolveRoot(...paths);\n }\n return resolvePath(this.rootDir, ...paths);\n };\n}\n\n/**\n * Lazily resolved paths relative to the target project. Import this directly\n * for cwd-based path resolution without needing `__dirname`.\n *\n * @public\n */\nexport const targetPaths: TargetPaths = new TargetPathsImpl();\n\n/**\n * Find paths relative to the package that the calling code lives in.\n *\n * Results are cached per package root, and the package root lookup uses a\n * hierarchical directory cache so that multiple calls from different\n * subdirectories within the same package share work.\n *\n * @public\n */\nexport function findOwnPaths(searchDir: string): OwnPaths {\n return OwnPathsImpl.find(searchDir);\n}\n\n/**\n * Find paths related to a package and its execution context.\n *\n * @public\n * @deprecated Use {@link targetPaths} for cwd-based paths and\n * {@link findOwnPaths} for package-relative paths instead.\n *\n * @example\n *\n * const paths = findPaths(__dirname)\n */\nexport function findPaths(searchDir: string): Paths {\n const own = findOwnPaths(searchDir);\n return {\n get ownDir() {\n return own.dir;\n },\n get ownRoot() {\n return own.rootDir;\n },\n get targetDir() {\n return targetPaths.dir;\n },\n get targetRoot() {\n return targetPaths.rootDir;\n },\n resolveOwn: own.resolve,\n resolveOwnRoot: own.resolveRoot,\n resolveTarget: targetPaths.resolve,\n resolveTargetRoot: targetPaths.resolveRoot,\n };\n}\n\n/**\n * The name of the backstage's config file\n *\n * @public\n */\nexport const BACKSTAGE_JSON = 'backstage.json';\n"],"names":["resolvePath","fs","dirname","targetPathsOverride"],"mappings":";;;;;;;;;AAsFO,SAAS,YAAA,CACd,WACA,UAAA,EACoB;AACpB,EAAA,IAAI,IAAA,GAAO,SAAA;AAGX,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,GAAA,EAAM,CAAA,EAAA,EAAK;AAC7B,IAAA,MAAM,WAAA,GAAcA,iBAAA,CAAY,IAAA,EAAM,cAAc,CAA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EAA0B;AAClD,EAAA,MAAM,GAAA,GAAM,aAAa,SAAS,CAAA;AAClC,EAAA,OAAO;AAAA,IACL,IAAI,MAAA,GAAS;AACX,MAAA,OAAO,GAAA,CAAI,GAAA;AAAA,IACb,CAAA;AAAA,IACA,IAAI,OAAA,GAAU;AACZ,MAAA,OAAO,GAAA,CAAI,OAAA;AAAA,IACb,CAAA;AAAA,IACA,IAAI,SAAA,GAAY;AACd,MAAA,OAAO,WAAA,CAAY,GAAA;AAAA,IACrB,CAAA;AAAA,IACA,IAAI,UAAA,GAAa;AACf,MAAA,OAAO,WAAA,CAAY,OAAA;AAAA,IACrB,CAAA;AAAA,IACA,YAAY,GAAA,CAAI,OAAA;AAAA,IAChB,gBAAgB,GAAA,CAAI,WAAA;AAAA,IACpB,eAAe,WAAA,CAAY,OAAA;AAAA,IAC3B,mBAAmB,WAAA,CAAY;AAAA,GACjC;AACF;AAOO,MAAM,cAAA,GAAiB;;;;;;;;;;"} |
+29
-15
| { | ||
| "name": "@backstage/cli-common", | ||
| "version": "0.1.18", | ||
| "version": "0.2.0-next.0", | ||
| "description": "Common functionality used by cli, backend, and create-app", | ||
@@ -9,5 +9,3 @@ "backstage": { | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "main": "dist/index.cjs.js", | ||
| "types": "dist/index.d.ts" | ||
| "access": "public" | ||
| }, | ||
@@ -24,4 +22,27 @@ "keywords": [ | ||
| "license": "Apache-2.0", | ||
| "main": "dist/index.cjs.js", | ||
| "types": "dist/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "require": "./dist/index.cjs.js", | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.cjs.js" | ||
| }, | ||
| "./testUtils": { | ||
| "require": "./dist/testUtils.cjs.js", | ||
| "types": "./dist/testUtils.d.ts", | ||
| "default": "./dist/testUtils.cjs.js" | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "main": "./dist/index.cjs.js", | ||
| "types": "./dist/index.d.ts", | ||
| "typesVersions": { | ||
| "*": { | ||
| "testUtils": [ | ||
| "dist/testUtils.d.ts" | ||
| ], | ||
| "package.json": [ | ||
| "package.json" | ||
| ] | ||
| } | ||
| }, | ||
| "files": [ | ||
@@ -40,3 +61,3 @@ "dist" | ||
| "dependencies": { | ||
| "@backstage/errors": "^1.2.7", | ||
| "@backstage/errors": "1.2.7", | ||
| "cross-spawn": "^7.0.3", | ||
@@ -47,13 +68,6 @@ "global-agent": "^3.0.0", | ||
| "devDependencies": { | ||
| "@backstage/cli": "^0.35.4", | ||
| "@backstage/cli": "0.35.5-next.0", | ||
| "@types/cross-spawn": "^6.0.2", | ||
| "@types/node": "^22.13.14" | ||
| }, | ||
| "typesVersions": { | ||
| "*": { | ||
| "package.json": [ | ||
| "package.json" | ||
| ] | ||
| } | ||
| } | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
59487
40.45%19
18.75%625
48.81%Updated