infinitered / gluegun Goto Github PK
View Code? Open in Web Editor NEWA delightful toolkit for building TypeScript-powered command-line apps.
License: MIT License
A delightful toolkit for building TypeScript-powered command-line apps.
License: MIT License
These files are pretty much copy & paste of each other:
Do the right thing.
For printing the header in the CLI, if we're in brand mode, we will do the first of this list:
brand/header.js
brand/header.txt
as straight up textWe only show the gluegun header if we're not in branded mode.
Will need to setup CI to protect this code base from myself.
I've only used semaphore, but I'm open to anything really.
brew install nodejs
npm i -g n
n 7.2
npm i -g yarn
git clone [email protected]/skellock/gluegun
cd gluegun
npm i
cd packages/gluegun
yarn
yarn test
yarn run lint
yarn run watch
git branch fun
# furious typing
git commit -m "Adds fun"
# submit a PR with an awesome gif
# win
These two would be great additions to our filesystem extension:
context.filesystem.eol
= os.EOL
is https://nodejs.org/api/os.html#os_os_eol
context.filesystem.separator
= path.sep
is https://nodejs.org/api/path.html#path_path_sep
When invoking gluegun
, it currently shows all commands. This could quickly spiral. Let's switch to this:
gluegun
# show a list of namespaces
gluegun something
# show a list of commands in the something namespace
Currently we capture errors, tuck them away, and never show them.
https://github.com/infinitered/gluegun/blob/master/packages/gluegun/src/domain/runtime.js#L141
Instead of forcing CLI's to print these with:
const context = await runtime.run()
if (context.error) {
context.print.error(error.message)
context.print.debug(context.error)
}
Let's add a new builder function called .rethrowErrorsWhenRunning(true)
that people can opt-into when developing.
@GantMan pointed out that commander has a dsl that might work well for us.
We could use that in the front matter for the *.js files by including it:
@command name <thing> [otherThing]
Also, lets promote & clobber onto the context.parameters
object the things the user names (e.g. thing
and otherThing
).
Allow templates to be pseudo-forked.
Provide some kind of directory we can copy the *.njk
files to. When we then run a generate()
call, if the template has been overridden, we'll call that one instead.
This configuration will be handled in the app's configuration file.
I just donned on me that we might conflicting with other jsdoc things or whatever.
Let's prefix ours with @gg-name
, etc
And put a way to execute async and capture output in it.
Inside the app .toml
file, let's add:
[defaults]
silent = true
When true (default is false), it will suppress all print commands triggered through the print extension.
There's no tests in the CLI. It kinda just grew and grew until it started doing important things. Now it needs tests.
Let's setup coveralls. I know my tests coverage is slipping, but having an automated score will motivate me.
Let's add another few paths to the mix.
~/.gluegun/plugins/*
These are the gateway to the system. And they've become a bit messy now. Let's clean these up so people wanting to hack at the core aren't confused.
It still says 'staple gun'.
This was unhinged when I switched from inquirer
to enquirer
.
Let's put a version back that works.
Currently we have
.load('one_plugin_dir') // loads a directory as plugin
.loadAll('many_plugins_dir') // loads the immediate sub-directories as plugins
But what we could use this as well:
.loadAll('node_modules', 'ignite-*') // same, but only ones that match a jetpack pattern
Plugins have unique names. I call these namespaces. But there's nothing magical or special about them. I'm thinking for simplicity sake, change the name from "namespace" to "name".
Namespace seems to imply there's stuff to learn. But there isn't. It's just a name.
Then the description of the command line goes:
<cliname> <pluginname> <commandname>
Right now the identification of the meta tags are looking for // @
. That's misleading because of JavaScript's other style of commenting.
Let's support both.
We need a way to load the extensions dynamically from plugins. The sample way we do it with commands
, but this time from an extensions
directory.
I'd like to be language independent, so let's get out of the js
wheelhouse for configuration.
The printWtf script should be opened up so we can see which plugins & commands & extensions aren't loading and why.
Right now when you generate
files, the root is the plugin's root. Let's change this to be the templates
sub directory.
And put fs-jetpack
in it.
@GantMan suggested this.
And put inquirer in it.
Currently a command can't live on it's own. It needs to live under a namespace.
With spork
, i made that name space. And since namespaces aren't commands, you can't just type it. So I created default
as the command.
So now it's:
gluegun spork default
Which is lame.
I want:
gluegun spork
.
So we need to build the concept of a default command. default.js
would be fine, but I think index.js
is a little nicer because of the convention on the web and React Native.
Prevent these namespaces from being defined in 3rd party plugins:
If we see those namespaces, we should just go into a badnamespace
error state on the plugin.
When a plugin, extension, or command is in a bad state, there's no way of knowing. Let's provide a --debug
flag people can run which will emit the errors somehow.
This seems to be broken after a batch of refactoring. The tests didn't seem to catch this.
https://github.com/infinitered/gluegun/blob/master/docs/context-api.md
not inquirer anymore
Let's make this askToOverwrite
prompt be more like askYesOrNo
or something like that.
We can pass in { message: 'something', yes: 'Yup', no: 'Newp' }
or something like that.
@GantMan helped me clarify what I was after. ๐ฎ
As violent delights have violent ends, so do default commands have unpruned params
-- Dolores
running ignite add ui
gives parameters.first
the value of "default"
This looks like some leakage.
๐ Bikini Bonus:
Would be helpful to have parameters.last
- which is how I plan on fixing this for futureproof ways. But I'm not a fan of that method.
We would like support for hidden plugins & commands.
This is useful if CLIs want to have their own plugins in the gluegun plugin format, but prevent the end user from having to know of them.
You would still be able to call these from runtime.run({})
.
I recommend adding an object as a 2nd parameter to:
.load('dir', { hidden: true })
.loadDefault('dir', { hidden: true })
.loadAll('dir', { hidden: true })
Problem is, loadAll
already has an optional 2nd parameter for matching sub-directories, so let's upgrade that to:
.loadAll('dir', { hidden: true, matching: 'ignite-*' })`
This would be a breaking change, but now is the time!
Allow a command line option to pass to the CLI which specifies a default namespace.
gluegun --gluegun-namespace ignite
This namespace then gets priority over all others. In fact, it will be checked even before the other namespace names.
This allows people to brand their own cli like: alias ignite="gluegun --gluegun-namespace ignite"
or even in their package.json
bin
scripts.
I'd like to see a string extension. These would be the things that are automatically placed on the filters list in nunjucks
. Let's grow this slowly and start with the cases that we already put into the generate
extension.
They're useful to many people, so let's hang them on context.
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.