Skip to content

Commit f8103f2

Browse files
nojafcknitt
andauthored
Remove dev flag usage (#7934)
* Remove dev flag usage * Update bash tests * Remove nonexisting-dev-files sample * Correct rescript name * Update snapshots * Update count in suffix test * Update count in format test * Update snapshot * Remove obvious duplicated test * Lock file * Add changelog * Update CHANGELOG.md Co-authored-by: Christoph Knittel <[email protected]> * Update rewatch/src/cli.rs Co-authored-by: Christoph Knittel <[email protected]> * Increase wait for watch test to 20s * Hopefully increase the right timeout now... * Ok it needs both --------- Co-authored-by: Christoph Knittel <[email protected]> Co-authored-by: Christoph Knittel <[email protected]>
1 parent 11cde90 commit f8103f2

30 files changed

+106
-130
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
- Removed "rescript legacy" subcommand in favor of separate "rescript-legacy" binary. https://github.com/rescript-lang/rescript/pull/7928
1818
- Add comparison fn for Error in Result.equal and compare. https://github.com/rescript-lang/rescript/pull/7933
19+
- Rewatch: `"type": "dev"` and `dev-dependencies` will be compiled by default for local packages. The `--dev` flag no longer does anything. https://github.com/rescript-lang/rescript/pull/7934
1920

2021
#### :eyeglasses: Spec Compliance
2122

rewatch/src/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ pub fn initialize_build(
131131
filter: &Option<regex::Regex>,
132132
show_progress: bool,
133133
path: &Path,
134-
build_dev_deps: bool,
135134
snapshot_output: bool,
136135
warn_error: Option<String>,
137136
) -> Result<BuildCommandState> {
@@ -144,7 +143,7 @@ pub fn initialize_build(
144143
}
145144

146145
let timing_package_tree = Instant::now();
147-
let packages = packages::make(filter, &project_context, show_progress, build_dev_deps)?;
146+
let packages = packages::make(filter, &project_context, show_progress)?;
148147
let timing_package_tree_elapsed = timing_package_tree.elapsed();
149148

150149
let compiler_check = verify_compiler_info(&packages, &compiler);
@@ -540,7 +539,6 @@ pub fn build(
540539
show_progress: bool,
541540
no_timing: bool,
542541
create_sourcedirs: bool,
543-
build_dev_deps: bool,
544542
snapshot_output: bool,
545543
warn_error: Option<String>,
546544
) -> Result<BuildCommandState> {
@@ -555,7 +553,6 @@ pub fn build(
555553
filter,
556554
show_progress,
557555
path,
558-
build_dev_deps,
559556
snapshot_output,
560557
warn_error,
561558
)

rewatch/src/build/clean.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ pub fn cleanup_after_build(build_state: &BuildCommandState) {
331331
});
332332
}
333333

334-
pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool, clean_dev_deps: bool) -> Result<()> {
334+
pub fn clean(path: &Path, show_progress: bool, snapshot_output: bool) -> Result<()> {
335335
let project_context = ProjectContext::new(path)?;
336336
let compiler_info = build::get_compiler_info(&project_context)?;
337-
let packages = packages::make(&None, &project_context, show_progress, clean_dev_deps)?;
337+
let packages = packages::make(&None, &project_context, show_progress)?;
338338

339339
let timing_clean_compiler_assets = Instant::now();
340340
if !snapshot_output && show_progress {

rewatch/src/build/packages.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ fn read_dependencies(
288288
project_context: &ProjectContext,
289289
package_config: &Config,
290290
show_progress: bool,
291-
build_dev_deps: bool,
291+
is_local_dep: bool,
292292
) -> Vec<Dependency> {
293293
let mut dependencies = package_config.dependencies.to_owned().unwrap_or_default();
294294

295-
// Concatenate dev dependencies if build_dev_deps is true
296-
if build_dev_deps && let Some(dev_deps) = package_config.dev_dependencies.to_owned() {
295+
// Concatenate dev dependencies if is_local_dep is true
296+
if is_local_dep && let Some(dev_deps) = package_config.dev_dependencies.to_owned() {
297297
dependencies.extend(dev_deps);
298298
}
299299

@@ -367,7 +367,7 @@ fn read_dependencies(
367367
project_context,
368368
&config,
369369
show_progress,
370-
is_local_dep && build_dev_deps,
370+
is_local_dep,
371371
);
372372

373373
Dependency {
@@ -477,11 +477,7 @@ This inconsistency will cause issues with package resolution.\n",
477477
}
478478
}
479479

480-
fn read_packages(
481-
project_context: &ProjectContext,
482-
show_progress: bool,
483-
build_dev_deps: bool,
484-
) -> Result<AHashMap<String, Package>> {
480+
fn read_packages(project_context: &ProjectContext, show_progress: bool) -> Result<AHashMap<String, Package>> {
485481
// Store all packages and completely deduplicate them
486482
let mut map: AHashMap<String, Package> = AHashMap::new();
487483
let current_package = {
@@ -501,7 +497,7 @@ fn read_packages(
501497
project_context,
502498
&project_context.current_config,
503499
show_progress,
504-
build_dev_deps,
500+
/* is local dep */ true,
505501
));
506502
dependencies.iter().for_each(|d| {
507503
if !map.contains_key(&d.name) {
@@ -564,7 +560,6 @@ pub fn get_source_files(
564560
fn extend_with_children(
565561
filter: &Option<regex::Regex>,
566562
mut build: AHashMap<String, Package>,
567-
build_dev_deps: bool,
568563
) -> AHashMap<String, Package> {
569564
for (_key, package) in build.iter_mut() {
570565
let mut map: AHashMap<PathBuf, SourceFileMeta> = AHashMap::new();
@@ -577,7 +572,7 @@ fn extend_with_children(
577572
Path::new(&package.path),
578573
filter,
579574
source,
580-
package.is_local_dep && build_dev_deps,
575+
package.is_local_dep,
581576
)
582577
})
583578
.collect::<Vec<AHashMap<PathBuf, SourceFileMeta>>>()
@@ -620,13 +615,12 @@ pub fn make(
620615
filter: &Option<regex::Regex>,
621616
project_context: &ProjectContext,
622617
show_progress: bool,
623-
build_dev_deps: bool,
624618
) -> Result<AHashMap<String, Package>> {
625-
let map = read_packages(project_context, show_progress, build_dev_deps)?;
619+
let map = read_packages(project_context, show_progress)?;
626620

627621
/* Once we have the deduplicated packages, we can add the source files for each - to minimize
628622
* the IO */
629-
let result = extend_with_children(filter, map, build_dev_deps);
623+
let result = extend_with_children(filter, map);
630624

631625
Ok(result)
632626
}

rewatch/src/cli.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,10 @@ pub struct CreateSourceDirsArg {
212212

213213
#[derive(Args, Debug, Clone, Copy)]
214214
pub struct DevArg {
215-
/// Build development dependencies
215+
/// Deprecated: Build development dependencies
216216
///
217-
/// This is the flag to also compile development dependencies
218-
/// It's important to know that we currently do not discern between project src, and
219-
/// dependencies. So enabling this flag will enable building _all_ development dependencies of
220-
/// _all_ packages
221-
#[arg(long, default_value_t = false, num_args = 0..=1)]
217+
/// This is the flag no longer does anything and will be removed in future versions.
218+
#[arg(long, default_value_t = false, num_args = 0..=1, hide = true)]
222219
pub dev: bool,
223220
}
224221

rewatch/src/format.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ use crate::build::packages;
1212
use crate::cli::FileExtension;
1313
use clap::ValueEnum;
1414

15-
pub fn format(
16-
stdin_extension: Option<FileExtension>,
17-
check: bool,
18-
files: Vec<String>,
19-
format_dev_deps: bool,
20-
) -> Result<()> {
15+
pub fn format(stdin_extension: Option<FileExtension>, check: bool, files: Vec<String>) -> Result<()> {
2116
let bsc_path = helpers::get_bsc();
2217

2318
match stdin_extension {
@@ -26,7 +21,7 @@ pub fn format(
2621
}
2722
None => {
2823
let files = if files.is_empty() {
29-
get_files_in_scope(format_dev_deps)?
24+
get_files_in_scope()?
3025
} else {
3126
files
3227
};
@@ -37,13 +32,13 @@ pub fn format(
3732
Ok(())
3833
}
3934

40-
fn get_files_in_scope(format_dev_deps: bool) -> Result<Vec<String>> {
35+
fn get_files_in_scope() -> Result<Vec<String>> {
4136
let current_dir = std::env::current_dir()?;
4237
let project_context = project_context::ProjectContext::new(&current_dir)?;
4338

44-
let packages = packages::make(&None, &project_context, false, format_dev_deps)?;
39+
let packages = packages::make(&None, &project_context, false)?;
4540
let mut files: Vec<String> = Vec::new();
46-
let packages_to_format = project_context.get_scoped_local_packages(format_dev_deps);
41+
let packages_to_format = project_context.get_scoped_local_packages();
4742

4843
for (_package_name, package) in packages {
4944
if packages_to_format.contains(&package.name)

rewatch/src/main.rs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ fn main() -> Result<()> {
3636
cli::Command::Build(build_args) => {
3737
let _lock = get_lock(&build_args.folder);
3838

39+
if build_args.dev.dev {
40+
log::warn!(
41+
"`--dev no longer has any effect. Please remove it from your command. It will be removed in a future version."
42+
);
43+
}
44+
3945
match build::build(
4046
&build_args.filter,
4147
Path::new(&build_args.folder as &str),
4248
show_progress,
4349
build_args.no_timing,
4450
*build_args.create_sourcedirs,
45-
*build_args.dev,
4651
*build_args.snapshot_output,
4752
build_args.warn_error.clone(),
4853
) {
@@ -61,13 +66,18 @@ fn main() -> Result<()> {
6166
cli::Command::Watch(watch_args) => {
6267
let _lock = get_lock(&watch_args.folder);
6368

69+
if watch_args.dev.dev {
70+
log::warn!(
71+
"`--dev no longer has any effect. Please remove it from your command. It will be removed in a future version."
72+
);
73+
}
74+
6475
watcher::start(
6576
&watch_args.filter,
6677
show_progress,
6778
&watch_args.folder,
6879
(*watch_args.after_build).clone(),
6980
*watch_args.create_sourcedirs,
70-
*watch_args.dev,
7181
*watch_args.snapshot_output,
7282
watch_args.warn_error.clone(),
7383
);
@@ -81,19 +91,27 @@ fn main() -> Result<()> {
8191
} => {
8292
let _lock = get_lock(&folder);
8393

84-
build::clean::clean(
85-
Path::new(&folder as &str),
86-
show_progress,
87-
*snapshot_output,
88-
dev.dev,
89-
)
94+
if dev.dev {
95+
log::warn!(
96+
"`--dev no longer has any effect. Please remove it from your command. It will be removed in a future version."
97+
);
98+
}
99+
100+
build::clean::clean(Path::new(&folder as &str), show_progress, *snapshot_output)
90101
}
91102
cli::Command::Format {
92103
stdin,
93104
check,
94105
files,
95106
dev,
96-
} => format::format(stdin, check, files, dev.dev),
107+
} => {
108+
if dev.dev {
109+
log::warn!(
110+
"`--dev no longer has any effect. Please remove it from your command. It will be removed in a future version."
111+
);
112+
}
113+
format::format(stdin, check, files)
114+
}
97115
}
98116
}
99117

rewatch/src/project_context.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl ProjectContext {
226226

227227
/// Returns the local packages relevant for the current context.
228228
/// Either a single project, all projects from a monorepo or a single package inside a monorepo.
229-
pub fn get_scoped_local_packages(&self, include_dev_deps: bool) -> AHashSet<String> {
229+
pub fn get_scoped_local_packages(&self) -> AHashSet<String> {
230230
let mut local_packages = AHashSet::<String>::new();
231231
match &self.monorepo_context {
232232
None => {
@@ -238,9 +238,7 @@ impl ProjectContext {
238238
}) => {
239239
local_packages.insert(self.current_config.name.clone());
240240
local_packages.extend(local_dependencies.iter().cloned());
241-
if include_dev_deps {
242-
local_packages.extend(local_dev_dependencies.iter().cloned());
243-
}
241+
local_packages.extend(local_dev_dependencies.iter().cloned());
244242
}
245243
Some(MonoRepoContext::MonorepoPackage { .. }) => {
246244
local_packages.insert(self.current_config.name.clone());

rewatch/src/watcher.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct AsyncWatchArgs<'a> {
6262
filter: &'a Option<regex::Regex>,
6363
after_build: Option<String>,
6464
create_sourcedirs: bool,
65-
build_dev_deps: bool,
6665
snapshot_output: bool,
6766
warn_error: Option<String>,
6867
}
@@ -75,21 +74,13 @@ async fn async_watch(
7574
filter,
7675
after_build,
7776
create_sourcedirs,
78-
build_dev_deps,
7977
snapshot_output,
8078
warn_error,
8179
}: AsyncWatchArgs<'_>,
8280
) -> notify::Result<()> {
83-
let mut build_state: build::build_types::BuildCommandState = build::initialize_build(
84-
None,
85-
filter,
86-
show_progress,
87-
path,
88-
build_dev_deps,
89-
snapshot_output,
90-
warn_error,
91-
)
92-
.expect("Can't initialize build");
81+
let mut build_state: build::build_types::BuildCommandState =
82+
build::initialize_build(None, filter, show_progress, path, snapshot_output, warn_error)
83+
.expect("Can't initialize build");
9384
let mut needs_compile_type = CompileType::Incremental;
9485
// create a mutex to capture if ctrl-c was pressed
9586
let ctrlc_pressed = Arc::new(Mutex::new(false));
@@ -283,7 +274,6 @@ async fn async_watch(
283274
filter,
284275
show_progress,
285276
path,
286-
build_dev_deps,
287277
snapshot_output,
288278
build_state.get_warn_error_override(),
289279
)
@@ -331,7 +321,6 @@ pub fn start(
331321
folder: &str,
332322
after_build: Option<String>,
333323
create_sourcedirs: bool,
334-
build_dev_deps: bool,
335324
snapshot_output: bool,
336325
warn_error: Option<String>,
337326
) {
@@ -358,7 +347,6 @@ pub fn start(
358347
filter,
359348
after_build,
360349
create_sourcedirs,
361-
build_dev_deps,
362350
snapshot_output,
363351
warn_error: warn_error.clone(),
364352
})

rewatch/testrepo/packages/nonexisting-dev-files/package.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)