1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
use clap::Args;
use std::path::PathBuf;
#[derive(Args)]
pub struct DumpAutoloadArgs {
/// Optimizes PSR-0 and PSR-4 packages to be loaded with classmaps
#[arg(short, long)]
pub optimize: bool,
/// Autoload classes from the classmap only
#[arg(short = 'a', long)]
pub classmap_authoritative: bool,
/// Use APCu to cache found/not-found classes
#[arg(long)]
pub apcu: bool,
/// Use a custom prefix for the APCu autoloader cache
#[arg(long)]
pub apcu_prefix: Option<String>,
/// Only output what would be changed, do not modify files
#[arg(long)]
pub dry_run: bool,
/// Enables autoload-dev rules
#[arg(long)]
pub dev: bool,
/// Disables autoload-dev rules
#[arg(long)]
pub no_dev: bool,
/// Ignore a specific platform requirement
#[arg(long)]
pub ignore_platform_req: Vec<String>,
/// Ignore all platform requirements
#[arg(long)]
pub ignore_platform_reqs: bool,
/// Return a failed status code if there are PSR mapping errors
#[arg(long)]
pub strict_psr: bool,
/// Return a failed status code if there are ambiguous class mappings
#[arg(long)]
pub strict_ambiguous: bool,
}
pub fn execute(
args: &DumpAutoloadArgs,
cli: &super::Cli,
console: &crate::console::Console,
) -> anyhow::Result<()> {
let working_dir = match &cli.working_dir {
Some(dir) => PathBuf::from(dir),
None => std::env::current_dir()?,
};
let vendor_dir = working_dir.join("vendor");
let dev_mode = !args.no_dev;
// Determine suffix: read from existing autoload.php, or from lock file, or generate
let suffix = crate::autoload::determine_suffix(&working_dir, &vendor_dir)?;
if args.dry_run {
console.info("Dry run: would generate autoload files");
return Ok(());
}
crate::autoload::generate(&crate::autoload::AutoloadConfig {
project_dir: working_dir,
vendor_dir,
dev_mode,
suffix,
classmap_authoritative: args.classmap_authoritative,
optimize: args.optimize,
apcu: args.apcu,
apcu_prefix: args.apcu_prefix.clone(),
strict_psr: args.strict_psr,
platform_check: crate::autoload::PlatformCheckMode::Full,
ignore_platform_reqs: args.ignore_platform_reqs,
})?;
console.info("Generated autoload files");
Ok(())
}
|