forked from FoundKeyGang/FoundKey
実行時にpackage.jsonを参照しないように (#5418)
* 実行時にpackage.jsonを参照しないように * nodeinfo * move meta.json * add dummy * lowercase
This commit is contained in:
parent
5b0dfa6130
commit
92af4401e2
10 changed files with 43 additions and 62 deletions
|
@ -96,7 +96,7 @@ gulp.task('cleanall', gulp.parallel('clean', cb =>
|
||||||
));
|
));
|
||||||
|
|
||||||
gulp.task('build:client:script', () => {
|
gulp.task('build:client:script', () => {
|
||||||
const client = require('./built/client/meta.json');
|
const client = require('./built/meta.json');
|
||||||
return gulp.src(['./src/client/app/boot.js', './src/client/app/safe.js'])
|
return gulp.src(['./src/client/app/boot.js', './src/client/app/safe.js'])
|
||||||
.pipe(replace('VERSION', JSON.stringify(client.version)))
|
.pipe(replace('VERSION', JSON.stringify(client.version)))
|
||||||
.pipe(replace('ENV', JSON.stringify(env)))
|
.pipe(replace('ENV', JSON.stringify(env)))
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as program from 'commander';
|
import * as program from 'commander';
|
||||||
import * as pkg from '../package.json';
|
import config from './config';
|
||||||
|
|
||||||
program
|
program
|
||||||
.version(pkg.version)
|
.version(config.version)
|
||||||
.option('--no-daemons', 'Disable daemon processes (for debbuging)')
|
.option('--no-daemons', 'Disable daemon processes (for debbuging)')
|
||||||
.option('--disable-clustering', 'Disable clustering')
|
.option('--disable-clustering', 'Disable clustering')
|
||||||
.option('--only-server', 'Run server only (without job queue processing)')
|
.option('--only-server', 'Run server only (without job queue processing)')
|
||||||
|
|
|
@ -8,7 +8,6 @@ import Logger from '../services/logger';
|
||||||
import loadConfig from '../config/load';
|
import loadConfig from '../config/load';
|
||||||
import { Config } from '../config/types';
|
import { Config } from '../config/types';
|
||||||
import { lessThan } from '../prelude/array';
|
import { lessThan } from '../prelude/array';
|
||||||
import * as pkg from '../../package.json';
|
|
||||||
import { program } from '../argv';
|
import { program } from '../argv';
|
||||||
import { showMachineInfo } from '../misc/show-machine-info';
|
import { showMachineInfo } from '../misc/show-machine-info';
|
||||||
import { initDb } from '../db/postgre';
|
import { initDb } from '../db/postgre';
|
||||||
|
@ -16,10 +15,10 @@ import { initDb } from '../db/postgre';
|
||||||
const logger = new Logger('core', 'cyan');
|
const logger = new Logger('core', 'cyan');
|
||||||
const bootLogger = logger.createSubLogger('boot', 'magenta', false);
|
const bootLogger = logger.createSubLogger('boot', 'magenta', false);
|
||||||
|
|
||||||
function greet() {
|
function greet(config: Config) {
|
||||||
if (!program.quiet) {
|
if (!program.quiet) {
|
||||||
//#region Misskey logo
|
//#region Misskey logo
|
||||||
const v = `v${pkg.version}`;
|
const v = `v${config.version}`;
|
||||||
console.log(' _____ _ _ ');
|
console.log(' _____ _ _ ');
|
||||||
console.log(' | |_|___ ___| |_ ___ _ _ ');
|
console.log(' | |_|___ ___| |_ ___ _ _ ');
|
||||||
console.log(' | | | | |_ -|_ -| \'_| -_| | |');
|
console.log(' | | | | |_ -|_ -| \'_| -_| | |');
|
||||||
|
@ -35,21 +34,21 @@ function greet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bootLogger.info('Welcome to Misskey!');
|
bootLogger.info('Welcome to Misskey!');
|
||||||
bootLogger.info(`Misskey v${pkg.version}`, null, true);
|
bootLogger.info(`Misskey v${config.version}`, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init master process
|
* Init master process
|
||||||
*/
|
*/
|
||||||
export async function masterMain() {
|
export async function masterMain() {
|
||||||
greet();
|
|
||||||
|
|
||||||
let config!: Config;
|
let config!: Config;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// initialize app
|
// initialize app
|
||||||
config = await init();
|
config = await init();
|
||||||
|
|
||||||
|
greet(config);
|
||||||
|
|
||||||
if (config.port == null || Number.isNaN(config.port)) {
|
if (config.port == null || Number.isNaN(config.port)) {
|
||||||
bootLogger.error('The port is not configured. Please configure port.', null, true);
|
bootLogger.error('The port is not configured. Please configure port.', null, true);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as yaml from 'js-yaml';
|
import * as yaml from 'js-yaml';
|
||||||
import { Source, Mixin } from './types';
|
import { Source, Mixin } from './types';
|
||||||
import * as pkg from '../../package.json';
|
import * as meta from '../meta.json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path of configuration directory
|
* Path of configuration directory
|
||||||
|
@ -30,6 +30,7 @@ export default function load() {
|
||||||
|
|
||||||
config.port = config.port || parseInt(process.env.PORT || '', 10);
|
config.port = config.port || parseInt(process.env.PORT || '', 10);
|
||||||
|
|
||||||
|
mixin.version = meta.version;
|
||||||
mixin.host = url.host;
|
mixin.host = url.host;
|
||||||
mixin.hostname = url.hostname;
|
mixin.hostname = url.hostname;
|
||||||
mixin.scheme = url.protocol.replace(/:$/, '');
|
mixin.scheme = url.protocol.replace(/:$/, '');
|
||||||
|
@ -38,7 +39,7 @@ export default function load() {
|
||||||
mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`;
|
mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`;
|
||||||
mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`;
|
mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`;
|
||||||
mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`;
|
mixin.driveUrl = `${mixin.scheme}://${mixin.host}/files`;
|
||||||
mixin.userAgent = `Misskey/${pkg.version} (${config.url})`;
|
mixin.userAgent = `Misskey/${meta.version} (${config.url})`;
|
||||||
|
|
||||||
if (config.autoAdmin == null) config.autoAdmin = false;
|
if (config.autoAdmin == null) config.autoAdmin = false;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ export type Source = {
|
||||||
* Misskeyが自動的に(ユーザーが設定した情報から推論して)設定する情報
|
* Misskeyが自動的に(ユーザーが設定した情報から推論して)設定する情報
|
||||||
*/
|
*/
|
||||||
export type Mixin = {
|
export type Mixin = {
|
||||||
|
version: string;
|
||||||
host: string;
|
host: string;
|
||||||
hostname: string;
|
hostname: string;
|
||||||
scheme: string;
|
scheme: string;
|
||||||
|
|
3
src/meta.json
Normal file
3
src/meta.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"version": "unknown"
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ import * as os from 'os';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
import define from '../define';
|
import define from '../define';
|
||||||
import { fetchMeta } from '../../../misc/fetch-meta';
|
import { fetchMeta } from '../../../misc/fetch-meta';
|
||||||
import * as pkg from '../../../../package.json';
|
|
||||||
import { Emojis } from '../../../models';
|
import { Emojis } from '../../../models';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import redis from '../../../db/redis';
|
import redis from '../../../db/redis';
|
||||||
|
@ -36,7 +35,7 @@ export const meta = {
|
||||||
type: 'string' as const,
|
type: 'string' as const,
|
||||||
optional: false as const, nullable: false as const,
|
optional: false as const, nullable: false as const,
|
||||||
description: 'The version of Misskey of this instance.',
|
description: 'The version of Misskey of this instance.',
|
||||||
example: pkg.version
|
example: config.version
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: 'string' as const,
|
type: 'string' as const,
|
||||||
|
@ -114,7 +113,7 @@ export default define(meta, async (ps, me) => {
|
||||||
maintainerName: instance.maintainerName,
|
maintainerName: instance.maintainerName,
|
||||||
maintainerEmail: instance.maintainerEmail,
|
maintainerEmail: instance.maintainerEmail,
|
||||||
|
|
||||||
version: pkg.version,
|
version: config.version,
|
||||||
|
|
||||||
name: instance.name,
|
name: instance.name,
|
||||||
uri: config.url,
|
uri: config.url,
|
||||||
|
|
|
@ -2,7 +2,6 @@ import * as Router from '@koa/router';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import { fetchMeta } from '../misc/fetch-meta';
|
import { fetchMeta } from '../misc/fetch-meta';
|
||||||
// import User from '../models/user';
|
// import User from '../models/user';
|
||||||
import { name as softwareName, version, repository } from '../../package.json';
|
|
||||||
// import Note from '../models/note';
|
// import Note from '../models/note';
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
@ -20,27 +19,7 @@ export const links = [/* (awaiting release) {
|
||||||
|
|
||||||
const nodeinfo2 = async () => {
|
const nodeinfo2 = async () => {
|
||||||
const [
|
const [
|
||||||
{
|
meta,
|
||||||
name,
|
|
||||||
description,
|
|
||||||
maintainerName,
|
|
||||||
maintainerEmail,
|
|
||||||
langs,
|
|
||||||
ToSUrl,
|
|
||||||
repositoryUrl,
|
|
||||||
feedbackUrl,
|
|
||||||
announcements,
|
|
||||||
disableRegistration,
|
|
||||||
disableLocalTimeline,
|
|
||||||
disableGlobalTimeline,
|
|
||||||
enableRecaptcha,
|
|
||||||
maxNoteTextLength,
|
|
||||||
enableTwitterIntegration,
|
|
||||||
enableGithubIntegration,
|
|
||||||
enableDiscordIntegration,
|
|
||||||
enableEmail,
|
|
||||||
enableServiceWorker
|
|
||||||
},
|
|
||||||
// total,
|
// total,
|
||||||
// activeHalfyear,
|
// activeHalfyear,
|
||||||
// activeMonth,
|
// activeMonth,
|
||||||
|
@ -57,43 +36,43 @@ const nodeinfo2 = async () => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
software: {
|
software: {
|
||||||
name: softwareName,
|
name: 'misskey',
|
||||||
version,
|
version: config.version,
|
||||||
repository: repository.url
|
repository: meta.repositoryUrl,
|
||||||
},
|
},
|
||||||
protocols: ['activitypub'],
|
protocols: ['activitypub'],
|
||||||
services: {
|
services: {
|
||||||
inbound: [] as string[],
|
inbound: [] as string[],
|
||||||
outbound: ['atom1.0', 'rss2.0']
|
outbound: ['atom1.0', 'rss2.0']
|
||||||
},
|
},
|
||||||
openRegistrations: !disableRegistration,
|
openRegistrations: !meta.disableRegistration,
|
||||||
usage: {
|
usage: {
|
||||||
users: {} // { total, activeHalfyear, activeMonth },
|
users: {} // { total, activeHalfyear, activeMonth },
|
||||||
// localPosts,
|
// localPosts,
|
||||||
// localComments
|
// localComments
|
||||||
},
|
},
|
||||||
metadata: {
|
metadata: {
|
||||||
name,
|
name: meta.name,
|
||||||
description,
|
description: meta.description,
|
||||||
maintainer: {
|
maintainer: {
|
||||||
name: maintainerName,
|
name: meta.maintainerName,
|
||||||
email: maintainerEmail
|
email: meta.maintainerEmail
|
||||||
},
|
},
|
||||||
langs,
|
langs: meta.langs,
|
||||||
ToSUrl,
|
ToSUrl: meta.ToSUrl,
|
||||||
repositoryUrl,
|
repositoryUrl: meta.repositoryUrl,
|
||||||
feedbackUrl,
|
feedbackUrl: meta.feedbackUrl,
|
||||||
announcements,
|
announcements: meta.announcements,
|
||||||
disableRegistration,
|
disableRegistration: meta.disableRegistration,
|
||||||
disableLocalTimeline,
|
disableLocalTimeline: meta.disableLocalTimeline,
|
||||||
disableGlobalTimeline,
|
disableGlobalTimeline: meta.disableGlobalTimeline,
|
||||||
enableRecaptcha,
|
enableRecaptcha: meta.enableRecaptcha,
|
||||||
maxNoteTextLength,
|
maxNoteTextLength: meta.maxNoteTextLength,
|
||||||
enableTwitterIntegration,
|
enableTwitterIntegration: meta.enableTwitterIntegration,
|
||||||
enableGithubIntegration,
|
enableGithubIntegration: meta.enableGithubIntegration,
|
||||||
enableDiscordIntegration,
|
enableDiscordIntegration: meta.enableDiscordIntegration,
|
||||||
enableEmail,
|
enableEmail: meta.enableEmail,
|
||||||
enableServiceWorker
|
enableServiceWorker: meta.enableServiceWorker
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,6 @@ import * as views from 'koa-views';
|
||||||
import docs from './docs';
|
import docs from './docs';
|
||||||
import packFeed from './feed';
|
import packFeed from './feed';
|
||||||
import { fetchMeta } from '../../misc/fetch-meta';
|
import { fetchMeta } from '../../misc/fetch-meta';
|
||||||
import * as pkg from '../../../package.json';
|
|
||||||
import { genOpenapiSpec } from '../api/openapi/gen-spec';
|
import { genOpenapiSpec } from '../api/openapi/gen-spec';
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
import { Users, Notes, Emojis, UserProfiles, Pages } from '../../models';
|
import { Users, Notes, Emojis, UserProfiles, Pages } from '../../models';
|
||||||
|
@ -257,7 +256,7 @@ router.get('/info', async ctx => {
|
||||||
where: { host: null }
|
where: { host: null }
|
||||||
});
|
});
|
||||||
await ctx.render('info', {
|
await ctx.render('info', {
|
||||||
version: pkg.version,
|
version: config.version,
|
||||||
machine: os.hostname(),
|
machine: os.hostname(),
|
||||||
os: os.platform(),
|
os: os.platform(),
|
||||||
node: process.version,
|
node: process.version,
|
||||||
|
|
|
@ -130,7 +130,7 @@ module.exports = {
|
||||||
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development')
|
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development')
|
||||||
}),
|
}),
|
||||||
new WebpackOnBuildPlugin((stats: any) => {
|
new WebpackOnBuildPlugin((stats: any) => {
|
||||||
fs.writeFileSync('./built/client/meta.json', JSON.stringify({ version: meta.version }), 'utf-8');
|
fs.writeFileSync('./built/meta.json', JSON.stringify({ version: meta.version }), 'utf-8');
|
||||||
|
|
||||||
fs.mkdirSync('./built/client/assets/locales', { recursive: true });
|
fs.mkdirSync('./built/client/assets/locales', { recursive: true });
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue