Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/optimization #339

Merged
merged 7 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions build/build.static.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ call runasadmin.bat "%~dpnx0"
if %errorlevel% == 0 (
PUSHD %~dp0..

echo "mode=%1"

REM call yarn wipe
call yarn install

REM call yarn build
call yarn build
IF "%1"=="" (
call yarn build
) ELSE (
call yarn build:personal
)

REM call yarn wipe
call yarn deploy
IF "%1"=="" (
call yarn deploy
) ELSE (
call yarn deploy:personal
)

REM copy nginx configurations to deploy folder
xcopy config\nginx\onlyoffice.conf build\deploy\nginx\ /E /R /Y
Expand Down
18 changes: 18 additions & 0 deletions build/buildAndDeploy.PERSONAL.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
PUSHD %~dp0
call runasadmin.bat "%~dpnx0"
if %errorlevel% == 0 (

call start\stop.bat

PUSHD %~dp0..

echo "FRONT-END static"
call build\build.static.bat --personal

echo "BACK-END"
call build\build.backend.bat

start /b call build\start\start.bat

pause
)
44 changes: 23 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "appserver",
"private": true,
"version": "0.1.10",
"private": true,
"workspaces": [
"packages/asc-web-components",
"packages/asc-web-common",
Expand All @@ -16,38 +16,40 @@
"products/ASC.Calendar/Client"
],
"scripts": {
"wipe": "shx rm -rf node_modules yarn.lock web/**/node_modules products/**/node_modules",
"build": "concurrently \"wsrun --parallel build\"",
"build": "lerna run build --parallel --ignore @appserver/common --ignore @appserver/components",
"build:personal": "lerna run build --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor}",
"bump": "lerna version --no-push --no-git-tag-version",
"clean": "lerna run clean --parallel",
"deploy": "shx rm -rf build/deploy/products && shx rm -rf build/deploy/public && shx rm -rf build/deploy/studio && lerna run deploy --parallel --ignore @appserver/common --ignore @appserver/components && shx cp -r public build/deploy && yarn sw-build",
"deploy:personal": "shx rm -rf build/deploy/products && shx rm -rf build/deploy/public && shx rm -rf build/deploy/studio && lerna run deploy --parallel --scope {@appserver/studio,@appserver/people,@appserver/files,@appserver/editor} && shx cp -r public build/deploy && yarn sw-build:personal",
"serve": "lerna run serve --parallel --ignore @appserver/common --ignore @appserver/components",
"start": "lerna run start --parallel --ignore @appserver/common --ignore @appserver/components",
"start-prod": "lerna run start-prod --parallel --ignore @appserver/common --ignore @appserver/components",
"storybook": "yarn workspace @appserver/components storybook",
"storybook-build": "yarn workspace @appserver/components run storybook-build",
"sw-build": "workbox injectManifest config/workbox-config.js && yarn sw-modify && yarn sw-minimize",
"sw-build:personal": "workbox injectManifest config/workbox-config.js && yarn sw-modify:personal && yarn sw-minimize",
"sw-calendar-replace": "replace-in-files --string='products/ASC.Calendar/client/' --replacement='products/calendar/' build/deploy/public/sw.js",
"sw-crm-replace": "replace-in-files --string='products/ASC.CRM/client/' --replacement='products/crm/' build/deploy/public/sw.js",
"sw-files-replace": "replace-in-files --string='products/ASC.Files/client/' --replacement='products/files/' build/deploy/public/sw.js",
"sw-files-editor-replace": "replace-in-files --string='products/ASC.Files/editor/' --replacement='products/files/doceditor/' build/deploy/public/sw.js",
"sw-files-replace": "replace-in-files --string='products/ASC.Files/client/' --replacement='products/files/' build/deploy/public/sw.js",
"sw-mail-replace": "replace-in-files --string='products/ASC.Mail/client/' --replacement='products/mail/' build/deploy/public/sw.js",
"sw-minimize": "yarn terser --compress --mangle -- build/deploy/public/sw.js --output build/deploy/public/sw.js",
"sw-modify": "yarn sw-calendar-replace && yarn sw-crm-replace && yarn sw-files-replace && yarn sw-files-editor-replace && yarn sw-mail-replace && yarn sw-people-replace && yarn sw-projects-replace && yarn sw-studio-replace && yarn sw-studio-login-replace && yarn sw-public-replace",
"sw-modify:personal": "yarn sw-files-replace && yarn sw-files-editor-replace && yarn sw-people-replace && yarn sw-studio-replace && yarn sw-public-replace",
"sw-people-replace": "replace-in-files --string='products/ASC.People/client/' --replacement='products/people/' build/deploy/public/sw.js",
"sw-projects-replace": "replace-in-files --string='products/ASC.Projects/client/' --replacement='products/projects/' build/deploy/public/sw.js",
"sw-studio-replace": "replace-in-files --string='studio/client/' --replacement='/' build/deploy/public/sw.js",
"sw-studio-login-replace": "replace-in-files --string='studio/login/' --replacement='login/' build/deploy/public/sw.js",
"sw-public-replace": "replace-in-files --string='public/' --replacement='static/' build/deploy/public/sw.js",
"sw-modify": "yarn sw-calendar-replace && yarn sw-crm-replace && yarn sw-crm-replace && yarn sw-files-replace && yarn sw-files-editor-replace && yarn sw-mail-replace && yarn sw-people-replace && yarn sw-projects-replace && yarn sw-studio-replace && yarn sw-studio-login-replace && yarn sw-public-replace",
"sw-minimize": "yarn terser --compress --mangle -- build/deploy/public/sw.js --output build/deploy/public/sw.js",
"start": "concurrently \"wsrun --parallel start\"",
"start-prod": "concurrently \"wsrun --parallel start-prod\"",
"serve": "concurrently \"wsrun --parallel serve\"",
"sw-studio-login-replace": "replace-in-files --string='studio/login/' --replacement='login/' build/deploy/public/sw.js",
"sw-studio-replace": "replace-in-files --string='studio/client/' --replacement='/' build/deploy/public/sw.js",
"test": "yarn workspace @appserver/components test",
"clean": "concurrently \"wsrun --parallel clean\"",
"storybook": "yarn workspace @appserver/components storybook",
"storybook-build": "yarn workspace @appserver/components run storybook-build",
"bump": "lerna version --no-push --no-git-tag-version",
"deploy": "shx rm -rf build/deploy && concurrently \"wsrun --parallel deploy\" && shx cp -r public build/deploy && yarn sw-build"
"wipe": "shx rm -rf node_modules yarn.lock web/**/node_modules products/**/node_modules"
},
"devDependencies": {
"concurrently": "^5.3.0",
"lerna": "^3.22.1",
"lerna": "^4.0.0",
"replace-in-files-cli": "^1.0.0",
"shx": "^0.3.3",
"terser": "^5.7.1",
"workbox-cli": "^6.2.3",
"wsrun": "^5.2.4"
"terser": "^5.8.0",
"workbox-cli": "^6.3.0"
}
}
4 changes: 2 additions & 2 deletions packages/asc-web-common/api/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const loginURL = combineUrl(proxyURL, "/login");
const paymentsURL = combineUrl(proxyURL, "/payments");

window.AppServer = {
...window.AppServer,
origin,
proxyURL,
apiPrefixURL,
apiBaseURL,
apiTimeout,
loginURL,
paymentsURL,
};

Expand Down Expand Up @@ -85,7 +85,7 @@ export const request = function (options) {
url: "/authentication/logout",
}).then(() => {
setWithCredentialsStatus(false);
window.location.href = loginURL;
window.location.href = window?.AppServer?.personal ? "/" : loginURL;
});
break;
case 402:
Expand Down
6 changes: 6 additions & 0 deletions packages/asc-web-common/store/SettingsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ class SettingsStore {
localStorage.setItem(LANGUAGE, newSettings[key]);
}
}
if (key === "personal") {
window.AppServer = {
...window.AppServer,
personal: newSettings[key],
};
}
} else if (key === "passwordHash") {
this.setValue("hashSettings", newSettings[key]);
}
Expand Down
35 changes: 20 additions & 15 deletions web/ASC.Web.Client/src/Shell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Payments = React.lazy(() => import("./components/pages/Payments"));
const Error404 = React.lazy(() => import("studio/Error404"));
const Error401 = React.lazy(() => import("studio/Error401"));
const Home = React.lazy(() => import("./components/pages/Home"));
const Login = React.lazy(() => import("login/app"));

const About = React.lazy(() => import("./components/pages/About"));
const Wizard = React.lazy(() => import("./components/pages/Wizard"));
const Settings = React.lazy(() => import("./components/pages/Settings"));
Expand Down Expand Up @@ -105,14 +105,6 @@ const ConfirmRoute = (props) => (
</React.Suspense>
);

const LoginRoute = (props) => (
<React.Suspense fallback={<AppLoader />}>
<ErrorBoundary>
<Login {...props} />
</ErrorBoundary>
</React.Suspense>
);

const AboutRoute = (props) => (
<React.Suspense fallback={<AppLoader />}>
<ErrorBoundary>
Expand Down Expand Up @@ -383,7 +375,24 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
);
});

//console.log("Shell ", history);
const loginRoutes = [];

if (!personal) {
const loginSystem = {
url: combineUrl(AppServerConfig.proxyURL, "/login/remoteEntry.js"),
scope: "login",
module: "./app",
};
loginRoutes.push(
<PublicRoute
key={loginSystem.scope}
exact
path={LOGIN_URLS}
component={System}
system={loginSystem}
/>
);
}

return (
<Layout>
Expand All @@ -396,11 +405,7 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
<PrivateRoute exact path={HOME_URLS} component={HomeRoute} />
<PublicRoute exact path={WIZARD_URL} component={WizardRoute} />
<PrivateRoute path={ABOUT_URL} component={AboutRoute} />
<PublicRoute
exact
path={personal ? "/" : LOGIN_URLS}
component={LoginRoute}
/>
{loginRoutes}
<Route path={CONFIRM_URL} component={ConfirmRoute} />
<PrivateRoute
path={COMING_SOON_URLS}
Expand Down
4 changes: 0 additions & 4 deletions web/ASC.Web.Client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ const config = {
AppServerConfig.proxyURL,
"/remoteEntry.js"
)}`,
login: `login@${combineUrl(
AppServerConfig.proxyURL,
"/login/remoteEntry.js"
)}`,
people: `people@${combineUrl(
AppServerConfig.proxyURL,
"/products/people/remoteEntry.js"
Expand Down
Loading