11import { Env , fsa , LogConfig } from '@basemaps/shared' ;
2- import { BaseConfig , ConfigBundled , ConfigProviderMemory } from '@basemaps/config' ;
2+ import { BaseConfig , Config , ConfigBundle , ConfigBundled , ConfigProviderMemory } from '@basemaps/config' ;
33import { CommandLineAction , CommandLineFlagParameter , CommandLineStringParameter } from '@rushstack/ts-command-line' ;
44import { Q , Updater } from './config.update.js' ;
55import { invalidateCache } from '../util.js' ;
@@ -27,7 +27,7 @@ export class CommandImport extends CommandLineAction {
2727 this . config = this . defineStringParameter ( {
2828 argumentName : 'CONFIG' ,
2929 parameterLongName : '--config' ,
30- description : 'Path of config json' ,
30+ description : 'Path of config json, this can be both a local path or s3 location ' ,
3131 required : true ,
3232 } ) ;
3333 this . backup = this . defineStringParameter ( {
@@ -49,6 +49,8 @@ export class CommandImport extends CommandLineAction {
4949 const config = this . config . value ;
5050 const backup = this . backup . value ;
5151 if ( config == null ) throw new Error ( 'Please provide a config json' ) ;
52+ if ( commit && ! config . startsWith ( 's3://' ) )
53+ throw new Error ( 'To acturally import into dynamo has to use the config file from s3.' ) ;
5254
5355 const HostPrefix = Env . isProduction ( ) ? '' : 'dev.' ;
5456 const healthEndpoint = `https://${ HostPrefix } basemaps.linz.govt.nz/v1/health` ;
@@ -68,6 +70,17 @@ export class CommandImport extends CommandLineAction {
6870 for ( const config of mem . objects . values ( ) ) this . update ( config , commit ) ;
6971 await Promise . all ( this . promises ) ;
7072
73+ if ( commit ) {
74+ const configBundle : ConfigBundle = {
75+ id : Config . ConfigBundle . id ( configJson . id ) ,
76+ name : Config . ConfigBundle . id ( `config-${ configJson . hash } .json` ) ,
77+ path : config ,
78+ hash : configJson . hash ,
79+ } ;
80+ logger . info ( { config } , 'Import:ConfigBundle' ) ;
81+ if ( Config . ConfigBundle . isWriteable ( ) ) await Config . ConfigBundle . put ( configBundle ) ;
82+ }
83+
7184 if ( commit && this . invalidations . length > 0 ) {
7285 // Lots of invalidations just invalidate everything
7386 if ( this . invalidations . length > 10 ) {
0 commit comments