@@ -6,8 +6,7 @@ const { spawn } = require("child_process");
6
6
const readline = require ( "readline" ) ;
7
7
const semver = require ( "semver" ) ;
8
8
9
- const RELEASE_BRANCH = "release" ;
10
- const MAIN_BRANCH = "main" ;
9
+ const MAIN_BRANCH = "v1" ;
11
10
12
11
/**
13
12
* Handles execSync errors and logs them in a readable format.
@@ -51,11 +50,7 @@ function getWorkspaceVersion(workspaceDirectory) {
51
50
* @returns {Array<{ dir: string, packageJSON: Record<string, any>}> }
52
51
*/
53
52
function getAllWorkspaces ( ) {
54
- const possibleWorkspaceDirectories = [
55
- "./libs/*" ,
56
- "./langchain" ,
57
- "./langchain-core" ,
58
- ] ;
53
+ const possibleWorkspaceDirectories = [ "./libs/*" , "./libs/providers/*" ] ;
59
54
const allWorkspaces = possibleWorkspaceDirectories . flatMap (
60
55
( workspaceDirectory ) => {
61
56
if ( workspaceDirectory . endsWith ( "*" ) ) {
@@ -64,22 +59,30 @@ function getAllWorkspaces() {
64
59
path . join ( process . cwd ( ) , workspaceDirectory . replace ( "*" , "" ) )
65
60
) ;
66
61
const subDirs = allDirs . map ( ( dir ) => {
62
+ const packageJSONPath = path . join (
63
+ process . cwd ( ) ,
64
+ `${ workspaceDirectory . replace ( "*" , "" ) } ${ dir } ` ,
65
+ "package.json"
66
+ ) ;
67
+ if ( ! fs . existsSync ( packageJSONPath ) ) {
68
+ return null ;
69
+ }
67
70
return {
68
71
dir : `${ workspaceDirectory . replace ( "*" , "" ) } ${ dir } ` ,
69
- packageJSON : require ( path . join (
70
- process . cwd ( ) ,
71
- `${ workspaceDirectory . replace ( "*" , "" ) } ${ dir } ` ,
72
- "package.json"
73
- ) ) ,
72
+ packageJSON : require ( packageJSONPath ) ,
74
73
} ;
75
74
} ) ;
76
- return subDirs ;
75
+ return subDirs . filter ( ( dir ) => dir !== null ) ;
77
76
}
78
- const packageJSON = require ( path . join (
77
+ const packageJSONPath = path . join (
79
78
process . cwd ( ) ,
80
79
workspaceDirectory ,
81
80
"package.json"
82
- ) ) ;
81
+ ) ;
82
+ if ( ! fs . existsSync ( packageJSONPath ) ) {
83
+ return null ;
84
+ }
85
+ const packageJSON = require ( packageJSONPath ) ;
83
86
return {
84
87
dir : workspaceDirectory ,
85
88
packageJSON,
@@ -137,12 +140,13 @@ function updateDependencies(
137
140
* @param {string | undefined } tag An optional tag to publish to.
138
141
* @returns {Promise<void> }
139
142
*/
140
- async function runPnpmRelease ( packageDirectory , npm2FACode , tag ) {
143
+ async function runPnpmRelease ( packageDirectory , npm2FACode , tag , dryRun ) {
141
144
return new Promise ( ( resolve , reject ) => {
142
145
const workingDirectory = path . join ( process . cwd ( ) , packageDirectory ) ;
143
146
const tagArg = tag ? `--npm.tag=${ tag } ` : "" ;
144
147
const args = [
145
148
"release-it" ,
149
+ dryRun ? "--dry-run" : "" ,
146
150
`--npm.otp=${ npm2FACode } ` ,
147
151
tagArg ,
148
152
"--config" ,
@@ -342,26 +346,6 @@ function commitAndPushChanges(workspaceName, version, onlyPush) {
342
346
console . log ( "Successfully committed and pushed changes." ) ;
343
347
}
344
348
345
- /**
346
- * Verifies the current branch is main, then checks out a new release branch
347
- * and pushes an empty commit.
348
- *
349
- * @returns {void }
350
- * @throws {Error } If the current branch is not main.
351
- */
352
- function checkoutReleaseBranch ( ) {
353
- const currentBranch = execSync ( "git branch --show-current" ) . toString ( ) . trim ( ) ;
354
- if ( currentBranch === MAIN_BRANCH || currentBranch === RELEASE_BRANCH ) {
355
- console . log ( `Checking out '${ RELEASE_BRANCH } ' branch.` ) ;
356
- execSyncWithErrorHandling ( `git checkout -B ${ RELEASE_BRANCH } ` ) ;
357
- execSyncWithErrorHandling ( `git push -u origin ${ RELEASE_BRANCH } ` ) ;
358
- } else {
359
- throw new Error (
360
- `Current branch is not ${ MAIN_BRANCH } or ${ RELEASE_BRANCH } . Current branch: ${ currentBranch } `
361
- ) ;
362
- }
363
- }
364
-
365
349
/**
366
350
* Prompts the user for input and returns the input. This is used
367
351
* for requesting an OTP from the user for NPM 2FA.
@@ -428,7 +412,8 @@ async function main() {
428
412
"--bump-deps" ,
429
413
"Whether or not to bump other workspaces that depend on this one."
430
414
)
431
- . option ( "--tag <tag>" , "Optionally specify a tag to publish to." ) ;
415
+ . option ( "--tag <tag>" , "Optionally specify a tag to publish to." )
416
+ . option ( "--dry-run" , "Whether or not to run the release in dry-run mode." ) ;
432
417
433
418
program . parse ( ) ;
434
419
@@ -456,13 +441,10 @@ async function main() {
456
441
throw new Error ( `Could not find workspace ${ options . workspace } ` ) ;
457
442
}
458
443
459
- // Checkout new "release" branch & push
460
- checkoutReleaseBranch ( ) ;
461
-
462
444
// Run build, lint, tests
463
445
console . log ( "Running build, lint, and tests." ) ;
464
446
execSyncWithErrorHandling (
465
- `pnpm --filter ${ options . workspace } build lint test -- concurrency 1`
447
+ `pnpm --filter ${ options . workspace } --workspace- concurrency 1 build lint test `
466
448
) ;
467
449
console . log ( "Successfully ran build, lint, and tests." ) ;
468
450
@@ -473,7 +455,12 @@ async function main() {
473
455
const preReleaseVersion = getWorkspaceVersion ( matchingWorkspace . dir ) ;
474
456
475
457
// Run `release-it` on workspace
476
- await runPnpmRelease ( matchingWorkspace . dir , npm2FACode , options . tag ) ;
458
+ await runPnpmRelease (
459
+ matchingWorkspace . dir ,
460
+ npm2FACode ,
461
+ options . tag ,
462
+ options . dryRun
463
+ ) ;
477
464
478
465
const hasStaged = hasStagedChanges ( ) ;
479
466
const hasUnCommitted = hasUncommittedChanges ( ) ;
0 commit comments