From 2bdae5bf26847e5b97e5226405d11925ad7883a1 Mon Sep 17 00:00:00 2001 From: Ricardo Devis Agullo Date: Thu, 12 Jan 2023 18:05:41 +0100 Subject: [PATCH] remove putdir method --- .../__mocks__/@azure/storage-blob.js | 19 -------- .../__test__/azure.test.ts | 39 +--------------- .../__test__/privateFilesExclusion.test.ts | 26 ----------- .../oc-azure-storage-adapter/package.json | 6 +-- .../oc-azure-storage-adapter/src/index.ts | 39 ---------------- .../oc-gs-storage-adapter/__test__/gs.test.ts | 42 +---------------- .../__test__/privateFilesExclusion.test.ts | 44 ------------------ packages/oc-gs-storage-adapter/package.json | 4 +- packages/oc-gs-storage-adapter/src/index.ts | 39 ---------------- .../__test__/s3.test.ts | 45 +------------------ .../__mocks__/@aws-sdk/client-s3.js | 19 -------- .../__test__/privateFilesExclusion.test.ts | 28 ------------ .../oc-s3-storage-adapter/__test__/s3.test.ts | 45 +------------------ packages/oc-s3-storage-adapter/package.json | 6 +-- packages/oc-s3-storage-adapter/src/index.ts | 39 ---------------- .../oc-storage-adapters-utils/src/index.ts | 1 - 16 files changed, 13 insertions(+), 428 deletions(-) delete mode 100644 packages/oc-azure-storage-adapter/__test__/privateFilesExclusion.test.ts delete mode 100644 packages/oc-gs-storage-adapter/__test__/privateFilesExclusion.test.ts delete mode 100644 packages/oc-s3-storage-adapter/__test__/privateFilesExclusion.test.ts diff --git a/packages/oc-azure-storage-adapter/__mocks__/@azure/storage-blob.js b/packages/oc-azure-storage-adapter/__mocks__/@azure/storage-blob.js index 753decb..0bcd74f 100644 --- a/packages/oc-azure-storage-adapter/__mocks__/@azure/storage-blob.js +++ b/packages/oc-azure-storage-adapter/__mocks__/@azure/storage-blob.js @@ -8,25 +8,6 @@ jest.mock('fs-extra', () => { }; }); -jest.mock('node-dir', () => { - return { - paths: jest.fn((pathToDir, cb) => { - cb(null, { - files: [ - `${pathToDir}\\package.json`, - `${pathToDir}\\server.js`, - `${pathToDir}\\.env`, - `${pathToDir}\\template.js`, - `${pathToDir}/package.json`, - `${pathToDir}/server.js`, - `${pathToDir}/.env`, - `${pathToDir}/template.js` - ] - }); - }) - }; -}); - let cachedTxt = 0; let cachedJson = 0; diff --git a/packages/oc-azure-storage-adapter/__test__/azure.test.ts b/packages/oc-azure-storage-adapter/__test__/azure.test.ts index a3c407b..afcb572 100644 --- a/packages/oc-azure-storage-adapter/__test__/azure.test.ts +++ b/packages/oc-azure-storage-adapter/__test__/azure.test.ts @@ -15,7 +15,8 @@ const validOptions = { privateContainerName: 'privcon', accountName: 'name', accountKey: 'key', - path: '/' + path: '/', + componentsDir: 'components' }; test('should expose the correct methods', () => { @@ -29,7 +30,6 @@ test('should expose the correct methods', () => { { method: 'isValid', type: Function }, { method: 'listSubDirectories', type: Function }, { method: 'maxConcurrentRequests', value: 20 }, - { method: 'putDir', type: Function }, { method: 'putFileContent', type: Function } ].forEach(api => { if (api.type === Function) { @@ -201,41 +201,6 @@ test('test getUrl ', () => { expect(client.getUrl('test', '1.0.0', 'test.js')).toBe('/test/1.0.0/test.js'); }); -test('test put dir (failure)', () => { - const client = azure(validOptions); - - return expect( - client.putDir( - '/absolute-path-to-dir', - 'components\\componentName-error\\1.0.0' - ) - ).rejects.toEqual({ msg: 'sorry' }); -}); - -test('test put dir (stream failure throwing)', () => { - const client = azure(validOptions); - - return expect( - client.putDir( - '/absolute-path-to-dir', - 'components\\componentName-error-throw\\1.0.0' - ) - ).rejects.toEqual({ msg: 'sorry' }); -}); - -test('Put dir uploads the package.json the last file to use it as a verifier', async () => { - const client = azure(validOptions); - - const results = (await client.putDir( - '/absolute-path-to-dir', - 'components\\componentName\\1.0.0' - )) as any[]; - - expect(results.pop().fileName).toBe( - 'components/componentName/1.0.0/package.json' - ); -}); - test('test private putFileContent', async () => { const client = azure(validOptions); diff --git a/packages/oc-azure-storage-adapter/__test__/privateFilesExclusion.test.ts b/packages/oc-azure-storage-adapter/__test__/privateFilesExclusion.test.ts deleted file mode 100644 index 4bf4c7c..0000000 --- a/packages/oc-azure-storage-adapter/__test__/privateFilesExclusion.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ -import adapter from '../src'; - -test('put directory recognizes server.js and .env to be private', async () => { - const client = adapter({ - publicContainerName: 'pubcon', - privateContainerName: 'privcon', - accountName: 'name', - accountKey: 'key', - path: '/' - }); - - const mockResult = (await client.putDir('.', '.')) as Array<{ - fileName: string; - container: string; - }>; - const serverMock = mockResult.find(x => x.fileName === `./server.js`)!; - const envMock = mockResult.find(x => x.fileName === './.env')!; - const packageMock = mockResult.find(x => x.fileName === './package.json')!; - const templateMock = mockResult.find(x => x.fileName === './template.js')!; - - expect(serverMock.container).toBe('privcon'); - expect(envMock.container).toBe('privcon'); - expect(packageMock.container).toBe('pubcon'); - expect(templateMock.container).toBe('pubcon'); -}); diff --git a/packages/oc-azure-storage-adapter/package.json b/packages/oc-azure-storage-adapter/package.json index 7b4c96f..433c670 100644 --- a/packages/oc-azure-storage-adapter/package.json +++ b/packages/oc-azure-storage-adapter/package.json @@ -36,12 +36,10 @@ "fs-extra": "8.1.0", "lodash": "^4.17.4", "nice-cache": "^0.0.5", - "node-dir": "^0.1.17", "oc-storage-adapters-utils": "2.0.2" }, "devDependencies": { "@types/fs-extra": "9.0.13", - "@types/lodash": "4.14.186", - "@types/node-dir": "0.0.34" + "@types/lodash": "4.14.186" } -} +} \ No newline at end of file diff --git a/packages/oc-azure-storage-adapter/src/index.ts b/packages/oc-azure-storage-adapter/src/index.ts index 451b3db..8ef8a91 100644 --- a/packages/oc-azure-storage-adapter/src/index.ts +++ b/packages/oc-azure-storage-adapter/src/index.ts @@ -5,19 +5,12 @@ import { } from '@azure/storage-blob'; import Cache from 'nice-cache'; import fs from 'fs-extra'; -import nodeDir, { PathsResult } from 'node-dir'; -import { promisify } from 'util'; import { getFileInfo, strings, StorageAdapter, StorageAdapterBaseConfig } from 'oc-storage-adapters-utils'; -import path from 'path'; - -const getPaths: (path: string) => Promise = promisify( - nodeDir.paths -); // [Node.js only] A helper method used to read a Node.js readable stream into a Buffer async function streamToBuffer(readableStream: NodeJS.ReadableStream) { @@ -154,37 +147,6 @@ export default function azureAdapter(conf: AzureConfig): StorageAdapter { return subDirectories; }; - const putDir = async (dirInput: string, dirOutput: string) => { - const paths = await getPaths(dirInput); - const packageJsonFile = path.join(dirInput, 'package.json'); - const files = paths.files.filter(file => file !== packageJsonFile); - - const filesResults = await Promise.all( - files.map((file: string) => { - const relativeFile = file.slice(dirInput.length); - const url = (dirOutput + relativeFile).replace(/\\/g, '/'); - - const serverPattern = /(\\|\/)server\.js/; - const dotFilePattern = /(\\|\/)\..+/; - const privateFilePatterns = [serverPattern, dotFilePattern]; - return putFile( - file, - url, - privateFilePatterns.some(r => r.test(relativeFile)) - ); - }) - ); - // Ensuring package.json is uploaded last so we can verify that a component - // was properly uploaded by checking if package.json exists - const packageJsonFileResult = await putFile( - packageJsonFile, - `${dirOutput}/package.json`.replace(/\\/g, '/'), - false - ); - - return [...filesResults, packageJsonFileResult]; - }; - const putFileContent = async ( fileContent: string | fs.ReadStream, fileName: string, @@ -235,7 +197,6 @@ export default function azureAdapter(conf: AzureConfig): StorageAdapter { getUrl, listSubDirectories, maxConcurrentRequests: 20, - putDir, putFile, putFileContent, adapterType: 'azure-blob-storage', diff --git a/packages/oc-gs-storage-adapter/__test__/gs.test.ts b/packages/oc-gs-storage-adapter/__test__/gs.test.ts index 0dbe3d4..d8c1d02 100644 --- a/packages/oc-gs-storage-adapter/__test__/gs.test.ts +++ b/packages/oc-gs-storage-adapter/__test__/gs.test.ts @@ -1,22 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import gs from '../src'; -jest.mock('node-dir', () => { - return { - paths: jest.fn((pathToDir, cb) => { - const sep = require('path').sep; - cb(null, { - files: [ - `${pathToDir}${sep}package.json`, - `${pathToDir}${sep}server.js`, - `${pathToDir}${sep}.env`, - `${pathToDir}${sep}template.js` - ] - }); - }) - }; -}); - //Mock Date functions const DATE_TO_USE = new Date('2017'); const _Date = Date; @@ -28,7 +12,8 @@ global.Date.now = _Date.now; const validOptions = { bucket: 'test', projectId: '12345', - path: '/' + path: '/', + componentsDir: 'components' }; test('should expose the correct methods', () => { @@ -41,7 +26,6 @@ test('should expose the correct methods', () => { { method: 'isValid', type: Function }, { method: 'listSubDirectories', type: Function }, { method: 'maxConcurrentRequests', value: 20 }, - { method: 'putDir', type: Function }, { method: 'putFileContent', type: Function } ].forEach(api => { if (api.type === Function) { @@ -189,28 +173,6 @@ test('test getUrl ', () => { expect(client.getUrl('test', '1.0.0', 'test.js')).toBe('/test/1.0.0/test.js'); }); -test('test put dir (failure)', () => { - const client = gs(validOptions); - - return expect( - client.putDir( - '/absolute-path-to-dir', - 'components\\componentName-error\\1.0.0' - ) - ).rejects.toEqual({ code: 1234, msg: 'an error message' }); -}); - -test('Put dir uploads the package.json the last file to use it as a verifier', async () => { - const client = gs(validOptions); - - const results = (await client.putDir( - '/absolute-path-to-dir', - 'components\\componentName\\1.0.0' - )) as any[]; - - expect(results.pop().Key).toBe('components/componentName/1.0.0/package.json'); -}); - test('test private putFileContent ', async () => { const client = gs(validOptions); diff --git a/packages/oc-gs-storage-adapter/__test__/privateFilesExclusion.test.ts b/packages/oc-gs-storage-adapter/__test__/privateFilesExclusion.test.ts deleted file mode 100644 index b9ccfdc..0000000 --- a/packages/oc-gs-storage-adapter/__test__/privateFilesExclusion.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ -import gs from '../src'; - -jest.mock('node-dir', () => { - return { - paths: jest.fn((pathToDir, cb) => { - cb(null, { - files: [ - `${pathToDir}\\package.json`, - `${pathToDir}\\server.js`, - `${pathToDir}\\.env`, - `${pathToDir}\\template.js`, - `${pathToDir}/package.json`, - `${pathToDir}/server.js`, - `${pathToDir}/.env`, - `${pathToDir}/template.js` - ] - }); - }) - }; -}); - -test('put directory recognizes server.js and .env to be private', async () => { - const options = { - bucket: 'test', - projectId: '12345', - path: 'somepath' - }; - const client = gs(options); - - const mockResult = (await client.putDir('.', '.')) as Array<{ - Key: string; - ACL: string; - }>; - const serverMock = mockResult.find(x => x.Key === `./server.js`)!; - const envMock = mockResult.find(x => x.Key === './.env')!; - const packageMock = mockResult.find(x => x.Key === './package.json')!; - const templateMock = mockResult.find(x => x.Key === './template.js')!; - - expect(serverMock.ACL).toBe('authenticated-read'); - expect(envMock.ACL).toBe('authenticated-read'); - expect(packageMock.ACL).toBe('public-read'); - expect(templateMock.ACL).toBe('public-read'); -}); diff --git a/packages/oc-gs-storage-adapter/package.json b/packages/oc-gs-storage-adapter/package.json index 673191f..aa3fbc7 100644 --- a/packages/oc-gs-storage-adapter/package.json +++ b/packages/oc-gs-storage-adapter/package.json @@ -35,14 +35,12 @@ "fs-extra": "8.1.0", "lodash": "^4.17.4", "nice-cache": "^0.0.5", - "node-dir": "^0.1.17", "oc-storage-adapters-utils": "2.0.2", "tmp": "0.1.0" }, "devDependencies": { "@types/fs-extra": "9.0.13", "@types/lodash": "4.14.186", - "@types/node-dir": "0.0.34", "@types/tmp": "0.2.3" } -} +} \ No newline at end of file diff --git a/packages/oc-gs-storage-adapter/src/index.ts b/packages/oc-gs-storage-adapter/src/index.ts index f257ab9..df71ab7 100644 --- a/packages/oc-gs-storage-adapter/src/index.ts +++ b/packages/oc-gs-storage-adapter/src/index.ts @@ -1,6 +1,5 @@ import Cache from 'nice-cache'; import fs from 'fs-extra'; -import nodeDir, { PathsResult } from 'node-dir'; import { Storage, UploadOptions } from '@google-cloud/storage'; import tmp from 'tmp'; import { @@ -9,12 +8,6 @@ import { StorageAdapter, StorageAdapterBaseConfig } from 'oc-storage-adapters-utils'; -import { promisify } from 'util'; -import path from 'path'; - -const getPaths: (path: string) => Promise = promisify( - nodeDir.paths -); export interface GsConfig extends StorageAdapterBaseConfig { bucket: string; @@ -139,37 +132,6 @@ export default function gsAdapter(conf: GsConfig): StorageAdapter { } }; - const putDir = async (dirInput: string, dirOutput: string) => { - const paths = await getPaths(dirInput); - const packageJsonFile = path.join(dirInput, 'package.json'); - const files = paths.files.filter(file => file !== packageJsonFile); - - const filesResults = await Promise.all( - files.map((file: string) => { - const relativeFile = file.slice(dirInput.length); - const url = (dirOutput + relativeFile).replace(/\\/g, '/'); - - const serverPattern = /(\\|\/)server\.js/; - const dotFilePattern = /(\\|\/)\..+/; - const privateFilePatterns = [serverPattern, dotFilePattern]; - return putFile( - file, - url, - privateFilePatterns.some(r => r.test(relativeFile)) - ); - }) - ); - // Ensuring package.json is uploaded last so we can verify that a component - // was properly uploaded by checking if package.json exists - const packageJsonFileResult = await putFile( - packageJsonFile, - `${dirOutput}/package.json`.replace(/\\/g, '/'), - false - ); - - return [...filesResults, packageJsonFileResult]; - }; - const putFileContent = async ( fileContent: string, fileName: string, @@ -241,7 +203,6 @@ export default function gsAdapter(conf: GsConfig): StorageAdapter { getUrl, listSubDirectories, maxConcurrentRequests: 20, - putDir, putFile, putFileContent, adapterType: 'gs', diff --git a/packages/oc-riak-storage-adapter/__test__/s3.test.ts b/packages/oc-riak-storage-adapter/__test__/s3.test.ts index 1e12632..ad298db 100644 --- a/packages/oc-riak-storage-adapter/__test__/s3.test.ts +++ b/packages/oc-riak-storage-adapter/__test__/s3.test.ts @@ -14,7 +14,8 @@ const validOptions = { region: 'region-test', key: 'test-key', secret: 'test-secret', - path: '/' + path: '/', + componentsDir: 'components' }; test('should expose the correct methods', () => { @@ -28,7 +29,6 @@ test('should expose the correct methods', () => { { method: 'isValid', type: Function }, { method: 'listSubDirectories', type: Function }, { method: 'maxConcurrentRequests', value: 20 }, - { method: 'putDir', type: Function }, { method: 'putFileContent', type: Function } ].forEach(api => { if (api.type === Function) { @@ -204,47 +204,6 @@ test('test getUrl ', () => { expect(client.getUrl('test', '1.0.0', 'test.js')).toBe('/test/1.0.0/test.js'); }); -test('test put dir (failure)', () => { - const client = s3(validOptions); - - return expect( - client.putDir( - '/absolute-path-to-dir', - 'components\\componentName-error\\1.0.0' - ) - ).rejects.toEqual({ - code: 1234, - message: 'an error message', - retryable: true, - statusCode: 500, - time: DATE_TO_USE, - hostname: 'hostname', - region: 'us-west2' - }); -}); - -test('test put dir (stream failure throwing)', () => { - const client = s3(validOptions); - - return expect( - client.putDir( - '/absolute-path-to-dir', - 'components\\componentName-error-throw\\1.0.0' - ) - ).rejects.toThrow('sorry'); -}); - -test('Put dir uploads the package.json the last file to use it as a verifier', async () => { - const client = s3(validOptions); - - const results = (await client.putDir( - '/absolute-path-to-dir', - 'components\\componentName\\1.0.0' - )) as any[]; - - expect(results.pop().Key).toBe('components/componentName/1.0.0/package.json'); -}); - test('test private putFileContent ', async () => { const client = s3(validOptions); diff --git a/packages/oc-s3-storage-adapter/__mocks__/@aws-sdk/client-s3.js b/packages/oc-s3-storage-adapter/__mocks__/@aws-sdk/client-s3.js index fcb1e9f..7d044c2 100644 --- a/packages/oc-s3-storage-adapter/__mocks__/@aws-sdk/client-s3.js +++ b/packages/oc-s3-storage-adapter/__mocks__/@aws-sdk/client-s3.js @@ -9,25 +9,6 @@ jest.mock('fs-extra', () => { }; }); -jest.mock('node-dir', () => { - return { - paths: jest.fn((pathToDir, cb) => { - cb(null, { - files: [ - `${pathToDir}\\package.json`, - `${pathToDir}\\server.js`, - `${pathToDir}\\.env`, - `${pathToDir}\\template.js`, - `${pathToDir}/package.json`, - `${pathToDir}/server.js`, - `${pathToDir}/.env`, - `${pathToDir}/template.js` - ] - }); - }) - }; -}); - let cachedTxt = 0; let cachedJson = 0; const _S3 = class { diff --git a/packages/oc-s3-storage-adapter/__test__/privateFilesExclusion.test.ts b/packages/oc-s3-storage-adapter/__test__/privateFilesExclusion.test.ts deleted file mode 100644 index b330633..0000000 --- a/packages/oc-s3-storage-adapter/__test__/privateFilesExclusion.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ -import s3 from '../src'; - -test('put directory recognizes server.js and .env to be private', async () => { - const options = { - bucket: 'test', - region: 'region-test', - key: 'test-key', - secret: 'test-secret', - path: '/' - }; - - const client = s3(options); - - const mockResult = (await client.putDir('.', '.')) as Array<{ - Key: string; - ACL: string; - }>; - const serverMock = mockResult.find(x => x.Key === `./server.js`)!; - const envMock = mockResult.find(x => x.Key === './.env')!; - const packageMock = mockResult.find(x => x.Key === './package.json')!; - const templateMock = mockResult.find(x => x.Key === './template.js')!; - - expect(serverMock.ACL).toBe('authenticated-read'); - expect(envMock.ACL).toBe('authenticated-read'); - expect(packageMock.ACL).toBe('public-read'); - expect(templateMock.ACL).toBe('public-read'); -}); diff --git a/packages/oc-s3-storage-adapter/__test__/s3.test.ts b/packages/oc-s3-storage-adapter/__test__/s3.test.ts index 1e12632..ad298db 100644 --- a/packages/oc-s3-storage-adapter/__test__/s3.test.ts +++ b/packages/oc-s3-storage-adapter/__test__/s3.test.ts @@ -14,7 +14,8 @@ const validOptions = { region: 'region-test', key: 'test-key', secret: 'test-secret', - path: '/' + path: '/', + componentsDir: 'components' }; test('should expose the correct methods', () => { @@ -28,7 +29,6 @@ test('should expose the correct methods', () => { { method: 'isValid', type: Function }, { method: 'listSubDirectories', type: Function }, { method: 'maxConcurrentRequests', value: 20 }, - { method: 'putDir', type: Function }, { method: 'putFileContent', type: Function } ].forEach(api => { if (api.type === Function) { @@ -204,47 +204,6 @@ test('test getUrl ', () => { expect(client.getUrl('test', '1.0.0', 'test.js')).toBe('/test/1.0.0/test.js'); }); -test('test put dir (failure)', () => { - const client = s3(validOptions); - - return expect( - client.putDir( - '/absolute-path-to-dir', - 'components\\componentName-error\\1.0.0' - ) - ).rejects.toEqual({ - code: 1234, - message: 'an error message', - retryable: true, - statusCode: 500, - time: DATE_TO_USE, - hostname: 'hostname', - region: 'us-west2' - }); -}); - -test('test put dir (stream failure throwing)', () => { - const client = s3(validOptions); - - return expect( - client.putDir( - '/absolute-path-to-dir', - 'components\\componentName-error-throw\\1.0.0' - ) - ).rejects.toThrow('sorry'); -}); - -test('Put dir uploads the package.json the last file to use it as a verifier', async () => { - const client = s3(validOptions); - - const results = (await client.putDir( - '/absolute-path-to-dir', - 'components\\componentName\\1.0.0' - )) as any[]; - - expect(results.pop().Key).toBe('components/componentName/1.0.0/package.json'); -}); - test('test private putFileContent ', async () => { const client = s3(validOptions); diff --git a/packages/oc-s3-storage-adapter/package.json b/packages/oc-s3-storage-adapter/package.json index bb68b69..d0ebd09 100644 --- a/packages/oc-s3-storage-adapter/package.json +++ b/packages/oc-s3-storage-adapter/package.json @@ -34,12 +34,10 @@ "fs-extra": "8.1.0", "lodash": "^4.17.4", "nice-cache": "^0.0.5", - "node-dir": "^0.1.17", "oc-storage-adapters-utils": "2.0.2" }, "devDependencies": { "@types/fs-extra": "9.0.13", - "@types/lodash": "4.14.186", - "@types/node-dir": "0.0.34" + "@types/lodash": "4.14.186" } -} +} \ No newline at end of file diff --git a/packages/oc-s3-storage-adapter/src/index.ts b/packages/oc-s3-storage-adapter/src/index.ts index 892131f..c85c55d 100644 --- a/packages/oc-s3-storage-adapter/src/index.ts +++ b/packages/oc-s3-storage-adapter/src/index.ts @@ -5,9 +5,7 @@ import { } from '@aws-sdk/node-http-handler'; import Cache from 'nice-cache'; import fs from 'fs-extra'; -import nodeDir, { PathsResult } from 'node-dir'; import _ from 'lodash'; -import { promisify } from 'util'; import { getFileInfo, @@ -16,15 +14,10 @@ import { StorageAdapter, StorageAdapterBaseConfig } from 'oc-storage-adapters-utils'; -import path from 'path'; import type { Agent as httpAgent } from 'http'; import type { Agent as httpsAgent } from 'https'; -const getPaths: (path: string) => Promise = promisify( - nodeDir.paths -); - type RequireAllOrNone = ( | Required> // Require all of the given keys. | Partial> @@ -189,37 +182,6 @@ export default function s3Adapter(conf: S3Config): StorageAdapter { return result; }; - const putDir = async (dirInput: string, dirOutput: string) => { - const paths = await getPaths(dirInput); - const packageJsonFile = path.join(dirInput, 'package.json'); - const files = paths.files.filter(file => file !== packageJsonFile); - - const filesResults = await Promise.all( - files.map((file: string) => { - const relativeFile = file.slice(dirInput.length); - const url = (dirOutput + relativeFile).replace(/\\/g, '/'); - - const serverPattern = /(\\|\/)server\.js/; - const dotFilePattern = /(\\|\/)\..+/; - const privateFilePatterns = [serverPattern, dotFilePattern]; - return putFile( - file, - url, - privateFilePatterns.some(r => r.test(relativeFile)) - ); - }) - ); - // Ensuring package.json is uploaded last so we can verify that a component - // was properly uploaded by checking if package.json exists - const packageJsonFileResult = await putFile( - packageJsonFile, - `${dirOutput}/package.json`.replace(/\\/g, '/'), - false - ); - - return [...filesResults, packageJsonFileResult]; - }; - const putFileContent = async ( fileContent: string | fs.ReadStream, fileName: string, @@ -251,7 +213,6 @@ export default function s3Adapter(conf: S3Config): StorageAdapter { getUrl, listSubDirectories, maxConcurrentRequests: 20, - putDir, putFile, putFileContent, adapterType: 's3', diff --git a/packages/oc-storage-adapters-utils/src/index.ts b/packages/oc-storage-adapters-utils/src/index.ts index 6844700..62b8a2c 100644 --- a/packages/oc-storage-adapters-utils/src/index.ts +++ b/packages/oc-storage-adapters-utils/src/index.ts @@ -17,7 +17,6 @@ export interface StorageAdapter { getUrl: (componentName: string, version: string, fileName: string) => string; listSubDirectories(dir: string): Promise; maxConcurrentRequests: number; - putDir(folderPath: string, filePath: string): Promise; putFile( filePath: string, fileName: string,