From cb6558bb10fe4afe4054d0be4b3136e673eb5e7f Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 16:22:09 -0400 Subject: [PATCH 1/9] Exclude hidden files by default --- README.md | 5 +++ __tests__/search.test.ts | 54 +++++++++++++++++++++++++++++++ action.yml | 5 +++ dist/merge/index.js | 16 +++++---- dist/upload/index.js | 16 +++++---- docs/MIGRATION.md | 61 ++++++++++++++++++++++++++++------- merge/action.yml | 5 +++ package-lock.json | 4 +-- package.json | 2 +- src/merge/constants.ts | 3 +- src/merge/input-helper.ts | 4 ++- src/merge/merge-artifacts.ts | 2 +- src/merge/merge-inputs.ts | 5 +++ src/shared/search.ts | 9 +++--- src/upload/constants.ts | 3 +- src/upload/input-helper.ts | 4 ++- src/upload/upload-artifact.ts | 2 +- src/upload/upload-inputs.ts | 5 +++ 18 files changed, 169 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index a4f4c7f..8143668 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ There is also a new sub-action, `actions/upload-artifact/merge`. For more info, Due to how Artifacts are created in this new version, it is no longer possible to upload to the same named Artifact multiple times. You must either split the uploads into multiple Artifacts with different names, or only upload once. Otherwise you _will_ encounter an error. 3. Limit of Artifacts for an individual job. Each job in a workflow run now has a limit of 500 artifacts. +4. With `v4.4` and later, hidden files are excluded by default. For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md). @@ -107,6 +108,10 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md). # Does not fail if the artifact does not exist. # Optional. Default is 'false' overwrite: + + # Whether to include hidden files in the provided path in the artifact + # Optional. Default is 'false' + include-hidden-files: ``` ### Outputs diff --git a/__tests__/search.test.ts b/__tests__/search.test.ts index e0ab26d..5cbc032 100644 --- a/__tests__/search.test.ts +++ b/__tests__/search.test.ts @@ -61,6 +61,20 @@ const lonelyFilePath = path.join( 'lonely-file.txt' ) +const fileInHiddenFolderPath = path.join( + root, + '.hidden-folder', + 'folder-in-hidden-folder', + 'file.txt' +) +const hiddenFile = path.join(root, '.hidden-file.txt') +const fileInHiddenFolderInFolderA = path.join( + root, + 'folder-a', + '.hidden-folder-in-folder-a', + 'file.txt' +) + describe('Search', () => { beforeAll(async () => { // mock all output so that there is less noise when running tests @@ -93,6 +107,14 @@ describe('Search', () => { recursive: true }) + await fs.mkdir( + path.join(root, '.hidden-folder', 'folder-in-hidden-folder'), + {recursive: true} + ) + await fs.mkdir(path.join(root, 'folder-a', '.hidden-folder-in-folder-a'), { + recursive: true + }) + await fs.writeFile(searchItem1Path, 'search item1 file') await fs.writeFile(searchItem2Path, 'search item2 file') await fs.writeFile(searchItem3Path, 'search item3 file') @@ -113,7 +135,12 @@ describe('Search', () => { /* Directory structure of files that get created: root/ + .hidden-folder/ + folder-in-hidden-folder/ + file.txt folder-a/ + .hidden-folder-in-folder-a/ + file.txt folder-b/ folder-c/ search-item1.txt @@ -136,6 +163,7 @@ describe('Search', () => { folder-j/ folder-k/ lonely-file.txt + .hidden-file.txt search-item5.txt */ }) @@ -352,4 +380,30 @@ describe('Search', () => { ) expect(searchResult.filesToUpload.includes(lonelyFilePath)).toEqual(true) }) + + it('Hidden files ignored by default', async () => { + const searchPath = path.join(root, '**/*') + const searchResult = await findFilesToUpload(searchPath) + + expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false) + expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual( + false + ) + expect( + searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA) + ).toEqual(false) + }) + + it('Hidden files included', async () => { + const searchPath = path.join(root, '**/*') + const searchResult = await findFilesToUpload(searchPath, true) + + expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false) + expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual( + false + ) + expect( + searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA) + ).toEqual(false) + }) }) diff --git a/action.yml b/action.yml index 38d4fdc..d3eb907 100644 --- a/action.yml +++ b/action.yml @@ -40,6 +40,11 @@ inputs: If false, the action will fail if an artifact for the given name already exists. Does not fail if the artifact does not exist. default: 'false' + include-hidden-files: + description: > + If true, hidden files will be included in the merged artifact. + If false, hidden files will be excluded from the merged artifact. + default: 'false' outputs: artifact-id: diff --git a/dist/merge/index.js b/dist/merge/index.js index c09bb45..699ddac 100644 --- a/dist/merge/index.js +++ b/dist/merge/index.js @@ -125727,6 +125727,7 @@ var Inputs; Inputs["RetentionDays"] = "retention-days"; Inputs["CompressionLevel"] = "compression-level"; Inputs["DeleteMerged"] = "delete-merged"; + Inputs["IncludeHiddenFiles"] = "include-hidden-files"; })(Inputs = exports.Inputs || (exports.Inputs = {})); @@ -125810,13 +125811,15 @@ function getInputs() { const pattern = core.getInput(constants_1.Inputs.Pattern, { required: true }); const separateDirectories = core.getBooleanInput(constants_1.Inputs.SeparateDirectories); const deleteMerged = core.getBooleanInput(constants_1.Inputs.DeleteMerged); + const includeHiddenFiles = core.getBooleanInput(constants_1.Inputs.IncludeHiddenFiles); const inputs = { name, pattern, separateDirectories, deleteMerged, retentionDays: 0, - compressionLevel: 6 + compressionLevel: 6, + includeHiddenFiles, }; const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays); if (retentionDaysStr) { @@ -125932,7 +125935,7 @@ function run() { if (typeof inputs.compressionLevel !== 'undefined') { options.compressionLevel = inputs.compressionLevel; } - const searchResult = yield (0, search_1.findFilesToUpload)(tmpDir); + const searchResult = yield (0, search_1.findFilesToUpload)(tmpDir, inputs.includeHiddenFiles); yield (0, upload_artifact_1.uploadArtifact)(inputs.name, searchResult.filesToUpload, searchResult.rootDirectory, options); core.info(`The ${artifacts.length} artifact(s) have been successfully merged!`); if (inputs.deleteMerged) { @@ -125999,11 +126002,12 @@ const fs_1 = __nccwpck_require__(57147); const path_1 = __nccwpck_require__(71017); const util_1 = __nccwpck_require__(73837); const stats = (0, util_1.promisify)(fs_1.stat); -function getDefaultGlobOptions() { +function getDefaultGlobOptions(_includeHiddenFiles) { return { followSymbolicLinks: true, implicitDescendants: true, - omitBrokenSymbolicLinks: true + omitBrokenSymbolicLinks: true, + // excludeHiddenFiles: !includeHiddenFiles, }; } /** @@ -126057,10 +126061,10 @@ function getMultiPathLCA(searchPaths) { } return path.join(...commonPaths); } -function findFilesToUpload(searchPath, globOptions) { +function findFilesToUpload(searchPath, includeHiddenFiles) { return __awaiter(this, void 0, void 0, function* () { const searchResults = []; - const globber = yield glob.create(searchPath, globOptions || getDefaultGlobOptions()); + const globber = yield glob.create(searchPath, getDefaultGlobOptions(includeHiddenFiles || false)); const rawSearchResults = yield globber.glob(); /* Files are saved with case insensitivity. Uploading both a.txt and A.txt will files to be overwritten diff --git a/dist/upload/index.js b/dist/upload/index.js index b28794f..d3b8743 100644 --- a/dist/upload/index.js +++ b/dist/upload/index.js @@ -125757,11 +125757,12 @@ const fs_1 = __nccwpck_require__(57147); const path_1 = __nccwpck_require__(71017); const util_1 = __nccwpck_require__(73837); const stats = (0, util_1.promisify)(fs_1.stat); -function getDefaultGlobOptions() { +function getDefaultGlobOptions(_includeHiddenFiles) { return { followSymbolicLinks: true, implicitDescendants: true, - omitBrokenSymbolicLinks: true + omitBrokenSymbolicLinks: true, + // excludeHiddenFiles: !includeHiddenFiles, }; } /** @@ -125815,10 +125816,10 @@ function getMultiPathLCA(searchPaths) { } return path.join(...commonPaths); } -function findFilesToUpload(searchPath, globOptions) { +function findFilesToUpload(searchPath, includeHiddenFiles) { return __awaiter(this, void 0, void 0, function* () { const searchResults = []; - const globber = yield glob.create(searchPath, globOptions || getDefaultGlobOptions()); + const globber = yield glob.create(searchPath, getDefaultGlobOptions(includeHiddenFiles || false)); const rawSearchResults = yield globber.glob(); /* Files are saved with case insensitivity. Uploading both a.txt and A.txt will files to be overwritten @@ -125956,6 +125957,7 @@ var Inputs; Inputs["RetentionDays"] = "retention-days"; Inputs["CompressionLevel"] = "compression-level"; Inputs["Overwrite"] = "overwrite"; + Inputs["IncludeHiddenFiles"] = "include-hidden-files"; })(Inputs = exports.Inputs || (exports.Inputs = {})); var NoFileOptions; (function (NoFileOptions) { @@ -126053,6 +126055,7 @@ function getInputs() { const name = core.getInput(constants_1.Inputs.Name); const path = core.getInput(constants_1.Inputs.Path, { required: true }); const overwrite = core.getBooleanInput(constants_1.Inputs.Overwrite); + const includeHiddenFiles = core.getBooleanInput(constants_1.Inputs.IncludeHiddenFiles); const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound); const noFileBehavior = constants_1.NoFileOptions[ifNoFilesFound]; if (!noFileBehavior) { @@ -126062,7 +126065,8 @@ function getInputs() { artifactName: name, searchPath: path, ifNoFilesFound: noFileBehavior, - overwrite: overwrite + overwrite: overwrite, + includeHiddenFiles: includeHiddenFiles, }; const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays); if (retentionDaysStr) { @@ -126151,7 +126155,7 @@ function deleteArtifactIfExists(artifactName) { function run() { return __awaiter(this, void 0, void 0, function* () { const inputs = (0, input_helper_1.getInputs)(); - const searchResult = yield (0, search_1.findFilesToUpload)(inputs.searchPath); + const searchResult = yield (0, search_1.findFilesToUpload)(inputs.searchPath, inputs.includeHiddenFiles); if (searchResult.filesToUpload.length === 0) { // No files were found, different use cases warrant different types of behavior if nothing is found switch (inputs.ifNoFilesFound) { diff --git a/docs/MIGRATION.md b/docs/MIGRATION.md index 1c656fc..55ddd01 100644 --- a/docs/MIGRATION.md +++ b/docs/MIGRATION.md @@ -4,6 +4,7 @@ - [Multiple uploads to the same named Artifact](#multiple-uploads-to-the-same-named-artifact) - [Overwriting an Artifact](#overwriting-an-artifact) - [Merging multiple artifacts](#merging-multiple-artifacts) + - [Hidden files](#hidden-files) Several behavioral differences exist between Artifact actions `v3` and below vs `v4`. This document outlines common scenarios in `v3`, and how they would be handled in `v4`. @@ -189,21 +190,59 @@ jobs: - name: Create a File run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt - name: Upload Artifact -- uses: actions/upload-artifact@v3 -+ uses: actions/upload-artifact@v4 +- uses: actions/upload-artifact@v3 ++ uses: actions/upload-artifact@v4 with: - name: all-my-files + name: my-artifact-${{ matrix.runs-on }} path: file-${{ matrix.runs-on }}.txt -+ merge: -+ runs-on: ubuntu-latest -+ needs: upload -+ steps: -+ - name: Merge Artifacts -+ uses: actions/upload-artifact/merge@v4 -+ with: -+ name: all-my-files -+ pattern: my-artifact-* ++ merge: ++ runs-on: ubuntu-latest ++ needs: upload ++ steps: ++ - name: Merge Artifacts ++ uses: actions/upload-artifact/merge@v4 ++ with: ++ name: all-my-files ++ pattern: my-artifact-* ``` Note that this will download all artifacts to a temporary directory and reupload them as a single artifact. For more information on inputs and other use cases for `actions/upload-artifact/merge@v4`, see [the action documentation](../merge/README.md). + +## Hidden Files + +By default, hidden files are ignored by this action to avoid unintentionally uploading sensitive +information. + +In versions of this action before v4.4.0, these hidden files were included by default. + +If you need to upload hidden files, you can use the `include-hidden-files` input. + +```yaml +jobs: + upload: + runs-on: ubuntu-latest + steps: + - name: Create a Hidden File + run: echo "hello from a hidden file" > .hidden-file.txt + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + path: .hidden-file.txt +``` + + +```diff +jobs: + upload: + runs-on: ubuntu-latest + steps: + - name: Create a Hidden File + run: echo "hello from a hidden file" > .hidden-file.txt + - name: Upload Artifact +- uses: actions/upload-artifact@v3 ++ uses: actions/upload-artifact@v4 + with: + path: .hidden-file.txt ++ include-hidden-files: true +``` \ No newline at end of file diff --git a/merge/action.yml b/merge/action.yml index 8d85864..81407ee 100644 --- a/merge/action.yml +++ b/merge/action.yml @@ -36,6 +36,11 @@ inputs: If true, the artifacts that were merged will be deleted. If false, the artifacts will still exist. default: 'false' + include-hidden-files: + description: > + If true, hidden files will be included in the merged artifact. + If false, hidden files will be excluded from the merged artifact. + default: 'false' outputs: artifact-id: diff --git a/package-lock.json b/package-lock.json index 296b9f1..e1c4ca9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "upload-artifact", - "version": "4.3.6", + "version": "4.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "upload-artifact", - "version": "4.3.6", + "version": "4.4.0", "license": "MIT", "dependencies": { "@actions/artifact": "2.1.8", diff --git a/package.json b/package.json index 8f51092..7219abe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "upload-artifact", - "version": "4.3.6", + "version": "4.4.0", "description": "Upload an Actions Artifact in a workflow run", "main": "dist/upload/index.js", "scripts": { diff --git a/src/merge/constants.ts b/src/merge/constants.ts index 8bc9539..7869ab1 100644 --- a/src/merge/constants.ts +++ b/src/merge/constants.ts @@ -5,5 +5,6 @@ export enum Inputs { SeparateDirectories = 'separate-directories', RetentionDays = 'retention-days', CompressionLevel = 'compression-level', - DeleteMerged = 'delete-merged' + DeleteMerged = 'delete-merged', + IncludeHiddenFiles = 'include-hidden-files', } diff --git a/src/merge/input-helper.ts b/src/merge/input-helper.ts index de53a2f..cc26a96 100644 --- a/src/merge/input-helper.ts +++ b/src/merge/input-helper.ts @@ -10,6 +10,7 @@ export function getInputs(): MergeInputs { const pattern = core.getInput(Inputs.Pattern, {required: true}) const separateDirectories = core.getBooleanInput(Inputs.SeparateDirectories) const deleteMerged = core.getBooleanInput(Inputs.DeleteMerged) + const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles) const inputs = { name, @@ -17,7 +18,8 @@ export function getInputs(): MergeInputs { separateDirectories, deleteMerged, retentionDays: 0, - compressionLevel: 6 + compressionLevel: 6, + includeHiddenFiles, } as MergeInputs const retentionDaysStr = core.getInput(Inputs.RetentionDays) diff --git a/src/merge/merge-artifacts.ts b/src/merge/merge-artifacts.ts index b45ef9c..8562e86 100644 --- a/src/merge/merge-artifacts.ts +++ b/src/merge/merge-artifacts.ts @@ -62,7 +62,7 @@ export async function run(): Promise { options.compressionLevel = inputs.compressionLevel } - const searchResult = await findFilesToUpload(tmpDir) + const searchResult = await findFilesToUpload(tmpDir, inputs.includeHiddenFiles) await uploadArtifact( inputs.name, diff --git a/src/merge/merge-inputs.ts b/src/merge/merge-inputs.ts index def507a..adfdff6 100644 --- a/src/merge/merge-inputs.ts +++ b/src/merge/merge-inputs.ts @@ -30,4 +30,9 @@ export interface MergeInputs { * If false, the artifacts will be merged into the root of the destination. */ separateDirectories: boolean + + /** + * Whether or not to include hidden files in the artifact + */ + includeHiddenFiles: boolean } diff --git a/src/shared/search.ts b/src/shared/search.ts index bd80164..465507f 100644 --- a/src/shared/search.ts +++ b/src/shared/search.ts @@ -11,11 +11,12 @@ export interface SearchResult { rootDirectory: string } -function getDefaultGlobOptions(): glob.GlobOptions { +function getDefaultGlobOptions(_includeHiddenFiles: boolean): glob.GlobOptions { return { followSymbolicLinks: true, implicitDescendants: true, - omitBrokenSymbolicLinks: true + omitBrokenSymbolicLinks: true, + // excludeHiddenFiles: !includeHiddenFiles, } } @@ -80,12 +81,12 @@ function getMultiPathLCA(searchPaths: string[]): string { export async function findFilesToUpload( searchPath: string, - globOptions?: glob.GlobOptions + includeHiddenFiles?: boolean, ): Promise { const searchResults: string[] = [] const globber = await glob.create( searchPath, - globOptions || getDefaultGlobOptions() + getDefaultGlobOptions(includeHiddenFiles || false) ) const rawSearchResults: string[] = await globber.glob() diff --git a/src/upload/constants.ts b/src/upload/constants.ts index 272f842..2c281de 100644 --- a/src/upload/constants.ts +++ b/src/upload/constants.ts @@ -5,7 +5,8 @@ export enum Inputs { IfNoFilesFound = 'if-no-files-found', RetentionDays = 'retention-days', CompressionLevel = 'compression-level', - Overwrite = 'overwrite' + Overwrite = 'overwrite', + IncludeHiddenFiles = 'include-hidden-files', } export enum NoFileOptions { diff --git a/src/upload/input-helper.ts b/src/upload/input-helper.ts index 3e24f25..f1912f1 100644 --- a/src/upload/input-helper.ts +++ b/src/upload/input-helper.ts @@ -9,6 +9,7 @@ export function getInputs(): UploadInputs { const name = core.getInput(Inputs.Name) const path = core.getInput(Inputs.Path, {required: true}) const overwrite = core.getBooleanInput(Inputs.Overwrite) + const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles) const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound) const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound] @@ -27,7 +28,8 @@ export function getInputs(): UploadInputs { artifactName: name, searchPath: path, ifNoFilesFound: noFileBehavior, - overwrite: overwrite + overwrite: overwrite, + includeHiddenFiles: includeHiddenFiles, } as UploadInputs const retentionDaysStr = core.getInput(Inputs.RetentionDays) diff --git a/src/upload/upload-artifact.ts b/src/upload/upload-artifact.ts index 8c77543..c6368bf 100644 --- a/src/upload/upload-artifact.ts +++ b/src/upload/upload-artifact.ts @@ -24,7 +24,7 @@ async function deleteArtifactIfExists(artifactName: string): Promise { export async function run(): Promise { const inputs = getInputs() - const searchResult = await findFilesToUpload(inputs.searchPath) + const searchResult = await findFilesToUpload(inputs.searchPath, inputs.includeHiddenFiles) if (searchResult.filesToUpload.length === 0) { // No files were found, different use cases warrant different types of behavior if nothing is found switch (inputs.ifNoFilesFound) { diff --git a/src/upload/upload-inputs.ts b/src/upload/upload-inputs.ts index 1e7a46f..9d680d3 100644 --- a/src/upload/upload-inputs.ts +++ b/src/upload/upload-inputs.ts @@ -30,4 +30,9 @@ export interface UploadInputs { * Whether or not to replace an existing artifact with the same name */ overwrite: boolean + + /** + * Whether or not to include hidden files in the artifact + */ + includeHiddenFiles: boolean } From acb59e47763b6e601a344d04cf3c082ee336b709 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 16:31:57 -0400 Subject: [PATCH 2/9] `lint` --- src/merge/constants.ts | 2 +- src/merge/input-helper.ts | 2 +- src/merge/merge-artifacts.ts | 5 ++++- src/shared/search.ts | 2 +- src/upload/constants.ts | 2 +- src/upload/input-helper.ts | 2 +- src/upload/upload-artifact.ts | 5 ++++- 7 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/merge/constants.ts b/src/merge/constants.ts index 7869ab1..1a24021 100644 --- a/src/merge/constants.ts +++ b/src/merge/constants.ts @@ -6,5 +6,5 @@ export enum Inputs { RetentionDays = 'retention-days', CompressionLevel = 'compression-level', DeleteMerged = 'delete-merged', - IncludeHiddenFiles = 'include-hidden-files', + IncludeHiddenFiles = 'include-hidden-files' } diff --git a/src/merge/input-helper.ts b/src/merge/input-helper.ts index cc26a96..0c36735 100644 --- a/src/merge/input-helper.ts +++ b/src/merge/input-helper.ts @@ -19,7 +19,7 @@ export function getInputs(): MergeInputs { deleteMerged, retentionDays: 0, compressionLevel: 6, - includeHiddenFiles, + includeHiddenFiles } as MergeInputs const retentionDaysStr = core.getInput(Inputs.RetentionDays) diff --git a/src/merge/merge-artifacts.ts b/src/merge/merge-artifacts.ts index 8562e86..dc39ff7 100644 --- a/src/merge/merge-artifacts.ts +++ b/src/merge/merge-artifacts.ts @@ -62,7 +62,10 @@ export async function run(): Promise { options.compressionLevel = inputs.compressionLevel } - const searchResult = await findFilesToUpload(tmpDir, inputs.includeHiddenFiles) + const searchResult = await findFilesToUpload( + tmpDir, + inputs.includeHiddenFiles + ) await uploadArtifact( inputs.name, diff --git a/src/shared/search.ts b/src/shared/search.ts index 465507f..c468f14 100644 --- a/src/shared/search.ts +++ b/src/shared/search.ts @@ -81,7 +81,7 @@ function getMultiPathLCA(searchPaths: string[]): string { export async function findFilesToUpload( searchPath: string, - includeHiddenFiles?: boolean, + includeHiddenFiles?: boolean ): Promise { const searchResults: string[] = [] const globber = await glob.create( diff --git a/src/upload/constants.ts b/src/upload/constants.ts index 2c281de..8407bc1 100644 --- a/src/upload/constants.ts +++ b/src/upload/constants.ts @@ -6,7 +6,7 @@ export enum Inputs { RetentionDays = 'retention-days', CompressionLevel = 'compression-level', Overwrite = 'overwrite', - IncludeHiddenFiles = 'include-hidden-files', + IncludeHiddenFiles = 'include-hidden-files' } export enum NoFileOptions { diff --git a/src/upload/input-helper.ts b/src/upload/input-helper.ts index f1912f1..a867a21 100644 --- a/src/upload/input-helper.ts +++ b/src/upload/input-helper.ts @@ -29,7 +29,7 @@ export function getInputs(): UploadInputs { searchPath: path, ifNoFilesFound: noFileBehavior, overwrite: overwrite, - includeHiddenFiles: includeHiddenFiles, + includeHiddenFiles: includeHiddenFiles } as UploadInputs const retentionDaysStr = core.getInput(Inputs.RetentionDays) diff --git a/src/upload/upload-artifact.ts b/src/upload/upload-artifact.ts index c6368bf..6c06d53 100644 --- a/src/upload/upload-artifact.ts +++ b/src/upload/upload-artifact.ts @@ -24,7 +24,10 @@ async function deleteArtifactIfExists(artifactName: string): Promise { export async function run(): Promise { const inputs = getInputs() - const searchResult = await findFilesToUpload(inputs.searchPath, inputs.includeHiddenFiles) + const searchResult = await findFilesToUpload( + inputs.searchPath, + inputs.includeHiddenFiles + ) if (searchResult.filesToUpload.length === 0) { // No files were found, different use cases warrant different types of behavior if nothing is found switch (inputs.ifNoFilesFound) { From a0c40cf60283f329afac2bc0fa77f1a59fa11e6e Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 17:26:43 -0400 Subject: [PATCH 3/9] Update to latest `@actions/glob` and fix tests --- __tests__/search.test.ts | 26 ++++++++++++-------------- package-lock.json | 18 +++++++++--------- package.json | 2 +- src/shared/search.ts | 4 ++-- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/__tests__/search.test.ts b/__tests__/search.test.ts index 5cbc032..58f41ab 100644 --- a/__tests__/search.test.ts +++ b/__tests__/search.test.ts @@ -61,13 +61,13 @@ const lonelyFilePath = path.join( 'lonely-file.txt' ) +const hiddenFile = path.join(root, '.hidden-file.txt') const fileInHiddenFolderPath = path.join( root, '.hidden-folder', 'folder-in-hidden-folder', 'file.txt' ) -const hiddenFile = path.join(root, '.hidden-file.txt') const fileInHiddenFolderInFolderA = path.join( root, 'folder-a', @@ -132,6 +132,10 @@ describe('Search', () => { await fs.writeFile(amazingFileInFolderHPath, 'amazing file') await fs.writeFile(lonelyFilePath, 'all by itself') + + await fs.writeFile(hiddenFile, 'hidden file') + await fs.writeFile(fileInHiddenFolderPath, 'file in hidden directory') + await fs.writeFile(fileInHiddenFolderInFolderA, 'file in hidden directory') /* Directory structure of files that get created: root/ @@ -385,25 +389,19 @@ describe('Search', () => { const searchPath = path.join(root, '**/*') const searchResult = await findFilesToUpload(searchPath) - expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false) - expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual( - false + expect(searchResult.filesToUpload).not.toContain(hiddenFile) + expect(searchResult.filesToUpload).not.toContain(fileInHiddenFolderPath) + expect(searchResult.filesToUpload).not.toContain( + fileInHiddenFolderInFolderA ) - expect( - searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA) - ).toEqual(false) }) it('Hidden files included', async () => { const searchPath = path.join(root, '**/*') const searchResult = await findFilesToUpload(searchPath, true) - expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false) - expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual( - false - ) - expect( - searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA) - ).toEqual(false) + expect(searchResult.filesToUpload).toContain(hiddenFile) + expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath) + expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA) }) }) diff --git a/package-lock.json b/package-lock.json index e1c4ca9..6c1729e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@actions/artifact": "2.1.8", "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", - "@actions/glob": "^0.3.0", + "@actions/glob": "^0.5.0", "@actions/io": "^1.1.2", "minimatch": "^9.0.3" }, @@ -191,11 +191,11 @@ } }, "node_modules/@actions/glob": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz", - "integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", + "integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", "dependencies": { - "@actions/core": "^1.2.6", + "@actions/core": "^1.9.1", "minimatch": "^3.0.4" } }, @@ -8036,11 +8036,11 @@ } }, "@actions/glob": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz", - "integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", + "integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", "requires": { - "@actions/core": "^1.2.6", + "@actions/core": "^1.9.1", "minimatch": "^3.0.4" }, "dependencies": { diff --git a/package.json b/package.json index 7219abe..f43f656 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@actions/artifact": "2.1.8", "@actions/core": "^1.10.1", "@actions/github": "^6.0.0", - "@actions/glob": "^0.3.0", + "@actions/glob": "^0.5.0", "@actions/io": "^1.1.2", "minimatch": "^9.0.3" }, diff --git a/src/shared/search.ts b/src/shared/search.ts index c468f14..67b2422 100644 --- a/src/shared/search.ts +++ b/src/shared/search.ts @@ -11,12 +11,12 @@ export interface SearchResult { rootDirectory: string } -function getDefaultGlobOptions(_includeHiddenFiles: boolean): glob.GlobOptions { +function getDefaultGlobOptions(includeHiddenFiles: boolean): glob.GlobOptions { return { followSymbolicLinks: true, implicitDescendants: true, omitBrokenSymbolicLinks: true, - // excludeHiddenFiles: !includeHiddenFiles, + excludeHiddenFiles: !includeHiddenFiles, } } From 0a398c14804ead69f18a166f0a99f91239261ee5 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 17:30:44 -0400 Subject: [PATCH 4/9] `npm run release` --- dist/merge/index.js | 147 ++++++++++++++++++++++++++++--------------- dist/upload/index.js | 147 ++++++++++++++++++++++++++++--------------- 2 files changed, 192 insertions(+), 102 deletions(-) diff --git a/dist/merge/index.js b/dist/merge/index.js index 699ddac..abf5610 100644 --- a/dist/merge/index.js +++ b/dist/merge/index.js @@ -8881,16 +8881,18 @@ exports.create = create; * Computes the sha256 hash of a glob * * @param patterns Patterns separated by newlines + * @param currentWorkspace Workspace used when matching files * @param options Glob options + * @param verbose Enables verbose logging */ -function hashFiles(patterns, options, verbose = false) { +function hashFiles(patterns, currentWorkspace = '', options, verbose = false) { return __awaiter(this, void 0, void 0, function* () { let followSymbolicLinks = true; if (options && typeof options.followSymbolicLinks === 'boolean') { followSymbolicLinks = options.followSymbolicLinks; } const globber = yield create(patterns, { followSymbolicLinks }); - return internal_hash_files_1.hashFiles(globber, verbose); + return (0, internal_hash_files_1.hashFiles)(globber, currentWorkspace, verbose); }); } exports.hashFiles = hashFiles; @@ -8905,7 +8907,11 @@ exports.hashFiles = hashFiles; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -8918,7 +8924,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -8933,7 +8939,8 @@ function getOptions(copy) { followSymbolicLinks: true, implicitDescendants: true, matchDirectories: true, - omitBrokenSymbolicLinks: true + omitBrokenSymbolicLinks: true, + excludeHiddenFiles: false }; if (copy) { if (typeof copy.followSymbolicLinks === 'boolean') { @@ -8952,6 +8959,10 @@ function getOptions(copy) { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } + if (typeof copy.excludeHiddenFiles === 'boolean') { + result.excludeHiddenFiles = copy.excludeHiddenFiles; + core.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + } } return result; } @@ -8967,7 +8978,11 @@ exports.getOptions = getOptions; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -8980,7 +8995,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9034,19 +9049,21 @@ class DefaultGlobber { return this.searchPaths.slice(); } glob() { - var e_1, _a; + var _a, e_1, _b, _c; return __awaiter(this, void 0, void 0, function* () { const result = []; try { - for (var _b = __asyncValues(this.globGenerator()), _c; _c = yield _b.next(), !_c.done;) { - const itemPath = _c.value; + for (var _d = true, _e = __asyncValues(this.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { + _c = _f.value; + _d = false; + const itemPath = _c; result.push(itemPath); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); + if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); } finally { if (e_1) throw e_1.error; } } @@ -9104,6 +9121,10 @@ class DefaultGlobber { if (!stats) { continue; } + // Hidden file or directory? + if (options.excludeHiddenFiles && path.basename(item.path).match(/^\./)) { + continue; + } // Directory if (stats.isDirectory()) { // Matched @@ -9209,7 +9230,11 @@ exports.DefaultGlobber = DefaultGlobber; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9222,7 +9247,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9250,18 +9275,22 @@ const fs = __importStar(__nccwpck_require__(57147)); const stream = __importStar(__nccwpck_require__(12781)); const util = __importStar(__nccwpck_require__(73837)); const path = __importStar(__nccwpck_require__(71017)); -function hashFiles(globber, verbose = false) { - var e_1, _a; - var _b; +function hashFiles(globber, currentWorkspace, verbose = false) { + var _a, e_1, _b, _c; + var _d; return __awaiter(this, void 0, void 0, function* () { const writeDelegate = verbose ? core.info : core.debug; let hasMatch = false; - const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd(); + const githubWorkspace = currentWorkspace + ? currentWorkspace + : (_d = process.env['GITHUB_WORKSPACE']) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto.createHash('sha256'); let count = 0; try { - for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) { - const file = _d.value; + for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) { + _c = _g.value; + _e = false; + const file = _c; writeDelegate(file); if (!file.startsWith(`${githubWorkspace}${path.sep}`)) { writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`); @@ -9284,7 +9313,7 @@ function hashFiles(globber, verbose = false) { catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c); + if (!_e && !_a && (_b = _f.return)) yield _b.call(_f); } finally { if (e_1) throw e_1.error; } } @@ -9324,7 +9353,7 @@ var MatchKind; MatchKind[MatchKind["File"] = 2] = "File"; /** Matched */ MatchKind[MatchKind["All"] = 3] = "All"; -})(MatchKind = exports.MatchKind || (exports.MatchKind = {})); +})(MatchKind || (exports.MatchKind = MatchKind = {})); //# sourceMappingURL=internal-match-kind.js.map /***/ }), @@ -9336,7 +9365,11 @@ var MatchKind; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9349,7 +9382,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9399,8 +9432,8 @@ exports.dirname = dirname; * or `C:` are expanded based on the current working directory. */ function ensureAbsoluteRoot(root, itemPath) { - assert_1.default(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); - assert_1.default(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); + (0, assert_1.default)(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); + (0, assert_1.default)(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); // Already rooted if (hasAbsoluteRoot(itemPath)) { return itemPath; @@ -9410,7 +9443,7 @@ function ensureAbsoluteRoot(root, itemPath) { // Check for itemPath like C: or C:foo if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) { let cwd = process.cwd(); - assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); + (0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); // Drive letter matches cwd? Expand to cwd if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) { // Drive only, e.g. C: @@ -9435,11 +9468,11 @@ function ensureAbsoluteRoot(root, itemPath) { // Check for itemPath like \ or \foo else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) { const cwd = process.cwd(); - assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); + (0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); return `${cwd[0]}:\\${itemPath.substr(1)}`; } } - assert_1.default(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); + (0, assert_1.default)(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); // Otherwise ensure root ends with a separator if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) { // Intentionally empty @@ -9456,7 +9489,7 @@ exports.ensureAbsoluteRoot = ensureAbsoluteRoot; * `\\hello\share` and `C:\hello` (and using alternate separator). */ function hasAbsoluteRoot(itemPath) { - assert_1.default(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); + (0, assert_1.default)(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); // Normalize separators itemPath = normalizeSeparators(itemPath); // Windows @@ -9473,7 +9506,7 @@ exports.hasAbsoluteRoot = hasAbsoluteRoot; * `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator). */ function hasRoot(itemPath) { - assert_1.default(itemPath, `isRooted parameter 'itemPath' must not be empty`); + (0, assert_1.default)(itemPath, `isRooted parameter 'itemPath' must not be empty`); // Normalize separators itemPath = normalizeSeparators(itemPath); // Windows @@ -9541,7 +9574,11 @@ exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9554,7 +9591,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9579,7 +9616,7 @@ class Path { this.segments = []; // String if (typeof itemPath === 'string') { - assert_1.default(itemPath, `Parameter 'itemPath' must not be empty`); + (0, assert_1.default)(itemPath, `Parameter 'itemPath' must not be empty`); // Normalize slashes and trim unnecessary trailing slash itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); // Not rooted @@ -9606,24 +9643,24 @@ class Path { // Array else { // Must not be empty - assert_1.default(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); + (0, assert_1.default)(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); // Each segment for (let i = 0; i < itemPath.length; i++) { let segment = itemPath[i]; // Must not be empty - assert_1.default(segment, `Parameter 'itemPath' must not contain any empty segments`); + (0, assert_1.default)(segment, `Parameter 'itemPath' must not contain any empty segments`); // Normalize slashes segment = pathHelper.normalizeSeparators(itemPath[i]); // Root segment if (i === 0 && pathHelper.hasRoot(segment)) { segment = pathHelper.safeTrimTrailingSeparator(segment); - assert_1.default(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); + (0, assert_1.default)(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); this.segments.push(segment); } // All other segments else { // Must not contain slash - assert_1.default(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); + (0, assert_1.default)(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); this.segments.push(segment); } } @@ -9661,7 +9698,11 @@ exports.Path = Path; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9674,7 +9715,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9762,7 +9803,11 @@ exports.partialMatch = partialMatch; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9775,7 +9820,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9807,9 +9852,9 @@ class Pattern { else { // Convert to pattern segments = segments || []; - assert_1.default(segments.length, `Parameter 'segments' must not empty`); + (0, assert_1.default)(segments.length, `Parameter 'segments' must not empty`); const root = Pattern.getLiteral(segments[0]); - assert_1.default(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); + (0, assert_1.default)(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); pattern = new internal_path_1.Path(segments).toString().trim(); if (patternOrNegate) { pattern = `!${pattern}`; @@ -9903,13 +9948,13 @@ class Pattern { */ static fixupPattern(pattern, homedir) { // Empty - assert_1.default(pattern, 'pattern cannot be empty'); + (0, assert_1.default)(pattern, 'pattern cannot be empty'); // Must not contain `.` segment, unless first segment // Must not contain `..` segment const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x)); - assert_1.default(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); + (0, assert_1.default)(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); // Must not contain globs in root, e.g. Windows UNC path \\foo\b*r - assert_1.default(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); + (0, assert_1.default)(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); // Normalize slashes pattern = pathHelper.normalizeSeparators(pattern); // Replace leading `.` segment @@ -9919,8 +9964,8 @@ class Pattern { // Replace leading `~` segment else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) { homedir = homedir || os.homedir(); - assert_1.default(homedir, 'Unable to determine HOME directory'); - assert_1.default(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); + (0, assert_1.default)(homedir, 'Unable to determine HOME directory'); + (0, assert_1.default)(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); pattern = Pattern.globEscape(homedir) + pattern.substr(1); } // Replace relative drive root, e.g. pattern is C: or C:foo @@ -125819,7 +125864,7 @@ function getInputs() { deleteMerged, retentionDays: 0, compressionLevel: 6, - includeHiddenFiles, + includeHiddenFiles }; const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays); if (retentionDaysStr) { @@ -126002,12 +126047,12 @@ const fs_1 = __nccwpck_require__(57147); const path_1 = __nccwpck_require__(71017); const util_1 = __nccwpck_require__(73837); const stats = (0, util_1.promisify)(fs_1.stat); -function getDefaultGlobOptions(_includeHiddenFiles) { +function getDefaultGlobOptions(includeHiddenFiles) { return { followSymbolicLinks: true, implicitDescendants: true, omitBrokenSymbolicLinks: true, - // excludeHiddenFiles: !includeHiddenFiles, + excludeHiddenFiles: !includeHiddenFiles, }; } /** diff --git a/dist/upload/index.js b/dist/upload/index.js index d3b8743..7937adc 100644 --- a/dist/upload/index.js +++ b/dist/upload/index.js @@ -8881,16 +8881,18 @@ exports.create = create; * Computes the sha256 hash of a glob * * @param patterns Patterns separated by newlines + * @param currentWorkspace Workspace used when matching files * @param options Glob options + * @param verbose Enables verbose logging */ -function hashFiles(patterns, options, verbose = false) { +function hashFiles(patterns, currentWorkspace = '', options, verbose = false) { return __awaiter(this, void 0, void 0, function* () { let followSymbolicLinks = true; if (options && typeof options.followSymbolicLinks === 'boolean') { followSymbolicLinks = options.followSymbolicLinks; } const globber = yield create(patterns, { followSymbolicLinks }); - return internal_hash_files_1.hashFiles(globber, verbose); + return (0, internal_hash_files_1.hashFiles)(globber, currentWorkspace, verbose); }); } exports.hashFiles = hashFiles; @@ -8905,7 +8907,11 @@ exports.hashFiles = hashFiles; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -8918,7 +8924,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -8933,7 +8939,8 @@ function getOptions(copy) { followSymbolicLinks: true, implicitDescendants: true, matchDirectories: true, - omitBrokenSymbolicLinks: true + omitBrokenSymbolicLinks: true, + excludeHiddenFiles: false }; if (copy) { if (typeof copy.followSymbolicLinks === 'boolean') { @@ -8952,6 +8959,10 @@ function getOptions(copy) { result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); } + if (typeof copy.excludeHiddenFiles === 'boolean') { + result.excludeHiddenFiles = copy.excludeHiddenFiles; + core.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`); + } } return result; } @@ -8967,7 +8978,11 @@ exports.getOptions = getOptions; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -8980,7 +8995,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9034,19 +9049,21 @@ class DefaultGlobber { return this.searchPaths.slice(); } glob() { - var e_1, _a; + var _a, e_1, _b, _c; return __awaiter(this, void 0, void 0, function* () { const result = []; try { - for (var _b = __asyncValues(this.globGenerator()), _c; _c = yield _b.next(), !_c.done;) { - const itemPath = _c.value; + for (var _d = true, _e = __asyncValues(this.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { + _c = _f.value; + _d = false; + const itemPath = _c; result.push(itemPath); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); + if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); } finally { if (e_1) throw e_1.error; } } @@ -9104,6 +9121,10 @@ class DefaultGlobber { if (!stats) { continue; } + // Hidden file or directory? + if (options.excludeHiddenFiles && path.basename(item.path).match(/^\./)) { + continue; + } // Directory if (stats.isDirectory()) { // Matched @@ -9209,7 +9230,11 @@ exports.DefaultGlobber = DefaultGlobber; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9222,7 +9247,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9250,18 +9275,22 @@ const fs = __importStar(__nccwpck_require__(57147)); const stream = __importStar(__nccwpck_require__(12781)); const util = __importStar(__nccwpck_require__(73837)); const path = __importStar(__nccwpck_require__(71017)); -function hashFiles(globber, verbose = false) { - var e_1, _a; - var _b; +function hashFiles(globber, currentWorkspace, verbose = false) { + var _a, e_1, _b, _c; + var _d; return __awaiter(this, void 0, void 0, function* () { const writeDelegate = verbose ? core.info : core.debug; let hasMatch = false; - const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd(); + const githubWorkspace = currentWorkspace + ? currentWorkspace + : (_d = process.env['GITHUB_WORKSPACE']) !== null && _d !== void 0 ? _d : process.cwd(); const result = crypto.createHash('sha256'); let count = 0; try { - for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) { - const file = _d.value; + for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) { + _c = _g.value; + _e = false; + const file = _c; writeDelegate(file); if (!file.startsWith(`${githubWorkspace}${path.sep}`)) { writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`); @@ -9284,7 +9313,7 @@ function hashFiles(globber, verbose = false) { catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c); + if (!_e && !_a && (_b = _f.return)) yield _b.call(_f); } finally { if (e_1) throw e_1.error; } } @@ -9324,7 +9353,7 @@ var MatchKind; MatchKind[MatchKind["File"] = 2] = "File"; /** Matched */ MatchKind[MatchKind["All"] = 3] = "All"; -})(MatchKind = exports.MatchKind || (exports.MatchKind = {})); +})(MatchKind || (exports.MatchKind = MatchKind = {})); //# sourceMappingURL=internal-match-kind.js.map /***/ }), @@ -9336,7 +9365,11 @@ var MatchKind; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9349,7 +9382,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9399,8 +9432,8 @@ exports.dirname = dirname; * or `C:` are expanded based on the current working directory. */ function ensureAbsoluteRoot(root, itemPath) { - assert_1.default(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); - assert_1.default(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); + (0, assert_1.default)(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); + (0, assert_1.default)(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); // Already rooted if (hasAbsoluteRoot(itemPath)) { return itemPath; @@ -9410,7 +9443,7 @@ function ensureAbsoluteRoot(root, itemPath) { // Check for itemPath like C: or C:foo if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) { let cwd = process.cwd(); - assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); + (0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); // Drive letter matches cwd? Expand to cwd if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) { // Drive only, e.g. C: @@ -9435,11 +9468,11 @@ function ensureAbsoluteRoot(root, itemPath) { // Check for itemPath like \ or \foo else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) { const cwd = process.cwd(); - assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); + (0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); return `${cwd[0]}:\\${itemPath.substr(1)}`; } } - assert_1.default(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); + (0, assert_1.default)(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); // Otherwise ensure root ends with a separator if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) { // Intentionally empty @@ -9456,7 +9489,7 @@ exports.ensureAbsoluteRoot = ensureAbsoluteRoot; * `\\hello\share` and `C:\hello` (and using alternate separator). */ function hasAbsoluteRoot(itemPath) { - assert_1.default(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); + (0, assert_1.default)(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); // Normalize separators itemPath = normalizeSeparators(itemPath); // Windows @@ -9473,7 +9506,7 @@ exports.hasAbsoluteRoot = hasAbsoluteRoot; * `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator). */ function hasRoot(itemPath) { - assert_1.default(itemPath, `isRooted parameter 'itemPath' must not be empty`); + (0, assert_1.default)(itemPath, `isRooted parameter 'itemPath' must not be empty`); // Normalize separators itemPath = normalizeSeparators(itemPath); // Windows @@ -9541,7 +9574,11 @@ exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9554,7 +9591,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9579,7 +9616,7 @@ class Path { this.segments = []; // String if (typeof itemPath === 'string') { - assert_1.default(itemPath, `Parameter 'itemPath' must not be empty`); + (0, assert_1.default)(itemPath, `Parameter 'itemPath' must not be empty`); // Normalize slashes and trim unnecessary trailing slash itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); // Not rooted @@ -9606,24 +9643,24 @@ class Path { // Array else { // Must not be empty - assert_1.default(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); + (0, assert_1.default)(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); // Each segment for (let i = 0; i < itemPath.length; i++) { let segment = itemPath[i]; // Must not be empty - assert_1.default(segment, `Parameter 'itemPath' must not contain any empty segments`); + (0, assert_1.default)(segment, `Parameter 'itemPath' must not contain any empty segments`); // Normalize slashes segment = pathHelper.normalizeSeparators(itemPath[i]); // Root segment if (i === 0 && pathHelper.hasRoot(segment)) { segment = pathHelper.safeTrimTrailingSeparator(segment); - assert_1.default(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); + (0, assert_1.default)(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); this.segments.push(segment); } // All other segments else { // Must not contain slash - assert_1.default(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); + (0, assert_1.default)(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); this.segments.push(segment); } } @@ -9661,7 +9698,11 @@ exports.Path = Path; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9674,7 +9715,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9762,7 +9803,11 @@ exports.partialMatch = partialMatch; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; @@ -9775,7 +9820,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9807,9 +9852,9 @@ class Pattern { else { // Convert to pattern segments = segments || []; - assert_1.default(segments.length, `Parameter 'segments' must not empty`); + (0, assert_1.default)(segments.length, `Parameter 'segments' must not empty`); const root = Pattern.getLiteral(segments[0]); - assert_1.default(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); + (0, assert_1.default)(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); pattern = new internal_path_1.Path(segments).toString().trim(); if (patternOrNegate) { pattern = `!${pattern}`; @@ -9903,13 +9948,13 @@ class Pattern { */ static fixupPattern(pattern, homedir) { // Empty - assert_1.default(pattern, 'pattern cannot be empty'); + (0, assert_1.default)(pattern, 'pattern cannot be empty'); // Must not contain `.` segment, unless first segment // Must not contain `..` segment const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x)); - assert_1.default(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); + (0, assert_1.default)(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); // Must not contain globs in root, e.g. Windows UNC path \\foo\b*r - assert_1.default(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); + (0, assert_1.default)(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); // Normalize slashes pattern = pathHelper.normalizeSeparators(pattern); // Replace leading `.` segment @@ -9919,8 +9964,8 @@ class Pattern { // Replace leading `~` segment else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) { homedir = homedir || os.homedir(); - assert_1.default(homedir, 'Unable to determine HOME directory'); - assert_1.default(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); + (0, assert_1.default)(homedir, 'Unable to determine HOME directory'); + (0, assert_1.default)(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); pattern = Pattern.globEscape(homedir) + pattern.substr(1); } // Replace relative drive root, e.g. pattern is C: or C:foo @@ -125757,12 +125802,12 @@ const fs_1 = __nccwpck_require__(57147); const path_1 = __nccwpck_require__(71017); const util_1 = __nccwpck_require__(73837); const stats = (0, util_1.promisify)(fs_1.stat); -function getDefaultGlobOptions(_includeHiddenFiles) { +function getDefaultGlobOptions(includeHiddenFiles) { return { followSymbolicLinks: true, implicitDescendants: true, omitBrokenSymbolicLinks: true, - // excludeHiddenFiles: !includeHiddenFiles, + excludeHiddenFiles: !includeHiddenFiles, }; } /** @@ -126066,7 +126111,7 @@ function getInputs() { searchPath: path, ifNoFilesFound: noFileBehavior, overwrite: overwrite, - includeHiddenFiles: includeHiddenFiles, + includeHiddenFiles: includeHiddenFiles }; const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays); if (retentionDaysStr) { From 453e8d0a40444939146df5febed0b1221b9dd073 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 17:31:21 -0400 Subject: [PATCH 5/9] Update glob license --- .licenses/npm/@actions/glob.dep.yml | Bin 1229 -> 1229 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.licenses/npm/@actions/glob.dep.yml b/.licenses/npm/@actions/glob.dep.yml index ef0579276c863b1360e637d28842d9e5f6f38631..0df84784759fcc0d8fc23cb4d455a5a5387af131 100644 GIT binary patch delta 12 TcmX@hd6sj6Dx>K}wdE`T9e4y9 delta 12 TcmX@hd6sj6Dx>j6wdE`T9c}~| From 3be2180eb79b56341b1b127ca06a5adba2a5a3e4 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 17:35:00 -0400 Subject: [PATCH 6/9] Remove another trailing comma --- src/shared/search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/search.ts b/src/shared/search.ts index 67b2422..e573f83 100644 --- a/src/shared/search.ts +++ b/src/shared/search.ts @@ -16,7 +16,7 @@ function getDefaultGlobOptions(includeHiddenFiles: boolean): glob.GlobOptions { followSymbolicLinks: true, implicitDescendants: true, omitBrokenSymbolicLinks: true, - excludeHiddenFiles: !includeHiddenFiles, + excludeHiddenFiles: !includeHiddenFiles } } From 3b315f26f6f828f74089e1863e67e60e48e37563 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 17:36:20 -0400 Subject: [PATCH 7/9] =?UTF-8?q?`npm=20run=20release`=20again=20?= =?UTF-8?q?=F0=9F=99=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/merge/index.js | 2 +- dist/upload/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/merge/index.js b/dist/merge/index.js index abf5610..af01cf6 100644 --- a/dist/merge/index.js +++ b/dist/merge/index.js @@ -126052,7 +126052,7 @@ function getDefaultGlobOptions(includeHiddenFiles) { followSymbolicLinks: true, implicitDescendants: true, omitBrokenSymbolicLinks: true, - excludeHiddenFiles: !includeHiddenFiles, + excludeHiddenFiles: !includeHiddenFiles }; } /** diff --git a/dist/upload/index.js b/dist/upload/index.js index 7937adc..22ef724 100644 --- a/dist/upload/index.js +++ b/dist/upload/index.js @@ -125807,7 +125807,7 @@ function getDefaultGlobOptions(includeHiddenFiles) { followSymbolicLinks: true, implicitDescendants: true, omitBrokenSymbolicLinks: true, - excludeHiddenFiles: !includeHiddenFiles, + excludeHiddenFiles: !includeHiddenFiles }; } /** From 710f36207581d49e465ccbed3e007c317290fe11 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 19:39:39 -0400 Subject: [PATCH 8/9] Remove "merged" from `include-hidden-files` input description --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d3eb907..ef24659 100644 --- a/action.yml +++ b/action.yml @@ -42,8 +42,8 @@ inputs: default: 'false' include-hidden-files: description: > - If true, hidden files will be included in the merged artifact. - If false, hidden files will be excluded from the merged artifact. + If true, hidden files will be included in the artifact. + If false, hidden files will be excluded from the artifact. default: 'false' outputs: From d52396ac5d312b1bda1b9fe2ae55d862c65abd68 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 15 Aug 2024 19:45:59 -0400 Subject: [PATCH 9/9] Add a warning about enabling `include-hidden-files` --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8143668..9b4d3ee 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md). overwrite: # Whether to include hidden files in the provided path in the artifact + # The file contents of any hidden files in the path should be validated before + # enabled this to avoid uploading sensitive information. # Optional. Default is 'false' include-hidden-files: ```