@becollective/utils 1.7.1 → 1.7.2
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/.semaphore/utils.yml +44 -0
- package/README.md +133 -0
- package/bundle.js +53 -96
- package/package.json +1 -1
- package/src/password.js +1 -1
- package/tests/password.test.js +3 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
version: v1.0
|
|
2
|
+
name: @becollective/utils
|
|
3
|
+
agent:
|
|
4
|
+
machine:
|
|
5
|
+
type: e1-standard-2
|
|
6
|
+
os_image: ubuntu1804
|
|
7
|
+
blocks:
|
|
8
|
+
- name: Test
|
|
9
|
+
task:
|
|
10
|
+
secrets:
|
|
11
|
+
- name: NPM
|
|
12
|
+
- name: BUILD_DEPRECATED
|
|
13
|
+
prologue:
|
|
14
|
+
commands:
|
|
15
|
+
- checkout
|
|
16
|
+
- export AWS_ACCESS_KEY_ID=$AWS_BUILD_DEPRECATED_ACCESS_KEY
|
|
17
|
+
- export AWS_SECRET_ACCESS_KEY=$AWS_BUILD_DEPRECATED_SECRET_ACCESS_KEY
|
|
18
|
+
jobs:
|
|
19
|
+
- name: Test
|
|
20
|
+
commands:
|
|
21
|
+
- cd ./packages/utils
|
|
22
|
+
- npm ci
|
|
23
|
+
- npm run test
|
|
24
|
+
- name: Publish
|
|
25
|
+
skip:
|
|
26
|
+
when: "branch != 'master'"
|
|
27
|
+
task:
|
|
28
|
+
secrets:
|
|
29
|
+
- name: NPM
|
|
30
|
+
- name: BUILD_DEPRECATED
|
|
31
|
+
env_vars:
|
|
32
|
+
- name: PACKAGE_DIR
|
|
33
|
+
value: ./packages/utils
|
|
34
|
+
prologue:
|
|
35
|
+
commands:
|
|
36
|
+
- checkout
|
|
37
|
+
- export AWS_ACCESS_KEY_ID=$AWS_BUILD_DEPRECATED_ACCESS_KEY
|
|
38
|
+
- export AWS_SECRET_ACCESS_KEY=$AWS_BUILD_DEPRECATED_SECRET_ACCESS_KEY
|
|
39
|
+
jobs:
|
|
40
|
+
- name: Publish
|
|
41
|
+
commands:
|
|
42
|
+
- echo "deploying @becollective/utils"
|
|
43
|
+
- sh ./.semaphore/deployer.sh
|
|
44
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @becollective/utils
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
---
|
|
5
|
+
A collection of helper methods for handling regional issues, feature-flags and password checking functionality.
|
|
6
|
+
|
|
7
|
+
These include:
|
|
8
|
+
- Age, underSixteen and date diff checks
|
|
9
|
+
- Turns shift dates into readable text
|
|
10
|
+
- Fetch feature-flags from feature flag service
|
|
11
|
+
- Get a tagged home location from a list of locations
|
|
12
|
+
- Money formatting strings
|
|
13
|
+
- Password checks
|
|
14
|
+
|
|
15
|
+
## :computer: Pre-requisites
|
|
16
|
+
---
|
|
17
|
+
Some projects have different node versions I would recommend using:
|
|
18
|
+
[nvm](https://github.com/nvm-sh/nvm/blob/master/README.md)
|
|
19
|
+
|
|
20
|
+
node version for api: `node:14-alpine`
|
|
21
|
+
|
|
22
|
+
Ensure you have done the following in the [confluence](https://becollective.atlassian.net/wiki/spaces/ENGINEERIN/pages/1605849/Setup+Local+Development+Environment) link
|
|
23
|
+
|
|
24
|
+
- `Setup Local Development Environment`
|
|
25
|
+
|
|
26
|
+
- `Dependency services for local Be Collective Services`
|
|
27
|
+
|
|
28
|
+
## :wave: Getting started
|
|
29
|
+
---
|
|
30
|
+
- Clone the repository
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
git clone <https://github.com/tickboxAU/becollective-npm.git>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
cd becollective-npm
|
|
38
|
+
```
|
|
39
|
+
```
|
|
40
|
+
cd packages/utils
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
bcDocker
|
|
45
|
+
```
|
|
46
|
+
- `bcDocker` [confluence](https://becollective.atlassian.net/wiki/spaces/ENGINEERIN/pages/1605849/1+-+Setup+Local+Development+Environment#Dependency-services-for-local-Be-Collective-Services)
|
|
47
|
+
|
|
48
|
+
- Install dependencies
|
|
49
|
+
```
|
|
50
|
+
npm install
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- how to run tests
|
|
54
|
+
```
|
|
55
|
+
npm run test
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- how to build
|
|
59
|
+
```
|
|
60
|
+
npm run build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Project Structure
|
|
64
|
+
---
|
|
65
|
+
The folder structure of this project is explained below:
|
|
66
|
+
|
|
67
|
+
| Name | Description |
|
|
68
|
+
|-------------------------|-----------------------------------------------------|
|
|
69
|
+
| **node_modules** | Contains all npm dependencies |
|
|
70
|
+
| **.semaphore** | Contains the deployment yml for semaphore |
|
|
71
|
+
| **src/date-time** | Date-time helper methods |
|
|
72
|
+
| **src/FeatureFlag** | Feature flag helper methods |
|
|
73
|
+
| **src/locality** | Location helper methods |
|
|
74
|
+
| **src/money** | Money string helper methods |
|
|
75
|
+
| **src/opportunity** | Opportunity types |
|
|
76
|
+
| **src/opportunityUser** | Opportunity time helper methods |
|
|
77
|
+
| **src/password** | Password validation helper methods |
|
|
78
|
+
| **tests** | Contain all tests |
|
|
79
|
+
| **jestconfig.js** | Test configuration |
|
|
80
|
+
| **package.json** | Contains npm dependencies as well as build scripts |
|
|
81
|
+
| **rollup.config.js** | config for babel and rollup combination |
|
|
82
|
+
| **setup.ts** | Test setup script |
|
|
83
|
+
| **tsconfig.json** | Config settings for TS transpiling |
|
|
84
|
+
| **tslint.json** | Config settings for TSLint code style checking |
|
|
85
|
+
|
|
86
|
+
### :sparkles: Guidelines
|
|
87
|
+
---
|
|
88
|
+
Remember that these packages will be consumed by other services, many of which are lambda's that have strict size restrictions.
|
|
89
|
+
Please be mindful of any packages you add here, as they could potentially cause inoperable deployments of ingesting services.
|
|
90
|
+
*Basically, only import if you really, really need it*
|
|
91
|
+
|
|
92
|
+
## Import and usage syntax
|
|
93
|
+
```
|
|
94
|
+
import {
|
|
95
|
+
isUnderSixteen,
|
|
96
|
+
FeatureFlag,
|
|
97
|
+
getAge,
|
|
98
|
+
getCurrencyFromCurrencyCode
|
|
99
|
+
makeMoneyString,
|
|
100
|
+
password
|
|
101
|
+
} from '@becollective/utils';
|
|
102
|
+
|
|
103
|
+
const isUnderSixteen = isUnderSixteen(birthdate);
|
|
104
|
+
|
|
105
|
+
const featureFlag = new FeatureFlag();
|
|
106
|
+
const isFeatureActive = await featureFlag.isFeatureActive(
|
|
107
|
+
'this-is-a-feature-key',
|
|
108
|
+
{ env: process.env.APP_ENV },
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const ageInYears = getAge(birthdate);
|
|
112
|
+
|
|
113
|
+
const currency = getCurrencyFromCurrencyCode('AUD');
|
|
114
|
+
|
|
115
|
+
const dollarDollarBills = makeMoneyString({ amount: 100, currencyCode: 'AUD' });
|
|
116
|
+
|
|
117
|
+
const isValid = password.isValid('this-is-a-password');
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
### Running npm scripts
|
|
122
|
+
|
|
123
|
+
| Npm Script | Description |
|
|
124
|
+
|-------------------|--------------------------------------------|
|
|
125
|
+
| `npm run test` | Run the tests |
|
|
126
|
+
| `npm run build` | runs rollup |
|
|
127
|
+
| `npm run prepare` | runs build (not sure why this is required) |
|
|
128
|
+
|
|
129
|
+
### :red_circle: Common Issues & FAQ
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
package/bundle.js
CHANGED
|
@@ -35,7 +35,7 @@ var password = {
|
|
|
35
35
|
validate: function validate(input) {
|
|
36
36
|
if (typeof input !== 'string') {
|
|
37
37
|
throw new Error('not-string');
|
|
38
|
-
} else if (input.length <
|
|
38
|
+
} else if (input.length < 12) {
|
|
39
39
|
throw new Error('invalid-length');
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -2843,54 +2843,38 @@ var followRedirects = wrap({ http: http__default['default'], https: https__defau
|
|
|
2843
2843
|
var wrap_1 = wrap;
|
|
2844
2844
|
followRedirects.wrap = wrap_1;
|
|
2845
2845
|
|
|
2846
|
-
var
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2846
|
+
var name = "axios";
|
|
2847
|
+
var version = "0.21.1";
|
|
2848
|
+
var description = "Promise based HTTP client for the browser and node.js";
|
|
2849
|
+
var main = "index.js";
|
|
2850
|
+
var scripts = {
|
|
2851
|
+
test: "grunt test && bundlesize",
|
|
2852
|
+
start: "node ./sandbox/server.js",
|
|
2853
|
+
build: "NODE_ENV=production grunt build",
|
|
2854
|
+
preversion: "npm test",
|
|
2855
|
+
version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
|
|
2856
|
+
postversion: "git push && git push --tags",
|
|
2857
|
+
examples: "node ./examples/server.js",
|
|
2858
|
+
coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
2859
|
+
fix: "eslint --fix lib/**/*.js"
|
|
2858
2860
|
};
|
|
2859
|
-
var
|
|
2860
|
-
type: "
|
|
2861
|
-
|
|
2862
|
-
raw: "axios@0.21.1",
|
|
2863
|
-
name: "axios",
|
|
2864
|
-
escapedName: "axios",
|
|
2865
|
-
rawSpec: "0.21.1",
|
|
2866
|
-
saveSpec: null,
|
|
2867
|
-
fetchSpec: "0.21.1"
|
|
2861
|
+
var repository = {
|
|
2862
|
+
type: "git",
|
|
2863
|
+
url: "https://github.com/axios/axios.git"
|
|
2868
2864
|
};
|
|
2869
|
-
var
|
|
2870
|
-
"
|
|
2865
|
+
var keywords = [
|
|
2866
|
+
"xhr",
|
|
2867
|
+
"http",
|
|
2868
|
+
"ajax",
|
|
2869
|
+
"promise",
|
|
2870
|
+
"node"
|
|
2871
2871
|
];
|
|
2872
|
-
var
|
|
2873
|
-
var
|
|
2874
|
-
var _where = "/codefresh/volume/becollective-npm/packages/utils";
|
|
2875
|
-
var author = {
|
|
2876
|
-
name: "Matt Zabriskie"
|
|
2877
|
-
};
|
|
2878
|
-
var browser = {
|
|
2879
|
-
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
|
2880
|
-
};
|
|
2872
|
+
var author = "Matt Zabriskie";
|
|
2873
|
+
var license = "MIT";
|
|
2881
2874
|
var bugs = {
|
|
2882
2875
|
url: "https://github.com/axios/axios/issues"
|
|
2883
2876
|
};
|
|
2884
|
-
var
|
|
2885
|
-
{
|
|
2886
|
-
path: "./dist/axios.min.js",
|
|
2887
|
-
threshold: "5kB"
|
|
2888
|
-
}
|
|
2889
|
-
];
|
|
2890
|
-
var dependencies = {
|
|
2891
|
-
"follow-redirects": "^1.10.0"
|
|
2892
|
-
};
|
|
2893
|
-
var description = "Promise based HTTP client for the browser and node.js";
|
|
2877
|
+
var homepage = "https://github.com/axios/axios";
|
|
2894
2878
|
var devDependencies = {
|
|
2895
2879
|
bundlesize: "^0.17.0",
|
|
2896
2880
|
coveralls: "^3.0.0",
|
|
@@ -2928,67 +2912,40 @@ var devDependencies = {
|
|
|
2928
2912
|
webpack: "^1.13.1",
|
|
2929
2913
|
"webpack-dev-server": "^1.14.1"
|
|
2930
2914
|
};
|
|
2931
|
-
var
|
|
2932
|
-
|
|
2933
|
-
var keywords = [
|
|
2934
|
-
"xhr",
|
|
2935
|
-
"http",
|
|
2936
|
-
"ajax",
|
|
2937
|
-
"promise",
|
|
2938
|
-
"node"
|
|
2939
|
-
];
|
|
2940
|
-
var license = "MIT";
|
|
2941
|
-
var main = "index.js";
|
|
2942
|
-
var name = "axios";
|
|
2943
|
-
var repository = {
|
|
2944
|
-
type: "git",
|
|
2945
|
-
url: "git+https://github.com/axios/axios.git"
|
|
2946
|
-
};
|
|
2947
|
-
var scripts = {
|
|
2948
|
-
build: "NODE_ENV=production grunt build",
|
|
2949
|
-
coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
2950
|
-
examples: "node ./examples/server.js",
|
|
2951
|
-
fix: "eslint --fix lib/**/*.js",
|
|
2952
|
-
postversion: "git push && git push --tags",
|
|
2953
|
-
preversion: "npm test",
|
|
2954
|
-
start: "node ./sandbox/server.js",
|
|
2955
|
-
test: "grunt test && bundlesize",
|
|
2956
|
-
version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"
|
|
2915
|
+
var browser = {
|
|
2916
|
+
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
|
2957
2917
|
};
|
|
2958
|
-
var
|
|
2918
|
+
var jsdelivr = "dist/axios.min.js";
|
|
2959
2919
|
var unpkg = "dist/axios.min.js";
|
|
2960
|
-
var
|
|
2920
|
+
var typings = "./index.d.ts";
|
|
2921
|
+
var dependencies = {
|
|
2922
|
+
"follow-redirects": "^1.10.0"
|
|
2923
|
+
};
|
|
2924
|
+
var bundlesize = [
|
|
2925
|
+
{
|
|
2926
|
+
path: "./dist/axios.min.js",
|
|
2927
|
+
threshold: "5kB"
|
|
2928
|
+
}
|
|
2929
|
+
];
|
|
2961
2930
|
var pkg = {
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
_requested: _requested,
|
|
2970
|
-
_requiredBy: _requiredBy,
|
|
2971
|
-
_resolved: _resolved,
|
|
2972
|
-
_spec: _spec,
|
|
2973
|
-
_where: _where,
|
|
2931
|
+
name: name,
|
|
2932
|
+
version: version,
|
|
2933
|
+
description: description,
|
|
2934
|
+
main: main,
|
|
2935
|
+
scripts: scripts,
|
|
2936
|
+
repository: repository,
|
|
2937
|
+
keywords: keywords,
|
|
2974
2938
|
author: author,
|
|
2975
|
-
|
|
2939
|
+
license: license,
|
|
2976
2940
|
bugs: bugs,
|
|
2977
|
-
bundlesize: bundlesize,
|
|
2978
|
-
dependencies: dependencies,
|
|
2979
|
-
description: description,
|
|
2980
|
-
devDependencies: devDependencies,
|
|
2981
2941
|
homepage: homepage,
|
|
2942
|
+
devDependencies: devDependencies,
|
|
2943
|
+
browser: browser,
|
|
2982
2944
|
jsdelivr: jsdelivr,
|
|
2983
|
-
keywords: keywords,
|
|
2984
|
-
license: license,
|
|
2985
|
-
main: main,
|
|
2986
|
-
name: name,
|
|
2987
|
-
repository: repository,
|
|
2988
|
-
scripts: scripts,
|
|
2989
|
-
typings: typings,
|
|
2990
2945
|
unpkg: unpkg,
|
|
2991
|
-
|
|
2946
|
+
typings: typings,
|
|
2947
|
+
dependencies: dependencies,
|
|
2948
|
+
bundlesize: bundlesize
|
|
2992
2949
|
};
|
|
2993
2950
|
|
|
2994
2951
|
var httpFollow = followRedirects.http;
|
package/package.json
CHANGED
package/src/password.js
CHANGED
package/tests/password.test.js
CHANGED
|
@@ -2,7 +2,7 @@ const util = require('../bundle.js');
|
|
|
2
2
|
|
|
3
3
|
describe('password.valiate', () => {
|
|
4
4
|
test('validate a valid password', async () => {
|
|
5
|
-
const password = '
|
|
5
|
+
const password = 'Password123456';
|
|
6
6
|
let result;
|
|
7
7
|
try {
|
|
8
8
|
result = util.password.validate(password);
|
|
@@ -18,13 +18,13 @@ describe('password.valiate', () => {
|
|
|
18
18
|
}).toThrow('invalid-length');
|
|
19
19
|
}, 1000);
|
|
20
20
|
test('validate a one rule password', async () => {
|
|
21
|
-
const password = '
|
|
21
|
+
const password = 'foobarabpcip';
|
|
22
22
|
expect(() => {
|
|
23
23
|
util.password.validate(password);
|
|
24
24
|
}).toThrow('invalid-minimum-rules');
|
|
25
25
|
}, 1000);
|
|
26
26
|
test('validate a two rule password', async () => {
|
|
27
|
-
const password = '
|
|
27
|
+
const password = 'foobarpcip123';
|
|
28
28
|
expect(() => {
|
|
29
29
|
util.password.validate(password);
|
|
30
30
|
}).toThrow('invalid-minimum-rules');
|