Compare commits
9 Commits
52898734ab
...
main
Author | SHA1 | Date | |
---|---|---|---|
Sambo Chea | b1b37b069f | ||
Sambo Chea | f2f0c823e2 | ||
Sambo Chea | 478c7ab38f | ||
Sambo Chea | 010dda1cad | ||
Sambo Chea | eea6a7bb32 | ||
Sambo Chea | 9e9cbe1162 | ||
Sambo Chea | df0b744058 | ||
Sambo Chea | b44cef99ca | ||
Sambo Chea | 2e9721a3f2 |
|
@ -0,0 +1,15 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
name: ci
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: node
|
||||
environment:
|
||||
DOCKER_REGISTRY:
|
||||
from_secret: docker_registry
|
||||
commands:
|
||||
- echo $DOCKER_REGISTRY
|
||||
- yarn
|
||||
- yarn
|
||||
- yarn test
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest Current File",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["${relativeFile}"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
# CUBETIQ TypeScript Utils
|
||||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
|
||||
[![Build Status](https://dci.osa.cubetiqs.com/api/badges/CUBETIQ/cubetiq-ts-utils/status.svg)](https://dci.osa.cubetiqs.com/CUBETIQ/cubetiq-ts-utils)
|
||||
|
||||
- Function Utils
|
||||
- General Functions for TypeScript project(s)
|
||||
- Extends more
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
transform: { '^.+\\.ts?$': 'ts-jest' },
|
||||
testEnvironment: 'node',
|
||||
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$',
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
|
||||
};
|
63
package.json
63
package.json
|
@ -1,25 +1,42 @@
|
|||
{
|
||||
"name": "cubetiq-ts-utils",
|
||||
"version": "1.0.0",
|
||||
"description": "CUBETIQ TypeScript Utils",
|
||||
"main": "index.ts",
|
||||
"repository": "https://github.com/CUBETIQ/cubetiq-ts-utils.git",
|
||||
"author": "Sambo Chea",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
||||
"@typescript-eslint/parser": "^4.17.0",
|
||||
"eslint": "^7.21.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"prettier": "^2.2.1",
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"prettier": "prettier --config .prettierrc 'src/**/*.ts' --write"
|
||||
}
|
||||
"name": "@cubetiq/tsutil",
|
||||
"version": "1.0.0",
|
||||
"description": "CUBETIQ TypeScript Utils",
|
||||
"main": "dist/index.js.umd.js",
|
||||
"module": "dist/index.es5.js",
|
||||
"typings": "dist/types/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"repository": "https://github.com/CUBETIQ/cubetiq-ts-utils.git",
|
||||
"author": "Sambo Chea <sombochea@cubetiqs.com>",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.20",
|
||||
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
||||
"@typescript-eslint/parser": "^4.17.0",
|
||||
"eslint": "^7.21.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"jest": "^26.6.3",
|
||||
"lodash.camelcase": "^4.3.0",
|
||||
"prettier": "^2.2.1",
|
||||
"rollup": "^2.41.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-json": "^4.0.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"ts-jest": "^26.5.3",
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --module commonjs && rollup -c rollup.config.ts",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"prettier": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"test": "jest",
|
||||
"coverage": "jest --coverage"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import resolve from 'rollup-plugin-node-resolve'
|
||||
import commonjs from 'rollup-plugin-commonjs'
|
||||
import sourceMaps from 'rollup-plugin-sourcemaps'
|
||||
import camelCase from 'lodash.camelcase'
|
||||
import typescript from 'rollup-plugin-typescript2'
|
||||
import json from 'rollup-plugin-json'
|
||||
|
||||
const pkg = require('./package.json')
|
||||
const libraryName = 'tsutil'
|
||||
|
||||
export default {
|
||||
input: `src/index.ts`,
|
||||
output: [
|
||||
{ file: pkg.main, name: camelCase(libraryName), format: 'umd', sourcemap: true },
|
||||
{ file: pkg.module, format: 'es', sourcemap: true },
|
||||
],
|
||||
external: [],
|
||||
watch: {
|
||||
include: 'src/**',
|
||||
},
|
||||
plugins: [
|
||||
json(),
|
||||
typescript({ useTsconfigDeclarationDir: true }),
|
||||
commonjs(),
|
||||
resolve(),
|
||||
sourceMaps(),
|
||||
],
|
||||
}
|
|
@ -1,5 +1 @@
|
|||
const Index = (): void => {
|
||||
console.log('Index', 'Hello, you are init the default function!');
|
||||
};
|
||||
|
||||
export default Index;
|
||||
export * as Log from './log/index'
|
|
@ -0,0 +1,31 @@
|
|||
import { Loggable } from './interfaces';
|
||||
|
||||
class Log {
|
||||
static log(loggable: Loggable): void {
|
||||
switch (loggable.type) {
|
||||
case 'error':
|
||||
this.error(loggable.from, loggable.data);
|
||||
break;
|
||||
case 'warn':
|
||||
this.warn(loggable.from, loggable.data);
|
||||
break;
|
||||
default:
|
||||
this.info(loggable.from, loggable.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static info(...data: any[]): void {
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
static error(...data: any[]): void {
|
||||
console.error(data);
|
||||
}
|
||||
|
||||
static warn(...data: any[]): void {
|
||||
console.warn(data);
|
||||
}
|
||||
}
|
||||
|
||||
export default Log;
|
|
@ -0,0 +1,7 @@
|
|||
export type LogType = 'info' | 'error' | 'warn';
|
||||
|
||||
export interface Loggable {
|
||||
type: LogType;
|
||||
from?: string;
|
||||
data?: any;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
import Log from '../src/log'
|
||||
|
||||
describe('logging into console', function () {
|
||||
it('info', function () {
|
||||
Log.info('I am an info!');
|
||||
});
|
||||
|
||||
it('warn', function () {
|
||||
Log.info('I am a warn!');
|
||||
});
|
||||
|
||||
it('error', function () {
|
||||
Log.info('I am an error!');
|
||||
});
|
||||
|
||||
it('loggable', function () {
|
||||
Log.log({
|
||||
type: 'info',
|
||||
from: 'log.test.ts',
|
||||
data: 'I am loggable called'
|
||||
});
|
||||
});
|
||||
});
|
|
@ -8,14 +8,15 @@
|
|||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "commonjs",
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
"rootDir": "src"
|
||||
"outDir": "dist/lib",
|
||||
"rootDir": "src",
|
||||
"lib": ["es2015", "es2016", "es2017", "dom"]
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user