gruntjs / grunt-init-gruntfile Goto Github PK
View Code? Open in Web Editor NEWCreate a basic Gruntfile with grunt-init.
Create a basic Gruntfile with grunt-init.
running grunt-init gruntfile results in:
Please answer the following:
[?] Is the DOM involved in ANY way? (Y/n) (node:30284) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use node --trace-warnings ...
to show where the warning was created)
Using the ? results in:
?
Fatal error: util.error is not a function
Please help, I have just installed latest grunt-cli (1.4.3) and made sure to upgrade npm (10.1.0), node (20.7.0)
Works great however under "Usage" section of readme.md instead of :-
grunt-init gruntfile
I think it should be :-
grunt-init grunt-init-gruntfile
Love this tool and grunt too btw. ๐
With github newbies,
git clone https://github.com/gruntjs/grunt-init-gruntfile.git
is more full proof than
git clone [email protected]:gruntjs/grunt-init-gruntfile.git
which can give way to a puzzling "Permission denied (publickey)."
Hey,
it's quite obvious that developers using the package.json will add the necessary attributes like name and homepage themselves, but for first time users it might be confusing that this grunt template's grunt tasks fails due to missing package attributes (used in the banner config). The outputted warning with a fresh install is:
Running "concat:dist" (concat) task
Warning: An error occurred while processing a template (Cannot read property 'name' of undefined). Use --force to continue.
Should the generated package.json include placeholders or empty values for all attributes used in the banner, and maybe when using the package.json generator print a notice to edit those.
I can provide a PR for this, if needed.
I'd like this to support coffeescript Gruntfiles. Is that something that's already available, or there's any interest in?
no matter what you answer to "will you have a package.json file"
I just grabbed the latest "grunt-init-gruntfile" repo (~1 hour ago) from GitHub. When I did a grunt-init
with it, though, the resulting "Gruntfile.js" had tasks for qunit
but did a loadNpmTasks("grunt-contrib-nodeunit")
instead of grunt-contrib-qunit
. Honestly, I'm not sure which was the intended result.
Here is how I answered the grunt-init
prompts:
Resulting Gruntfile.js:
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
// Task configuration.
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['lib/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
gruntfile: {
src: 'Gruntfile.js'
},
lib_test: {
src: ['lib/**/*.js', 'test/**/*.js']
}
},
qunit: {
files: ['test/**/*.html']
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib_test: {
files: '<%= jshint.lib_test.src %>',
tasks: ['jshint:lib_test', 'qunit']
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task.
grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
};
Looks like there could be a few other minor problems as well, e.g. should it have made a ".jshintrc" file instead of declaring the options in the "Gruntfile.js"?
The docs don't mention anywhere that this will nuke the existing package.json - when I said "yes" when asked if I "will have a package.json", I didn't mean that I wanted it destroyed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.