From 995bb871389b1c631ca9a25f11d9514c98798d88 Mon Sep 17 00:00:00 2001 From: Andrey Lunyov Date: Tue, 4 Jan 2022 15:18:33 -0800 Subject: [PATCH] Add `include` option to single project config file, and warn if it is used. Summary: In `v12` we have support for `include` array of glob patterns for directories that should be included when searching for relay files. In `rust` we do not have support for these patterns. Currently, if the new compiler is used with the config that has `include` section, we would show a confusing error message: ``` Error searching config: Invalid config file: "/Users/alunyov/relay-examples/todo/package.json": Found key `relay` in package.json, but failed incorrect value: The config file cannot be parsed as a multi-project config file due to: - Error("unknown field `artifactDirectory`, expected one of `name`, `root`, `header`, `codegenCommand`, `sources`, `excludes`, `projects`, `featureFlags`, `savedStateConfig`, `isDevVariableName`", line: 0, column: 0). It also cannot be a single project config file due to: - Error("unknown field `include`, expected one of `schema`, `src`, `artifactDirectory`, `excludes`, `schemaExtensions`, `noFutureProofEnums`, `language`, `customScalars`, `eagerEsModules`, `persistConfig`, `isDevVariableName`, `codegenCommand`, `jsModuleFormat`", line: 0, column: 0). ``` With this change, we will only warn, if the `include` is used. Reviewed By: voideanvalue Differential Revision: D33404317 fbshipit-source-id: 40cd03d40615e83fa58471c643d1eb7b423ff2da --- compiler/crates/relay-compiler/src/config.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/crates/relay-compiler/src/config.rs b/compiler/crates/relay-compiler/src/config.rs index 10beea8b99958..b9beaa3712e61 100644 --- a/compiler/crates/relay-compiler/src/config.rs +++ b/compiler/crates/relay-compiler/src/config.rs @@ -20,6 +20,7 @@ use fnv::{FnvBuildHasher, FnvHashSet}; use graphql_ir::{OperationDefinition, Program}; use indexmap::IndexMap; use intern::string_key::{Intern, StringKey}; +use log::warn; use persist_query::PersistError; use rayon::prelude::*; use regex::Regex; @@ -560,6 +561,9 @@ pub struct SingleProjectConfigFile { /// the babel plugin needs `artifactDirectory` set as well. pub artifact_directory: Option, + /// This is deprecated field, we're not using it in the V13. + pub include: Vec, + /// Directories to ignore under src /// default: ['**/node_modules/**', '**/__mocks__/**', '**/__generated__/**'], #[serde(alias = "exclude")] @@ -607,6 +611,7 @@ impl Default for SingleProjectConfigFile { schema: Default::default(), src: Default::default(), artifact_directory: Default::default(), + include: vec![], excludes: get_default_excludes(), schema_extensions: vec![], no_future_proof_enums: false, @@ -671,6 +676,13 @@ impl SingleProjectConfigFile { } fn create_multi_project_config(self, config_path: &Path) -> Result { + if !self.include.is_empty() { + warn!( + r#"The configuration contains `include: {:#?}` section. This configuration option is no longer supported. Consider removing it."#, + &self.include + ); + } + let current_dir = std::env::current_dir().unwrap(); let common_root_dir = self.get_common_root(current_dir.clone()).map_err(|err| { Error::ConfigFileValidation {