From bd5a4c272d7b76d79d91f436cf7c3347d05b2fd4 Mon Sep 17 00:00:00 2001 From: DmitryAstafyev Date: Mon, 22 Jan 2024 10:27:37 +0100 Subject: [PATCH] Add missed script links --- .../apps/rustcore/ts-bindings/package.json | 1 + application/holder/package.json | 1 + application/platform/package.json | 1 + cli/src/modules/app.rs | 16 +++++++++++++--- cli/src/modules/client.rs | 7 +++++++ cli/src/modules/mod.rs | 7 +++++-- cli/src/modules/wrapper.rs | 2 +- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/application/apps/rustcore/ts-bindings/package.json b/application/apps/rustcore/ts-bindings/package.json index a8fc62b7b..57d2b7a70 100644 --- a/application/apps/rustcore/ts-bindings/package.json +++ b/application/apps/rustcore/ts-bindings/package.json @@ -6,6 +6,7 @@ "types": "./dist/index.d.ts", "scripts": { "build": "node_modules/.bin/tsc -p tsconfig.json", + "prod": "node_modules/.bin/tsc -p tsconfig.json", "test_cancel": "node_modules/.bin/electron node_modules/jasmine-ts/lib/index.js ./spec/session.cancel.spec.ts", "lint": "node_modules/.bin/eslint . --ext .ts --max-warnings=0", "check": "node_modules/.bin/tsc -p tsconfig.json --noemit" diff --git a/application/holder/package.json b/application/holder/package.json index f52804883..e30fbb33a 100644 --- a/application/holder/package.json +++ b/application/holder/package.json @@ -115,6 +115,7 @@ "electron": "npm run build && ./node_modules/.bin/electron --inspect ./dist/app.js", "electron-win": "node_modules/.bin/electron --inspect ./dist/app.js", "build": "node_modules/.bin/tsc -p tsconfig.json", + "prod": "node_modules/.bin/tsc -p tsconfig.json", "start": "npm run build-ts && npm run electron", "postinstall": "electron-builder install-app-deps", "build-darwin": "node_modules/.bin/electron-builder --mac --dir", diff --git a/application/platform/package.json b/application/platform/package.json index ee3393bfc..451833d81 100644 --- a/application/platform/package.json +++ b/application/platform/package.json @@ -34,6 +34,7 @@ }, "scripts": { "build": "node_modules/.bin/tsc -p tsconfig.json", + "prod": "node_modules/.bin/tsc -p tsconfig.json", "lint": "node_modules/.bin/eslint . --ext .ts --max-warnings=0 ", "check": "node_modules/.bin/tsc -p tsconfig.json --noemit" }, diff --git a/cli/src/modules/app.rs b/cli/src/modules/app.rs index 143c42055..e1198b658 100644 --- a/cli/src/modules/app.rs +++ b/cli/src/modules/app.rs @@ -36,8 +36,11 @@ impl Manager for Module { // For app we don't need --production Some(String::from("yarn install")) } - async fn after(&self) -> Result, Error> { - let src = Target::Client.get().cwd().join("dist/client"); + async fn after(&self, prod: bool) -> Result, Error> { + let src = Target::Client.get().dist_path(prod).ok_or(Error::new( + ErrorKind::NotFound, + "Fail to get client artifacts", + ))?; let dest = self.cwd().join("dist"); if !src.exists() { return Err(Error::new( @@ -52,7 +55,14 @@ impl Manager for Module { if prev.exists() { fstools::rm_folder(prev).await?; } - fstools::cp_folder(src, dest).await?; + fstools::cp_folder(src.clone(), dest.clone()).await?; + std::fs::rename( + dest.join(src.file_name().ok_or(Error::new( + ErrorKind::NotFound, + "Fail to parse client artifacts path", + ))?), + dest.join("client"), + )?; Ok(None) } } diff --git a/cli/src/modules/client.rs b/cli/src/modules/client.rs index 3791c0594..978791a1c 100644 --- a/cli/src/modules/client.rs +++ b/cli/src/modules/client.rs @@ -28,4 +28,11 @@ impl Manager for Module { fn deps(&self) -> Vec { vec![Target::Shared, Target::Wasm] } + fn dist_path(&self, prod: bool) -> Option { + Some(LOCATION.root.clone().join(PATH).join(if prod { + "dist/release" + } else { + "dist/debug" + })) + } } diff --git a/cli/src/modules/mod.rs b/cli/src/modules/mod.rs index 25239df93..e486a1731 100644 --- a/cli/src/modules/mod.rs +++ b/cli/src/modules/mod.rs @@ -64,6 +64,9 @@ pub trait Manager { fn kind(&self) -> Kind; fn owner(&self) -> Target; fn cwd(&self) -> PathBuf; + fn dist_path(&self, _prod: bool) -> Option { + None + } fn deps(&self) -> Vec; fn build_cmd(&self, _prod: bool) -> Option { None @@ -114,7 +117,7 @@ pub trait Manager { Kind::Rs => Ok(SpawnResult::empty()), } } - async fn after(&self) -> Result, Error> { + async fn after(&self, _prod: bool) -> Result, Error> { Ok(None) } async fn build(&self, prod: bool) -> Result { @@ -138,7 +141,7 @@ pub trait Manager { if !status.status.success() { Ok(status) } else { - let res = self.after().await?; + let res = self.after(prod).await?; if matches!(self.kind(), Kind::Ts) && prod { self.clean().await?; self.install(prod).await?; diff --git a/cli/src/modules/wrapper.rs b/cli/src/modules/wrapper.rs index caca879f2..024b71d69 100644 --- a/cli/src/modules/wrapper.rs +++ b/cli/src/modules/wrapper.rs @@ -32,7 +32,7 @@ impl Manager for Module { fn deps(&self) -> Vec { vec![Target::Binding, Target::Shared] } - async fn after(&self) -> Result, Error> { + async fn after(&self, _prod: bool) -> Result, Error> { let src = Target::Binding.get().cwd().join("dist/index.node"); let dest = self.cwd().join("dist/native"); if !src.exists() {