Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Commitizen and Husky hooks to the build pipeline #27

Merged
merged 18 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d3c95a9
docs(contributing): fix code format issue in commits
M-Scott-Lassiter Apr 26, 2022
611f674
docs: format with Prettier
M-Scott-Lassiter Apr 26, 2022
cfa7276
build: add commitizen support for developers
M-Scott-Lassiter Apr 26, 2022
c96bb37
build: add Commitizen and Husky support
M-Scott-Lassiter Apr 26, 2022
00b362a
build: configure lint-staged and pre-commit hook
M-Scott-Lassiter Apr 26, 2022
66fb881
refactor: update the pre-commit hook
M-Scott-Lassiter Apr 26, 2022
5050476
ci: remove the Husky script from package.json
M-Scott-Lassiter Apr 26, 2022
fcc1942
build: remove extra Github release files from semantic-release config
M-Scott-Lassiter Apr 26, 2022
f1c0e10
docs: manually fix problem in changelog
M-Scott-Lassiter Apr 26, 2022
4624ddb
build: remove 'build' as a patch trigger for semantic-release
M-Scott-Lassiter Apr 26, 2022
d41920d
ci: remove 'next' branch from test CI script
M-Scott-Lassiter Apr 26, 2022
693b9ba
add YAML files to the lint-staged format list
M-Scott-Lassiter Apr 26, 2022
fde6467
docs: fix broken link in README
M-Scott-Lassiter Apr 26, 2022
387304b
docs(contributing): make final content additions to CONTRIBUTING.md
M-Scott-Lassiter Apr 26, 2022
d75a303
refactor: order package.json proprties per npm documentation order
M-Scott-Lassiter Apr 26, 2022
ec17803
ci: add support for Node v18 in bug report template
M-Scott-Lassiter Apr 26, 2022
7dddb0b
docs: update link in security policy
M-Scott-Lassiter Apr 26, 2022
a76db95
docs(api): add JSDoc annotation for all major accessors and functions…
M-Scott-Lassiter Apr 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 76 additions & 0 deletions .cz-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module.exports = {
types: [
{
value: 'build',
name: 'build: Changes that affect the build system configuration, package scripts, or dev dependencies (i.e. adds/remove/modify/update)'
},
{
value: 'ci',
name: 'ci: Changes to CI configuration files and scripts (e.g. release configs, YAML scripts)'
},
{ value: 'docs', name: 'docs: Documentation only changes' },
{ value: 'feat', name: 'feat: Adds a new feature' },
{
value: 'fix',
name: 'fix: Fixes a bug in an existing feature. Also used for non-dev dependency updates.'
},
{
value: 'perf',
name: 'perf: A code change that improves performance'
},
{
value: 'refactor',
name: 'refactor: A code change that neither fixes a bug nor adds a feature'
},
{ value: 'revert', name: 'revert: Revert to a commit' },
{ value: 'test', name: 'test: Add missing tests or correct existing tests' }
],

scopes: [
{ name: 'api' },
{ name: 'contributing' },
{ name: 'license' },
{ name: 'readme' },
{ name: 'security' }
],

allowTicketNumber: false,
isTicketNumberRequired: false,
ticketNumberPrefix: 'TICKET-',
ticketNumberRegExp: '\\d{1,5}',

// it needs to match the value for field type. Eg.: 'fix'
/*
scopeOverrides: {
fix: [
{name: 'merge'},
{name: 'style'},
{name: 'e2eTest'},
{name: 'unitTest'}
]
},
*/
// override the messages, defaults are as follows
messages: {
type: "Select the type of change that you're committing:",
scope: '\nDenote the SCOPE of this change (optional):',
// used if allowCustomScopes is true
customScope: 'Denote the SCOPE of this change:',
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional):\n',
footer: 'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
confirmCommit: 'Are you sure you want to proceed with the commit above?'
},

allowCustomScopes: true,
allowBreakingChanges: ['feat', 'fix'],
// skip any questions you want
// skipQuestions: ['body'],

// limit subject length
subjectLimit: 100,
// breaklineChar: '|', // It is supported for fields body and footer.
footerPrefix: 'Resolves:'
// askForBreakingChangeFirst : true, // default is false
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ body:
- 14
- 16
- 17
- 18
validations:
required: true
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ This information will help me triage your report more quickly.

## Response

Once the issue has been fixed, the [CI/CD process](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/blob/main/CONTRIBUTING.md) will trigger a new build. Once that build releases, I will make a [security advisory](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/security/advisories).
Once the issue has been fixed, the [CI/CD process](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/blob/main/CONTRIBUTING.md#continuous-integrationcontinuous-deployment-setup) will trigger a new build. Once that build releases, I will make a [security advisory](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/security/advisories).
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: CI Tests

on:
push:
branches: [main, next]
branches: [main]
pull_request:
branches: [main]

Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"**/*.{js,ts}": ["npm run lint"],
"**/*.{js,jsx,ts,tsx,json,html,css,scss,md,yml}": ["npm run format"]
}
116 changes: 102 additions & 14 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,131 @@

- [AlphanumericEncoder][1]
- [dictionary][2]
- [dictionary][3]
- [Parameters][4]
- [Parameters][3]
- [Examples][4]
- [encode][5]
- [Parameters][6]
- [Examples][7]
- [decode][8]
- [Parameters][9]
- [Examples][10]

## AlphanumericEncoder

A class for encoding and decoding base 10 integers to a custom alphanumeric base representation.

### dictionary

Returns the current dictionary. Default is the English alphabet in order: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
Set or get the current dictionary.

Returns **[string][7]** The current dictionary in use

### dictionary
Default is the English alphabet in order: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`

#### Parameters

- `newDictionary` **[string][7]** String of unique characters in order for the new dictionary
- `newDictionary` **[string][11]** (If setting) String of unique letters and numbers, in order, for the new dictionary

#### Examples

```javascript
console.log(AlphanumericEncoder.dictionary) // 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

AlphanumericEncoder.dictionary = 'ABCD'
console.log(AlphanumericEncoder.dictionary) // 'ABCD'

AlphanumericEncoder.dictionary = 'ABCDA' // Throws error because the letter 'A' is repeated
```

Returns **[string][11]** (If used as getter) The current dictionary in use

### encode

Takes any number and converts it into a base (dictionary length) letter combo.
It converts any numerical entry into a positive integer.

#### Parameters

- `number` **[number][8]** Base 10 number. Must be positive and non-zero. Decimals values are truncated.
- `integerToEncode` **[number][12]** Base 10 integer. If passed a non-integer number, decimal values are truncated.
Passing zero, negative numbers, or non-numbers will return `undefined`.

#### Examples

```javascript
const encoder = new AlphanumericEncoder()
console.log(encoder.encode(5)) // 'E'
console.log(encoder.encode(48)) // 'AV'
console.log(encoder.encode(733)) // 'ABE'
```

```javascript
const encoder = new AlphanumericEncoder()
encoder.dictionary = 'ABCD'
console.log(encoder.encode(5)) // 'AA'
console.log(encoder.encode(48)) // 'BCD'
console.log(encoder.encode(733)) // 'BCACA'
```

```javascript
const encoder = new AlphanumericEncoder()
encoder.dictionary = 'DCBA'
console.log(encoder.encode(5)) // 'DD'
console.log(encoder.encode(48)) // 'CBA'
console.log(encoder.encode(733)) // 'CBDBD'
```

```javascript
const encoder = new AlphanumericEncoder()
encoder.dictionary = 'ABC123'
console.log(encoder.encode(5)) // '2'
console.log(encoder.encode(48)) // 'AA3'
console.log(encoder.encode(733)) // 'CBBA'
```

Returns **[string][11]** Dictionary encoded value

### decode

Takes any string and converts it into a base 10 integer based on the defined dictionary.

#### Parameters

- `stringToDecode` **[string][11]** If passed a non-integer number, decimal values are truncated.
Passing an empty string, `null`, or `undefined` will return `undefined`.

#### Examples

```javascript
const encoder = new AlphanumericEncoder()
console.log(encoder.decode('A')) // 1
console.log(encoder.decode('AC')) // 29
console.log(encoder.decode('ANE')) // 1045
```

```javascript
const encoder = new AlphanumericEncoder()
console.log(encoder.decode('a')) // undefined
console.log(encoder.decode(123)) // undefined
console.log(encoder.decode('A?')) // undefined
```

```javascript
const encoder = new AlphanumericEncoder()
encoder.dictionary = 'ABCD'
console.log(encoder.decode('A')) // 1
console.log(encoder.decode('AC')) // 7
console.log(encoder.decode('ADBAC')) // 551
console.log(encoder.decode('ANE')) // undefined
```

Returns **[string][7]** Dictionary encoded value
Returns **[number][12]** Positive integer representation. If one of the characters is not present in the dictionary, it will return `undefined`.

[1]: #alphanumericencoder
[2]: #dictionary
[3]: #dictionary-1
[4]: #parameters
[3]: #parameters
[4]: #examples
[5]: #encode
[6]: #parameters-1
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[7]: #examples-1
[8]: #decode
[9]: #parameters-2
[10]: #examples-2
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
17 changes: 7 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
## [1.1.0](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/compare/v1.0.5...v1.1.0) (2022-04-26)


### :building_construction: Build Changes

* add Airbnb style guide to the ESLint configuration ([c30eac9](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/c30eac9ce98e3f564343ac5a83a1969e14e82430)), closes [#20](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/20)
* add Prettier for code formatting ([398dc54](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/398dc5416133df3b252fa429bf040293295955da)), closes [#21](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/21)

- add Airbnb style guide to the ESLint configuration ([c30eac9](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/c30eac9ce98e3f564343ac5a83a1969e14e82430)), closes [#20](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/20)
- add Prettier for code formatting ([398dc54](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/398dc5416133df3b252fa429bf040293295955da)), closes [#21](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/21)

### :lady_beetle: Bug Fixes

* remove unnecessary files from distribution ([a40e6be](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/a40e6beab4d9d2bb076acfa7b08e85d2d957ec0a)), closes [#22](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/22)

- remove unnecessary files from distribution ([a40e6be](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/a40e6beab4d9d2bb076acfa7b08e85d2d957ec0a)), closes [#22](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/22)

### :gift: Feature Changes

* add engine support for Node v10.x ([a04bd74](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/a04bd747b5e54c5c392ee308f9ceeeb4bfe27cc8)), closes [#23](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/23)
* add support for Node v18.x ([6056d72](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/6056d72a9d81c1db9bdaee6f4d06eda6af45e75b)), closes [#23](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/23)
- add engine support for Node v10.x ([a04bd74](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/a04bd747b5e54c5c392ee308f9ceeeb4bfe27cc8)), closes [#23](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/23)
- add support for Node v18.x ([6056d72](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/6056d72a9d81c1db9bdaee6f4d06eda6af45e75b)), closes [#23](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/23)

### [1.0.5](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/compare/v1.0.4...v1.0.5) (2022-04-24)
## [1.0.5](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/compare/v1.0.4...v1.0.5) (2022-04-24)

### :building_construction: Build Changes

- add a build script to the package ([51016bf](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/51016bf462f7e851635a38d7b2193b9bbfc0b0c2)), closes [#18](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/18)
- update the CD scripts to run `build` ([15f8d48](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/commit/15f8d483f29bf3b5afdd9810b6d03a7f70c98f02)), closes [#18](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/issues/18)

### [1.0.4](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/compare/v1.0.3...v1.0.4) (2022-04-24)
## [1.0.4](https://github.com/M-Scott-Lassiter/Alphanumeric-Encoder/compare/v1.0.3...v1.0.4) (2022-04-24)

### :building_construction: Build Changes

Expand Down