@@ -10,8 +10,9 @@ use std::io::Write;
10
10
use std:: path:: PathBuf ;
11
11
use std:: process:: Command ;
12
12
13
- /// This literally includes the entire subcrate in the program, allowing more efficient development.
14
- const SUBCRATES : Dir = include_dir ! ( "../../examples/cli/.perseus" ) ;
13
+ // This literally includes the entire subcrate in the program, allowing more efficient development.
14
+ // This MUST be copied in from `../../examples/cli/.perseus/` every time the CLI is tested (use the Bonnie script).
15
+ const SUBCRATES : Dir = include_dir ! ( "./.perseus" ) ;
15
16
16
17
/// Prepares the user's project by copying in the `.perseus/` subcrates. We use these subcrates to do all the building/serving, we just
17
18
/// have to execute the right commands in the CLI. We can essentially treat the subcrates themselves as a blackbox of just a folder.
@@ -42,19 +43,24 @@ pub fn prepare(dir: PathBuf) -> Result<()> {
42
43
}
43
44
// Use the current version of this crate (and thus all Perseus crates) to replace the relative imports
44
45
// That way everything works in dev and in prod on another system!
46
+ // We have to store `Cargo.toml` as `Cargo.toml.old` for packaging
47
+ let mut root_manifest_pkg = target. clone ( ) ;
48
+ root_manifest_pkg. extend ( [ "Cargo.toml.old" ] ) ;
45
49
let mut root_manifest = target. clone ( ) ;
46
50
root_manifest. extend ( [ "Cargo.toml" ] ) ;
51
+ let mut server_manifest_pkg = target. clone ( ) ;
52
+ server_manifest_pkg. extend ( [ "server" , "Cargo.toml.old" ] ) ;
47
53
let mut server_manifest = target. clone ( ) ;
48
54
server_manifest. extend ( [ "server" , "Cargo.toml" ] ) ;
49
- let root_manifest_contents = fs:: read_to_string ( & root_manifest ) . map_err ( |err| {
55
+ let root_manifest_contents = fs:: read_to_string ( & root_manifest_pkg ) . map_err ( |err| {
50
56
ErrorKind :: ManifestUpdateFailed (
51
- root_manifest . to_str ( ) . map ( |s| s. to_string ( ) ) ,
57
+ root_manifest_pkg . to_str ( ) . map ( |s| s. to_string ( ) ) ,
52
58
err. to_string ( ) ,
53
59
)
54
60
} ) ?;
55
- let server_manifest_contents = fs:: read_to_string ( & server_manifest ) . map_err ( |err| {
61
+ let server_manifest_contents = fs:: read_to_string ( & server_manifest_pkg ) . map_err ( |err| {
56
62
ErrorKind :: ManifestUpdateFailed (
57
- server_manifest . to_str ( ) . map ( |s| s. to_string ( ) ) ,
63
+ server_manifest_pkg . to_str ( ) . map ( |s| s. to_string ( ) ) ,
58
64
err. to_string ( ) ,
59
65
)
60
66
} ) ?;
0 commit comments