Skip to content

Commit

Permalink
Add the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed Sep 28, 2024
1 parent fdb2965 commit 952bac7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
15 changes: 15 additions & 0 deletions MAINTAINERS_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
To release, bump the version in `package.json` manually, push the commit to let the CI pipeline check the code.

Then build the latest version of the package:

```bash
pnpm build
```

Finally, publish the package to npm:

```bash
pnpm publish
```

Then go on GitHub and create a release and write the changelog.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ function getIndex(fileOrFolder: File | Folder): File | undefined;

Get the index (public API) of a slice or segment. When a segment is a file, it is its own index.

#### `isIndex`

```ts
export function isIndex(fileOrFolder: File | Folder): boolean;
```

Determine if a given file or folder is an index file (only files can be indexes, folders are accepted for convenience, but always return false).

#### `isSlice`

> [!NOTE]
Expand All @@ -208,4 +216,30 @@ Determine if this folder is a slice.

Slices are defined as folders that contain at least one segment. Additional segment names can be provided if some slice in project contains only unconventional segments.

#### `isCrossImportPublicApi`

```ts
export function isCrossImportPublicApi(
file: File,
{
inSlice,
forSlice,
layerPath,
}: { inSlice: string; forSlice: string; layerPath: string },
): boolean;
```

Check if a given file is a cross-import public API defined in the slice `inSlice` for the slice `forSlice` on a given layer.

For example:

```ts
const file = { path: "./src/entities/user/@x/product.ts", type: "file" };
isCrossImportPublicApi(file, {
inSlice: "user",
forSlice: "product",
layerPath: "./src/entities",
}); // true
```

[feature-sliced-design]: https://feature-sliced.design
2 changes: 1 addition & 1 deletion src/fsd-aware-traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function getIndex(fileOrFolder: File | Folder): File | undefined {
}
}

/** Check if a given file or folder is an index file. */
/** Determine if a given file or folder is an index file. */
export function isIndex(fileOrFolder: File | Folder): boolean {
return (
fileOrFolder.type === "file" && parse(fileOrFolder.path).name === "index"
Expand Down

0 comments on commit 952bac7

Please sign in to comment.