@@ -1413,6 +1413,35 @@ const registerServiceWithSuiteJson = ({ root_dir, name, port }) => {
14131413 config . services . push ( { name, port } ) ;
14141414 writeFile ( configPath , JSON . stringify ( config , null , 2 ) , 'utf8' ) ;
14151415}
1416+
1417+ /**
1418+ * Releases a package or generates a release for the workspace.
1419+ * @async
1420+ * @param {Object } options - Options for releasing the package.
1421+ * @param {string } options.package - The name of the package to release (optional).
1422+ * @returns {Promise<void> } A Promise that resolves when the release process is completed.
1423+ */
1424+ const test = async ( { package } ) => {
1425+ let rootDir = cwd ( ) ;
1426+ if ( ! package ) {
1427+ rootDir = generatRootPath ( { currentDir : cwd ( ) } ) ;
1428+ }
1429+ try {
1430+ const package_json_path = join ( rootDir , 'package.json' ) ;
1431+
1432+ // Read the package.json file
1433+ const { workspace_name } = retrieveWorkSpaceName ( { package_json_path } ) ;
1434+ if ( package ) {
1435+ logInfo ( { message : `Looking for package: ${ workspace_name } /${ package } ` } ) ;
1436+ await executeCommand ( 'yarn' , [ 'workspace' , `${ workspace_name } /${ package } ` , 'test' ] , { stdio : 'inherit' , shell : true } ) ;
1437+ } else {
1438+ await executeCommand ( 'yarn' , [ 'test' ] , { cwd : rootDir , stdio : 'inherit' , shell : true } ) ;
1439+ }
1440+ } catch ( error ) {
1441+ ora ( ) . fail ( 'Command failed to run' ) ;
1442+ }
1443+ }
1444+
14161445const readFileContent = ( { path } ) => { }
14171446module . exports = {
14181447 generateDirectoryPath,
@@ -1441,5 +1470,6 @@ module.exports = {
14411470 scaffoldNewService,
14421471 scaffoldNewLibrary,
14431472 getNextAvailablePort,
1444- getExistingServices
1473+ getExistingServices,
1474+ test
14451475}
0 commit comments