1+ import * as constants from '../constants' ;
2+ import { cloneAndGenerateBasePaths , validateAndReturnReadmePath } from '../specs' ;
3+ import chalk from 'chalk' ;
4+ import { findAutogenEntries } from '../autogenlist' ;
5+ import { executeSynchronous , lowerCaseEquals , writeJsonFile , safeMkdir } from '../utils' ;
6+ import { getApiVersionsByNamespace } from '../generate' ;
7+ import { keys , partition } from 'lodash' ;
8+ import path from 'path' ;
9+
10+ executeSynchronous ( async ( ) => {
11+ const basePaths = await cloneAndGenerateBasePaths ( constants . specsRepoPath , constants . specsRepoUri , constants . specsRepoCommitHash ) ;
12+
13+ let allBasePaths = [ ] ;
14+
15+ for ( const basePath of basePaths ) {
16+ const readme = await validateAndReturnReadmePath ( constants . specsRepoPath , basePath ) ;
17+ const namespaces = keys ( await getApiVersionsByNamespace ( readme ) ) ;
18+ const autogenlistEntries = findAutogenEntries ( basePath ) ;
19+
20+ const [ autogened , unautogened ] = partition (
21+ namespaces ,
22+ n => autogenlistEntries . findIndex ( w => lowerCaseEquals ( w . namespace , n ) ) > - 1 ) ;
23+
24+ if ( unautogened . length > 0 && autogened . length > 0 ) {
25+ // For partial autogeneration only, add two items
26+ // one item containing resource types not onboarded for autogeneration
27+ // and the other item containing resource types onboarded for autogeneration
28+ allBasePaths . push ( {
29+ 'basePath' : basePath ,
30+ 'onboardedToAutogen' : 'no' ,
31+ 'missing' : unautogened ,
32+ 'included' : [ ]
33+ } ) ;
34+
35+ allBasePaths . push ( {
36+ 'basePath' : basePath ,
37+ 'onboardedToAutogen' : 'yes' ,
38+ 'missing' : [ ] ,
39+ 'included' : autogened
40+ } ) ;
41+ }
42+ else {
43+ // unautogened.length === 0 means all resource types are onboarded for autogeneration
44+ allBasePaths . push ( {
45+ 'basePath' : basePath ,
46+ 'onboardedToAutogen' : unautogened . length === 0 ? 'yes' : 'no' ,
47+ 'missing' : unautogened ,
48+ 'onboarded' : [ ]
49+ } ) ;
50+ }
51+ }
52+
53+ const autogenResultPath = path . join ( constants . autogenResultPath , 'result.json' ) ;
54+ await safeMkdir ( constants . autogenResultPath ) ;
55+ await writeJsonFile ( autogenResultPath , allBasePaths ) ;
56+ } ) ;
0 commit comments