Skip to content

Commit

Permalink
move static assets to /public so the paths work same in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamNowotny committed Aug 29, 2024
1 parent dcb804f commit db7bc1f
Show file tree
Hide file tree
Showing 37 changed files with 44 additions and 46 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
28 changes: 14 additions & 14 deletions src/common/__mocks__/core.mock.serviceTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export default [
{
typeName: 'Atlassian Bamboo',
baseUrl: 'bamboo',
icon: 'services/bamboo/icon.png',
logo: 'services/bamboo/logo.png',
icon: 'bamboo.png',
logo: 'bamboo.png',
fields: [
{
type: 'url',
Expand All @@ -23,8 +23,8 @@ export default [
{
typeName: 'BuildBot',
baseUrl: 'buildbot',
icon: 'services/buildbot/icon.png',
logo: 'services/buildbot/logo.png',
icon: 'buildbot.png',
logo: 'buildbot.png',
fields: [
{ type: 'url', name: 'Server URL, e.g. https://build.webkit.org/' },
{ type: 'username' },
Expand All @@ -42,8 +42,8 @@ export default [
{
typeName: 'BuildKite',
baseUrl: 'buildkite',
icon: 'services/buildkite/icon.png',
logo: 'services/buildkite/logo.svg',
icon: 'buildkite.png',
logo: 'buildkite.svg',
fields: [
{
type: 'token',
Expand All @@ -62,8 +62,8 @@ export default [
{
typeName: 'CCTray XML',
baseUrl: 'cctray',
icon: 'services/cctray/icon.png',
logo: 'services/cctray/logo.png',
icon: 'cctray.png',
logo: 'cctray.png',
defaultConfig: {
baseUrl: 'cctray',
name: '',
Expand All @@ -85,8 +85,8 @@ export default [
{
typeName: 'GitHub Actions',
baseUrl: 'github',
icon: 'services/github/icon.png',
logo: 'services/github/logo.svg',
icon: 'github.png',
logo: 'github.svg',
fields: [
{
type: 'url',
Expand All @@ -109,8 +109,8 @@ export default [
{
typeName: 'Jenkins',
baseUrl: 'jenkins',
icon: 'services/jenkins/icon.png',
logo: 'services/jenkins/logo.png',
icon: 'jenkins.png',
logo: 'jenkins.png',
fields: [
{
type: 'url',
Expand All @@ -131,8 +131,8 @@ export default [
{
typeName: 'TeamCity',
baseUrl: 'teamcity',
icon: 'services/teamcity/icon.png',
logo: 'services/teamcity/logo.png',
icon: 'teamcity.png',
logo: 'teamcity.png',
fields: [
{ type: 'url', name: 'Server URL, e.g. http://teamcity.jetbrains.com/' },
{ type: 'username' },
Expand Down
2 changes: 1 addition & 1 deletion src/options/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default ({ service, view }: { service?: CIServiceSettings; view?: string

const getIconFor = (baseUrl): string => {
const item = serviceTypes.find(serviceType => serviceType.baseUrl === baseUrl);
return item ? `/${item.icon}` : '';
return item ? `/icons/${item.icon}` : '';
};
// TODO: sortable
return (
Expand Down
5 changes: 4 additions & 1 deletion src/options/pages/add/components/serviceThumbnails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default ({
}}
>
<div className="thumbnail-image">
<img src={`/${serviceType.logo}`} alt={serviceType.typeName} />
<img
src={`/logos/${serviceType.logo}`}
alt={serviceType.typeName}
/>
</div>
<div className="caption">{serviceType.typeName}</div>
</a>
Expand Down
8 changes: 5 additions & 3 deletions src/service-worker/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ describe('show', () => {
});

it('adds iconUrl', async () => {
mockChrome.runtime.getURL.mockImplementation(icon => `https://google.com/${icon}`);
mockChrome.runtime.getURL.mockImplementation(
icon => `chrome-extension://BR${icon}`,
);

await notification.show(testInfo);

expect(mockChrome.runtime.getURL).toBeCalledWith(`services/baseUrl/icon.png`);
expect(mockChrome.runtime.getURL).toBeCalledWith(`/icons/baseUrl.png`);
expect(mockChrome.notifications.create).toBeCalledWith(
testInfo.id,
expect.objectContaining({
iconUrl: `https://google.com/services/baseUrl/icon.png`,
iconUrl: `chrome-extension://BR/icons/baseUrl.png`,
}),
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/service-worker/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function getIcon(info: NotificationInfo) {
const service = await serviceConfig.getItem(info.serviceName);
if (!service) throw new Error(`Service ${info.serviceName} not found`);
const serviceType = service.baseUrl;
const icon = chrome.runtime.getURL(`services/${serviceType}/icon.png`);
const icon = chrome.runtime.getURL(`/icons/${serviceType}.png`);
return icon;
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/bamboo/bamboo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default {
getDefinition: (): CIServiceDefinition => ({
typeName: 'Atlassian Bamboo',
baseUrl: 'bamboo',
icon: 'services/bamboo/icon.png',
logo: 'services/bamboo/logo.png',
icon: 'bamboo.png',
logo: 'bamboo.png',
fields: [
{
type: 'url',
Expand Down
4 changes: 2 additions & 2 deletions src/services/buildbot/buildbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export default {
getDefinition: () => ({
typeName: 'BuildBot',
baseUrl: 'buildbot',
icon: 'services/buildbot/icon.png',
logo: 'services/buildbot/logo.png',
icon: 'buildbot.png',
logo: 'buildbot.png',
fields: [
{ type: 'url', name: 'Server URL, e.g. https://build.webkit.org/' },
{ type: 'username' },
Expand Down
4 changes: 2 additions & 2 deletions src/services/buildkite/buildkite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export default {
getDefinition: (): CIServiceDefinition => ({
typeName: 'BuildKite',
baseUrl: 'buildkite',
icon: 'services/buildkite/icon.png',
logo: 'services/buildkite/logo.svg',
icon: 'buildkite.png',
logo: 'buildkite.svg',
fields: [
{
type: 'token',
Expand Down
4 changes: 2 additions & 2 deletions src/services/cctray/cctray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default {
getDefinition: (): CIServiceDefinition => ({
typeName: 'CCTray XML',
baseUrl: 'cctray',
icon: 'services/cctray/icon.png',
logo: 'services/cctray/logo.png',
icon: 'cctray.png',
logo: 'cctray.png',
defaultConfig: {
baseUrl: 'cctray',
name: '',
Expand Down
4 changes: 2 additions & 2 deletions src/services/github/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export default {
getDefinition: (): CIServiceDefinition => ({
typeName: 'GitHub Actions',
baseUrl: 'github',
icon: 'services/github/icon.png',
logo: 'services/github/logo.svg',
icon: 'github.png',
logo: 'github.svg',
fields: [
{
type: 'url',
Expand Down
4 changes: 2 additions & 2 deletions src/services/jenkins/jenkins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export default {
return {
typeName: 'Jenkins',
baseUrl: 'jenkins',
icon: 'services/jenkins/icon.png',
logo: 'services/jenkins/logo.png',
icon: 'jenkins.png',
logo: 'jenkins.png',
fields: [
{
type: 'url',
Expand Down
4 changes: 2 additions & 2 deletions src/services/teamcity/teamcity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export default {
getDefinition: (): CIServiceDefinition => ({
typeName: 'TeamCity',
baseUrl: 'teamcity',
icon: 'services/teamcity/icon.png',
logo: 'services/teamcity/logo.png',
icon: 'teamcity.png',
logo: 'teamcity.png',
fields: [
{ type: 'url', name: 'Server URL, e.g. http://teamcity.jetbrains.com/' },
{ type: 'username' },
Expand Down
4 changes: 2 additions & 2 deletions src/services/travis/travis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export default {
getDefinition: (): CIServiceDefinition => ({
typeName: 'Travis',
baseUrl: 'travis',
icon: 'services/travis/icon.png',
logo: 'services/travis/logo.png',
icon: 'travis.png',
logo: 'travis.png',
fields: [
{
type: 'url',
Expand Down
13 changes: 3 additions & 10 deletions vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ export default defineConfig({
react(),
copy({
flatten: false,
targets: [
{
src: ['src/services/**/*.png', 'src/services/**/*.svg'],
dest: 'dist/build/',
},
{ src: 'img/*', dest: 'dist/build/img/' },
{ src: 'manifest.json', dest: 'dist/build/' },
],
targets: [{ src: 'manifest.json', dest: 'dist/build/' }],
}),
tsconfigPaths(),
zipPack({
Expand All @@ -33,7 +26,7 @@ export default defineConfig({
],
build: {
assetsInlineLimit: 0,
emptyOutDir: false,
emptyOutDir: true,
sourcemap: true,
minify: true,
rollupOptions: {
Expand All @@ -48,7 +41,7 @@ export default defineConfig({
format: 'es',
entryFileNames: '[name].js',
chunkFileNames: '[name]-chunk.js',
assetFileNames: '[name].[ext]',
assetFileNames: 'assets/[name].[ext]',
},
},
},
Expand Down

0 comments on commit db7bc1f

Please sign in to comment.