Skip to content

Commit

Permalink
Add Banners
Browse files Browse the repository at this point in the history
  • Loading branch information
st3phhays committed Jun 26, 2024
1 parent 368fc0f commit 02ea590
Show file tree
Hide file tree
Showing 63 changed files with 24,914 additions and 1,189 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"datatables",
"Disqus",
"DOCSEARCH",
"dompurify",
"dropoverlay",
"easymde",
"favicons",
Expand All @@ -31,6 +32,7 @@
"Luxon",
"Navbars",
"navigations",
"nodenext",
"nouislider",
"offcanvas",
"outdir",
Expand Down
20 changes: 0 additions & 20 deletions build/build-partials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,6 @@ const init = async () => {
replacementContentIsFile: false
});

// Delete TopAlertBanner.html
await fs.rm(path.join(destinationHbs, 'TopAlertBanner.html'));
await fs.rm(path.join(destinationAstro, 'TopAlertBanner.html'));

// cshtml files
await updateContent({
destination: destinationCshtml,
targetFile: 'TopAlertBanner.html',
targetFileDestination: destinationCshtml,
targetFileContentToReplace: 'topNoticeText = ""',
replaceWithContent: 'AlertText.html',
replacementContentIsFile: true,
replacementTemplate: 'topNoticeText = "{0}"'
});

// Delete AlertText.html
await fs.rm(path.join(destinationHbs, 'AlertText.html'));
await fs.rm(path.join(destinationCshtml, 'AlertText.html'));
await fs.rm(path.join(destinationAstro, 'AlertText.html'));

// Update file extensions and casing of names
const filesHbs = await fs.readdir(destinationHbs);
const filesCshtml = await fs.readdir(destinationCshtml);
Expand Down
11 changes: 5 additions & 6 deletions build/build-portal.ts → build/build-repository.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/usr/bin/env ts-node

/*!
* Script to build additional assets for portal.
* Script to build additional assets for a repository.
* Copyright 2020-2024 Chocolatey Software
* Licensed under Apache License (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
*/

import * as esbuild from 'esbuild';
import { purgeCss } from './functions/purge-css';
import { repositoryConfig } from './data/repository-config';
import { repository } from './functions/determine-repository';

const init = async () => {
console.log('🚀 Compiling and minifying Portal JS...');
const repository = repositoryConfig.portal;
console.log('🚀 Compiling and minifying repository JS...');

await esbuild.build({
entryPoints: [`${repository.js}src/*.js`],
entryPoints: [`${repository.js}src/banners/*.js`],
target: 'es2015',
bundle: true,
outdir: repository.js,
minify: true,
outExtension: { '.js': '.min.js' }
}).then(async () => {
console.log('✅ Portal JS compiled and minified');
console.log('✅ Repository JS compiled and minified');

// PurgeCSS
await purgeCss({
Expand Down
29 changes: 9 additions & 20 deletions build/choco-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,12 @@
*/

import * as fs from 'fs/promises';
import * as process from 'process';
import { repository } from './functions/determine-repository';
import { repositoryConfig } from './data/repository-config';
import { purgeCss } from './functions/purge-css';
import { updateContent } from './functions/update-content';

// Process args
const params: Record<string, string> = {};
process.argv.slice(2).forEach(val => {
const [key, value] = val.split('=');

if (key.startsWith('--')) {
params[key.slice(2)] = value;
}
});

// Determine repository information
let repository = repositoryConfig.default;
if (params.repository && repositoryConfig[params.repository]) {
repository = repositoryConfig[params.repository];
console.log('Using repository information:', repository);
}
console.log('Using repository information:', repository);

// Determine source CSS name
let sourceCss: string;
Expand Down Expand Up @@ -67,7 +52,7 @@ const copyTheme = async ({

const init = async () => {
try {
const containsValidation = repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.community.name;
const containsValidation = repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.community.name || repository.name === repositoryConfig.hub.name;

// Define arrays for parallel tasks
const parallelTasksInitial = [
Expand Down Expand Up @@ -200,7 +185,11 @@ const init = async () => {
}

// ESLint and tsconfig - needed if repository contains it's own assets along with choco-theme
<<<<<<< HEAD
if (repository.name === repositoryConfig.portal.name) {
=======
if (repository.playwright || repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.hub.name) {
>>>>>>> 51c1e20 (Add Banners)
parallelTasksInitial.push(
{
task: '.eslintrc.js',
Expand Down Expand Up @@ -254,7 +243,7 @@ const init = async () => {

// Change CSS content
// Font Awesome
if (repository.name === repositoryConfig.portal.name || repository.language === 'astro') {
if (repository.name === repositoryConfig.portal.name || repository.name === repositoryConfig.hub.name || repository.language === 'astro') {
console.log('🚀 Updating Font Awesome font path...');
await updateContent({
destination: repository.css,
Expand Down Expand Up @@ -294,7 +283,7 @@ const init = async () => {
}

// PurgeCSS
if (repository.name !== repositoryConfig.portal.name) {
if (repository.name !== repositoryConfig.portal.name && repository.name !== repositoryConfig.hub.name) {
await purgeCss({
source: `${repository.css}${repository.name}.min.css`,
repository: repository
Expand Down
8 changes: 8 additions & 0 deletions build/data/preview-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export const folderMapping: FolderMapping = {
isStatiq: true,
isAstro: false
},
'--hub': {
folder: 'admin-portal',
protocol: 'https',
port: 44362,
isStatiq: false,
isAstro: false,
root: '/source/AdminPortal'
},
'--org': {
folder: 'chocolatey.org',
port: 5081,
Expand Down
43 changes: 43 additions & 0 deletions build/data/repository-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const defaultRepositoryConfig = {
'::-webkit-scrollbar-thumb',
/^fa-(check|triangle-exclamation|info|xmark)/,
/^text-bg-(info|warning|danger|success)/,
/^text-bg-(blue|pink|purple|green|red|yellow|orange)/,
/^alert-(blue|pink|purple|green|red|yellow|orange)/,
/^data-bs-popper/
]
},
Expand Down Expand Up @@ -77,10 +79,25 @@ export const astroRepositoryConfig = {
'::-webkit-scrollbar-thumb',
/^fa-(check|triangle-exclamation|info|xmark)/,
/^text-bg-(info|warning|danger|success)/,
<<<<<<< HEAD
=======
<<<<<<< HEAD
<<<<<<< HEAD
>>>>>>> 57a58db (Add Banners)
/^data-bs-popper/,
/^ratio-/,
/^callout-/,
/^btn-(primary|danger|success)/
<<<<<<< HEAD
=======
=======
=======
/^text-bg-(blue|pink|purple|green|red|yellow|orange)/,
/^alert-(blue|pink|purple|green|red|yellow|orange)/,
>>>>>>> 51c1e20 (Add Banners)
/^data-bs-popper/
>>>>>>> bff5039 ((#405) Support Astro Framework)
>>>>>>> 57a58db (Add Banners)
]
},
root: './'
Expand Down Expand Up @@ -119,6 +136,16 @@ export const repositoryConfig: Record<string, RepositoryConfig> = {
...defaultRepositoryConfig,
name: 'fest'
},
hub: {
...defaultRepositoryConfig,
name: 'hub',
favicons: 'wwwroot/',
css: 'wwwroot/css/',
js: 'wwwroot/js/',
fontAwesome: 'wwwroot/fonts/fontawesome-free/',
images: 'wwwroot/images/global-shared/',
partials: 'Pages/Global/'
},
org: {
...defaultRepositoryConfig,
name: 'org',
Expand Down Expand Up @@ -186,6 +213,22 @@ repositoryConfig.community.purgeCss = {
]
};

// Merge purgeCss section into the hub configuration
repositoryConfig.hub.purgeCss = {
content: [
`${repositoryConfig.hub.js}*.js`,
'Areas/**/*.cshtml',
'Pages/**/*.cshtml'
],
safelist: [
...defaultRepositoryConfig.purgeCss.safelist,
/^bg-(secondary|danger|success)/,
/^callout-(danger|success)/,
/^form-check-input-(blue|pink|purple|green|red|yellow|orange)/,
/^spinner-grow/
]
};

// Merge purgeCss section into the org configuration
repositoryConfig.org.purgeCss = {
content: [
Expand Down
28 changes: 28 additions & 0 deletions build/functions/determine-repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env ts-node

/*!
* Determines the repository to use based on the provided parameters.
* Copyright 2020-2024 Chocolatey Software
* Licensed under Apache License (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
*/

import * as process from 'process';
import { repositoryConfig } from '../data/repository-config';

// Process args
const params: Record<string, string> = {};
process.argv.slice(2).forEach(val => {
const [key, value] = val.split('=');

if (key.startsWith('--')) {
params[key.slice(2)] = value;
}
});

// Determine repository information
let repository = repositoryConfig.default;
if (params.repository && repositoryConfig[params.repository]) {
repository = repositoryConfig[params.repository];
}

export { repository };
Loading

0 comments on commit 02ea590

Please sign in to comment.