@squiz/dx-common-lib 1.2.1-alpha.106 → 1.2.1-alpha.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -56
- package/jest.integration.config.ts +26 -0
- package/lib/index.d.ts +7 -4
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/package.json +4 -8
- package/src/index.ts +10 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/assertions/index.d.ts +0 -7
- package/lib/assertions/index.js +0 -26
- package/lib/assertions/index.js.map +0 -1
- package/lib/error/BadRequestError.d.ts +0 -4
- package/lib/error/BadRequestError.js +0 -11
- package/lib/error/BadRequestError.js.map +0 -1
- package/lib/error/ErrorWithHttpStatusCode.d.ts +0 -5
- package/lib/error/ErrorWithHttpStatusCode.js +0 -12
- package/lib/error/ErrorWithHttpStatusCode.js.map +0 -1
- package/lib/error/InternalServerError.d.ts +0 -4
- package/lib/error/InternalServerError.js +0 -11
- package/lib/error/InternalServerError.js.map +0 -1
- package/lib/error/MethodNotImplementedError.d.ts +0 -4
- package/lib/error/MethodNotImplementedError.js +0 -11
- package/lib/error/MethodNotImplementedError.js.map +0 -1
- package/lib/error/ResourceNotFoundError.d.ts +0 -4
- package/lib/error/ResourceNotFoundError.js +0 -11
- package/lib/error/ResourceNotFoundError.js.map +0 -1
- package/lib/error/TimeoutError.d.ts +0 -4
- package/lib/error/TimeoutError.js +0 -11
- package/lib/error/TimeoutError.js.map +0 -1
- package/lib/error/index.d.ts +0 -6
- package/lib/error/index.js +0 -23
- package/lib/error/index.js.map +0 -1
- package/lib/util/getNodeEnv.d.ts +0 -1
- package/lib/util/getNodeEnv.js +0 -14
- package/lib/util/getNodeEnv.js.map +0 -1
- package/lib/util/getNodeEnv.spec.d.ts +0 -1
- package/lib/util/getNodeEnv.spec.js +0 -22
- package/lib/util/getNodeEnv.spec.js.map +0 -1
- package/lib/util/index.d.ts +0 -5
- package/lib/util/index.js +0 -14
- package/lib/util/index.js.map +0 -1
- package/lib/util/isPathTryingToAccessOutsideOfRoot.d.ts +0 -1
- package/lib/util/isPathTryingToAccessOutsideOfRoot.js +0 -14
- package/lib/util/isPathTryingToAccessOutsideOfRoot.js.map +0 -1
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.d.ts +0 -1
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js +0 -25
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js.map +0 -1
- package/lib/util/joinAbsoluteUrlPath.d.ts +0 -1
- package/lib/util/joinAbsoluteUrlPath.js +0 -26
- package/lib/util/joinAbsoluteUrlPath.js.map +0 -1
- package/lib/util/joinAbsoluteUrlPath.spec.d.ts +0 -1
- package/lib/util/joinAbsoluteUrlPath.spec.js +0 -43
- package/lib/util/joinAbsoluteUrlPath.spec.js.map +0 -1
- package/lib/util/never.d.ts +0 -1
- package/lib/util/never.js +0 -9
- package/lib/util/never.js.map +0 -1
- package/lib/util/parseEnvVarForVar.d.ts +0 -1
- package/lib/util/parseEnvVarForVar.js +0 -15
- package/lib/util/parseEnvVarForVar.js.map +0 -1
- package/lib/util/parseEnvVarForVar.spec.d.ts +0 -1
- package/lib/util/parseEnvVarForVar.spec.js +0 -20
- package/lib/util/parseEnvVarForVar.spec.js.map +0 -1
- package/lib/zip/zipDirectory.d.ts +0 -1
- package/lib/zip/zipDirectory.js +0 -32
- package/lib/zip/zipDirectory.js.map +0 -1
- package/lib/zip/zipDirectory.spec.d.ts +0 -1
- package/lib/zip/zipDirectory.spec.js +0 -25
- package/lib/zip/zipDirectory.spec.js.map +0 -1
- package/src/assertions/index.ts +0 -10
- package/src/error/BadRequestError.ts +0 -7
- package/src/error/ErrorWithHttpStatusCode.ts +0 -5
- package/src/error/InternalServerError.ts +0 -7
- package/src/error/MethodNotImplementedError.ts +0 -7
- package/src/error/ResourceNotFoundError.ts +0 -7
- package/src/error/TimeoutError.ts +0 -7
- package/src/error/index.ts +0 -6
- package/src/util/getNodeEnv.spec.ts +0 -25
- package/src/util/getNodeEnv.ts +0 -11
- package/src/util/index.ts +0 -5
- package/src/util/isPathTryingToAccessOutsideOfRoot.spec.ts +0 -25
- package/src/util/isPathTryingToAccessOutsideOfRoot.ts +0 -8
- package/src/util/joinAbsoluteUrlPath.spec.ts +0 -62
- package/src/util/joinAbsoluteUrlPath.ts +0 -22
- package/src/util/never.ts +0 -4
- package/src/util/parseEnvVarForVar.spec.ts +0 -22
- package/src/util/parseEnvVarForVar.ts +0 -12
- package/src/zip/zipDirectory.spec.ts +0 -24
- package/src/zip/zipDirectory.ts +0 -31
@@ -1,24 +0,0 @@
|
|
1
|
-
import path from 'path';
|
2
|
-
import fs from 'fs';
|
3
|
-
import { zipDirectory } from './zipDirectory';
|
4
|
-
|
5
|
-
describe('zipDirectory', () => {
|
6
|
-
const inputDir = fs.mkdtempSync('zip-test');
|
7
|
-
const outDir = fs.mkdtempSync('zip-test-out');
|
8
|
-
|
9
|
-
beforeAll(() => {
|
10
|
-
fs.writeFileSync(path.join(inputDir, 'f1.txt'), '1');
|
11
|
-
fs.writeFileSync(path.join(inputDir, 'f2.txt'), '2');
|
12
|
-
});
|
13
|
-
|
14
|
-
afterAll(() => {
|
15
|
-
fs.rmSync(inputDir, { force: true, recursive: true });
|
16
|
-
fs.rmSync(outDir, { force: true, recursive: true });
|
17
|
-
});
|
18
|
-
|
19
|
-
it('should take an input path and an output path and create a export.zip', async () => {
|
20
|
-
await zipDirectory(inputDir, outDir);
|
21
|
-
|
22
|
-
expect(fs.existsSync(path.join(outDir, 'export.zip'))).toEqual(true);
|
23
|
-
});
|
24
|
-
});
|
package/src/zip/zipDirectory.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import path from 'path';
|
2
|
-
import fs from 'fs';
|
3
|
-
|
4
|
-
import archiver from 'archiver';
|
5
|
-
|
6
|
-
export function zipDirectory(sourceDirectory: string, outputDirectory: string) {
|
7
|
-
return new Promise<string>((resolve, reject) => {
|
8
|
-
const outputZipFile = path.join(outputDirectory, '/export.zip');
|
9
|
-
const output = fs.createWriteStream(outputZipFile);
|
10
|
-
|
11
|
-
const archive = archiver('zip', {
|
12
|
-
zlib: { level: 9 }, // Sets the compression level.
|
13
|
-
});
|
14
|
-
|
15
|
-
output.on('close', function () {
|
16
|
-
resolve(outputZipFile);
|
17
|
-
});
|
18
|
-
|
19
|
-
archive.on('warning', function (err) {
|
20
|
-
reject(err);
|
21
|
-
});
|
22
|
-
|
23
|
-
archive.on('error', function (err) {
|
24
|
-
reject(err);
|
25
|
-
});
|
26
|
-
|
27
|
-
archive.pipe(output);
|
28
|
-
archive.directory(sourceDirectory, false);
|
29
|
-
archive.finalize();
|
30
|
-
});
|
31
|
-
}
|