pattern-lab / edition-node-grunt Goto Github PK
View Code? Open in Web Editor NEWThe grunt wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.
License: MIT License
The grunt wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.
License: MIT License
I am using Edition Node Grunt v1.0.1
on Mac
, with Node v6.9.4
.
If I change a *.js file after running patternlab:serve the page should be updated like if I change a CSS file.
Nothing is updated.
I am using Edition Node Grunt v2.12.0
on Linux
, with Node v10.6.0
.
Running grunt patternlab:serve runs pattern lab
Error
====[ Pattern Lab / Node - v2.12.0 ]====
Loading "Gruntfile.js" tasks...ERROR
TypeError: Cannot read property 'options' of undefined
at pluginInit (/home/juanfernandes/sites/design-framework/node_modules/plugin-node-tab/index.js:64:66)
at initializePlugins (/home/juanfernandes/sites/design-framework/node_modules/patternlab-node/core/lib/patternlab.js:135:7)
at patternlab_engine (/home/juanfernandes/sites/design-framework/node_modules/patternlab-node/core/lib/patternlab.js:183:3)
at Object.module.exports (/home/juanfernandes/sites/design-framework/Gruntfile.js:24:36)
at loadTask (/home/juanfernandes/sites/design-framework/node_modules/grunt/lib/grunt/task.js:315:10)
at Task.task.init (/home/juanfernandes/sites/design-framework/node_modules/grunt/lib/grunt/task.js:434:5)
at Object.grunt.tasks (/home/juanfernandes/sites/design-framework/node_modules/grunt/lib/grunt.js:111:8)
at Object.module.exports [as cli] (/home/juanfernandes/sites/design-framework/node_modules/grunt/lib/grunt/cli.js:27:9)
at Object. (/usr/local/lib/node_modules/grunt-cli/bin/grunt:44:20)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:236:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
Running tasks: patternlab:serve
Warning: Task "patternlab:serve" not found. Use --force to continue.
My gruntfile:
/******************************************************
module.exports = function (grunt) {
var path = require('path'),
argv = require('minimist')(process.argv.slice(2));
// load all grunt tasks
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browser-sync');
grunt.loadNpmTasks('grunt-contrib-sass');
/******************************************************
//read all paths from our namespaced config file
var config = require('./patternlab-config.json'),
pl = require('patternlab-node')(config);
function paths() {
return config.paths;
}
function getConfiguredCleanOption() {
return config.cleanPublic;
}
grunt.registerTask('patternlab', 'create design systems with atomic design', function (arg) {
if (arguments.length === 0) {
pl.build(function(){}, getConfiguredCleanOption());
}
if (arg && arg === 'version') {
pl.version();
}
if (arg && arg === "patternsonly") {
pl.patternsonly(function(){},getConfiguredCleanOption());
}
if (arg && arg === "help") {
pl.help();
}
if (arg && arg === "liststarterkits") {
pl.liststarterkits();
}
if (arg && arg === "loadstarterkit") {
pl.loadstarterkit(argv.kit, argv.clean);
}
if (arg && (arg !== "version" && arg !== "patternsonly" && arg !== "help" && arg !== "starterkit-list" && arg !== "starterkit-load")) {
pl.help();
}
});
grunt.initConfig({
/******************************************************
* COPY TASKS
******************************************************/
copy: {
main: {
files: [
{ expand: true, cwd: path.resolve(paths().source.js), src: '**/*.js', dest: path.resolve(paths().public.js) },
{ expand: true, cwd: path.resolve(paths().source.js), src: '**/*.js.map', dest: path.resolve(paths().public.js) },
{ expand: true, cwd: path.resolve(paths().source.css), src: '**/*.css', dest: path.resolve(paths().public.css) },
{ expand: true, cwd: path.resolve(paths().source.css), src: '**/*.css.map', dest: path.resolve(paths().public.css) },
{ expand: true, cwd: path.resolve(paths().source.images), src: '**/*', dest: path.resolve(paths().public.images) },
{ expand: true, cwd: path.resolve(paths().source.fonts), src: '**/*', dest: path.resolve(paths().public.fonts) },
{ expand: true, cwd: path.resolve(paths().source.root), src: 'favicon.ico', dest: path.resolve(paths().public.root) },
{ expand: true, cwd: path.resolve(paths().source.styleguide), src: ['*', '**'], dest: path.resolve(paths().public.root) },
// slightly inefficient to do this again - I am not a grunt glob master. someone fix
{ expand: true, flatten: true, cwd: path.resolve(paths().source.styleguide, 'styleguide', 'css', 'custom'), src: '*.css)', dest: path.resolve(paths().public.styleguide, 'css') }
]
}
},
/******************************************************
* SERVER AND WATCH TASKS
******************************************************/
watch: {
all: {
files: [
path.resolve(paths().source.scss + '**/*.scss'),
// path.resolve(paths().source.css + '**/*.css'),
path.resolve(paths().source.styleguide + 'css/*.css'),
path.resolve(paths().source.patterns + '**/*'),
path.resolve(paths().source.fonts + '/*'),
path.resolve(paths().source.images + '/*'),
path.resolve(paths().source.data + '*.json'),
path.resolve(paths().source.js + '/*.js'),
path.resolve(paths().source.root + '/*.ico')
],
tasks: ['default', 'bsReload:css']
}
},
sass: {
options: {
style: 'expanded'
},
dist: {
files: {
'source/css/style.css': 'source/scss/style.scss'
}
}
},
browserSync: {
dev: {
options: {
server: path.resolve(paths().public.root),
watchTask: true,
watchOptions: {
ignoreInitial: true,
ignored: '*.html'
},
snippetOptions: {
// Ignore all HTML files within the templates folder
blacklist: ['/index.html', '/', '/?*']
},
plugins: [
{
module: 'bs-html-injector',
options: {
files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')]
}
}
],
notify: {
styles: [
'display: none',
'padding: 15px',
'font-family: sans-serif',
'position: fixed',
'font-size: 1em',
'z-index: 9999',
'bottom: 0px',
'right: 0px',
'border-top-left-radius: 5px',
'background-color: #1B2032',
'opacity: 0.4',
'margin: 0',
'color: white',
'text-align: center'
]
}
}
}
},
bsReload: {
css: path.resolve(paths().public.root + '**/*.css')
}
});
/******************************************************
grunt.registerTask('default', ['patternlab', 'sass', 'copy:main']);
grunt.registerTask('patternlab:build', ['patternlab', 'sass', 'copy:main']);
grunt.registerTask('patternlab:watch', ['patternlab', 'sass', 'copy:main', 'watch:all']);
grunt.registerTask('patternlab:serve', ['patternlab', 'sass', 'copy:main', 'browserSync', 'watch:all']);
};
I cd into my sites/design-framework folder and run: grunt patternlab:serve
Add support for pattern-lab/patternlab-node#448
I am using Edition Node Grunt v1.2.0
on Linux
, with Node v2.7.2
.
Using grunt patternlab:loadstarterkit --kit=[kit]
yields
Running "patternlab:loadstarterkit" (patternlab) task
Attempting to load starterkit from edition-node-grunt/node_modules/starterkit/dist
Overwriting contents of ./source/ during starterkit load.
Done.
It does the above but also shows the help. Still, loadstarterkit
is executed, which could irritate users.
Execute grunt patternlab:loadstarterkit --kit=[kit]
on Version 1.2.0.
I am using Edition Node Grunt v1.1.0
on Windows
, with Node v6.5.0
.
Installation as dependecy works
postinstall script throws Exception after installation
mkdir test
cd test
npm init
npm install --save edition-node-grunt
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN prefer global [email protected] should be installed with -g
> [email protected] postinstall C:\Users\schleuse\Desktop\test\node_modules\edition-node-grunt
> node node_modules/patternlab-node/core/scripts/postinstall.js
module.js:457
throw err;
^
Error: Cannot find module 'C:\Users\schleuse\Desktop\test\node_modules\edition-node-grunt\node_modules\patternlab-node\core\scripts\postinstall.js'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\schleuse\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "edition-node-grunt"
npm ERR! node v6.5.0
npm ERR! npm v3.10.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: `node node_modules/patternlab-node/core/scripts/postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node node_modules/patternlab-node/core/scripts/postinstall.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the edition-node-grunt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node node_modules/patternlab-node/core/scripts/postinstall.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs edition-node-grunt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls edition-node-grunt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\schleuse\Desktop\test\npm-debug.log
During WDD 2016 one user reported errors in what appeared to be core Node code. The only difference between his rig and mine that I could tell was the Node version, me being on 5.5.X
and him being on 6.X.X
At least
I am using Edition Node Grunt v2.3.0
on Mac
, with Node v4.4.7
.
According to grunt patternlab:help
, grunt patternlab:liststarterkits
should list the available starterkits. grunt patternlab:loadstarterkit --kit=[starterkit-name]
should copy the starterkit files to ./source/
.
Both commands/tasks just show the Pattern Lab Node Help.
Enter either grunt patternlab:liststarterkits
or grunt patternlab:loadstarterkit --kit=[starterkit-name]
. (Tested in master
and dev
.)
Apparently, the proper commands are grunt patternlab:starterkit-list
and grunt patternlab:starterkit-load --kit=[starterkit-name]
(figured that out looking at the Gruntfile.js
). Probably just “legacy documentation” (in the README and patternlab:help
)?
I am using Edition Node Grunt v2.3.0
on Mac
, with Node v4.4.7
.
grunt patternlab:starterkit-load --kit=[starterkit-name]
should copy the files from node_modules/[starterkit-name]/dist
to ./source/
.
Task runs with proper output/path names etc., but does not actually copy any files (tested with starterkit-mustache-demo
in master
and dev
).
npm install starterkit-mustache-demo
grunt patternlab:starterkit-load --kit=starterkit-mustache-demo
Here's a gist of the output that I get for this. ./source/_patterns/
remains empty.
Is there a reason this isn't set up as a grunt plugin for easy installation and configuration using grunt.loadNpmTasks('edition-node-grunt')
and grunt.initConfig
instead of the config.json file?
This would avoid the mess that occurs if one wanted to run patternlab node as a npm dependency.
Summary
When linking patterns in other patterns it requires the patternType to be prefixed before the pattern.
E.g. {{> promos-promo-1 }}
It'd be great if there were a way around this.
Use Case
I'm using the _patterns
folder as a central source for handlebars files to be used in Pattern Lab and in my Yeoman generator. Pattern Lab serves as my documentation and patterns source, while the Yeoman generator is my scaffolding for projects that utilizes the handlebars files in Pattern Lab.
Issue
The issue I'm running into is including patterns in other patterns causes errors in my generator because a linked pattern like {{> promos-promo-1 }}
only works in Pattern Lab.
My current solution is utilizing regex to remove all the prefixes, allowing the original (unprefixed) handlebars file {{> promo-1 }}
to work.
I am using Edition Node Grunt v2.3.0
on Windows
, with Node v6.3.1
.
The Creation of new patterns should trigger the watcher to rebuild patternlab.
Nothing happens when new patterns are created. I have to restart my watch-task to trigger a rebuild.
Start the Watcher.
Create a new pattern.
See nothing happen.
Seems to be a general issue with grunt-contrib-watch
or more specifically fs.watch
(gruntjs/grunt-contrib-watch#282)
My current workaround is to remove the call of path.resolve(...)
around the paths that should be watched. Absolute paths seem to mess with grunt-contrib-watch
Running grunt patternlab:build
generates the front-end of Pattern Lab
Running grunt patternlab:build
does nothing (except output the help text)
public/
directorygrunt patternlab:build
taskpublic/
directory has not been created/populatedShould just be a case of adding the task alias to Grunt. PR incoming.
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.