From c01f3ebd5dcd21eede9e4af07d6df8da663283e0 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 8 Sep 2024 13:45:29 -0700 Subject: [PATCH] Fix CSS source maps, simplify dev mode * Add "npm run" commands in package.json so that following README doesn't require npx or globally installed grunt-cli. * Merge "default" task into "build" for clarity and simplicity. * Remove unused Procfille and Heroku instructions. * Remove unused Travis CI. * Add GitHub CI. * Fix source maps. With source maps fixed, remove the separate less:dev task. --- .github/workflows/CI.yaml | 14 +++++++++++ .gitignore | 9 ++++--- .travis.yml | 10 -------- Gruntfile.js | 32 ++++++++--------------- Procfile | 1 - README.md | 53 ++++++++++++++------------------------- package.json | 6 +++-- 7 files changed, 52 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/CI.yaml delete mode 100644 .travis.yml delete mode 100644 Procfile diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml new file mode 100644 index 00000000..06572777 --- /dev/null +++ b/.github/workflows/CI.yaml @@ -0,0 +1,14 @@ +name: CI +on: + - push + - pull_request + +jobs: + test: + # Includes Firefox, Node.js LTS, and Java. + # https://github.com/actions/runner-images/blob/releases/ubuntu22/20240804/images/ubuntu/Ubuntu2204-Readme.md + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - run: npm install + - run: npm test diff --git a/.gitignore b/.gitignore index b4af474a..15afedc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -build/ -node_modules/ -tmp/ -npm-debug.log +/build/ +/node_modules/ +/tmp/ +/package-lock.json +/npm-debug.log diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e709bc95..00000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -sudo: required -dist: trusty -language: node_js -node_js: - - "6" -matrix: - fast_finish: true -cache: - directories: - - node_modules diff --git a/Gruntfile.js b/Gruntfile.js index 88bafede..86526e2b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,14 +13,6 @@ module.exports = function(grunt) { sourceMap: true, outputSourceFiles: true }, - development: { - options: { - paths: ['src/less'] - }, - files: { - 'build/css/main.css': 'src/less/main.less' - } - }, production: { options: { paths: ['src/less'], @@ -57,11 +49,11 @@ module.exports = function(grunt) { watch: { less: { files: 'src/less/**/*.less', - tasks: ['less:development', 'autoprefixer'] + tasks: ['less', 'autoprefixer'] }, tmpl: { files: 'src/tmpl/**/*.pug', - tasks: ['default'] + tasks: ['build'] }, js: { files: 'src/js/**', @@ -69,15 +61,15 @@ module.exports = function(grunt) { }, other: { files: 'src/img/**', - tasks: ['default'] + tasks: ['build'] }, gruntfile: { files: 'Gruntfile.js', - tasks: ['default'] + tasks: ['build'] }, docs: { files: 'node_modules/grunt-docs/**', - tasks: ['default'] + tasks: ['build'] } }, @@ -219,32 +211,28 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-puglint'); } - grunt.registerTask('build', 'Build the site', [ + grunt.registerTask('build', 'Build the site for production', [ 'copy', 'docs', 'blog', 'pug', 'plugins', 'uglify', - 'sitemap' - ]); - grunt.registerTask('default', 'Build the site, download plugins, production ready', [ - 'build', + 'sitemap', 'downloadPlugins', - 'less:production', + 'less', 'autoprefixer' ]); + grunt.registerTask('test', [ 'build', 'jshint', 'puglint', + // Requires Java 8+ 'htmllint' ]); grunt.registerTask('dev', 'Development Mode', [ 'build', - 'less:development', - 'autoprefixer', - 'jshint', 'concurrent' ]); }; diff --git a/Procfile b/Procfile deleted file mode 100644 index 489b2700..00000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: node server.js diff --git a/README.md b/README.md index aa2c20b3..8b27da4f 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,27 @@ -# Grunt Website [![Build Status: Linux](https://travis-ci.org/gruntjs/gruntjs.com.svg?branch=master)](https://travis-ci.org/gruntjs/gruntjs.com) +[![Build Status](https://github.com/gruntjs/gruntjs.com/actions/workflows/CI.yaml/badge.svg)](https://github.com/gruntjs/gruntjs.com/actions/workflows/CI.yaml) -## Setup Development +# Grunt Website -1. `npm install` -2. `grunt` +## Local Development -## Tasks +1. Download dependencies: + ```shell + npm install + ``` +2. Create production site: + ```shell + npm run build + ``` +3. Start web server: + ```shell + npm start + ``` -* `grunt build` - Manually Rebuild -* `grunt dev` - Development Mode +Local address is: http://localhost:5678/ -## Manually Run Server +To automatically rebuild and restart the server after any file changes, +use the development mode instead: ```shell -npm start -``` - -Server port is: `5678`. - -## Deploy to Heroku - -Set Heroku keys (if needed) with - -```shell -ssh-keygen -t rsa -C "YOUR_HEROKU_EMAIL" -f ~/.ssh/id_rsa_heroku -ssh-add ~/.ssh/id_rsa_heroku -heroku keys:add ~/.ssh/id_rsa_heroku.pub -``` - -Push - -```shell -git push git@heroku.com:grunt.git master:master -``` - -If you need to regenerate the Heroku site, use empty commits: - -```shell -git commit --allow-empty -m "empty commit" -git push git@heroku.com:grunt.git master:master +npm run dev ``` diff --git a/package.json b/package.json index 2764e286..d92fdf7a 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,11 @@ "npm": ">=3" }, "scripts": { + "postinstall": "grunt build", + "build": "grunt build", "start": "node server.js", - "postinstall": "grunt", - "test": "grunt test" + "test": "grunt test", + "dev": "grunt dev" }, "private": true, "dependencies": {