@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.
Files changed (88) hide show
  1. package/CHANGELOG.md +0 -56
  2. package/jest.integration.config.ts +26 -0
  3. package/lib/index.d.ts +7 -4
  4. package/lib/index.js +9 -4
  5. package/lib/index.js.map +1 -1
  6. package/package.json +4 -8
  7. package/src/index.ts +10 -4
  8. package/tsconfig.tsbuildinfo +1 -1
  9. package/lib/assertions/index.d.ts +0 -7
  10. package/lib/assertions/index.js +0 -26
  11. package/lib/assertions/index.js.map +0 -1
  12. package/lib/error/BadRequestError.d.ts +0 -4
  13. package/lib/error/BadRequestError.js +0 -11
  14. package/lib/error/BadRequestError.js.map +0 -1
  15. package/lib/error/ErrorWithHttpStatusCode.d.ts +0 -5
  16. package/lib/error/ErrorWithHttpStatusCode.js +0 -12
  17. package/lib/error/ErrorWithHttpStatusCode.js.map +0 -1
  18. package/lib/error/InternalServerError.d.ts +0 -4
  19. package/lib/error/InternalServerError.js +0 -11
  20. package/lib/error/InternalServerError.js.map +0 -1
  21. package/lib/error/MethodNotImplementedError.d.ts +0 -4
  22. package/lib/error/MethodNotImplementedError.js +0 -11
  23. package/lib/error/MethodNotImplementedError.js.map +0 -1
  24. package/lib/error/ResourceNotFoundError.d.ts +0 -4
  25. package/lib/error/ResourceNotFoundError.js +0 -11
  26. package/lib/error/ResourceNotFoundError.js.map +0 -1
  27. package/lib/error/TimeoutError.d.ts +0 -4
  28. package/lib/error/TimeoutError.js +0 -11
  29. package/lib/error/TimeoutError.js.map +0 -1
  30. package/lib/error/index.d.ts +0 -6
  31. package/lib/error/index.js +0 -23
  32. package/lib/error/index.js.map +0 -1
  33. package/lib/util/getNodeEnv.d.ts +0 -1
  34. package/lib/util/getNodeEnv.js +0 -14
  35. package/lib/util/getNodeEnv.js.map +0 -1
  36. package/lib/util/getNodeEnv.spec.d.ts +0 -1
  37. package/lib/util/getNodeEnv.spec.js +0 -22
  38. package/lib/util/getNodeEnv.spec.js.map +0 -1
  39. package/lib/util/index.d.ts +0 -5
  40. package/lib/util/index.js +0 -14
  41. package/lib/util/index.js.map +0 -1
  42. package/lib/util/isPathTryingToAccessOutsideOfRoot.d.ts +0 -1
  43. package/lib/util/isPathTryingToAccessOutsideOfRoot.js +0 -14
  44. package/lib/util/isPathTryingToAccessOutsideOfRoot.js.map +0 -1
  45. package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.d.ts +0 -1
  46. package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js +0 -25
  47. package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js.map +0 -1
  48. package/lib/util/joinAbsoluteUrlPath.d.ts +0 -1
  49. package/lib/util/joinAbsoluteUrlPath.js +0 -26
  50. package/lib/util/joinAbsoluteUrlPath.js.map +0 -1
  51. package/lib/util/joinAbsoluteUrlPath.spec.d.ts +0 -1
  52. package/lib/util/joinAbsoluteUrlPath.spec.js +0 -43
  53. package/lib/util/joinAbsoluteUrlPath.spec.js.map +0 -1
  54. package/lib/util/never.d.ts +0 -1
  55. package/lib/util/never.js +0 -9
  56. package/lib/util/never.js.map +0 -1
  57. package/lib/util/parseEnvVarForVar.d.ts +0 -1
  58. package/lib/util/parseEnvVarForVar.js +0 -15
  59. package/lib/util/parseEnvVarForVar.js.map +0 -1
  60. package/lib/util/parseEnvVarForVar.spec.d.ts +0 -1
  61. package/lib/util/parseEnvVarForVar.spec.js +0 -20
  62. package/lib/util/parseEnvVarForVar.spec.js.map +0 -1
  63. package/lib/zip/zipDirectory.d.ts +0 -1
  64. package/lib/zip/zipDirectory.js +0 -32
  65. package/lib/zip/zipDirectory.js.map +0 -1
  66. package/lib/zip/zipDirectory.spec.d.ts +0 -1
  67. package/lib/zip/zipDirectory.spec.js +0 -25
  68. package/lib/zip/zipDirectory.spec.js.map +0 -1
  69. package/src/assertions/index.ts +0 -10
  70. package/src/error/BadRequestError.ts +0 -7
  71. package/src/error/ErrorWithHttpStatusCode.ts +0 -5
  72. package/src/error/InternalServerError.ts +0 -7
  73. package/src/error/MethodNotImplementedError.ts +0 -7
  74. package/src/error/ResourceNotFoundError.ts +0 -7
  75. package/src/error/TimeoutError.ts +0 -7
  76. package/src/error/index.ts +0 -6
  77. package/src/util/getNodeEnv.spec.ts +0 -25
  78. package/src/util/getNodeEnv.ts +0 -11
  79. package/src/util/index.ts +0 -5
  80. package/src/util/isPathTryingToAccessOutsideOfRoot.spec.ts +0 -25
  81. package/src/util/isPathTryingToAccessOutsideOfRoot.ts +0 -8
  82. package/src/util/joinAbsoluteUrlPath.spec.ts +0 -62
  83. package/src/util/joinAbsoluteUrlPath.ts +0 -22
  84. package/src/util/never.ts +0 -4
  85. package/src/util/parseEnvVarForVar.spec.ts +0 -22
  86. package/src/util/parseEnvVarForVar.ts +0 -12
  87. package/src/zip/zipDirectory.spec.ts +0 -24
  88. 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
- });
@@ -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
- }