Skip to content

Commit e240591

Browse files
committed
chore: update-release-tool
1 parent e1a5d2f commit e240591

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

tools/release/commands/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Effect, Stream, Console } from 'effect';
22
import { Command } from '@effect/platform';
3+
34
// Effect to check git status for staged files
45
export const checkGitStatus = Command.make('git', 'status', '--porcelain').pipe(
56
Command.string,

tools/release/release.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
publishPackages,
1010
} from './commands/commands.js';
1111

12-
// Effect to check for the presence of changeset files
1312
const 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
4542
const 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
8678
NodeRuntime.runMain(Effect.scoped(program));

0 commit comments

Comments
 (0)