vanilla-jet 1.0.29 → 1.0.31
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.
- package/.github/workflows/deploy.yml +1 -2
- package/.grunt/compile_html.js +3 -1
- package/Gruntfile.js +37 -37
- package/bin.js +5 -4
- package/framework/functions.js +95 -98
- package/framework/router.js +1 -1
- package/framework/server.js +4 -2
- package/index.js +1 -11
- package/package.json +1 -1
package/.grunt/compile_html.js
CHANGED
|
@@ -89,6 +89,8 @@ function main() {
|
|
|
89
89
|
const newHtml = lines.join('\n');
|
|
90
90
|
// -- Create HTML file
|
|
91
91
|
createHTMLFile(newHtml, homePageName);
|
|
92
|
+
// -- Console finish
|
|
93
|
+
console.log("VanillaJet - Finish build");
|
|
92
94
|
}
|
|
93
95
|
});
|
|
94
96
|
}
|
|
@@ -201,7 +203,7 @@ async function createHTMLFile(content, filePath) {
|
|
|
201
203
|
fs.mkdirSync(publicPath, { recursive: true });
|
|
202
204
|
const absolutePath = path.join(publicPath, filePath);
|
|
203
205
|
fs.writeFileSync(absolutePath, minified, 'utf8');
|
|
204
|
-
console.log(`Html :) file created at: ${absolutePath}`);
|
|
206
|
+
//console.log(`Html :) file created at: ${absolutePath}`);
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
// -- Helpers
|
package/Gruntfile.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = function(grunt) {
|
|
|
16
16
|
require('./.grunt/build_styles_task')(grunt);
|
|
17
17
|
|
|
18
18
|
// -- Functions
|
|
19
|
-
function
|
|
19
|
+
function getCwd() {
|
|
20
20
|
const cwd = process.cwd();
|
|
21
21
|
let newCwd = cwd
|
|
22
22
|
.replace('/node_modules', '')
|
|
@@ -28,19 +28,19 @@ module.exports = function(grunt) {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
// -- Vars
|
|
31
|
-
const cssDestination = `${
|
|
32
|
-
const cssOrigin = `${
|
|
33
|
-
const jsDestination = `${
|
|
31
|
+
const cssDestination = `${getCwd()}/public/styles/app.min.css`;
|
|
32
|
+
const cssOrigin = `${getCwd()}/assets/styles/less/admin_build.less`;
|
|
33
|
+
const jsDestination = `${getCwd()}/public/`;
|
|
34
34
|
|
|
35
35
|
// -- Init
|
|
36
36
|
grunt.initConfig({
|
|
37
37
|
clean: {
|
|
38
|
-
build: [`${
|
|
38
|
+
build: [`${getCwd()}/public/scripts/vanilla.min.js`],
|
|
39
39
|
minified: [
|
|
40
|
-
`${
|
|
41
|
-
`${
|
|
42
|
-
`${
|
|
43
|
-
`${
|
|
40
|
+
`${getCwd()}/public/scripts/api`,
|
|
41
|
+
`${getCwd()}/public/scripts/controllers`,
|
|
42
|
+
`${getCwd()}/public/scripts/views`,
|
|
43
|
+
`${getCwd()}/public/scripts/app.min.js`
|
|
44
44
|
],
|
|
45
45
|
//minified: ['public/scripts/**/*.min.js', 'public/scripts/*', '!public/scripts/vanilla.min.js']
|
|
46
46
|
},
|
|
@@ -63,10 +63,10 @@ module.exports = function(grunt) {
|
|
|
63
63
|
},
|
|
64
64
|
styles: {
|
|
65
65
|
files: [
|
|
66
|
-
`${
|
|
67
|
-
`${
|
|
68
|
-
`${
|
|
69
|
-
`${
|
|
66
|
+
`${getCwd()}/assets/styles/less/*.less`,
|
|
67
|
+
`${getCwd()}/assets/styles/less/**/*.less`,
|
|
68
|
+
`${getCwd()}/assets/styles/less/**/**/*.less`,
|
|
69
|
+
`${getCwd()}/!assets/styles/less/admin_build.less`
|
|
70
70
|
],
|
|
71
71
|
tasks: ['buildLess'],
|
|
72
72
|
options: {
|
|
@@ -75,22 +75,22 @@ module.exports = function(grunt) {
|
|
|
75
75
|
},
|
|
76
76
|
scripts: {
|
|
77
77
|
files: [
|
|
78
|
-
`${
|
|
79
|
-
`${
|
|
80
|
-
`${
|
|
81
|
-
`${
|
|
82
|
-
`${
|
|
83
|
-
`${
|
|
78
|
+
`${getCwd()}/assets/pages/*.html`,
|
|
79
|
+
`${getCwd()}/assets/templates/**/*.html`,
|
|
80
|
+
`${getCwd()}/assets/templates/**/**/*.html`,
|
|
81
|
+
`${getCwd()}/external/view/*.js`,
|
|
82
|
+
`${getCwd()}/external/*.js`,
|
|
83
|
+
`${getCwd()}/framework/*.js`
|
|
84
84
|
],
|
|
85
85
|
tasks: ['shell:compileTemplates']
|
|
86
86
|
},
|
|
87
87
|
specificScripts: {
|
|
88
88
|
files: [
|
|
89
|
-
`${
|
|
90
|
-
`${
|
|
91
|
-
`${
|
|
89
|
+
`${getCwd()}/assets/scripts/*.js`,
|
|
90
|
+
`${getCwd()}/assets/scripts/**/*.js`,
|
|
91
|
+
`${getCwd()}/assets/scripts/**/**/*.js`
|
|
92
92
|
],
|
|
93
|
-
tasks: ['uglify', '
|
|
93
|
+
tasks: ['uglify', 'cleanForce:build', 'concat', 'cleanForce:minified']
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
uglify: {
|
|
@@ -114,12 +114,12 @@ module.exports = function(grunt) {
|
|
|
114
114
|
files: [{
|
|
115
115
|
expand: true,
|
|
116
116
|
src: [
|
|
117
|
-
`${
|
|
118
|
-
`${
|
|
119
|
-
`${
|
|
120
|
-
`${
|
|
117
|
+
`${getCwd()}/assets/scripts/*.js`,
|
|
118
|
+
`${getCwd()}/assets/scripts/**/*.js`,
|
|
119
|
+
`${getCwd()}/assets/scripts/**/**/*.js`,
|
|
120
|
+
`${getCwd()}/assets/scripts/**/**/**/*.js`
|
|
121
121
|
],
|
|
122
|
-
dest:
|
|
122
|
+
dest: getCwd() + '/public',
|
|
123
123
|
rename : function (dest, src) {
|
|
124
124
|
|
|
125
125
|
var folder = src.substring(0, src.lastIndexOf('/')),
|
|
@@ -137,17 +137,17 @@ module.exports = function(grunt) {
|
|
|
137
137
|
build: {
|
|
138
138
|
src: [
|
|
139
139
|
// Order
|
|
140
|
-
`${
|
|
141
|
-
`${
|
|
142
|
-
`${
|
|
143
|
-
`${
|
|
140
|
+
`${getCwd()}/public/scripts/controllers/**/*.min.js`,
|
|
141
|
+
`${getCwd()}/public/scripts/views/**/*.min.js`,
|
|
142
|
+
`${getCwd()}/public/scripts/api/**/*.min.js`,
|
|
143
|
+
`${getCwd()}/public/scripts/*.min.js`,
|
|
144
144
|
|
|
145
145
|
// Ignore files
|
|
146
|
-
`!${
|
|
147
|
-
`!${
|
|
148
|
-
`!${
|
|
146
|
+
`!${getCwd()}/public/scripts/core/**`,
|
|
147
|
+
`!${getCwd()}/public/scripts/plugins/**`,
|
|
148
|
+
`!${getCwd()}/public/scripts/plugins/ui/**`
|
|
149
149
|
],
|
|
150
|
-
dest: `${
|
|
150
|
+
dest: `${getCwd()}/public/scripts/vanilla.min.js`
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
153
|
compress: {
|
|
@@ -157,7 +157,7 @@ module.exports = function(grunt) {
|
|
|
157
157
|
},
|
|
158
158
|
files: [{
|
|
159
159
|
expand: true,
|
|
160
|
-
src: [`${
|
|
160
|
+
src: [`${getCwd()}/public/scripts/vanilla.min.js`],
|
|
161
161
|
dest: '',
|
|
162
162
|
ext: '.min.js.gz'
|
|
163
163
|
}]
|
package/bin.js
CHANGED
|
@@ -6,6 +6,7 @@ const { execSync } = require('child_process');
|
|
|
6
6
|
|
|
7
7
|
const generatePackagesJson = require(path.join(__dirname, './.scripts/generate_packages_json.js'));
|
|
8
8
|
|
|
9
|
+
console.log(args[0]);
|
|
9
10
|
switch (args[0]) {
|
|
10
11
|
|
|
11
12
|
case 'setup':
|
|
@@ -20,17 +21,17 @@ switch (args[0]) {
|
|
|
20
21
|
}
|
|
21
22
|
break;
|
|
22
23
|
|
|
23
|
-
case 'qa':
|
|
24
|
+
case 'build:qa':
|
|
24
25
|
try {
|
|
25
|
-
execSync('grunt --env=qa', { stdio: 'inherit', cwd: __dirname });
|
|
26
|
+
execSync('grunt build --env=qa', { stdio: 'inherit', cwd: __dirname });
|
|
26
27
|
} catch (error) {
|
|
27
28
|
console.error('Error ejecutando grunt:', error.message);
|
|
28
29
|
}
|
|
29
30
|
break;
|
|
30
31
|
|
|
31
|
-
case 'prod':
|
|
32
|
+
case 'build:prod':
|
|
32
33
|
try {
|
|
33
|
-
execSync('grunt --env=production', { stdio: 'inherit', cwd: __dirname });
|
|
34
|
+
execSync('grunt build --env=production', { stdio: 'inherit', cwd: __dirname });
|
|
34
35
|
} catch (error) {
|
|
35
36
|
console.error('Error ejecutando grunt:', error.message);
|
|
36
37
|
}
|
package/framework/functions.js
CHANGED
|
@@ -1,103 +1,100 @@
|
|
|
1
1
|
class Functions {
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
dipper.addMeta('og:url', dipper.urlTo(''), 'property');
|
|
99
|
-
dipper.addMeta('theme-color', '#ffffff', '');
|
|
100
|
-
}
|
|
3
|
+
constructor() {
|
|
4
|
+
|
|
5
|
+
// Dipper
|
|
6
|
+
dipper = global.dipper;
|
|
7
|
+
|
|
8
|
+
// -- Hydrate
|
|
9
|
+
Functions.hydrate(dipper);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static hydrate(dipper) {
|
|
13
|
+
|
|
14
|
+
// -- Get vanillaJet.package.json
|
|
15
|
+
let json = dipper.openJsonFile('vanillaJet.package.json');
|
|
16
|
+
|
|
17
|
+
// -- Google Fonts
|
|
18
|
+
if (json.fonts && json.fonts.length > 0) {
|
|
19
|
+
dipper.registerStyle('google-fonts', dipper.get_google_fonts(json.fonts));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// - Styles
|
|
23
|
+
let stylesKeys = [];
|
|
24
|
+
if (json.styles) {
|
|
25
|
+
|
|
26
|
+
// -- Gettign the keys
|
|
27
|
+
stylesKeys = Object.keys(json.styles);
|
|
28
|
+
|
|
29
|
+
// -- Add google-fonts to keys
|
|
30
|
+
stylesKeys.push('google-fonts');
|
|
31
|
+
|
|
32
|
+
// -- Adding styles
|
|
33
|
+
for (let key in json.styles) {
|
|
34
|
+
// -- Check if init with http or https
|
|
35
|
+
let url = json.styles[key];
|
|
36
|
+
if (!/^(https?:\/\/|\/\/)/.test(url)) {
|
|
37
|
+
dipper.registerStyle(key, dipper.style(url));
|
|
38
|
+
} else {
|
|
39
|
+
dipper.registerStyle(key, url);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
dipper.registerStyle('app', dipper.style('app.min.css'), stylesKeys);
|
|
44
|
+
dipper.enqueueStyle('app');
|
|
45
|
+
|
|
46
|
+
// -- Scripts
|
|
47
|
+
let scriptsKeys = [];
|
|
48
|
+
if (json.dependencies) {
|
|
49
|
+
|
|
50
|
+
// -- Adding scripts
|
|
51
|
+
for (let key in json.dependencies) {
|
|
52
|
+
|
|
53
|
+
// -- Key name and requires
|
|
54
|
+
let keyParts = key.split(':');
|
|
55
|
+
let keyName = keyParts[0];
|
|
56
|
+
let keyRequires = keyParts[1] || '';
|
|
57
|
+
|
|
58
|
+
// -- Add key to scriptsKeys
|
|
59
|
+
scriptsKeys.push(keyName);
|
|
60
|
+
|
|
61
|
+
// -- Check if init with http or https
|
|
62
|
+
let url = json.dependencies[key];
|
|
63
|
+
if (!/^(https?:\/\/|\/\/)/.test(url)) {
|
|
64
|
+
dipper.registerScript(
|
|
65
|
+
keyName,
|
|
66
|
+
dipper.script(url),
|
|
67
|
+
(keyRequires !== '') ? [keyRequires] : undefined
|
|
68
|
+
);
|
|
69
|
+
} else {
|
|
70
|
+
dipper.registerScript(
|
|
71
|
+
keyName,
|
|
72
|
+
url,
|
|
73
|
+
(keyRequires !== '') ? [keyRequires] : undefined
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
scriptsKeys.push('jquery');
|
|
79
|
+
scriptsKeys.push('underscore');
|
|
80
|
+
dipper.registerScript('vanillaJet', dipper.script('core/vanillaJet.js'), scriptsKeys);
|
|
81
|
+
dipper.enqueueScript('vanillaJet');
|
|
82
|
+
|
|
83
|
+
// -- Main app
|
|
84
|
+
dipper.registerScript('vanilla', dipper.script('vanilla.js'));
|
|
85
|
+
dipper.enqueueScript('vanilla');
|
|
86
|
+
|
|
87
|
+
// Adding meta tags
|
|
88
|
+
dipper.addMeta('UTF-8', '', 'charset');
|
|
89
|
+
dipper.addMeta('viewport', 'width=device-width, minimum-scale=1');
|
|
90
|
+
dipper.addMeta('og:title', dipper.getPageTitle(), 'property');
|
|
91
|
+
dipper.addMeta('og:site_name', dipper.getSiteTitle(), 'property');
|
|
92
|
+
dipper.addMeta('og:description', dipper.getDescription(), 'property');
|
|
93
|
+
dipper.addMeta('og:image', dipper.img('logo.png'), 'property');
|
|
94
|
+
dipper.addMeta('og:type', 'website', 'property');
|
|
95
|
+
dipper.addMeta('og:url', dipper.urlTo(''), 'property');
|
|
96
|
+
dipper.addMeta('theme-color', '#ffffff', '');
|
|
97
|
+
}
|
|
101
98
|
}
|
|
102
99
|
|
|
103
100
|
module.exports = Functions;
|
package/framework/router.js
CHANGED
package/framework/server.js
CHANGED
|
@@ -18,6 +18,7 @@ class Server {
|
|
|
18
18
|
this.router = null;
|
|
19
19
|
this.functions = null;
|
|
20
20
|
this.dipper = null;
|
|
21
|
+
this.endpoints = {};
|
|
21
22
|
this.init(options, endpoints);
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -82,9 +83,10 @@ class Server {
|
|
|
82
83
|
for (let endpoint of endpoints) {
|
|
83
84
|
endpoints_built[endpoint.name] = new endpoint(obj.router);
|
|
84
85
|
}
|
|
86
|
+
this.endpoints = endpoints_built;
|
|
85
87
|
|
|
86
88
|
// Setting endpoints
|
|
87
|
-
obj.functions = new Functions(
|
|
89
|
+
obj.functions = new Functions();
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
start() {
|
|
@@ -96,7 +98,7 @@ class Server {
|
|
|
96
98
|
obj.httpx.listen(port);
|
|
97
99
|
|
|
98
100
|
// Logging
|
|
99
|
-
obj.log('__________________
|
|
101
|
+
obj.log('__________________ VanillaJet server started ___________________');
|
|
100
102
|
obj.log(` > Listening on ${obj.options.site_url}:${obj.options.port}${obj.options.base_url} < `);
|
|
101
103
|
obj.log('-----------------------------------------------------------------');
|
|
102
104
|
}
|
package/index.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
const Dipper = require('./framework/dipper.js');
|
|
2
|
-
const Request = require('./framework/request.js');
|
|
3
|
-
const Response = require('./framework/response.js');
|
|
4
|
-
const Router = require('./framework/router.js');
|
|
5
1
|
const Server = require('./framework/server.js');
|
|
6
|
-
const Functions = require('./framework/functions.js');
|
|
7
2
|
|
|
8
3
|
module.exports = {
|
|
9
|
-
|
|
10
|
-
Request,
|
|
11
|
-
Response,
|
|
12
|
-
Router,
|
|
13
|
-
Server,
|
|
14
|
-
Functions
|
|
4
|
+
Server
|
|
15
5
|
};
|