From 3a79ec02bffd8ecde5f84225bc24c7fc1ee3da8a Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Wed, 1 May 2024 18:17:48 -0700 Subject: [PATCH] scripts[patch]: Ability to add additional gitignore paths to lc config (#5270) --- libs/langchain-scripts/bin/build | 13 ++++++++++++- libs/langchain-scripts/package.json | 2 +- libs/langchain-scripts/src/types.ts | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libs/langchain-scripts/bin/build b/libs/langchain-scripts/bin/build index b960d786f4df..5b93d883c177 100755 --- a/libs/langchain-scripts/bin/build +++ b/libs/langchain-scripts/bin/build @@ -434,6 +434,8 @@ const updateConfig = ({ requiresOptionalDependency, /** @type {boolean} */ shouldTestExports, + /** @type {Array | undefined} */ + additionalGitignorePaths = [], }) => { const generatedFiles = generateFiles(entrypoints); const filenames = Object.keys(generatedFiles); @@ -468,10 +470,12 @@ const updateConfig = ({ fs.writeFileSync(filename, content); }); + const gitignorePaths = [...filenames, ...DEFAULT_GITIGNORE_PATHS, ...(additionalGitignorePaths ? additionalGitignorePaths : [])]; + // Update .gitignore fs.writeFileSync( "./.gitignore", - `${filenames.join("\n")}\n${DEFAULT_GITIGNORE_PATHS.join("\n")}\n` + `${gitignorePaths.join("\n")}\n` ); if (shouldTestExports) { @@ -724,6 +728,11 @@ export function createEntrypoints({ * @type {boolean} */ shouldGenMaps, + /** + * Additional paths to add to the .gitignore file. + * @type {Array | undefined} + */ + additionalGitignorePaths, }) { if (isPre) { cleanGenerated({ entrypoints }); @@ -753,6 +762,7 @@ export function createEntrypoints({ deprecatedNodeOnly, requiresOptionalDependency, shouldTestExports, + additionalGitignorePaths, }); } } @@ -850,6 +860,7 @@ async function main() { absTsConfigPath: config.tsConfigPath, isPre, shouldGenMaps, + additionalGitignorePaths: config.additionalGitignorePaths, }); } diff --git a/libs/langchain-scripts/package.json b/libs/langchain-scripts/package.json index c077d0672d7e..00fc377359b6 100644 --- a/libs/langchain-scripts/package.json +++ b/libs/langchain-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@langchain/scripts", - "version": "0.0.12", + "version": "0.0.13", "description": "Shared scripts for LangChain.js", "type": "module", "engines": { diff --git a/libs/langchain-scripts/src/types.ts b/libs/langchain-scripts/src/types.ts index 2dd38375a1d6..64a43f749342 100644 --- a/libs/langchain-scripts/src/types.ts +++ b/libs/langchain-scripts/src/types.ts @@ -147,4 +147,10 @@ export interface LangChainConfig { * @returns {string} */ abs: (relativePath: string) => string; + /** + * Additional paths to add to the gitignore file. + * @default undefined + * @type {string[]} + */ + additionalGitignorePaths?: string[]; }