@squiz/dx-common-lib 1.2.1-alpha.101 → 1.2.1-alpha.103
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 +16 -0
- package/lib/assertions/index.d.ts +7 -0
- package/lib/assertions/index.js +26 -0
- package/lib/assertions/index.js.map +1 -0
- package/lib/error/BadRequestError.d.ts +4 -0
- package/lib/error/BadRequestError.js +11 -0
- package/lib/error/BadRequestError.js.map +1 -0
- package/lib/error/ErrorWithHttpStatusCode.d.ts +5 -0
- package/lib/error/ErrorWithHttpStatusCode.js +12 -0
- package/lib/error/ErrorWithHttpStatusCode.js.map +1 -0
- package/lib/error/InternalServerError.d.ts +4 -0
- package/lib/error/InternalServerError.js +11 -0
- package/lib/error/InternalServerError.js.map +1 -0
- package/lib/error/MethodNotImplementedError.d.ts +4 -0
- package/lib/error/MethodNotImplementedError.js +11 -0
- package/lib/error/MethodNotImplementedError.js.map +1 -0
- package/lib/error/ResourceNotFoundError.d.ts +4 -0
- package/lib/error/ResourceNotFoundError.js +11 -0
- package/lib/error/ResourceNotFoundError.js.map +1 -0
- package/lib/error/TimeoutError.d.ts +4 -0
- package/lib/error/TimeoutError.js +11 -0
- package/lib/error/TimeoutError.js.map +1 -0
- package/lib/error/index.d.ts +6 -0
- package/lib/error/index.js +23 -0
- package/lib/error/index.js.map +1 -0
- package/lib/index.d.ts +4 -7
- package/lib/index.js +4 -9
- package/lib/index.js.map +1 -1
- package/lib/util/getNodeEnv.d.ts +1 -0
- package/lib/util/getNodeEnv.js +14 -0
- package/lib/util/getNodeEnv.js.map +1 -0
- package/lib/util/getNodeEnv.spec.d.ts +1 -0
- package/lib/util/getNodeEnv.spec.js +22 -0
- package/lib/util/getNodeEnv.spec.js.map +1 -0
- package/lib/util/index.d.ts +5 -0
- package/lib/util/index.js +14 -0
- package/lib/util/index.js.map +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.d.ts +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.js +14 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.js.map +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.d.ts +1 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js +25 -0
- package/lib/util/isPathTryingToAccessOutsideOfRoot.spec.js.map +1 -0
- package/lib/util/joinAbsoluteUrlPath.d.ts +1 -0
- package/lib/util/joinAbsoluteUrlPath.js +26 -0
- package/lib/util/joinAbsoluteUrlPath.js.map +1 -0
- package/lib/util/joinAbsoluteUrlPath.spec.d.ts +1 -0
- package/lib/util/joinAbsoluteUrlPath.spec.js +43 -0
- package/lib/util/joinAbsoluteUrlPath.spec.js.map +1 -0
- package/lib/util/never.d.ts +1 -0
- package/lib/util/never.js +9 -0
- package/lib/util/never.js.map +1 -0
- package/lib/util/parseEnvVarForVar.d.ts +1 -0
- package/lib/util/parseEnvVarForVar.js +15 -0
- package/lib/util/parseEnvVarForVar.js.map +1 -0
- package/lib/util/parseEnvVarForVar.spec.d.ts +1 -0
- package/lib/util/parseEnvVarForVar.spec.js +20 -0
- package/lib/util/parseEnvVarForVar.spec.js.map +1 -0
- package/lib/zip/zipDirectory.d.ts +1 -0
- package/lib/zip/zipDirectory.js +32 -0
- package/lib/zip/zipDirectory.js.map +1 -0
- package/lib/zip/zipDirectory.spec.d.ts +1 -0
- package/lib/zip/zipDirectory.spec.js +25 -0
- package/lib/zip/zipDirectory.spec.js.map +1 -0
- package/package.json +8 -4
- package/src/assertions/index.ts +10 -0
- package/src/error/BadRequestError.ts +7 -0
- package/src/error/ErrorWithHttpStatusCode.ts +5 -0
- package/src/error/InternalServerError.ts +7 -0
- package/src/error/MethodNotImplementedError.ts +7 -0
- package/src/error/ResourceNotFoundError.ts +7 -0
- package/src/error/TimeoutError.ts +7 -0
- package/src/error/index.ts +6 -0
- package/src/index.ts +4 -10
- package/src/util/getNodeEnv.spec.ts +25 -0
- package/src/util/getNodeEnv.ts +11 -0
- package/src/util/index.ts +5 -0
- package/src/util/isPathTryingToAccessOutsideOfRoot.spec.ts +25 -0
- package/src/util/isPathTryingToAccessOutsideOfRoot.ts +8 -0
- package/src/util/joinAbsoluteUrlPath.spec.ts +62 -0
- package/src/util/joinAbsoluteUrlPath.ts +22 -0
- package/src/util/never.ts +4 -0
- package/src/util/parseEnvVarForVar.spec.ts +22 -0
- package/src/util/parseEnvVarForVar.ts +12 -0
- package/src/zip/zipDirectory.spec.ts +24 -0
- package/src/zip/zipDirectory.ts +31 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/jest.integration.config.ts +0 -26
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [1.2.1-alpha.103](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.103) (2022-08-23)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.2.1-alpha.102](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.102) (2022-08-23)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @squiz/dx-common-lib
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
6
22
|
## [1.2.1-alpha.101](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.101) (2022-08-19)
|
7
23
|
|
8
24
|
**Note:** Version bump only for package @squiz/dx-common-lib
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export * from './assertIsString';
|
2
|
+
export * from './assertIsDefined';
|
3
|
+
export * from './assertIsMapOfStringString';
|
4
|
+
export * from './assertIsObject';
|
5
|
+
export * from './assertIsNotAnEmptyString';
|
6
|
+
export * from './assertAssignWithDefaultUndefinedValue';
|
7
|
+
export * from './assertAssign';
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
// Common Assertions
|
18
|
+
__exportStar(require("./assertIsString"), exports);
|
19
|
+
__exportStar(require("./assertIsDefined"), exports);
|
20
|
+
__exportStar(require("./assertIsMapOfStringString"), exports);
|
21
|
+
__exportStar(require("./assertIsObject"), exports);
|
22
|
+
__exportStar(require("./assertIsNotAnEmptyString"), exports);
|
23
|
+
// Assert assign
|
24
|
+
__exportStar(require("./assertAssignWithDefaultUndefinedValue"), exports);
|
25
|
+
__exportStar(require("./assertAssign"), exports);
|
26
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assertions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oBAAoB;AACpB,mDAAiC;AACjC,oDAAkC;AAClC,8DAA4C;AAC5C,mDAAiC;AACjC,6DAA2C;AAE3C,gBAAgB;AAChB,0EAAwD;AACxD,iDAA+B"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BadRequestError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class BadRequestError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message) {
|
7
|
+
super(400, message);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.BadRequestError = BadRequestError;
|
11
|
+
//# sourceMappingURL=BadRequestError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"BadRequestError.js","sourceRoot":"","sources":["../../src/error/BadRequestError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,eAAgB,SAAQ,iDAAuB;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAJD,0CAIC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ErrorWithHttpStatusCode = void 0;
|
4
|
+
class ErrorWithHttpStatusCode extends Error {
|
5
|
+
constructor(statusCode, message) {
|
6
|
+
super(message);
|
7
|
+
this.statusCode = statusCode;
|
8
|
+
this.message = message;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
exports.ErrorWithHttpStatusCode = ErrorWithHttpStatusCode;
|
12
|
+
//# sourceMappingURL=ErrorWithHttpStatusCode.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ErrorWithHttpStatusCode.js","sourceRoot":"","sources":["../../src/error/ErrorWithHttpStatusCode.ts"],"names":[],"mappings":";;;AAAA,MAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAmB,UAAkB,EAAS,OAAe;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,eAAU,GAAV,UAAU,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAQ;IAE7D,CAAC;CACF;AAJD,0DAIC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.InternalServerError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class InternalServerError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message) {
|
7
|
+
super(500, message);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.InternalServerError = InternalServerError;
|
11
|
+
//# sourceMappingURL=InternalServerError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"InternalServerError.js","sourceRoot":"","sources":["../../src/error/InternalServerError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,mBAAoB,SAAQ,iDAAuB;IAC9D,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAJD,kDAIC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MethodNotImplementedError = void 0;
|
4
|
+
const InternalServerError_1 = require("./InternalServerError");
|
5
|
+
class MethodNotImplementedError extends InternalServerError_1.InternalServerError {
|
6
|
+
constructor(message) {
|
7
|
+
super(message !== null && message !== void 0 ? message : 'method is not implemented');
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.MethodNotImplementedError = MethodNotImplementedError;
|
11
|
+
//# sourceMappingURL=MethodNotImplementedError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MethodNotImplementedError.js","sourceRoot":"","sources":["../../src/error/MethodNotImplementedError.ts"],"names":[],"mappings":";;;AAAA,+DAA4D;AAE5D,MAAa,yBAA0B,SAAQ,yCAAmB;IAChE,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,2BAA2B,CAAC,CAAC;IAChD,CAAC;CACF;AAJD,8DAIC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ResourceNotFoundError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class ResourceNotFoundError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message) {
|
7
|
+
super(404, message);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.ResourceNotFoundError = ResourceNotFoundError;
|
11
|
+
//# sourceMappingURL=ResourceNotFoundError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ResourceNotFoundError.js","sourceRoot":"","sources":["../../src/error/ResourceNotFoundError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,qBAAsB,SAAQ,iDAAuB;IAChE,YAAY,OAAe;QACzB,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAJD,sDAIC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TimeoutError = void 0;
|
4
|
+
const ErrorWithHttpStatusCode_1 = require("./ErrorWithHttpStatusCode");
|
5
|
+
class TimeoutError extends ErrorWithHttpStatusCode_1.ErrorWithHttpStatusCode {
|
6
|
+
constructor(message = 'request failed to evaluate within the timeout period') {
|
7
|
+
super(500, message);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
exports.TimeoutError = TimeoutError;
|
11
|
+
//# sourceMappingURL=TimeoutError.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../../src/error/TimeoutError.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAEpE,MAAa,YAAa,SAAQ,iDAAuB;IACvD,YAAY,UAAkB,sDAAsD;QAClF,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;CACF;AAJD,oCAIC"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./BadRequestError"), exports);
|
18
|
+
__exportStar(require("./ErrorWithHttpStatusCode"), exports);
|
19
|
+
__exportStar(require("./InternalServerError"), exports);
|
20
|
+
__exportStar(require("./ResourceNotFoundError"), exports);
|
21
|
+
__exportStar(require("./TimeoutError"), exports);
|
22
|
+
__exportStar(require("./MethodNotImplementedError"), exports);
|
23
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,4DAA0C;AAC1C,wDAAsC;AACtC,0DAAwC;AACxC,iDAA+B;AAC/B,8DAA4C"}
|
package/lib/index.d.ts
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
export * from './assertions/
|
2
|
-
export * from './
|
3
|
-
export * from './
|
4
|
-
export * from './
|
5
|
-
export * from './assertions/assertIsNotAnEmptyString';
|
6
|
-
export * from './assertions/assertAssignWithDefaultUndefinedValue';
|
7
|
-
export * from './assertions/assertAssign';
|
1
|
+
export * from './assertions/';
|
2
|
+
export * from './error';
|
3
|
+
export * from './util';
|
4
|
+
export * from './zip/zipDirectory';
|
package/lib/index.js
CHANGED
@@ -14,13 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
|
18
|
-
__exportStar(require("./
|
19
|
-
__exportStar(require("./
|
20
|
-
__exportStar(require("./
|
21
|
-
__exportStar(require("./assertions/assertIsObject"), exports);
|
22
|
-
__exportStar(require("./assertions/assertIsNotAnEmptyString"), exports);
|
23
|
-
// Assert assign
|
24
|
-
__exportStar(require("./assertions/assertAssignWithDefaultUndefinedValue"), exports);
|
25
|
-
__exportStar(require("./assertions/assertAssign"), exports);
|
17
|
+
__exportStar(require("./assertions/"), exports);
|
18
|
+
__exportStar(require("./error"), exports);
|
19
|
+
__exportStar(require("./util"), exports);
|
20
|
+
__exportStar(require("./zip/zipDirectory"), exports);
|
26
21
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,0CAAwB;AACxB,yCAAuB;AACvB,qDAAmC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function getNodeEnv(): 'production' | 'development';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getNodeEnv = void 0;
|
4
|
+
function getNodeEnv() {
|
5
|
+
if (process.env.NODE_ENV == 'production') {
|
6
|
+
return 'production';
|
7
|
+
}
|
8
|
+
if (process.env.NODE_ENV == 'development' || process.env.NODE_ENV === undefined) {
|
9
|
+
return 'development';
|
10
|
+
}
|
11
|
+
throw new Error('NODE_ENV env var can only be values "production" or "development"');
|
12
|
+
}
|
13
|
+
exports.getNodeEnv = getNodeEnv;
|
14
|
+
//# sourceMappingURL=getNodeEnv.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getNodeEnv.js","sourceRoot":"","sources":["../../src/util/getNodeEnv.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU;IACxB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,YAAY,EAAE;QACxC,OAAO,YAAY,CAAC;KACrB;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE;QAC/E,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;AACvF,CAAC;AAVD,gCAUC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const getNodeEnv_1 = require("./getNodeEnv");
|
4
|
+
describe('getNodeEnv', () => {
|
5
|
+
it('should return production if NODE_ENV equals production', () => {
|
6
|
+
process.env.NODE_ENV = 'production';
|
7
|
+
expect((0, getNodeEnv_1.getNodeEnv)()).toEqual('production');
|
8
|
+
});
|
9
|
+
it('should return development if NODE_ENV equals development', () => {
|
10
|
+
process.env.NODE_ENV = 'development';
|
11
|
+
expect((0, getNodeEnv_1.getNodeEnv)()).toEqual('development');
|
12
|
+
});
|
13
|
+
it('should return development if NODE_ENV is not set', () => {
|
14
|
+
delete process.env.NODE_ENV;
|
15
|
+
expect((0, getNodeEnv_1.getNodeEnv)()).toEqual('development');
|
16
|
+
});
|
17
|
+
it('should throw if NODE_ENV set to non valid environment', () => {
|
18
|
+
process.env.NODE_ENV = 'invalid';
|
19
|
+
expect(() => (0, getNodeEnv_1.getNodeEnv)()).toThrowError(new Error('NODE_ENV env var can only be values "production" or "development"'));
|
20
|
+
});
|
21
|
+
});
|
22
|
+
//# sourceMappingURL=getNodeEnv.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getNodeEnv.spec.js","sourceRoot":"","sources":["../../src/util/getNodeEnv.spec.ts"],"names":[],"mappings":";;AAAA,6CAA0C;AAE1C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;QACpC,MAAM,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAC;QACrC,MAAM,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC5B,MAAM,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC;QACjC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,uBAAU,GAAE,CAAC,CAAC,YAAY,CACrC,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAC/E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,5 @@
|
|
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';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.never = exports.parseEnvVarForVar = exports.joinAbsoluteUrlPath = exports.isPathTryingToAccessOutsideOfRoot = exports.getNodeEnv = void 0;
|
4
|
+
var getNodeEnv_1 = require("./getNodeEnv");
|
5
|
+
Object.defineProperty(exports, "getNodeEnv", { enumerable: true, get: function () { return getNodeEnv_1.getNodeEnv; } });
|
6
|
+
var isPathTryingToAccessOutsideOfRoot_1 = require("./isPathTryingToAccessOutsideOfRoot");
|
7
|
+
Object.defineProperty(exports, "isPathTryingToAccessOutsideOfRoot", { enumerable: true, get: function () { return isPathTryingToAccessOutsideOfRoot_1.isPathTryingToAccessOutsideOfRoot; } });
|
8
|
+
var joinAbsoluteUrlPath_1 = require("./joinAbsoluteUrlPath");
|
9
|
+
Object.defineProperty(exports, "joinAbsoluteUrlPath", { enumerable: true, get: function () { return joinAbsoluteUrlPath_1.joinAbsoluteUrlPath; } });
|
10
|
+
var parseEnvVarForVar_1 = require("./parseEnvVarForVar");
|
11
|
+
Object.defineProperty(exports, "parseEnvVarForVar", { enumerable: true, get: function () { return parseEnvVarForVar_1.parseEnvVarForVar; } });
|
12
|
+
var never_1 = require("./never");
|
13
|
+
Object.defineProperty(exports, "never", { enumerable: true, get: function () { return never_1.never; } });
|
14
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,yFAAwF;AAA/E,sJAAA,iCAAiC,OAAA;AAC1C,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,iCAAgC;AAAvB,8FAAA,KAAK,OAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function isPathTryingToAccessOutsideOfRoot(rootPath: string, filePath: string): boolean;
|
@@ -0,0 +1,14 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,25 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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,MAA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: string[]): string;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,43 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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,sBAAs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,MAAM,CAAC,IAAA,yCAAmB,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function never(a: never): void;
|
@@ -0,0 +1,9 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function parseEnvVarForVar(varName: string, defaultValue?: string | undefined): string;
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function zipDirectory(sourceDirectory: string, outputDirectory: string): Promise<string>;
|