Skip to content
This repository was archived by the owner on Dec 9, 2021. It is now read-only.

Commit cd2366c

Browse files
author
rsavian
committed
Initial troubleshooting project
1 parent 3ff5661 commit cd2366c

File tree

95 files changed

+27276
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+27276
-0
lines changed

examples/troubleshooting/.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "./src/assets/vendor"
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 4
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.json]
13+
indent_size = 2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.sh eol=lf
3+
*.cmd eol=crlf
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# don't ignore .npmignore files
2+
!.npmignore
3+
!.gitignore
4+
!build-env.js
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
const gulp = require('gulp');
2+
const requireDir = require('require-dir');
3+
const runSequence = require('run-sequence');
4+
const argv = require('yargs').argv;
5+
const gulpIf = require('gulp-if');
6+
const uglify = require('gulp-uglify');
7+
const useref = require('gulp-useref');
8+
const header = require('gulp-header');
9+
const cleanCSS = require('gulp-clean-css');
10+
const browserSync = require('browser-sync').create();
11+
12+
/**
13+
* Uncomment the next line to report the Gulp execution time (for optimization, etc)
14+
*/
15+
//require('time-require');
16+
17+
/**
18+
* Pulling in all tasks from the tasks folder
19+
*/
20+
requireDir('./tools/tasks', {
21+
recurse: true
22+
});
23+
24+
/**
25+
* Setup global variables to use across tasks
26+
*/
27+
global.pkg = require('./package.json');
28+
global.env = require('./build-env.js');
29+
30+
global.reloadBrowser = browserSync.reload;
31+
32+
/**
33+
* Determines the build mode. Default will be read from the env file but can be overridden with a flag.
34+
* Flags are: --dev , --prod
35+
*/
36+
if (argv.prod === true || argv.dev === true) {
37+
global.isProd = !!argv.prod;
38+
global.isDev = !!argv.dev;
39+
} else {
40+
global.isProd = (env.BUILD_MODE === 'prod');
41+
global.isDev = (env.BUILD_MODE === 'dev');
42+
}
43+
44+
// -- Tasks ----------------------------------------------------------------
45+
/**
46+
* Run default tasks for the target environment.
47+
*
48+
* @task default
49+
*/
50+
gulp.task('default', (done) => {
51+
runSequence(
52+
(isDev === true) ? ['lint', 'build'] :
53+
(isProd === true) ? ['build'] : [],
54+
done
55+
);
56+
});
57+
58+
/**
59+
* Compile source code and outputs to destination.
60+
*
61+
* @task build
62+
*/
63+
gulp.task('build', (done) => {
64+
const tasks = [
65+
['clean:dest'],
66+
['buildStatic', 'buildMarkup', 'buildStyles', 'buildScripts', 'buildJST']
67+
];
68+
69+
if (isProd === true) {
70+
tasks.push(['minify']);
71+
tasks.push(['clean:minify']);
72+
}
73+
74+
runSequence(...tasks, done);
75+
});
76+
77+
/**
78+
* Minify source code.
79+
*
80+
* @task minify
81+
*/
82+
gulp.task('minify', (done) => {
83+
gulp
84+
.src(env.DIR_DEST + '/*.html')
85+
.pipe(useref())
86+
.pipe(gulpIf('*.js', uglify({
87+
mangle: false,
88+
preserveComments: 'license'
89+
})))
90+
.pipe(gulpIf('*.css', cleanCSS()))
91+
.pipe(gulp.dest(env.DIR_DEST))
92+
.on('end', done);
93+
});
94+
95+
/**
96+
* Generate documentation.
97+
*
98+
* @task docs
99+
*/
100+
gulp.task('docs', (done) => {
101+
runSequence(
102+
['clean:docs'], ['buildDocs'],
103+
done
104+
);
105+
});
106+
107+
/**
108+
* Validate code syntax.
109+
*
110+
* @task lint
111+
*/
112+
gulp.task('lint', (done) => {
113+
runSequence(
114+
['lintScripts'],
115+
done
116+
);
117+
});
118+
119+
/**
120+
* Start a web server and reloads the browser file changes.
121+
*
122+
* @task watch
123+
* @options --open
124+
*/
125+
gulp.task('watch', (done) => {
126+
127+
// BrowserSync setup
128+
browserSync.init({
129+
notify: false,
130+
injectChanges: true,
131+
open: (argv.open === true),
132+
server: {
133+
baseDir: env.DIR_DEST
134+
}
135+
}, (err, bs) => {
136+
if (err) {
137+
console.warn(err);
138+
}
139+
140+
});
141+
142+
// Watch and trigger tasks on file changes
143+
gulp.watch(env.DIR_SRC + '/assets/scripts/**/*', ['buildScripts']);
144+
gulp.watch(env.DIR_SRC + '/assets/styles/**/*', ['buildStyles']);
145+
gulp.watch(env.DIR_SRC + '/**/*.{hbs,html}', ['buildMarkup']);
146+
gulp.watch(env.DIR_SRC + '/templates/jst/**/*', ['buildJST']);
147+
gulp.watch([env.DIR_SRC + '/assets/{media,data}/**/*'], ['buildStatic']);
148+
});
149+
150+
/**
151+
* Helper task to builds and then watches files.
152+
* Same as doing "gulp && gulp watch"
153+
*
154+
* @task launch
155+
*/
156+
gulp.task('launch', (done) => {
157+
runSequence(
158+
['default'], ['watch'],
159+
done
160+
);
161+
});

examples/troubleshooting/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# CLIENT.Project
2+
3+
## Build Files
4+
Builds the project either in the develop or production mode depending on what is set for ```BUILD_MODE``` in **build-env.js** file.
5+
6+
$ gulp
7+
8+
// Override the BUILD_MODE with one of the following flag
9+
$ gulp --dev
10+
$ gulp --prod
11+
12+
By default the ```BUILD_MODE``` in **build-env.js** file production mode. Don't forget to change this so you not always building in production mode.
13+
14+
## Watch Files
15+
16+
$ gulp watch
17+
18+
// Automatically open project in the browser:
19+
$ gulp watch --open
20+
21+
// All at once:
22+
$ gulp && gulp watch --open
23+
24+
25+
## Other Tasks
26+
27+
// Build YUIDocs:
28+
$ gulp docs
29+
30+
// Check for linting issues:
31+
$ gulp lint
32+
33+
// Helper task for "gulp && gulp watch"
34+
$ gulp launch
35+
$ gulp launch --open
36+
37+
## Install
38+
After code is committed to source control and pulled down to another computer you will need to do the following:
39+
40+
$ cp build-env.js.dist build-env.js
41+
$ npm install
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "client-project",
3+
"version": "1.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"handlebars": "~4.0.5"
7+
},
8+
"devDependencies": {}
9+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
'use strict';
2+
3+
/**
4+
* Environment constants.
5+
*
6+
* This configuration file contains all of the environment-specific values
7+
* needed to build a working website. The common values should be committed to
8+
* the `build-env.js.dist` file. A non-committed environment-specific copy of
9+
* the file should then be made to setup production, staging, and sandboxes as
10+
* needed.
11+
*
12+
* @class Config
13+
* @static
14+
*/
15+
var Config = {
16+
/**
17+
* The canonical address of the website. No trailing slash. Protocol may be
18+
* omitted (http://www.paulirish.com/2010/the-protocol-relative-url/).
19+
*
20+
* @property URL_SITE
21+
* @type {String}
22+
*/
23+
URL_SITE: '//www.example.com', // protocol-relative address
24+
// URL_SITE: 'https://www.example.com', // absolute address
25+
26+
/**
27+
* The base path of the website. Trailing slashes should be included for any
28+
* path other than an empty page-relative value.
29+
*
30+
* @property URL_BASE
31+
* @type {String}
32+
*/
33+
URL_BASE: '', // page-relative base path
34+
// URL_BASE: '/', // root-relative base path
35+
// URL_BASE: '/foo/bar/', // root-directory-relative base path
36+
// URL_BASE: '//www.example.com/foo/', // absolute base path
37+
38+
/**
39+
* Path where Node.js modules are installed. No trailing slash.
40+
*
41+
* @property DIR_NPM
42+
* @type {String}
43+
*/
44+
DIR_NPM: 'node_modules',
45+
46+
/**
47+
* Path where Bower components are installed. No trailing slash.
48+
*
49+
* @property DIR_BOWER
50+
* @type {String}
51+
*/
52+
DIR_BOWER: 'src/assets/vendor',
53+
54+
/**
55+
* Path to uncompiled source files. No trailing slash.
56+
*
57+
* @property DIR_SRC
58+
* @type {String}
59+
*/
60+
DIR_SRC: 'src',
61+
62+
/**
63+
* Path to compiled output files. No trailing slash.
64+
*
65+
* @property DIR_DEST
66+
* @type {String}
67+
*/
68+
DIR_DEST: 'web',
69+
70+
/**
71+
* Path to documentation output files. No trailing slash.
72+
*
73+
* @property DIR_DOCS
74+
* @type {String}
75+
*/
76+
DIR_DOCS: 'docs',
77+
78+
/**
79+
* Value to determine what tasks should be triggered to build the output.
80+
*
81+
* @property BUILD_MODE
82+
* @type {String} Options are 'dev' or 'prod'
83+
*/
84+
BUILD_MODE: 'prod',
85+
86+
/**
87+
* DANGER: Whether the Gulpfile should be allowed to modify directories
88+
* outside of the current working directory (CDW). Should only be enabled
89+
* if you understand the effects and repercussions. Useful when building
90+
* in environments where only the contents of DIR_DEST should be publicly
91+
* accessible.
92+
*
93+
* @property UNSAFE_MODE
94+
* @type {Boolean}
95+
*/
96+
UNSAFE_MODE: false
97+
};
98+
99+
module.exports = Config;

0 commit comments

Comments
 (0)