Skip to content

Commit 4c20853

Browse files
committed
(#405) Support Astro Framework
The changes here are needed in order to support the Astro framework. A few styles were updated, but the majority of the changes are in the build process and some updates to converted markdown inside code blocks. All existing choco-theme commands still work and are ran the same way from the command line, except now when running anything with `--docs` it will run Astro commands instead of a preview.sh or preview.ps1 file.
1 parent 630dbbc commit 4c20853

File tree

83 files changed

+2120
-887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2120
-887
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"cSpell.words": [
3+
"astro",
34
"atcb",
45
"blockquotes",
56
"bluesky",
@@ -41,6 +42,7 @@
4142
"socialmedia",
4243
"splide",
4344
"splidejs",
45+
"Statiq",
4446
"stylelint",
4547
"stylelintcache",
4648
"svgstyles",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Chocolatey choco-theme 0.7.0
1+
# Chocolatey choco-theme 0.7.1
22

33
**NOTE: This project is used on Chocolatey websites and is being released for the benefit of the community. While we endeavour to help and fix issues, it will be limited to GitHub issues, discussions and pull requests when we are able to.**
44

build/build-partials.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const init = async () => {
5858
const destinationTemp = './dist/partials/temp';
5959
const destinationCshtml = './dist/partials/cshtml';
6060
const destinationHbs = './dist/partials/hbs';
61+
const destinationAstro = './dist/partials/astro';
6162

6263
await fs.cp('./partials/', destinationTemp, { recursive: true });
6364

@@ -73,6 +74,7 @@ const init = async () => {
7374

7475
await fs.cp(destinationTemp, destinationCshtml, { recursive: true });
7576
await fs.cp(destinationTemp, destinationHbs, { recursive: true });
77+
await fs.cp(destinationTemp, destinationAstro, { recursive: true });
7678
await fs.rm(destinationTemp, { recursive: true });
7779

7880
// hbs files
@@ -87,6 +89,7 @@ const init = async () => {
8789

8890
// Delete TopAlertBanner.html
8991
await fs.rm(path.join(destinationHbs, 'TopAlertBanner.html'));
92+
await fs.rm(path.join(destinationAstro, 'TopAlertBanner.html'));
9093

9194
// cshtml files
9295
await updateContent({
@@ -102,10 +105,12 @@ const init = async () => {
102105
// Delete AlertText.html
103106
await fs.rm(path.join(destinationHbs, 'AlertText.html'));
104107
await fs.rm(path.join(destinationCshtml, 'AlertText.html'));
108+
await fs.rm(path.join(destinationAstro, 'AlertText.html'));
105109

106110
// Update file extensions and casing of names
107111
const filesHbs = await fs.readdir(destinationHbs);
108112
const filesCshtml = await fs.readdir(destinationCshtml);
113+
const filesAstro = await fs.readdir(destinationAstro);
109114

110115
await updateLanguageAttributes({
111116
files: filesHbs,
@@ -119,6 +124,12 @@ const init = async () => {
119124
newExt: '.cshtml'
120125
});
121126

127+
await updateLanguageAttributes({
128+
files: filesAstro,
129+
destination: destinationAstro,
130+
newExt: '.astro'
131+
});
132+
122133
console.log('✅ Partials built');
123134
} catch (error) {
124135
console.error(error);

build/choco-theme.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,16 @@ const init = async () => {
149149
if (repository.playwright) {
150150
parallelTasksInitial.push(
151151
{
152-
task: 'playwright.config.ts',
153-
source: `${repositoryConfig.theme.root}playwright.config.ts`,
154-
destination: `${repository.root}playwright.config.ts`,
155-
isFolder: false
152+
task: 'Playwright tests - general',
153+
source: `${repositoryConfig.theme.playwright}tests/general/`,
154+
destination: `${repository.playwright}general/`
156155
}
157156
);
158157

159158
if (repository.name === repositoryConfig.org.name) {
160159
parallelTasksInitial.push(
161160
{
162-
task: 'Playwright tests',
161+
task: 'Playwright tests - pricing calculator',
163162
source: `${repositoryConfig.theme.playwright}tests/pricing-calculator/`,
164163
destination: `${repository.playwright}pricing-calculator/`
165164
}
@@ -201,7 +200,7 @@ const init = async () => {
201200
}
202201

203202
// ESLint and tsconfig - needed if repository contains it's own assets along with choco-theme
204-
if (repository.playwright || repository.name === repositoryConfig.portal.name) {
203+
if (repository.name === repositoryConfig.portal.name) {
205204
parallelTasksInitial.push(
206205
{
207206
task: '.eslintrc.js',
@@ -255,7 +254,7 @@ const init = async () => {
255254

256255
// Change CSS content
257256
// Font Awesome
258-
if (repository.name === repositoryConfig.portal.name) {
257+
if (repository.name === repositoryConfig.portal.name || repository.language === 'astro') {
259258
console.log('🚀 Updating Font Awesome font path...');
260259
await updateContent({
261260
destination: repository.css,

build/data/playwright-config.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env ts-node
2+
3+
/*!
4+
* Configuration for repositories to use a shared Playwright config.
5+
* Copyright 2020-2024 Chocolatey Software
6+
* Licensed under Apache License (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
7+
*/
8+
9+
import type { PlaywrightTestConfig } from '@playwright/test';
10+
11+
export const playwrightConfig: PlaywrightTestConfig = {
12+
testDir: './src/tests',
13+
/* Run tests in files in parallel */
14+
fullyParallel: true,
15+
/* Fail the build on CI if you accidentally left test.only in the source code. */
16+
forbidOnly: !!process.env.CI,
17+
/* Retry on CI only */
18+
retries: process.env.CI ? 2 : 0,
19+
/* Opt out of parallel tests on CI. */
20+
workers: process.env.CI ? 1 : undefined,
21+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
22+
reporter: 'html',
23+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
24+
use: {
25+
/* Base URL to use in actions like `await page.goto('/')`. */
26+
baseURL: '',
27+
28+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
29+
trace: 'on-first-retry'
30+
},
31+
webServer: {
32+
command: 'yarn preview',
33+
timeout: 120 * 1000,
34+
reuseExistingServer: !process.env.CI,
35+
url: ''
36+
}
37+
};

build/data/preview-config.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export interface FolderMapping {
1111
folder: string;
1212
protocol?: string;
1313
port?: null | number;
14-
isStatic: boolean;
14+
isStatiq: boolean;
15+
isAstro: boolean;
1516
root?: string
1617
};
1718
}
@@ -20,48 +21,57 @@ export const folderMapping: FolderMapping = {
2021
'--blog': {
2122
folder: 'blog',
2223
port: 5082,
23-
isStatic: true
24+
isStatiq: true,
25+
isAstro: false
2426
},
2527
'--boxstarter': {
2628
folder: 'boxstarter.org',
2729
port: 5083,
28-
isStatic: true
30+
isStatiq: true,
31+
isAstro: false
2932
},
3033
'--community': {
3134
folder: 'community.chocolatey.org',
3235
port: 55881,
33-
isStatic: false,
36+
isStatiq: false,
37+
isAstro: false,
3438
root: '/chocolatey/Website'
3539
},
3640
'--design': {
3741
folder: 'choco-design-system',
3842
port: 5085,
39-
isStatic: true
43+
isStatiq: true,
44+
isAstro: false
4045
},
4146
'--docs': {
4247
folder: 'docs',
4348
port: 5086,
44-
isStatic: true
49+
isStatiq: false,
50+
isAstro: true
4551
},
4652
'--fest': {
4753
folder: 'chocolateyfest',
4854
port: 5084,
49-
isStatic: true
55+
isStatiq: true,
56+
isAstro: false
5057
},
5158
'--org': {
5259
folder: 'chocolatey.org',
5360
port: 5081,
54-
isStatic: true
61+
isStatiq: true,
62+
isAstro: false
5563
},
5664
'--portal': {
5765
folder: 'licensing-services',
5866
protocol: 'https',
5967
port: 44362,
60-
isStatic: false,
68+
isStatiq: false,
69+
isAstro: false,
6170
root: '/source/LicensingServices'
6271
},
6372
'--zendesk': {
6473
folder: 'copenhagen_theme',
65-
isStatic: false
74+
isStatiq: false,
75+
isAstro: false
6676
}
6777
};

build/data/repository-config.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,38 @@ export const defaultRepositoryConfig = {
4646
/^fa-(check|triangle-exclamation|info|xmark)/,
4747
/^text-bg-(info|warning|danger|success)/,
4848
/^data-bs-popper/
49+
]
50+
},
51+
root: './'
52+
};
4953

54+
export const astroRepositoryConfig = {
55+
css: 'public/styles/',
56+
js: 'public/scripts/',
57+
favicons: 'public/',
58+
fontAwesome: 'public/fonts/fontawesome-free/',
59+
images: 'public/images/global-shared/',
60+
partials: 'src/components/global/',
61+
language: 'astro',
62+
purgeCss: {
63+
content: [
64+
'src/**/*.astro',
65+
'src/**/*.html',
66+
'src/**/*.txt',
67+
'src/**/*.md',
68+
'src/**/*.mdx',
69+
'src/**/*.js',
70+
'src/**/*.ts',
71+
'public/**/*.js'
72+
],
73+
safelist: [
74+
'::-webkit-scrollbar',
75+
'::-webkit-scrollbar-thumb',
76+
/^fa-(check|triangle-exclamation|info|xmark)/,
77+
/^text-bg-(info|warning|danger|success)/,
78+
/^data-bs-popper/,
79+
/^ratio-/,
80+
/^callout-/
5081
]
5182
},
5283
root: './'
@@ -77,8 +108,9 @@ export const repositoryConfig: Record<string, RepositoryConfig> = {
77108
name: 'design'
78109
},
79110
docs: {
80-
...defaultRepositoryConfig,
81-
name: 'docs'
111+
...astroRepositoryConfig,
112+
name: 'docs',
113+
playwright: 'src/tests/'
82114
},
83115
fest: {
84116
...defaultRepositoryConfig,

build/esbuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const init = async () => {
1313
const minify = process.argv.includes('--minify');
1414

1515
const banner: string = `/*!
16-
* choco-theme v0.7.0 (https://github.com/chocolatey/choco-theme#readme)
16+
* choco-theme v0.7.1 (https://github.com/chocolatey/choco-theme#readme)
1717
* Copyright 2020-2024 Chocolatey Software
1818
* Licensed under MIT (https://github.com/chocolatey/choco-theme/blob/main/LICENSE)
1919
*/`;

0 commit comments

Comments
 (0)