Fixed the ts library and add rollup config for build
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Fixed log tests and updated config
This commit is contained in:
parent
f2f0c823e2
commit
b1b37b069f
@ -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
|
||||
|
18
package.json
18
package.json
@ -2,9 +2,14 @@
|
||||
"name": "@cubetiq/tsutil",
|
||||
"version": "1.0.0",
|
||||
"description": "CUBETIQ TypeScript Utils",
|
||||
"main": "index.ts",
|
||||
"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",
|
||||
"author": "Sambo Chea <sombochea@cubetiqs.com>",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"dependencies": {},
|
||||
@ -16,12 +21,19 @@
|
||||
"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 -p tsconfig.json",
|
||||
"build": "tsc --module commonjs && rollup -c rollup.config.ts",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"prettier": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"test": "jest",
|
||||
|
28
rollup.config.ts
Normal file
28
rollup.config.ts
Normal file
@ -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'
|
@ -1,6 +1,6 @@
|
||||
import { Loggable } from './interfaces';
|
||||
|
||||
class Index {
|
||||
class Log {
|
||||
static log(loggable: Loggable): void {
|
||||
switch (loggable.type) {
|
||||
case 'error':
|
||||
@ -28,4 +28,4 @@ class Index {
|
||||
}
|
||||
}
|
||||
|
||||
export default Index;
|
||||
export default Log;
|
||||
|
@ -1,20 +1,20 @@
|
||||
import Index from '../src/Log';
|
||||
import Log from '../src/log'
|
||||
|
||||
describe('logging into console', function () {
|
||||
it('info', function () {
|
||||
Index.info('I am an info!');
|
||||
Log.info('I am an info!');
|
||||
});
|
||||
|
||||
it('warn', function () {
|
||||
Index.info('I am a warn!');
|
||||
Log.info('I am a warn!');
|
||||
});
|
||||
|
||||
it('error', function () {
|
||||
Index.info('I am an error!');
|
||||
Log.info('I am an error!');
|
||||
});
|
||||
|
||||
it('loggable', function () {
|
||||
Index.log({
|
||||
Log.log({
|
||||
type: 'info',
|
||||
from: 'log.test.ts',
|
||||
data: 'I am loggable called'
|
||||
|
@ -8,7 +8,7 @@
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "commonjs",
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"noEmit": true,
|
||||
@ -17,6 +17,6 @@
|
||||
"rootDir": "src",
|
||||
"lib": ["es2015", "es2016", "es2017", "dom"]
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user