99
1010import * as fs from 'fs' ;
1111import * as path from 'path' ;
12+ import { IMAGE_REF_PATTERN , TEMPLATE_OPTION_PATTERN , TemplateJson , findFiles } from './utils' ;
1213
1314const RED = '\x1b[0;31m' ;
1415const GREEN = '\x1b[0;32m' ;
1516const YELLOW = '\x1b[0;33m' ;
1617const NC = '\x1b[0m' ;
1718
18- const MCR_PREFIX = 'mcr.microsoft.com/devcontainers/' ;
19- const IMAGE_REF_PATTERN = / m c r \. m i c r o s o f t \. c o m \/ d e v c o n t a i n e r s \/ ( [ ^ " ] + ) / g;
20- const TEMPLATE_OPTION_PATTERN = / \$ \{ t e m p l a t e O p t i o n : ( [ ^ } ] + ) \} / ;
21-
2219interface ImageManifest {
2320 version : string ;
2421 variants ?: string [ ] ;
@@ -28,13 +25,6 @@ interface ImageManifest {
2825 } ;
2926}
3027
31- interface TemplateJson {
32- options ?: Record < string , {
33- default ?: string ;
34- proposals ?: string [ ] ;
35- } > ;
36- }
37-
3828interface TemplateTag {
3929 templateName : string ;
4030 relFile : string ;
@@ -110,22 +100,6 @@ function computeImageTags(imagesRepo: string): Set<string> {
110100
111101// --- Step 2: Compute all tags that templates would produce ---
112102
113- function findFiles ( dir : string , names : string [ ] ) : string [ ] {
114- const results : string [ ] = [ ] ;
115- function walk ( d : string ) {
116- for ( const entry of fs . readdirSync ( d , { withFileTypes : true } ) ) {
117- const full = path . join ( d , entry . name ) ;
118- if ( entry . isDirectory ( ) ) {
119- walk ( full ) ;
120- } else if ( names . includes ( entry . name ) || names . some ( n => n . startsWith ( '*.' ) && entry . name . endsWith ( n . slice ( 1 ) ) ) ) {
121- results . push ( full ) ;
122- }
123- }
124- }
125- walk ( dir ) ;
126- return results ;
127- }
128-
129103function computeTemplateTags ( templatesDir : string ) : TemplateTag [ ] {
130104 const results : TemplateTag [ ] = [ ] ;
131105
0 commit comments