Skip to content

Commit

Permalink
improve typings for Table method
Browse files Browse the repository at this point in the history
  • Loading branch information
LCluber committed Mar 3, 2021
1 parent c4de741 commit c5a1cf3
Show file tree
Hide file tree
Showing 48 changed files with 111 additions and 1,400 deletions.
19 changes: 19 additions & 0 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,24 @@
"bundled": 9909,
"minified": 4061,
"gzipped": 1667
},
"src/build/csvx.js": {
"bundled": 6206,
"minified": 2862,
"gzipped": 1130,
"treeshaked": {
"rollup": {
"code": 27,
"import_statements": 27
},
"webpack": {
"code": 2080
}
}
},
"src/build/csvx.iife.js": {
"bundled": 9909,
"minified": 4061,
"gzipped": 1667
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.2.5 (March 03rd 2021)
-----------------------------
- improved typings for table conversion method

Version 0.2.4 (February 22th 2021)
-----------------------------
- Simplified data typing for TypeScript
Expand Down
174 changes: 1 addition & 173 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function(grunt){
const host = 'localhost';

const srcDir = 'src/';
const compiledSrcDir = srcDir + 'ts/build/';
const compiledSrcDir = srcDir + 'build/';
const compiledES6Dir = compiledSrcDir + 'es6/';
const distDir = 'dist/';
const webDir = 'web/';
Expand Down Expand Up @@ -53,19 +53,6 @@ module.exports = function(grunt){
src: [ distDir + '*',
compiledES6Dir + '*'
]
},
websass:{
src: [ webDir + 'sass/build/*',
publicDir + 'css/*'
]
},
webjs:{
src: [ publicDir + 'js/*'
]
},
webmisc: {
src: [ publicDir + 'fonts/*'
]
}
},
// jshint: {
Expand All @@ -74,21 +61,6 @@ module.exports = function(grunt){
// },
// web: [ webDir + 'js/**/*.js']
// },
sass: {
options: {
implementation: sass,
sourceMap: true
},
dist: {
files: [{
expand: true,
cwd: webDir + 'sass/',
src: ['*.scss'],
dest: webDir + 'sass/build/',
ext: '.css'
}]
}
},
uglify: {
libIife: {
options: {
Expand Down Expand Up @@ -119,42 +91,6 @@ module.exports = function(grunt){
},
src: distDir + projectNameLC + '.iife.js',
dest: distDir + projectNameLC + '.iife.min.js'
},
web: {
options: {
sourceMap: false,
sourceMapName: srcDir + 'sourcemap.map',
banner: '',
mangle: {
reserved: ['jQuery']
},
compress: {
sequences: true,
properties: true,
dead_code: true,
unsafe: false,
conditionals:true,
comparisons:true,
booleans:true,
loops:true,
unused: true,
hoist_funs:true,
if_return:true,
join_vars:true,
warnings: true,
drop_console: false,
keep_fargs: false,
keep_fnames: false
}
},
files: [{
src : [
nodeDir + 'jquery-easing/jquery.easing.1.3.js',
//distDir + projectNameLC + '.iife.js',
webDir + 'js/*.js'
],
dest : publicDir + 'js/main.min.js'
}]
}
},
concat:{
Expand All @@ -166,32 +102,6 @@ module.exports = function(grunt){
},
src: compiledES6Dir + '*.d.ts',
dest: distDir + projectNameLC + '.d.ts'
},
webjs: {
options: {
separator: '',
stripBanners: true,
banner: ''
},
src: [nodeDir + 'jquery/dist/jquery.min.js',
nodeDir + '@fortawesome/fontawesome-free/js/all.min.js',
nodeDir + 'bootstrap/dist/js/bootstrap.min.js',
nodeDir + '@lcluber/weejs/dist/wee.iife.min.js',
publicDir + 'js/main.min.js'
],
dest: publicDir + 'js/main.min.js'
},
webcss: {
options: {
separator: '',
stripBanners: true,
banner: ''
},
src: [// nodeDir + 'font-awesome/css/font-awesome.min.css',
nodeDir + 'bootstrap/dist/css/bootstrap.min.css',
publicDir + 'css/style.min.css'
],
dest: publicDir + 'css/style.min.css'
}
},
strip_code: {
Expand All @@ -206,45 +116,6 @@ module.exports = function(grunt){
declaration: {
src: distDir + projectName + '.d.ts'
}
},
copy: {
fonts:{
expand: true,
cwd: nodeDir + 'bootstrap/dist/',
src: ['fonts/**/*'],
dest: publicDir,
filter: 'isFile'
},
css:{
expand: true,
cwd: webDir + 'sass/build/',
src: ['*'],
dest: publicDir + 'css/',
filter: 'isFile'
}
},
nodemon: {
dev: {
script: 'bin/www',
options: {
//nodeArgs: ['--debug'],
delay:1000,
watch: ['web/routes', 'web/app.js'],
ext: 'js,scss'
}
}
},
open: {
all: {
path: 'http://' + host + ':' + port
}
},
// run watch and nodemon at the same time
concurrent: {
options: {
logConcurrentOutput: true
},
tasks: ['nodemon' ]
}
});

Expand All @@ -253,9 +124,6 @@ module.exports = function(grunt){
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-concat' );
grunt.loadNpmTasks( 'grunt-strip-code' );
grunt.loadNpmTasks( 'grunt-concurrent' );
grunt.loadNpmTasks( 'grunt-nodemon' );
grunt.loadNpmTasks( 'grunt-sass' );


grunt.registerTask( 'ugly',
Expand All @@ -271,44 +139,4 @@ module.exports = function(grunt){
]
);

grunt.registerTask( 'serve',
'launch server, open website and watch for changes',
[ 'concurrent' ]
);

grunt.registerTask( 'websass',
'Compile website css',
[ 'clean:websass',
'sass',
// 'cssmin',
'copy:css',
'concat:webcss'
]
);

grunt.registerTask( 'webjs',
'Compile website js',
[ //'jshint:web',
'clean:webjs',
'uglify:web',
'concat:webjs'
]
);

grunt.registerTask( 'webmisc',
'Compile website misc',
[ 'clean:webmisc',
'copy:fonts'
]
);

grunt.registerTask( 'website',
'build the website in the website/ folder',
function() {
grunt.task.run('webjs');
grunt.task.run('websass');
grunt.task.run('webmisc');
}
);

};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Convert {
// convert CSV to Javascript array
static array(data: string, options?: Partial<Options>, css?: Partial<CSS>): Array<Array<string>> | false;
// convert CSV to HTML table
static table(data: string, options?: Options, css?: CSS): string | false;
static table(data: string, options?: Partial<Options>, css?: Partial<CSS>): string | false;
}

class Export {
Expand Down
2 changes: 1 addition & 1 deletion dist/csvx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export declare class Convert {
static setOptions(options: Partial<Options>): void;
static setCSS(css: Partial<CSS>): void;
static array(data: string, options?: Partial<Options>, css?: Partial<CSS>): Array<Array<string>> | false;
static table(data: string, options?: Options, css?: CSS): string | false;
static table(data: string, options?: Partial<Options>, css?: Partial<CSS>): string | false;
private static createTr;
private static setObject;
}
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3.8"
services:

csvx:
build: ./
container_name: csvx
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules
15 changes: 15 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:15.6.0-alpine3.12
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm i -no-progress --loglevel=error
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
# COPY . /usr/src/app
# EXPOSE 3000
CMD [ "npm", "run", "build" ]
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dwtechs/csvx",
"version": "0.2.4",
"version": "0.2.5",
"description": "CSV Export library written in TypeScript.",
"keywords": [],
"homepage": "https://github.com/DWTechs/CSVx.js",
Expand All @@ -22,13 +22,13 @@
},
"contributors": [],
"scripts": {
"start": "node ./bin/www",
"build": "npm run clean && tsc && npm run rollup && grunt declaration && npm run banner && npm run uglify && grunt website && npm run serve",
"clean": "rimraf dist/* src/ts/build/*",
"start": "",
"build": "npm run clean && tsc && npm run rollup && grunt declaration && npm run banner && npm run uglify",
"clean": "rimraf dist/* src/build/*",
"rollup": "rollup --config rollup.config.mjs && rollup --config rollup.config.js",
"banner": "cat lic.js src/ts/build/csvx.js > dist/csvx.js && cat lic.js src/ts/build/csvx.iife.js > dist/csvx.iife.js",
"banner": "cat lic.js src/build/csvx.js > dist/csvx.js && cat lic.js src/build/csvx.iife.js > dist/csvx.iife.js",
"uglify": "grunt ugly",
"serve": "grunt serve"
"test": "jest --coverage"
},
"files": [
"dist/"
Expand All @@ -45,6 +45,7 @@
"@rollup/plugin-commonjs": "11.0.2",
"@rollup/plugin-node-resolve": "7.1.3",
"@types/node": "^14.14.12",
"babel-jest": "24.9.0",
"body-parser": "1.18.2",
"bootstrap": "3.3.7",
"connect-livereload": "0.6.0",
Expand All @@ -57,18 +58,15 @@
"grunt-contrib-concat": "1.0.1",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-uglify": "3.3.0",
"grunt-nodemon": "0.4.2",
"grunt-sass": "3.1.0",
"grunt-strip-code": "1.0.6",
"grunt-ts": "6.0.0-beta.22",
"i18next": "11.2.3",
"i18next-express-middleware": "1.1.1",
"i18next-node-fs-backend": "1.0.0",
"jest": "24.9.0",
"jquery": "3.2.1",
"jquery-easing": "0.0.1",
"morgan": "1.9.0",
"node-sass": "4.14.0",
"pug": "2.0.3",
"rimraf": "3.0.2",
"rollup": "2.3.3",
"rollup-plugin-analyzer": "3.2.2",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const onAnalysis = ({ bundleSize }) => {
};

module.exports = {
input: "src/ts/build/es6/csvx.js",
input: "src/build/es6/csvx.js",
output: {
name: "CSVx",
file: "src/ts/build/csvx.iife.js",
file: "src/build/csvx.iife.js",
format: "iife"
},
external: [], // <-- suppresses the warning
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const onAnalysis = ({ bundleSize }) => {
};

module.exports = {
input: "src/ts/build/es6/csvx.js",
input: "src/build/es6/csvx.js",
output: {
name: "CSVx",
file: "src/ts/build/csvx.js",
file: "src/build/csvx.js",
format: "es"
},
external: [
Expand Down
2 changes: 1 addition & 1 deletion src/ts/convert.ts → src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Convert {
return array;
}

public static table( data: string, options?: Options, css?: CSS): string|false {
public static table( data: string, options?: Partial<Options>, css?: Partial<CSS>): string|false {

let array = this.array( data, options, css);
if (array) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c5a1cf3

Please sign in to comment.