Skip to content

Commit

Permalink
fix(cli): Split metadata.json per major version. (#7276)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars authored Jun 22, 2023
1 parent 0ef9c6b commit 38d0bed
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-cli-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
run: ./.scripts/ci/pack-cli.sh

- name: Get CLI version
run: echo "CLI_VERSION=$(cat tooling/cli/metadata.json | jq '."@tauri-apps/cli".version' -r)" >> $GITHUB_ENV
run: echo "CLI_VERSION=$(cat tooling/cli/metadata-v2.json | jq '."@tauri-apps/cli".version' -r)" >> $GITHUB_ENV

- name: Publish release
uses: softprops/action-gh-release@50195ba7f6f93d1ac97ba8332a178e008ad176aa
Expand Down
10 changes: 6 additions & 4 deletions .scripts/covector/sync-cli-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const { resolve } = require('path')
const packageNickname = process.argv[2]
const filePath =
packageNickname === '@tauri-apps/cli'
? `../../../tooling/cli/metadata.json`
: `../../tooling/cli/metadata.json`
? `../../../tooling/cli/metadata-v2.json`
: `../../tooling/cli/metadata-v2.json`
const bump = process.argv[3]
let index = null

Expand Down Expand Up @@ -50,7 +50,9 @@ const inc = (version) => {
}
}
if (bump === 'premajor') {
const pre = JSON.parse(readFileSync(resolve(filePath, '../../../.changes/pre.json'), 'utf-8'))
const pre = JSON.parse(
readFileSync(resolve(filePath, '../../../.changes/pre.json'), 'utf-8')
)
return `${v.join('.')}-${pre.tag}.0`
}
return v.join('.')
Expand All @@ -70,5 +72,5 @@ if (packageNickname === '@tauri-apps/cli') {
}

writeFileSync(filePath, JSON.stringify(metadata, null, 2) + '\n')
console.log(`wrote ${version} for ${packageNickname} into metadata.json`)
console.log(`wrote ${version} for ${packageNickname} into metadata-v2.json`)
console.dir(metadata)
8 changes: 8 additions & 0 deletions tooling/cli/metadata-v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"cli.js": {
"version": "2.0.0-alpha.10",
"node": ">= 10.0.0"
},
"tauri": "2.0.0-alpha.10",
"tauri-build": "2.0.0-alpha.6"
}
6 changes: 3 additions & 3 deletions tooling/cli/metadata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"cli.js": {
"version": "2.0.0-alpha.10",
"version": "1.4.0",
"node": ">= 10.0.0"
},
"tauri": "2.0.0-alpha.10",
"tauri-build": "2.0.0-alpha.6"
"tauri": "1.4.0",
"tauri-build": "1.4.0"
}
5 changes: 3 additions & 2 deletions tooling/cli/src/info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ pub struct VersionMetadata {
}

fn version_metadata() -> Result<VersionMetadata> {
serde_json::from_str::<VersionMetadata>(include_str!("../../metadata.json")).map_err(Into::into)
serde_json::from_str::<VersionMetadata>(include_str!("../../metadata-v2.json"))
.map_err(Into::into)
}

#[cfg(not(debug_assertions))]
Expand All @@ -46,7 +47,7 @@ pub(crate) fn cli_current_version() -> Result<String> {
#[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",
"https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/metadata-v2.json",
)
.timeout(std::time::Duration::from_secs(3))
.call()
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn command(mut options: Options) -> Result<()> {
options = options.load()?;

let template_target_path = PathBuf::from(&options.directory).join("src-tauri");
let metadata = serde_json::from_str::<VersionMetadata>(include_str!("../metadata.json"))?;
let metadata = serde_json::from_str::<VersionMetadata>(include_str!("../metadata-v2.json"))?;

if template_target_path.exists() && !options.force {
warn!(
Expand Down
3 changes: 2 additions & 1 deletion tooling/cli/src/plugin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ pub fn plugin_name_data(data: &mut BTreeMap<&'static str, serde_json::Value>, pl
}

pub fn crates_metadata() -> Result<VersionMetadata> {
serde_json::from_str::<VersionMetadata>(include_str!("../../metadata.json")).map_err(Into::into)
serde_json::from_str::<VersionMetadata>(include_str!("../../metadata-v2.json"))
.map_err(Into::into)
}

pub fn generate_android_out_file(
Expand Down

0 comments on commit 38d0bed

Please sign in to comment.