autofront 2.1.1 → 2.2.1

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.
Files changed (3) hide show
  1. package/README.md +1 -2
  2. package/index.js +148 -149
  3. package/package.json +66 -63
package/README.md CHANGED
@@ -113,7 +113,7 @@ One of modules should to be named "app", ideally the main one.
113
113
  Optionally, to work with [HTML5 mode](https://docs.angularjs.org/api/ng/provider/$locationProvider#html5Mode), invoke it:
114
114
 
115
115
  ```js
116
- var autofront = require('autofront');
116
+ let autofront = require('autofront');
117
117
  autofront.html5Mode();
118
118
  ```
119
119
 
@@ -125,7 +125,6 @@ Any asset (e.g. a PDF document) will keep the location path and, particularly at
125
125
 
126
126
  Fixes and improvements to do:
127
127
 
128
- * Avoid process-breaking Sass errors, like Less rightly does.
129
128
  * Once the server watch for changes:
130
129
  * Synchronize also the deletion of source files.
131
130
  * Resolve overwriting bug between pure CSS and preprocessors (Less/Sass).
package/index.js CHANGED
@@ -1,150 +1,149 @@
1
- this.html5Mode = html5Mode;
2
-
3
- const gulp = require('gulp'),
4
- path = require('path'),
5
- args = require('get-gulp-args')(),
6
- mergeStream = require('merge-stream'),
7
- mainBowerFiles = require('main-bower-files'),
8
- $ = require('gulp-load-plugins')(),
9
- injStr = $.injectString,
10
- gulpSass = $.sass(require('sass')),
11
- notifyError = $.notify.onError(error => error.message),
12
- browserSync = require('browser-sync').create();
13
-
14
- var domain = undefined;
15
-
16
- const allFiles = getFiles(),
17
- indexHtmlFile = 'index.html',
18
- cssFilename = 'index',
19
- cssFullFilename = cssFilename + '.css';
20
- var stylesFolder = 'styles/',
21
- jsTemplatesFile = 'scripts/templates.js';
22
-
23
- const paths = {
24
- src: 'src/',
25
- tmp: '.tmp/',
26
- dist: 'dist/'
27
- };
28
- paths.srcIndexHtml = paths.src + indexHtmlFile;
29
- paths.srcSass = paths.src + getFiles('scss');
30
- paths.srcLess = paths.src + getFiles('less');
31
- paths.srcJs = paths.src + getFiles('js');
32
- paths.srcOthers = [paths.src + allFiles, '!' + paths.srcIndexHtml, '!' + paths.srcSass, '!' + paths.srcLess, '!' + paths.srcJs];
33
-
34
- const nl = '\n',
35
- tab = ' ';
36
-
37
- gulp.task('check', () => {
38
- const pckg = require(path.resolve('package.json')),
39
- domains = pckg.domains;
40
- var domainIndex = args[0] || 'local';
41
- if (domains) {
42
- const domainAliases = pckg.domainAliases;
43
- if (domainAliases) {
44
- const alias = domainAliases[domainIndex];
45
- if (alias)
46
- domainIndex = alias;
47
- }
48
- domain = domains[domainIndex];
49
- }
50
- const isMatched = domain !== undefined;
51
- return gulp.src(paths.src)
52
- .pipe($.notify(isMatched ? 'Matching domain: "' + domainIndex + '".' : 'No domain matched.'));
53
- });
54
-
55
- gulp.task('del', () => delFolder(paths.tmp));
56
- gulp.task('index-build', () => gulp.src(paths.srcIndexHtml).pipe(injStr.after('<!-- endbuild -->', nl + tab + '<link rel="stylesheet" href="' + stylesFolder + cssFullFilename + '">')).pipe($.inject(gulp.src(paths.srcJs).pipe($.angularFilesort()), { relative: true })).on('error', notifyError).pipe($.wiredep()).pipe($.useref()).pipe(gulp.dest(paths.tmp)));
57
- gulp.task('index-domain', () => gulp.src(paths.tmp + getFiles('js')).pipe(injStr.replace('{{AUTOFRONT_DOMAIN}}', domain)).pipe(gulp.dest(paths.tmp)));
58
- gulp.task('index', gulp.series('index-build', 'index-domain'));
59
- gulp.task('styles', () => {
60
- return mergeStream(getCssStream('scss', gulpSass, '@import "variables";'), getCssStream('less', $.less))
61
- .pipe($.concat(cssFullFilename))
62
- .pipe(gulp.dest(paths.tmp + stylesFolder))
63
- .pipe(browserSync.stream());
64
-
65
- function getCssStream(ext, process, extraCode) {
66
- return gulp.src(paths.src + stylesFolder + cssFilename + '.' + ext, { allowEmpty: true }).pipe(injStr.prepend((extraCode ? extraCode + nl : '') + '// bower:' + ext + nl + '// endbower' + nl)).pipe($.wiredep()).pipe(process()).on('error', notifyError);
67
- }
68
- });
69
- gulp.task('fonts', () => gulp.src(mainBowerFiles()).pipe(filter(['eot', 'otf', 'svg', 'ttf', 'woff', 'woff2'], true)).pipe(gulp.dest(paths.tmp + 'fonts/')));
70
- gulp.task('others', () => {
71
- const pugFilter = filter('pug');
72
- return gulp.src(paths.srcOthers)
73
- .pipe(pugFilter).pipe($.pug()).on('error', notifyError).pipe(pugFilter.restore)
74
- .pipe(gulp.dest(paths.tmp));
75
- });
76
- gulp.task('about', () => gulp.src('package.json').pipe($.about()).pipe(gulp.dest(paths.tmp)));
77
- gulp.task('build:tmp', gulp.series('del', 'check', gulp.parallel('index', 'styles', 'fonts', 'others', 'about')));
78
- gulp.task('browser', gulp.series('build:tmp', (cb) => {
79
- browserSyncInit(paths.tmp);
80
- cb();
81
- }));
82
- gulp.task('serve', gulp.series('browser', () => {
83
- gulp.watch([paths.srcIndexHtml, paths.srcJs], gulp.task('index'));
84
- gulp.watch([paths.srcSass, paths.srcLess], gulp.task('styles'));
85
- gulp.watch(paths.srcOthers, gulp.task('others'));
86
- gulp.watch([paths.tmp + allFiles, '!' + paths.tmp + stylesFolder + cssFullFilename], function (cb) {
87
- browserSync.reload();
88
- cb();
89
- });
90
- }));
91
-
92
- gulp.task('del:dist', () => delFolder(paths.dist));
93
- gulp.task('copy', gulp.series('del:dist', () => gulp.src(paths.tmp + allFiles).pipe(gulp.dest(paths.dist))));
94
- gulp.task('templates-build', () => gulp.src([paths.dist + getFiles('html'), '!' + paths.dist + indexHtmlFile]).pipe($.cleanDest(paths.dist)).pipe(minifyHtml()).pipe($.angularTemplatecache(jsTemplatesFile, { module: 'app', transformUrl: function (url) { return url.slice(1); } })).pipe(gulp.dest(paths.dist)));
95
- gulp.task('templates-clean', () => require('delete-empty')(paths.dist));
96
- gulp.task('templates', gulp.series('templates-build', 'templates-clean'));
97
- gulp.task('build', gulp.series('build:tmp', 'copy', 'templates', () => {
98
- const indexHtmlFilter = filter('html'),
99
- cssFilter = filter('css'),
100
- jsFilter = filter('js'),
101
- cssAndJsFilter = filter(['css', 'js']),
102
- imgFilter = filter(['png', 'jpg', 'gif', 'svg']),
103
- jsonFilter = filter('json');
104
- return gulp.src(paths.dist + allFiles)
105
- .pipe(indexHtmlFilter).pipe(injStr.before('</body>', '<script src="' + jsTemplatesFile + '"></script>' + nl)).pipe(minifyHtml()).pipe(indexHtmlFilter.restore)
106
- .pipe(cssFilter).pipe($.cssnano({ zindex: false })).pipe(cssFilter.restore)
107
- .pipe(jsFilter).pipe($.ngAnnotate()).pipe($.terser()).pipe(jsFilter.restore)
108
- .pipe(cssAndJsFilter).pipe($.rev()).pipe($.revDeleteOriginal()).pipe(cssAndJsFilter.restore)
109
- .pipe($.revReplace())
110
- .pipe(imgFilter).pipe($.imagemin()).pipe(imgFilter.restore)
111
- .pipe(jsonFilter).pipe($.jsonmin()).pipe(jsonFilter.restore)
112
- .pipe($.size({ showFiles: true }))
113
- .pipe(gulp.dest(paths.dist));
114
- }));
115
- gulp.task('serve:dist', gulp.series('build', () => browserSyncInit(paths.dist)));
116
-
117
- gulp.task('default', gulp.task('serve'));
118
-
119
- function html5Mode() {
120
- const pathPrefix = '/';
121
- stylesFolder = pathPrefix + stylesFolder;
122
- jsTemplatesFile = pathPrefix + jsTemplatesFile;
123
- }
124
-
125
- function getFiles(ext) {
126
- ext = ext || '*';
127
- const isArray = typeof ext != 'string';
128
- return '**/*.' + (isArray ? '{' : '') + (isArray ? ext.join() : ext) + (isArray ? '}' : '');
129
- }
130
-
131
- function delFolder(path) {
132
- return gulp.src(path, { allowEmpty: true, read: false })
133
- .pipe($.clean());
134
- }
135
-
136
- function filter(ext, isUnrestored) {
137
- return $.filter(getFiles(ext), { restore: !isUnrestored });
138
- }
139
-
140
- function browserSyncInit(path) {
141
- browserSync.init({
142
- server: {
143
- baseDir: path
144
- }
145
- });
146
- }
147
-
148
- function minifyHtml() {
149
- return $.htmlmin({ collapseWhitespace: true, conservativeCollapse: true });
1
+ this.html5Mode = html5Mode;
2
+
3
+ const gulp = require('gulp'),
4
+ path = require('path'),
5
+ args = require('get-gulp-args')(),
6
+ mergeStream = require('merge-stream'),
7
+ mainBowerFiles = require('main-bower-files'),
8
+ $ = require('gulp-load-plugins')(),
9
+ injStr = $.injectString,
10
+ gulpSass = $.sass(require('sass')),
11
+ notifyError = $.notify.onError(error => error.message),
12
+ browserSync = require('browser-sync').create();
13
+
14
+ let domain = undefined;
15
+
16
+ const allFiles = getFiles(),
17
+ indexHtmlFile = 'index.html',
18
+ cssFilename = 'index',
19
+ cssFullFilename = cssFilename + '.css';
20
+ let stylesFolder = 'styles/',
21
+ jsTemplatesFile = 'scripts/templates.js';
22
+
23
+ const paths = {
24
+ src: 'src/',
25
+ tmp: '.tmp/',
26
+ dist: 'dist/'
27
+ };
28
+ paths.srcIndexHtml = paths.src + indexHtmlFile;
29
+ paths.srcSass = paths.src + getFiles('scss');
30
+ paths.srcLess = paths.src + getFiles('less');
31
+ paths.srcJs = paths.src + getFiles('js');
32
+ paths.srcOthers = [paths.src + allFiles, '!' + paths.srcIndexHtml, '!' + paths.srcSass, '!' + paths.srcLess, '!' + paths.srcJs];
33
+
34
+ const nl = '\n',
35
+ tab = ' ';
36
+
37
+ gulp.task('check', () => {
38
+ const pckg = require(path.resolve('package.json')),
39
+ domains = pckg.domains;
40
+ let domainIndex = args[0] || 'local';
41
+ if (domains) {
42
+ const domainAliases = pckg.domainAliases;
43
+ if (domainAliases) {
44
+ const alias = domainAliases[domainIndex];
45
+ if (alias)
46
+ domainIndex = alias;
47
+ }
48
+ domain = domains[domainIndex];
49
+ }
50
+ const isMatched = domain !== undefined;
51
+ return gulp.src(paths.src)
52
+ .pipe($.notify(isMatched ? `Matching domain: "${domainIndex}".` : 'No domain matched.'));
53
+ });
54
+
55
+ gulp.task('del', () => delFolder(paths.tmp));
56
+ gulp.task('index-build', () => gulp.src(paths.srcIndexHtml).pipe(injStr.after('<!-- endbuild -->', nl + tab + `<link rel="stylesheet" href="${stylesFolder}${cssFullFilename}">`)).pipe($.inject(gulp.src(paths.srcJs).pipe($.angularFilesort()), { relative: true })).on('error', notifyError).pipe($.wiredep()).pipe($.useref()).pipe(gulp.dest(paths.tmp)));
57
+ gulp.task('index-domain', () => gulp.src(paths.tmp + getFiles('js')).pipe(injStr.replace('{{AUTOFRONT_DOMAIN}}', domain)).pipe(gulp.dest(paths.tmp)));
58
+ gulp.task('index', gulp.series('index-build', 'index-domain'));
59
+ gulp.task('styles', () => {
60
+ return mergeStream(getCssStream('scss', gulpSass, '@import "variables";'), getCssStream('less', $.less))
61
+ .pipe($.concat(cssFullFilename))
62
+ .pipe(gulp.dest(paths.tmp + stylesFolder))
63
+ .pipe(browserSync.stream());
64
+
65
+ function getCssStream(ext, process, extraCode) {
66
+ return gulp.src(paths.src + stylesFolder + cssFilename + '.' + ext, { allowEmpty: true }).pipe(injStr.prepend((extraCode ? extraCode + nl : '') + '// bower:' + ext + nl + '// endbower' + nl)).pipe($.wiredep()).pipe(process()).on('error', notifyError);
67
+ }
68
+ });
69
+ gulp.task('fonts', () => gulp.src(mainBowerFiles()).pipe(filter(['eot', 'otf', 'svg', 'ttf', 'woff', 'woff2'], true)).pipe(gulp.dest(paths.tmp + 'fonts/')));
70
+ gulp.task('others', () => {
71
+ const pugFilter = filter('pug');
72
+ return gulp.src(paths.srcOthers)
73
+ .pipe(pugFilter).pipe($.pug()).on('error', notifyError).pipe(pugFilter.restore)
74
+ .pipe(gulp.dest(paths.tmp));
75
+ });
76
+ gulp.task('about', () => gulp.src('package.json').pipe($.about()).pipe(gulp.dest(paths.tmp)));
77
+ gulp.task('build:tmp', gulp.series('del', 'check', gulp.parallel('index', 'styles', 'fonts', 'others', 'about')));
78
+ gulp.task('browser', gulp.series('build:tmp', (cb) => {
79
+ browserSyncInit(paths.tmp);
80
+ cb();
81
+ }));
82
+ gulp.task('serve', gulp.series('browser', () => {
83
+ gulp.watch([paths.srcIndexHtml, paths.srcJs], gulp.task('index'));
84
+ gulp.watch([paths.srcSass, paths.srcLess], gulp.task('styles'));
85
+ gulp.watch(paths.srcOthers, gulp.task('others'));
86
+ gulp.watch([paths.tmp + allFiles, '!' + paths.tmp + stylesFolder + cssFullFilename], function (cb) {
87
+ browserSync.reload();
88
+ cb();
89
+ });
90
+ }));
91
+
92
+ gulp.task('del:dist', () => delFolder(paths.dist));
93
+ gulp.task('copy', gulp.series('del:dist', () => gulp.src(paths.tmp + allFiles).pipe(gulp.dest(paths.dist))));
94
+ gulp.task('templates-build', () => gulp.src([paths.dist + getFiles('html'), '!' + paths.dist + indexHtmlFile]).pipe($.cleanDest(paths.dist)).pipe(minifyHtml()).pipe($.angularTemplatecache(jsTemplatesFile, { module: 'app', transformUrl: function (url) { return url.slice(1); } })).pipe(gulp.dest(paths.dist)));
95
+ gulp.task('templates-clean', () => require('delete-empty')(paths.dist));
96
+ gulp.task('templates', gulp.series('templates-build', 'templates-clean'));
97
+ gulp.task('build', gulp.series('build:tmp', 'copy', 'templates', () => {
98
+ const indexHtmlFilter = filter('html'),
99
+ cssFilter = filter('css'),
100
+ jsFilter = filter('js'),
101
+ cssAndJsFilter = filter(['css', 'js']),
102
+ imgFilter = filter(['png', 'jpg', 'gif', 'svg']),
103
+ jsonFilter = filter('json');
104
+ return gulp.src(paths.dist + allFiles)
105
+ .pipe(indexHtmlFilter).pipe(injStr.before('</body>', `<script src="${jsTemplatesFile}"></script>` + nl)).pipe(minifyHtml()).pipe(indexHtmlFilter.restore)
106
+ .pipe(cssFilter).pipe($.cssnano({ zindex: false })).pipe(cssFilter.restore)
107
+ .pipe(jsFilter).pipe($.ngAnnotate()).pipe($.terser()).pipe(jsFilter.restore)
108
+ .pipe(cssAndJsFilter).pipe($.rev()).pipe($.revDeleteOriginal()).pipe(cssAndJsFilter.restore)
109
+ .pipe($.revReplace())
110
+ .pipe(imgFilter).pipe($.imagemin()).pipe(imgFilter.restore)
111
+ .pipe(jsonFilter).pipe($.jsonmin()).pipe(jsonFilter.restore)
112
+ .pipe($.size({ showFiles: true }))
113
+ .pipe(gulp.dest(paths.dist));
114
+ }));
115
+ gulp.task('serve:dist', gulp.series('build', () => browserSyncInit(paths.dist)));
116
+
117
+ gulp.task('default', gulp.task('serve'));
118
+
119
+ function html5Mode() {
120
+ const pathPrefix = '/';
121
+ stylesFolder = pathPrefix + stylesFolder;
122
+ jsTemplatesFile = pathPrefix + jsTemplatesFile;
123
+ }
124
+
125
+ function getFiles(ext = '*') {
126
+ const isArray = typeof ext != 'string';
127
+ return '**/*.' + (isArray ? '{' : '') + (isArray ? ext.join() : ext) + (isArray ? '}' : '');
128
+ }
129
+
130
+ function delFolder(path) {
131
+ return gulp.src(path, { allowEmpty: true, read: false })
132
+ .pipe($.clean());
133
+ }
134
+
135
+ function filter(ext, isUnrestored) {
136
+ return $.filter(getFiles(ext), { restore: !isUnrestored });
137
+ }
138
+
139
+ function browserSyncInit(path) {
140
+ browserSync.init({
141
+ server: {
142
+ baseDir: path
143
+ }
144
+ });
145
+ }
146
+
147
+ function minifyHtml() {
148
+ return $.htmlmin({ collapseWhitespace: true, conservativeCollapse: true });
150
149
  }
package/package.json CHANGED
@@ -1,63 +1,66 @@
1
- {
2
- "name": "autofront",
3
- "version": "2.1.1",
4
- "description": "Automatisation of front-end by Gulp and Bower.",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/mvicens/autofront.git"
12
- },
13
- "keywords": [
14
- "html",
15
- "pug",
16
- "css",
17
- "less",
18
- "sass",
19
- "javascript",
20
- "angularjs"
21
- ],
22
- "author": "Miquel Alejandro Vicens Dalmau",
23
- "license": "ISC",
24
- "bugs": {
25
- "url": "https://github.com/mvicens/autofront/issues"
26
- },
27
- "homepage": "https://github.com/mvicens/autofront#readme",
28
- "dependencies": {
29
- "browser-sync": "^2.26.3",
30
- "delete-empty": "^2.0.0",
31
- "get-gulp-args": "^0.0.1",
32
- "gulp": "^4.0.2",
33
- "gulp-about": "^1.1.0",
34
- "gulp-angular-filesort": "^1.2.1",
35
- "gulp-angular-templatecache": "^2.2.3",
36
- "gulp-clean": "^0.4.0",
37
- "gulp-clean-dest": "^0.2.0",
38
- "gulp-concat": "^2.6.1",
39
- "gulp-cssnano": "^2.1.3",
40
- "gulp-filter": "^5.1.0",
41
- "gulp-htmlmin": "^4.0.0",
42
- "gulp-imagemin": "^4.1.0",
43
- "gulp-inject": "^4.3.2",
44
- "gulp-inject-string": "^1.1.1",
45
- "gulp-jsonmin": "^1.2.0",
46
- "gulp-less": "^3.5.0",
47
- "gulp-load-plugins": "^1.5.0",
48
- "gulp-ng-annotate": "^2.1.0",
49
- "gulp-notify": "^3.2.0",
50
- "gulp-pug": "^4.0.1",
51
- "gulp-rev": "^8.1.1",
52
- "gulp-rev-delete-original": "^0.2.3",
53
- "gulp-rev-replace": "^0.4.4",
54
- "gulp-sass": "^5.0.0",
55
- "gulp-size": "^3.0.0",
56
- "gulp-terser": "^1.1.7",
57
- "gulp-useref": "^3.1.6",
58
- "gulp-wiredep": "^1.2.0",
59
- "main-bower-files": "^2.13.1",
60
- "merge-stream": "^1.0.1",
61
- "sass": "^1.38.2"
62
- }
63
- }
1
+ {
2
+ "name": "autofront",
3
+ "version": "2.2.1",
4
+ "description": "Automatisation of front-end by Gulp and Bower.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "serve": "gulp",
8
+ "serve:dist": "gulp serve:dist",
9
+ "build": "gulp build",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/mvicens/autofront.git"
15
+ },
16
+ "keywords": [
17
+ "html",
18
+ "pug",
19
+ "css",
20
+ "less",
21
+ "sass",
22
+ "javascript",
23
+ "angularjs"
24
+ ],
25
+ "author": "Miquel Alejandro Vicens Dalmau",
26
+ "license": "ISC",
27
+ "bugs": {
28
+ "url": "https://github.com/mvicens/autofront/issues"
29
+ },
30
+ "homepage": "https://github.com/mvicens/autofront#readme",
31
+ "dependencies": {
32
+ "browser-sync": "^2.26.3",
33
+ "delete-empty": "^2.0.0",
34
+ "get-gulp-args": "^0.0.1",
35
+ "gulp": "^4.0.2",
36
+ "gulp-about": "^1.1.0",
37
+ "gulp-angular-filesort": "^1.2.1",
38
+ "gulp-angular-templatecache": "^2.2.3",
39
+ "gulp-clean": "^0.4.0",
40
+ "gulp-clean-dest": "^0.2.0",
41
+ "gulp-concat": "^2.6.1",
42
+ "gulp-cssnano": "^2.1.3",
43
+ "gulp-filter": "^5.1.0",
44
+ "gulp-htmlmin": "^4.0.0",
45
+ "gulp-imagemin": "^4.1.0",
46
+ "gulp-inject": "^4.3.2",
47
+ "gulp-inject-string": "^1.1.1",
48
+ "gulp-jsonmin": "^1.2.0",
49
+ "gulp-less": "^3.5.0",
50
+ "gulp-load-plugins": "^1.5.0",
51
+ "gulp-ng-annotate": "^2.1.0",
52
+ "gulp-notify": "^3.2.0",
53
+ "gulp-pug": "^4.0.1",
54
+ "gulp-rev": "^8.1.1",
55
+ "gulp-rev-delete-original": "^0.2.3",
56
+ "gulp-rev-replace": "^0.4.4",
57
+ "gulp-sass": "^5.0.0",
58
+ "gulp-size": "^3.0.0",
59
+ "gulp-terser": "^1.1.7",
60
+ "gulp-useref": "^3.1.6",
61
+ "gulp-wiredep": "^1.2.0",
62
+ "main-bower-files": "^2.13.1",
63
+ "merge-stream": "^1.0.1",
64
+ "sass": "^1.38.2"
65
+ }
66
+ }