Skip to content

Commit

Permalink
[GH-1] typescript refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
karmaniverous committed Apr 21, 2024
1 parent bf976fa commit d7bf0cf
Show file tree
Hide file tree
Showing 39 changed files with 4,727 additions and 6,435 deletions.
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion .env

This file was deleted.

8 changes: 0 additions & 8 deletions .env.local.template

This file was deleted.

29 changes: 0 additions & 29 deletions .eslintrc.json

This file was deleted.

7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules
*.local
.nyc_output/
coverage/
dist/
esm/
node_modules/
19 changes: 19 additions & 0 deletions .lefthook/pre-commit/branch-naming-policy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#!/bin/sh

BRANCH=$(git rev-parse --abbrev-ref HEAD)
REGEX="^(head|main|(bugfix|chore|docs|feature|hotfix)\/[-_a-zA-Z0-9]+|release\/[0-9]+\.[0-9]+\.[0-9]+)(-[_a-zA-Z0-9]+)?$"

if ! [[ $BRANCH =~ $REGEX ]]; then
echo "$BRANCH"
echo ""
echo "Invalid branch name. Valid patterns:"
echo "- main"
echo "- bugfix/[-_a-zA-Z0-9]+"
echo "- chore/[-_a-zA-Z0-9]+"
echo "- docs/[-_a-zA-Z0-9]+"
echo "- feature/[-_a-zA-Z0-9]+"
echo "- hotfix/[-_a-zA-Z0-9]+"
echo "- release/{semantic version}"
exit 1
fi
8 changes: 8 additions & 0 deletions .lefthook/prepare-commit-msg/add-issue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=[$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(\w+/)?(\w+[-_]|#)?[0-9]+' | grep -Eo '(\w+[-_]|#)?[0-9]+' | tr "[:lower:]" "[:upper:]")]
if [[ $TICKET == "[]" || "$MESSAGE" == "$TICKET"* ]];then
exit 0;
fi

echo "$TICKET $MESSAGE" > $FILE
21 changes: 21 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"exclude": [
"./dist/**",
"./node_modules/**",
"./**/*.json"
],
"extension": [
"ts"
],
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm",
"no-warnings"
],
"recursive": true,
"require": [
"jsdom-global",
"source-map-support"
],
"spec": "./**/*.test.!(*.*)"
}
23 changes: 0 additions & 23 deletions .npmignore

This file was deleted.

7 changes: 7 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"all": true,
"include": ["src/**/*"],
"reporter": ["html", "lcov", "text", "text-summary"],
"skip-empty": true,
"skip-full": true
}
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"endOfLine": "crlf"
}
5 changes: 2 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"shyykoserhiy.git-autoconfig",
"hbenl.vscode-mocha-test-adapter",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"hbenl.vscode-mocha-test-adapter"
]
}
28 changes: 13 additions & 15 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
"git.autofetch": true,
"diffEditor.ignoreTrimWhitespace": false,
"javascript.updateImportsOnFileMove.enabled": "always",
"git.enableSmartCommit": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true,
"prettier.useTabs": false,
"prettier.singleQuote": true,
"editor.tabSize": 2,
"editor.formatOnPaste": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.accessibilitySupport": "off",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"git.autofetch": true,
"git.enableSmartCommit": true,
"javascript.preferences.importModuleSpecifierEnding": "minimal",
"[markdown]": {
"editor.wordWrap": "bounded"
}
"javascript.updateImportsOnFileMove.enabled": "always",
"mochaExplorer.nodeArgv": [
"--loader=ts-node/esm",
"--no-warnings=ExperimentalWarning",
"--experimental-specifier-resolution=node"
],
"testExplorer.mergeSuites": true,
"eslint.experimental.useFlatConfig": true
}

42 changes: 1 addition & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The `map` object is a [POJO](https://masteringjs.io/tutorials/fundamentals/pojo)

The transformation output will reflect the structure of your `map` object and include any static values. To add mapping logic, use a structured value that consists of an object with a single `$` key, like this:

```js
```ts
const map = {
foo: 'static value passed directly to output',
// Structure passed directly to output.
Expand Down Expand Up @@ -112,46 +112,6 @@ const output = await jsonMap.transform(input);

The [unit tests](https://github.com/karmaniverous/jsonmap/blob/main/lib/JsonMap/JsonMap.test.js) demonstrate this example in action.

# API Documentation

<a name="JsonMap"></a>

## JsonMap
JsonMap class to apply transformations to a JSON object

**Kind**: global class

* [JsonMap](#JsonMap)
* [new JsonMap([map], [lib], [options])](#new_JsonMap_new)
* [.transform(input)](#JsonMap+transform) ⇒ <code>object</code>

<a name="new_JsonMap_new"></a>

### new JsonMap([map], [lib], [options])
Creates an instance of JsonMap.


| Param | Type | Description |
| --- | --- | --- |
| [map] | <code>object</code> | The data mapping configuration. |
| [lib] | <code>object</code> | A collection of function libraries. |
| [options] | <code>object</code> | Options object |
| [options.ignore] | <code>string</code> | Regex pattern of keys to ignore. Defaults to '^\\$'. |
| [options.logger] | <code>string</code> | Logger object |

<a name="JsonMap+transform"></a>

### jsonMap.transform(input) ⇒ <code>object</code>
Transforms the input data according to the map configuration.

**Kind**: instance method of [<code>JsonMap</code>](#JsonMap)
**Returns**: <code>object</code> - - The transformed data.

| Param | Type | Description |
| --- | --- | --- |
| input | <code>object</code> | The input data to be transformed. |


---

See more great templates and other tools on
Expand Down
3 changes: 0 additions & 3 deletions dist/default/.babelrc

This file was deleted.

1 change: 0 additions & 1 deletion dist/default/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion dist/default/.npmignore

This file was deleted.

3 changes: 0 additions & 3 deletions dist/package.json

This file was deleted.

1 change: 0 additions & 1 deletion doc/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion doc/.prettierignore

This file was deleted.

113 changes: 0 additions & 113 deletions doc/1-main.md

This file was deleted.

4 changes: 0 additions & 4 deletions doc/3-footer.md

This file was deleted.

3 changes: 0 additions & 3 deletions doc/api-template.hbs

This file was deleted.

5 changes: 0 additions & 5 deletions doc/jsdoc.config.json

This file was deleted.

Loading

0 comments on commit d7bf0cf

Please sign in to comment.