Skip to content

Commit

Permalink
tweak f13b479
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Sep 28, 2023
1 parent 055c2d8 commit f18e1e2
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/backend/src/boot/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function greet() {

bootLogger.info('Welcome to CherryPick!');
bootLogger.info(`CherryPick v${meta.version}`, null, true);
bootLogger.info(`Based on Misskey v${meta.basedMisskeyVersion}`, null, true);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export type Config = {
signToActivityPubGet: boolean | undefined;

version: string;
basedMisskeyVersion: string;
host: string;
hostname: string;
scheme: string;
Expand Down Expand Up @@ -201,6 +202,7 @@ export function loadConfig(): Config {

const url = tryCreateUrl(config.url);
const version = meta.version;
const basedMisskeyVersion = meta.basedMisskeyVersion;
const host = url.host;
const hostname = url.hostname;
const scheme = url.protocol.replace(/:$/, '');
Expand All @@ -214,6 +216,7 @@ export function loadConfig(): Config {

return {
version,
basedMisskeyVersion,
url: url.origin,
port: config.port ?? parseInt(process.env.PORT ?? '', 10),
socket: config.socket,
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/core/FetchInstanceMetadataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type NodeInfo = {
software?: {
name?: unknown;
version?: unknown;
basedMisskeyVersion?: unknown;
};
metadata?: {
name?: unknown;
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/NodeinfoServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class NodeinfoServerService {
*/
name: 'cherrypick',
version: this.config.version,
basedMisskeyVersion: this.config.basedMisskeyVersion,
homepage: nodeinfo_homepage,
repository: meta.repositoryUrl,
},
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
maintainerName: instance.maintainerName,
maintainerEmail: instance.maintainerEmail,
version: this.config.version,
basedMisskeyVersion: this.config.basedMisskeyVersion,
name: instance.name,
shortName: instance.shortName,
uri: this.config.url,
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/server/api/endpoints/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export const meta = {
type: 'string',
optional: false, nullable: false,
},
basedMisskeyVersion: {
type: 'string',
optional: false, nullable: false,
},
name: {
type: 'string',
optional: false, nullable: false,
Expand Down Expand Up @@ -290,6 +294,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
maintainerEmail: instance.maintainerEmail,

version: this.config.version,
basedMisskeyVersion: this.config.basedMisskeyVersion,

name: instance.name,
shortName: instance.shortName,
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/api/openapi/gen-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function genOpenapiSpec(config: Config) {

info: {
version: config.version,
basedMisskeyVersion: config.basedMisskeyVersion,
title: 'CherryPick API',
'x-logo': { url: '/static-assets/api-doc.png' },
},
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/server/web/ClientServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export class ClientServerService {
},
defaultContext: {
version: this.config.version,
basedMisskeyVersion: this.config.basedMisskeyVersion,
config: this.config,
},
});
Expand Down Expand Up @@ -689,6 +690,7 @@ export class ClientServerService {

return await reply.view('info-card', {
version: this.config.version,
basedMisskeyVersion: this.config.basedMisskeyVersion,
host: this.config.host,
meta: meta,
originalUsersCount: await this.usersRepository.countBy({ host: IsNull() }),
Expand All @@ -699,12 +701,14 @@ export class ClientServerService {
fastify.get('/bios', async (request, reply) => {
return await reply.view('bios', {
version: this.config.version,
basedMisskeyVersion: this.config.basedMisskeyVersion,
});
});

fastify.get('/cli', async (request, reply) => {
return await reply.view('cli', {
version: this.config.version,
basedMisskeyVersion: this.config.basedMisskeyVersion,
});
});

Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/server/web/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@
}
const meta = await metaRes.json();
const v = meta.version;
const basedMisskeyVersion = meta.basedMisskeyVersion;
if (v == null) {
renderError('META_FETCH_V');
return;
}
if (basedMisskeyVersion == null) {
renderError('META_FETCH_BASEDMISSKEY_V');
return;
}

// for https://github.com/misskey-dev/misskey/issues/10202
if (lang == null || lang.toString == null || lang.toString() === 'null') {
Expand Down
3 changes: 2 additions & 1 deletion packages/cherrypick-js/etc/cherrypick-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,7 @@ type LiteInstanceMetadata = {
maintainerName: string | null;
maintainerEmail: string | null;
version: string;
basedMisskeyVersion: string;
name: string | null;
shortName: string | null;
uri: string;
Expand Down Expand Up @@ -3032,7 +3033,7 @@ type UserSorting = '+follower' | '-follower' | '+createdAt' | '-createdAt' | '+u
// src/api.types.ts:16:32 - (ae-forgotten-export) The symbol "TODO" needs to be exported by the entry point index.d.ts
// src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts
// src/api.types.ts:659:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts
// src/entities.ts:587:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/entities.ts:588:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)
Expand Down
1 change: 1 addition & 0 deletions packages/cherrypick-js/src/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export type LiteInstanceMetadata = {
maintainerName: string | null;
maintainerEmail: string | null;
version: string;
basedMisskeyVersion: string;
name: string | null;
shortName: string | null;
uri: string;
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export async function common(createVue: () => App<Element>) {

fetchInstanceMetaPromise.then(() => {
miLocalStorage.setItem('v', instance.version);
miLocalStorage.setItem('basedMisskeyVersion', instance.basedMisskeyVersion);
});

//#region loginId
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/local-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

type Keys =
'v' |
'basedMisskeyVersion' |
'lastVersion' |
'instance' |
'account' |
Expand Down
2 changes: 1 addition & 1 deletion packages/sw/src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ globalThis.addEventListener('activate', ev => {
});

function offlineContentHTML(): string {
return `<!doctype html>Offline. Service Worker @${_VERSION_} <button onclick="location.reload()">reload</button>`;
return `<!doctype html>Offline. Service Worker @${_VERSION_} | @${_BASEDMISSKEYVERSION_} <button onclick="location.reload()">reload</button>`;
}

globalThis.addEventListener('fetch', ev => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const fs = require('fs');
const meta = require('../package.json');

fs.mkdirSync(__dirname + '/../built', { recursive: true });
fs.writeFileSync(__dirname + '/../built/meta.json', JSON.stringify({ version: meta.version }), 'utf-8');
fs.writeFileSync(__dirname + '/../built/meta.json', JSON.stringify({ version: meta.version, basedMisskeyVersion: meta.basedMisskeyVersion }), 'utf-8');

0 comments on commit f18e1e2

Please sign in to comment.