Skip to content

Commit

Permalink
feat: make schema files next to model
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Sep 3, 2024
1 parent 1df7a98 commit 9bf96c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion js/packages/quary-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
"package-web": "webpack --config webpack.web.config.js --mode production --devtool hidden-source-map --env STAGE=production",
"package-node": "webpack --config webpack.node.config.js --mode production --devtool hidden-source-map --env STAGE=production",
"lint": "eslint src --ext ts",
"run-in-browser": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=. ../../../../analytics"
"run-in-browser": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=. ../../../rust/core/src/init"
},
"devDependencies": {
"@quary/eslint-config-shared": "workspace:*",
Expand Down
24 changes: 15 additions & 9 deletions rust/wasm-binding/src/rpc_proto_defined_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,19 @@ async fn create_model_schema_entry_internal(
path.push(model.file_path.as_str());
path.pop();

let mut path = PathBuf::from(&project_root);
path.push(model.file_path.as_str());
let file = path.file_stem().ok_or("Failed to get file stem")?;

// Make the schema.yaml file be in there
let mut schema_path = path.clone();
schema_path.push("schema.yaml");
let mut schema_path = PathBuf::from(&project_root);
schema_path.push(model.file_path.as_str());
schema_path.pop();
schema_path.push(format!(
"{}.yaml",
file.to_str()
.ok_or("Failed to convert file stem to string")?
));
let string_schema_path = schema_path
.to_str()
.ok_or("Failed to convert path to string")?
Expand Down Expand Up @@ -1943,7 +1953,7 @@ models:
.unwrap();

let binding = written_files.borrow();
let updated_content = binding.get(&"models/schema.yaml".to_string()).unwrap();
let updated_content = binding.get(&"models/shifts.yaml".to_string()).unwrap();

assert_eq!(
updated_content,
Expand Down Expand Up @@ -1976,11 +1986,7 @@ models:
"models/schema.yaml".to_string(),
quary_proto::File {
name: "models/schema.yaml".to_string(),
contents: prost::bytes::Bytes::from(
"
models:
",
),
contents: prost::bytes::Bytes::from(""),
},
),
]
Expand All @@ -1999,7 +2005,7 @@ models:
.unwrap();

let binding = written_files.borrow();
let updated_content = binding.get(&"models/schema.yaml".to_string()).unwrap();
let updated_content = binding.get(&"models/shifts.yaml".to_string()).unwrap();

assert_eq!(
updated_content,
Expand Down

0 comments on commit 9bf96c0

Please sign in to comment.