nicolium: update vite-plugin-compile-time
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -127,6 +127,7 @@
|
||||
"resize-observer": "^1.0.4",
|
||||
"sass-embedded": "^1.93.3",
|
||||
"stringz": "^2.1.0",
|
||||
"tabbable": "^6.4.0",
|
||||
"use-mutative": "^1.3.1",
|
||||
"util": "^0.12.5",
|
||||
"valibot": "^1.2.0",
|
||||
@ -171,7 +172,7 @@
|
||||
"typescript": "5.7.3",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-checker": "^0.12.0",
|
||||
"vite-plugin-compile-time": "^0.3.2",
|
||||
"vite-plugin-compile-time": "^0.4.6",
|
||||
"vite-plugin-html": "^3.2.2",
|
||||
"vite-plugin-pwa": "^1.2.0",
|
||||
"vite-plugin-require": "^1.2.14",
|
||||
|
||||
@ -1,8 +1,51 @@
|
||||
import type { PlFeEnv } from './build-config-compiletime';
|
||||
/**
|
||||
* Build config: configuration set at build time.
|
||||
* @module pl-fe/build-config
|
||||
*/
|
||||
|
||||
export const {
|
||||
// eslint-disable-next-line import/extensions
|
||||
import trim from 'lodash/trim.js';
|
||||
// eslint-disable-next-line import/extensions
|
||||
import trimEnd from 'lodash/trimEnd.js';
|
||||
|
||||
const env = compileTime(() => {
|
||||
const {
|
||||
NODE_ENV,
|
||||
BACKEND_URL,
|
||||
FE_SUBDIRECTORY,
|
||||
WITH_LANDING_PAGE,
|
||||
} = process.env;
|
||||
|
||||
const sanitizeURL = (url: string | undefined = ''): string => {
|
||||
try {
|
||||
return trimEnd(new URL(url).toString(), '/');
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
const sanitizeBasename = (path: string | undefined = ''): string => `/${trim(path, '/')}`;
|
||||
|
||||
return {
|
||||
NODE_ENV: NODE_ENV || 'development',
|
||||
BACKEND_URL: sanitizeURL(BACKEND_URL),
|
||||
FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY),
|
||||
WITH_LANDING_PAGE: WITH_LANDING_PAGE === 'true',
|
||||
};
|
||||
});
|
||||
|
||||
const {
|
||||
NODE_ENV,
|
||||
BACKEND_URL,
|
||||
FE_SUBDIRECTORY,
|
||||
WITH_LANDING_PAGE,
|
||||
} = import.meta.compileTime<PlFeEnv>('./build-config-compiletime.ts');
|
||||
} = env;
|
||||
|
||||
export type PlFeEnv = typeof env;
|
||||
|
||||
export {
|
||||
NODE_ENV,
|
||||
BACKEND_URL,
|
||||
FE_SUBDIRECTORY,
|
||||
WITH_LANDING_PAGE,
|
||||
};
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
// Converts cryptocurrency-icon's manifest file from a list to a map.
|
||||
// See: https://github.com/spothq/cryptocurrency-icons/blob/master/manifest.json
|
||||
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const manifest = require('cryptocurrency-icons/manifest.json');
|
||||
|
||||
const manifestMap = manifest.reduce((acc: Record<string, typeof manifest[0]>, entry: typeof manifest[0]) => {
|
||||
acc[entry.symbol.toLowerCase()] = entry;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
export default () => ({
|
||||
data: manifestMap,
|
||||
});
|
||||
@ -1,3 +1,5 @@
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
interface ManifestMap {
|
||||
[s: string]: {
|
||||
symbol: string;
|
||||
@ -6,6 +8,18 @@ interface ManifestMap {
|
||||
};
|
||||
}
|
||||
|
||||
export default import.meta.compileTime<ManifestMap>('./manifest-map-compiletime.ts');
|
||||
const manifestMap = compileTime(() => {
|
||||
const require = createRequire(import.meta.url);
|
||||
const manifest = require('cryptocurrency-icons/manifest.json');
|
||||
|
||||
const manifestMap = manifest.reduce((acc: Record<string, typeof manifest[0]>, entry: typeof manifest[0]) => {
|
||||
acc[entry.symbol.toLowerCase()] = entry;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return manifestMap;
|
||||
});
|
||||
|
||||
export default manifestMap;
|
||||
|
||||
export type { ManifestMap };
|
||||
|
||||
@ -1,107 +0,0 @@
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
import type { EmojiData } from './data';
|
||||
import type { UnicodeMap } from './mapping';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const data = require('@emoji-mart/data/sets/14/twitter.json');
|
||||
|
||||
const stripLeadingZeros = /^0+/;
|
||||
|
||||
/*
|
||||
* Twemoji strips their hex codes from unicode codepoints to make it look "pretty"
|
||||
* - leading 0s are removed
|
||||
* - fe0f is removed unless it has 200d
|
||||
* - fe0f is NOT removed for 1f441-fe0f-200d-1f5e8-fe0f even though it has a 200d
|
||||
*
|
||||
* this is all wrong
|
||||
*/
|
||||
const blacklist = {
|
||||
'1f441-fe0f-200d-1f5e8-fe0f': true,
|
||||
};
|
||||
|
||||
const tweaks = {
|
||||
'#⃣': ['23-20e3', 'hash'],
|
||||
'*⃣': ['2a-20e3', 'keycap_star'],
|
||||
'0⃣': ['30-20e3', 'zero'],
|
||||
'1⃣': ['31-20e3', 'one'],
|
||||
'2⃣': ['32-20e3', 'two'],
|
||||
'3⃣': ['33-20e3', 'three'],
|
||||
'4⃣': ['34-20e3', 'four'],
|
||||
'5⃣': ['35-20e3', 'five'],
|
||||
'6⃣': ['36-20e3', 'six'],
|
||||
'7⃣': ['37-20e3', 'seven'],
|
||||
'8⃣': ['38-20e3', 'eight'],
|
||||
'9⃣': ['39-20e3', 'nine'],
|
||||
'❤🔥': ['2764-fe0f-200d-1f525', 'heart_on_fire'],
|
||||
'❤🩹': ['2764-fe0f-200d-1fa79', 'mending_heart'],
|
||||
'👁🗨️': ['1f441-fe0f-200d-1f5e8-fe0f', 'eye-in-speech-bubble'],
|
||||
'👁️🗨': ['1f441-fe0f-200d-1f5e8-fe0f', 'eye-in-speech-bubble'],
|
||||
'👁🗨': ['1f441-fe0f-200d-1f5e8-fe0f', 'eye-in-speech-bubble'],
|
||||
'🕵♂️': ['1f575-fe0f-200d-2642-fe0f', 'male-detective'],
|
||||
'🕵️♂': ['1f575-fe0f-200d-2642-fe0f', 'male-detective'],
|
||||
'🕵♂': ['1f575-fe0f-200d-2642-fe0f', 'male-detective'],
|
||||
'🕵♀️': ['1f575-fe0f-200d-2640-fe0f', 'female-detective'],
|
||||
'🕵️♀': ['1f575-fe0f-200d-2640-fe0f', 'female-detective'],
|
||||
'🕵♀': ['1f575-fe0f-200d-2640-fe0f', 'female-detective'],
|
||||
'🏌♂️': ['1f3cc-fe0f-200d-2642-fe0f', 'man-golfing'],
|
||||
'🏌️♂': ['1f3cc-fe0f-200d-2642-fe0f', 'man-golfing'],
|
||||
'🏌♂': ['1f3cc-fe0f-200d-2642-fe0f', 'man-golfing'],
|
||||
'🏌♀️': ['1f3cc-fe0f-200d-2640-fe0f', 'woman-golfing'],
|
||||
'🏌️♀': ['1f3cc-fe0f-200d-2640-fe0f', 'woman-golfing'],
|
||||
'🏌♀': ['1f3cc-fe0f-200d-2640-fe0f', 'woman-golfing'],
|
||||
'⛹♂️': ['26f9-fe0f-200d-2642-fe0f', 'man-bouncing-ball'],
|
||||
'⛹️♂': ['26f9-fe0f-200d-2642-fe0f', 'man-bouncing-ball'],
|
||||
'⛹♂': ['26f9-fe0f-200d-2642-fe0f', 'man-bouncing-ball'],
|
||||
'⛹♀️': ['26f9-fe0f-200d-2640-fe0f', 'woman-bouncing-ball'],
|
||||
'⛹️♀': ['26f9-fe0f-200d-2640-fe0f', 'woman-bouncing-ball'],
|
||||
'⛹♀': ['26f9-fe0f-200d-2640-fe0f', 'woman-bouncing-ball'],
|
||||
'🏋♂️': ['1f3cb-fe0f-200d-2642-fe0f', 'man-lifting-weights'],
|
||||
'🏋️♂': ['1f3cb-fe0f-200d-2642-fe0f', 'man-lifting-weights'],
|
||||
'🏋♂': ['1f3cb-fe0f-200d-2642-fe0f', 'man-lifting-weights'],
|
||||
'🏋♀️': ['1f3cb-fe0f-200d-2640-fe0f', 'woman-lifting-weights'],
|
||||
'🏋️♀': ['1f3cb-fe0f-200d-2640-fe0f', 'woman-lifting-weights'],
|
||||
'🏋♀': ['1f3cb-fe0f-200d-2640-fe0f', 'woman-lifting-weights'],
|
||||
'🏳🌈': ['1f3f3-fe0f-200d-1f308', 'rainbow_flag'],
|
||||
'🏳⚧️': ['1f3f3-fe0f-200d-26a7-fe0f', 'transgender_flag'],
|
||||
'🏳️⚧': ['1f3f3-fe0f-200d-26a7-fe0f', 'transgender_flag'],
|
||||
'🏳⚧': ['1f3f3-fe0f-200d-26a7-fe0f', 'transgender_flag'],
|
||||
};
|
||||
|
||||
const stripcodes = (unified: string, native: string) => {
|
||||
const stripped = unified.replace(stripLeadingZeros, '');
|
||||
|
||||
if (unified.includes('200d') && !(unified in blacklist)) {
|
||||
return stripped;
|
||||
} else {
|
||||
return stripped.replaceAll('-fe0f', '');
|
||||
}
|
||||
};
|
||||
|
||||
const generateMappings = (emojiMap: EmojiData['emojis']): UnicodeMap => {
|
||||
const result: UnicodeMap = {};
|
||||
const emojis = Object.values(emojiMap ?? {});
|
||||
|
||||
for (const value of emojis) {
|
||||
for (const item of value.skins) {
|
||||
const { unified, native } = item;
|
||||
const stripped = stripcodes(unified, native);
|
||||
|
||||
result[native] = { unified: stripped, shortcode: value.id };
|
||||
}
|
||||
}
|
||||
|
||||
for (const [native, [unified, shortcode]] of Object.entries(tweaks)) {
|
||||
const stripped = stripcodes(unified, native);
|
||||
|
||||
result[native] = { unified: stripped, shortcode };
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const unicodeMapping = generateMappings(data.emojis);
|
||||
|
||||
export default () => ({
|
||||
data: unicodeMapping,
|
||||
});
|
||||
@ -1,3 +1,7 @@
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
import type { EmojiData } from './data';
|
||||
|
||||
interface UnicodeMap {
|
||||
[s: string]: {
|
||||
unified: string;
|
||||
@ -5,6 +9,106 @@ interface UnicodeMap {
|
||||
};
|
||||
}
|
||||
|
||||
export default import.meta.compileTime<UnicodeMap>('./mapping-compiletime.ts');
|
||||
const unicodeMapping = compileTime(() => {
|
||||
const require = createRequire(import.meta.url);
|
||||
const data = require('@emoji-mart/data/sets/14/twitter.json');
|
||||
|
||||
const stripLeadingZeros = /^0+/;
|
||||
|
||||
/*
|
||||
* Twemoji strips their hex codes from unicode codepoints to make it look "pretty"
|
||||
* - leading 0s are removed
|
||||
* - fe0f is removed unless it has 200d
|
||||
* - fe0f is NOT removed for 1f441-fe0f-200d-1f5e8-fe0f even though it has a 200d
|
||||
*
|
||||
* this is all wrong
|
||||
*/
|
||||
const blacklist = {
|
||||
'1f441-fe0f-200d-1f5e8-fe0f': true,
|
||||
};
|
||||
|
||||
const tweaks = {
|
||||
'#⃣': ['23-20e3', 'hash'],
|
||||
'*⃣': ['2a-20e3', 'keycap_star'],
|
||||
'0⃣': ['30-20e3', 'zero'],
|
||||
'1⃣': ['31-20e3', 'one'],
|
||||
'2⃣': ['32-20e3', 'two'],
|
||||
'3⃣': ['33-20e3', 'three'],
|
||||
'4⃣': ['34-20e3', 'four'],
|
||||
'5⃣': ['35-20e3', 'five'],
|
||||
'6⃣': ['36-20e3', 'six'],
|
||||
'7⃣': ['37-20e3', 'seven'],
|
||||
'8⃣': ['38-20e3', 'eight'],
|
||||
'9⃣': ['39-20e3', 'nine'],
|
||||
'❤🔥': ['2764-fe0f-200d-1f525', 'heart_on_fire'],
|
||||
'❤🩹': ['2764-fe0f-200d-1fa79', 'mending_heart'],
|
||||
'👁🗨️': ['1f441-fe0f-200d-1f5e8-fe0f', 'eye-in-speech-bubble'],
|
||||
'👁️🗨': ['1f441-fe0f-200d-1f5e8-fe0f', 'eye-in-speech-bubble'],
|
||||
'👁🗨': ['1f441-fe0f-200d-1f5e8-fe0f', 'eye-in-speech-bubble'],
|
||||
'🕵♂️': ['1f575-fe0f-200d-2642-fe0f', 'male-detective'],
|
||||
'🕵️♂': ['1f575-fe0f-200d-2642-fe0f', 'male-detective'],
|
||||
'🕵♂': ['1f575-fe0f-200d-2642-fe0f', 'male-detective'],
|
||||
'🕵♀️': ['1f575-fe0f-200d-2640-fe0f', 'female-detective'],
|
||||
'🕵️♀': ['1f575-fe0f-200d-2640-fe0f', 'female-detective'],
|
||||
'🕵♀': ['1f575-fe0f-200d-2640-fe0f', 'female-detective'],
|
||||
'🏌♂️': ['1f3cc-fe0f-200d-2642-fe0f', 'man-golfing'],
|
||||
'🏌️♂': ['1f3cc-fe0f-200d-2642-fe0f', 'man-golfing'],
|
||||
'🏌♂': ['1f3cc-fe0f-200d-2642-fe0f', 'man-golfing'],
|
||||
'🏌♀️': ['1f3cc-fe0f-200d-2640-fe0f', 'woman-golfing'],
|
||||
'🏌️♀': ['1f3cc-fe0f-200d-2640-fe0f', 'woman-golfing'],
|
||||
'🏌♀': ['1f3cc-fe0f-200d-2640-fe0f', 'woman-golfing'],
|
||||
'⛹♂️': ['26f9-fe0f-200d-2642-fe0f', 'man-bouncing-ball'],
|
||||
'⛹️♂': ['26f9-fe0f-200d-2642-fe0f', 'man-bouncing-ball'],
|
||||
'⛹♂': ['26f9-fe0f-200d-2642-fe0f', 'man-bouncing-ball'],
|
||||
'⛹♀️': ['26f9-fe0f-200d-2640-fe0f', 'woman-bouncing-ball'],
|
||||
'⛹️♀': ['26f9-fe0f-200d-2640-fe0f', 'woman-bouncing-ball'],
|
||||
'⛹♀': ['26f9-fe0f-200d-2640-fe0f', 'woman-bouncing-ball'],
|
||||
'🏋♂️': ['1f3cb-fe0f-200d-2642-fe0f', 'man-lifting-weights'],
|
||||
'🏋️♂': ['1f3cb-fe0f-200d-2642-fe0f', 'man-lifting-weights'],
|
||||
'🏋♂': ['1f3cb-fe0f-200d-2642-fe0f', 'man-lifting-weights'],
|
||||
'🏋♀️': ['1f3cb-fe0f-200d-2640-fe0f', 'woman-lifting-weights'],
|
||||
'🏋️♀': ['1f3cb-fe0f-200d-2640-fe0f', 'woman-lifting-weights'],
|
||||
'🏋♀': ['1f3cb-fe0f-200d-2640-fe0f', 'woman-lifting-weights'],
|
||||
'🏳🌈': ['1f3f3-fe0f-200d-1f308', 'rainbow_flag'],
|
||||
'🏳⚧️': ['1f3f3-fe0f-200d-26a7-fe0f', 'transgender_flag'],
|
||||
'🏳️⚧': ['1f3f3-fe0f-200d-26a7-fe0f', 'transgender_flag'],
|
||||
'🏳⚧': ['1f3f3-fe0f-200d-26a7-fe0f', 'transgender_flag'],
|
||||
};
|
||||
|
||||
const stripcodes = (unified: string, native: string) => {
|
||||
const stripped = unified.replace(stripLeadingZeros, '');
|
||||
|
||||
if (unified.includes('200d') && !(unified in blacklist)) {
|
||||
return stripped;
|
||||
} else {
|
||||
return stripped.replaceAll('-fe0f', '');
|
||||
}
|
||||
};
|
||||
|
||||
const generateMappings = (emojiMap: EmojiData['emojis']): UnicodeMap => {
|
||||
const result: UnicodeMap = {};
|
||||
const emojis = Object.values(emojiMap ?? {});
|
||||
|
||||
for (const value of emojis) {
|
||||
for (const item of value.skins) {
|
||||
const { unified, native } = item;
|
||||
const stripped = stripcodes(unified, native);
|
||||
|
||||
result[native] = { unified: stripped, shortcode: value.id };
|
||||
}
|
||||
}
|
||||
|
||||
for (const [native, [unified, shortcode]] of Object.entries(tweaks)) {
|
||||
const stripped = stripcodes(unified, native);
|
||||
|
||||
result[native] = { unified: stripped, shortcode };
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return generateMappings(data.emojis);
|
||||
});
|
||||
export default unicodeMapping;
|
||||
|
||||
export type { UnicodeMap };
|
||||
|
||||
@ -3,14 +3,14 @@ import IntlMessageFormat from 'intl-messageformat';
|
||||
import 'intl-pluralrules';
|
||||
import unescape from 'lodash/unescape';
|
||||
|
||||
import locales from './web-push-locales';
|
||||
|
||||
import type {
|
||||
Account as AccountEntity,
|
||||
Notification as NotificationEntity,
|
||||
Status as StatusEntity,
|
||||
} from 'pl-api';
|
||||
|
||||
const locales = import.meta.compileTime<Record<string, Record<string, string>>>('./web-push-locales.ts');
|
||||
|
||||
/** Limit before we start grouping device notifications into a single notification. */
|
||||
const MAX_NOTIFICATIONS = 5;
|
||||
/** Tag for the grouped notification. */
|
||||
|
||||
@ -1,37 +1,39 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'path';
|
||||
|
||||
const filtered: Record<string, Record<string, string>> = {};
|
||||
const filenames = fs.readdirSync(path.resolve(__dirname, '../locales'));
|
||||
const filtered = compileTime(() => {
|
||||
const filtered: Record<string, Record<string, string>> = {};
|
||||
const filenames = fs.readdirSync(path.resolve(__dirname, '../locales'));
|
||||
|
||||
filenames.forEach(filename => {
|
||||
if (!filename.match(/\.json$/) || filename.match(/defaultMessages|whitelist/)) return;
|
||||
filenames.forEach(filename => {
|
||||
if (!filename.match(/\.json$/) || filename.match(/defaultMessages|whitelist/)) return;
|
||||
|
||||
const content = fs.readFileSync(path.resolve(__dirname, `../locales/${filename}`), 'utf-8');
|
||||
const full = JSON.parse(content) as Record<string, string>;
|
||||
const locale = filename.split('.')[0];
|
||||
const content = fs.readFileSync(path.resolve(__dirname, `../locales/${filename}`), 'utf-8');
|
||||
const full = JSON.parse(content) as Record<string, string>;
|
||||
const locale = filename.split('.')[0];
|
||||
|
||||
filtered[locale] = {
|
||||
'notification.favourite': full['notification.favourite'] || '',
|
||||
'notification.follow': full['notification.follow'] || '',
|
||||
'notification.follow_request': full['notification.follow_request'] || '',
|
||||
'notification.mention': full['notification.mention'] || '',
|
||||
'notification.reblog': full['notification.reblog'] || '',
|
||||
'notification.poll': full['notification.poll'] || '',
|
||||
'notification.status': full['notification.status'] || '',
|
||||
'notification.move': full['notification.move'] || '',
|
||||
filtered[locale] = {
|
||||
'notification.favourite': full['notification.favourite'] || '',
|
||||
'notification.follow': full['notification.follow'] || '',
|
||||
'notification.follow_request': full['notification.follow_request'] || '',
|
||||
'notification.mention': full['notification.mention'] || '',
|
||||
'notification.reblog': full['notification.reblog'] || '',
|
||||
'notification.poll': full['notification.poll'] || '',
|
||||
'notification.status': full['notification.status'] || '',
|
||||
'notification.move': full['notification.move'] || '',
|
||||
|
||||
'notification.pleroma:chat_mention': full['notification.pleroma:chat_mention'] || '',
|
||||
'notification.pleroma:emoji_reaction': full['notification.pleroma:emoji_reaction'] || '',
|
||||
'notification.pleroma:chat_mention': full['notification.pleroma:chat_mention'] || '',
|
||||
'notification.pleroma:emoji_reaction': full['notification.pleroma:emoji_reaction'] || '',
|
||||
|
||||
'status.show_more': full['status.show_more'] || '',
|
||||
'status.reblog': full['status.reblog'] || '',
|
||||
'status.favourite': full['status.favourite'] || '',
|
||||
'status.show_more': full['status.show_more'] || '',
|
||||
'status.reblog': full['status.reblog'] || '',
|
||||
'status.favourite': full['status.favourite'] || '',
|
||||
|
||||
'notifications.group': full['notifications.group'] || '',
|
||||
};
|
||||
'notifications.group': full['notifications.group'] || '',
|
||||
};
|
||||
});
|
||||
|
||||
return filtered;
|
||||
});
|
||||
|
||||
export default () => ({
|
||||
data: filtered,
|
||||
});
|
||||
export default filtered;
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
import pkg from '../../package.json';
|
||||
|
||||
const { CI_COMMIT_TAG, CI_COMMIT_REF_NAME, CI_COMMIT_SHA } = process.env;
|
||||
|
||||
const shortRepoName = (url: string): string => new URL(url).pathname.substring(1);
|
||||
const trimHash = (hash: string): string => hash.substring(0, 7);
|
||||
|
||||
const tryGit = (cmd: string): string | undefined => {
|
||||
try {
|
||||
return String(execSync(cmd));
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const version = (pkg: { version: string }): string => {
|
||||
// Try to discern from GitLab CI first
|
||||
if (CI_COMMIT_TAG === `v${pkg.version}` || CI_COMMIT_REF_NAME === 'stable') {
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
if (typeof CI_COMMIT_SHA === 'string') {
|
||||
return `${pkg.version}-${trimHash(CI_COMMIT_SHA)}`;
|
||||
}
|
||||
|
||||
// Fall back to git directly
|
||||
const head = tryGit('git rev-parse HEAD');
|
||||
const tag = tryGit(`git rev-parse v${pkg.version}`);
|
||||
|
||||
if (head && head !== tag) return `${pkg.version}-${trimHash(head)}`;
|
||||
|
||||
// Fall back to version in package.json
|
||||
return pkg.version;
|
||||
};
|
||||
|
||||
const code = {
|
||||
name: pkg.name,
|
||||
displayName: pkg.displayName,
|
||||
url: pkg.repository.url,
|
||||
repository: shortRepoName(pkg.repository.url),
|
||||
version: version(pkg),
|
||||
homepage: pkg.homepage,
|
||||
ref: CI_COMMIT_TAG || CI_COMMIT_SHA || tryGit('git rev-parse HEAD'),
|
||||
};
|
||||
|
||||
export type Code = typeof code;
|
||||
|
||||
export default () => ({
|
||||
data: code,
|
||||
});
|
||||
@ -1,3 +1,54 @@
|
||||
import type { Code } from './code-compiletime';
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
export default import.meta.compileTime<Code>('./code-compiletime.ts');
|
||||
import pkg from '../../package.json';
|
||||
|
||||
const code = compileTime(() => {
|
||||
const { CI_COMMIT_TAG, CI_COMMIT_REF_NAME, CI_COMMIT_SHA } = process.env;
|
||||
|
||||
const shortRepoName = (url: string): string => new URL(url).pathname.substring(1);
|
||||
const trimHash = (hash: string): string => hash.substring(0, 7);
|
||||
|
||||
const tryGit = (cmd: string): string | undefined => {
|
||||
try {
|
||||
return String(execSync(cmd));
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const version = (pkg: { version: string }): string => {
|
||||
// Try to discern from GitLab CI first
|
||||
if (CI_COMMIT_TAG === `v${pkg.version}` || CI_COMMIT_REF_NAME === 'stable') {
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
if (typeof CI_COMMIT_SHA === 'string') {
|
||||
return `${pkg.version}-${trimHash(CI_COMMIT_SHA)}`;
|
||||
}
|
||||
|
||||
// Fall back to git directly
|
||||
const head = tryGit('git rev-parse HEAD');
|
||||
const tag = tryGit(`git rev-parse v${pkg.version}`);
|
||||
|
||||
if (head && head !== tag) return `${pkg.version}-${trimHash(head)}`;
|
||||
|
||||
// Fall back to version in package.json
|
||||
return pkg.version;
|
||||
};
|
||||
|
||||
const code = {
|
||||
name: pkg.name,
|
||||
displayName: pkg.displayName,
|
||||
url: pkg.repository.url,
|
||||
repository: shortRepoName(pkg.repository.url),
|
||||
version: version(pkg),
|
||||
homepage: pkg.homepage,
|
||||
ref: CI_COMMIT_TAG || CI_COMMIT_SHA || tryGit('git rev-parse HEAD'),
|
||||
};
|
||||
|
||||
return code;
|
||||
});
|
||||
|
||||
export type Code = typeof code;
|
||||
|
||||
export default code;
|
||||
|
||||
82
pnpm-lock.yaml
generated
82
pnpm-lock.yaml
generated
@ -280,9 +280,6 @@ importers:
|
||||
html-react-parser:
|
||||
specifier: ^5.2.11
|
||||
version: 5.2.11(@types/react@18.3.27)(react@19.2.3)
|
||||
immutable:
|
||||
specifier: ^5.0.3
|
||||
version: 5.1.3
|
||||
intersection-observer:
|
||||
specifier: ^0.12.2
|
||||
version: 0.12.2
|
||||
@ -349,9 +346,6 @@ importers:
|
||||
react-dom:
|
||||
specifier: ^19.2.3
|
||||
version: 19.2.3(react@19.2.3)
|
||||
react-error-boundary:
|
||||
specifier: ^4.1.2
|
||||
version: 4.1.2(react@19.2.3)
|
||||
react-helmet-async:
|
||||
specifier: ^2.0.5
|
||||
version: 2.0.5(react@19.2.3)
|
||||
@ -400,9 +394,6 @@ importers:
|
||||
tabbable:
|
||||
specifier: ^6.4.0
|
||||
version: 6.4.0
|
||||
tiny-queue:
|
||||
specifier: ^0.2.1
|
||||
version: 0.2.1
|
||||
use-mutative:
|
||||
specifier: ^1.3.1
|
||||
version: 1.3.1(@types/react@18.3.27)(mutative@1.3.0)(react@19.2.3)
|
||||
@ -422,9 +413,6 @@ importers:
|
||||
'@formatjs/cli':
|
||||
specifier: ^6.9.0
|
||||
version: 6.9.0(@vue/compiler-core@3.5.18)
|
||||
'@jedmao/redux-mock-store':
|
||||
specifier: ^3.0.5
|
||||
version: 3.0.5(redux@5.0.1)
|
||||
'@sentry/types':
|
||||
specifier: ^8.47.0
|
||||
version: 8.55.0
|
||||
@ -461,9 +449,6 @@ importers:
|
||||
'@types/react-swipeable-views':
|
||||
specifier: ^0.13.6
|
||||
version: 0.13.6
|
||||
'@types/redux-mock-store':
|
||||
specifier: ^1.5.0
|
||||
version: 1.5.0
|
||||
'@typescript-eslint/eslint-plugin':
|
||||
specifier: ^8.24.1
|
||||
version: 8.38.0(@typescript-eslint/parser@8.38.0(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(typescript@5.7.3)
|
||||
@ -537,8 +522,8 @@ importers:
|
||||
specifier: ^0.12.0
|
||||
version: 0.12.0(eslint@8.57.1)(meow@13.2.0)(optionator@0.9.4)(stylelint@16.23.0(typescript@5.7.3))(typescript@5.7.3)(vite@7.3.1(@types/node@25.0.3)(jiti@1.21.7)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)(yaml@2.8.0))
|
||||
vite-plugin-compile-time:
|
||||
specifier: ^0.3.2
|
||||
version: 0.3.2(vite@7.3.1(@types/node@25.0.3)(jiti@1.21.7)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)(yaml@2.8.0))
|
||||
specifier: ^0.4.6
|
||||
version: 0.4.6(vite@7.3.1(@types/node@25.0.3)(jiti@1.21.7)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)(yaml@2.8.0))
|
||||
vite-plugin-html:
|
||||
specifier: ^3.2.2
|
||||
version: 3.2.2(vite@7.3.1(@types/node@25.0.3)(jiti@1.21.7)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)(yaml@2.8.0))
|
||||
@ -1891,11 +1876,6 @@ packages:
|
||||
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
'@jedmao/redux-mock-store@3.0.5':
|
||||
resolution: {integrity: sha512-zNcVCd5/ekSMdQWk64CqTPM24D9Lo59st9KvS+fljGpQXV4SliB7Vo0NFQIgvQJWPYeeobdngnrGy0XbCaARNw==}
|
||||
peerDependencies:
|
||||
redux: ^4
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.12':
|
||||
resolution: {integrity: sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==}
|
||||
|
||||
@ -2837,9 +2817,6 @@ packages:
|
||||
peerDependencies:
|
||||
'@types/react': ^18.3.18
|
||||
|
||||
'@types/redux-mock-store@1.5.0':
|
||||
resolution: {integrity: sha512-jcscBazm6j05Hs6xYCca6psTUBbFT2wqMxT7wZEHAYFxHB/I8jYk7d5msrHUlDiSL02HdTqTmkK2oIV8i3C8DA==}
|
||||
|
||||
'@types/resolve@1.20.2':
|
||||
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
|
||||
|
||||
@ -3373,6 +3350,9 @@ packages:
|
||||
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
babel-dead-code-elimination@1.0.12:
|
||||
resolution: {integrity: sha512-GERT7L2TiYcYDtYk1IpD+ASAYXjKbLTDPhBtYj7X1NuRMDTMtAx9kyBenub1Ev41lo91OHCKdmP+egTDmfQ7Ig==}
|
||||
|
||||
babel-plugin-polyfill-corejs2@0.4.15:
|
||||
resolution: {integrity: sha512-hR3GwrRwHUfYwGfrisXPIDP3JcYfBrW7wKE7+Au6wDYl7fm/ka1NEII6kORzxNU556JjfidZeBsO10kYvtV1aw==}
|
||||
peerDependencies:
|
||||
@ -5609,11 +5589,6 @@ packages:
|
||||
peerDependencies:
|
||||
react: ^19.2.3
|
||||
|
||||
react-error-boundary@4.1.2:
|
||||
resolution: {integrity: sha512-GQDxZ5Jd+Aq/qUxbCm1UtzmL/s++V7zKgE8yMktJiCQXCCFZnMZh9ng+6/Ne6PjNSXH0L9CjeOEREfRnq6Duag==}
|
||||
peerDependencies:
|
||||
react: '>=16.13.1'
|
||||
|
||||
react-error-boundary@6.0.0:
|
||||
resolution: {integrity: sha512-gdlJjD7NWr0IfkPlaREN2d9uUZUlksrfOx7SX62VRerwXbMY6ftGCIZua1VG1aXFNOimhISsTq+Owp725b9SiA==}
|
||||
peerDependencies:
|
||||
@ -5741,9 +5716,6 @@ packages:
|
||||
peerDependencies:
|
||||
redux: ^5.0.0
|
||||
|
||||
redux@4.2.1:
|
||||
resolution: {integrity: sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==}
|
||||
|
||||
redux@5.0.1:
|
||||
resolution: {integrity: sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==}
|
||||
|
||||
@ -6427,9 +6399,6 @@ packages:
|
||||
tiny-invariant@1.3.3:
|
||||
resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==}
|
||||
|
||||
tiny-queue@0.2.1:
|
||||
resolution: {integrity: sha512-EijGsv7kzd9I9g0ByCl6h42BWNGUZrlCSejfrb3AKeHC33SGbASu1VDf5O3rRiiUOhAC9CHdZxFPbZu0HmR70A==}
|
||||
|
||||
tiny-warning@1.0.3:
|
||||
resolution: {integrity: sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==}
|
||||
|
||||
@ -6689,8 +6658,8 @@ packages:
|
||||
vue-tsc:
|
||||
optional: true
|
||||
|
||||
vite-plugin-compile-time@0.3.2:
|
||||
resolution: {integrity: sha512-obNDktew663JQlriX5MJV/l2e8ofPzr1yfZBq0erjIxMuwmmnEfT7SYBGfcb/Y35u17nzQqsAvCvqbsxpbmvwQ==}
|
||||
vite-plugin-compile-time@0.4.6:
|
||||
resolution: {integrity: sha512-0aHRCd3AtDekc5pMq5+cyrVqBPVjT8bISD1/EU3ebJDovZsv3Wom6uDF4+Uf1zxUTfn27gHFSFQ11R3ciqPg7g==}
|
||||
peerDependencies:
|
||||
vite: '>=2'
|
||||
|
||||
@ -8276,10 +8245,6 @@ snapshots:
|
||||
wrap-ansi: 8.1.0
|
||||
wrap-ansi-cjs: wrap-ansi@7.0.0
|
||||
|
||||
'@jedmao/redux-mock-store@3.0.5(redux@5.0.1)':
|
||||
dependencies:
|
||||
redux: 5.0.1
|
||||
|
||||
'@jridgewell/gen-mapping@0.3.12':
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.4
|
||||
@ -9356,10 +9321,6 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/react': 18.3.27
|
||||
|
||||
'@types/redux-mock-store@1.5.0':
|
||||
dependencies:
|
||||
redux: 4.2.1
|
||||
|
||||
'@types/resolve@1.20.2': {}
|
||||
|
||||
'@types/semver@7.7.0': {}
|
||||
@ -10059,6 +10020,15 @@ snapshots:
|
||||
|
||||
axobject-query@4.1.0: {}
|
||||
|
||||
babel-dead-code-elimination@1.0.12:
|
||||
dependencies:
|
||||
'@babel/core': 7.29.0
|
||||
'@babel/parser': 7.29.0
|
||||
'@babel/traverse': 7.29.0
|
||||
'@babel/types': 7.29.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
babel-plugin-polyfill-corejs2@0.4.15(@babel/core@7.29.0):
|
||||
dependencies:
|
||||
'@babel/compat-data': 7.29.0
|
||||
@ -12573,11 +12543,6 @@ snapshots:
|
||||
react: 19.2.3
|
||||
scheduler: 0.27.0
|
||||
|
||||
react-error-boundary@4.1.2(react@19.2.3):
|
||||
dependencies:
|
||||
'@babel/runtime': 7.28.2
|
||||
react: 19.2.3
|
||||
|
||||
react-error-boundary@6.0.0(react@19.2.3):
|
||||
dependencies:
|
||||
'@babel/runtime': 7.28.6
|
||||
@ -12709,10 +12674,6 @@ snapshots:
|
||||
dependencies:
|
||||
redux: 5.0.1
|
||||
|
||||
redux@4.2.1:
|
||||
dependencies:
|
||||
'@babel/runtime': 7.28.2
|
||||
|
||||
redux@5.0.1: {}
|
||||
|
||||
reflect.getprototypeof@1.0.10:
|
||||
@ -13503,8 +13464,6 @@ snapshots:
|
||||
|
||||
tiny-invariant@1.3.3: {}
|
||||
|
||||
tiny-queue@0.2.1: {}
|
||||
|
||||
tiny-warning@1.0.3: {}
|
||||
|
||||
tinycolor2@1.6.0: {}
|
||||
@ -13762,13 +13721,20 @@ snapshots:
|
||||
stylelint: 16.23.0(typescript@5.7.3)
|
||||
typescript: 5.7.3
|
||||
|
||||
vite-plugin-compile-time@0.3.2(vite@7.3.1(@types/node@25.0.3)(jiti@1.21.7)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)(yaml@2.8.0)):
|
||||
vite-plugin-compile-time@0.4.6(vite@7.3.1(@types/node@25.0.3)(jiti@1.21.7)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)(yaml@2.8.0)):
|
||||
dependencies:
|
||||
'@babel/generator': 7.29.1
|
||||
'@babel/parser': 7.29.0
|
||||
'@babel/traverse': 7.29.0
|
||||
'@babel/types': 7.29.0
|
||||
babel-dead-code-elimination: 1.0.12
|
||||
bundle-require: 5.1.0(esbuild@0.24.2)
|
||||
devalue: 5.1.1
|
||||
esbuild: 0.24.2
|
||||
magic-string: 0.30.17
|
||||
vite: 7.3.1(@types/node@25.0.3)(jiti@1.21.7)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)(yaml@2.8.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
vite-plugin-dts@4.5.4(@types/node@20.19.9)(rollup@4.57.1)(typescript@5.9.2)(vite@5.4.21(@types/node@20.19.9)(sass-embedded@1.93.3)(sass@1.93.3)(terser@5.46.0)):
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user