@@ -6,7 +6,7 @@ import path from "node:path";
66 *
77 * @param options Command-line options for the script.
88 */
9- export default async function runCreateLetter ( options : {
9+ export async function runCreateLetter ( options : {
1010 filter ?: string ;
1111 supplierId : string ;
1212 environment : string ;
@@ -33,7 +33,6 @@ export default async function runCreateLetter(options: {
3333 ) ;
3434 const cmd = process . platform === "win32" ? "npm.cmd" : "npm" ;
3535 const root = path . resolve ( workspaceRoot ) ;
36- console . log ( "Workspace root:" , root ) ;
3736
3837 // Build arguments array
3938 const args = [
@@ -79,3 +78,61 @@ export default async function runCreateLetter(options: {
7978 child . on ( "error" , reject ) ;
8079 } ) ;
8180}
81+
82+ export async function createSupplierData ( options : {
83+ filter ?: string ;
84+ supplierId : string ;
85+ name : string ;
86+ apimId : string ;
87+ environment : string ;
88+ status : string ;
89+ } ) {
90+ const { apimId, environment, name, status, supplierId, filter } = options ;
91+
92+ const workspaceRoot = path . resolve (
93+ __dirname ,
94+ "../../scripts/utilities/supplier-data" ,
95+ ) ;
96+ const cmd = process . platform === "win32" ? "npm.cmd" : "npm" ;
97+ const root = path . resolve ( workspaceRoot ) ;
98+
99+ // Build arguments array
100+ const args = [
101+ "-w" ,
102+ String ( filter ) ,
103+ // '--filter', String(filter),
104+ "run" ,
105+ "cli" ,
106+ "--" ,
107+ "put-supplier" ,
108+ "--id" ,
109+ supplierId ,
110+ "--name" ,
111+ name ,
112+ "--apimId" ,
113+ apimId ,
114+ "--status" ,
115+ status ,
116+ "--environment" ,
117+ environment ,
118+ ] ;
119+
120+ await new Promise < void > ( ( resolve , reject ) => {
121+ let output = "" ;
122+ const child = spawn ( cmd , args , {
123+ stdio : "inherit" ,
124+ cwd : root ,
125+ shell : false ,
126+ } ) ;
127+ child . stdout ?. on ( "id" , ( id ) => {
128+ const text = id . toString ( ) ;
129+ output += text ;
130+ process . stdout . write ( text ) ;
131+ } ) ;
132+
133+ child . on ( "close" , ( code ) =>
134+ code === 0 ? resolve ( ) : reject ( new Error ( `pnpm exited with ${ code } ` ) ) ,
135+ ) ;
136+ child . on ( "error" , reject ) ;
137+ } ) ;
138+ }
0 commit comments