diff --git a/.changeset/new-cows-cheer.md b/.changeset/new-cows-cheer.md new file mode 100644 index 00000000..ad8ffac9 --- /dev/null +++ b/.changeset/new-cows-cheer.md @@ -0,0 +1,5 @@ +--- +"@nodesecure/scanner": major +--- + +refactor: rename cwd() to workingDir() diff --git a/README.md b/README.md index 78dfb62d..2165d4e7 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ await Promise.allSettled(promises); See [types.ts](https://github.com/NodeSecure/scanner/blob/master/workspaces/scanner/src/types.ts) for a complete TypeScript definition. ```ts -function cwd( +function workingDir( location: string, - options?: Scanner.CwdOptions, + options?: Scanner.WorkingDirOptions, logger?: Scanner.Logger ): Promise; function from( @@ -77,11 +77,11 @@ function verify( ): Promise; ``` -`CwdOptions` and `FromOptions` are described with the following TypeScript interfaces: +`WorkingDirOptions` and `FromOptions` are described with the following TypeScript interfaces: ```ts -type CwdOptions = Options & { +type WorkingDirOptions = Options & { /** * NPM runtime configuration (such as local .npmrc file) * It is optionally used to fetch registry authentication tokens @@ -94,7 +94,7 @@ type FromOptions = Omit; interface Options { /** * Specifies the maximum depth to traverse for each root dependency. - * For example, a value of 2 would mean only traversing dependencies and their immediate dependencies. + * A value of 2 would mean only traversing deps and their immediate deps. * * @default Infinity */ diff --git a/workspaces/scanner/src/index.ts b/workspaces/scanner/src/index.ts index e3db7e58..446d3ef3 100644 --- a/workspaces/scanner/src/index.ts +++ b/workspaces/scanner/src/index.ts @@ -19,7 +19,7 @@ import { comparePayloads } from "./comparePayloads.ts"; import type { Options } from "./types.ts"; // CONSTANTS -const kDefaultCwdOptions = { +const kDefaultWorkingDirOptions = { forceRootAnalysis: true, includeDevDeps: false }; @@ -27,7 +27,7 @@ const kDefaultCwdOptions = { export * from "./types.ts"; export * from "./extractors/index.ts"; -export type CwdOptions = Options & { +export type WorkingDirOptions = Options & { /** * NPM runtime configuration (such as local .npmrc file) * It is optionally used to fetch registry authentication tokens @@ -35,9 +35,9 @@ export type CwdOptions = Options & { npmRcConfig?: Config; }; -export async function cwd( +export async function workingDir( location = process.cwd(), - options: CwdOptions = {}, + options: WorkingDirOptions = {}, logger = new Logger() ) { const registry = options.registry ? @@ -50,7 +50,7 @@ export async function cwd( const finalizedOptions = Object.assign( { location }, - kDefaultCwdOptions, + kDefaultWorkingDirOptions, { ...options, packageLock, diff --git a/workspaces/scanner/test/depWalker.spec.ts b/workspaces/scanner/test/depWalker.spec.ts index ca1d5dd4..a7efc545 100644 --- a/workspaces/scanner/test/depWalker.spec.ts +++ b/workspaces/scanner/test/depWalker.spec.ts @@ -14,7 +14,7 @@ import { depWalker } from "../src/depWalker.ts"; import { Logger, from, - cwd, + workingDir, type Payload, type DependencyVersion } from "../src/index.ts"; @@ -342,7 +342,7 @@ test("highlight contacts from a remote package", async() => { describe("scanner.cwd()", () => { test("should parse author, homepage and links for a local package who doesn't exist on the remote registry", async() => { - const result = await cwd(path.join(kFixturePath, "non-npm-package")); + const result = await workingDir(path.join(kFixturePath, "non-npm-package")); const dep = result.dependencies["non-npm-package"]; const v1 = dep.versions["1.0.0"]; @@ -368,7 +368,7 @@ describe("scanner.cwd()", () => { }); test("should parse local manifest author field without throwing when attempting to highlight contacts", async() => { - const { dependencies } = await cwd( + const { dependencies } = await workingDir( path.join(kFixturePath, "non-valid-authors") ); const pkg = dependencies["random-package"]; @@ -380,7 +380,7 @@ describe("scanner.cwd()", () => { }); test("should scan a workspace package.json and assign 'workspace' as the package name", async() => { - const result = await cwd( + const result = await workingDir( path.join(kFixturePath, "workspace-no-name-version") );