@@ -32,8 +32,8 @@ def sdk_automation_typespec(config: dict) -> List[dict]:
3232 if 'relatedTypeSpecProjectFolder' not in config :
3333 return packages
3434
35- head_sha : str = config ['headSha' ]
36- repo_url : str = config ['repoHttpsUrl' ]
35+ head_sha = config ['headSha' ]
36+ repo_url = config ['repoHttpsUrl' ]
3737
3838 tsp_projects = config ['relatedTypeSpecProjectFolder' ]
3939 if isinstance (tsp_projects , str ):
@@ -47,40 +47,16 @@ def sdk_automation_typespec(config: dict) -> List[dict]:
4747 service = None
4848 module = None
4949 try :
50- def remove_prefix (text , prefix ):
51- if text .startswith (prefix ):
52- return text [len (prefix ):]
53- return text
54-
55- def find_sdk_folder ():
56- cmd = ['git' , 'add' , '.' ]
57- check_call (cmd , sdk_root )
58-
59- cmd = ['git' , 'status' , '--porcelain' , '**/tsp-location.yaml' ]
60- logging .info ('Command line: ' + ' ' .join (cmd ))
61- output = subprocess .check_output (cmd , cwd = sdk_root )
62- output_str = str (output , 'utf-8' )
63- git_items = output_str .splitlines ()
64- sdk_folder = None
65- if len (git_items ) > 0 :
66- tsp_location_item : str = git_items [0 ]
67- sdk_folder = tsp_location_item [1 :].strip ()[0 :- len ('/tsp-location.yaml' )]
68-
69- cmd = ['git' , 'reset' , '.' ]
70- check_call (cmd , sdk_root )
71-
72- return sdk_folder
73-
74- repo = remove_prefix (repo_url , 'https://github.com/' )
75- cmd = ['npx' , 'tsp-client' , 'init' , '--debug' , '--tsp-config' , tsp_dir , '--commit' , head_sha , '--repo' , repo ]
76- check_call (cmd , sdk_root )
77-
78- sdk_folder = find_sdk_folder ()
50+ cmd = ['pwsh' , './eng/common/scripts/TypeSpec-Project-Process.ps1' , tsp_dir , head_sha , repo_url ]
51+ logging .info ('Command line: ' + ' ' .join (cmd ))
52+ output = subprocess .check_output (cmd , cwd = sdk_root )
53+ output_str = str (output , 'utf-8' )
54+ script_return = output_str .splitlines ()[- 1 ] # the path to sdk folder
55+ sdk_folder = os .path .relpath (script_return , sdk_root )
7956 logging .info ('SDK folder: ' + sdk_folder )
80- if sdk_folder :
81- succeeded = True
57+ succeeded = True
8258 except subprocess .CalledProcessError as error :
83- logging .error (f'tsp-client init fail: { error } ' )
59+ logging .error (f'TypeSpec-Project-Process.ps1 fail: { error } ' )
8460
8561 if succeeded :
8662 # check require_sdk_integration
0 commit comments