Skip to content

Commit

Permalink
add default.nix; 00-publish --> 00_buid; change some URLs to use https
Browse files Browse the repository at this point in the history
  • Loading branch information
oakmac committed Jan 10, 2020
1 parent 1aad69f commit 5b62334
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ignore the publish directory
00-publish/
# ignore the build directory
00_build

# ignore node_modules
node_modules/
Expand Down
32 changes: 16 additions & 16 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,30 +182,30 @@ module.exports = function (grunt) {
}

function hashAssets () {
const cssFile = grunt.file.read('00-publish/css/main.min.css')
const cssFile = grunt.file.read('00_build/css/main.min.css')
const cssHash = md5(cssFile).substr(0, 8)
const jsFile = grunt.file.read('00-publish/js/cheatsheet.min.js')
const jsFile = grunt.file.read('00_build/js/cheatsheet.min.js')
const jsHash = md5(jsFile).substr(0, 8)
const htmlFile = grunt.file.read('00-publish/index.html')
const htmlFile = grunt.file.read('00_build/index.html')

// write the new files
grunt.file.write('00-publish/css/main.min.' + cssHash + '.css', cssFile)
grunt.file.write('00-publish/js/cheatsheet.min.' + jsHash + '.js', jsFile)
grunt.file.write('00_build/css/main.min.' + cssHash + '.css', cssFile)
grunt.file.write('00_build/js/cheatsheet.min.' + jsHash + '.js', jsFile)

// delete the old files
grunt.file.delete('00-publish/css/main.min.css')
grunt.file.delete('00-publish/js/cheatsheet.min.js')
grunt.file.delete('00_build/css/main.min.css')
grunt.file.delete('00_build/js/cheatsheet.min.js')

// update the HTML file
grunt.file.write('00-publish/index.html',
grunt.file.write('00_build/index.html',
htmlFile.replace('main.min.css', 'main.min.' + cssHash + '.css')
.replace('cheatsheet.min.js', 'cheatsheet.min.' + jsHash + '.js'))

// show some output
grunt.log.writeln('00-publish/css/main.min.css → ' +
'00-publish/css/main.min.' + cssHash + '.css')
grunt.log.writeln('00-publish/js/cheatsheet.min.js → ' +
'00-publish/js/cheatsheet.min.' + jsHash + '.js')
grunt.log.writeln('00_build/css/main.min.css → ' +
'00_build/css/main.min.' + cssHash + '.css')
grunt.log.writeln('00_build/js/cheatsheet.min.js → ' +
'00_build/js/cheatsheet.min.' + jsHash + '.js')
}

// ---------------------------------------------------------------------------
Expand All @@ -219,17 +219,17 @@ module.exports = function (grunt) {
force: true
},

// remove all the files in the 00-publish folder
pre: ['00-publish'],
// remove all the files in the 00_build folder
pre: ['00_build'],

// remove the uncompressed CLJS client file
post: ['00-publish/js/cheatsheet.js']
post: ['00_build/js/cheatsheet.js']
},

copy: {
cheatsheet: {
files: [
{expand: true, cwd: 'public/', src: ['**'], dest: '00-publish/'}
{expand: true, cwd: 'public/', src: ['**'], dest: '00_build/'}
]
}
},
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can read about some of the design decisions that went into the cheatsheet

### First time setup

Install [Leiningen], [Node.js], and [Yarn].
Install [Leiningen], [Node.js], and [Yarn] or use [nix-shell] from the project root.

```sh
# install node_modules
Expand All @@ -26,7 +26,7 @@ You may wish to run these commands in separate console tabs / screens.
# does two things:
# - compiles LESS into CSS whenever a less/*.less file changes
# - builds public/docs.json whenever a docs/*.cljsdoc file changes
grunt watch
npx grunt watch

# run a local web server on port 9224
# the port is configurable and defaults to 8888 if not provided
Expand All @@ -39,16 +39,17 @@ lein clean && lein cljsbuild auto
# NOTE: app.js is generated from "lein cljsbuild auto" above
node app.js

# create a build into the 00-publish directory
grunt build
# create a build into the 00-build directory
npx grunt build
```

## License

[MIT License]

[cljs.info/cheatsheet]:http://cljs.info/cheatsheet
[Leiningen]:http://leiningen.org
[Node.js]:http://nodejs.org
[cljs.info/cheatsheet]:https://cljs.info/cheatsheet
[Leiningen]:https://leiningen.org
[Node.js]:https://nodejs.org
[Yarn]:https://yarnpkg.com/
[nix-shell]:https://nixos.wiki/wiki/Development_environment_with_nix-shell
[MIT License]:https://github.com/oakmac/cljs-cheatsheet/blob/master/LICENSE.md
23 changes: 23 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ nixpkgs ? import <nixpkgs> { } }:

let
pkgs = [
/* Core runtime libraries */
nixpkgs.nodejs
nixpkgs.yarn
nixpkgs.clojure
nixpkgs.jdk11
nixpkgs.leiningen

/* Dev Tools */
nixpkgs.ack
nixpkgs.git
nixpkgs.gnupg
nixpkgs.which
];

in
nixpkgs.stdenv.mkDerivation {
name = "env";
buildInputs = pkgs;
}

0 comments on commit 5b62334

Please sign in to comment.