mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-25 15:35:12 +00:00
実行時に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', () => {
|
||||
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'])
|
||||
.pipe(replace('VERSION', JSON.stringify(client.version)))
|
||||
.pipe(replace('ENV', JSON.stringify(env)))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import * as program from 'commander';
|
||||
import * as pkg from '../package.json';
|
||||
import config from './config';
|
||||
|
||||
program
|
||||
.version(pkg.version)
|
||||
.version(config.version)
|
||||
.option('--no-daemons', 'Disable daemon processes (for debbuging)')
|
||||
.option('--disable-clustering', 'Disable clustering')
|
||||
.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 { Config } from '../config/types';
|
||||
import { lessThan } from '../prelude/array';
|
||||
import * as pkg from '../../package.json';
|
||||
import { program } from '../argv';
|
||||
import { showMachineInfo } from '../misc/show-machine-info';
|
||||
import { initDb } from '../db/postgre';
|
||||
|
@ -16,10 +15,10 @@ import { initDb } from '../db/postgre';
|
|||
const logger = new Logger('core', 'cyan');
|
||||
const bootLogger = logger.createSubLogger('boot', 'magenta', false);
|
||||
|
||||
function greet() {
|
||||
function greet(config: Config) {
|
||||
if (!program.quiet) {
|
||||
//#region Misskey logo
|
||||
const v = `v${pkg.version}`;
|
||||
const v = `v${config.version}`;
|
||||
console.log(' _____ _ _ ');
|
||||
console.log(' | |_|___ ___| |_ ___ _ _ ');
|
||||
console.log(' | | | | |_ -|_ -| \'_| -_| | |');
|
||||
|
@ -35,21 +34,21 @@ function greet() {
|
|||
}
|
||||
|
||||
bootLogger.info('Welcome to Misskey!');
|
||||
bootLogger.info(`Misskey v${pkg.version}`, null, true);
|
||||
bootLogger.info(`Misskey v${config.version}`, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init master process
|
||||
*/
|
||||
export async function masterMain() {
|
||||
greet();
|
||||
|
||||
let config!: Config;
|
||||
|
||||
try {
|
||||
// initialize app
|
||||
config = await init();
|
||||
|
||||
greet(config);
|
||||
|
||||
if (config.port == null || Number.isNaN(config.port)) {
|
||||
bootLogger.error('The port is not configured. Please configure port.', null, true);
|
||||
process.exit(1);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import * as fs from 'fs';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { Source, Mixin } from './types';
|
||||
import * as pkg from '../../package.json';
|
||||
import * as meta from '../meta.json';
|
||||
|
||||
/**
|
||||
* Path of configuration directory
|
||||
|
@ -30,6 +30,7 @@ export default function load() {
|
|||
|
||||
config.port = config.port || parseInt(process.env.PORT || '', 10);
|
||||
|
||||
mixin.version = meta.version;
|
||||
mixin.host = url.host;
|
||||
mixin.hostname = url.hostname;
|
||||
mixin.scheme = url.protocol.replace(/:$/, '');
|
||||
|
@ -38,7 +39,7 @@ export default function load() {
|
|||
mixin.apiUrl = `${mixin.scheme}://${mixin.host}/api`;
|
||||
mixin.authUrl = `${mixin.scheme}://${mixin.host}/auth`;
|
||||
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;
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ export type Source = {
|
|||
* Misskeyが自動的に(ユーザーが設定した情報から推論して)設定する情報
|
||||
*/
|
||||
export type Mixin = {
|
||||
version: string;
|
||||
host: string;
|
||||
hostname: 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 define from '../define';
|
||||
import { fetchMeta } from '../../../misc/fetch-meta';
|
||||
import * as pkg from '../../../../package.json';
|
||||
import { Emojis } from '../../../models';
|
||||
import { getConnection } from 'typeorm';
|
||||
import redis from '../../../db/redis';
|
||||
|
@ -36,7 +35,7 @@ export const meta = {
|
|||
type: 'string' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
description: 'The version of Misskey of this instance.',
|
||||
example: pkg.version
|
||||
example: config.version
|
||||
},
|
||||
name: {
|
||||
type: 'string' as const,
|
||||
|
@ -114,7 +113,7 @@ export default define(meta, async (ps, me) => {
|
|||
maintainerName: instance.maintainerName,
|
||||
maintainerEmail: instance.maintainerEmail,
|
||||
|
||||
version: pkg.version,
|
||||
version: config.version,
|
||||
|
||||
name: instance.name,
|
||||
uri: config.url,
|
||||
|
|
|
@ -2,7 +2,6 @@ import * as Router from '@koa/router';
|
|||
import config from '../config';
|
||||
import { fetchMeta } from '../misc/fetch-meta';
|
||||
// import User from '../models/user';
|
||||
import { name as softwareName, version, repository } from '../../package.json';
|
||||
// import Note from '../models/note';
|
||||
|
||||
const router = new Router();
|
||||
|
@ -20,27 +19,7 @@ export const links = [/* (awaiting release) {
|
|||
|
||||
const nodeinfo2 = async () => {
|
||||
const [
|
||||
{
|
||||
name,
|
||||
description,
|
||||
maintainerName,
|
||||
maintainerEmail,
|
||||
langs,
|
||||
ToSUrl,
|
||||
repositoryUrl,
|
||||
feedbackUrl,
|
||||
announcements,
|
||||
disableRegistration,
|
||||
disableLocalTimeline,
|
||||
disableGlobalTimeline,
|
||||
enableRecaptcha,
|
||||
maxNoteTextLength,
|
||||
enableTwitterIntegration,
|
||||
enableGithubIntegration,
|
||||
enableDiscordIntegration,
|
||||
enableEmail,
|
||||
enableServiceWorker
|
||||
},
|
||||
meta,
|
||||
// total,
|
||||
// activeHalfyear,
|
||||
// activeMonth,
|
||||
|
@ -57,43 +36,43 @@ const nodeinfo2 = async () => {
|
|||
|
||||
return {
|
||||
software: {
|
||||
name: softwareName,
|
||||
version,
|
||||
repository: repository.url
|
||||
name: 'misskey',
|
||||
version: config.version,
|
||||
repository: meta.repositoryUrl,
|
||||
},
|
||||
protocols: ['activitypub'],
|
||||
services: {
|
||||
inbound: [] as string[],
|
||||
outbound: ['atom1.0', 'rss2.0']
|
||||
},
|
||||
openRegistrations: !disableRegistration,
|
||||
openRegistrations: !meta.disableRegistration,
|
||||
usage: {
|
||||
users: {} // { total, activeHalfyear, activeMonth },
|
||||
// localPosts,
|
||||
// localComments
|
||||
},
|
||||
metadata: {
|
||||
name,
|
||||
description,
|
||||
name: meta.name,
|
||||
description: meta.description,
|
||||
maintainer: {
|
||||
name: maintainerName,
|
||||
email: maintainerEmail
|
||||
name: meta.maintainerName,
|
||||
email: meta.maintainerEmail
|
||||
},
|
||||
langs,
|
||||
ToSUrl,
|
||||
repositoryUrl,
|
||||
feedbackUrl,
|
||||
announcements,
|
||||
disableRegistration,
|
||||
disableLocalTimeline,
|
||||
disableGlobalTimeline,
|
||||
enableRecaptcha,
|
||||
maxNoteTextLength,
|
||||
enableTwitterIntegration,
|
||||
enableGithubIntegration,
|
||||
enableDiscordIntegration,
|
||||
enableEmail,
|
||||
enableServiceWorker
|
||||
langs: meta.langs,
|
||||
ToSUrl: meta.ToSUrl,
|
||||
repositoryUrl: meta.repositoryUrl,
|
||||
feedbackUrl: meta.feedbackUrl,
|
||||
announcements: meta.announcements,
|
||||
disableRegistration: meta.disableRegistration,
|
||||
disableLocalTimeline: meta.disableLocalTimeline,
|
||||
disableGlobalTimeline: meta.disableGlobalTimeline,
|
||||
enableRecaptcha: meta.enableRecaptcha,
|
||||
maxNoteTextLength: meta.maxNoteTextLength,
|
||||
enableTwitterIntegration: meta.enableTwitterIntegration,
|
||||
enableGithubIntegration: meta.enableGithubIntegration,
|
||||
enableDiscordIntegration: meta.enableDiscordIntegration,
|
||||
enableEmail: meta.enableEmail,
|
||||
enableServiceWorker: meta.enableServiceWorker
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -13,7 +13,6 @@ import * as views from 'koa-views';
|
|||
import docs from './docs';
|
||||
import packFeed from './feed';
|
||||
import { fetchMeta } from '../../misc/fetch-meta';
|
||||
import * as pkg from '../../../package.json';
|
||||
import { genOpenapiSpec } from '../api/openapi/gen-spec';
|
||||
import config from '../../config';
|
||||
import { Users, Notes, Emojis, UserProfiles, Pages } from '../../models';
|
||||
|
@ -257,7 +256,7 @@ router.get('/info', async ctx => {
|
|||
where: { host: null }
|
||||
});
|
||||
await ctx.render('info', {
|
||||
version: pkg.version,
|
||||
version: config.version,
|
||||
machine: os.hostname(),
|
||||
os: os.platform(),
|
||||
node: process.version,
|
||||
|
|
|
@ -130,7 +130,7 @@ module.exports = {
|
|||
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development')
|
||||
}),
|
||||
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 });
|
||||
|
||||
|
|
Loading…
Reference in a new issue