@latticexyz/cli 2.0.0-main-e196ca27 → 2.0.0-main-3bfee32c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mud.js +15 -9
- package/dist/mud.js.map +1 -1
- package/package.json +12 -12
- package/src/commands/dev-contracts.ts +33 -23
- package/src/runDeploy.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/cli",
|
|
3
|
-
"version": "2.0.0-main-
|
|
3
|
+
"version": "2.0.0-main-3bfee32c",
|
|
4
4
|
"description": "Command line interface for mud",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"yargs": "^17.7.1",
|
|
41
41
|
"zod": "^3.21.4",
|
|
42
42
|
"zod-validation-error": "^1.3.0",
|
|
43
|
-
"@latticexyz/abi-ts": "2.0.0-main-
|
|
44
|
-
"@latticexyz/common": "2.0.0-main-
|
|
45
|
-
"@latticexyz/config": "2.0.0-main-
|
|
46
|
-
"@latticexyz/gas-report": "2.0.0-main-
|
|
47
|
-
"@latticexyz/protocol-parser": "2.0.0-main-
|
|
48
|
-
"@latticexyz/schema-type": "2.0.0-main-
|
|
49
|
-
"@latticexyz/services": "2.0.0-main-
|
|
50
|
-
"@latticexyz/store": "2.0.0-main-
|
|
51
|
-
"@latticexyz/utils": "2.0.0-main-
|
|
52
|
-
"@latticexyz/world": "2.0.0-main-
|
|
53
|
-
"@latticexyz/world-modules": "2.0.0-main-
|
|
43
|
+
"@latticexyz/abi-ts": "2.0.0-main-3bfee32c",
|
|
44
|
+
"@latticexyz/common": "2.0.0-main-3bfee32c",
|
|
45
|
+
"@latticexyz/config": "2.0.0-main-3bfee32c",
|
|
46
|
+
"@latticexyz/gas-report": "2.0.0-main-3bfee32c",
|
|
47
|
+
"@latticexyz/protocol-parser": "2.0.0-main-3bfee32c",
|
|
48
|
+
"@latticexyz/schema-type": "2.0.0-main-3bfee32c",
|
|
49
|
+
"@latticexyz/services": "2.0.0-main-3bfee32c",
|
|
50
|
+
"@latticexyz/store": "2.0.0-main-3bfee32c",
|
|
51
|
+
"@latticexyz/utils": "2.0.0-main-3bfee32c",
|
|
52
|
+
"@latticexyz/world": "2.0.0-main-3bfee32c",
|
|
53
|
+
"@latticexyz/world-modules": "2.0.0-main-3bfee32c"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/debug": "^4.1.7",
|
|
@@ -9,8 +9,9 @@ import { WorldConfig } from "@latticexyz/world";
|
|
|
9
9
|
import { homedir } from "os";
|
|
10
10
|
import { rmSync } from "fs";
|
|
11
11
|
import { deployOptions, runDeploy } from "../runDeploy";
|
|
12
|
-
import { BehaviorSubject, debounceTime, exhaustMap } from "rxjs";
|
|
12
|
+
import { BehaviorSubject, debounceTime, exhaustMap, filter } from "rxjs";
|
|
13
13
|
import { Address } from "viem";
|
|
14
|
+
import { isDefined } from "@latticexyz/common/utils";
|
|
14
15
|
|
|
15
16
|
const devOptions = {
|
|
16
17
|
rpc: deployOptions.rpc,
|
|
@@ -52,13 +53,15 @@ const commandModule: CommandModule<typeof devOptions, InferredOptionTypes<typeof
|
|
|
52
53
|
|
|
53
54
|
// Watch for changes
|
|
54
55
|
const lastChange$ = new BehaviorSubject<number>(Date.now());
|
|
55
|
-
chokidar.watch([configPath, srcDir, scriptDir]).on("all", async (_, updatePath) => {
|
|
56
|
+
chokidar.watch([configPath, srcDir, scriptDir], { ignoreInitial: true }).on("all", async (_, updatePath) => {
|
|
56
57
|
if (updatePath.includes(configPath)) {
|
|
58
|
+
console.log(chalk.blue("Config changed, queuing deploy…"));
|
|
57
59
|
lastChange$.next(Date.now());
|
|
58
60
|
}
|
|
59
61
|
if (updatePath.includes(srcDir) || updatePath.includes(scriptDir)) {
|
|
60
62
|
// Ignore changes to codegen files to avoid an infinite loop
|
|
61
63
|
if (!updatePath.includes(initialConfig.codegenDirectory)) {
|
|
64
|
+
console.log(chalk.blue("Contracts changed, queuing deploy…"));
|
|
62
65
|
lastChange$.next(Date.now());
|
|
63
66
|
}
|
|
64
67
|
}
|
|
@@ -71,29 +74,36 @@ const commandModule: CommandModule<typeof devOptions, InferredOptionTypes<typeof
|
|
|
71
74
|
debounceTime(200),
|
|
72
75
|
exhaustMap(async (lastChange) => {
|
|
73
76
|
if (worldAddress) {
|
|
74
|
-
console.log(chalk.blue("
|
|
77
|
+
console.log(chalk.blue("Rebuilding and upgrading world…"));
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const deploy = await runDeploy({
|
|
82
|
+
...opts,
|
|
83
|
+
configPath,
|
|
84
|
+
rpc,
|
|
85
|
+
skipBuild: false,
|
|
86
|
+
printConfig: false,
|
|
87
|
+
profile: undefined,
|
|
88
|
+
saveDeployment: true,
|
|
89
|
+
worldAddress,
|
|
90
|
+
srcDir,
|
|
91
|
+
});
|
|
92
|
+
worldAddress = deploy.address;
|
|
93
|
+
// if there were changes while we were deploying, trigger it again
|
|
94
|
+
if (lastChange < lastChange$.value) {
|
|
95
|
+
lastChange$.next(lastChange$.value);
|
|
96
|
+
} else {
|
|
97
|
+
console.log(chalk.gray("\nWaiting for file changes…\n"));
|
|
98
|
+
}
|
|
99
|
+
return deploy;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error(chalk.bgRed(chalk.whiteBright("\n Error while attempting deploy \n")));
|
|
102
|
+
console.error(error);
|
|
103
|
+
console.log(chalk.gray("\nWaiting for file changes…\n"));
|
|
94
104
|
}
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
}),
|
|
106
|
+
filter(isDefined)
|
|
97
107
|
);
|
|
98
108
|
|
|
99
109
|
deploys$.subscribe();
|
package/src/runDeploy.ts
CHANGED
|
@@ -16,6 +16,8 @@ import { getChainId } from "viem/actions";
|
|
|
16
16
|
import { postDeploy } from "./utils/utils/postDeploy";
|
|
17
17
|
import { WorldDeploy } from "./deploy/common";
|
|
18
18
|
import { tablegen } from "@latticexyz/store/codegen";
|
|
19
|
+
import { worldgen } from "@latticexyz/world/node";
|
|
20
|
+
import { getExistingContracts } from "./utils/getExistingContracts";
|
|
19
21
|
|
|
20
22
|
export const deployOptions = {
|
|
21
23
|
configPath: { type: "string", desc: "Path to the config file" },
|
|
@@ -57,10 +59,10 @@ export async function runDeploy(opts: DeployOptions): Promise<WorldDeploy> {
|
|
|
57
59
|
)
|
|
58
60
|
);
|
|
59
61
|
|
|
60
|
-
// Run
|
|
62
|
+
// Run build
|
|
61
63
|
if (!opts.skipBuild) {
|
|
62
64
|
const outPath = path.join(srcDir, config.codegenDirectory);
|
|
63
|
-
await tablegen(config, outPath, remappings);
|
|
65
|
+
await Promise.all([tablegen(config, outPath, remappings), worldgen(config, getExistingContracts(srcDir), outPath)]);
|
|
64
66
|
await forge(["build"], { profile });
|
|
65
67
|
await execa("mud", ["abi-ts"], { stdio: "inherit" });
|
|
66
68
|
}
|