vanilla-jet 1.0.30 → 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/.grunt/compile_html.js +3 -1
- 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/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
|
};
|