@@ -13,7 +13,7 @@ import {
13
13
} from "./actions-util" ;
14
14
import * as api from "./api-client" ;
15
15
import { CliError , wrapCliConfigurationError } from "./cli-errors" ;
16
- import { type Config } from "./config-utils" ;
16
+ import { generateCodeScanningConfig , type Config } from "./config-utils" ;
17
17
import { DocUrl } from "./doc-url" ;
18
18
import { EnvVar } from "./environment" ;
19
19
import {
@@ -35,7 +35,7 @@ import { ToolsDownloadStatusReport } from "./tools-download";
35
35
import { ToolsFeature , isSupportedToolsFeature } from "./tools-features" ;
36
36
import { shouldEnableIndirectTracing } from "./tracer-config" ;
37
37
import * as util from "./util" ;
38
- import { BuildMode , cloneObject , getErrorMessage } from "./util" ;
38
+ import { BuildMode , getErrorMessage } from "./util" ;
39
39
40
40
type Options = Array < string | number | boolean > ;
41
41
@@ -574,7 +574,7 @@ export async function getCodeQLForCmd(
574
574
extraArgs . push ( `--trace-process-name=${ processName } ` ) ;
575
575
}
576
576
577
- const codeScanningConfigFile = await generateCodeScanningConfig (
577
+ const codeScanningConfigFile = await writeCodeScanningConfigFile (
578
578
config ,
579
579
logger ,
580
580
) ;
@@ -1217,66 +1217,15 @@ async function runCli(
1217
1217
* @param config The configuration to use.
1218
1218
* @returns the path to the generated user configuration file.
1219
1219
*/
1220
- async function generateCodeScanningConfig (
1220
+ async function writeCodeScanningConfigFile (
1221
1221
config : Config ,
1222
1222
logger : Logger ,
1223
1223
) : Promise < string > {
1224
1224
const codeScanningConfigFile = getGeneratedCodeScanningConfigPath ( config ) ;
1225
-
1226
- // make a copy so we can modify it
1227
- const augmentedConfig = cloneObject ( config . originalUserInput ) ;
1228
-
1229
- // Inject the queries from the input
1230
- if ( config . augmentationProperties . queriesInput ) {
1231
- if ( config . augmentationProperties . queriesInputCombines ) {
1232
- augmentedConfig . queries = ( augmentedConfig . queries || [ ] ) . concat (
1233
- config . augmentationProperties . queriesInput ,
1234
- ) ;
1235
- } else {
1236
- augmentedConfig . queries = config . augmentationProperties . queriesInput ;
1237
- }
1238
- }
1239
- if ( augmentedConfig . queries ?. length === 0 ) {
1240
- delete augmentedConfig . queries ;
1241
- }
1242
-
1243
- // Inject the packs from the input
1244
- if ( config . augmentationProperties . packsInput ) {
1245
- if ( config . augmentationProperties . packsInputCombines ) {
1246
- // At this point, we already know that this is a single-language analysis
1247
- if ( Array . isArray ( augmentedConfig . packs ) ) {
1248
- augmentedConfig . packs = ( augmentedConfig . packs || [ ] ) . concat (
1249
- config . augmentationProperties . packsInput ,
1250
- ) ;
1251
- } else if ( ! augmentedConfig . packs ) {
1252
- augmentedConfig . packs = config . augmentationProperties . packsInput ;
1253
- } else {
1254
- // At this point, we know there is only one language.
1255
- // If there were more than one language, an error would already have been thrown.
1256
- const language = Object . keys ( augmentedConfig . packs ) [ 0 ] ;
1257
- augmentedConfig . packs [ language ] = augmentedConfig . packs [
1258
- language
1259
- ] . concat ( config . augmentationProperties . packsInput ) ;
1260
- }
1261
- } else {
1262
- augmentedConfig . packs = config . augmentationProperties . packsInput ;
1263
- }
1264
- }
1265
- if ( Array . isArray ( augmentedConfig . packs ) && ! augmentedConfig . packs . length ) {
1266
- delete augmentedConfig . packs ;
1267
- }
1268
-
1269
- augmentedConfig [ "query-filters" ] = [
1270
- // Ordering matters. If the first filter is an inclusion, it implicitly
1271
- // excludes all queries that are not included. If it is an exclusion,
1272
- // it implicitly includes all queries that are not excluded. So user
1273
- // filters (if any) should always be first to preserve intent.
1274
- ...( augmentedConfig [ "query-filters" ] || [ ] ) ,
1275
- ...( config . augmentationProperties . extraQueryExclusions || [ ] ) ,
1276
- ] ;
1277
- if ( augmentedConfig [ "query-filters" ] ?. length === 0 ) {
1278
- delete augmentedConfig [ "query-filters" ] ;
1279
- }
1225
+ const augmentedConfig = generateCodeScanningConfig (
1226
+ config . originalUserInput ,
1227
+ config . augmentationProperties ,
1228
+ ) ;
1280
1229
1281
1230
logger . info (
1282
1231
`Writing augmented user configuration file to ${ codeScanningConfigFile } ` ,
0 commit comments