Skip to content

Commit 3df5f62

Browse files
committed
Restructure the project for usage with npm/yarn
Signed-off-by: Max Magorsch <[email protected]>
1 parent a1d0718 commit 3df5f62

Some content is hidden

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

67 files changed

+131
-224
lines changed

.gitignore

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/.DS_Store
2-
/node_modules
3-
/assets/*
1+
.DS_Store
2+
node_modules
3+
assets
4+
dist
45

56
# Ignore these due to dynamic build process
6-
/package-lock.json
7-
/sources/css/tyrian/package-lock.json
7+
package-lock.json
88

99
# ignore npm cache
10-
/npm-cacache
10+
npm-cacache

.gitmodules

-3
This file was deleted.

docker/Dockerfile Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM node:alpine
22
ENTRYPOINT ["/run.sh"]
3-
COPY /run.sh /run.sh
3+
COPY bin/run.sh /run.sh
44
RUN mkdir -p /repo
55
VOLUME /repo

Gruntfile.js

+58-71
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,81 @@
22
// Alex Legler <[email protected]>
33

44
'use strict';
5-
65
module.exports = function(grunt) {
76
grunt.initConfig({
87
pkg: grunt.file.readJSON('package.json'),
9-
shell: {
10-
update_bootstrap: {
11-
command: ['git submodule update --init --checkout', 'npm i'].join('&&'),
8+
less: {
9+
compile: {
1210
options: {
13-
execOptions: {
14-
cwd: 'sources/css/bootstrap/'
15-
}
11+
strictMath: true,
12+
paths: ["node_modules"]
13+
},
14+
files: {
15+
"dist/tyrian.css": "src/less/tyrian.less"
1616
}
1717
},
18-
build_tyrian_css: {
19-
command: 'grunt dist',
18+
minify: {
2019
options: {
21-
stdout: true,
22-
execOptions: {
23-
cwd: './sources/css/tyrian/'
24-
}
20+
compress: true,
21+
yuicompress: true,
22+
optimization: 2
23+
},
24+
files: {
25+
"dist/tyrian.min.css": "dist/tyrian.css"
2526
}
2627
}
2728
},
28-
copy: {
29-
copy_assets: {
29+
replace: {
30+
compile: {
31+
options: {
32+
patterns: [
33+
{
34+
match: /^(.*\r?\n)*\/\* tyrian-start \*\/\r?\n/gm,
35+
replacement: ""
36+
}
37+
]
38+
},
39+
files: [
40+
{expand: true, flatten: true, src: ['dist/tyrian.css'], dest: 'dist/'}
41+
]
42+
},
43+
inject_variables: {
44+
options: {
45+
patterns: [
46+
{
47+
match: /@import "variables\.less";$/m,
48+
replacement: '@import "variables.less"; @import "../../tyrian/bootstrap/variables-tyrian.less";'
49+
}
50+
],
51+
silent: true
52+
},
3053
files: [
31-
{
32-
cwd: 'sources/css/bootstrap/dist/',
33-
src: [
34-
'js/bootstrap.js',
35-
'js/bootstrap.min.js',
36-
'css/bootstrap.css',
37-
'css/bootstrap.css.map',
38-
'css/bootstrap.min.css',
39-
'fonts/*'
40-
],
41-
dest: 'assets/',
42-
expand: true,
43-
flatten: true
44-
},
45-
{
46-
cwd: 'sources/css/tyrian/dist/',
47-
src: [
48-
'*.css'
49-
],
50-
dest: 'assets/',
51-
expand: true,
52-
flatten: true
53-
},
54-
{
55-
cwd: 'sources/fonts/',
56-
src: [
57-
'*.*'
58-
],
59-
dest: 'assets/',
60-
expand: true,
61-
flatten: true
62-
},
63-
{
64-
cwd: 'sources/img/',
65-
src: [
66-
'*.*'
67-
],
68-
dest: 'assets/',
69-
expand: true,
70-
flatten: true
71-
},
72-
{
73-
cwd: 'sources/js/',
74-
src: [
75-
'*.*'
76-
],
77-
dest: 'assets/',
78-
expand: true,
79-
flatten: true
80-
},
54+
{expand: true, flatten: true, src: ['../bootstrap/less/bootstrap.less'], dest: '../bootstrap/less/'}
8155
]
8256
}
57+
},
58+
shell: {
59+
build_bootstrap: {
60+
command: 'grunt dist',
61+
options: {
62+
stdout: true,
63+
execOptions: {
64+
cwd: '../bootstrap/'
65+
}
66+
}
67+
}
8368
}
8469
});
8570

86-
grunt.loadNpmTasks("grunt-contrib-copy");
71+
grunt.loadNpmTasks("grunt-contrib-less");
72+
grunt.loadNpmTasks("grunt-replace-regex");
8773
grunt.loadNpmTasks("grunt-shell");
8874

89-
grunt.registerTask("compile", ["shell:build_tyrian_css"]);
90-
grunt.registerTask("copy_assets", ["copy:copy_assets"]);
75+
grunt.registerTask("compile", ["less:compile", "replace:compile"]);
76+
grunt.registerTask("compress", ["less:minify"]);
77+
grunt.registerTask("bootstrap", ["replace:inject_variables", "shell:build_bootstrap"]);
9178

92-
grunt.registerTask("default", ["compile", "copy_assets"]);
93-
94-
grunt.registerTask("update_bootstrap", ["shell:update_bootstrap"]);
79+
grunt.registerTask("dist", ["compile", "compress"]);
80+
grunt.registerTask("default", ["dist"]);
9581
};
82+

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker-build:
2020
docker build \
2121
-t $(TAG_LATEST) \
2222
-t $(TAG_TS) \
23-
docker/
23+
.
2424

2525
docker-run: docker-build
2626
@mkdir -p $(CACHEDIR_EXT)

README.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tyrian
22
======
33

4-
Tyrian The new look of gentoo.org
4+
Tyrian - The new look of gentoo.org
55

66
### Deployment
77

@@ -10,14 +10,13 @@ See assets-cdn.txt for the URLs.
1010

1111
### Development (local)
1212

13-
* `emerge net-libs/nodejs` to get node.js up and running
14-
* `sudo npm install -g grunt-cli` to get grunt(1)
15-
* clone this repository (don't forget to `init` and `update` the git submodules)
16-
* run `npm install` in the repository root as well as in `sources/css/{bootstrap,tyrian}`
17-
* run `grunt`
18-
* Output appears in `assets/`
13+
* `emerge net-libs/nodejs` to get node.js up and running (you will need at least npm v6.9.0)
14+
* clone this repository
15+
* run `npm install` in the repository root
16+
* run `npm run dist` in the repository root
17+
* Output appears in `dist/`
1918

2019
### Development (containerized)
21-
* clone this repository (don't forget to `init` and `update` the git submodules)
20+
* clone this repository
2221
* run `make docker-run`
23-
* Output appears in `assets/`
22+
* Output appears in `dist/`

bin/run.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
# POSIX sh, not bash!
3+
die() {
4+
set +x
5+
echo "$*" 1>&2
6+
exit 1
7+
}
8+
# export for debugging
9+
[ "$DEBUG" == "1" ] && set -x
10+
# go to volume
11+
cd /repo
12+
npm install || die "FAIL:${PWD}: npm install failed"
13+
npm run dist || die "FAIL:${PWD}: npm run dist failed"

docker/run.sh

-22
This file was deleted.

index.html examples/tyrian.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta name="theme-color" content="#54487a">
88
<meta name="description" content="">
9-
<link href="assets/bootstrap.css" rel="stylesheet" media="screen">
10-
<link href="assets/tyrian.css" rel="stylesheet" media="screen">
9+
<link href="../dist/bootstrap.css" rel="stylesheet" media="screen">
10+
<link href="../dist/tyrian.css" rel="stylesheet" media="screen">
1111
</head>
1212
<body>
1313
<header>
@@ -39,8 +39,8 @@
3939
</div>
4040
<div class="logo">
4141
<a href="/" title="Back to the homepage" class="site-logo">
42-
<object data="assets/site-logo.svg" type="image/svg+xml">
43-
<img src="assets/site-logo.png" alt="Gentoo Linux Logo">
42+
<object data="../dist/site-logo.svg" type="image/svg+xml">
43+
<img src="../dist/site-logo.png" alt="Gentoo Linux Logo">
4444
</object>
4545
</a>
4646
<span class="site-label">Site Title</span>
@@ -156,9 +156,9 @@ <h2>Developer Blogs (Planet Gentoo)</h2>
156156
<h2>Sponsors</h2>
157157
<p>Gentoo is proudly sponsored by:</p>
158158
<p style="text-align: center;">
159-
<img src="assets/ad1.png" alt="ad" style="margin-right: 1em;">
160-
<img src="assets/ad2.png" alt="ad" style="margin-right: 1em;">
161-
<img src="assets/ad3.png" alt="ad">
159+
<img src="../dist/ad1.png" alt="ad" style="margin-right: 1em;">
160+
<img src="../dist/ad2.png" alt="ad" style="margin-right: 1em;">
161+
<img src="../dist/ad3.png" alt="ad">
162162
</p>
163163
</div>
164164
</div>
@@ -242,6 +242,6 @@ <h3 class="footerhead">Questions or comments?</h3>
242242
</footer>
243243

244244
<script src="http://code.jquery.com/jquery.js"></script>
245-
<script src="assets/bootstrap.js"></script>
245+
<script src="../dist/bootstrap.js"></script>
246246
</body>
247247
</html>

package.json

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
11
{
2-
"name": "gentoo-tyrian",
3-
"version": "0.0.1",
2+
"name": "@gentoo/tyrian",
3+
"version": "1.0.0",
44
"description": "Gentoo Tyrian theme",
5-
"repository": "https://anongit.gentoo.org/git/sites/tyrian-theme.git",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://anongit.gentoo.org/git/sites/tyrian-theme.git"
8+
},
9+
"files": [
10+
"dist",
11+
"src"
12+
],
613
"devDependencies": {
14+
"npm-run-all": "^4.1.2",
715
"grunt": "~1.0.4",
816
"grunt-contrib-copy": "~1.0.0",
9-
"grunt-shell": "~3.0.1"
17+
"grunt-shell": "~3.0.1",
18+
"grunt-contrib-less": "~2.0.0",
19+
"grunt-replace-regex": "~1.0.3"
20+
},
21+
"scripts": {
22+
"prepare": "npm run dist",
23+
"dist": "npm-run-all clean:dist css:tyrian:dist copy:assets",
24+
"clean:dist": "rm -rf dist && mkdir -p dist",
25+
"css:tyrian:dist": "grunt",
26+
"copy:assets": "npm-run-all copy:js copy:img copy:fonts copy:tyrian:assets",
27+
"copy:js": "cp src/js/*.js dist",
28+
"copy:img": "cp src/img/*.* dist",
29+
"copy:fonts": "cp src/fonts/*.* dist",
30+
"copy:tyrian:assets": "cp node_modules/bootstrap/dist/fonts/* dist && cp node_modules/bootstrap/dist/js/bootstrap.js dist && cp node_modules/bootstrap/dist/js/bootstrap.min.js dist && cp node_modules/bootstrap/dist/css/bootstrap.css dist && cp node_modules/bootstrap/dist/css/bootstrap.css.map dist && cp node_modules/bootstrap/dist/css/bootstrap.min.css dist"
31+
},
32+
"dependencies": {
33+
"jquery": "^3.3.1",
34+
"popper.js": "1.14.7",
35+
"bootstrap": "3.4.1",
36+
"font-awesome": "4.7.0",
37+
"autoprefixer": "^7.2.4"
1038
}
1139
}

sources/css/bootstrap

-1
This file was deleted.

sources/css/tyrian/.gitignore

-2
This file was deleted.

0 commit comments

Comments
 (0)