@@ -6,8 +6,7 @@ const { spawn } = require("child_process");
66const readline = require ( "readline" ) ;
77const semver = require ( "semver" ) ;
88
9- const RELEASE_BRANCH = "release" ;
10- const MAIN_BRANCH = "main" ;
9+ const MAIN_BRANCH = "v1" ;
1110
1211/**
1312 * Handles execSync errors and logs them in a readable format.
@@ -51,11 +50,7 @@ function getWorkspaceVersion(workspaceDirectory) {
5150 * @returns {Array<{ dir: string, packageJSON: Record<string, any>}> }
5251 */
5352function getAllWorkspaces ( ) {
54- const possibleWorkspaceDirectories = [
55- "./libs/*" ,
56- "./langchain" ,
57- "./langchain-core" ,
58- ] ;
53+ const possibleWorkspaceDirectories = [ "./libs/*" , "./libs/providers/*" ] ;
5954 const allWorkspaces = possibleWorkspaceDirectories . flatMap (
6055 ( workspaceDirectory ) => {
6156 if ( workspaceDirectory . endsWith ( "*" ) ) {
@@ -64,22 +59,30 @@ function getAllWorkspaces() {
6459 path . join ( process . cwd ( ) , workspaceDirectory . replace ( "*" , "" ) )
6560 ) ;
6661 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+ }
6770 return {
6871 dir : `${ workspaceDirectory . replace ( "*" , "" ) } ${ dir } ` ,
69- packageJSON : require ( path . join (
70- process . cwd ( ) ,
71- `${ workspaceDirectory . replace ( "*" , "" ) } ${ dir } ` ,
72- "package.json"
73- ) ) ,
72+ packageJSON : require ( packageJSONPath ) ,
7473 } ;
7574 } ) ;
76- return subDirs ;
75+ return subDirs . filter ( ( dir ) => dir !== null ) ;
7776 }
78- const packageJSON = require ( path . join (
77+ const packageJSONPath = path . join (
7978 process . cwd ( ) ,
8079 workspaceDirectory ,
8180 "package.json"
82- ) ) ;
81+ ) ;
82+ if ( ! fs . existsSync ( packageJSONPath ) ) {
83+ return null ;
84+ }
85+ const packageJSON = require ( packageJSONPath ) ;
8386 return {
8487 dir : workspaceDirectory ,
8588 packageJSON,
@@ -137,12 +140,13 @@ function updateDependencies(
137140 * @param {string | undefined } tag An optional tag to publish to.
138141 * @returns {Promise<void> }
139142 */
140- async function runPnpmRelease ( packageDirectory , npm2FACode , tag ) {
143+ async function runPnpmRelease ( packageDirectory , npm2FACode , tag , dryRun ) {
141144 return new Promise ( ( resolve , reject ) => {
142145 const workingDirectory = path . join ( process . cwd ( ) , packageDirectory ) ;
143146 const tagArg = tag ? `--npm.tag=${ tag } ` : "" ;
144147 const args = [
145148 "release-it" ,
149+ dryRun ? "--dry-run" : "" ,
146150 `--npm.otp=${ npm2FACode } ` ,
147151 tagArg ,
148152 "--config" ,
@@ -342,26 +346,6 @@ function commitAndPushChanges(workspaceName, version, onlyPush) {
342346 console . log ( "Successfully committed and pushed changes." ) ;
343347}
344348
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-
365349/**
366350 * Prompts the user for input and returns the input. This is used
367351 * for requesting an OTP from the user for NPM 2FA.
@@ -428,7 +412,8 @@ async function main() {
428412 "--bump-deps" ,
429413 "Whether or not to bump other workspaces that depend on this one."
430414 )
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." ) ;
432417
433418 program . parse ( ) ;
434419
@@ -456,13 +441,10 @@ async function main() {
456441 throw new Error ( `Could not find workspace ${ options . workspace } ` ) ;
457442 }
458443
459- // Checkout new "release" branch & push
460- checkoutReleaseBranch ( ) ;
461-
462444 // Run build, lint, tests
463445 console . log ( "Running build, lint, and tests." ) ;
464446 execSyncWithErrorHandling (
465- `pnpm --filter ${ options . workspace } build lint test -- concurrency 1`
447+ `pnpm --filter ${ options . workspace } --workspace- concurrency 1 build lint test `
466448 ) ;
467449 console . log ( "Successfully ran build, lint, and tests." ) ;
468450
@@ -473,7 +455,12 @@ async function main() {
473455 const preReleaseVersion = getWorkspaceVersion ( matchingWorkspace . dir ) ;
474456
475457 // 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+ ) ;
477464
478465 const hasStaged = hasStagedChanges ( ) ;
479466 const hasUnCommitted = hasUncommittedChanges ( ) ;
0 commit comments