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

Commit b6f0e6b

Browse files
committed
removed grunt-string-replace from devDependencies. no longer building demo on top of source in demo folder. grunt live now puts assets for interactive demo into .tmp folder and then grunt demo creates a min bundle in the demo folder. raw source for interactive demo now exists in src folder in demo subdirectory. now using grunt-contrib-cssmin to create single css bundle file for demo. refs #2
1 parent 3a6eb89 commit b6f0e6b

20 files changed

+167
-42726
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
npm-debug.log
33
.idea/
44
.ref/
5+
.tmp/

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ demo
33
dist
44
src
55
.ref
6+
.tmp
67
TODO.md
78
Gruntfile.js
89
.gitignore

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ All notable changes to this project will be documented in this file.
2626
hats 'hat'
2727
```
2828

29+
- removed `grunt-string-replace` from `devDependencies`
30+
- no longer building demo on top of source in `demo/` folder. `grunt live` now puts assets for interactive demo into `.tmp/` folder and then `grunt demo` creates a min bundle in the `demo/` folder
31+
- raw source for interactive demo now exists in `src/demo/` folder
32+
- now using `grunt-contrib-cssmin` to create single css bundle file for demo
33+
2934
### Notes
3035
- there is way too much magic/nonsense in the `smartError()` method of `Tracer`. need to come up with an alternative approach to getting the right information for syntax errors.
3136

Gruntfile.js

Lines changed: 67 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = function(grunt) {
66
src: ['index.js'],
77
dest: 'dist/sqlite-parser.js'
88
},
9-
demo: {
9+
interactive: {
1010
options: {
1111
alias: {
1212
'sqlite-parser': './index',
@@ -30,12 +30,12 @@ module.exports = function(grunt) {
3030
'node_modules/codemirror/mode/javascript/javascript',
3131
'node_modules/codemirror/mode/sql/sql'
3232
],
33-
src: ['demo/js/demo.js'],
34-
dest: 'demo/sqlite-parser-demo.js'
33+
src: ['src/demo/demo.js'],
34+
dest: '.tmp/js/sqlite-parser-demo.js'
3535
}
3636
},
3737
copy: {
38-
main: {
38+
build: {
3939
files: [{
4040
filter: 'isFile',
4141
expand: true,
@@ -44,24 +44,29 @@ module.exports = function(grunt) {
4444
dest: 'lib/'
4545
}]
4646
},
47+
interactive: {
48+
files: [{
49+
src: ['src/demo/index.html'],
50+
flatten: true,
51+
expand: true,
52+
dest: '.tmp/'
53+
}],
54+
},
4755
demo: {
48-
src: [
49-
'node_modules/codemirror/lib/codemirror.css',
50-
'node_modules/codemirror/addon/fold/foldgutter.css',
51-
'node_modules/codemirror/theme/monokai.css'
52-
],
53-
flatten: true,
56+
src: ['**/*.{html,css}'],
5457
expand: true,
55-
dest: 'demo/css/'
58+
cwd: '.tmp/',
59+
dest: 'demo/'
5660
}
5761
},
5862
clean: {
59-
main: ['lib/*.js'],
63+
build: ['lib/*.js'],
6064
dist: ['dist/*.js'],
61-
demo: ['demo/sqlite-parser-demo.js', 'demo/css/*.css', '!demo/css/demo.css']
65+
interactive: ['.tmp/**/*'],
66+
demo: ['demo/**/*']
6267
},
6368
shell: {
64-
pegjs: {
69+
build: {
6570
options: {
6671
failOnError: true
6772
},
@@ -92,7 +97,7 @@ module.exports = function(grunt) {
9297
server: {
9398
options: {
9499
port: 8080,
95-
base: 'demo',
100+
base: '.tmp',
96101
livereload: true
97102
}
98103
}
@@ -104,24 +109,23 @@ module.exports = function(grunt) {
104109
livereload: false
105110
},
106111
files: [
107-
'Gruntfile.js', 'index.js', 'test/*.js', 'src/*.js',
108-
'src/*.pegjs', 'test/sql/*.sql'
112+
'index.js', 'test/*.js', 'src/*.js', 'src/*.pegjs',
113+
'test/sql/*.sql', 'Gruntfile.js'
109114
],
110-
tasks: ['default', 'shell:debug']
115+
tasks: ['build', 'shell:debug']
111116
},
112-
demo: {
117+
live: {
113118
options: {
114119
debounceDelay: 1000,
115120
livereload: {
116-
directory: 'demo/',
121+
directory: '.tmp/',
117122
port: 35729
118123
},
119124
},
120125
files: [
121-
'index.js', 'src/*.js', 'src/*.pegjs', 'demo/js/*.js',
122-
'Gruntfile.js', 'demo/css/demo.css', 'demo/index.html'
126+
'index.js', 'src/**/*.{js,pegjs,css,html}', 'Gruntfile.js'
123127
],
124-
tasks: ['default', 'clean:demo', 'browserify:demo', 'copy:demo']
128+
tasks: ['interactive']
125129
}
126130
},
127131
uglify: {
@@ -132,31 +136,22 @@ module.exports = function(grunt) {
132136
},
133137
demo: {
134138
files: {
135-
'demo/sqlite-parser-demo-min.js': ['demo/sqlite-parser-demo.js']
139+
'demo/js/sqlite-parser-demo.js': ['.tmp/js/sqlite-parser-demo.js']
136140
}
137141
}
138142
},
139-
'string-replace': {
140-
demo: {
141-
files: {
142-
'demo/index.html': 'demo/index.html'
143-
},
144-
options: {
145-
replacements: [{
146-
pattern: '<script src="sqlite-parser-demo.js"></script>',
147-
replacement: '<script src="sqlite-parser-demo-min.js"></script>'
148-
}]
149-
}
150-
},
143+
cssmin: {
151144
interactive: {
152-
files: {
153-
'demo/index.html': 'demo/index.html'
154-
},
155145
options: {
156-
replacements: [{
157-
pattern: '<script src="sqlite-parser-demo-min.js"></script>',
158-
replacement: '<script src="sqlite-parser-demo.js"></script>'
159-
}]
146+
processImport: true
147+
},
148+
files: {
149+
'.tmp/css/sqlite-parser-demo.css': [
150+
'node_modules/codemirror/lib/codemirror.css',
151+
'node_modules/codemirror/addon/fold/foldgutter.css',
152+
'node_modules/codemirror/theme/monokai.css',
153+
'src/demo/demo.css'
154+
]
160155
}
161156
}
162157
}
@@ -169,18 +164,37 @@ module.exports = function(grunt) {
169164
grunt.loadNpmTasks('grunt-browserify');
170165
grunt.loadNpmTasks('grunt-contrib-connect');
171166
grunt.loadNpmTasks('grunt-contrib-uglify');
172-
grunt.loadNpmTasks('grunt-string-replace');
167+
grunt.loadNpmTasks('grunt-contrib-cssmin');
173168

174-
grunt.registerTask('default', ['clean:main', 'shell:pegjs', 'copy:main']);
175-
grunt.registerTask('test', ['default', 'shell:test']);
176-
grunt.registerTask('debug', ['default', 'shell:debug', 'watch:debug']);
177-
grunt.registerTask('json', ['default', 'shell:json']);
178-
grunt.registerTask('demo', [
179-
'default', 'clean:demo', 'browserify:demo', 'copy:demo', 'uglify:demo', 'string-replace:demo'
169+
grunt.registerTask('default', [
170+
'build'
171+
]);
172+
grunt.registerTask('build', [
173+
'clean:build', 'shell:build', 'copy:build'
174+
]);
175+
grunt.registerTask('test', [
176+
'build', 'shell:test'
177+
]);
178+
grunt.registerTask('debug', [
179+
'build', 'shell:debug', 'watch:debug'
180+
]);
181+
grunt.registerTask('json', [
182+
'build', 'shell:json'
180183
]);
181184
grunt.registerTask('interactive', [
182-
'default', 'clean:demo', 'browserify:demo', 'copy:demo', 'string-replace:interactive', 'connect:server', 'watch:demo'
185+
'clean:interactive', 'default', 'copy:interactive', 'cssmin:interactive',
186+
'browserify:interactive'
187+
]);
188+
grunt.registerTask('live', [
189+
'interactive', 'connect:server', 'watch:live'
190+
]);
191+
grunt.registerTask('demo', [
192+
'interactive', 'clean:demo', 'copy:demo', 'uglify:demo'
193+
]);
194+
grunt.registerTask('dist', [
195+
'default', 'clean:dist', 'browserify:dist', 'uglify:dist'
196+
]);
197+
grunt.registerTask('release', [
198+
'test', 'dist', 'demo', 'clean:interactive'
183199
]);
184-
grunt.registerTask('dist', ['default', 'clean:dist', 'browserify:dist', 'uglify:dist']);
185-
grunt.registerTask('release', ['test', 'dist', 'demo']);
186200
};

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ There interactive demo of the parser hosted
2121
[at this location](http://codeschool.github.io/sqlite-parser/demo/). The source
2222
for the interactive demo exists in the `demo/` folder of this repository. You
2323
can serve a LiveReload version of the demo on your local machine by running
24-
`grunt interactive`.
24+
`grunt live`.
2525

2626
## Install
2727

0 commit comments

Comments
 (0)