99 publishPackages ,
1010} from './commands/commands.js' ;
1111
12- // Effect to check for the presence of changeset files
1312const checkForChangesets = Effect . gen ( function * ( ) {
1413 yield * Console . log ( 'Checking for changeset files...' ) ;
1514
@@ -18,10 +17,8 @@ const checkForChangesets = Effect.gen(function* () {
1817
1918 const changesetDir = path . join ( process . cwd ( ) , '.changesets' ) ;
2019
21- // 3. Read the directory and check for *.md files (excluding README.md)
2220 const files = yield * fs . readDirectory ( changesetDir ) . pipe (
2321 Effect . catchTag ( 'SystemError' , ( e ) => {
24- // If the directory doesn't exist, treat it as "no changesets found"
2522 if ( e . reason === 'NotFound' ) {
2623 return Effect . fail ( 'No changesets found. Please add a changeset before releasing.' ) ;
2724 }
@@ -30,33 +27,31 @@ const checkForChangesets = Effect.gen(function* () {
3027 } ) ,
3128 ) ;
3229
33- const hasChangesetFiles = files . every ( ( file ) => file . endsWith ( '.md' ) && file !== 'README.md' ) ;
30+ const hasChangesetFiles = files
31+ . filter ( ( file ) => file !== 'README.md' )
32+ . filter ( ( file ) => file !== 'config.json' )
33+ . every ( ( file ) => file . endsWith ( '.md' ) ) ;
3434
3535 if ( ! hasChangesetFiles ) {
3636 yield * Effect . fail ( 'No changesets found. Please add a changeset before releasing.' ) ;
3737 }
3838
3939 yield * Console . log ( 'Changeset files found.' ) ;
40- } ) . pipe (
41- Effect . tapError ( ( error ) => Console . error ( `Changeset check failed: ${ error } ` ) ) , // Log specific failure reason
42- ) ;
40+ } ) . pipe ( Effect . tapError ( ( error ) => Console . error ( `Changeset check failed: ${ error } ` ) ) ) ;
4341
44- // Main program flow using Effect.gen
4542const program = Effect . gen ( function * ( ) {
4643 yield * Console . log ( 'Starting release script...' ) ;
4744
4845 yield * Console . log ( 'Checking Git status for staged files...' ) ;
49- yield * checkGitStatus ; // This will fail the Effect if staged changes exist
50- yield * Console . log ( 'Git status OK (no staged files found).' ) ;
46+ yield * checkGitStatus ;
5147
52- // Check for changesets *before* running snapshot
48+ yield * Console . log ( 'Git status OK (no staged files found).' ) ;
5349 yield * checkForChangesets ;
5450
5551 yield * Console . log ( 'Running Changesets snapshot version...' ) ;
5652 yield * runChangesetsSnapshot ;
5753
5854 yield * startLocalRegistry ;
59- // Add delay to give Verdaccio time to start up. Adjust duration if needed.
6055 yield * Console . log ( 'Waiting for local registry to initialize... (5 seconds)' ) ;
6156 yield * Effect . sleep ( '5 seconds' ) ;
6257
@@ -71,16 +66,13 @@ const program = Effect.gen(function* () {
7166
7267 yield * Effect . never ; // Keep script running if needed, e.g., for background process
7368} ) . pipe (
74- // Fallback for any other Failures (like strings from Effect.fail)
7569 Effect . catchAll ( ( error ) => {
7670 if ( typeof error === 'string' ) {
7771 return Console . error ( `Error: ${ error } ` ) ;
7872 }
79- // Handle unexpected error types if necessary
8073 return Console . error ( `An unexpected error occurred: ${ JSON . stringify ( error ) } ` ) ;
8174 } ) ,
82- Effect . provide ( NodeContext . layer ) , // Provide necessary Node services (includes FileSystem, Path, CommandExecutor)
75+ Effect . provide ( NodeContext . layer ) ,
8376) ;
8477
85- // Execute the program using the Node runtime
8678NodeRuntime . runMain ( Effect . scoped ( program ) ) ;
0 commit comments