-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move all workspace dependencies to workspace
- Loading branch information
1 parent
9e6ffe2
commit fa01c81
Showing
12 changed files
with
1,024 additions
and
413 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,16 @@ members = [ | |
"manager", | ||
"runner-protocol", | ||
] | ||
|
||
[workspace.package] | ||
version = "0.0.1" | ||
edition = "2021" | ||
authors = ["Rivet Gaming, LLC <[email protected]>"] | ||
license = "Apache-2.0" | ||
|
||
[workspace.dependencies] | ||
container-runner = { path = "container-runner" } | ||
echo = { path = "echo" } | ||
isolate-v8-runner = { path = "isolate-v8-runner" } | ||
runner-protocol = { path = "runner-protocol", package = "pegboard-runner-protocol" } | ||
|
27 changes: 0 additions & 27 deletions
27
packages/services/cluster/src/ops/server/dc-init/Cargo.toml
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
packages/services/cluster/src/ops/server/dc-init/src/lib.rs
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
packages/services/cluster/src/ops/server/dc-init/tests/integration.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env -S deno run --allow-net --allow-env --allow-read --allow-write | ||
|
||
import { parse, stringify } from "@std/toml"; | ||
import { walk } from "@std/fs"; | ||
import { join, relative } from "@std/path"; | ||
|
||
const rootDir = join(import.meta.dirname, "../.."); | ||
|
||
async function updateCargoToml() { | ||
const workspaceTomlPath = join(rootDir, "Cargo.toml"); | ||
const workspaceTomlContent = await Deno.readTextFile(workspaceTomlPath); | ||
const workspaceToml = parse(workspaceTomlContent); | ||
|
||
// Find all workspace members | ||
const members: string[] = []; | ||
for await ( | ||
const entry of walk(join(rootDir, "packages"), { | ||
includeDirs: false, | ||
exts: ["toml"], | ||
}) | ||
) { | ||
// Exclude infra packages | ||
if ( | ||
entry.path.includes("packages/infra/client") || | ||
entry.path.includes("packages/infra/job-runner") | ||
) { | ||
continue; | ||
} | ||
|
||
const packagePath = relative( | ||
rootDir, | ||
entry.path.replace(/\/Cargo\.toml$/, ""), | ||
); | ||
members.push(packagePath); | ||
} | ||
|
||
// Hardcode extra workspace members | ||
members.push("sdks/full/rust"); | ||
|
||
// Remove path dependencies, since we'll replace these. This lets us | ||
// preserve existing external dependencies. | ||
const existingDependencies = workspaceToml.workspace?.dependencies || {}; | ||
for (const [name, dep] of Object.entries(existingDependencies)) { | ||
if (dep && typeof dep === "object" && "path" in dep) { | ||
delete existingDependencies[name]; | ||
} | ||
} | ||
|
||
// Build new workspace dependencies | ||
const newDependencies: Record<string, any> = {}; | ||
for (const packagePath of members) { | ||
const packageTomlPath = join(rootDir, packagePath, "Cargo.toml"); | ||
const packageTomlContent = await Deno.readTextFile(packageTomlPath); | ||
const packageToml = parse(packageTomlContent); | ||
|
||
// Save to workspace | ||
newDependencies[packageToml.package.name] = { | ||
path: packagePath, | ||
}; | ||
|
||
// // Replace all package dependencies that refer to a workspace package to use `*.workspace = true` | ||
// for ( | ||
// const [depName, dep] of Object.entries(packageToml.dependencies || {}) | ||
// ) { | ||
// if (dep && typeof dep === "object" && "path" in dep) { | ||
// const depAbsolutePath = join(packagePath, dep.path); | ||
// const depRelativePath = relative(rootDir, depAbsolutePath); | ||
// if (members.includes(depRelativePath)) { | ||
// delete packageToml.dependencies[depName].path; | ||
// packageToml.dependencies[depName].workspace = true; | ||
// } | ||
// } | ||
// } | ||
|
||
// // Write the updated package Cargo.toml | ||
// const updatedPackageTomlContent = stringify(packageToml); | ||
// await Deno.writeTextFile(packageTomlPath, updatedPackageTomlContent); | ||
} | ||
|
||
// Update and write workspace | ||
workspaceToml.workspace = workspaceToml.workspace || {}; | ||
workspaceToml.workspace.members = members; | ||
workspaceToml.workspace.dependencies = { | ||
...existingDependencies, | ||
...newDependencies, | ||
}; | ||
|
||
const updatedTomlContent = stringify(workspaceToml); | ||
await Deno.writeTextFile(workspaceTomlPath, updatedTomlContent); | ||
} | ||
|
||
updateCargoToml().catch(console.error); |
Oops, something went wrong.