サーバーのバージョンとクライアントのバージョンを分けた

This commit is contained in:
syuilo 2018-04-22 21:32:09 +09:00
parent 8682fd21c4
commit 0b99483ccb
8 changed files with 16 additions and 22 deletions

1
.gitignore vendored
View file

@ -10,4 +10,3 @@ npm-debug.log
run.bat run.bat
api-docs.json api-docs.json
package-lock.json package-lock.json
version.json

View file

@ -21,7 +21,7 @@ import * as htmlmin from 'gulp-htmlmin';
const uglifyes = require('uglify-es'); const uglifyes = require('uglify-es');
import { fa } from './src/build/fa'; import { fa } from './src/build/fa';
import version from './src/version'; const client = require('./built/client/meta.json');
import config from './src/config'; import config from './src/config';
const uglify = uglifyComposer(uglifyes, console); const uglify = uglifyComposer(uglifyes, console);
@ -113,7 +113,7 @@ gulp.task('build:client', [
gulp.task('build:client:script', () => gulp.task('build:client:script', () =>
gulp.src(['./src/client/app/boot.js', './src/client/app/safe.js']) gulp.src(['./src/client/app/boot.js', './src/client/app/safe.js'])
.pipe(replace('VERSION', JSON.stringify(version))) .pipe(replace('VERSION', JSON.stringify(client.version)))
.pipe(replace('API', JSON.stringify(config.api_url))) .pipe(replace('API', JSON.stringify(config.api_url)))
.pipe(replace('ENV', JSON.stringify(env))) .pipe(replace('ENV', JSON.stringify(env)))
.pipe(isProduction ? uglify({ .pipe(isProduction ? uglify({

View file

@ -1,12 +1,9 @@
{ {
"name": "misskey", "name": "misskey",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"version": "0.0.5089", "version": "1.0.0",
"clientVersion": "1.0.0",
"codename": "nighthike", "codename": "nighthike",
"license": "MIT",
"description": "A miniblog-based SNS",
"bugs": "https://github.com/syuilo/misskey/issues",
"repository": "https://github.com/syuilo/misskey.git",
"main": "./built/index.js", "main": "./built/index.js",
"private": true, "private": true,
"scripts": { "scripts": {

View file

@ -105,8 +105,8 @@
const meta = await res.json(); const meta = await res.json();
// Compare versions // Compare versions
if (meta.version != ver) { if (meta.clientVersion != ver) {
localStorage.setItem('v', meta.version); localStorage.setItem('v', meta.clientVersion);
alert( alert(
'Misskeyの新しいバージョンがあります。ページを再度読み込みします。' + 'Misskeyの新しいバージョンがあります。ページを再度読み込みします。' +

View file

@ -3,7 +3,7 @@ import { version as current } from '../../config';
export default async function(mios: MiOS, force = false, silent = false) { export default async function(mios: MiOS, force = false, silent = false) {
const meta = await mios.getMeta(force); const meta = await mios.getMeta(force);
const newer = meta.version; const newer = meta.clientVersion;
if (newer != current) { if (newer != current) {
localStorage.setItem('should-refresh', 'true'); localStorage.setItem('should-refresh', 'true');

View file

@ -2,10 +2,12 @@
* Module dependencies * Module dependencies
*/ */
import * as os from 'os'; import * as os from 'os';
import version from '../../../version';
import config from '../../../config'; import config from '../../../config';
import Meta from '../../../models/meta'; import Meta from '../../../models/meta';
const pkg = require('../../../../package.json');
const client = require('../../../../built/client/meta.json');
/** /**
* @swagger * @swagger
* /meta: * /meta:
@ -41,7 +43,10 @@ module.exports = (params) => new Promise(async (res, rej) => {
res({ res({
maintainer: config.maintainer, maintainer: config.maintainer,
version: version,
version: pkg.version,
clientVersion: client.version,
secure: config.https != null, secure: config.https != null,
machine: os.hostname(), machine: os.hostname(),
os: os.platform(), os: os.platform(),

View file

@ -1,7 +0,0 @@
/**
* Version
*/
const meta = require('../version.json');
export default meta.version as string;

View file

@ -19,7 +19,7 @@ import { licenseHtml } from './src/build/license';
import locales from './locales'; import locales from './locales';
const meta = require('./package.json'); const meta = require('./package.json');
const version = meta.version; const version = meta.clientVersion;
const codename = meta.codename; const codename = meta.codename;
//#region Replacer definitions //#region Replacer definitions
@ -114,7 +114,7 @@ module.exports = entries.map(x => {
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development') 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development')
}), }),
new WebpackOnBuildPlugin(stats => { new WebpackOnBuildPlugin(stats => {
fs.writeFileSync('./version.json', JSON.stringify({ fs.writeFileSync('./built/client/meta.json', JSON.stringify({
version version
}), 'utf-8'); }), 'utf-8');
}) })