From 1f6f06ab55a3c4dc02c37b2ea72b72b87b2418cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Wed, 12 Jun 2024 16:42:26 +0900 Subject: [PATCH] patch xtask --- xtask/src/npm/nightly.rs | 51 +++++++++------------------------------- xtask/src/npm/util.rs | 32 ------------------------- 2 files changed, 11 insertions(+), 72 deletions(-) diff --git a/xtask/src/npm/nightly.rs b/xtask/src/npm/nightly.rs index d90f16cb4bb7..35de6b6e8c99 100644 --- a/xtask/src/npm/nightly.rs +++ b/xtask/src/npm/nightly.rs @@ -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) @@ -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(()) }) diff --git a/xtask/src/npm/util.rs b/xtask/src/npm/util.rs index b79316a4b412..8faae7e4dc0b 100644 --- a/xtask/src/npm/util.rs +++ b/xtask/src/npm/util.rs @@ -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> { - 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::>()) -} - -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");