Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-cows-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/scanner": major
---

refactor: rename cwd() to workingDir()
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scanner.Payload>;
function from(
Expand All @@ -77,11 +77,11 @@ function verify(
): Promise<tarball.ScannedPackageResult>;
```

`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
Expand All @@ -94,7 +94,7 @@ type FromOptions = Omit<Options, "includeDevDeps">;
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
*/
Expand Down
10 changes: 5 additions & 5 deletions workspaces/scanner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ import { comparePayloads } from "./comparePayloads.ts";
import type { Options } from "./types.ts";

// CONSTANTS
const kDefaultCwdOptions = {
const kDefaultWorkingDirOptions = {
forceRootAnalysis: true,
includeDevDeps: false
};

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
*/
npmRcConfig?: Config;
};

export async function cwd(
export async function workingDir(
location = process.cwd(),
options: CwdOptions = {},
options: WorkingDirOptions = {},
logger = new Logger()
) {
const registry = options.registry ?
Expand All @@ -50,7 +50,7 @@ export async function cwd(

const finalizedOptions = Object.assign(
{ location },
kDefaultCwdOptions,
kDefaultWorkingDirOptions,
{
...options,
packageLock,
Expand Down
8 changes: 4 additions & 4 deletions workspaces/scanner/test/depWalker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { depWalker } from "../src/depWalker.ts";
import {
Logger,
from,
cwd,
workingDir,
type Payload,
type DependencyVersion
} from "../src/index.ts";
Expand Down Expand Up @@ -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"];
Expand All @@ -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"];
Expand All @@ -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")
);

Expand Down
Loading