Code Monkey home page Code Monkey logo

builder-init's People

Contributors

coopy avatar exogen avatar ryan-roemer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

builder-init's Issues

Feature: Add `archetypePackage` helper variable with the full `package.json` from archetype.

Goals / Task

  • Make <archetype>[dev/|]/package.json available as template data.

Original Proposal

So that you can do this in init/package.json:

  "dependencies": {
    "builder": "~2.2.0",
    "builder-react-component": "^<%= archetypePackage.version %>"
  },
  "devDependencies": {
    "builder-react-component-dev": "^<%= archetypePackage.version %>",
    "chai": "^3.2.0",
    "mocha": "^2.3.3",
    "react": "^0.14.0",
    "react-addons-test-utils": "^0.14.0",
    "react-dom": "^0.14.0",
    "sinon": "^1.17.2",
    "sinon-chai": "^2.8.0"
  }

This probably obviates the need to implement FormidableLabs/builder-support#7

/cc @chaseadamsio

Feature: Documentation / usage

  • Basic usage section
  • File layout: init.js, init/
  • Example: Init from local file.
  • Example: Init from github.
  • Example: Init from npm.
  • Note: Destination directories cannot already exist.

Feature: Add a task to generate a class

It would be great if there is a command that could auto generate a class and a spec file for the class.

For e.g. builder run generate MyClass would generate MyClass and also generate a spec file for the class.

Feature: Allow `builder-init` to exclude template files.

Two strawmen options:

  1. Put it in init.js as an "excludes: FUNCTION" thing that gets the finished data object from all user prompts and derived promptes and can then be applied to the output, resolved file list.
  2. Have something in the โ€‹_template files themselves_โ€‹ that enables / hooks to "don't write this file at all"
module.exports = {
  prompts: {
    redux: {
      message: "Create a Redux-aware component?",
      default: false
    },
  },

  excludes: (data, fileList, cb) {
    fileList = fileList.filter(function (name) {
      // Exclude redux files if no redux.
      if (!data.redux && /src\/[actions|reducersmiddleware]\//.test(name) {
        return false;
      }

      return true;
    });

    cb(null, fileList);
  }
};

Feature: Detect missing `init.js` data fields used in templates

Scenario: We have a templates in <archetype>/init/ that have some data field that is not gathered / created in <archetype>/init.js

Task:

  • Add some way of inferring all needed props in templates and erroring if not present
  • Complexity: But, need to handle props that can be empty... (shouldn't be an issue?)

Feature: Logger

  • Use logging of certain features like builder.
  • Logging levels (or punt to builder ticket)
  • Maybe a builder-logger project?

Multiple init folders - select by choice in init.js?

I don't know if this is already possible and I missed it.

I'd like to have multiple different init folders like

+ init-react
+ init-reactwithrouter
+ init-somethinelse

and I'd like to allow the user when running builder-init to choose which one to use.

Is this possible already or would this need to be implemented?

Doc Bug: `require` is not supported in init.js

I'm trying to use the "File Name Parsing" feature of builder-init:

This works (https://github.com/plotly/dash-components-archetype/tree/template-file-name-prompt):

  • I have in init.js a {{packageName}} prompt
  • I have an init/{{packagename}}.txt file

Result:

~/dev/plotly/test$ builder-init "`pwd`/../dash-components-archetype"
dash-components-archetype-0.1.3.tgz
[builder-init] Preparing templates for: dash-components-archetype
? Please name your component suite. foo-prompted
? Enter a description Dash UI component suite
? GitHub organization or user name
? License organization (e.g., you or your company)
? Destination directory to write foo-prompted

[builder-init] Wrote files:
 - foo-prompted/.babelrc
 - foo-prompted/.builderrc
 - foo-prompted/LICENSE.txt
 - foo-prompted/README.md
 - foo-prompted/package.json
 - foo-prompted/.eslintrc
 - foo-prompted/.gitignore
 - foo-prompted/.npmignore
 - foo-prompted/foo-prompted.txt
 - foo-prompted/src/index.js
 - foo-prompted/src/components/ExampleComponent.react.js

[builder-init] New dash-components-archetype project is ready at: foo-prompted

This does not work (https://github.com/plotly/dash-components-archetype/tree/template-file-name-derived):

  • I have in init.js a {{capitalCamelCasePackageName}} derived field
  • I have an init/{{capitalCamelCasePackageName}}.txt file

Result:

EDITED: I copy-pasted the wrong error here before.

~/dev/plotly/test$ builder-init "`pwd`/../dash-components-archetype"
dash-components-archetype-0.1.3.tgz
[builder-init] Preparing templates for: dash-components-archetype
? Destination directory to write yeah-man
Error: Unknown token: 'capitalCamelCasePackageName' for path: /var/folders/dr/4nn6l7t17cvdjcmx6tdtvgrr0000gp/T/builder-init116530-32509-elt0x8/extracted/init/{{capitalCamelCasePackageName}}.txt

Note: When using the derived field, the first prompt is "? Destination directory to write", not "? Please name your component suite."

Repro:

git clone [email protected]:plotly/dash-components-archetype.git
cd dash-components-archetype
git checkout template-file-name-derived
npm install

cd ..
npm install -g builder-init
builder-init "`pwd`/../dash-components-archetype"
# now enter a valid package name like "foo-component-suite"

Feature: License chooser

Probably as external plugin. Provide an easy way of "choose a license enum + files".

  • Options: MIT, BSD, GPL, Apache, etc.

Feature: Filter `init/*` templates and ignore appropriately.

Scenario: We potentially have non-git-included extra files in <archetype>/init/ that we want to ignore and not process (like .DS_Store, etc.)

Task:

  • Apply a filter to only process non-.gitignore-ed files from archetype (E.g., /Users/rye/scm/fmd/builder-react-component/init/.DS_Store)

Feature: Run `scripts` placed in `init.js` after project initialization.

Research and add a scripts functionality for things like having a project after initialization do:

$ npm install
$ node_modules/.bin/builder run check-ci

Task:

  • Research scripts use cases and implement.
  • Consider defaults tasks like npm install if nothing supplied.
    • Allow user to override and have "nothing" run

Feature: Install from various sources

  • Do actual CLI with arguments and flags (share with builder?)
  • From NPM (at a version?)
  • From filesystem
  • From GitHub / generic git (at a version?)
  • Maybe do GH ORG/PROJECT shortcut if possible (?) (Like use npm internals)
  • Hook up to Travis CI to actually init an archetype and run the new project's CI commands.

Optional:

  • builder-init help #5
  • init.js:scripts #12

"builder-init builder-react-component" fails on Windows

On my Windows 10 machine with node 5.6.0 & npm 3.6.0...

C:\Code> npm -g install builder-init
C:\Users\Stephen\AppData\Roaming\npm\builder-init -> C:\Users\Stephen\AppData\Roaming\npm\node_modules\builder-init\bin\builder-init.js
C:\Users\Stephen\AppData\Roaming\npm
`-- [email protected]

All seems OK...

C:\Code\my-project> builder-init
Usage:

  builder-init [flags] <archetype>

Flags:
...

But...

C:\Code\my-project> builder-init builder-react-component
Error: spawn npm ENOENT
    at exports._errnoException (util.js:856:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:475:9)
    at process._tickCallback (node.js:389:17)

Have I done something wrong?

Kind regards,

Stephen

PS. Builder looks like it could be a serious time saver. Brilliant work!

Feature: Install dependencies for `init.js`

Currently, init.js can only require locally available files in the archetype and standard Node libraries. It cannot require normal npm dependencies because an archetype's dependencies aren't installed. (See #32 ). This is actually a good thing because we don't want to have the time of a full npm install before starting the template prompts because in our common case, the prompts don't need nearly any of those dependencies.

Task:

  • Create a scheme for having dependencies from npm available to init.js.
    • Strawman: Add a dependencies field to init.js. If present, manually npm install DEP1 DEP2 etc. in the extracted/ directory so init.js can use them.

/cc @coopy

Bug: propagate `--` extra flags on `builder run <task1> && builder run <task2>`

The -- propagation is very naive right now as well as builder detection. In this case, we only propagate to one of the two tasks:

// package.json
    "one": "echo one",
    "two": "echo two",
    "all": "builder run one && builder run two"

Produces this:

$ builder run all -- --hi
[builder:proc:start] Command: builder run one && builder run two -- --hi
[builder:proc:start] Command: echo one
one
[builder:proc:start] Command: echo two --hi
two --hi

Task:

  • Propagate the flag to builder ... && builder ... tasks (maybe via environment?)
  • Have more sophisticated builder task detection for echo NOT_BUILDER && builder run <task> too

Extract abstract template engine out.

We have a generic templating tool here that's not builder specific, so let's move that to it's own project

  • Move all of lib/ to new project.
  • Move the bin/builder-init.js logic to a lib/ library and leave a very small shell.
  • Take default prompts values as an argument to executor in new project.
  • Proposal: Make all tool-provided automatic values prefaced with an _. So, e.g., instead of eslint, npmignore, etc. we'd have _eslint, _npmignore, etc. in new tool
    • Deprecate eslint, npmignore, etc. in builder-init and provide transition aliases and documentation.
  • Open Question: Make destination into _destination and just another normal field that if empty blows up?

New list of proposed default fields:

/**
 * Default prompts values added to all prompt calls.
 */
var DEFAULTS = {
  destination: {
    message: "Destination directory to write",
    validate: function (val) { /* existing stuff */ }
  },
  derived: {
    // Existing renamed file name helpers.
    _npmignore: function (data, cb) { cb(null, ".npmignore"); },
    _gitignore: function (data, cb) { cb(null, ".gitignore"); },
    _eslintrc: function (data, cb) { cb(null, ".eslintrc"); },
    _npmrc: function (data, cb) { cb(null, ".npmrc"); }

    // New stuff
    //
    // Location of templates directory to use.
    // Default to `init` for `builder-init`. Could be anything for new project.
    // https://github.com/FormidableLabs/builder-init/issues/36
    _templatesDir: /* snipped */
  }
};

/cc @kenwheeler

Chore: Better error messages on download of archetype.

In downloading / extracting an archetype, we go through creating a temp directory, a process spawn (npm pack), ungzip, untarring to the temp directory and walking that file path. There's a lot that can go wrong with very terse / hard-to-understand error messages.

Task:

  • Review and add error wrappers to make captured errors much more accesible.
  • Add information to error about where things went wrong.

Scenarios:

  • Archetype doesn't have init.js
  • Archetype doesn't have init/

Question: What happens if I update an archetype?

I guess I can answer my own question by putting this into practice, but I've just found this package and it's a bit late.

But what I would expect to have happen is when I push a new release of a builder-init archetype, I should also want to update other repos that are built on that archetype to reflect the new changes.

  • do I just rerun builder-init?
  • if so, do existing files get overwritten?
  • do new files get created if they are added in a later update from the version of the archetype initially used to initialize the project?

Thanks a bunch in advance! Love the work you guys do at Formidable.

Feature: Ingest user prompts from `init.js`

  • Basic init.js file + structure (METADATA)
  • Validation
    • Missing props (Captured separately in #8)
    • Validators: "", must match regex for file path, etc.
  • Dynamic:
    (1) default, and/or
    (2) actual value from some other value
  • Tests

Notes:

Update sinon

Left behind because we reuse tests from denim at intermediate version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.