Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize old templates #746

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Generated by [Rojo](https://github.com/rojo-rbx/rojo) {rojo_version}.
To build this library, use:

```bash
rojo build -o "{project_name}.rbxmx"
rojo build -o "{project_name}.rbxm"
```

For more help, check out [the Rojo documentation](https://rojo.space/docs).
For more help, check out [the Rojo documentation](https://rojo.space/docs).
7 changes: 7 additions & 0 deletions assets/default-library-project/gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Model files
/*.rbxmx
/*.rbxm

# Roblox Studio lock files
*.rbxlx.lock
*.rbxl.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ return {
hello = function()
print("Hello world, from {project_name}!")
end,
}
}
3 changes: 0 additions & 3 deletions assets/default-model-project/gitignore.txt

This file was deleted.

6 changes: 3 additions & 3 deletions assets/default-place-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Generated by [Rojo](https://github.com/rojo-rbx/rojo) {rojo_version}.
To build the place from scratch, use:

```bash
rojo build -o "{project_name}.rbxlx"
rojo build -o "{project_name}.rbxl"
```

Next, open `{project_name}.rbxlx` in Roblox Studio and start the Rojo server:
Next, open `{project_name}.rbxl` in Roblox Studio and start the Rojo server:

```bash
rojo serve
```

For more help, check out [the Rojo documentation](https://rojo.space/docs).
For more help, check out [the Rojo documentation](https://rojo.space/docs).
61 changes: 27 additions & 34 deletions assets/default-place-project/default.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,64 @@
"name": "{project_name}",
"tree": {
"$className": "DataModel",

"Lighting": {
"$properties": {
"Outlines": false,
"Ambient": [
0.0,
0.0,
0.0
],
"GlobalShadows": true,
"Brightness": 2.0,
"Technology": "Voxel"
}
},
"ReplicatedStorage": {
"Shared": {
"$path": "src/shared"
}
},

"ServerScriptService": {
"Server": {
"$path": "src/server"
}
},

"SoundService": {
"$properties": {
"RespectFilteringEnabled": true
}
},
"StarterPlayer": {
"StarterPlayerScripts": {
"Client": {
"$path": "src/client"
}
}
},

"Workspace": {
"$properties": {
"FilteringEnabled": true
},
"Baseplate": {
"$className": "Part",
"$properties": {
"Anchored": true,
"Color": [
0.38823,
0.37254,
0.38823
],
"Locked": true,
"Position": [
0,
-10,
0
0.0,
-10.0,
0.0
],
"Size": [
512,
20,
512
]
512.0,
20.0,
512.0
],
"Anchored": true,
"Locked": true
}
}
},
"Lighting": {
"$properties": {
"Ambient": [
0,
0,
0
],
"Brightness": 2,
"GlobalShadows": true,
"Outlines": false,
"Technology": "Voxel"
}
},
"SoundService": {
"$properties": {
"RespectFilteringEnabled": true
}
}
}
}
9 changes: 5 additions & 4 deletions assets/default-place-project/gitignore.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Project place file
/{project_name}.rbxlx
# Place files
/*.rbxlx
/*.rbxl

# Roblox Studio lock files
/*.rbxlx.lock
/*.rbxl.lock
*.rbxlx.lock
*.rbxl.lock
41 changes: 21 additions & 20 deletions src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ use fs_err::OpenOptions;

use super::resolve_path;

static MODEL_PROJECT: &str =
include_str!("../../assets/default-model-project/default.project.json");
static MODEL_README: &str = include_str!("../../assets/default-model-project/README.md");
static MODEL_INIT: &str = include_str!("../../assets/default-model-project/src-init.lua");
static MODEL_GIT_IGNORE: &str = include_str!("../../assets/default-model-project/gitignore.txt");
static LIBRARY_PROJECT: &str =
include_str!("../../assets/default-library-project/default.project.json");
static LIBRARY_README: &str = include_str!("../../assets/default-library-project/README.md");
static LIBRARY_INIT: &str = include_str!("../../assets/default-library-project/src-init.lua");
static LIBRARY_GIT_IGNORE: &str =
include_str!("../../assets/default-library-project/gitignore.txt");

static PLACE_PROJECT: &str =
include_str!("../../assets/default-place-project/default.project.json");
Expand All @@ -33,7 +34,7 @@ pub struct InitCommand {
#[clap(default_value = "")]
pub path: PathBuf,

/// The kind of project to create, 'place', 'plugin', or 'model'. Defaults to place.
/// The kind of project to create, 'place', 'plugin', or 'library'. Defaults to place.
#[clap(long, default_value = "place")]
pub kind: InitKind,
}
Expand All @@ -55,7 +56,7 @@ impl InitCommand {

match self.kind {
InitKind::Place => init_place(&base_path, project_params)?,
InitKind::Model => init_model(&base_path, project_params)?,
InitKind::Library => init_library(&base_path, project_params)?,
InitKind::Plugin => init_plugin(&base_path, project_params)?,
}

Expand All @@ -71,8 +72,8 @@ pub enum InitKind {
/// A place that contains a baseplate.
Place,

/// An empty model, suitable for a library.
Model,
/// An empty library.
Library,

/// An empty plugin.
Plugin,
Expand All @@ -84,10 +85,10 @@ impl FromStr for InitKind {
fn from_str(source: &str) -> Result<Self, Self::Err> {
match source {
"place" => Ok(InitKind::Place),
"model" => Ok(InitKind::Model),
"library" => Ok(InitKind::Library),
"plugin" => Ok(InitKind::Plugin),
_ => Err(format_err!(
"Invalid init kind '{}'. Valid kinds are: place, model, plugin",
"Invalid init kind '{}'. Valid kinds are: place, library, plugin",
source
)),
}
Expand Down Expand Up @@ -117,17 +118,17 @@ fn init_place(base_path: &Path, project_params: ProjectParams) -> anyhow::Result

write_if_not_exists(
&src_shared.join("Hello.lua"),
"return function()\n\tprint(\"Hello, world!\")\nend",
"return function()\n\tprint(\"Hello, world!\")\nend\n",
)?;

write_if_not_exists(
&src_server.join("init.server.lua"),
"print(\"Hello world, from server!\")",
"print(\"Hello world, from server!\")\n",
)?;

write_if_not_exists(
&src_client.join("init.client.lua"),
"print(\"Hello world, from client!\")",
"print(\"Hello world, from client!\")\n",
)?;

let git_ignore = project_params.render_template(PLACE_GIT_IGNORE);
Expand All @@ -136,22 +137,22 @@ fn init_place(base_path: &Path, project_params: ProjectParams) -> anyhow::Result
Ok(())
}

fn init_model(base_path: &Path, project_params: ProjectParams) -> anyhow::Result<()> {
println!("Creating new model project '{}'", project_params.name);
fn init_library(base_path: &Path, project_params: ProjectParams) -> anyhow::Result<()> {
println!("Creating new library project '{}'", project_params.name);

let project_file = project_params.render_template(MODEL_PROJECT);
let project_file = project_params.render_template(LIBRARY_PROJECT);
try_create_project(base_path, &project_file)?;

let readme = project_params.render_template(MODEL_README);
let readme = project_params.render_template(LIBRARY_README);
write_if_not_exists(&base_path.join("README.md"), &readme)?;

let src = base_path.join("src");
fs::create_dir_all(&src)?;

let init = project_params.render_template(MODEL_INIT);
let init = project_params.render_template(LIBRARY_INIT);
write_if_not_exists(&src.join("init.lua"), &init)?;

let git_ignore = project_params.render_template(MODEL_GIT_IGNORE);
let git_ignore = project_params.render_template(LIBRARY_GIT_IGNORE);
try_git_init(base_path, &git_ignore)?;

Ok(())
Expand Down
Loading