Skip to content

Commit 81b42ef

Browse files
authored
Migrate from bower to npm (#8209)
* Migrate from bower to npm This change migrates from the use of bower (deprecated) to npm for dependencies. We also update Bootstrap to 4.3 Several packages do not exist in NPM so they are copied into the static directory for the theme Signed-off-by: Matt Stratton <[email protected]> * Add gulp for build * Create gulp task for building scss and js Signed-off-by: Matt Stratton <[email protected]> * Update with docs on gulp task
1 parent 2f33d35 commit 81b42ef

Some content is hidden

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

52 files changed

+15846
-156
lines changed

gulp/tasks/dev/dev.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var gulp = require('gulp');
2+
var HubRegistry = require('gulp-hub');
3+
4+
5+
6+
// load some files into the registry
7+
var hub = new HubRegistry(['tasks/dev/*.js']);
8+
9+
// tell gulp to use the tasks just loaded
10+
gulp.registry(hub);
11+
gulp.task('dev', gulp.series('js-concat', 'sass'))

gulp/tasks/dev/javascript.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var gulp = require('gulp'),
2+
concat = require('gulp-concat'),
3+
rename = require('gulp-rename'),
4+
uglify = require('gulp-uglify');
5+
sourcemaps = require('gulp-sourcemaps');
6+
7+
var scripts = [
8+
'node_modules/jquery/dist/jquery.js',
9+
'node_modules/tether/dist/js/tether.js',
10+
'node_modules/bootstrap/dist/js/bootstrap.js',
11+
'themes/devopsdays-theme/static/components/jquery-oembed-all/jquery.oembed.js',
12+
'themes/devopsdays-theme/static/components/bootstrap-sortable/Scripts/bootstrap-sortable.js',
13+
'node_modules/moment/moment.js',
14+
'node_modules/jssocials/dist/jssocials.js',
15+
'themes/devopsdays-theme/static/js/devopsdays.js'
16+
]
17+
18+
gulp.task('js-concat', function(){
19+
return gulp.src(scripts)
20+
.pipe(sourcemaps.init())
21+
.pipe(concat('concat.js'))
22+
// .pipe(gulp.dest('dist'))
23+
.pipe(rename('devopsdays-min.js'))
24+
.pipe(uglify({ keep_fnames: true }))
25+
.pipe(sourcemaps.write('./'))
26+
.pipe(gulp.dest('themes/devopsdays-theme/static/js'));
27+
});

gulp/tasks/dev/sass.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var gulp = require('gulp'),
2+
sass = require('gulp-sass'),
3+
sourcemaps = require('gulp-sourcemaps');
4+
5+
sass.compiler = require('node-sass');
6+
7+
gulp.task('sass', function () {
8+
return gulp.src('themes/devopsdays-theme/static/scss/site.scss')
9+
.pipe(sourcemaps.init())
10+
.pipe(sass().on('error', sass.logError))
11+
.pipe(sourcemaps.write('./'))
12+
.pipe(gulp.dest('themes/devopsdays-theme/static/css'));
13+
});

gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var requireDir = require('require-dir');
22

33
// Require all tasks in gulp/tasks, including subfolders
4-
requireDir('./gulp/tasks', { recurse: true });
4+
requireDir('./gulp/tasks', { recurse: true });

package-lock.json

+56-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+14-6
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,32 @@
2020
"del": "~5.1.0",
2121
"gulp": "~4.0.0",
2222
"gulp-cache": "~1.1.0",
23-
"gulp-concat": "~2.6.1",
23+
"gulp-concat": "^2.6.1",
2424
"gulp-htmlmin": "~5.0.1",
2525
"gulp-hub": "~4.2.0",
2626
"gulp-imagemin": "6.1.0",
2727
"gulp-img-retina": "0.0.4",
28-
"gulp-rename": "~1.4.0",
28+
"gulp-rename": "^1.4.0",
2929
"gulp-responsive": "~2.11.0",
3030
"gulp-rev": "~9.0.0",
3131
"gulp-rev-replace": "~0.4.4",
32-
"gulp-sass": "~4.0.2",
33-
"gulp-sourcemaps": "~2.6.4",
34-
"gulp-uglify": "~3.0.1",
32+
"gulp-sass": "^4.0.2",
33+
"gulp-sourcemaps": "^2.6.5",
34+
"gulp-uglify": "^3.0.2",
3535
"gulp-useref": "~3.1.6",
3636
"gulp-util": "~3.0.8",
3737
"gulp-watch": "~5.0.1",
38+
"node-sass": "^4.12.0",
3839
"require-dir": "~1.2.0"
3940
},
4041
"dependencies": {
41-
"netlify-cli": "^2.11.10"
42+
"netlify-cli": "^2.11.10",
43+
"bootstrap": "^4.3.1",
44+
"font-awesome": "^4.7.0",
45+
"jquery": "^3.4.1",
46+
"jssocials": "^1.5.0",
47+
"moment": "^2.24.0",
48+
"popper.js": "^1.15.0",
49+
"tether": "^1.4.7"
4250
}
4351
}

themes/devopsdays-theme/CONTRIBUTING.md

+24-35
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,13 @@ The technical details on how to set up your local development environment for ma
3131

3232
## Dev Setup
3333

34-
Working with a Hugo theme outside of a content-based repo has a few challenges. The `devopsdays-theme` repo contains a directory called `exampleSite`, which is what is used for testing theme development. The `config.toml` for the `exampleSite` contains the following value:
34+
One of the more important things to know is that if you are going to make changes to CSS or JavaScript, you will need to be able to run the scripts that compile the SCSS files to CSS, and also concatenate and minifiy the JavaScript we use. In order to do this, you need the following installed on your local machine:
3535

36-
```
37-
themesdir = "../.."
38-
```
39-
40-
This tells Hugo where to look for its theme directories.
41-
42-
You will need to run your watch command from the `exampleSite` directory; use something like this:
43-
44-
```
45-
hugo server -w --baseUrl="http://localhost:1313"
46-
```
36+
- [node](https://nodejs.org/en/)
37+
- [npm](https://www.npmjs.com/get-npm)
38+
- [gulp](https://gulpjs.com/)
4739

48-
NOTE: If you also load the existing `devopsdays-web` project, it is highly suggested that you use the `-p` flag on `hugo server` to load this theme on a different port. This will prevent your browser from caching assets like stylesheets, etc, from the other instance.
40+
Once you have these install, navigate to the root of `devopsdays-web` in a terminal, and run `npm install` to get all the pieces installed into `devopsdays-web`. The `node_modules` directory is not committed to source control, so you will have to run `npm install` any time you are setting up a new copy of the repo on a workstation.
4941

5042
## How can I help?
5143

@@ -55,7 +47,7 @@ Sort the existing GitHub issues for the tag of `ready`. These are issues that ca
5547

5648
### Frameworks
5749

58-
We use [Boostrap v4 Alpha](http://v4-alpha.getbootstrap.com/) as our basic framework.
50+
We use [Boostrap v4.3](https://getbootstrap.com/docs/4.3/getting-started/introduction/) as our basic framework.
5951

6052
### Blocks
6153
All page templates should make use of the `layouts/_default/baseof.html` file. This file contains all wrappers for the content. Anything within the `{{- block "main" . }} {{- end -}}` section is what will be displayed on a sub-template. Include a `{{ define "main" }}` block in your template to include what should be rendered.
@@ -81,28 +73,29 @@ The `devopsdays-theme` repo has hooks into Travis, Appveyor, and Netlify. Curren
8173
All changes are built by Netlify to https://dev.devopsdays.org once merged to master.
8274

8375
### Asset Pipeline
84-
Peruse the `gulpfile.js` to see what is processed for the asset pipeline. Gulp is only called when changes are merged to master. Pull requests, and local changes will not trigger gulp.
85-
86-
If you are manipulating JavaScript or SCSS files, please be sure to use Gulp. If you run `gulp dev` inside the repo, it will build the CSS and JS files, and also start a `watch` task for you.
76+
If you make changes to SCSS files, or the `themes/devopsdays-theme/static/js/devopsdays.js` file, you will need to run a `gulp` task to compile the SCSS to CSS and to concatenate and minify the Javascript files.
8777

88-
If you need help with this, ask @mattstratton.
89-
90-
## Workflow
78+
To run this, navigate to the root of `devopsdays-web` in your terminal, and run `gulp dev`. If you get errors, you likely don't have `node`, `npm`, and/or `gulp` installed. You also may not have run `npm install`.
9179

92-
Our workflow is inspired by [Ian Bickering's guide to using GitHub Issues](http://www.ianbicking.org/blog/2014/03/use-github-issues-to-organize-a-project.html).
80+
The output of `gulp dev` should look something like this:
9381

94-
### Milestones
95-
96-
**Stuff we are doing right now:** this is the “main” milestone. We give it a minor SemVer name (like 1.2 or 2.3). We create a new milestone when we have released a new minor version.
97-
98-
**Stuff we’ll probably do soon:** this is the standing [“Next Tasks” milestone](https://github.com/devopsdays/devopsdays-theme/milestone/4). We never change or rename this milestone.
99-
100-
**Stuff we probably won’t do soon:** this is the standing [“Blue Sky” milestone](https://github.com/devopsdays/devopsdays-theme/milestone/3). We refer to these tickets and sometimes look through them, but they are easy to ignore, somewhat intentionally ignored.
101-
102-
**What aren’t we sure about?:** issues with no milestone.
82+
```
83+
[12:31:47] Using gulpfile ~/src/github.com/devopsdays/devopsdays-web/gulpfile.js
84+
[12:31:47] Starting 'dev'...
85+
[12:31:47] Starting 'js-concat'...
86+
[12:31:50] Finished 'js-concat' after 3.51 s
87+
[12:31:50] Starting 'sass'...
88+
[12:31:51] Finished 'sass' after 652 ms
89+
[12:31:51] Finished 'dev' after 4.16 s
90+
```
10391

104-
There should be no other milestones; issues that are logged as `bug` or `enhancement` will be prioritized into the milestone when we are ready to work on them. Only issues with the tag of `ready` should be worked on.
92+
After running, you should see updates to the following files in `themes/devopsdays-theme/static`:
93+
- `css/site.css`
94+
- `css/site.css.map`
95+
- `js/devopsdays-min.js`
96+
- `js/devopsdays-min.js.map`
10597

98+
## Workflow
10699

107100
### Issues
108101

@@ -134,7 +127,3 @@ These are the labels we use, and what they mean:
134127
### Pull Requests
135128

136129
Please submit your proposed changes as a Pull Request against this repository. If the PR will resolve an issue, please add `Fixes #123` to the PR.
137-
138-
## Releasing
139-
140-
See [utils/README](https://github.com/devopsdays/devopsdays-theme/blob/master/utils/README.md) for instructions.

0 commit comments

Comments
 (0)