pattern-lab / patternlab-node-cli Goto Github PK
View Code? Open in Web Editor NEWMoved to https://github.com/pattern-lab/patternlab-node/tree/dev/packages/cli
License: MIT License
Moved to https://github.com/pattern-lab/patternlab-node/tree/dev/packages/cli
License: MIT License
v3
wrapAsync()
back to async/await
(already done in local branch as we started with async/await)edition
use case and how to use the CLI within different build toolsShould we re-add support for Node v4?
/cc @bmuenzenmeyer
Add install step to readme.md
Pattern Lab CLI isn't properly watching and rebuilding patterns after changes are made.
Install CLI
$ npm install pattern-lab/patternlab-node-cli --save-dev
Create npm tasks to use the CLI actions
"pl:init": "patternlab init",
"pl:build": "patternlab build --config ./patternlab/patternlab-config.json",
"pl:serve": "patternlab serve --config ./patternlab/patternlab-config.json",
Init new PL project
$ npm run pl:init
? Please specify a directory for your PatternLab project. patternlab
? Which edition do you want to use (defaults to edition-node)? edition-node-gulp
? Which starterkit do you want to use? starterkit-mustache-demo
? Are you happy with your choices? (Hit enter for YES)? Yes
$ npm run pl:serve
...
Ready for changes
Serving "C:\...\my-project\patternlab\public" at http://127.0.0.1:8080
GET / 404 8.031 ms - 139
First Issue
Here theserver
task does not run thebuild
task before launching server.
Next step:
$ npm run pl:build
PL build task goes through and generate everything inside public.
$ npm run pl:serve
Here, PL serve
task starts serving the patterns at 8080. Everything's looks fine. However, there is no watching happening upon any file changes (source/css/style.css or source/_patterns etc). This is also the behavior even if I add the --watch
flag to pl:serve or pl:build
Additional info:
pl:init
as shown above installs these dependencies to the project:
{
...
"dependencies": {
"@pattern-lab/starterkit-mustache-demo": "^4.0.4",
"edition-node-gulp": "^1.4.0"
}
}
Add support for project that use yarn package manager instead of npm.
patternlab export
breaks due to TypeError: Cannot read property 'pipesCount' of undefined
Related: archiverjs/node-archiver#236
Proposal: patternlab config set <key> <value>
Fix const
binding in test/replace_config_paths.test.js for Node v4
When invoking an unknown command show the man page.
patternlab init throws an error
OSX version 10.10.5
After running patternlab init I get the following error:
if (err) { throw err; }
^
Error: ENOENT: no such file or directory, scandir '/Users/benhalverson/projects/pl-test/node_modules'
at Object.fs.readdirSync (fs.js:871:18)
at diveSync (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/diveSync/diveSync.js:30:19)
at findEngineModulesInDirectory (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:37:3)
at /Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:58:28
at Array.forEach (native)
at loadAllEngines (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:57:22)
at Object.<anonymous> (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:183:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)```
### Reproduction steps
npm i -g pattern-lab/patternlab-node-cli
patternlab init
npm ERR! missing: @pattern-lab/starterkit-twig-demo@github:pattern-lab/starterkit-twig-demo, required by [email protected]
npm ERR! peer dep missing: react@^15.0.2 || ^0.14.8, required by [email protected]
npm ERR! peer dep missing: react@^0.14.0 || ^15.0.0, required by [email protected]
https://github.com/pattern-lab/patternlab-node-cli/blob/master/bin/init.js#L101-L160
Keep in-sync with core
pattern-lab/patternlab-node#780
braindump, intended to start discussion. nothing here is prescriptive.
At any time, a user should be able to ask the PL CLI what starterkits are available for download.
Current exposed command on editions:
Proposed CLI command:
patternlab starterkit --install
With no additional parameters, perhaps it suggest like https://github.com/pattern-lab/patternlab-node-cli/blob/master/bin/init.js#L236
Proposed option:
patternlab starterkit --install --starterkit-mustache-demo
With this option, it reaches out to install from npm if needed, and then installs similar to
With the patternlab cli, there is no way to report the current core version. Today people can do this with gulp patternlab:version
Now that I am removing PL boilerplate logs (pattern-lab/patternlab-node#636) it would be nice if the CLI could also report the version of core.
This would be similar to how gulp -v
works too (which reports the local and then the global version)
patternlab --version
According to the documentation, I should be able to run patternlab -V
to emit the CLI version. Other commands have this lowercased, such as help and config. Is there a reason why this is inconsistent, or is it just the README that needs updating. I'd think that lowercase is preferred in most cases, if not both.
disregard most of above, kept for records...
I did a patternlab -h
to see how it emits the help and just now noticed the verbose flag, so perhaps only the documentation needs updating to explain that option too.
Merge back tests.
Fail hard on unrejected promises.
Add .travisyml to run tests …
Add a benchmarking suite.
Related to pattern-lab/patternlab-node#561
When running patternlab init
and interactively setting up a new project, I cannot arrow through edition options.
I wonder if this has to do with the node version, or the OS?
This is a must-have for all PatternLab power users, so that they can specify their own paths to watch
Add issue and PR templates.
Adding reload('*.js')
.
pattern-lab/edition-node-gulp#92
Add more content about usage etc. to the readme
Add event-based logger so that a --verbose
flag can be easier implemented
Tidy up logs eg. remove the patternlab
bit from it as it is automatically prepended via logger
Implement a global install
command to install starterkits and plugins.
execa
to replace promisified child_process
Extend docs to explain all cli options. See #21
Add a better progress indicator when the cli initialises (or installs) needed components.
replaceConfigPaths is adding unnecessary styleguide
and patternlabFiles
keys to patternlab-config.json
We e2e tests land, a CI solution has to be established. PL core uses Travis … so might opt for that. Any suggestions from PL node team welcome :>
/cc @pattern-lab/node
Remove vestigial configuration entries
Remove outdated configuration. Probably already subsided via getDefaultConfig
Running the CLI results in
patternlab init
Loading engines from the core...
Loading engines from the edition or test directory...
mustache: good to go
Done loading engines.
====[ Pattern Lab / Node - v2.7.1 ]====
Update readme with yarn instructions.
When I type patternlab init
, all I get back is:
Loading engines from the core...
Loading engines from the edition or test directory...
but nothing else.
npm install -g pattern-lab/patternlab-node-cli
npm install @pattern-lab/patternlab-node
npm init
Switch the default starterkit from starterkit-mustache-demo
to starterkit-mustache-base
braindump, intended to start discussion. nothing here is prescriptive.
At any time, a user should be able to install a plugin.
Current exposed command on editions/core:
Plugin installation is a bit one-two stepped right now, with users needing to npm install
first and then either call the above or even npm run postinstall
, so it'd be nice if we could get all that into one method.
patternlab plugin --install --plugin-node-tab
This could reach out to npm if plugin-node-tab is not found already locally, and do everything for the user.
Future commands to enable/disable would be nice too, as mentioned here: https://github.com/pattern-lab/plugin-node-tab#enabling--disabling-the-plugin
watches have already been discussed inside #23
I am going to break down the remaining browsersync config on the patternlab:connect
gulp task found within edition-node-gulp's gulpfile: https://github.com/pattern-lab/edition-node-gulp/blob/master/gulpfile.js
gulp.task('patternlab:connect', gulp.series(function(done) {
browserSync.init({
server: {
baseDir: resolvePath(paths().public.root)
},
snippetOptions: {
// Ignore all HTML files within the templates folder
blacklist: ['/index.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'
]
}
}, function(){
console.log('PATTERN LAB NODE WATCHING FOR CHANGES');
done();
});
}));
server: {
baseDir: resolvePath(paths().public.root)
},
the server baseDir
command should map to the above always, which is again configurable by the user and supplied within patternlab-config.json
✔️
snippetOptions: {
// Ignore all HTML files within the templates folder
blacklist: ['/index.html', '/', '/?*']
},
this option prevents the PL chrome from refreshing, preserving a user's scroll position, while updating the iframe content (the patterns). we should be able to safely do this blackbox for users without any problem
✔️
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'
]
}
Geoff added this override of the default snippet to make it less obtrusive for users. It could probably be blackboxed too. If someone really wants to change it, we can look into ways I suppose. Understanding what class, if any, there is on that, and if it's accessible via the pattern-scaffold.css
file that we load might be all we need.
✔️
function(){
console.log('PATTERN LAB NODE WATCHING FOR CHANGES');
done();
});
It'd be nice if we had a way to provide users with a callback like this after BS starts. I have a feeling, this being a CLI, that we will be able to do just that.
✔️
@raphaelokon does this help clarify what is needed, along with the other issue?
Add following feature:
patternlab enable --plugins=plugin-name1, plugin-name2
patternlab disable --plugins=plugin-name1, plugin-name2
Silences all cli output. Involves a more gradual logger behaviour
Add a check if starter kits are already present in node_modules
patternlab serve
launches BrowserSync, which reports that it is watching for changes.
Long-term, this should not be the responsibility of the CLI, nor the `serve1 command.
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.