diff --git a/.gitignore b/.gitignore index 3e7a542cc58..aedc2d91aed 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ package-lock.json npm-shrinkwrap.json yarn.lock *.d.ts +/publish +/publish.exe diff --git a/Cargo.toml b/Cargo.toml index e1f1079dcf8..6ca9412ecf7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" readme = "README.md" @@ -28,15 +28,15 @@ nightly = [] xxx_debug_only_print_generated_code = ["wasm-bindgen-macro/xxx_debug_only_print_generated_code"] [dependencies] -wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.17" } +wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.18" } serde = { version = "1.0", optional = true } serde_json = { version = "1.0", optional = true } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = { path = 'crates/test', version = '=0.2.17' } +wasm-bindgen-test = { path = 'crates/test', version = '=0.2.18' } serde_derive = "1.0" -wasm-bindgen-test-crate-a = { path = 'tests/crates/a' } -wasm-bindgen-test-crate-b = { path = 'tests/crates/b' } +wasm-bindgen-test-crate-a = { path = 'tests/crates/a', version = '0.1' } +wasm-bindgen-test-crate-b = { path = 'tests/crates/b', version = '0.1' } [workspace] members = [ diff --git a/crates/backend/Cargo.toml b/crates/backend/Cargo.toml index 7d61d9ae232..f2bc2839843 100644 --- a/crates/backend/Cargo.toml +++ b/crates/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-backend" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/backend" @@ -21,4 +21,4 @@ proc-macro2 = "0.4.8" quote = '0.6' serde_json = "1.0" syn = { version = '0.14', features = ['full', 'visit'] } -wasm-bindgen-shared = { path = "../shared", version = "=0.2.17" } +wasm-bindgen-shared = { path = "../shared", version = "=0.2.18" } diff --git a/crates/cli-support/Cargo.toml b/crates/cli-support/Cargo.toml index 40102d7dd62..f666236324f 100644 --- a/crates/cli-support/Cargo.toml +++ b/crates/cli-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-cli-support" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/cli-support" @@ -17,6 +17,6 @@ parity-wasm = "0.31" serde = "1.0" serde_json = "1.0" tempfile = "3.0" -wasm-bindgen-shared = { path = "../shared", version = '=0.2.17' } -wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.17' } +wasm-bindgen-shared = { path = "../shared", version = '=0.2.18' } +wasm-bindgen-wasm-interpreter = { path = "../wasm-interpreter", version = '=0.2.18' } wasm-gc-api = "0.1.9" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 7f4291fa171..8cfe2ad797d 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-cli" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/cli" @@ -23,8 +23,8 @@ rouille = { version = "2.1.0", default-features = false } serde = "1.0" serde_derive = "1.0" serde_json = "1.0" -wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.17" } -wasm-bindgen-shared = { path = "../shared", version = "=0.2.17" } +wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.18" } +wasm-bindgen-shared = { path = "../shared", version = "=0.2.18" } openssl = { version = '0.10.11', optional = true } [features] diff --git a/crates/futures/Cargo.toml b/crates/futures/Cargo.toml index 1e8fadabb8a..f73def61faf 100644 --- a/crates/futures/Cargo.toml +++ b/crates/futures/Cargo.toml @@ -7,12 +7,12 @@ license = "MIT/Apache-2.0" name = "wasm-bindgen-futures" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/futures" readme = "./README.md" -version = "0.2.17" +version = "0.2.18" [dependencies] futures = "0.1.20" -js-sys = { path = "../js-sys", version = '0.2.1' } -wasm-bindgen = { path = "../..", version = '0.2.17' } +js-sys = { path = "../js-sys", version = '0.2.3' } +wasm-bindgen = { path = "../..", version = '0.2.18' } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen-test = { path = '../test', version = '0.2.17' } +wasm-bindgen-test = { path = '../test', version = '0.2.18' } diff --git a/crates/js-sys/Cargo.toml b/crates/js-sys/Cargo.toml index fada74bc8f6..33ad544d4a2 100644 --- a/crates/js-sys/Cargo.toml +++ b/crates/js-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "js-sys" -version = "0.2.2" +version = "0.2.3" authors = ["The wasm-bindgen Developers"] readme = "./README.md" categories = ["wasm"] @@ -18,9 +18,9 @@ test = false doctest = false [dependencies] -wasm-bindgen = { path = "../..", version = "0.2.17" } +wasm-bindgen = { path = "../..", version = "0.2.18" } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] futures = "0.1.20" -wasm-bindgen-test = { path = '../test', version = '=0.2.17' } -wasm-bindgen-futures = { path = '../futures', version = '=0.2.17' } +wasm-bindgen-test = { path = '../test', version = '=0.2.18' } +wasm-bindgen-futures = { path = '../futures', version = '=0.2.18' } diff --git a/crates/macro-support/Cargo.toml b/crates/macro-support/Cargo.toml index 49c867d463d..0c0156af902 100644 --- a/crates/macro-support/Cargo.toml +++ b/crates/macro-support/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-macro-support" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro-support" @@ -18,5 +18,5 @@ extra-traits = ["syn/extra-traits"] syn = { version = '0.14', features = ['full'] } quote = '0.6' proc-macro2 = "0.4.9" -wasm-bindgen-backend = { path = "../backend", version = "=0.2.17" } -wasm-bindgen-shared = { path = "../shared", version = "=0.2.17" } +wasm-bindgen-backend = { path = "../backend", version = "=0.2.18" } +wasm-bindgen-shared = { path = "../shared", version = "=0.2.18" } diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index 2f46fc16a9a..2c4b4f03d52 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-macro" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/macro" @@ -18,5 +18,5 @@ spans = ["wasm-bindgen-macro-support/spans"] xxx_debug_only_print_generated_code = [] [dependencies] -wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.17" } +wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.18" } quote = "0.6" diff --git a/crates/shared/Cargo.toml b/crates/shared/Cargo.toml index 9b6d9b804c7..eebeb8d1985 100644 --- a/crates/shared/Cargo.toml +++ b/crates/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-shared" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/shared" diff --git a/crates/test-macro/Cargo.toml b/crates/test-macro/Cargo.toml index 14271bb4206..3b9a3914a5f 100644 --- a/crates/test-macro/Cargo.toml +++ b/crates/test-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-test-macro" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] description = "Internal testing macro for wasm-bindgen" license = "MIT/Apache-2.0" diff --git a/crates/test/Cargo.toml b/crates/test/Cargo.toml index 274cae208c4..e043d09f318 100644 --- a/crates/test/Cargo.toml +++ b/crates/test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-test" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] description = "Internal testing crate for wasm-bindgen" license = "MIT/Apache-2.0" @@ -9,11 +9,11 @@ repository = "https://github.com/rustwasm/wasm-bindgen" [dependencies] console_error_panic_hook = '0.1' futures = "0.1" -js-sys = { path = '../js-sys', version = '0.2.1' } +js-sys = { path = '../js-sys', version = '0.2.3' } scoped-tls = "0.1" -wasm-bindgen = { path = '../..', version = '0.2.17' } -wasm-bindgen-futures = { path = '../futures', version = '0.2.17' } -wasm-bindgen-test-macro = { path = '../test-macro', version = '=0.2.17' } +wasm-bindgen = { path = '../..', version = '0.2.18' } +wasm-bindgen-futures = { path = '../futures', version = '0.2.18' } +wasm-bindgen-test-macro = { path = '../test-macro', version = '=0.2.18' } [lib] test = false diff --git a/crates/wasm-interpreter/Cargo.toml b/crates/wasm-interpreter/Cargo.toml index eb837fedbc5..ec420f915f1 100644 --- a/crates/wasm-interpreter/Cargo.toml +++ b/crates/wasm-interpreter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm-bindgen-wasm-interpreter" -version = "0.2.17" +version = "0.2.18" authors = ["The wasm-bindgen Developers"] license = "MIT/Apache-2.0" repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/wasm-interpreter" diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 25261494010..623fca83b25 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -15,11 +15,10 @@ wasm-bindgen-webidl = { path = "../webidl", version = "=0.2.17" } sourcefile = "0.1" [dependencies] -wasm-bindgen = { path = "../..", version = "0.2.17" } -js-sys = { path = '../js-sys', version = '0.2.1' } +wasm-bindgen = { path = "../..", version = "0.2.18" } +js-sys = { path = '../js-sys', version = '0.2.3' } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] futures = "0.1" -js-sys = { path = '../js-sys', version = '0.2.1' } -wasm-bindgen-test = { path = '../test', version = '0.2.17' } -wasm-bindgen-futures = { path = '../futures', version = '0.2.17' } +wasm-bindgen-test = { path = '../test', version = '0.2.18' } +wasm-bindgen-futures = { path = '../futures', version = '0.2.18' } diff --git a/crates/webidl/Cargo.toml b/crates/webidl/Cargo.toml index 6a0d67fc6dc..48d495592ef 100644 --- a/crates/webidl/Cargo.toml +++ b/crates/webidl/Cargo.toml @@ -19,5 +19,5 @@ log = "0.4.1" proc-macro2 = "0.4.8" quote = '0.6' syn = { version = '0.14', features = ['full'] } -wasm-bindgen-backend = { version = "=0.2.17", path = "../backend" } +wasm-bindgen-backend = { version = "=0.2.18", path = "../backend" } weedle = "0.6" diff --git a/publish.rs b/publish.rs new file mode 100644 index 00000000000..6afa8b16e59 --- /dev/null +++ b/publish.rs @@ -0,0 +1,197 @@ +//! Helper script to publish the wasm-bindgen suite of crates +//! +//! Usage: +//! +//! * First, compile this script +//! * Next, set cwd to the root of the wasm-bindgen repository +//! * Execute `./publish bump` to bump versions +//! * Send a PR +//! * Merge when green +//! * Execute `./publish publish` to publish crates + +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::Command; + +const CRATES_TO_PUBLISH: &[&str] = &[ + "wasm-bindgen", + "js-sys", + "wasm-bindgen-backend", + "wasm-bindgen-cli", + "wasm-bindgen-cli-support", + "wasm-bindgen-futures", + "wasm-bindgen-macro", + "wasm-bindgen-macro-support", + "wasm-bindgen-shared", + "wasm-bindgen-test", + "wasm-bindgen-test-macro", + "wasm-bindgen-wasm-interpreter", +]; + +const CRATES_TO_AVOID_PUBLISH: &[&str] = &[ + // We'll publish these when they're ready one day + "wasm-bindgen-typescript", + "web-sys", + "wasm-bindgen-webidl", + + // These are internal crates, unlikely to ever be published + "ui-tests", + "sample", + "webidl-tests", +]; + +struct Crate { + manifest: PathBuf, + name: String, + version: String, + next_version: String, +} + +fn main() { + let mut crates = Vec::new(); + crates.push(read_crate("./Cargo.toml".as_ref())); + find_crates("crates".as_ref(), &mut crates); + + match &env::args().nth(1).expect("must have one argument")[..] { + "bump" => { + for krate in crates.iter() { + bump_version(&krate, &crates); + } + } + + "publish" => { + for krate in crates.iter() { + publish(&krate); + } + } + + s => panic!("unknown command: {}", s), + } +} + +fn find_crates(dir: &Path, dst: &mut Vec) { + if dir.join("Cargo.toml").exists() { + let krate = read_crate(&dir.join("Cargo.toml")); + if CRATES_TO_PUBLISH.iter() + .chain(CRATES_TO_AVOID_PUBLISH) + .any(|c| krate.name == *c) + { + dst.push(krate); + } else { + panic!("failed to find {:?} in whitelist or blacklist", krate.name); + } + } + + for entry in dir.read_dir().unwrap() { + let entry = entry.unwrap(); + if entry.file_type().unwrap().is_dir() { + find_crates(&entry.path(), dst); + } + } +} + +fn read_crate(manifest: &Path) -> Crate { + let mut name = None; + let mut version = None; + for line in fs::read_to_string(manifest).unwrap().lines() { + if name.is_none() && line.starts_with("name = \"") { + name = Some(line.replace("name = \"", "") + .replace("\"", "") + .trim() + .to_string()); + } + if version.is_none() && line.starts_with("version = \"") { + version = Some(line.replace("version = \"", "") + .replace("\"", "") + .trim() + .to_string()); + } + } + let name = name.unwrap(); + let version = version.unwrap(); + let next_version = if CRATES_TO_PUBLISH.contains(&&name[..]) { + bump(&version) + } else { + version.clone() + }; + Crate { + manifest: manifest.to_path_buf(), + name, + version, + next_version, + } +} + +fn bump_version(krate: &Crate, crates: &[Crate]) { + let contents = fs::read_to_string(&krate.manifest).unwrap(); + + let mut new_manifest = String::new(); + let mut is_deps = false; + for line in contents.lines() { + let mut rewritten = false; + if line.starts_with("version =") { + if CRATES_TO_PUBLISH.contains(&&krate.name[..]) { + println!("bump `{}` {} => {}", + krate.name, + krate.version, + krate.next_version); + new_manifest.push_str(&line.replace(&krate.version, &krate.next_version)); + rewritten = true; + } + } + + is_deps = if line.starts_with("[") { + line.contains("dependencies") + } else { + is_deps + }; + + for other in crates { + if !is_deps || !line.starts_with(&format!("{} ", other.name)) { + continue + } + if !line.contains(&other.version) { + if !line.contains("version =") { + continue + } + panic!("{:?} has a dep on {} but doesn't list version {}", + krate.manifest, + other.name, + other.version); + } + rewritten = true; + new_manifest.push_str(&line.replace(&other.version, &other.next_version)); + break + } + if !rewritten { + new_manifest.push_str(line); + } + new_manifest.push_str("\n"); + } + fs::write(&krate.manifest, new_manifest).unwrap(); +} + +fn bump(version: &str) -> String { + let mut iter = version.split('.').map(|s| s.parse::().unwrap()); + let major = iter.next().expect("major version"); + let minor = iter.next().expect("minor version"); + let patch = iter.next().expect("patch version"); + format!("{}.{}.{}", major, minor, patch + 1) +} + +fn publish(krate: &Crate) { + if !CRATES_TO_PUBLISH.iter().any(|s| *s == krate.name) { + return + } + let status = Command::new("cargo") + .arg("publish") + .current_dir(krate.manifest.parent().unwrap()) + .arg("--no-verify") + .arg("--allow-dirty") + .status() + .expect("failed to run cargo"); + if !status.success() { + println!("FAIL: failed to publish `{}`: {}", krate.name, status); + } +}