mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 06:43:35 +00:00 
			
		
		
		
	Apply fixes
This commit is contained in:
		
							parent
							
								
									7406bf5e76
								
							
						
					
					
						commit
						9ddc512bc1
					
				@ -32,13 +32,13 @@ describe('cache-restore', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  function findCacheFolder(command: string) {
 | 
					  function findCacheFolder(command: string) {
 | 
				
			||||||
    switch (command) {
 | 
					    switch (command) {
 | 
				
			||||||
      case utils.npmGetCacheFolderCommand:
 | 
					      case 'npm config get cache':
 | 
				
			||||||
        return npmCachePath;
 | 
					        return npmCachePath;
 | 
				
			||||||
      case utils.pnpmGetCacheFolderCommand:
 | 
					      case 'pnpm store path --silent':
 | 
				
			||||||
        return pnpmCachePath;
 | 
					        return pnpmCachePath;
 | 
				
			||||||
      case utils.yarn1GetCacheFolderCommand:
 | 
					      case 'yarn cache dir':
 | 
				
			||||||
        return yarn1CachePath;
 | 
					        return yarn1CachePath;
 | 
				
			||||||
      case utils.yarn2GetCacheFolderCommand:
 | 
					      case 'yarn config get cacheFolder':
 | 
				
			||||||
        return yarn2CachePath;
 | 
					        return yarn2CachePath;
 | 
				
			||||||
      default:
 | 
					      default:
 | 
				
			||||||
        return 'packge/not/found';
 | 
					        return 'packge/not/found';
 | 
				
			||||||
 | 
				
			|||||||
@ -118,13 +118,10 @@ describe('run', () => {
 | 
				
			|||||||
      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Project directory "." derived from cache-dependency-path: ""'
 | 
					        'Consumed yarn version is 1.2.3 (working dir: "")'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Consumed yarn version is 1.2.3 (working dir: ".")'
 | 
					        'yarn\'s cache folder "/some/random/path/yarn1" configured for the root directory'
 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					 | 
				
			||||||
        'yarn\'s cache folder "/some/random/path/yarn1" configured for the directory "."'
 | 
					 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(infoSpy).toHaveBeenCalledWith(
 | 
					      expect(infoSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
					        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
				
			||||||
@ -145,13 +142,10 @@ describe('run', () => {
 | 
				
			|||||||
      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Project directory "." derived from cache-dependency-path: ""'
 | 
					        'Consumed yarn version is 2.2.3 (working dir: "")'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Consumed yarn version is 2.2.3 (working dir: ".")'
 | 
					        'yarn\'s cache folder "/some/random/path/yarn2" configured for the root directory'
 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					 | 
				
			||||||
        'yarn\'s cache folder "/some/random/path/yarn2" configured for the directory "."'
 | 
					 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(infoSpy).toHaveBeenCalledWith(
 | 
					      expect(infoSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
					        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
				
			||||||
@ -218,13 +212,10 @@ describe('run', () => {
 | 
				
			|||||||
      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Project directory "." derived from cache-dependency-path: ""'
 | 
					        'Consumed yarn version is 1.2.3 (working dir: "")'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Consumed yarn version is 1.2.3 (working dir: ".")'
 | 
					        'yarn\'s cache folder "/some/random/path/yarn1" configured for the root directory'
 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					 | 
				
			||||||
        'yarn\'s cache folder "/some/random/path/yarn1" configured for the directory "."'
 | 
					 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(infoSpy).not.toHaveBeenCalledWith(
 | 
					      expect(infoSpy).not.toHaveBeenCalledWith(
 | 
				
			||||||
        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
					        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
				
			||||||
@ -255,13 +246,10 @@ describe('run', () => {
 | 
				
			|||||||
      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getStateSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
					      expect(getCommandOutputSpy).toHaveBeenCalledTimes(2);
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Project directory "." derived from cache-dependency-path: ""'
 | 
					        'Consumed yarn version is 2.2.3 (working dir: "")'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					      expect(debugSpy).toHaveBeenCalledWith(
 | 
				
			||||||
        'Consumed yarn version is 2.2.3 (working dir: ".")'
 | 
					        'yarn\'s cache folder "/some/random/path/yarn2" configured for the root directory'
 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(debugSpy).toHaveBeenCalledWith(
 | 
					 | 
				
			||||||
        'yarn\'s cache folder "/some/random/path/yarn2" configured for the directory "."'
 | 
					 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      expect(infoSpy).not.toHaveBeenCalledWith(
 | 
					      expect(infoSpy).not.toHaveBeenCalledWith(
 | 
				
			||||||
        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
					        `Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
 | 
				
			||||||
 | 
				
			|||||||
@ -7,8 +7,7 @@ import {
 | 
				
			|||||||
  isCacheFeatureAvailable,
 | 
					  isCacheFeatureAvailable,
 | 
				
			||||||
  supportedPackageManagers,
 | 
					  supportedPackageManagers,
 | 
				
			||||||
  getCommandOutput,
 | 
					  getCommandOutput,
 | 
				
			||||||
  expandCacheDependencyPath,
 | 
					  memoizedCacheDependencies
 | 
				
			||||||
  expandedPatternsMemoized
 | 
					 | 
				
			||||||
} from '../src/cache-utils';
 | 
					} from '../src/cache-utils';
 | 
				
			||||||
import fs from 'fs';
 | 
					import fs from 'fs';
 | 
				
			||||||
import * as cacheUtils from '../src/cache-utils';
 | 
					import * as cacheUtils from '../src/cache-utils';
 | 
				
			||||||
@ -106,8 +105,8 @@ describe('cache-utils', () => {
 | 
				
			|||||||
          MockGlobber.create(['/foo', '/bar'])
 | 
					          MockGlobber.create(['/foo', '/bar'])
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      Object.keys(expandedPatternsMemoized).forEach(
 | 
					      Object.keys(memoizedCacheDependencies).forEach(
 | 
				
			||||||
        key => delete expandedPatternsMemoized[key]
 | 
					        key => delete memoizedCacheDependencies[key]
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -117,44 +116,6 @@ describe('cache-utils', () => {
 | 
				
			|||||||
      globCreateSpy.mockRestore();
 | 
					      globCreateSpy.mockRestore();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('expandCacheDependencyPath should handle one line', async () => {
 | 
					 | 
				
			||||||
      expect(await expandCacheDependencyPath('one')).toEqual(['one']);
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    it('expandCacheDependencyPath should handle one line glob', async () => {
 | 
					 | 
				
			||||||
      globCreateSpy.mockImplementation(
 | 
					 | 
				
			||||||
        (pattern: string): Promise<Globber> =>
 | 
					 | 
				
			||||||
          MockGlobber.create(['one', 'two'])
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(await expandCacheDependencyPath('**')).toEqual(['one', 'two']);
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    it('expandCacheDependencyPath should handle multiple lines', async () => {
 | 
					 | 
				
			||||||
      const lines = `
 | 
					 | 
				
			||||||
          one
 | 
					 | 
				
			||||||
two
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          `;
 | 
					 | 
				
			||||||
      expect(await expandCacheDependencyPath(lines)).toEqual(['one', 'two']);
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    it('expandCacheDependencyPath should handle multiple globs', async () => {
 | 
					 | 
				
			||||||
      const lines = `
 | 
					 | 
				
			||||||
          one
 | 
					 | 
				
			||||||
**
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          `;
 | 
					 | 
				
			||||||
      globCreateSpy.mockImplementation(
 | 
					 | 
				
			||||||
        (pattern: string): Promise<Globber> =>
 | 
					 | 
				
			||||||
          MockGlobber.create(['two', 'three'])
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      expect(await expandCacheDependencyPath(lines)).toEqual([
 | 
					 | 
				
			||||||
        'one',
 | 
					 | 
				
			||||||
        'two',
 | 
					 | 
				
			||||||
        'three'
 | 
					 | 
				
			||||||
      ]);
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    it.each([
 | 
					    it.each([
 | 
				
			||||||
      [supportedPackageManagers.npm, ''],
 | 
					      [supportedPackageManagers.npm, ''],
 | 
				
			||||||
      [supportedPackageManagers.npm, '/dir/file.lock'],
 | 
					      [supportedPackageManagers.npm, '/dir/file.lock'],
 | 
				
			||||||
@ -167,7 +128,7 @@ two
 | 
				
			|||||||
      async (packageManagerInfo, cacheDependency) => {
 | 
					      async (packageManagerInfo, cacheDependency) => {
 | 
				
			||||||
        getCommandOutputSpy.mockImplementation(() => 'foo');
 | 
					        getCommandOutputSpy.mockImplementation(() => 'foo');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const dirs = await cacheUtils.getCacheDirectoriesPaths(
 | 
					        const dirs = await cacheUtils.getCacheDirectories(
 | 
				
			||||||
          packageManagerInfo,
 | 
					          packageManagerInfo,
 | 
				
			||||||
          cacheDependency
 | 
					          cacheDependency
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
@ -181,7 +142,7 @@ two
 | 
				
			|||||||
    it('getCacheDirectoriesPaths should return one dir for yarn without cacheDependency', async () => {
 | 
					    it('getCacheDirectoriesPaths should return one dir for yarn without cacheDependency', async () => {
 | 
				
			||||||
      getCommandOutputSpy.mockImplementation(() => 'foo');
 | 
					      getCommandOutputSpy.mockImplementation(() => 'foo');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const dirs = await cacheUtils.getCacheDirectoriesPaths(
 | 
					      const dirs = await cacheUtils.getCacheDirectories(
 | 
				
			||||||
        supportedPackageManagers.yarn,
 | 
					        supportedPackageManagers.yarn,
 | 
				
			||||||
        ''
 | 
					        ''
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
@ -208,10 +169,7 @@ two
 | 
				
			|||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await expect(
 | 
					        await expect(
 | 
				
			||||||
          cacheUtils.getCacheDirectoriesPaths(
 | 
					          cacheUtils.getCacheDirectories(packageManagerInfo, cacheDependency)
 | 
				
			||||||
            packageManagerInfo,
 | 
					 | 
				
			||||||
            cacheDependency
 | 
					 | 
				
			||||||
          )
 | 
					 | 
				
			||||||
        ).rejects.toThrow(); //'Could not get cache folder path for /dir');
 | 
					        ).rejects.toThrow(); //'Could not get cache folder path for /dir');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
@ -234,10 +192,7 @@ two
 | 
				
			|||||||
        }));
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await expect(
 | 
					        await expect(
 | 
				
			||||||
          cacheUtils.getCacheDirectoriesPaths(
 | 
					          cacheUtils.getCacheDirectories(packageManagerInfo, cacheDependency)
 | 
				
			||||||
            packageManagerInfo,
 | 
					 | 
				
			||||||
            cacheDependency
 | 
					 | 
				
			||||||
          )
 | 
					 | 
				
			||||||
        ).rejects.toThrow(); //'Could not get cache folder path for /dir');
 | 
					        ).rejects.toThrow(); //'Could not get cache folder path for /dir');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
@ -248,7 +203,7 @@ two
 | 
				
			|||||||
        getCommandOutputSpy.mockImplementationOnce(() => version);
 | 
					        getCommandOutputSpy.mockImplementationOnce(() => version);
 | 
				
			||||||
        getCommandOutputSpy.mockImplementationOnce(() => `foo${version}`);
 | 
					        getCommandOutputSpy.mockImplementationOnce(() => `foo${version}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const dirs = await cacheUtils.getCacheDirectoriesPaths(
 | 
					        const dirs = await cacheUtils.getCacheDirectories(
 | 
				
			||||||
          supportedPackageManagers.yarn,
 | 
					          supportedPackageManagers.yarn,
 | 
				
			||||||
          ''
 | 
					          ''
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
@ -268,7 +223,7 @@ two
 | 
				
			|||||||
            MockGlobber.create(['/tmp/dir1/file', '/tmp/dir2/file'])
 | 
					            MockGlobber.create(['/tmp/dir1/file', '/tmp/dir2/file'])
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const dirs = await cacheUtils.getCacheDirectoriesPaths(
 | 
					        const dirs = await cacheUtils.getCacheDirectories(
 | 
				
			||||||
          supportedPackageManagers.yarn,
 | 
					          supportedPackageManagers.yarn,
 | 
				
			||||||
          '/tmp/**/file'
 | 
					          '/tmp/**/file'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
@ -292,7 +247,7 @@ two
 | 
				
			|||||||
            ])
 | 
					            ])
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const dirs = await cacheUtils.getCacheDirectoriesPaths(
 | 
					        const dirs = await cacheUtils.getCacheDirectories(
 | 
				
			||||||
          supportedPackageManagers.yarn,
 | 
					          supportedPackageManagers.yarn,
 | 
				
			||||||
          '/tmp/**/file'
 | 
					          '/tmp/**/file'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
@ -318,7 +273,7 @@ two
 | 
				
			|||||||
            ])
 | 
					            ])
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const dirs = await cacheUtils.getCacheDirectoriesPaths(
 | 
					        const dirs = await cacheUtils.getCacheDirectories(
 | 
				
			||||||
          supportedPackageManagers.yarn,
 | 
					          supportedPackageManagers.yarn,
 | 
				
			||||||
          '/tmp/**/file'
 | 
					          '/tmp/**/file'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
@ -367,13 +322,18 @@ two
 | 
				
			|||||||
          `;
 | 
					          `;
 | 
				
			||||||
        globCreateSpy.mockImplementation(
 | 
					        globCreateSpy.mockImplementation(
 | 
				
			||||||
          (pattern: string): Promise<Globber> =>
 | 
					          (pattern: string): Promise<Globber> =>
 | 
				
			||||||
            MockGlobber.create(['/tmp/dir3/file', '/tmp/dir4/file'])
 | 
					            MockGlobber.create([
 | 
				
			||||||
 | 
					              '/tmp/dir1/file',
 | 
				
			||||||
 | 
					              '/tmp/dir2/file',
 | 
				
			||||||
 | 
					              '/tmp/dir3/file',
 | 
				
			||||||
 | 
					              '/tmp/dir4/file'
 | 
				
			||||||
 | 
					            ])
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        let dirNo = 1;
 | 
					        let dirNo = 1;
 | 
				
			||||||
        getCommandOutputSpy.mockImplementation((command: string) =>
 | 
					        getCommandOutputSpy.mockImplementation((command: string) =>
 | 
				
			||||||
          command.includes('version') ? version : `file_${version}_${dirNo++}`
 | 
					          command.includes('version') ? version : `file_${version}_${dirNo++}`
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        const dirs = await cacheUtils.getCacheDirectoriesPaths(
 | 
					        const dirs = await cacheUtils.getCacheDirectories(
 | 
				
			||||||
          supportedPackageManagers.yarn,
 | 
					          supportedPackageManagers.yarn,
 | 
				
			||||||
          cacheDependencyPath
 | 
					          cacheDependencyPath
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										143
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										143
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							@ -60378,7 +60378,7 @@ const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, func
 | 
				
			|||||||
    // TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
 | 
					    // TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
 | 
				
			||||||
    //       export declare function getInput(name: string, options?: InputOptions): string;
 | 
					    //       export declare function getInput(name: string, options?: InputOptions): string;
 | 
				
			||||||
    const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
 | 
					    const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
 | 
				
			||||||
    const cachePaths = yield cache_utils_1.getCacheDirectoriesPaths(packageManagerInfo, cacheDependencyPath);
 | 
					    const cachePaths = yield cache_utils_1.getCacheDirectories(packageManagerInfo, cacheDependencyPath);
 | 
				
			||||||
    if (cachePaths.length === 0) {
 | 
					    if (cachePaths.length === 0) {
 | 
				
			||||||
        throw new Error(`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`);
 | 
					        throw new Error(`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -60434,38 +60434,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
				
			|||||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
					    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
					Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
				
			||||||
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoriesPaths = exports.expandCacheDependencyPath = exports.expandedPatternsMemoized = exports.getPackageManagerInfo = exports.getCommandOutputGuarded = exports.getCommandOutput = exports.supportedPackageManagers = exports.yarn2GetCacheFolderCommand = exports.yarn1GetCacheFolderCommand = exports.pnpmGetCacheFolderCommand = exports.npmGetCacheFolderCommand = void 0;
 | 
					exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectories = exports.memoizedCacheDependencies = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
 | 
				
			||||||
const core = __importStar(__nccwpck_require__(2186));
 | 
					const core = __importStar(__nccwpck_require__(2186));
 | 
				
			||||||
const exec = __importStar(__nccwpck_require__(1514));
 | 
					const exec = __importStar(__nccwpck_require__(1514));
 | 
				
			||||||
const cache = __importStar(__nccwpck_require__(7799));
 | 
					const cache = __importStar(__nccwpck_require__(7799));
 | 
				
			||||||
const glob = __importStar(__nccwpck_require__(8090));
 | 
					const glob = __importStar(__nccwpck_require__(8090));
 | 
				
			||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
					const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
				
			||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
					const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
				
			||||||
// for testing purposes
 | 
					 | 
				
			||||||
exports.npmGetCacheFolderCommand = 'npm config get cache';
 | 
					 | 
				
			||||||
exports.pnpmGetCacheFolderCommand = 'pnpm store path --silent';
 | 
					 | 
				
			||||||
exports.yarn1GetCacheFolderCommand = 'yarn cache dir';
 | 
					 | 
				
			||||||
exports.yarn2GetCacheFolderCommand = 'yarn config get cacheFolder';
 | 
					 | 
				
			||||||
exports.supportedPackageManagers = {
 | 
					exports.supportedPackageManagers = {
 | 
				
			||||||
    npm: {
 | 
					    npm: {
 | 
				
			||||||
        name: 'npm',
 | 
					        name: 'npm',
 | 
				
			||||||
        lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
 | 
					        lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
 | 
				
			||||||
        getCacheFolderPath: () => exports.getCommandOutputGuarded(exports.npmGetCacheFolderCommand, 'Could not get npm cache folder path')
 | 
					        getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path')
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    pnpm: {
 | 
					    pnpm: {
 | 
				
			||||||
        name: 'pnpm',
 | 
					        name: 'pnpm',
 | 
				
			||||||
        lockFilePatterns: ['pnpm-lock.yaml'],
 | 
					        lockFilePatterns: ['pnpm-lock.yaml'],
 | 
				
			||||||
        getCacheFolderPath: () => exports.getCommandOutputGuarded(exports.pnpmGetCacheFolderCommand, 'Could not get pnpm cache folder path')
 | 
					        getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path')
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    yarn: {
 | 
					    yarn: {
 | 
				
			||||||
        name: 'yarn',
 | 
					        name: 'yarn',
 | 
				
			||||||
        lockFilePatterns: ['yarn.lock'],
 | 
					        lockFilePatterns: ['yarn.lock'],
 | 
				
			||||||
        getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					        getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
            const yarnVersion = yield exports.getCommandOutputGuarded(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
 | 
					            const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
 | 
				
			||||||
            core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir}")`);
 | 
					            core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
 | 
				
			||||||
            const stdOut = yarnVersion.startsWith('1.')
 | 
					            const stdOut = yarnVersion.startsWith('1.')
 | 
				
			||||||
                ? yield exports.getCommandOutput(exports.yarn1GetCacheFolderCommand, projectDir)
 | 
					                ? yield exports.getCommandOutput('yarn cache dir', projectDir)
 | 
				
			||||||
                : yield exports.getCommandOutput(exports.yarn2GetCacheFolderCommand, projectDir);
 | 
					                : yield exports.getCommandOutput('yarn config get cacheFolder', projectDir);
 | 
				
			||||||
            if (!stdOut) {
 | 
					            if (!stdOut) {
 | 
				
			||||||
                throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
 | 
					                throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -60484,14 +60479,14 @@ const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0,
 | 
				
			|||||||
    return stdout.trim();
 | 
					    return stdout.trim();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
exports.getCommandOutput = getCommandOutput;
 | 
					exports.getCommandOutput = getCommandOutput;
 | 
				
			||||||
const getCommandOutputGuarded = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const stdOut = exports.getCommandOutput(toolCommand, cwd);
 | 
					    const stdOut = exports.getCommandOutput(toolCommand, cwd);
 | 
				
			||||||
    if (!stdOut) {
 | 
					    if (!stdOut) {
 | 
				
			||||||
        throw new Error(error);
 | 
					        throw new Error(error);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return stdOut;
 | 
					    return stdOut;
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
exports.getCommandOutputGuarded = getCommandOutputGuarded;
 | 
					exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty;
 | 
				
			||||||
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    if (packageManager === 'npm') {
 | 
					    if (packageManager === 'npm') {
 | 
				
			||||||
        return exports.supportedPackageManagers.npm;
 | 
					        return exports.supportedPackageManagers.npm;
 | 
				
			||||||
@ -60511,54 +60506,7 @@ exports.getPackageManagerInfo = getPackageManagerInfo;
 | 
				
			|||||||
 * glob expanding memoized because it involves potentially very deep
 | 
					 * glob expanding memoized because it involves potentially very deep
 | 
				
			||||||
 * traversing through the directories tree
 | 
					 * traversing through the directories tree
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
exports.expandedPatternsMemoized = {};
 | 
					exports.memoizedCacheDependencies = {};
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Wrapper around `glob.create(pattern).glob()` with the memoization
 | 
					 | 
				
			||||||
 * @param pattern is expected to be a globed path
 | 
					 | 
				
			||||||
 * @return list of files or directories expanded from glob
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const globPatternToArray = (pattern) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					 | 
				
			||||||
    const memoized = exports.expandedPatternsMemoized[pattern];
 | 
					 | 
				
			||||||
    if (memoized)
 | 
					 | 
				
			||||||
        return Promise.resolve(memoized);
 | 
					 | 
				
			||||||
    const globber = yield glob.create(pattern);
 | 
					 | 
				
			||||||
    const expanded = yield globber.glob();
 | 
					 | 
				
			||||||
    exports.expandedPatternsMemoized[pattern] = expanded;
 | 
					 | 
				
			||||||
    return expanded;
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Expands (converts) the string input `cache-dependency-path` to list of files' paths
 | 
					 | 
				
			||||||
 * First it breaks the input by new lines and then expand glob patterns if any
 | 
					 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const expandCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					 | 
				
			||||||
    const multilinePaths = cacheDependencyPath
 | 
					 | 
				
			||||||
        .split(/\r?\n/)
 | 
					 | 
				
			||||||
        .map(path => path.trim())
 | 
					 | 
				
			||||||
        .filter(path => Boolean(path));
 | 
					 | 
				
			||||||
    const expandedPathsPromises = multilinePaths.map(path => path.includes('*') ? globPatternToArray(path) : Promise.resolve([path]));
 | 
					 | 
				
			||||||
    const expandedPaths = yield Promise.all(expandedPathsPromises);
 | 
					 | 
				
			||||||
    return expandedPaths.length === 0 ? [''] : expandedPaths.flat();
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
exports.expandCacheDependencyPath = expandCacheDependencyPath;
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Converts dependency file path to the directory it resides in and ensures the directory exists
 | 
					 | 
				
			||||||
 * @param cacheDependencyPath - a file name path
 | 
					 | 
				
			||||||
 * @return either directory containing the file or null
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const cacheDependencyPathToProjectDirectory = (cacheDependencyPath) => {
 | 
					 | 
				
			||||||
    const projectDirectory = path_1.default.dirname(cacheDependencyPath);
 | 
					 | 
				
			||||||
    if (fs_1.default.existsSync(projectDirectory) &&
 | 
					 | 
				
			||||||
        fs_1.default.lstatSync(projectDirectory).isDirectory()) {
 | 
					 | 
				
			||||||
        core.debug(`Project directory "${projectDirectory}" derived from cache-dependency-path: "${cacheDependencyPath}"`);
 | 
					 | 
				
			||||||
        return projectDirectory;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
        core.debug(`No project directory found for cache-dependency-path: "${cacheDependencyPath}", will be skipped`);
 | 
					 | 
				
			||||||
        return null;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Expands (converts) the string input `cache-dependency-path` to list of directories that
 | 
					 * Expands (converts) the string input `cache-dependency-path` to list of directories that
 | 
				
			||||||
 * may be project roots
 | 
					 * may be project roots
 | 
				
			||||||
@ -60566,69 +60514,76 @@ const cacheDependencyPathToProjectDirectory = (cacheDependencyPath) => {
 | 
				
			|||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of directories and possible
 | 
					 * @return list of directories and possible
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheDependencyPathToProjectsDirectories = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const cacheDependenciesPaths = yield exports.expandCacheDependencyPath(cacheDependencyPath);
 | 
					    let cacheDependenciesPaths;
 | 
				
			||||||
 | 
					    // memoize unglobbed paths to avoid traversing FS
 | 
				
			||||||
 | 
					    const memoized = exports.memoizedCacheDependencies[cacheDependencyPath];
 | 
				
			||||||
 | 
					    if (memoized) {
 | 
				
			||||||
 | 
					        cacheDependenciesPaths = memoized;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					        cacheDependenciesPaths = (yield glob
 | 
				
			||||||
 | 
					            .create(cacheDependencyPath)
 | 
				
			||||||
 | 
					            .then(globber => globber.glob())) || [''];
 | 
				
			||||||
 | 
					        exports.memoizedCacheDependencies[cacheDependencyPath] = cacheDependenciesPaths;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    const existingDirectories = cacheDependenciesPaths
 | 
					    const existingDirectories = cacheDependenciesPaths
 | 
				
			||||||
        .map(cacheDependencyPath => cacheDependencyPathToProjectDirectory(cacheDependencyPath))
 | 
					        .map(cacheDependencyPath => path_1.default.dirname(cacheDependencyPath))
 | 
				
			||||||
        .filter(path => path !== null);
 | 
					        // uniq in order to do not traverse the same directories during the further processing
 | 
				
			||||||
 | 
					        .filter((cachePath, i, result) => cachePath != null && result.indexOf(cachePath) === i)
 | 
				
			||||||
 | 
					        .filter(directory => fs_1.default.existsSync(directory) && fs_1.default.lstatSync(directory).isDirectory());
 | 
				
			||||||
    // if user explicitly pointed out some file, but it does not exist it is definitely
 | 
					    // if user explicitly pointed out some file, but it does not exist it is definitely
 | 
				
			||||||
    // not he wanted, thus we should throw an error not trying to workaround with unexpected
 | 
					    // not he wanted, thus we should throw an error not trying to workaround with unexpected
 | 
				
			||||||
    // result to the whole build
 | 
					    // result to the whole build
 | 
				
			||||||
    if (existingDirectories.length === 0)
 | 
					    if (existingDirectories.length === 0)
 | 
				
			||||||
        throw Error('No existing directories found containing `cache-dependency-path`="${cacheDependencyPath}"');
 | 
					        throw Error('No existing directories found containing `cache-dependency-path`="${cacheDependencyPath}"');
 | 
				
			||||||
    // uniq in order to do not traverse the same directories during the further processing
 | 
					    return existingDirectories;
 | 
				
			||||||
    return existingDirectories.filter((cachePath, i, result) => cachePath != null && result.indexOf(cachePath) === i);
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Utility function to be used from within `map`
 | 
					 * Finds the cache directories configured for the repo if cache-dependency-path is not empty
 | 
				
			||||||
 * Finds the cache directories configured for the project directory
 | 
					 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 | 
				
			||||||
 * @param projectDirectory - the string pointing out to a project dir (i.e. directory with its own .yarnrc)
 | 
					 | 
				
			||||||
 * @return list of directories to be cached according to the project configuration in the directory
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const projectDirectoryToCacheFolderPath = (packageManagerInfo, projectDirectory) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					 | 
				
			||||||
    const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory);
 | 
					 | 
				
			||||||
    core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
 | 
					 | 
				
			||||||
    return cacheFolderPath;
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Top-entry function to find the cache directories configured for the repo if cache-dependency-path is not empty
 | 
					 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
				
			||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheDependencyPathToCacheFoldersPaths = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const projectDirectories = yield cacheDependencyPathToProjectsDirectories(cacheDependencyPath);
 | 
					    const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
 | 
				
			||||||
    const cacheFoldersPaths = yield Promise.all(projectDirectories.map(projectDirectory => projectDirectoryToCacheFolderPath(packageManagerInfo, projectDirectory)));
 | 
					    const cacheFoldersPaths = yield Promise.all(projectDirectories.map(projectDirectory => packageManagerInfo
 | 
				
			||||||
 | 
					        .getCacheFolderPath(projectDirectory)
 | 
				
			||||||
 | 
					        .then(cacheFolderPath => {
 | 
				
			||||||
 | 
					        core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
 | 
				
			||||||
 | 
					        return cacheFolderPath;
 | 
				
			||||||
 | 
					    })));
 | 
				
			||||||
    // uniq in order to do not cache the same directories twice
 | 
					    // uniq in order to do not cache the same directories twice
 | 
				
			||||||
    return cacheFoldersPaths.filter((cachePath, i, result) => result.indexOf(cachePath) === i);
 | 
					    return cacheFoldersPaths.filter((cachePath, i, result) => result.indexOf(cachePath) === i);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Top-entry function to find the cache directories configured for the repo if cache-dependency-path is empty
 | 
					 * Finds the cache directories configured for the repo ignoring cache-dependency-path
 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheFoldersPathsForRoot = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
 | 
					    const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
 | 
				
			||||||
    core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
 | 
					    core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
 | 
				
			||||||
    return [cacheFolderPath];
 | 
					    return [cacheFolderPath];
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Main function to find the cache directories configured for the repo
 | 
					 * A function to find the cache directories configured for the repo
 | 
				
			||||||
 * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
 | 
					 * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
				
			||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const getCacheDirectoriesPaths = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    // TODO: multiple directories limited to yarn so far
 | 
					    // For yarn, if cacheDependencyPath is set, ask information about cache folders in each project
 | 
				
			||||||
    return packageManagerInfo === exports.supportedPackageManagers.yarn
 | 
					    // folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488
 | 
				
			||||||
        ? cacheDependencyPathToCacheFoldersPaths(packageManagerInfo, cacheDependencyPath)
 | 
					    if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
 | 
				
			||||||
        : cacheFoldersPathsForRoot(packageManagerInfo);
 | 
					        return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return getCacheDirectoriesForRootProject(packageManagerInfo);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
exports.getCacheDirectoriesPaths = getCacheDirectoriesPaths;
 | 
					exports.getCacheDirectories = getCacheDirectories;
 | 
				
			||||||
function isGhes() {
 | 
					function isGhes() {
 | 
				
			||||||
    const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
 | 
					    const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
 | 
				
			||||||
    return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 | 
					    return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										143
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										143
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -71144,7 +71144,7 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
 | 
				
			|||||||
        throw new Error(`Caching for '${packageManager}' is not supported`);
 | 
					        throw new Error(`Caching for '${packageManager}' is not supported`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const platform = process.env.RUNNER_OS;
 | 
					    const platform = process.env.RUNNER_OS;
 | 
				
			||||||
    const cachePaths = yield cache_utils_1.getCacheDirectoriesPaths(packageManagerInfo, cacheDependencyPath);
 | 
					    const cachePaths = yield cache_utils_1.getCacheDirectories(packageManagerInfo, cacheDependencyPath);
 | 
				
			||||||
    const lockFilePath = cacheDependencyPath
 | 
					    const lockFilePath = cacheDependencyPath
 | 
				
			||||||
        ? cacheDependencyPath
 | 
					        ? cacheDependencyPath
 | 
				
			||||||
        : findLockFile(packageManagerInfo);
 | 
					        : findLockFile(packageManagerInfo);
 | 
				
			||||||
@ -71216,38 +71216,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
 | 
				
			|||||||
    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
					    return (mod && mod.__esModule) ? mod : { "default": mod };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
					Object.defineProperty(exports, "__esModule", ({ value: true }));
 | 
				
			||||||
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoriesPaths = exports.expandCacheDependencyPath = exports.expandedPatternsMemoized = exports.getPackageManagerInfo = exports.getCommandOutputGuarded = exports.getCommandOutput = exports.supportedPackageManagers = exports.yarn2GetCacheFolderCommand = exports.yarn1GetCacheFolderCommand = exports.pnpmGetCacheFolderCommand = exports.npmGetCacheFolderCommand = void 0;
 | 
					exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectories = exports.memoizedCacheDependencies = exports.getPackageManagerInfo = exports.getCommandOutputNotEmpty = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
 | 
				
			||||||
const core = __importStar(__nccwpck_require__(2186));
 | 
					const core = __importStar(__nccwpck_require__(2186));
 | 
				
			||||||
const exec = __importStar(__nccwpck_require__(1514));
 | 
					const exec = __importStar(__nccwpck_require__(1514));
 | 
				
			||||||
const cache = __importStar(__nccwpck_require__(7799));
 | 
					const cache = __importStar(__nccwpck_require__(7799));
 | 
				
			||||||
const glob = __importStar(__nccwpck_require__(8090));
 | 
					const glob = __importStar(__nccwpck_require__(8090));
 | 
				
			||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
					const path_1 = __importDefault(__nccwpck_require__(1017));
 | 
				
			||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
					const fs_1 = __importDefault(__nccwpck_require__(7147));
 | 
				
			||||||
// for testing purposes
 | 
					 | 
				
			||||||
exports.npmGetCacheFolderCommand = 'npm config get cache';
 | 
					 | 
				
			||||||
exports.pnpmGetCacheFolderCommand = 'pnpm store path --silent';
 | 
					 | 
				
			||||||
exports.yarn1GetCacheFolderCommand = 'yarn cache dir';
 | 
					 | 
				
			||||||
exports.yarn2GetCacheFolderCommand = 'yarn config get cacheFolder';
 | 
					 | 
				
			||||||
exports.supportedPackageManagers = {
 | 
					exports.supportedPackageManagers = {
 | 
				
			||||||
    npm: {
 | 
					    npm: {
 | 
				
			||||||
        name: 'npm',
 | 
					        name: 'npm',
 | 
				
			||||||
        lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
 | 
					        lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
 | 
				
			||||||
        getCacheFolderPath: () => exports.getCommandOutputGuarded(exports.npmGetCacheFolderCommand, 'Could not get npm cache folder path')
 | 
					        getCacheFolderPath: () => exports.getCommandOutputNotEmpty('npm config get cache', 'Could not get npm cache folder path')
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    pnpm: {
 | 
					    pnpm: {
 | 
				
			||||||
        name: 'pnpm',
 | 
					        name: 'pnpm',
 | 
				
			||||||
        lockFilePatterns: ['pnpm-lock.yaml'],
 | 
					        lockFilePatterns: ['pnpm-lock.yaml'],
 | 
				
			||||||
        getCacheFolderPath: () => exports.getCommandOutputGuarded(exports.pnpmGetCacheFolderCommand, 'Could not get pnpm cache folder path')
 | 
					        getCacheFolderPath: () => exports.getCommandOutputNotEmpty('pnpm store path --silent', 'Could not get pnpm cache folder path')
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    yarn: {
 | 
					    yarn: {
 | 
				
			||||||
        name: 'yarn',
 | 
					        name: 'yarn',
 | 
				
			||||||
        lockFilePatterns: ['yarn.lock'],
 | 
					        lockFilePatterns: ['yarn.lock'],
 | 
				
			||||||
        getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					        getCacheFolderPath: (projectDir) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
            const yarnVersion = yield exports.getCommandOutputGuarded(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
 | 
					            const yarnVersion = yield exports.getCommandOutputNotEmpty(`yarn --version`, 'Could not retrieve version of yarn', projectDir);
 | 
				
			||||||
            core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir}")`);
 | 
					            core.debug(`Consumed yarn version is ${yarnVersion} (working dir: "${projectDir || ''}")`);
 | 
				
			||||||
            const stdOut = yarnVersion.startsWith('1.')
 | 
					            const stdOut = yarnVersion.startsWith('1.')
 | 
				
			||||||
                ? yield exports.getCommandOutput(exports.yarn1GetCacheFolderCommand, projectDir)
 | 
					                ? yield exports.getCommandOutput('yarn cache dir', projectDir)
 | 
				
			||||||
                : yield exports.getCommandOutput(exports.yarn2GetCacheFolderCommand, projectDir);
 | 
					                : yield exports.getCommandOutput('yarn config get cacheFolder', projectDir);
 | 
				
			||||||
            if (!stdOut) {
 | 
					            if (!stdOut) {
 | 
				
			||||||
                throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
 | 
					                throw new Error(`Could not get yarn cache folder path for ${projectDir}`);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -71266,14 +71261,14 @@ const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0,
 | 
				
			|||||||
    return stdout.trim();
 | 
					    return stdout.trim();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
exports.getCommandOutput = getCommandOutput;
 | 
					exports.getCommandOutput = getCommandOutput;
 | 
				
			||||||
const getCommandOutputGuarded = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCommandOutputNotEmpty = (toolCommand, error, cwd) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const stdOut = exports.getCommandOutput(toolCommand, cwd);
 | 
					    const stdOut = exports.getCommandOutput(toolCommand, cwd);
 | 
				
			||||||
    if (!stdOut) {
 | 
					    if (!stdOut) {
 | 
				
			||||||
        throw new Error(error);
 | 
					        throw new Error(error);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return stdOut;
 | 
					    return stdOut;
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
exports.getCommandOutputGuarded = getCommandOutputGuarded;
 | 
					exports.getCommandOutputNotEmpty = getCommandOutputNotEmpty;
 | 
				
			||||||
const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    if (packageManager === 'npm') {
 | 
					    if (packageManager === 'npm') {
 | 
				
			||||||
        return exports.supportedPackageManagers.npm;
 | 
					        return exports.supportedPackageManagers.npm;
 | 
				
			||||||
@ -71293,54 +71288,7 @@ exports.getPackageManagerInfo = getPackageManagerInfo;
 | 
				
			|||||||
 * glob expanding memoized because it involves potentially very deep
 | 
					 * glob expanding memoized because it involves potentially very deep
 | 
				
			||||||
 * traversing through the directories tree
 | 
					 * traversing through the directories tree
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
exports.expandedPatternsMemoized = {};
 | 
					exports.memoizedCacheDependencies = {};
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Wrapper around `glob.create(pattern).glob()` with the memoization
 | 
					 | 
				
			||||||
 * @param pattern is expected to be a globed path
 | 
					 | 
				
			||||||
 * @return list of files or directories expanded from glob
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const globPatternToArray = (pattern) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					 | 
				
			||||||
    const memoized = exports.expandedPatternsMemoized[pattern];
 | 
					 | 
				
			||||||
    if (memoized)
 | 
					 | 
				
			||||||
        return Promise.resolve(memoized);
 | 
					 | 
				
			||||||
    const globber = yield glob.create(pattern);
 | 
					 | 
				
			||||||
    const expanded = yield globber.glob();
 | 
					 | 
				
			||||||
    exports.expandedPatternsMemoized[pattern] = expanded;
 | 
					 | 
				
			||||||
    return expanded;
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Expands (converts) the string input `cache-dependency-path` to list of files' paths
 | 
					 | 
				
			||||||
 * First it breaks the input by new lines and then expand glob patterns if any
 | 
					 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const expandCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					 | 
				
			||||||
    const multilinePaths = cacheDependencyPath
 | 
					 | 
				
			||||||
        .split(/\r?\n/)
 | 
					 | 
				
			||||||
        .map(path => path.trim())
 | 
					 | 
				
			||||||
        .filter(path => Boolean(path));
 | 
					 | 
				
			||||||
    const expandedPathsPromises = multilinePaths.map(path => path.includes('*') ? globPatternToArray(path) : Promise.resolve([path]));
 | 
					 | 
				
			||||||
    const expandedPaths = yield Promise.all(expandedPathsPromises);
 | 
					 | 
				
			||||||
    return expandedPaths.length === 0 ? [''] : expandedPaths.flat();
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
exports.expandCacheDependencyPath = expandCacheDependencyPath;
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Converts dependency file path to the directory it resides in and ensures the directory exists
 | 
					 | 
				
			||||||
 * @param cacheDependencyPath - a file name path
 | 
					 | 
				
			||||||
 * @return either directory containing the file or null
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const cacheDependencyPathToProjectDirectory = (cacheDependencyPath) => {
 | 
					 | 
				
			||||||
    const projectDirectory = path_1.default.dirname(cacheDependencyPath);
 | 
					 | 
				
			||||||
    if (fs_1.default.existsSync(projectDirectory) &&
 | 
					 | 
				
			||||||
        fs_1.default.lstatSync(projectDirectory).isDirectory()) {
 | 
					 | 
				
			||||||
        core.debug(`Project directory "${projectDirectory}" derived from cache-dependency-path: "${cacheDependencyPath}"`);
 | 
					 | 
				
			||||||
        return projectDirectory;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
        core.debug(`No project directory found for cache-dependency-path: "${cacheDependencyPath}", will be skipped`);
 | 
					 | 
				
			||||||
        return null;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Expands (converts) the string input `cache-dependency-path` to list of directories that
 | 
					 * Expands (converts) the string input `cache-dependency-path` to list of directories that
 | 
				
			||||||
 * may be project roots
 | 
					 * may be project roots
 | 
				
			||||||
@ -71348,69 +71296,76 @@ const cacheDependencyPathToProjectDirectory = (cacheDependencyPath) => {
 | 
				
			|||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of directories and possible
 | 
					 * @return list of directories and possible
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheDependencyPathToProjectsDirectories = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const cacheDependenciesPaths = yield exports.expandCacheDependencyPath(cacheDependencyPath);
 | 
					    let cacheDependenciesPaths;
 | 
				
			||||||
 | 
					    // memoize unglobbed paths to avoid traversing FS
 | 
				
			||||||
 | 
					    const memoized = exports.memoizedCacheDependencies[cacheDependencyPath];
 | 
				
			||||||
 | 
					    if (memoized) {
 | 
				
			||||||
 | 
					        cacheDependenciesPaths = memoized;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					        cacheDependenciesPaths = (yield glob
 | 
				
			||||||
 | 
					            .create(cacheDependencyPath)
 | 
				
			||||||
 | 
					            .then(globber => globber.glob())) || [''];
 | 
				
			||||||
 | 
					        exports.memoizedCacheDependencies[cacheDependencyPath] = cacheDependenciesPaths;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    const existingDirectories = cacheDependenciesPaths
 | 
					    const existingDirectories = cacheDependenciesPaths
 | 
				
			||||||
        .map(cacheDependencyPath => cacheDependencyPathToProjectDirectory(cacheDependencyPath))
 | 
					        .map(cacheDependencyPath => path_1.default.dirname(cacheDependencyPath))
 | 
				
			||||||
        .filter(path => path !== null);
 | 
					        // uniq in order to do not traverse the same directories during the further processing
 | 
				
			||||||
 | 
					        .filter((cachePath, i, result) => cachePath != null && result.indexOf(cachePath) === i)
 | 
				
			||||||
 | 
					        .filter(directory => fs_1.default.existsSync(directory) && fs_1.default.lstatSync(directory).isDirectory());
 | 
				
			||||||
    // if user explicitly pointed out some file, but it does not exist it is definitely
 | 
					    // if user explicitly pointed out some file, but it does not exist it is definitely
 | 
				
			||||||
    // not he wanted, thus we should throw an error not trying to workaround with unexpected
 | 
					    // not he wanted, thus we should throw an error not trying to workaround with unexpected
 | 
				
			||||||
    // result to the whole build
 | 
					    // result to the whole build
 | 
				
			||||||
    if (existingDirectories.length === 0)
 | 
					    if (existingDirectories.length === 0)
 | 
				
			||||||
        throw Error('No existing directories found containing `cache-dependency-path`="${cacheDependencyPath}"');
 | 
					        throw Error('No existing directories found containing `cache-dependency-path`="${cacheDependencyPath}"');
 | 
				
			||||||
    // uniq in order to do not traverse the same directories during the further processing
 | 
					    return existingDirectories;
 | 
				
			||||||
    return existingDirectories.filter((cachePath, i, result) => cachePath != null && result.indexOf(cachePath) === i);
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Utility function to be used from within `map`
 | 
					 * Finds the cache directories configured for the repo if cache-dependency-path is not empty
 | 
				
			||||||
 * Finds the cache directories configured for the project directory
 | 
					 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 | 
				
			||||||
 * @param projectDirectory - the string pointing out to a project dir (i.e. directory with its own .yarnrc)
 | 
					 | 
				
			||||||
 * @return list of directories to be cached according to the project configuration in the directory
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const projectDirectoryToCacheFolderPath = (packageManagerInfo, projectDirectory) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					 | 
				
			||||||
    const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath(projectDirectory);
 | 
					 | 
				
			||||||
    core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
 | 
					 | 
				
			||||||
    return cacheFolderPath;
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Top-entry function to find the cache directories configured for the repo if cache-dependency-path is not empty
 | 
					 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
				
			||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheDependencyPathToCacheFoldersPaths = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const projectDirectories = yield cacheDependencyPathToProjectsDirectories(cacheDependencyPath);
 | 
					    const projectDirectories = yield getProjectDirectoriesFromCacheDependencyPath(cacheDependencyPath);
 | 
				
			||||||
    const cacheFoldersPaths = yield Promise.all(projectDirectories.map(projectDirectory => projectDirectoryToCacheFolderPath(packageManagerInfo, projectDirectory)));
 | 
					    const cacheFoldersPaths = yield Promise.all(projectDirectories.map(projectDirectory => packageManagerInfo
 | 
				
			||||||
 | 
					        .getCacheFolderPath(projectDirectory)
 | 
				
			||||||
 | 
					        .then(cacheFolderPath => {
 | 
				
			||||||
 | 
					        core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`);
 | 
				
			||||||
 | 
					        return cacheFolderPath;
 | 
				
			||||||
 | 
					    })));
 | 
				
			||||||
    // uniq in order to do not cache the same directories twice
 | 
					    // uniq in order to do not cache the same directories twice
 | 
				
			||||||
    return cacheFoldersPaths.filter((cachePath, i, result) => result.indexOf(cachePath) === i);
 | 
					    return cacheFoldersPaths.filter((cachePath, i, result) => result.indexOf(cachePath) === i);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Top-entry function to find the cache directories configured for the repo if cache-dependency-path is empty
 | 
					 * Finds the cache directories configured for the repo ignoring cache-dependency-path
 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheFoldersPathsForRoot = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCacheDirectoriesForRootProject = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
 | 
					    const cacheFolderPath = yield packageManagerInfo.getCacheFolderPath();
 | 
				
			||||||
    core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
 | 
					    core.debug(`${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the root directory`);
 | 
				
			||||||
    return [cacheFolderPath];
 | 
					    return [cacheFolderPath];
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Main function to find the cache directories configured for the repo
 | 
					 * A function to find the cache directories configured for the repo
 | 
				
			||||||
 * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
 | 
					 * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
				
			||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const getCacheDirectoriesPaths = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
					const getCacheDirectories = (packageManagerInfo, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
 | 
				
			||||||
    // TODO: multiple directories limited to yarn so far
 | 
					    // For yarn, if cacheDependencyPath is set, ask information about cache folders in each project
 | 
				
			||||||
    return packageManagerInfo === exports.supportedPackageManagers.yarn
 | 
					    // folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488
 | 
				
			||||||
        ? cacheDependencyPathToCacheFoldersPaths(packageManagerInfo, cacheDependencyPath)
 | 
					    if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
 | 
				
			||||||
        : cacheFoldersPathsForRoot(packageManagerInfo);
 | 
					        return getCacheDirectoriesFromCacheDependencyPath(packageManagerInfo, cacheDependencyPath);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return getCacheDirectoriesForRootProject(packageManagerInfo);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
exports.getCacheDirectoriesPaths = getCacheDirectoriesPaths;
 | 
					exports.getCacheDirectories = getCacheDirectories;
 | 
				
			||||||
function isGhes() {
 | 
					function isGhes() {
 | 
				
			||||||
    const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
 | 
					    const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
 | 
				
			||||||
    return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 | 
					    return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@ import fs from 'fs';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import {State} from './constants';
 | 
					import {State} from './constants';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  getCacheDirectoriesPaths,
 | 
					  getCacheDirectories,
 | 
				
			||||||
  getPackageManagerInfo,
 | 
					  getPackageManagerInfo,
 | 
				
			||||||
  PackageManagerInfo
 | 
					  PackageManagerInfo
 | 
				
			||||||
} from './cache-utils';
 | 
					} from './cache-utils';
 | 
				
			||||||
@ -21,7 +21,7 @@ export const restoreCache = async (
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  const platform = process.env.RUNNER_OS;
 | 
					  const platform = process.env.RUNNER_OS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const cachePaths = await getCacheDirectoriesPaths(
 | 
					  const cachePaths = await getCacheDirectories(
 | 
				
			||||||
    packageManagerInfo,
 | 
					    packageManagerInfo,
 | 
				
			||||||
    cacheDependencyPath
 | 
					    cacheDependencyPath
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
import * as core from '@actions/core';
 | 
					import * as core from '@actions/core';
 | 
				
			||||||
import * as cache from '@actions/cache';
 | 
					import * as cache from '@actions/cache';
 | 
				
			||||||
import {State} from './constants';
 | 
					import {State} from './constants';
 | 
				
			||||||
import {getCacheDirectoriesPaths, getPackageManagerInfo} from './cache-utils';
 | 
					import {getCacheDirectories, getPackageManagerInfo} from './cache-utils';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Catch and log any unhandled exceptions.  These exceptions can leak out of the uploadChunk method in
 | 
					// Catch and log any unhandled exceptions.  These exceptions can leak out of the uploadChunk method in
 | 
				
			||||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
 | 
					// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
 | 
				
			||||||
@ -33,7 +33,7 @@ const cachePackages = async (packageManager: string) => {
 | 
				
			|||||||
  // TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
 | 
					  // TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
 | 
				
			||||||
  //       export declare function getInput(name: string, options?: InputOptions): string;
 | 
					  //       export declare function getInput(name: string, options?: InputOptions): string;
 | 
				
			||||||
  const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
 | 
					  const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
 | 
				
			||||||
  const cachePaths = await getCacheDirectoriesPaths(
 | 
					  const cachePaths = await getCacheDirectories(
 | 
				
			||||||
    packageManagerInfo,
 | 
					    packageManagerInfo,
 | 
				
			||||||
    cacheDependencyPath
 | 
					    cacheDependencyPath
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
				
			|||||||
@ -16,19 +16,13 @@ interface SupportedPackageManagers {
 | 
				
			|||||||
  pnpm: PackageManagerInfo;
 | 
					  pnpm: PackageManagerInfo;
 | 
				
			||||||
  yarn: PackageManagerInfo;
 | 
					  yarn: PackageManagerInfo;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// for testing purposes
 | 
					 | 
				
			||||||
export const npmGetCacheFolderCommand = 'npm config get cache';
 | 
					 | 
				
			||||||
export const pnpmGetCacheFolderCommand = 'pnpm store path --silent';
 | 
					 | 
				
			||||||
export const yarn1GetCacheFolderCommand = 'yarn cache dir';
 | 
					 | 
				
			||||||
export const yarn2GetCacheFolderCommand = 'yarn config get cacheFolder';
 | 
					 | 
				
			||||||
export const supportedPackageManagers: SupportedPackageManagers = {
 | 
					export const supportedPackageManagers: SupportedPackageManagers = {
 | 
				
			||||||
  npm: {
 | 
					  npm: {
 | 
				
			||||||
    name: 'npm',
 | 
					    name: 'npm',
 | 
				
			||||||
    lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
 | 
					    lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
 | 
				
			||||||
    getCacheFolderPath: () =>
 | 
					    getCacheFolderPath: () =>
 | 
				
			||||||
      getCommandOutputGuarded(
 | 
					      getCommandOutputNotEmpty(
 | 
				
			||||||
        npmGetCacheFolderCommand,
 | 
					        'npm config get cache',
 | 
				
			||||||
        'Could not get npm cache folder path'
 | 
					        'Could not get npm cache folder path'
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
@ -36,8 +30,8 @@ export const supportedPackageManagers: SupportedPackageManagers = {
 | 
				
			|||||||
    name: 'pnpm',
 | 
					    name: 'pnpm',
 | 
				
			||||||
    lockFilePatterns: ['pnpm-lock.yaml'],
 | 
					    lockFilePatterns: ['pnpm-lock.yaml'],
 | 
				
			||||||
    getCacheFolderPath: () =>
 | 
					    getCacheFolderPath: () =>
 | 
				
			||||||
      getCommandOutputGuarded(
 | 
					      getCommandOutputNotEmpty(
 | 
				
			||||||
        pnpmGetCacheFolderCommand,
 | 
					        'pnpm store path --silent',
 | 
				
			||||||
        'Could not get pnpm cache folder path'
 | 
					        'Could not get pnpm cache folder path'
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
@ -45,19 +39,21 @@ export const supportedPackageManagers: SupportedPackageManagers = {
 | 
				
			|||||||
    name: 'yarn',
 | 
					    name: 'yarn',
 | 
				
			||||||
    lockFilePatterns: ['yarn.lock'],
 | 
					    lockFilePatterns: ['yarn.lock'],
 | 
				
			||||||
    getCacheFolderPath: async projectDir => {
 | 
					    getCacheFolderPath: async projectDir => {
 | 
				
			||||||
      const yarnVersion = await getCommandOutputGuarded(
 | 
					      const yarnVersion = await getCommandOutputNotEmpty(
 | 
				
			||||||
        `yarn --version`,
 | 
					        `yarn --version`,
 | 
				
			||||||
        'Could not retrieve version of yarn',
 | 
					        'Could not retrieve version of yarn',
 | 
				
			||||||
        projectDir
 | 
					        projectDir
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      core.debug(
 | 
					      core.debug(
 | 
				
			||||||
        `Consumed yarn version is ${yarnVersion} (working dir: "${projectDir}")`
 | 
					        `Consumed yarn version is ${yarnVersion} (working dir: "${
 | 
				
			||||||
 | 
					          projectDir || ''
 | 
				
			||||||
 | 
					        }")`
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      const stdOut = yarnVersion.startsWith('1.')
 | 
					      const stdOut = yarnVersion.startsWith('1.')
 | 
				
			||||||
        ? await getCommandOutput(yarn1GetCacheFolderCommand, projectDir)
 | 
					        ? await getCommandOutput('yarn cache dir', projectDir)
 | 
				
			||||||
        : await getCommandOutput(yarn2GetCacheFolderCommand, projectDir);
 | 
					        : await getCommandOutput('yarn config get cacheFolder', projectDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!stdOut) {
 | 
					      if (!stdOut) {
 | 
				
			||||||
        throw new Error(
 | 
					        throw new Error(
 | 
				
			||||||
@ -89,7 +85,7 @@ export const getCommandOutput = async (
 | 
				
			|||||||
  return stdout.trim();
 | 
					  return stdout.trim();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const getCommandOutputGuarded = async (
 | 
					export const getCommandOutputNotEmpty = async (
 | 
				
			||||||
  toolCommand: string,
 | 
					  toolCommand: string,
 | 
				
			||||||
  error: string,
 | 
					  error: string,
 | 
				
			||||||
  cwd?: string
 | 
					  cwd?: string
 | 
				
			||||||
@ -117,66 +113,7 @@ export const getPackageManagerInfo = async (packageManager: string) => {
 | 
				
			|||||||
 * glob expanding memoized because it involves potentially very deep
 | 
					 * glob expanding memoized because it involves potentially very deep
 | 
				
			||||||
 * traversing through the directories tree
 | 
					 * traversing through the directories tree
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export const expandedPatternsMemoized: Record<string, string[]> = {};
 | 
					export const memoizedCacheDependencies: Record<string, string[]> = {};
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Wrapper around `glob.create(pattern).glob()` with the memoization
 | 
					 | 
				
			||||||
 * @param pattern is expected to be a globed path
 | 
					 | 
				
			||||||
 * @return list of files or directories expanded from glob
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const globPatternToArray = async (pattern: string): Promise<string[]> => {
 | 
					 | 
				
			||||||
  const memoized = expandedPatternsMemoized[pattern];
 | 
					 | 
				
			||||||
  if (memoized) return Promise.resolve(memoized);
 | 
					 | 
				
			||||||
  const globber = await glob.create(pattern);
 | 
					 | 
				
			||||||
  const expanded = await globber.glob();
 | 
					 | 
				
			||||||
  expandedPatternsMemoized[pattern] = expanded;
 | 
					 | 
				
			||||||
  return expanded;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Expands (converts) the string input `cache-dependency-path` to list of files' paths
 | 
					 | 
				
			||||||
 * First it breaks the input by new lines and then expand glob patterns if any
 | 
					 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export const expandCacheDependencyPath = async (
 | 
					 | 
				
			||||||
  cacheDependencyPath: string
 | 
					 | 
				
			||||||
): Promise<string[]> => {
 | 
					 | 
				
			||||||
  const multilinePaths = cacheDependencyPath
 | 
					 | 
				
			||||||
    .split(/\r?\n/)
 | 
					 | 
				
			||||||
    .map(path => path.trim())
 | 
					 | 
				
			||||||
    .filter(path => Boolean(path));
 | 
					 | 
				
			||||||
  const expandedPathsPromises: Promise<string[]>[] = multilinePaths.map(path =>
 | 
					 | 
				
			||||||
    path.includes('*') ? globPatternToArray(path) : Promise.resolve([path])
 | 
					 | 
				
			||||||
  );
 | 
					 | 
				
			||||||
  const expandedPaths: string[][] = await Promise.all(expandedPathsPromises);
 | 
					 | 
				
			||||||
  return expandedPaths.length === 0 ? [''] : expandedPaths.flat();
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Converts dependency file path to the directory it resides in and ensures the directory exists
 | 
					 | 
				
			||||||
 * @param cacheDependencyPath - a file name path
 | 
					 | 
				
			||||||
 * @return either directory containing the file or null
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const cacheDependencyPathToProjectDirectory = (
 | 
					 | 
				
			||||||
  cacheDependencyPath: string
 | 
					 | 
				
			||||||
): string | null => {
 | 
					 | 
				
			||||||
  const projectDirectory = path.dirname(cacheDependencyPath);
 | 
					 | 
				
			||||||
  if (
 | 
					 | 
				
			||||||
    fs.existsSync(projectDirectory) &&
 | 
					 | 
				
			||||||
    fs.lstatSync(projectDirectory).isDirectory()
 | 
					 | 
				
			||||||
  ) {
 | 
					 | 
				
			||||||
    core.debug(
 | 
					 | 
				
			||||||
      `Project directory "${projectDirectory}" derived from cache-dependency-path: "${cacheDependencyPath}"`
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
    return projectDirectory;
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    core.debug(
 | 
					 | 
				
			||||||
      `No project directory found for cache-dependency-path: "${cacheDependencyPath}", will be skipped`
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
    return null;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Expands (converts) the string input `cache-dependency-path` to list of directories that
 | 
					 * Expands (converts) the string input `cache-dependency-path` to list of directories that
 | 
				
			||||||
 * may be project roots
 | 
					 * may be project roots
 | 
				
			||||||
@ -184,18 +121,33 @@ const cacheDependencyPathToProjectDirectory = (
 | 
				
			|||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of directories and possible
 | 
					 * @return list of directories and possible
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheDependencyPathToProjectsDirectories = async (
 | 
					const getProjectDirectoriesFromCacheDependencyPath = async (
 | 
				
			||||||
  cacheDependencyPath: string
 | 
					  cacheDependencyPath: string
 | 
				
			||||||
): Promise<string[]> => {
 | 
					): Promise<string[]> => {
 | 
				
			||||||
  const cacheDependenciesPaths = await expandCacheDependencyPath(
 | 
					  let cacheDependenciesPaths: string[];
 | 
				
			||||||
    cacheDependencyPath
 | 
					
 | 
				
			||||||
  );
 | 
					  // memoize unglobbed paths to avoid traversing FS
 | 
				
			||||||
 | 
					  const memoized = memoizedCacheDependencies[cacheDependencyPath];
 | 
				
			||||||
 | 
					  if (memoized) {
 | 
				
			||||||
 | 
					    cacheDependenciesPaths = memoized;
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    cacheDependenciesPaths = (await glob
 | 
				
			||||||
 | 
					      .create(cacheDependencyPath)
 | 
				
			||||||
 | 
					      .then(globber => globber.glob())) || [''];
 | 
				
			||||||
 | 
					    memoizedCacheDependencies[cacheDependencyPath] = cacheDependenciesPaths;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const existingDirectories: string[] = cacheDependenciesPaths
 | 
					  const existingDirectories: string[] = cacheDependenciesPaths
 | 
				
			||||||
    .map(cacheDependencyPath =>
 | 
					    .map(cacheDependencyPath => path.dirname(cacheDependencyPath))
 | 
				
			||||||
      cacheDependencyPathToProjectDirectory(cacheDependencyPath)
 | 
					    // uniq in order to do not traverse the same directories during the further processing
 | 
				
			||||||
 | 
					    .filter(
 | 
				
			||||||
 | 
					      (cachePath, i, result) =>
 | 
				
			||||||
 | 
					        cachePath != null && result.indexOf(cachePath) === i
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    .filter(path => path !== null) as string[];
 | 
					    .filter(
 | 
				
			||||||
 | 
					      directory =>
 | 
				
			||||||
 | 
					        fs.existsSync(directory) && fs.lstatSync(directory).isDirectory()
 | 
				
			||||||
 | 
					    ) as string[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // if user explicitly pointed out some file, but it does not exist it is definitely
 | 
					  // if user explicitly pointed out some file, but it does not exist it is definitely
 | 
				
			||||||
  // not he wanted, thus we should throw an error not trying to workaround with unexpected
 | 
					  // not he wanted, thus we should throw an error not trying to workaround with unexpected
 | 
				
			||||||
@ -205,50 +157,33 @@ const cacheDependencyPathToProjectsDirectories = async (
 | 
				
			|||||||
      'No existing directories found containing `cache-dependency-path`="${cacheDependencyPath}"'
 | 
					      'No existing directories found containing `cache-dependency-path`="${cacheDependencyPath}"'
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // uniq in order to do not traverse the same directories during the further processing
 | 
					  return existingDirectories;
 | 
				
			||||||
  return existingDirectories.filter(
 | 
					 | 
				
			||||||
    (cachePath, i, result) =>
 | 
					 | 
				
			||||||
      cachePath != null && result.indexOf(cachePath) === i
 | 
					 | 
				
			||||||
  );
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Utility function to be used from within `map`
 | 
					 * Finds the cache directories configured for the repo if cache-dependency-path is not empty
 | 
				
			||||||
 * Finds the cache directories configured for the project directory
 | 
					 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 | 
				
			||||||
 * @param projectDirectory - the string pointing out to a project dir (i.e. directory with its own .yarnrc)
 | 
					 | 
				
			||||||
 * @return list of directories to be cached according to the project configuration in the directory
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
const projectDirectoryToCacheFolderPath = async (
 | 
					 | 
				
			||||||
  packageManagerInfo: PackageManagerInfo,
 | 
					 | 
				
			||||||
  projectDirectory: string
 | 
					 | 
				
			||||||
): Promise<string> => {
 | 
					 | 
				
			||||||
  const cacheFolderPath = await packageManagerInfo.getCacheFolderPath(
 | 
					 | 
				
			||||||
    projectDirectory
 | 
					 | 
				
			||||||
  );
 | 
					 | 
				
			||||||
  core.debug(
 | 
					 | 
				
			||||||
    `${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`
 | 
					 | 
				
			||||||
  );
 | 
					 | 
				
			||||||
  return cacheFolderPath;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Top-entry function to find the cache directories configured for the repo if cache-dependency-path is not empty
 | 
					 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
				
			||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheDependencyPathToCacheFoldersPaths = async (
 | 
					const getCacheDirectoriesFromCacheDependencyPath = async (
 | 
				
			||||||
  packageManagerInfo: PackageManagerInfo,
 | 
					  packageManagerInfo: PackageManagerInfo,
 | 
				
			||||||
  cacheDependencyPath: string
 | 
					  cacheDependencyPath: string
 | 
				
			||||||
): Promise<string[]> => {
 | 
					): Promise<string[]> => {
 | 
				
			||||||
  const projectDirectories = await cacheDependencyPathToProjectsDirectories(
 | 
					  const projectDirectories = await getProjectDirectoriesFromCacheDependencyPath(
 | 
				
			||||||
    cacheDependencyPath
 | 
					    cacheDependencyPath
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  const cacheFoldersPaths = await Promise.all(
 | 
					  const cacheFoldersPaths = await Promise.all(
 | 
				
			||||||
    projectDirectories.map(projectDirectory =>
 | 
					    projectDirectories.map(projectDirectory =>
 | 
				
			||||||
      projectDirectoryToCacheFolderPath(packageManagerInfo, projectDirectory)
 | 
					      packageManagerInfo
 | 
				
			||||||
 | 
					        .getCacheFolderPath(projectDirectory)
 | 
				
			||||||
 | 
					        .then(cacheFolderPath => {
 | 
				
			||||||
 | 
					          core.debug(
 | 
				
			||||||
 | 
					            `${packageManagerInfo.name}'s cache folder "${cacheFolderPath}" configured for the directory "${projectDirectory}"`
 | 
				
			||||||
 | 
					          );
 | 
				
			||||||
 | 
					          return cacheFolderPath;
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  // uniq in order to do not cache the same directories twice
 | 
					  // uniq in order to do not cache the same directories twice
 | 
				
			||||||
@ -258,11 +193,11 @@ const cacheDependencyPathToCacheFoldersPaths = async (
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Top-entry function to find the cache directories configured for the repo if cache-dependency-path is empty
 | 
					 * Finds the cache directories configured for the repo ignoring cache-dependency-path
 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const cacheFoldersPathsForRoot = async (
 | 
					const getCacheDirectoriesForRootProject = async (
 | 
				
			||||||
  packageManagerInfo: PackageManagerInfo
 | 
					  packageManagerInfo: PackageManagerInfo
 | 
				
			||||||
): Promise<string[]> => {
 | 
					): Promise<string[]> => {
 | 
				
			||||||
  const cacheFolderPath = await packageManagerInfo.getCacheFolderPath();
 | 
					  const cacheFolderPath = await packageManagerInfo.getCacheFolderPath();
 | 
				
			||||||
@ -273,24 +208,27 @@ const cacheFoldersPathsForRoot = async (
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Main function to find the cache directories configured for the repo
 | 
					 * A function to find the cache directories configured for the repo
 | 
				
			||||||
 * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
 | 
					 * currently it handles only the case of PM=yarn && cacheDependencyPath is not empty
 | 
				
			||||||
 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
					 * @param packageManagerInfo - an object having getCacheFolderPath method specific to given PM
 | 
				
			||||||
 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
					 * @param cacheDependencyPath - either a single string or multiline string with possible glob patterns
 | 
				
			||||||
 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
					 *                              expected to be the result of `core.getInput('cache-dependency-path')`
 | 
				
			||||||
 * @return list of files on which the cache depends
 | 
					 * @return list of files on which the cache depends
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export const getCacheDirectoriesPaths = async (
 | 
					export const getCacheDirectories = async (
 | 
				
			||||||
  packageManagerInfo: PackageManagerInfo,
 | 
					  packageManagerInfo: PackageManagerInfo,
 | 
				
			||||||
  cacheDependencyPath: string
 | 
					  cacheDependencyPath: string
 | 
				
			||||||
): Promise<string[]> =>
 | 
					): Promise<string[]> => {
 | 
				
			||||||
  // TODO: multiple directories limited to yarn so far
 | 
					  // For yarn, if cacheDependencyPath is set, ask information about cache folders in each project
 | 
				
			||||||
  packageManagerInfo === supportedPackageManagers.yarn
 | 
					  // folder satisfied by cacheDependencyPath https://github.com/actions/setup-node/issues/488
 | 
				
			||||||
    ? cacheDependencyPathToCacheFoldersPaths(
 | 
					  if (packageManagerInfo.name === 'yarn' && cacheDependencyPath) {
 | 
				
			||||||
 | 
					    return getCacheDirectoriesFromCacheDependencyPath(
 | 
				
			||||||
      packageManagerInfo,
 | 
					      packageManagerInfo,
 | 
				
			||||||
      cacheDependencyPath
 | 
					      cacheDependencyPath
 | 
				
			||||||
      )
 | 
					    );
 | 
				
			||||||
    : cacheFoldersPathsForRoot(packageManagerInfo);
 | 
					  }
 | 
				
			||||||
 | 
					  return getCacheDirectoriesForRootProject(packageManagerInfo);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function isGhes(): boolean {
 | 
					export function isGhes(): boolean {
 | 
				
			||||||
  const ghUrl = new URL(
 | 
					  const ghUrl = new URL(
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user