11import fs from 'node:fs' ;
22import path from 'node:path' ;
33import process from 'node:process' ;
4+ import publicationPolicy from '../../../blog/services/policy.json' with { type : 'json' } ;
45
56const configuredPostsDirectory = process . env . BLOG_AUDIT_POSTS_DIR ?? 'posts' ;
67const postsDirectory = path . isAbsolute ( configuredPostsDirectory )
78 ? configuredPostsDirectory
89 : path . join ( process . cwd ( ) , configuredPostsDirectory ) ;
910const CONTENT_TYPES = [ 'essay' , 'retrospective' , 'review' ] ;
10- const CORE_REVIEW_KEYS = [ 'philosophy' , 'design' , 'implementation' ] ;
11+ const CORE_REVIEW_KEYS = publicationPolicy . publicTech . coreReviewFields ;
1112const WRITING_REVIEW_KEYS = [
1213 'clarity' ,
1314 'structure' ,
@@ -292,6 +293,8 @@ function reviewPostQuality(meta, content) {
292293function evaluatePolicy ( meta ) {
293294 const visibility = meta . visibility ?? 'private' ;
294295 const coreAverage = readCoreAverage ( meta . qualityReview ) ;
296+ const publicTechPolicy = publicationPolicy . publicTech ;
297+ const featuredPolicy = publicationPolicy . featured ;
295298 const warnings = [ ] ;
296299
297300 if ( visibility === 'public' && meta . series ) {
@@ -301,16 +304,33 @@ function evaluatePolicy(meta) {
301304 if ( visibility === 'public' && meta . category === 'Tech' ) {
302305 if ( coreAverage === null ) {
303306 warnings . push ( 'public Tech core 점수 누락' ) ;
304- } else if ( coreAverage <= 3 ) {
305- warnings . push ( `public Tech core 평균 ${ coreAverage . toFixed ( 2 ) } <= 3.0` ) ;
307+ } else if (
308+ coreAverage <= publicTechPolicy . minimumCoreReviewAverageExclusive
309+ ) {
310+ warnings . push (
311+ `public Tech core 평균 ${ coreAverage . toFixed ( 2 ) } <= ${ publicTechPolicy . minimumCoreReviewAverageExclusive . toFixed ( 1 ) } `
312+ ) ;
306313 }
307314 }
308315
309316 if ( meta . featured ) {
310317 const brandFit = meta . qualityReview ?. brandFit ;
311318
312- if ( typeof brandFit !== 'number' || brandFit < 4 ) {
313- warnings . push ( 'featured brandFit < 4.0' ) ;
319+ if ( meta . category !== featuredPolicy . category ) {
320+ warnings . push ( `featured category must be ${ featuredPolicy . category } ` ) ;
321+ }
322+
323+ if ( featuredPolicy . requiresNoSeries && meta . series ) {
324+ warnings . push ( 'featured series 글' ) ;
325+ }
326+
327+ if (
328+ typeof brandFit !== 'number' ||
329+ brandFit < featuredPolicy . minimumBrandFit
330+ ) {
331+ warnings . push (
332+ `featured brandFit < ${ featuredPolicy . minimumBrandFit . toFixed ( 1 ) } `
333+ ) ;
314334 }
315335 }
316336
@@ -602,20 +622,27 @@ function printReport(posts, errors) {
602622
603623 console . log ( '## Policy Checks' ) ;
604624 console . log (
605- `- public Tech core average > 3.0 : ${
625+ `- public Tech core average > ${ publicationPolicy . publicTech . minimumCoreReviewAverageExclusive . toFixed ( 1 ) } : ${
606626 publicTechPosts . every (
607627 ( post ) =>
608- post . policy . coreAverage !== null && post . policy . coreAverage > 3
628+ post . policy . coreAverage !== null &&
629+ post . policy . coreAverage >
630+ publicationPolicy . publicTech . minimumCoreReviewAverageExclusive
609631 )
610632 ? 'ok'
611633 : 'review'
612634 } `
613635 ) ;
614636 console . log (
615- `- featured brandFit >= 4.0 : ${
637+ `- featured eligibility : ${
616638 featuredPosts . every ( ( post ) => {
617639 const brandFit = post . qualityReview ?. brandFit ;
618- return typeof brandFit === 'number' && brandFit >= 4 ;
640+ return (
641+ post . category === publicationPolicy . featured . category &&
642+ ( ! publicationPolicy . featured . requiresNoSeries || ! post . series ) &&
643+ typeof brandFit === 'number' &&
644+ brandFit >= publicationPolicy . featured . minimumBrandFit
645+ ) ;
619646 } )
620647 ? 'ok'
621648 : 'review'
0 commit comments