@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,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.isPathTryingToAccessOutsideOfRoot = void 0;
|
7
|
-
const path_1 = __importDefault(require("path"));
|
8
|
-
function isPathTryingToAccessOutsideOfRoot(rootPath, filePath) {
|
9
|
-
const resolvedRoot = path_1.default.resolve(rootPath);
|
10
|
-
const joinedPath = path_1.default.join(resolvedRoot, filePath);
|
11
|
-
return !joinedPath.includes(resolvedRoot);
|
12
|
-
}
|
13
|
-
exports.isPathTryingToAccessOutsideOfRoot = isPathTryingToAccessOutsideOfRoot;
|
14
|
-
//# sourceMappingURL=isPathTryingToAccessOutsideOfRoot.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"isPathTryingToAccessOutsideOfRoot.js","sourceRoot":"","sources":["../../src/util/isPathTryingToAccessOutsideOfRoot.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,SAAgB,iCAAiC,CAAC,QAAgB,EAAE,QAAgB;IAClF,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrD,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC;AALD,8EAKC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const isPathTryingToAccessOutsideOfRoot_1 = require("./isPathTryingToAccessOutsideOfRoot");
|
4
|
-
describe('isPathTryingToAccessOutsideOfRoot', () => {
|
5
|
-
it("should return false if filepath doesn't try to access outside of root", () => {
|
6
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('my-root/', 'hello')).toEqual(false);
|
7
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('my-root/', './hello')).toEqual(false);
|
8
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('my-root/', './hello/../')).toEqual(false);
|
9
|
-
});
|
10
|
-
it('should resolve a relative root path', () => {
|
11
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello')).toEqual(false);
|
12
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/../world')).toEqual(false);
|
13
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/world/..')).toEqual(false);
|
14
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', './')).toEqual(false);
|
15
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/something', './else')).toEqual(false);
|
16
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/something', './else/1/../../')).toEqual(false);
|
17
|
-
});
|
18
|
-
it('should return true if filepath does access outside of the root', () => {
|
19
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', '../')).toEqual(true);
|
20
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', '../../')).toEqual(true);
|
21
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/../world/../../')).toEqual(true);
|
22
|
-
expect((0, isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot)('./my-root/', 'hello/../../')).toEqual(true);
|
23
|
-
});
|
24
|
-
});
|
25
|
-
//# sourceMappingURL=isPathTryingToAccessOutsideOfRoot.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"isPathTryingToAccessOutsideOfRoot.spec.js","sourceRoot":"","sources":["../../src/util/isPathTryingToAccessOutsideOfRoot.spec.ts"],"names":[],"mappings":";;AAAA,2FAAwF;AAExF,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,MAAM,CAAC,IAAA,qEAAiC,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9E,MAAM,CAAC,IAAA,qEAAiC,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChF,MAAM,CAAC,IAAA,qEAAiC,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,IAAA,qEAAiC,EAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CA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object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.joinAbsoluteUrlPath = void 0;
|
4
|
-
function joinAbsoluteUrlPath(...args) {
|
5
|
-
const [rootUrl] = args;
|
6
|
-
/**
|
7
|
-
* This method takes any form of input string and resolves them to make an absolute url
|
8
|
-
* Since these paths are web paths and not file paths, we are creating a URL object (https://nodejs.org/api/url.html). http://example.com has just been used as a dummy entry to create a valid url.
|
9
|
-
* Note: path.resolves gives you different output based on the OS node is running on. More reading here https://nodejs.org/api/path.html#windows-vs-posix.
|
10
|
-
*/
|
11
|
-
const url = new URL(getSanitisedString(args), 'http://example.com');
|
12
|
-
if (urlIsAbsolute(rootUrl)) {
|
13
|
-
return url.toString();
|
14
|
-
}
|
15
|
-
else {
|
16
|
-
return url.pathname.replace(/(^\/|\/$)/g, '');
|
17
|
-
}
|
18
|
-
}
|
19
|
-
exports.joinAbsoluteUrlPath = joinAbsoluteUrlPath;
|
20
|
-
function getSanitisedString(subdirs) {
|
21
|
-
return subdirs.map((dir) => dir.replace(/(^\.\/+)|(^\/+|\/+$)/g, '')).join('/');
|
22
|
-
}
|
23
|
-
function urlIsAbsolute(url) {
|
24
|
-
return url.match(/^http(s?):\/\//);
|
25
|
-
}
|
26
|
-
//# sourceMappingURL=joinAbsoluteUrlPath.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"joinAbsoluteUrlPath.js","sourceRoot":"","sources":["../../src/util/joinAbsoluteUrlPath.ts"],"names":[],"mappings":";;;AAAA,SAAgB,mBAAmB,CAAC,GAAG,IAAc;IACnD,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACvB;;;;OAIG;IACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;IACpE,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE;QAC1B,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;KACvB;SAAM;QACL,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;KAC/C;AACH,CAAC;AAbD,kDAaC;AAED,SAAS,kBAAkB,CAAC,OAAiB;IAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACrC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,43 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const joinAbsoluteUrlPath_1 = require("./joinAbsoluteUrlPath");
|
4
|
-
describe('joinAbsoluteUrlPath', () => {
|
5
|
-
it('should return a valid absolute url for protocol based inputs', () => {
|
6
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com', 'aaa', 'bbb')).toEqual('https://example.com/aaa/bbb');
|
7
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', '/aaa', 'bbb')).toEqual('https://example.com/aaa/bbb');
|
8
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', '/aaa/', '/bbb///')).toEqual('https://example.com/aaa/bbb');
|
9
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', './..///', '/bbb///')).toEqual('https://example.com/bbb');
|
10
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', './aaa/', '/bbb/')).toEqual('https://example.com/aaa/bbb');
|
11
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', '../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
|
12
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ccc', '../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
|
13
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ccc', '../../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
|
14
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ccc', '/../../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
|
15
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https://example.com/', 'ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('https://example.com/ddd/aaa/bbb');
|
16
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'aaa', 'bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
17
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', '/aaa', 'bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
18
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', '/aaa/', '/bbb///')).toEqual('http://localhost:3000/aaa/bbb');
|
19
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', './aaa/', '/bbb/')).toEqual('http://localhost:3000/aaa/bbb');
|
20
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', '../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
21
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'ccc', '../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
22
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'ccc', '../../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
23
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000', 'ccc', '/../../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
24
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000/', 'ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('http://localhost:3000/ddd/aaa/bbb');
|
25
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http://localhost:3000/', 'localhost', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('http://localhost:3000/localhost/aaa/bbb');
|
26
|
-
});
|
27
|
-
it('should return a valid resolved path for inputs', () => {
|
28
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('aaa', 'bbb')).toEqual('aaa/bbb');
|
29
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('/aaa', 'bbb')).toEqual('aaa/bbb');
|
30
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('/aaa/', '/bbb///')).toEqual('aaa/bbb');
|
31
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('./aaa/', '/bbb/')).toEqual('aaa/bbb');
|
32
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('../aaa/', '/bbb')).toEqual('aaa/bbb');
|
33
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ccc', '../aaa/', '/bbb')).toEqual('aaa/bbb');
|
34
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ccc', '../../aaa/', '/bbb')).toEqual('aaa/bbb');
|
35
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ccc', '/../../aaa/', '/bbb')).toEqual('aaa/bbb');
|
36
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('ddd/aaa/bbb');
|
37
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('http', 'ccc', '/aaa/', '/bbb')).toEqual('http/ccc/aaa/bbb');
|
38
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https', 'ccc', '/aaa/', '/bbb')).toEqual('https/ccc/aaa/bbb');
|
39
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https', '../ccc', '/aaa/', '/bbb')).toEqual('ccc/aaa/bbb');
|
40
|
-
expect((0, joinAbsoluteUrlPath_1.joinAbsoluteUrlPath)('https', './ccc', '/aaa/', '/bbb')).toEqual('https/ccc/aaa/bbb');
|
41
|
-
});
|
42
|
-
});
|
43
|
-
//# sourceMappingURL=joinAbsoluteUrlPath.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"joinAbsoluteUrlPath.spec.js","sourceRoot":"","sources":["../../src/util/joinAbsoluteUrlPath.spec.ts"],"names":[],"mappings":";;AAAA,+DAA4D;AAE5D,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,CAAC,IAAA,yCAAmB,EAAC,qBAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QACxG,MAAM,CAAC,IAAA,yCAAmB,EAAC,sBAAsB,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QAC1G,MAAM,CAAC,IAAA,yCAAmB,EAAC,sBAAsB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QAC/G,MAAM,CAAC,IAAA,yCAAmB,EAAC,sBAAsB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,yBAA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O,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/util/never.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare function never(a: never): void;
|
package/lib/util/never.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.never = void 0;
|
4
|
-
function never(a) {
|
5
|
-
// this should never be executed. This is a compile time check
|
6
|
-
throw new Error(`value ${a} is not valid`);
|
7
|
-
}
|
8
|
-
exports.never = never;
|
9
|
-
//# sourceMappingURL=never.js.map
|
package/lib/util/never.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"never.js","sourceRoot":"","sources":["../../src/util/never.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAC,CAAQ;IAC5B,8DAA8D;IAC9D,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC;AAHD,sBAGC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function parseEnvVarForVar(varName: string, defaultValue?: string | undefined): string;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.parseEnvVarForVar = void 0;
|
4
|
-
function parseEnvVarForVar(varName, defaultValue = undefined) {
|
5
|
-
if (process.env[varName] === undefined) {
|
6
|
-
if (defaultValue !== undefined) {
|
7
|
-
return defaultValue;
|
8
|
-
}
|
9
|
-
throw new Error(`env variable ${varName} must be set`);
|
10
|
-
}
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
12
|
-
return process.env[varName];
|
13
|
-
}
|
14
|
-
exports.parseEnvVarForVar = parseEnvVarForVar;
|
15
|
-
//# sourceMappingURL=parseEnvVarForVar.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"parseEnvVarForVar.js","sourceRoot":"","sources":["../../src/util/parseEnvVarForVar.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAAC,OAAe,EAAE,eAAmC,SAAS;IAC7F,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE;QACtC,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,OAAO,YAAY,CAAC;SACrB;QAED,MAAM,IAAI,KAAK,CAAC,gBAAgB,OAAO,cAAc,CAAC,CAAC;KACxD;IAED,oEAAoE;IACpE,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC;AAC/B,CAAC;AAXD,8CAWC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,20 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const parseEnvVarForVar_1 = require("./parseEnvVarForVar");
|
4
|
-
describe('parseEnvVarForVar', () => {
|
5
|
-
it('it should read an environment variable from process.env.*', () => {
|
6
|
-
process.env.MY_VAR = 'hello';
|
7
|
-
expect((0, parseEnvVarForVar_1.parseEnvVarForVar)('MY_VAR')).toEqual('hello');
|
8
|
-
});
|
9
|
-
it('it should throw an error if the variable is not available', () => {
|
10
|
-
expect(() => (0, parseEnvVarForVar_1.parseEnvVarForVar)('DOESNT_EXIST')).toThrowError(new Error('env variable DOESNT_EXIST must be set'));
|
11
|
-
});
|
12
|
-
it('it should not throw an error if a default value is provided and env var doesnt exist', () => {
|
13
|
-
expect((0, parseEnvVarForVar_1.parseEnvVarForVar)('DOESNT_EXIST', 'default')).toEqual('default');
|
14
|
-
});
|
15
|
-
it('it should return env var if its set and a defualt value is set', () => {
|
16
|
-
process.env.MY_VAR = 'hello';
|
17
|
-
expect((0, parseEnvVarForVar_1.parseEnvVarForVar)('MY_VAR', 'default')).toEqual('hello');
|
18
|
-
});
|
19
|
-
});
|
20
|
-
//# sourceMappingURL=parseEnvVarForVar.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"parseEnvVarForVar.spec.js","sourceRoot":"","sources":["../../src/util/parseEnvVarForVar.spec.ts"],"names":[],"mappings":";;AAAA,2DAAwD;AAExD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC;QAE7B,MAAM,CAAC,IAAA,qCAAiB,EAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,qCAAiB,EAAC,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC,CAAC;IACnH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sFAAsF,EAAE,GAAG,EAAE;QAC9F,MAAM,CAAC,IAAA,qCAAiB,EAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC;QAC7B,MAAM,CAAC,IAAA,qCAAiB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function zipDirectory(sourceDirectory: string, outputDirectory: string): Promise<string>;
|
package/lib/zip/zipDirectory.js
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.zipDirectory = void 0;
|
7
|
-
const path_1 = __importDefault(require("path"));
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
9
|
-
const archiver_1 = __importDefault(require("archiver"));
|
10
|
-
function zipDirectory(sourceDirectory, outputDirectory) {
|
11
|
-
return new Promise((resolve, reject) => {
|
12
|
-
const outputZipFile = path_1.default.join(outputDirectory, '/export.zip');
|
13
|
-
const output = fs_1.default.createWriteStream(outputZipFile);
|
14
|
-
const archive = (0, archiver_1.default)('zip', {
|
15
|
-
zlib: { level: 9 }, // Sets the compression level.
|
16
|
-
});
|
17
|
-
output.on('close', function () {
|
18
|
-
resolve(outputZipFile);
|
19
|
-
});
|
20
|
-
archive.on('warning', function (err) {
|
21
|
-
reject(err);
|
22
|
-
});
|
23
|
-
archive.on('error', function (err) {
|
24
|
-
reject(err);
|
25
|
-
});
|
26
|
-
archive.pipe(output);
|
27
|
-
archive.directory(sourceDirectory, false);
|
28
|
-
archive.finalize();
|
29
|
-
});
|
30
|
-
}
|
31
|
-
exports.zipDirectory = zipDirectory;
|
32
|
-
//# sourceMappingURL=zipDirectory.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"zipDirectory.js","sourceRoot":"","sources":["../../src/zip/zipDirectory.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AAEpB,wDAAgC;AAEhC,SAAgB,YAAY,CAAC,eAAuB,EAAE,eAAuB;IAC3E,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,YAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QAEnD,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,KAAK,EAAE;YAC9B,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,8BAA8B;SACnD,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,aAAa,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,GAAG;YACjC,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG;YAC/B,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAzBD,oCAyBC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,25 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const path_1 = __importDefault(require("path"));
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
8
|
-
const zipDirectory_1 = require("./zipDirectory");
|
9
|
-
describe('zipDirectory', () => {
|
10
|
-
const inputDir = fs_1.default.mkdtempSync('zip-test');
|
11
|
-
const outDir = fs_1.default.mkdtempSync('zip-test-out');
|
12
|
-
beforeAll(() => {
|
13
|
-
fs_1.default.writeFileSync(path_1.default.join(inputDir, 'f1.txt'), '1');
|
14
|
-
fs_1.default.writeFileSync(path_1.default.join(inputDir, 'f2.txt'), '2');
|
15
|
-
});
|
16
|
-
afterAll(() => {
|
17
|
-
fs_1.default.rmSync(inputDir, { force: true, recursive: true });
|
18
|
-
fs_1.default.rmSync(outDir, { force: true, recursive: true });
|
19
|
-
});
|
20
|
-
it('should take an input path and an output path and create a export.zip', async () => {
|
21
|
-
await (0, zipDirectory_1.zipDirectory)(inputDir, outDir);
|
22
|
-
expect(fs_1.default.existsSync(path_1.default.join(outDir, 'export.zip'))).toEqual(true);
|
23
|
-
});
|
24
|
-
});
|
25
|
-
//# sourceMappingURL=zipDirectory.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"zipDirectory.spec.js","sourceRoot":"","sources":["../../src/zip/zipDirectory.spec.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,iDAA8C;AAE9C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,MAAM,QAAQ,GAAG,YAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,YAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAE9C,SAAS,CAAC,GAAG,EAAE;QACb,YAAE,CAAC,aAAa,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;QACrD,YAAE,CAAC,aAAa,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE;QACZ,YAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,YAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACpF,MAAM,IAAA,2BAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAErC,MAAM,CAAC,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/src/assertions/index.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
// Common Assertions
|
2
|
-
export * from './assertIsString';
|
3
|
-
export * from './assertIsDefined';
|
4
|
-
export * from './assertIsMapOfStringString';
|
5
|
-
export * from './assertIsObject';
|
6
|
-
export * from './assertIsNotAnEmptyString';
|
7
|
-
|
8
|
-
// Assert assign
|
9
|
-
export * from './assertAssignWithDefaultUndefinedValue';
|
10
|
-
export * from './assertAssign';
|
package/src/error/index.ts
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
import { getNodeEnv } from './getNodeEnv';
|
2
|
-
|
3
|
-
describe('getNodeEnv', () => {
|
4
|
-
it('should return production if NODE_ENV equals production', () => {
|
5
|
-
process.env.NODE_ENV = 'production';
|
6
|
-
expect(getNodeEnv()).toEqual('production');
|
7
|
-
});
|
8
|
-
|
9
|
-
it('should return development if NODE_ENV equals development', () => {
|
10
|
-
process.env.NODE_ENV = 'development';
|
11
|
-
expect(getNodeEnv()).toEqual('development');
|
12
|
-
});
|
13
|
-
|
14
|
-
it('should return development if NODE_ENV is not set', () => {
|
15
|
-
delete process.env.NODE_ENV;
|
16
|
-
expect(getNodeEnv()).toEqual('development');
|
17
|
-
});
|
18
|
-
|
19
|
-
it('should throw if NODE_ENV set to non valid environment', () => {
|
20
|
-
process.env.NODE_ENV = 'invalid';
|
21
|
-
expect(() => getNodeEnv()).toThrowError(
|
22
|
-
new Error('NODE_ENV env var can only be values "production" or "development"'),
|
23
|
-
);
|
24
|
-
});
|
25
|
-
});
|
package/src/util/getNodeEnv.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
export function getNodeEnv(): 'production' | 'development' {
|
2
|
-
if (process.env.NODE_ENV == 'production') {
|
3
|
-
return 'production';
|
4
|
-
}
|
5
|
-
|
6
|
-
if (process.env.NODE_ENV == 'development' || process.env.NODE_ENV === undefined) {
|
7
|
-
return 'development';
|
8
|
-
}
|
9
|
-
|
10
|
-
throw new Error('NODE_ENV env var can only be values "production" or "development"');
|
11
|
-
}
|
package/src/util/index.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
export { getNodeEnv } from './getNodeEnv';
|
2
|
-
export { isPathTryingToAccessOutsideOfRoot } from './isPathTryingToAccessOutsideOfRoot';
|
3
|
-
export { joinAbsoluteUrlPath } from './joinAbsoluteUrlPath';
|
4
|
-
export { parseEnvVarForVar } from './parseEnvVarForVar';
|
5
|
-
export { never } from './never';
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { isPathTryingToAccessOutsideOfRoot } from './isPathTryingToAccessOutsideOfRoot';
|
2
|
-
|
3
|
-
describe('isPathTryingToAccessOutsideOfRoot', () => {
|
4
|
-
it("should return false if filepath doesn't try to access outside of root", () => {
|
5
|
-
expect(isPathTryingToAccessOutsideOfRoot('my-root/', 'hello')).toEqual(false);
|
6
|
-
expect(isPathTryingToAccessOutsideOfRoot('my-root/', './hello')).toEqual(false);
|
7
|
-
expect(isPathTryingToAccessOutsideOfRoot('my-root/', './hello/../')).toEqual(false);
|
8
|
-
});
|
9
|
-
|
10
|
-
it('should resolve a relative root path', () => {
|
11
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', 'hello')).toEqual(false);
|
12
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', 'hello/../world')).toEqual(false);
|
13
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', 'hello/world/..')).toEqual(false);
|
14
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', './')).toEqual(false);
|
15
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/something', './else')).toEqual(false);
|
16
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/something', './else/1/../../')).toEqual(false);
|
17
|
-
});
|
18
|
-
|
19
|
-
it('should return true if filepath does access outside of the root', () => {
|
20
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', '../')).toEqual(true);
|
21
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', '../../')).toEqual(true);
|
22
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', 'hello/../world/../../')).toEqual(true);
|
23
|
-
expect(isPathTryingToAccessOutsideOfRoot('./my-root/', 'hello/../../')).toEqual(true);
|
24
|
-
});
|
25
|
-
});
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import path from 'path';
|
2
|
-
|
3
|
-
export function isPathTryingToAccessOutsideOfRoot(rootPath: string, filePath: string) {
|
4
|
-
const resolvedRoot = path.resolve(rootPath);
|
5
|
-
|
6
|
-
const joinedPath = path.join(resolvedRoot, filePath);
|
7
|
-
return !joinedPath.includes(resolvedRoot);
|
8
|
-
}
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { joinAbsoluteUrlPath } from './joinAbsoluteUrlPath';
|
2
|
-
|
3
|
-
describe('joinAbsoluteUrlPath', () => {
|
4
|
-
it('should return a valid absolute url for protocol based inputs', () => {
|
5
|
-
expect(joinAbsoluteUrlPath('https://example.com', 'aaa', 'bbb')).toEqual('https://example.com/aaa/bbb');
|
6
|
-
expect(joinAbsoluteUrlPath('https://example.com/', '/aaa', 'bbb')).toEqual('https://example.com/aaa/bbb');
|
7
|
-
expect(joinAbsoluteUrlPath('https://example.com/', '/aaa/', '/bbb///')).toEqual('https://example.com/aaa/bbb');
|
8
|
-
expect(joinAbsoluteUrlPath('https://example.com/', './..///', '/bbb///')).toEqual('https://example.com/bbb');
|
9
|
-
expect(joinAbsoluteUrlPath('https://example.com/', './aaa/', '/bbb/')).toEqual('https://example.com/aaa/bbb');
|
10
|
-
expect(joinAbsoluteUrlPath('https://example.com/', '../aaa/', '/bbb')).toEqual('https://example.com/aaa/bbb');
|
11
|
-
|
12
|
-
expect(joinAbsoluteUrlPath('https://example.com/', 'ccc', '../aaa/', '/bbb')).toEqual(
|
13
|
-
'https://example.com/aaa/bbb',
|
14
|
-
);
|
15
|
-
expect(joinAbsoluteUrlPath('https://example.com/', 'ccc', '../../aaa/', '/bbb')).toEqual(
|
16
|
-
'https://example.com/aaa/bbb',
|
17
|
-
);
|
18
|
-
expect(joinAbsoluteUrlPath('https://example.com/', 'ccc', '/../../aaa/', '/bbb')).toEqual(
|
19
|
-
'https://example.com/aaa/bbb',
|
20
|
-
);
|
21
|
-
|
22
|
-
expect(joinAbsoluteUrlPath('https://example.com/', 'ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual(
|
23
|
-
'https://example.com/ddd/aaa/bbb',
|
24
|
-
);
|
25
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', 'aaa', 'bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
26
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', '/aaa', 'bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
27
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', '/aaa/', '/bbb///')).toEqual('http://localhost:3000/aaa/bbb');
|
28
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', './aaa/', '/bbb/')).toEqual('http://localhost:3000/aaa/bbb');
|
29
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', '../aaa/', '/bbb')).toEqual('http://localhost:3000/aaa/bbb');
|
30
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', 'ccc', '../aaa/', '/bbb')).toEqual(
|
31
|
-
'http://localhost:3000/aaa/bbb',
|
32
|
-
);
|
33
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', 'ccc', '../../aaa/', '/bbb')).toEqual(
|
34
|
-
'http://localhost:3000/aaa/bbb',
|
35
|
-
);
|
36
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000', 'ccc', '/../../aaa/', '/bbb')).toEqual(
|
37
|
-
'http://localhost:3000/aaa/bbb',
|
38
|
-
);
|
39
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000/', 'ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual(
|
40
|
-
'http://localhost:3000/ddd/aaa/bbb',
|
41
|
-
);
|
42
|
-
expect(joinAbsoluteUrlPath('http://localhost:3000/', 'localhost', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual(
|
43
|
-
'http://localhost:3000/localhost/aaa/bbb',
|
44
|
-
);
|
45
|
-
});
|
46
|
-
|
47
|
-
it('should return a valid resolved path for inputs', () => {
|
48
|
-
expect(joinAbsoluteUrlPath('aaa', 'bbb')).toEqual('aaa/bbb');
|
49
|
-
expect(joinAbsoluteUrlPath('/aaa', 'bbb')).toEqual('aaa/bbb');
|
50
|
-
expect(joinAbsoluteUrlPath('/aaa/', '/bbb///')).toEqual('aaa/bbb');
|
51
|
-
expect(joinAbsoluteUrlPath('./aaa/', '/bbb/')).toEqual('aaa/bbb');
|
52
|
-
expect(joinAbsoluteUrlPath('../aaa/', '/bbb')).toEqual('aaa/bbb');
|
53
|
-
expect(joinAbsoluteUrlPath('ccc', '../aaa/', '/bbb')).toEqual('aaa/bbb');
|
54
|
-
expect(joinAbsoluteUrlPath('ccc', '../../aaa/', '/bbb')).toEqual('aaa/bbb');
|
55
|
-
expect(joinAbsoluteUrlPath('ccc', '/../../aaa/', '/bbb')).toEqual('aaa/bbb');
|
56
|
-
expect(joinAbsoluteUrlPath('ddd', 'eee', 'ccc', '/../../aaa/', '/bbb')).toEqual('ddd/aaa/bbb');
|
57
|
-
expect(joinAbsoluteUrlPath('http', 'ccc', '/aaa/', '/bbb')).toEqual('http/ccc/aaa/bbb');
|
58
|
-
expect(joinAbsoluteUrlPath('https', 'ccc', '/aaa/', '/bbb')).toEqual('https/ccc/aaa/bbb');
|
59
|
-
expect(joinAbsoluteUrlPath('https', '../ccc', '/aaa/', '/bbb')).toEqual('ccc/aaa/bbb');
|
60
|
-
expect(joinAbsoluteUrlPath('https', './ccc', '/aaa/', '/bbb')).toEqual('https/ccc/aaa/bbb');
|
61
|
-
});
|
62
|
-
});
|
@@ -1,22 +0,0 @@
|
|
1
|
-
export function joinAbsoluteUrlPath(...args: string[]) {
|
2
|
-
const [rootUrl] = args;
|
3
|
-
/**
|
4
|
-
* This method takes any form of input string and resolves them to make an absolute url
|
5
|
-
* Since these paths are web paths and not file paths, we are creating a URL object (https://nodejs.org/api/url.html). http://example.com has just been used as a dummy entry to create a valid url.
|
6
|
-
* Note: path.resolves gives you different output based on the OS node is running on. More reading here https://nodejs.org/api/path.html#windows-vs-posix.
|
7
|
-
*/
|
8
|
-
const url = new URL(getSanitisedString(args), 'http://example.com');
|
9
|
-
if (urlIsAbsolute(rootUrl)) {
|
10
|
-
return url.toString();
|
11
|
-
} else {
|
12
|
-
return url.pathname.replace(/(^\/|\/$)/g, '');
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
function getSanitisedString(subdirs: string[]) {
|
17
|
-
return subdirs.map((dir) => dir.replace(/(^\.\/+)|(^\/+|\/+$)/g, '')).join('/');
|
18
|
-
}
|
19
|
-
|
20
|
-
function urlIsAbsolute(url: string) {
|
21
|
-
return url.match(/^http(s?):\/\//);
|
22
|
-
}
|
package/src/util/never.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import { parseEnvVarForVar } from './parseEnvVarForVar';
|
2
|
-
|
3
|
-
describe('parseEnvVarForVar', () => {
|
4
|
-
it('it should read an environment variable from process.env.*', () => {
|
5
|
-
process.env.MY_VAR = 'hello';
|
6
|
-
|
7
|
-
expect(parseEnvVarForVar('MY_VAR')).toEqual('hello');
|
8
|
-
});
|
9
|
-
|
10
|
-
it('it should throw an error if the variable is not available', () => {
|
11
|
-
expect(() => parseEnvVarForVar('DOESNT_EXIST')).toThrowError(new Error('env variable DOESNT_EXIST must be set'));
|
12
|
-
});
|
13
|
-
|
14
|
-
it('it should not throw an error if a default value is provided and env var doesnt exist', () => {
|
15
|
-
expect(parseEnvVarForVar('DOESNT_EXIST', 'default')).toEqual('default');
|
16
|
-
});
|
17
|
-
|
18
|
-
it('it should return env var if its set and a defualt value is set', () => {
|
19
|
-
process.env.MY_VAR = 'hello';
|
20
|
-
expect(parseEnvVarForVar('MY_VAR', 'default')).toEqual('hello');
|
21
|
-
});
|
22
|
-
});
|
@@ -1,12 +0,0 @@
|
|
1
|
-
export function parseEnvVarForVar(varName: string, defaultValue: string | undefined = undefined): string {
|
2
|
-
if (process.env[varName] === undefined) {
|
3
|
-
if (defaultValue !== undefined) {
|
4
|
-
return defaultValue;
|
5
|
-
}
|
6
|
-
|
7
|
-
throw new Error(`env variable ${varName} must be set`);
|
8
|
-
}
|
9
|
-
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
11
|
-
return process.env[varName]!;
|
12
|
-
}
|