Skip to content

Commit ddcbc1a

Browse files
[mvr-static] Adds plugin to detect MVR names in project (#112)
* Introduces mvr-static plugin -- recreated commit to deal with lockfile conflicts
1 parent b9ed79f commit ddcbc1a

File tree

14 files changed

+895
-1390
lines changed

14 files changed

+895
-1390
lines changed

.changeset/many-lamps-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@mysten/mvr-static': patch
3+
---
4+
5+
Introduces mvr-static package
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
tests/demo-project/
3+
CHANGELOG.md

packages/mvr-static/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# mvr-static
2+
3+
The mvr-static tool is a typescript CLI tool to generate a static file for Move Registry (mvr)
4+
resolution. This can be used to cache all MVR names for performance & security reasons, and used in
5+
the `NamedPackagesPlugin` (exported from `@mysten/sui`) in your project.
6+
7+
## Usage
8+
9+
### Generate a static file for MVR resolution
10+
11+
You can generate your static file by running the following command:
12+
13+
```bash
14+
pnpm dlx @mysten/mvr-static
15+
```
16+
17+
Available options:
18+
19+
- `--directory <directory>`: The directory to run the command in (defaults to `.`)
20+
- `--output <file-name>`: The output's file name (defaults to `mvr.ts`)
21+
- `--depth <depth>`: The depth of recursive search for MVR names (defaults to `10`)
22+
- `--url-mainnet <url>`: The URL to the mainnet MVR (defaults to
23+
`https://mainnet.mvr.mystenlabs.com`)
24+
- `--url-testnet <url>`: The URL to the testnet MVR (defaults to
25+
`https://testnet.mvr.mystenlabs.com`)
26+
- `--include <dir_patterns>`: The directory patterns to include in the search (defaults to
27+
`**/*.{js,ts,jsx,tsx,mjs,cjs}`)
28+
- `--exclude <dir_patterns>`: The directory patterns to exclude in the search (defaults to
29+
`'node_modules/**', '**/.*'`)
30+
- `--force`: Force overwrite the existing MVR file (useful in CI) (defaults to `false`)
31+
32+
### Use the static file in your project
33+
34+
Once you have your static file, you can use it in your project by importing it and passing it to the
35+
`NamedPackagesPlugin` in your project.
36+
37+
```ts
38+
import { NamedPackagesPlugin } from '@mysten/sui/src/transactions';
39+
40+
import { getMvrCache } from './mvr.ts';
41+
42+
// create a cache for your network.
43+
const cache = getMvrCache('mainnet');
44+
45+
const plugin = new NamedPackagesPlugin({
46+
// ...,
47+
overrides: cache,
48+
});
49+
```

packages/mvr-static/bin/parser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
// Copyright (c) Mysten Labs, Inc.
3+
// SPDX-License-Identifier: Apache-2.0
4+
require('../dist/execute.js');

packages/mvr-static/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@mysten/mvr-static",
3+
"author": "Mysten Labs <[email protected]>",
4+
"description": "The static generation tool for Move Registry (mvr)",
5+
"homepage": "https://sdk.mystenlabs.com",
6+
"version": "0.1.0",
7+
"license": "Apache-2.0",
8+
"files": [
9+
"CHANGELOG.md",
10+
"LICENSE",
11+
"README.md",
12+
"dist",
13+
"src"
14+
],
15+
"type": "commonjs",
16+
"main": "./dist/cjs/index.js",
17+
"module": "./dist/esm/index.js",
18+
"types": "./dist/cjs/index.d.ts",
19+
"scripts": {
20+
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
21+
"build": "tsc --build",
22+
"prepublishOnly": "pnpm build",
23+
"prettier:check": "prettier -c --ignore-unknown .",
24+
"prettier:fix": "prettier -w --ignore-unknown .",
25+
"eslint:check": "eslint --max-warnings=0 .",
26+
"eslint:fix": "pnpm run eslint:check --fix",
27+
"lint": "pnpm run eslint:check && pnpm run prettier:check",
28+
"lint:fix": "pnpm run eslint:fix && pnpm run prettier:fix",
29+
"test": "vitest run"
30+
},
31+
"bugs": {
32+
"url": "https://github.com/MystenLabs/mvr/issues/new"
33+
},
34+
"publishConfig": {
35+
"access": "public"
36+
},
37+
"devDependencies": {
38+
"@mysten/build-scripts": "workspace:*",
39+
"typescript": "^5.7.2",
40+
"vitest": "^2.1.8"
41+
},
42+
"dependencies": {
43+
"@mysten/sui": "workspace:*",
44+
"@types/node": "^22.10.5",
45+
"enquirer": "^2.4.1",
46+
"glob": "^11.0.1",
47+
"prettier": "^3.3.2"
48+
},
49+
"sideEffects": false,
50+
"bin": "./bin/parser.js"
51+
}

packages/mvr-static/src/execute.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) Mysten Labs, Inc.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import { parser } from './parsing.js';
4+
5+
parser();

0 commit comments

Comments
 (0)