vanilla-jet 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -221,5 +221,6 @@ function cleanALine(line) {
221
221
  function processCwd() {
222
222
  return process.cwd()
223
223
  .replace('/.grunt', '')
224
+ .replace('/gulp', '')
224
225
  .replace('/node_modules/vanilla-jet', '');
225
226
  }
package/bin.js CHANGED
@@ -15,33 +15,33 @@ switch (args[0]) {
15
15
 
16
16
  case 'dev':
17
17
  try {
18
- execSync('grunt --env=development', { stdio: 'inherit', cwd: __dirname });
18
+ execSync('gulp dev --env development', { stdio: 'inherit', cwd: __dirname });
19
19
  } catch (error) {
20
- console.error('Error ejecutando grunt:', error.message);
20
+ console.error('Error ejecutando gulp:', error.message);
21
21
  }
22
22
  break;
23
23
 
24
24
  case 'build:qa':
25
25
  try {
26
- execSync('grunt build --env=qa', { stdio: 'inherit', cwd: __dirname });
26
+ execSync('gulp build --env qa', { stdio: 'inherit', cwd: __dirname });
27
27
  } catch (error) {
28
- console.error('Error ejecutando grunt:', error.message);
28
+ console.error('Error ejecutando gulp:', error.message);
29
29
  }
30
30
  break;
31
31
 
32
32
  case 'build:staging':
33
33
  try {
34
- execSync('grunt build --env=staging', { stdio: 'inherit', cwd: __dirname });
34
+ execSync('gulp build --env staging', { stdio: 'inherit', cwd: __dirname });
35
35
  } catch (error) {
36
- console.error('Error ejecutando grunt:', error.message);
36
+ console.error('Error ejecutando gulp:', error.message);
37
37
  }
38
38
  break;
39
39
 
40
40
  case 'build:prod':
41
41
  try {
42
- execSync('grunt build --env=production', { stdio: 'inherit', cwd: __dirname });
42
+ execSync('gulp build --env production', { stdio: 'inherit', cwd: __dirname });
43
43
  } catch (error) {
44
- console.error('Error ejecutando grunt:', error.message);
44
+ console.error('Error ejecutando gulp:', error.message);
45
45
  }
46
46
  break;
47
47
  }
@@ -85,7 +85,6 @@ class Server {
85
85
  } else {
86
86
  console.log('HTTP server created - Without self managed certs');
87
87
  obj.httpx = http.createServer((req, res) => {
88
- console.log('Request received: ', req.url);
89
88
  obj.router.onRequest.call(obj.router, req, res);
90
89
  });
91
90
  }
package/gulpfile.js ADDED
@@ -0,0 +1,181 @@
1
+ const gulp = require('gulp');
2
+ const less = require('gulp-less');
3
+ const uglify = require('gulp-uglify');
4
+ const concat = require('gulp-concat');
5
+ const gzip = require('gulp-gzip');
6
+ const cleanCSS = require('gulp-clean-css');
7
+ const rename = require('gulp-rename');
8
+ const newer = require('gulp-newer');
9
+ const shell = require('gulp-shell');
10
+ const watch = require('gulp-watch');
11
+ const livereload = require('gulp-livereload');
12
+ const del = require('del');
13
+ const gulpif = require('gulp-if');
14
+ const minimist = require('minimist');
15
+
16
+ // Parse command line arguments
17
+ const knownOptions = {
18
+ string: 'env',
19
+ default: { env: process.env.NODE_ENV || 'development' }
20
+ };
21
+ const options = minimist(process.argv.slice(2), knownOptions);
22
+
23
+ // Helper functions
24
+ function getCwd() {
25
+ return process.cwd()
26
+ .replace('/node_modules', '')
27
+ .replace('/vanilla-jet', '')
28
+ .replace('/.gulp', '');
29
+ }
30
+
31
+ const base = getCwd();
32
+ const cssOrigin = `${getCwd()}/assets/styles/less/admin.less`;
33
+
34
+ // Clean tasks
35
+ function cleanBuildJS() {
36
+ return del([`${getCwd()}/public/scripts/vanilla.min.js`], { force: true });
37
+ }
38
+
39
+ function cleanMinified() {
40
+ return del([
41
+ `${getCwd()}/public/scripts/api`,
42
+ `${getCwd()}/public/scripts/controllers`,
43
+ `${getCwd()}/public/scripts/views`,
44
+ `${getCwd()}/public/scripts/app.min.js`
45
+ ], { force: true });
46
+ }
47
+
48
+ // LESS compilation
49
+ function buildLess() {
50
+ return gulp.src(cssOrigin)
51
+ .pipe(less({
52
+ //compress: true,
53
+ optimization: 2
54
+ }))
55
+ .pipe(rename('app.min.css'))
56
+ .pipe(cleanCSS())
57
+ .pipe(gulp.dest(`${getCwd()}/public/styles`))
58
+ .pipe(livereload());
59
+ }
60
+
61
+ // JavaScript tasks
62
+ function uglifyJs() {
63
+ return gulp.src([
64
+ `${getCwd()}/assets/scripts/*.js`,
65
+ `${getCwd()}/assets/scripts/**/*.js`,
66
+ `${getCwd()}/assets/scripts/**/**/*.js`,
67
+ `${getCwd()}/assets/scripts/**/**/**/*.js`
68
+ ])
69
+ .pipe(newer({
70
+ dest: `${getCwd()}/public`,
71
+ ext: '.min.js'
72
+ }))
73
+ .pipe(uglify({
74
+ compress: {
75
+ drop_console: false,
76
+ sequences: true,
77
+ dead_code: true,
78
+ conditionals: true,
79
+ booleans: true,
80
+ unused: true,
81
+ if_return: true,
82
+ join_vars: true
83
+ },
84
+ output: { ascii_only: true }
85
+ }))
86
+ .pipe(rename(function(path) {
87
+ path.basename += '.min';
88
+ }))
89
+ .pipe(gulp.dest(`${getCwd()}/public/scripts`));
90
+ }
91
+
92
+ // Concatenation task
93
+ function concatJs() {
94
+ return gulp.src([
95
+ `${getCwd()}/public/scripts/controllers/**/*.min.js`,
96
+ `${getCwd()}/public/scripts/views/**/*.min.js`,
97
+ `${getCwd()}/public/scripts/api/**/*.min.js`,
98
+ `${getCwd()}/public/scripts/*.min.js`,
99
+ `!${getCwd()}/public/scripts/core/**`,
100
+ `!${getCwd()}/public/scripts/plugins/**`,
101
+ `!${getCwd()}/public/scripts/plugins/ui/**`
102
+ ])
103
+ .pipe(concat('vanilla.min.js'))
104
+ .pipe(gulp.dest(`${getCwd()}/public/scripts`));
105
+ }
106
+
107
+ // Compression tasks
108
+ function compressJs() {
109
+ return gulp.src(`${getCwd()}/public/scripts/vanilla.min.js`)
110
+ .pipe(gzip({ gzipOptions: { level: 9 } }))
111
+ .pipe(gulp.dest(`${getCwd()}/public/scripts`));
112
+ }
113
+
114
+ function compressCss() {
115
+ return gulp.src(`${getCwd()}/public/styles/app.min.css`)
116
+ .pipe(gzip({ gzipOptions: { level: 9 } }))
117
+ .pipe(gulp.dest(`${getCwd()}/public/styles`));
118
+ }
119
+
120
+ // Template compilation
121
+ function compileTemplates() {
122
+ return gulp.src('.')
123
+ .pipe(shell([`node .grunt/compile_html.js ${options.env}`]));
124
+ }
125
+
126
+ // Watch task
127
+ function watchFiles(cb) {
128
+ livereload.listen();
129
+
130
+ // Watch LESS files
131
+ watch([`${base}/assets/styles/less/**/*.less`], gulp.series(
132
+ buildLess,
133
+ compressCss
134
+ ));
135
+
136
+ // Watch HTML files
137
+ watch([
138
+ `${base}/assets/pages/*.html`,
139
+ `${base}/assets/templates/**/*.html`
140
+ ], compileTemplates);
141
+
142
+ // Watch JS files
143
+ watch([`${base}/assets/scripts/**/*.js`], gulp.series(
144
+ cleanBuildJS,
145
+ uglifyJs,
146
+ concatJs,
147
+ cleanMinified,
148
+ compressJs
149
+ ));
150
+
151
+ cb();
152
+ }
153
+
154
+ // Define complex tasks
155
+ const build = gulp.series(
156
+ cleanBuildJS,
157
+ uglifyJs,
158
+ concatJs,
159
+ cleanMinified,
160
+ buildLess,
161
+ compileTemplates,
162
+ gulp.parallel(compressJs, compressCss)
163
+ );
164
+
165
+ const dev = gulp.series(
166
+ build,
167
+ watchFiles
168
+ );
169
+
170
+ // Export tasks
171
+ exports.cleanBuildJS = cleanBuildJS;
172
+ exports.cleanMinified = cleanMinified;
173
+ exports.buildLess = buildLess;
174
+ exports.uglifyJs = uglifyJs;
175
+ exports.concatJs = concatJs;
176
+ exports.compressJs = compressJs;
177
+ exports.compressCss = compressCss;
178
+ exports.compileTemplates = compileTemplates;
179
+ exports.build = build;
180
+ exports.dev = dev;
181
+ exports.default = dev;
package/index.js CHANGED
@@ -1,5 +1,3 @@
1
1
  const Server = require('./framework/server.js');
2
2
 
3
- module.exports = {
4
- Server
5
- };
3
+ module.exports = { Server };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-jet",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "VannilaJet framework",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -8,10 +8,10 @@
8
8
  },
9
9
  "scripts": {
10
10
  "setup": "node ./.scripts/generate_packages_json.js",
11
- "dev": "grunt --env=development",
12
- "build:qa": "grunt build --env=qa",
13
- "build:staging": "grunt build --env=staging",
14
- "build:prod": "grunt build --env=production",
11
+ "dev": "gulp dev --env development",
12
+ "build:qa": "gulp build --env qa",
13
+ "build:staging": "gulp build --env staging",
14
+ "build:prod": "gulp build --env production",
15
15
  "test": "npm run test"
16
16
  },
17
17
  "repository": {
@@ -31,19 +31,7 @@
31
31
  "dependencies": {
32
32
  "blueimp-md5": "2.19.0",
33
33
  "chalk": "4.1.2",
34
- "grunt": "1.6.1",
35
- "grunt-cli": "1.5.0",
36
- "grunt-contrib-clean": "2.0.1",
37
- "grunt-contrib-compress": "2.0.0",
38
- "grunt-contrib-concat": "2.1.0",
39
- "grunt-contrib-cssmin": "5.0.0",
40
- "grunt-contrib-less": "3.0.0",
41
- "grunt-contrib-uglify": "5.2.2",
42
- "grunt-contrib-watch": "1.1.0",
43
- "grunt-run": "0.8.1",
44
- "grunt-shell": "4.0.0",
45
34
  "html-minifier-terser": "7.2.0",
46
- "jit-grunt": "0.10.0",
47
35
  "js-beautify": "1.15.4",
48
36
  "jsrsasign": "11.1.0",
49
37
  "jwt-simple": "0.5.6",
@@ -51,6 +39,19 @@
51
39
  "nodemon": "3.1.10",
52
40
  "nunjucks": "3.2.4",
53
41
  "underscore": ">= 1.12.x",
54
- "zlib": "1.0.5"
42
+ "zlib": "1.0.5",
43
+ "del": "^6.0.0",
44
+ "gulp": "^4.0.2",
45
+ "gulp-clean-css": "^4.3.0",
46
+ "gulp-concat": "^2.6.1",
47
+ "gulp-gzip": "^1.4.2",
48
+ "gulp-if": "^3.0.0",
49
+ "gulp-less": "^5.0.0",
50
+ "gulp-livereload": "^4.0.2",
51
+ "gulp-newer": "^1.4.0",
52
+ "gulp-rename": "^2.0.0",
53
+ "gulp-shell": "^0.8.0",
54
+ "gulp-uglify": "^3.0.2",
55
+ "gulp-watch": "^5.0.1"
55
56
  }
56
57
  }
package/Gruntfile.js DELETED
@@ -1,182 +0,0 @@
1
- module.exports = function(grunt) {
2
-
3
- require('jit-grunt')(grunt, {
4
- concat: 'grunt-contrib-concat',
5
- //compress: 'grunt-contrib-compress',
6
- clean: 'grunt-contrib-clean'
7
- });
8
- grunt.option('force', true);
9
-
10
- // -- Load modules
11
- grunt.loadNpmTasks('grunt-contrib-cssmin');
12
- grunt.loadNpmTasks('grunt-contrib-uglify');
13
- grunt.loadNpmTasks('grunt-contrib-watch');
14
- grunt.loadNpmTasks('grunt-shell');
15
- grunt.loadNpmTasks('grunt-run');
16
- require('./.grunt/build_styles_task')(grunt);
17
-
18
- // -- Functions
19
- function getCwd() {
20
- const cwd = process.cwd();
21
- let newCwd = cwd
22
- .replace('/node_modules', '')
23
- .replace('/vanilla-jet', '')
24
- .replace('/.grunt', '');
25
- //console.log('cwd: ', newCwd);
26
- return newCwd;
27
- }
28
-
29
- // -- Vars
30
- const cssDestination = `${getCwd()}/public/styles/app.min.css`;
31
- const cssOrigin = `${getCwd()}/assets/styles/less/admin_build.less`;
32
- const jsDestination = `${getCwd()}/public/`;
33
-
34
- // -- Init
35
- grunt.initConfig({
36
- clean: {
37
- build: [`${getCwd()}/public/scripts/vanilla.min.js`],
38
- minified: [
39
- `${getCwd()}/public/scripts/api`,
40
- `${getCwd()}/public/scripts/controllers`,
41
- `${getCwd()}/public/scripts/views`,
42
- `${getCwd()}/public/scripts/app.min.js`
43
- ],
44
- //minified: ['public/scripts/**/*.min.js', 'public/scripts/*', '!public/scripts/vanilla.min.js']
45
- },
46
- less: {
47
- development: {
48
- options: {
49
- compress: true,
50
- yuicompress: true,
51
- optimization: 2,
52
- strictImports: true
53
- },
54
- files: {
55
- [cssDestination] : cssOrigin
56
- },
57
- }
58
- },
59
- watch: {
60
- options: {
61
- livereload: true
62
- },
63
- styles: {
64
- files: [
65
- `${getCwd()}/assets/styles/less/*.less`,
66
- `${getCwd()}/assets/styles/less/**/*.less`,
67
- `${getCwd()}/assets/styles/less/**/**/*.less`,
68
- `${getCwd()}/!assets/styles/less/admin_build.less`
69
- ],
70
- tasks: ['buildLess'],
71
- options: {
72
- nospawn: true
73
- }
74
- },
75
- scripts: {
76
- files: [
77
- `${getCwd()}/assets/pages/*.html`,
78
- `${getCwd()}/assets/templates/**/*.html`,
79
- `${getCwd()}/assets/templates/**/**/*.html`,
80
- `${getCwd()}/external/view/*.js`,
81
- `${getCwd()}/external/*.js`,
82
- `${getCwd()}/framework/*.js`
83
- ],
84
- tasks: ['shell:compileTemplates']
85
- },
86
- specificScripts: {
87
- files: [
88
- `${getCwd()}/assets/scripts/*.js`,
89
- `${getCwd()}/assets/scripts/**/*.js`,
90
- `${getCwd()}/assets/scripts/**/**/*.js`
91
- ],
92
- tasks: ['uglify', 'cleanForce:build', 'concat', 'cleanForce:minified']
93
- }
94
- },
95
- uglify: {
96
- build: {
97
- options: {
98
- sourceMap: false,
99
- compress: {
100
- drop_console: false,
101
- sequences: true,
102
- dead_code: true,
103
- conditionals: true,
104
- booleans: true,
105
- unused: true,
106
- if_return: true,
107
- join_vars: true
108
- },
109
- output: {
110
- ascii_only: true
111
- }
112
- },
113
- files: [{
114
- expand: true,
115
- src: [
116
- `${getCwd()}/assets/scripts/*.js`,
117
- `${getCwd()}/assets/scripts/**/*.js`,
118
- `${getCwd()}/assets/scripts/**/**/*.js`,
119
- `${getCwd()}/assets/scripts/**/**/**/*.js`
120
- ],
121
- dest: getCwd() + '/public',
122
- rename : function (dest, src) {
123
-
124
- var folder = src.substring(0, src.lastIndexOf('/')),
125
- filename = src.substring(src.lastIndexOf('/'), src.length);
126
- filename = filename.substring(0, filename.lastIndexOf('.'));
127
- folder = folder.replaceAll('assets/', 'public/');
128
- let file = folder + filename + '.min.js';
129
- //console.log('file: ', file);
130
- return file;
131
- }
132
- }]
133
- }
134
- },
135
- concat: {
136
- build: {
137
- src: [
138
- // Order
139
- `${getCwd()}/public/scripts/controllers/**/*.min.js`,
140
- `${getCwd()}/public/scripts/views/**/*.min.js`,
141
- `${getCwd()}/public/scripts/api/**/*.min.js`,
142
- `${getCwd()}/public/scripts/*.min.js`,
143
-
144
- // Ignore files
145
- `!${getCwd()}/public/scripts/core/**`,
146
- `!${getCwd()}/public/scripts/plugins/**`,
147
- `!${getCwd()}/public/scripts/plugins/ui/**`
148
- ],
149
- dest: `${getCwd()}/public/scripts/vanilla.min.js`
150
- }
151
- },
152
- compress: {
153
- main: {
154
- options: {
155
- mode: 'gzip',
156
- compressionLevel: 9
157
- },
158
- files: [{
159
- expand: true,
160
- src: [`${getCwd()}/public/scripts/vanilla.min.js`, `${getCwd()}/public/styles/app.min.css`],
161
- dest: '',
162
- rename: function(dest, src) {
163
- return src + '.gz';
164
- }
165
- }]
166
- }
167
- },
168
- shell: {
169
- compileTemplates: {
170
- command: 'node .grunt/compile_html.js <%= grunt.option("env") %>'
171
- }
172
- }
173
- });
174
-
175
- grunt.registerTask('cleanForce', function(target) {
176
- grunt.option('force', true);
177
- grunt.task.run('clean:' + target);
178
- });
179
- grunt.registerTask('default', ['buildLess', 'uglify', 'cleanForce:build', 'concat', 'cleanForce:minified', 'shell:compileTemplates', 'compress', 'watch']);
180
- grunt.registerTask('build', ['buildLess', 'uglify', 'cleanForce:build', 'concat', 'cleanForce:minified', 'shell:compileTemplates', 'compress']);
181
- grunt.registerTask('server', ['buildLess']);
182
- };
File without changes