mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-26 04:03:29 +03:00
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
4a405065c7
commit
a649aad7ad
6
.changes/cli-dev-update.md
Normal file
6
.changes/cli-dev-update.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"cli.rs": patch
|
||||||
|
"cli.js": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Notify CLI update when running `tauri dev`.
|
22
.github/workflows/publish-cli.yml
vendored
22
.github/workflows/publish-cli.yml
vendored
@ -22,14 +22,14 @@ jobs:
|
|||||||
target: x86_64-apple-darwin
|
target: x86_64-apple-darwin
|
||||||
architecture: x64
|
architecture: x64
|
||||||
build: |
|
build: |
|
||||||
yarn build
|
yarn build:release
|
||||||
strip -x *.node
|
strip -x *.node
|
||||||
- host: windows-latest
|
- host: windows-latest
|
||||||
build: yarn build
|
build: yarn build:release
|
||||||
target: x86_64-pc-windows-msvc
|
target: x86_64-pc-windows-msvc
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- host: windows-latest
|
- host: windows-latest
|
||||||
build: yarn build --target i686-pc-windows-msvc
|
build: yarn build:release --target i686-pc-windows-msvc
|
||||||
target: i686-pc-windows-msvc
|
target: i686-pc-windows-msvc
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- host: ubuntu-18.04
|
- host: ubuntu-18.04
|
||||||
@ -39,16 +39,16 @@ jobs:
|
|||||||
set -e &&
|
set -e &&
|
||||||
rustup target add x86_64-unknown-linux-gnu &&
|
rustup target add x86_64-unknown-linux-gnu &&
|
||||||
cd tooling/cli/node
|
cd tooling/cli/node
|
||||||
yarn build --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
|
yarn build:release --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
|
||||||
llvm-strip -x *.node
|
llvm-strip -x *.node
|
||||||
- host: ubuntu-18.04
|
- host: ubuntu-18.04
|
||||||
target: x86_64-unknown-linux-musl
|
target: x86_64-unknown-linux-musl
|
||||||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
|
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
|
||||||
build: set -e && cd tooling/cli/node && yarn build && strip *.node
|
build: set -e && cd tooling/cli/node && yarn build:release && strip *.node
|
||||||
- host: macos-latest
|
- host: macos-latest
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
build: |
|
build: |
|
||||||
yarn build --target=aarch64-apple-darwin
|
yarn build:release --target=aarch64-apple-darwin
|
||||||
strip -x *.node
|
strip -x *.node
|
||||||
- host: ubuntu-18.04
|
- host: ubuntu-18.04
|
||||||
architecture: x64
|
architecture: x64
|
||||||
@ -57,7 +57,7 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
|
sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
|
||||||
build: |
|
build: |
|
||||||
yarn build --target=aarch64-unknown-linux-gnu
|
yarn build:release --target=aarch64-unknown-linux-gnu
|
||||||
aarch64-linux-gnu-strip *.node
|
aarch64-linux-gnu-strip *.node
|
||||||
- host: ubuntu-18.04
|
- host: ubuntu-18.04
|
||||||
architecture: x64
|
architecture: x64
|
||||||
@ -66,7 +66,7 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
|
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
|
||||||
build: |
|
build: |
|
||||||
yarn build --target=armv7-unknown-linux-gnueabihf
|
yarn build:release --target=armv7-unknown-linux-gnueabihf
|
||||||
arm-linux-gnueabihf-strip *.node
|
arm-linux-gnueabihf-strip *.node
|
||||||
- host: ubuntu-18.04
|
- host: ubuntu-18.04
|
||||||
architecture: x64
|
architecture: x64
|
||||||
@ -76,12 +76,12 @@ jobs:
|
|||||||
set -e &&
|
set -e &&
|
||||||
rustup target add aarch64-unknown-linux-musl &&
|
rustup target add aarch64-unknown-linux-musl &&
|
||||||
cd tooling/cli/node &&
|
cd tooling/cli/node &&
|
||||||
yarn build --target aarch64-unknown-linux-musl &&
|
yarn build:release --target aarch64-unknown-linux-musl &&
|
||||||
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
|
/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node
|
||||||
#- host: windows-latest
|
#- host: windows-latest
|
||||||
# architecture: x64
|
# architecture: x64
|
||||||
# target: aarch64-pc-windows-msvc
|
# target: aarch64-pc-windows-msvc
|
||||||
# build: yarn build --target aarch64-pc-windows-msvc
|
# build: yarn build:release --target aarch64-pc-windows-msvc
|
||||||
name: stable - ${{ matrix.settings.target }} - node@16
|
name: stable - ${{ matrix.settings.target }} - node@16
|
||||||
runs-on: ${{ matrix.settings.host }}
|
runs-on: ${{ matrix.settings.host }}
|
||||||
steps:
|
steps:
|
||||||
@ -173,7 +173,7 @@ jobs:
|
|||||||
# freebsd-version
|
# freebsd-version
|
||||||
# cd ./tooling/cli/node/
|
# cd ./tooling/cli/node/
|
||||||
# yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
|
# yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
|
||||||
# yarn build
|
# yarn build:release
|
||||||
# strip -x *.node
|
# strip -x *.node
|
||||||
# rm -rf node_modules
|
# rm -rf node_modules
|
||||||
# rm -rf ../target
|
# rm -rf ../target
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"artifacts": "napi artifacts",
|
"artifacts": "napi artifacts",
|
||||||
"build": "napi build --platform --release",
|
"build:release": "napi build --platform --release",
|
||||||
"build:debug": "napi build --platform",
|
"build": "napi build --platform",
|
||||||
"prepublishOnly": "napi prepublish -t npm",
|
"prepublishOnly": "napi prepublish -t npm",
|
||||||
"test": "jest --runInBand --forceExit --no-cache",
|
"test": "jest --runInBand --forceExit --no-cache",
|
||||||
"version": "napi version",
|
"version": "napi version",
|
||||||
|
@ -78,6 +78,21 @@ pub fn command(options: Options) -> Result<()> {
|
|||||||
fn command_internal(options: Options) -> Result<()> {
|
fn command_internal(options: Options) -> Result<()> {
|
||||||
let logger = Logger::new("tauri:dev");
|
let logger = Logger::new("tauri:dev");
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
match check_for_updates() {
|
||||||
|
Ok((msg, sleep)) => {
|
||||||
|
if sleep {
|
||||||
|
logger.log(msg);
|
||||||
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
} else {
|
||||||
|
logger.log(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
logger.log(e.to_string());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let tauri_path = tauri_dir();
|
let tauri_path = tauri_dir();
|
||||||
set_current_dir(&tauri_path).with_context(|| "failed to change current working directory")?;
|
set_current_dir(&tauri_path).with_context(|| "failed to change current working directory")?;
|
||||||
let merge_config = if let Some(config) = &options.config {
|
let merge_config = if let Some(config) = &options.config {
|
||||||
@ -281,6 +296,23 @@ fn command_internal(options: Options) -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
fn check_for_updates() -> Result<(String, bool)> {
|
||||||
|
let current_version = crate::info::cli_current_version()?;
|
||||||
|
let current = semver::Version::parse(¤t_version)?;
|
||||||
|
|
||||||
|
let upstream_version = crate::info::cli_upstream_version()?;
|
||||||
|
let upstream = semver::Version::parse(&upstream_version)?;
|
||||||
|
if upstream.gt(¤t) {
|
||||||
|
let message = format!(
|
||||||
|
"🚀 A new version of Tauri CLI is avaliable! [{}]",
|
||||||
|
upstream.to_string()
|
||||||
|
);
|
||||||
|
return Ok((message, true));
|
||||||
|
}
|
||||||
|
Ok(("🎉 Tauri CLI is up-to-date!".into(), false))
|
||||||
|
}
|
||||||
|
|
||||||
fn lookup<F: FnMut(FileType, PathBuf)>(dir: &Path, mut f: F) {
|
fn lookup<F: FnMut(FileType, PathBuf)>(dir: &Path, mut f: F) {
|
||||||
let mut default_gitignore = std::env::temp_dir();
|
let mut default_gitignore = std::env::temp_dir();
|
||||||
default_gitignore.push(".tauri-dev");
|
default_gitignore.push(".tauri-dev");
|
||||||
|
@ -85,6 +85,43 @@ enum PackageManager {
|
|||||||
#[clap(about = "Shows information about Tauri dependencies and project configuration")]
|
#[clap(about = "Shows information about Tauri dependencies and project configuration")]
|
||||||
pub struct Options;
|
pub struct Options;
|
||||||
|
|
||||||
|
fn version_metadata() -> Result<VersionMetadata> {
|
||||||
|
serde_json::from_str::<VersionMetadata>(include_str!("../metadata.json")).map_err(Into::into)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
pub(crate) fn cli_current_version() -> Result<String> {
|
||||||
|
version_metadata().map(|meta| meta.js_cli.version)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
pub(crate) fn cli_upstream_version() -> Result<String> {
|
||||||
|
let upstream_metadata = match ureq::get(
|
||||||
|
"https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/metadata.json",
|
||||||
|
)
|
||||||
|
.call()
|
||||||
|
{
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(ureq::Error::Status(code, _response)) => {
|
||||||
|
let message = format!("Unable to find updates at the moment. Code: {}", code);
|
||||||
|
return Err(anyhow::Error::msg(message));
|
||||||
|
}
|
||||||
|
Err(ureq::Error::Transport(transport)) => {
|
||||||
|
let message = format!(
|
||||||
|
"Unable to find updates at the moment. Error: {:?}",
|
||||||
|
transport.kind()
|
||||||
|
);
|
||||||
|
return Err(anyhow::Error::msg(message));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
upstream_metadata
|
||||||
|
.into_string()
|
||||||
|
.and_then(|meta_str| Ok(serde_json::from_str::<VersionMetadata>(&meta_str)))
|
||||||
|
.and_then(|json| Ok(json.unwrap().js_cli.version))
|
||||||
|
.map_err(|e| anyhow::Error::new(e))
|
||||||
|
}
|
||||||
|
|
||||||
fn crate_latest_version(name: &str) -> Option<String> {
|
fn crate_latest_version(name: &str) -> Option<String> {
|
||||||
let url = format!("https://docs.rs/crate/{}/", name);
|
let url = format!("https://docs.rs/crate/{}/", name);
|
||||||
match ureq::get(&url).call() {
|
match ureq::get(&url).call() {
|
||||||
@ -582,7 +619,7 @@ pub fn command(_options: Options) -> Result<()> {
|
|||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
panic::set_hook(hook);
|
panic::set_hook(hook);
|
||||||
|
|
||||||
let metadata = serde_json::from_str::<VersionMetadata>(include_str!("../metadata.json"))?;
|
let metadata = version_metadata()?;
|
||||||
VersionBlock::new(
|
VersionBlock::new(
|
||||||
"Node.js",
|
"Node.js",
|
||||||
get_version("node", &[])
|
get_version("node", &[])
|
||||||
|
Loading…
Reference in New Issue
Block a user