-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: typescript port * build: workflow jobs
- Loading branch information
1 parent
169b990
commit 9d3de81
Showing
14 changed files
with
8,406 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | ||
|
||
name: npm Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
publish-npm: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./ts_version | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
cache-dependency-path: ts_version/package-lock.json | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: make publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} | ||
working-directory: ./ts_version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: npm test | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./ts_version | ||
strategy: | ||
matrix: | ||
node-version: [16.x, 17.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache-dependency-path: ts_version/package-lock.json | ||
cache: 'npm' | ||
- run: make install_prereqs | ||
- run: make test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
overrides: [ | ||
{ | ||
files: ['*.js', '*.jsx', '*.ts', '*.tsx'], | ||
} | ||
], | ||
rules: { | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.idea/** | ||
.vscode/** | ||
node_modules/ | ||
.DS_Store | ||
*.swp | ||
coverage/** | ||
.python-version | ||
**/build/** | ||
**/_build/** | ||
docs/assets/** | ||
docs/typedoc/** | ||
docs/providence_docs.egg-info/** | ||
dist/ | ||
src/**/*.js | ||
src/**/*.d.ts | ||
src/**/*.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
v16.15.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
export PATH := node_modules/.bin:$(PATH) | ||
export SHELL := /usr/bin/env bash | ||
export OS := $(shell uname -s) | ||
|
||
.DEFAULT_GOAL := oneshot | ||
|
||
install_prereqs: | ||
npm install -D | ||
|
||
build: # Build the NPM package. | ||
rm -rvf dist | ||
cp -a src dist | ||
cp tsconfig.json dist/ | ||
sed -i -e '/"rootDir"/d' dist/tsconfig.json | ||
cd dist && npx tsc && cd .. | ||
rm -rvf dist/__mocks__ | ||
find dist -depth -regex '.*/specs[/]?.*' -delete | ||
cp package.json README.md ../LICENSE.txt dist/ | ||
|
||
tarball: build | ||
cd dist && npm pack | ||
|
||
oneshot: install_prereqs build | ||
|
||
quality: | ||
npm run lint | ||
|
||
test: | ||
npm run test | ||
|
||
publish: install_prereqs build qa | ||
cd dist && npm publish --access public | ||
|
||
qa: quality test | ||
|
||
fix: | ||
npm run lint:fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Short Stuff | ||
|
||
**Typescript port of [short_stuff](https://github.com/Artconomy/short_stuff) built in python.** | ||
|
||
ShortStuff is a set of helper functions used for generating short unique | ||
identifiers, such as those used in YouTube video IDs or in URL shorteners. | ||
|
||
ShortStuff does this by generating random byte strings, running them through | ||
base64 encoding and then doing some cleanup for compatibility. | ||
|
||
Most distinct about the methodology is that it piggy-backs on UUIDs. That means | ||
that if you want to leverage your database or library's native UUID support, | ||
you can do so, and helper functions are provided for this. | ||
|
||
--- | ||
|
||
## Installation | ||
|
||
Short Stuff has been tested on node 16 and 17. | ||
|
||
To install: | ||
|
||
``` | ||
npm install shortStuff | ||
``` | ||
|
||
## Quick Guide | ||
|
||
To generate a short code: | ||
|
||
```javascript | ||
import { genShortcode } from 'shortStuff' | ||
console.log(genShortcode()) | ||
> 'XtFxMb7qTJ-A' | ||
``` | ||
|
||
To turn this code into a UUID (such as for DB storage): | ||
|
||
```javascript | ||
import { unSlugify } from 'shortStuff' | ||
console.log(unSlugify('XtFxMb7qTJ-A')) | ||
> '5ed17131-beea-4c9f-8000-000000000000' | ||
``` | ||
|
||
Notice that this is a truncated [uuid](https://github.com/uuidjs/uuid), with | ||
everything beyond the first eight bytes zeroed out. | ||
|
||
To turn the UUID back into a slug: | ||
|
||
```javascript | ||
import { slugify } from 'shortStuff' | ||
console.log(slugify('5ed17131-beea-4c9f-8000-000000000000')) | ||
> 'XtFxMb7qTJ-A' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
roots: ["src"], | ||
collectCoverageFrom: ['./src/**'], | ||
collectCoverage: true, | ||
coverageThreshold: { | ||
global: { | ||
lines: 90, | ||
} | ||
}, | ||
testMatch: [ | ||
'**/**/*.test.ts', | ||
], | ||
coveragePathIgnorePatterns: [ | ||
'.*[.]spec[.]ts', | ||
'.*[.]d[.]ts', | ||
'/specs/', | ||
'.*[.]js', | ||
] | ||
} | ||
|
Oops, something went wrong.