convert to workspace

This commit is contained in:
connorskees 2023-01-07 19:47:04 +00:00
parent 1f873e1f0e
commit 3c1b14406a
181 changed files with 73 additions and 57 deletions

View File

@ -1,47 +1,9 @@
[package]
name = "grass"
version = "0.12.1"
description = "A Sass compiler written purely in Rust"
readme = "README.md"
license = "MIT"
categories = ["command-line-utilities", "web-programming"]
keywords = ["scss", "sass", "css", "web"]
repository = "https://github.com/connorskees/grass"
authors = ["ConnorSkees <39542938+ConnorSkees@users.noreply.github.com>"]
edition = "2021"
include = ["src", "Cargo.toml", "README.md", "CHANGELOG.md", "Cargo.lock", "LICENSE"]
default-run = "grass"
[[bin]]
name = "grass"
path = "src/main.rs"
required-features = ["commandline"]
[lib]
name = "grass"
path = "src/lib.rs"
# crate-type = ["cdylib", "rlib"]
bench = false
[dependencies]
grass_internal = { path = "./grass_internal", version = "0.12.1" }
include_sass = { path = "./include_sass", version = "0.12.1", optional = true }
clap = { version = "2.34.0", optional = true }
[features]
# todo: no commandline by default
default = ["commandline", "random"]
# Option (enabled by default): build a binary using clap
commandline = ["clap"]
random = ["grass_internal/random"]
wasm-exports = ["grass_internal/wasm-exports"]
# Option: include the proc macro `include_sass!`
macro = ["include_sass"]
nightly = ["include_sass/nightly"]
[dev-dependencies]
tempfile = "3.3.0"
paste = "1.0.3"
[workspace]
members = [
"crates/compiler",
"crates/include_sass",
"crates/lib",
]
[profile.release]
debug = true

View File

@ -1,12 +1,12 @@
[package]
name = "grass_internal"
name = "compiler"
version = "0.12.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "grass_internal"
name = "compiler"
path = "src/lib.rs"
# crate-type = ["cdylib", "rlib"]
bench = false

View File

@ -0,0 +1,3 @@
a {
color: red;
}

View File

@ -14,6 +14,7 @@ implementation.
## Use as library
```
# use compiler as grass;
fn main() -> Result<(), Box<grass::Error>> {
let css = grass::from_string(
"a { b { color: &; } }".to_owned(),
@ -186,6 +187,7 @@ fn from_string_with_file_name<P: AsRef<Path>>(
/// n.b. `grass` does not currently support files or paths that are not valid UTF-8
///
/// ```
/// # use compiler as grass;
/// fn main() -> Result<(), Box<grass::Error>> {
/// let css = grass::from_path("input.scss", &grass::Options::default())?;
/// Ok(())
@ -199,6 +201,7 @@ pub fn from_path<P: AsRef<Path>>(p: P, options: &Options) -> Result<String> {
/// Compile CSS from a string
///
/// ```
/// # use compiler as grass;
/// fn main() -> Result<(), Box<grass::Error>> {
/// let css = grass::from_string("a { b { color: &; } }".to_string(), &grass::Options::default())?;
/// assert_eq!(css, "a b {\n color: a b;\n}\n");

View File

@ -8,7 +8,7 @@ proc-macro = true
[dependencies]
syn = { version = "1.0.103", default-features = false }
grass_internal = { path = "../grass_internal" }
compiler = { path = "../compiler" }
quote = { version = "1.0.23", default-features = false }
[features]

View File

@ -2,7 +2,7 @@
use std::{cell::RefCell, collections::HashSet, path::PathBuf};
use grass_internal::StdFs;
use compiler::StdFs;
use proc_macro::TokenStream;
use quote::format_ident;
use syn::{parse_macro_input, LitStr};
@ -12,10 +12,10 @@ use quote::__private::TokenStream as TokenStream2;
#[derive(Debug)]
struct FileTracker<'a> {
files: RefCell<HashSet<PathBuf>>,
fs: &'a dyn grass_internal::Fs,
fs: &'a dyn compiler::Fs,
}
impl<'a> grass_internal::Fs for FileTracker<'a> {
impl<'a> compiler::Fs for FileTracker<'a> {
fn is_dir(&self, path: &std::path::Path) -> bool {
#[cfg(feature = "nightly")]
if let Ok(p) = std::fs::canonicalize(path) {
@ -88,7 +88,7 @@ fn finish(css: String, files: &HashSet<PathBuf>) -> TokenStream {
pub fn include_sass(item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as LitStr);
let options = grass_internal::Options::default();
let options = compiler::Options::default();
let fs = FileTracker {
files: RefCell::new(HashSet::new()),
@ -97,11 +97,9 @@ pub fn include_sass(item: TokenStream) -> TokenStream {
let value = input.value();
let css = match grass_internal::from_path(
let css = match compiler::from_path(
value,
&options
.fs(&fs)
.style(grass_internal::OutputStyle::Compressed),
&options.fs(&fs).style(compiler::OutputStyle::Compressed),
) {
Ok(css) => css,
Err(e) => {

50
crates/lib/Cargo.toml Normal file
View File

@ -0,0 +1,50 @@
[package]
name = "grass"
version = "0.12.1"
description = "A Sass compiler written purely in Rust"
readme = "README.md"
license = "MIT"
categories = ["command-line-utilities", "web-programming"]
keywords = ["scss", "sass", "css", "web"]
repository = "https://github.com/connorskees/grass"
authors = ["ConnorSkees <39542938+ConnorSkees@users.noreply.github.com>"]
edition = "2021"
include = ["src", "Cargo.toml", "README.md", "CHANGELOG.md", "Cargo.lock", "LICENSE"]
default-run = "grass"
[[bin]]
name = "grass"
path = "src/main.rs"
required-features = ["commandline"]
[lib]
name = "grass"
path = "src/lib.rs"
# crate-type = ["cdylib", "rlib"]
bench = false
[dependencies]
compiler = { path = "../compiler", version = "0.12.1" }
include_sass = { path = "../include_sass", version = "0.12.1", optional = true }
clap = { version = "2.34.0", optional = true }
[features]
# todo: no commandline by default
default = ["commandline", "random"]
# Option (enabled by default): build a binary using clap
commandline = ["clap"]
random = ["compiler/random"]
wasm-exports = ["compiler/wasm-exports"]
# Option: include the proc macro `include_sass!`
macro = ["include_sass"]
nightly = ["include_sass/nightly"]
[dev-dependencies]
tempfile = "3.3.0"
paste = "1.0.3"
# [profile.release]
# debug = true
# panic = "abort"
# lto = true
# codegen-units = 1

View File

@ -80,11 +80,11 @@ grass input.scss
unknown_lints,
)]
pub use grass_internal::*;
pub use compiler::*;
/// Include CSS in your binary at compile time from a Sass source file
///
/// ```ignore
/// ```
/// static CSS: &str = grass::include!("../static/_main.scss");
/// ```
///

Some files were not shown because too many files have changed in this diff Show More