Skip to content

Commit

Permalink
fix(@turbo/repository): update types to latest signature (#7289)
Browse files Browse the repository at this point in the history
Fix types and update some readme instructions
  • Loading branch information
mehulkar authored Feb 6, 2024
1 parent 6189ce4 commit 4fe5a9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
4 changes: 1 addition & 3 deletions packages/turbo-repository/js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ export class Package {
readonly relativePath: string;
}
export class PackageManager {
/** The package manager name (lower case). */
/** The package manager name in lower case. */
readonly name: string;
/** The package manager version (semver). */
readonly version: string;
}
export class Workspace {
/** The absolute path to the workspace root. */
Expand Down
33 changes: 5 additions & 28 deletions packages/turbo-repository/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,11 @@ pnpm i

Build native library and js wrapper

```
pnpm exec napi build --platform
```sh
pnpm build
```

## Test
## Example Usage

```
greg@crisp:turborepo-napi (inference_crate *)$ node
Welcome to Node.js v18.14.1.
Type ".help" for more information.
> let tr = require('./index.js');
undefined
> tr
{
Repository: [Function: Repository],
}
> let repo = tr.Repository.detectJS('..')
undefined
> repo.root
'/Users/greg/workspace/turborepo'
> repo.isMonorepo
true
>
> let napiPackage = tr.Repository.detectJS()
undefined
> napiPackage.root
'/Users/greg/workspace/turborepo/crates/turborepo-napi'
> napiPackage.isMonorepo
false
>
```
You can see examples in the `__tests__` directory, or see a simple script in `node scripts/test.mjs`.
Note that this may fall out of date over time, but it's meant to be used during the early iterations.
5 changes: 5 additions & 0 deletions packages/turbo-repository/scripts/test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Workspace } from "../js/dist/index.js";
const workspace = await Workspace.find();
const packages = await workspace.findPackages();
const packagePaths = packages.map((pkg) => pkg.relativePath);
console.log(JSON.stringify(packagePaths, null, 2));

0 comments on commit 4fe5a9d

Please sign in to comment.