Skip to content
This repository was archived by the owner on Mar 27, 2019. It is now read-only.

Add display/setting of default values in component-create. #362

Closed

Conversation

timoxley
Copy link
Contributor

This adds some items of functionality relating to component-create's default values:

Prevents crash when not supplying username/repo for non-local components

Instead it just prompts user to fix, keeping all existing values (resolves #352).

> component-create /tmp/test-component
repo (username/project): [timoxley/test-component] nousername
description: a description
does this component have js? [yes]
does this component have css? [yes] no
does this component have html? [yes] no
  repo must be <username>/<project> : nousername
repo (username/project): [nousername] user/username
description: [a description]
does this component have js? [yes]
does this component have css? [no]
does this component have html? [no] yes

      create : /tmp/test-component
      create : /tmp/test-component/index.js
      create : /tmp/test-component/template.html
      create : /tmp/test-component/Makefile
      create : /tmp/test-component/Readme.md
      create : /tmp/test-component/History.md
      create : /tmp/test-component/.gitignore
      create : /tmp/test-component/component.json

Sets default project repo/name to be $USER + CWD

> component-create /tmp/test-component
repo (username/project): [timoxley/test-component]
description:
does this component have js? [yes]
does this component have css? [yes]
does this component have html? [yes]

      create : /tmp/test-component
      create : /tmp/test-component/index.js
      create : /tmp/test-component/template.html
      create : /tmp/test-component/test-component.css
      create : /tmp/test-component/Makefile
      create : /tmp/test-component/Readme.md
      create : /tmp/test-component/History.md
      create : /tmp/test-component/.gitignore
      create : /tmp/test-component/component.json

or just CWD for local components:

> component-create --local locals/test
name: [test]
description:
does this component have js? [yes]
does this component have css? [yes]
does this component have html? [yes]

      create : locals/test
      create : locals/test/index.js
      create : locals/test/template.html
      create : locals/test/test.css
      create : locals/test/component.json

Also displays default values in [ & ]if they exist.

May want to consider something that allows setting default user to something other than $USER.

@timoxley
Copy link
Contributor Author

I wonder if defaults functionality could be added directly to commander.js.

@timoxley
Copy link
Contributor Author

Also, no tests because there were no tests for component-create. you know, broken windows and all that. I could knock some up I guess.

@timoxley
Copy link
Contributor Author

bump

@tj
Copy link
Contributor

tj commented Oct 27, 2013

we could maybe check for ~/.gitconfig:

[github]
    user = visionmedia

@tj
Copy link
Contributor

tj commented Oct 27, 2013

little overkill maybe

@timoxley
Copy link
Contributor Author

ahh you could tap into the github config inheritance thing using git config github.user, but would require an async call to child_process.exec, which makes the code more ugly as everything else in here is sync…

@jonathanong
Copy link
Contributor

oh god why wasn't this merged. i used component create for the first time the other day and was like "WHERE ARE THE DEFAULTS, MAN!?"

@jonathanong
Copy link
Contributor

componentjs/create.js#5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

component-create: prompt instead of error on invalid repo
4 participants