Skip to content

Commit

Permalink
Fix the toastfile
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchowfun committed Nov 28, 2024
1 parent b9f56e1 commit 62ba578
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 24 deletions.
17 changes: 12 additions & 5 deletions src/generate_typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,14 @@ fn write_type<T: Write>(
}
},
schema::TypeVariant::Custom(import, name) => {
write_custom_type(buffer, imports, namespace, import, name, Some(direction))?;
write_custom_type(
buffer,
imports,
namespace,
import.as_ref(),
name,
Some(direction),
)?;
}
schema::TypeVariant::F64 => {
write!(buffer, "number")?;
Expand Down Expand Up @@ -1642,7 +1649,7 @@ fn write_custom_type<T: Write>(
buffer: &mut T,
imports: &BTreeMap<Identifier, schema::Namespace>,
namespace: &schema::Namespace,
import: &Option<Identifier>,
import: Option<&Identifier>,
name: &Identifier,
direction: Option<Direction>,
) -> Result<(), fmt::Error> {
Expand Down Expand Up @@ -1855,7 +1862,7 @@ fn write_atlas_calculation<T: Write>(
schema::TypeVariant::Custom(import, name) => {
write_indentation(buffer, indentation)?;
write!(buffer, "payloadAtlas = ")?;
write_custom_type(buffer, imports, namespace, import, name, None)?;
write_custom_type(buffer, imports, namespace, import.as_ref(), name, None)?;
writeln!(buffer, ".atlas(payload);")
}
schema::TypeVariant::F64 => {
Expand Down Expand Up @@ -2089,7 +2096,7 @@ fn write_serialization_invocation<T: Write>(
schema::TypeVariant::Custom(import, name) => {
write_indentation(buffer, indentation)?;
write!(buffer, "offset = ")?;
write_custom_type(buffer, imports, namespace, import, name, None)?;
write_custom_type(buffer, imports, namespace, import.as_ref(), name, None)?;
writeln!(
buffer,
".serializeWithAtlasUnsafe(dataView, offset, payload, payloadAtlas);",
Expand Down Expand Up @@ -2409,7 +2416,7 @@ fn write_deserialization_invocation<T: Write>(
schema::TypeVariant::Custom(import, name) => {
write_indentation(buffer, indentation)?;
write!(buffer, "let payload = ")?;
write_custom_type(buffer, imports, namespace, import, name, None)?;
write_custom_type(buffer, imports, namespace, import.as_ref(), name, None)?;
writeln!(buffer, ".deserializeUnsafe(dataView);")?;
write_indentation(buffer, indentation)?;
writeln!(buffer, "offset = dataView.byteLength;")
Expand Down
2 changes: 1 addition & 1 deletion src/schema_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn load_schemas(
// Perform a depth-first traversal of the transitive dependencies.
while let Some((namespace, path, origin)) = schemas_to_load.pop() {
// Read the file.
let contents = match read_to_string(&base_path.join(&path)) {
let contents = match read_to_string(base_path.join(&path)) {
Ok(contents) => contents,
Err(error) => {
let message = format!("Unable to load {}.", path.to_string_lossy().code_str());
Expand Down
45 changes: 27 additions & 18 deletions toast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ tasks:
for SCENARIO in benchmarks/rust examples/rust integration_tests/rust; do
echo "Validating $SCENARIO..."
(
cd "$SCENARIO" && \
cargo-offline check && \
cargo-offline clippy --all-features --all-targets --workspace && \
cargo-fmt --check && \
cd "$SCENARIO"
cargo-offline check
cargo-offline clippy --all-features --all-targets --workspace
cargo-fmt --check
cargo-offline run
)
done
Expand All @@ -218,7 +218,12 @@ tasks:
integration_tests/typescript_web
do
echo "Validating $SCENARIO..."
(cd "$SCENARIO" && npm ci && npm run main && npm run lint)
(
cd "$SCENARIO"
npm ci
npm run main
npm run lint
)
done
# Validate the data from the integration test.
Expand Down Expand Up @@ -247,19 +252,19 @@ tasks:
# Lint the Rust projects.
for PROJECT_PATH in . benchmarks/rust examples/rust integration_tests/rust; do
(
cd "$PROJECT_PATH" &&
cd "$PROJECT_PATH"
# Lint the code with Clippy.
cargo-offline clippy --all-features --all-targets --workspace &&
cargo-offline clippy --all-features --all-targets --workspace
# Check code formatting with Rustfmt. See [ref:format_macros] for an explanation of the
# `rg` commands.
rg --type rust --files-with-matches '' src | xargs sed -i 's/!(/_(/g' &&
rg --type rust --files-with-matches '' src | xargs sed -i 's/^\([^ (]*\)_(/\1!(/g' &&
rg --type rust --files-with-matches '' src | xargs sed -i 's/!(/_(/g'
rg --type rust --files-with-matches '' src | xargs sed -i 's/^\([^ (]*\)_(/\1!(/g'
if ! cargo-fmt --check; then
echo 'ERROR: Please correct the formatting errors above.' 1>&2
exit 1
fi &&
fi
rg --type rust --files-with-matches '' src | xargs sed -i 's/_(/!(/g'
# Forbid unconsolidated `use` declarations.
Expand Down Expand Up @@ -287,9 +292,9 @@ tasks:
integration_tests/typescript_web
do
(
cd "$PROJECT_PATH" &&
npm ci &&
npm run lint
cd "$PROJECT_PATH"
npm ci
npm run
)
done
Expand Down Expand Up @@ -331,13 +336,13 @@ tasks:
# Format the Rust projects.
for PROJECT_PATH in . benchmarks/rust examples/rust integration_tests/rust; do
(
cd "$PROJECT_PATH" &&
cd "$PROJECT_PATH"
# We temporarily convert macro invocations into function calls so Rustfmt's
# `trailing_comma` feature applies to macro arguments [tag:format_macros].
rg --type rust --files-with-matches '' src | xargs sed -i 's/!(/_(/g' &&
rg --type rust --files-with-matches '' src | xargs sed -i 's/^\([^ (]*\)_(/\1!(/g' &&
cargo-fmt &&
rg --type rust --files-with-matches '' src | xargs sed -i 's/!(/_(/g'
rg --type rust --files-with-matches '' src | xargs sed -i 's/^\([^ (]*\)_(/\1!(/g'
cargo-fmt
rg --type rust --files-with-matches '' src | xargs sed -i 's/_(/!(/g'
)
done
Expand All @@ -349,7 +354,11 @@ tasks:
integration_tests/typescript_node \
integration_tests/typescript_web
do
(cd "$PROJECT_PATH" && npm ci && npm run format)
(
cd "$PROJECT_PATH"
npm ci
npm run format
)
done
release:
Expand Down

0 comments on commit 62ba578

Please sign in to comment.