@@ -50,57 +50,63 @@ const defaultPlugin = await client.from('registry_plugins').upsert({
5050
5151const { id : pluginId , name : pluginName } = defaultPlugin . data ! [ 0 ] ;
5252
53+ const CodifySchema = require ( '../dist/schemas.json' ) ;
54+
5355console . log ( 'Upserting plugin version' ) ;
5456const versionRow = await client . from ( 'registry_plugin_versions' ) . upsert ( {
5557 plugin_id : pluginId ,
5658 version,
5759 bundle_url : `https://plugins.codifycli.com/${ name } /${ version } /index.js` ,
5860 min_cli_version : PluginManifest . minSupportedCliVersion ,
5961 published_at : new Date ( ) . toISOString ( ) ,
62+ json_schema : CodifySchema ,
6063} , { onConflict : 'plugin_id,version' } )
6164 . select ( )
6265 . throwOnError ( ) ;
6366
64- if ( ! isBeta ) {
65- await uploadResources ( ) ;
67+ await uploadResources ( isBeta ) ;
6668
69+ if ( ! isBeta ) {
6770 // Build and deploy completions as well.
6871 console . log ( 'Deploying completions...' )
6972 cp . spawnSync ( 'source ~/.zshrc; npm run deploy:completions' , { shell : 'zsh' , stdio : 'inherit' } )
7073}
7174
72- async function uploadResources ( ) {
73- const CodifySchema = require ( '../dist/schemas.json' ) ;
75+ async function uploadResources ( prerelease : boolean ) {
7476 const Metadata : Array < Record < string , any > > = require ( '../dist/metadata.json' ) ;
7577
7678 const metadataByType = new Map ( Metadata . map ( ( m ) => [ m . type , m ] ) ) ;
7779
7880 const { id : versionId } = versionRow . data ! [ 0 ] ;
7981
80- console . log ( 'Updating latest version pointer' ) ;
81- await client . from ( 'registry_plugins' )
82- . update ( { latest_version : version , latest_version_id : versionId } )
83- . eq ( 'id' , pluginId )
84- . throwOnError ( ) ;
82+ if ( ! prerelease ) {
83+ console . log ( 'Updating latest version pointer' ) ;
84+ await client . from ( 'registry_plugins' )
85+ . update ( { latest_version : version , latest_version_id : versionId } )
86+ . eq ( 'id' , pluginId )
87+ . throwOnError ( ) ;
88+ }
89+
8590 const resources = CodifySchema . items . oneOf ;
8691
8792 for ( const resource of resources ) {
8893 const type = resource . properties . type . const ;
8994 const metadata = metadataByType . get ( type ) ;
9095
91- console . log ( `Adding resource ${ type } ` )
96+ console . log ( `Adding resource ${ type } (prerelease= ${ prerelease } ) ` )
9297 const resourceRow = await client . from ( 'registry_resources' ) . upsert ( {
9398 type,
9499 plugin_id : pluginId ,
95100 plugin_name : pluginName ,
101+ prerelease,
96102 schema : JSON . stringify ( resource ) ,
97103 documentation_url : resource . $comment ,
98104 allow_multiple : metadata ?. allowMultiple ?? false ,
99105 os : metadata ?. operatingSystems ?? [ ] ,
100106 default_config : metadata ?. defaultConfig ? JSON . stringify ( metadata . defaultConfig ) : null ,
101107 example_config_1 : metadata ?. exampleConfigs ?. example1 ? JSON . stringify ( metadata . exampleConfigs . example1 ) : null ,
102108 example_config_2 : metadata ?. exampleConfigs ?. example2 ? JSON . stringify ( metadata . exampleConfigs . example2 ) : null ,
103- } , { onConflict : [ 'type' , ' plugin_id' ] } )
109+ } , { onConflict : 'type, plugin_id,prerelease' } )
104110 . select ( )
105111 . throwOnError ( ) ;
106112
@@ -115,12 +121,13 @@ async function uploadResources() {
115121 type : ( property as any ) . type ,
116122 name : key ,
117123 resource_id : resourceId ,
124+ prerelease,
118125 schema : property ,
119126 is_sensitive : allSensitive || sensitiveParams . includes ( key ) ,
120127 } ) )
121128
122129 await client . from ( 'registry_resource_parameters' )
123- . upsert ( parameters , { onConflict : [ 'name' , ' resource_id' ] } )
130+ . upsert ( parameters , { onConflict : 'name, resource_id,prerelease' } )
124131 . throwOnError ( ) ;
125132 }
126133}
0 commit comments