@becollective/utils 1.6.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.
@@ -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
+