@@ -3,19 +3,10 @@ import { exec } from 'child_process';
33import * as fs from 'fs-extra' ;
44import { series } from "async" ;
55import { getSemanticVersion } from './extension-version' ;
6- import * as tasks from './tasks' ;
7-
8- export interface IConfiguration {
9- "environments" : {
10- "Name" : string ;
11- "VssExtensionIdSuffix" : string ;
12- "VssExtensionGalleryFlags" : ( "Preview" | "Public" ) [ ] ;
13- "DisplayNamesSuffix" : string ;
14- "TaskIds" : {
15- [ key : string ] : string ;
16- } ;
17- } [ ] ;
18- } ;
6+ import { getTasks } from './tasks' ;
7+ import { getConfiguration } from './configuration' ;
8+ import { getEndpoints } from './endpoints' ;
9+ import { VstsTasksSchema } from './task' ;
1910
2011var currentDirectory = process . cwd ( ) ;
2112var buildOutputDirectory = path . join ( currentDirectory , '.BuildOutput' ) ;
@@ -26,7 +17,7 @@ fs.ensureDirSync(buildOutputDirectory);
2617
2718var version = getSemanticVersion ( ) ;
2819
29- var configuration = require ( path . join ( currentDirectory , 'configuration.json' ) ) as IConfiguration ;
20+ var configuration = getConfiguration ( ) ;
3021var createExtensionTasks = configuration . environments . map ( ( env ) => {
3122
3223 var environmentDirectory = path . join ( buildOutputDirectory , env . Name ) ;
@@ -47,21 +38,44 @@ var createExtensionTasks = configuration.environments.map((env) => {
4738 extension . contributions = [ ] ;
4839 }
4940
50- var patchTasks = tasks . getTasks ( environmentTasksDirectory ) . map ( ( taskDirectory ) => {
41+ let endpointMap : { [ source : string ] : string } = { } ;
42+
43+ getEndpoints ( ) . forEach ( endpoint => {
44+ endpointMap [ `connectedService:${ endpoint . name } ` ] = `connectedService:${ endpoint . name } ${ env . VssExtensionIdSuffix } ` ;
45+ var config = endpoint . manifest ;
46+ config . id = config . id + env . VssExtensionIdSuffix ;
47+ config . properties . name = endpoint . name + env . VssExtensionIdSuffix ;
48+ config . properties . displayName = config . properties . displayName + env . DisplayNamesSuffix ;
49+ extension . contributions . push ( config ) ;
50+ } ) ;
51+
52+ getTasks ( environmentTasksDirectory ) . map ( ( taskDirectory ) => {
5153 var taskFilePath = path . join ( taskDirectory . directory , 'task.json' ) ;
52- var task = fs . readJsonSync ( taskFilePath ) ;
54+ var task = fs . readJsonSync ( taskFilePath ) as VstsTasksSchema ;
5355
5456 task . id = env . TaskIds [ taskDirectory . name ] ;
5557 if ( task . id ) {
5658 task . friendlyName += env . DisplayNamesSuffix ;
5759
58- task . version . Major = version . major ;
59- task . version . Minor = version . minor ;
60- task . version . Patch = version . patch ;
60+ task . version = {
61+ Major : version . major ,
62+ Minor : version . minor ,
63+ Patch : version . patch ,
64+ } ;
65+
6166 if ( task . helpMarkDown ) {
6267 task . helpMarkDown = task . helpMarkDown . replace ( '#{Version}#' , version . getVersionString ( ) ) ;
6368 }
6469
70+ if ( task . inputs ) {
71+ task . inputs . forEach ( ( input ) => {
72+ var mappedType = endpointMap [ input . type ] ;
73+ if ( mappedType ) {
74+ input . type = mappedType ;
75+ }
76+ } ) ;
77+ }
78+
6579 fs . writeJsonSync ( taskFilePath , task ) ;
6680
6781 var taskLocFilePath = path . join ( taskDirectory . directory , 'task.loc.json' ) ;
0 commit comments