Skip to content

Commit

Permalink
Merge branch 'main' into perf-vc
Browse files Browse the repository at this point in the history
  • Loading branch information
swc-bot committed Jun 12, 2024
2 parents 1065e2b + 80d22e3 commit 435d1c6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 76 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

- **(es/minifier)** Visit RHS while hoisting properties ([#9032](https://github.com/swc-project/swc/issues/9032)) ([cb16994](https://github.com/swc-project/swc/commit/cb16994a8d7a203e923b52e444d265bad0fa9e6e))


- **(xtask)** Fix `nightly` action ([#9042](https://github.com/swc-project/swc/issues/9042)) ([733dcc6](https://github.com/swc-project/swc/commit/733dcc6b83e77a2571a3fee307a73fc0c17bd44c))

### Performance


Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings/swc_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "swc_cli"
repository = "https://github.com/swc-project/swc.git"
version = "0.91.279"
version = "0.91.280"

[[bin]]
bench = false
Expand Down
2 changes: 1 addition & 1 deletion crates/dbg-swc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license = "Apache-2.0"
name = "dbg-swc"
repository = { workspace = true }
version = "0.94.1"
version = "0.94.2"

[[bin]]
bench = false
Expand Down
51 changes: 11 additions & 40 deletions xtask/src/npm/nightly.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
use std::process::{Command, Stdio};

use anyhow::{Context, Result};
use anyhow::{ensure, Context, Result};
use chrono::Utc;
use clap::Args;
use semver::{Prerelease, Version};

use crate::{
npm::util::{bump_swc_cli, set_version, update_swc_crates},
npm::util::{bump_swc_cli, set_version},
util::{repository_root, wrap},
};

#[derive(Debug, Args)]
pub(super) struct NightlyCmd {
#[clap(long)]
git: bool,
}
pub(super) struct NightlyCmd {}

impl NightlyCmd {
pub fn run(self) -> Result<()> {
wrap(|| {
let date = Utc::now().format("%Y%m%d").to_string();

update_swc_crates().context("failed to update swc crates")?;

let root_pkg_json = repository_root()?.join("./packages/core/package.json");
let content = serde_json::from_reader::<_, serde_json::Value>(
std::fs::File::open(root_pkg_json)
Expand All @@ -37,38 +32,14 @@ impl NightlyCmd {
set_version(&version).context("failed to set version")?;
bump_swc_cli().context("failed to bump swc-cli")?;

if self.git {
// git add -A
Command::new("git")
.current_dir(repository_root()?)
.arg("add")
.arg("-A")
.stderr(Stdio::inherit())
.status()
.context("git add failed")?;

// git commit --no-verify -m 'chore: Publish $version'

Command::new("git")
.current_dir(repository_root()?)
.arg("commit")
.arg("--no-verify")
.arg("-m")
.arg(format!("chore: Publish {}", version))
.stderr(Stdio::inherit())
.status()
.context("git commit failed")?;

// git tag $version

Command::new("git")
.current_dir(repository_root()?)
.arg("tag")
.arg(format!("v{}", version))
.stderr(Stdio::inherit())
.status()
.context("git tag failed")?;
}
// ./scripts/publish.sh $version
let status = Command::new("sh")
.arg("./scripts/publish.sh")
.arg(format!("{}", version))
.status()
.context("failed to publish")?;

ensure!(status.success(), "failed to publish");

Ok(())
})
Expand Down
32 changes: 0 additions & 32 deletions xtask/src/npm/util.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,10 @@
use std::process::{Command, Stdio};

use anyhow::{Context, Result};
use cargo_metadata::MetadataCommand;
use semver::Version;

use crate::util::{repository_root, wrap};

/// Get the list of swc crates in the main swc repository.
fn get_swc_crates_of_bindings() -> Result<Vec<String>> {
let md = MetadataCommand::new()
.current_dir(repository_root()?.join("bindings"))
.exec()?;

Ok(md
.packages
.iter()
.filter(|p| p.repository.as_deref() == Some("https://github.com/swc-project/swc.git"))
.map(|p| p.name.clone())
.collect::<Vec<_>>())
}

pub fn update_swc_crates() -> Result<()> {
let mut c = Command::new("cargo");
c.current_dir(repository_root()?.join("bindings"));
c.arg("upgrade")
.arg("--incompatible")
.arg("--recursive")
.arg("false");

for pkg in get_swc_crates_of_bindings()? {
c.arg("--package").arg(pkg);
}

c.status()?;

Ok(())
}

pub fn set_version(version: &Version) -> Result<()> {
wrap(|| {
let mut c = Command::new("npm");
Expand Down

0 comments on commit 435d1c6

Please sign in to comment.