Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/all-tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
"color": "bg-[#E1224E]",
"borderColor": "border-[#B9012b]"
},
{
"name": "FastAPI",
"color": "bg-[#61d0f2]",
"borderColor": "border-[#40ccf7]"
},
{
"name": "Django",
"color": "bg-[#61d0f2]",
"borderColor": "border-[#40ccf7]"
},
{
"name": "Socket.IO",
"color": "bg-[#61d0f2]",
Expand Down
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ const config = {
'scripts/tools/tags-color.ts',
'scripts/helpers/logger.ts'
],
// Default: all tests
// Default: all tests except integration
testMatch: [
'**/tests/**/*.test.*',
'**/npm/integrationTests/**/*.test.*',
'!**/netlify/**/*.test.*'
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
Expand Down
24 changes: 12 additions & 12 deletions npm/runners/build-dashboard-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CustomError } from '@/types/errors/CustomError';
const currentFilePath = fileURLToPath(import.meta.url);
const currentDirPath = dirname(currentFilePath);

interface BuildDashboardOptions {
export interface BuildDashboardOptions {
outputPath?: string;
}

Expand All @@ -22,7 +22,7 @@ interface BuildDashboardOptions {
* @param options - Optional configuration for output path
* @throws {CustomError} If the build process fails or an error occurs in the runner
*/
async function runBuildDashboard(options: BuildDashboardOptions = {}): Promise<void> {
export async function runBuildDashboard(options: BuildDashboardOptions = {}): Promise<void> {
try {
const outputPath = options.outputPath || resolve(currentDirPath, '../../dashboard.json');

Expand All @@ -48,20 +48,20 @@ async function runBuildDashboard(options: BuildDashboardOptions = {}): Promise<v
}
}

// Run only in non-test environments
if (process.env.NODE_ENV === 'test') {
logger.info('Skipping dashboard build in test environment');
} else {
// Self-executing async function to handle top-level await
// Only run CLI if this file is executed directly, not when imported
if (import.meta.url === `file://${process.argv[1]}`) {
(async () => {
try {
await runBuildDashboard();
// Extract output file path from CLI args
const outputFileArgIndex = process.argv.indexOf('--outputFile');
const outputPath =
outputFileArgIndex === -1
? resolve(currentDirPath, '../../dashboard.json')
: process.argv[outputFileArgIndex + 1];

await runBuildDashboard({ outputPath });
} catch (error) {
// Ensure we exit with error code
process.exit(1);
}
})();
}

// Export for testing purposes
export { runBuildDashboard };
8 changes: 3 additions & 5 deletions npm/runners/build-pages-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { copyAndRenameFiles, ensureDirectoryExists } from '@/scripts/build-pages
import { logger } from '@/scripts/helpers/logger';
import { CustomError } from '@/types/errors/CustomError';

interface BuildPagesOptions {
export interface BuildPagesOptions {
sourceDir?: string;
targetDir?: string;
}
Expand Down Expand Up @@ -44,10 +44,8 @@ async function runBuildPages(options: BuildPagesOptions = {}): Promise<void> {
}
}

// Run only in non-test environments
if (process.env.NODE_ENV === 'test') {
logger.info('Skipping pages build in test environment');
} else {
// Only run CLI if this file is executed directly, not when imported
if (import.meta.url === `file://${process.argv[1]}`) {
// Self-executing async function to handle top-level await
(async () => {
try {
Expand Down
41 changes: 30 additions & 11 deletions npm/runners/build-post-list-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CustomError } from '@/types/errors/CustomError';
const currentFilePath = fileURLToPath(import.meta.url);
const currentDirPath = dirname(currentFilePath);

interface BuildPostListOptions {
export interface BuildPostListOptions {
postDirectories?: string[][];
basePath?: string;
outputPath?: string;
Expand All @@ -25,7 +25,7 @@ interface BuildPostListOptions {
* @param options - Optional configuration for post directories, base path, and output path.
* @throws {CustomError} If the build process fails or an error occurs in the runner.
*/
async function runBuildPostList(options: BuildPostListOptions = {}): Promise<void> {
export async function runBuildPostList(options: BuildPostListOptions = {}): Promise<void> {
try {
// Use provided options or fall back to default production paths
const postDirectories = options.postDirectories || [
Expand All @@ -50,12 +50,31 @@ async function runBuildPostList(options: BuildPostListOptions = {}): Promise<voi
}
}

// Self-executing async function to handle top-level await
(async () => {
try {
await runBuildPostList();
} catch (error) {
// Ensure we exit with error code
process.exit(1);
}
})();
// Only run CLI if this file is executed directly, not when imported
if (import.meta.url === `file://${process.argv[1]}`) {
// Self-executing async function to handle top-level await
(async () => {
try {
// Extract the file name and basePath from the CLI command
const outputFileArgIndex = process.argv.indexOf('--outputFile');
const outputFileName = outputFileArgIndex === -1 ? 'posts.json' : process.argv[outputFileArgIndex + 1];

const basePathArgIndex = process.argv.indexOf('--basePath');
const basePath = basePathArgIndex === -1 ? undefined : process.argv[basePathArgIndex + 1];

// Build outputPath using resolve(basePath, outputFileName)
let outputPath;

if (basePath) {
outputPath = resolve(basePath, outputFileName);
} else {
outputPath = resolve(currentDirPath, '../../config', outputFileName);
}

await runBuildPostList({ basePath, outputPath });
} catch (error) {
// Ensure we exit with error code
process.exit(1);
}
})();
}
13 changes: 6 additions & 7 deletions npm/runners/build-tools-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ async function runBuildTools(options: BuildToolsOptions = {}): Promise<void> {
}
}

// Run only in non-test environments
if (process.env.NODE_ENV === 'test') {
logger.info('Skipping tools build in test environment');
} else {
// Export the function and interface for testing purposes
export { runBuildTools };
export type { BuildToolsOptions };

// Only run CLI if this file is executed directly, not when imported
if (import.meta.url === `file://${process.argv[1]}`) {
// Self-executing async function to handle top-level await
(async () => {
try {
Expand All @@ -75,6 +77,3 @@ if (process.env.NODE_ENV === 'test') {
}
})();
}

// Export for testing purposes
export { runBuildTools };
105 changes: 90 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"scripts": {
"dev": "npm run build-scripts && next dev",
"build": "npm run build-scripts && next build",
"test": "npm run test:unit && npm run test:integration",
"test:e2e": "npx cypress run",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage",
"test:unit": "jest --passWithNoTests --testMatch=\"**/tests/**/*.test.*\" --testPathIgnorePatterns=\"integrationTests|netlify\"",
"test:integration": "jest --passWithNoTests --testMatch=\"**/integrationTests/**/*.test.*\"",
"test:unit": "jest --passWithNoTests --testMatch=\"**/tests/**/*.test.*\" --testPathIgnorePatterns=\"tests/integration|netlify\"",
"test:integration": "jest --passWithNoTests tests/integration",
"test:build-post-list-runner": "npx tsx npm/runners/build-post-list-runner.ts --outputFile output-post-list.json --basePath tests/integration",
"test:build-dashboard": "jest --passWithNoTests tests/integration/build-dashboard.test.ts",
"build:pages": "tsx npm/runners/build-pages-runner.ts && npm run format:mdx",
"build:posts": "tsx scripts/index.ts",
"build-scripts": "npm run build:pages && npm run lint:mdx && npm run build:posts",
Expand Down Expand Up @@ -176,6 +178,7 @@
"eslint-plugin-unused-imports": "^3.1.0",
"fast-xml-parser": "^4.5.0",
"jest": "^29.7.0",
"nock": "^14.0.10",
"postcss-import": "^16.0.1",
"remark-cli": "^12.0.1",
"remark-lint": "^10.0.0",
Expand Down
Loading
Loading