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

feat: add client version #2932

Merged
merged 3 commits into from
Nov 20, 2019
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
3 changes: 3 additions & 0 deletions packages/iceworks-server/src/app/middleware/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { checkAliInternal } from 'ice-npm-utils';

const packageJSON = require('../../../package.json');

export default function() {
return async function client(ctx, next) {
if (String(ctx.path).indexOf('/api') === 0) {
Expand All @@ -15,6 +17,7 @@ export default function() {
socketUrl: `//127.0.0.1:${process.env.PORT}/`,
apiUrl: `//127.0.0.1:${process.env.PORT}/api/`,
isAliInternal: await checkAliInternal(),
clientVersion: packageJSON.version.split('.').join(''),
};

await next();
Expand Down
4 changes: 2 additions & 2 deletions packages/iceworks-server/src/app/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" />
<meta name="viewport" content="width=device-width" />
<link href="{{ clientPath }}css/index.css" rel="stylesheet" />
<link href="{{ clientPath }}css/index.css?v={{clientVersion}}" rel="stylesheet" />
<link rel="shortcut icon" href="{{ clientPath }}favicon.png" />
<title>iceworks</title>
</head>
Expand All @@ -18,6 +18,6 @@
isAliInternal: {{isAliInternal}},
};
</script>
<script src="{{ clientPath }}js/index.js"></script>
<script src="{{ clientPath }}js/index.js?v={{clientVersion}}"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions packages/iceworks-server/test/app/controller/home.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ describe('GET /', () => {

assert.equal(status, 200);

const cssLinkReg = /<link\shref="(.+)css\/index.css"\srel="stylesheet" \/>/i;
const cssLinkReg = /<link\shref="(.+)css\/index.css(.+)"\srel="stylesheet" \/>/i;
const faviconLinkReg = /<link\srel="shortcut\sicon"\shref="(.+)favicon.png"\s\/>/i;
const scriptReg = /<script\ssrc="(.+)js\/index.js"/i;
const scriptReg = /<script\ssrc="(.+)js\/index.js(.+)"/i;
const iceworksConfigScriptReg = /<script>[\s]*window.iceworksConfig/i;
// should load common css
assert.equal(cssLinkReg.test(text), true);
Expand Down