Code Monkey home page Code Monkey logo

mili's Introduction

logo

Mili

version downloads license dependencies coveralls

简体中文

Projects that derived from the same scaffolding, have evolved over time and become different. Scaffolding lost control of the subsequent development of the project. When we need to improve some of the basic functions of scaffolding(e.g. eslint rules), we need to modify each project, and even have to design a customized solution for some old projects.

Therefore, in order to improve the control ability of scaffolding for the subsequent development of the project,template can modified some files and release new template version, then project can upgrade the template version.

It is useful for team project management.

Usage

Init Project

mkdir my_project
cd my_project

# template in npm
npx mili init npm:@mtpl/code-style
# template in github
npx mili init github:mili-project-manager/mtpl-code-style
# template in private git repository
npx mili init https://github.com/mili-project-manager/mtpl-code-style
# ssh is also support
npx mili init [email protected]:mili-project-manager/mtpl-code-style.git

Upgrade

The upgrade operation is very simple to use. It will upgrade the template to the latest version.

npx run upgrade
This command maybe overwrite your files.

Check Before Commit

With husky, it is easy to verify whether the project file meets the template before commit. Thereby ensuring the specification of the project code.

Run in terminal:

npx mili check --diff --fold

The example stdout:

mili check

Run npx mili upgrade command will auto modify code according to the diff.

Contributing & Development

If there is any doubt, it is very welcome to discuss the issue together. Please read Contributor Covenant Code of Conduct and CONTRIBUTING.

mili's People

Contributors

val-istar-guo avatar wenxianghu avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

Forkers

aa654321jxsi

mili's Issues

feat: Delete mode support

Is your feature request related to a problem? Please describe.
I want remove project file when i remove the file at template

Describe the solution you'd like
add a upgrade type 'static' for folder?or provide delete handler?

Need solutions

  • Possible effects of upgrading across versions
  • User-defined files may have duplicate names

Add option to control template version

Is your feature request related to a problem? Please describe.
I want to initialize the project with a specific version of the template.

Describe the solution you'd like
add -tv, --template-version options

Simplify config.rules[].path using glob

Is your feature request related to a problem? Please describe.
config.rules[].path can only be configured with a single file path. This causes the configuration file to write very long .

Describe the solution you'd like
micromatch is the package that match the path that follow the rule.

Recover overwritten files

Is your feature request related to a problem? Please describe.
mili update overwritten the file isn't commited. I want have a command to recover them.

Describe the solution you'd like
stash project files when upgrade, init, update.
And add a new command mili recover

File merge handler error

Describe the bug
All file cannot be merge.

To Reproduce
Steps to reproduce the behavior:

  1. template have a file that type is merge
  2. run upgrade
  3. the file is be cover

Expected behavior
merge two file content

Platform (please complete the following information):

  • Environment: nodejs
  • Version 1.0.1

feat: import handler from third-party packages

Describe the solution you'd like
The build-in handlers is not enough to do everything that handler can do. Allow import handers form third-party packages will accelerate mili development.

Access mili commands programmatically from javascript

Is your feature request related to a problem? Please describe.
Wrap mili into a basic tool for personal

Describe the solution you'd like

import mili from 'mili'

mili.init(options)
mili.update(options)
mili.upgrade(options)

Allows templates to provide upgrade scripts

Is your feature request related to a problem? Please describe.
When template upgrade affect keep file, sometime template could provide an upgrade script that can auto upgrade keep file.

Describe the solution you'd like
allows template to provide a list of upgrade scripts

Describe alternatives you've considered
Use the upgrade script as part of the template.

Check the mili version of template

Is your feature request related to a problem? Please describe.
Remind users to upgrade mili when the mili version of the project does not meet the mili version required by the template.

Bug: different meanings

Describe the bug

The path in npx mili init Val-istar-Guo/mili-template is mean https://github.com/Val-istar-Guo/mili-template.git. However, it's more like relative path.

Expected behavior

  1. Don't recommend use such path, use github:Val-istar-Guo/mili-template instead.
  2. Auto Turn Val-istar-Guo/mili-template into github:Val-istar-Guo/mili-template when generate .milirc
  3. Deprecate this style of writing next major version.

Separate the template

Is your feature request related to a problem? Please describe.

  • Centralized template management will lead to problems such as inflexible template extension, too large repository , etc.
  • mili should extract its core ideas, and applied to a wide range of project development.

Describe the solution you'd like

  • set each template as a repository
  • Initialization will clone the initialization file of the template to the local
  • The upgrade will be upgraded according to the template configuration that meets mili's standard ideas.

Describe alternatives you've considered
none

Additional context

  • Clear upgrade strategy
  • Support for command extension

Add the commit message specification

Is your feature request related to a problem? Please describe.
The standard commit message is very beneficial for multi-person collaboration, historical backtracking, and generation of CHANGELOG files for large projects.

Describe the solution you'd like
commizen is a very good option.

Describe alternatives you've considered
none

Additional context
none

bug: Throw error when the filed named "main" is unset in package.json

Describe the bug

https://github.com/Val-istar-Guo/mili/blob/5437fcf73fe9795c9dbf77a44e631491b60c68c4/src/load-config/load-template-config/index.js#L36

When the field named "main" was not existed in the package.json of template, there will throw error and the template could not be loaded.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare a template that have not field named "main" in package.json
  2. Run npx mili init path_to_template
  3. Throw error that the mili version needed by template is unset.

Expected behavior

  1. Auto load entry.js when main is not set in package.json.
  2. throw the error that template could not be load when template load fail.

Platform (please complete the following information):

  • Environment: NodeJS[e.g. nodejs, chrome, safari]

feat: Add cwd setting in cli

Is your feature request related to a problem? Please describe.
I have to write a script file used to cd dir where run mili upgrade, if i use lerna.

Describe the solution you'd like
Add --cwd option.

Shorthand for the github repository uri

Is your feature request related to a problem? Please describe.
Github is the most commonly used repository. It makes sense to provide shorthand.

Describe the solution you'd like
Automatically incomplete uri when the repository conforms to the xxx/xxx or github:xxx/xxx format.

Add `exist` upgrade type or handler

Is your feature request related to a problem? Please describe.
I hope that if the file exists, do nothing. If the file does not exist, create one using the template file.

Describe the solution you'd like
add exist upgrade type of handler

Bug: Cannot find relative path when upgrade

Describe the bug

https://github.com/Val-istar-Guo/mili/blob/3be721ccd6c4b0733047a1e0d17f0f74ddad04a1/src/load-config/load-milirc.js#L32

You should clone the config, if you want to change the value of the config.
Because the cosmiconfig will return same config object when you call explorer secondly.

https://github.com/Val-istar-Guo/mili/blob/3be721ccd6c4b0733047a1e0d17f0f74ddad04a1/src/load-config/load-milirc.js#L54-L56

Therefore, config.template will change again base on last change.

The better way is memorize loadMilirc function, that can improve performance.

Platform (please complete the following information):

  • Device: Mac
  • Environment: nodejs
  • Version: 2.6.0

feat: Check for unsafe file changes

Is your feature request related to a problem? Please describe.
Preventing users from submitting when not conforming to the current template.

Describe the solution you'd like

Add new command to do this.
Support -R options to check all subproject.

feat: Add options to control whether you need to install dependencies

Is your feature request related to a problem? Please describe.
At many times, there is no dependencies needed to be install when init/upgrade template.And the process of installing dependencies wastes a lot of time.

Describe the solution you'd like
Add the option --no-deps to remove the process of installing dependencies.
Or do not installing the dev denpendencies with npm install --production

feat: Support for publishing templates to npm mode

Is your feature request related to a problem? Please describe.

  • git clone will clone all repository history.It is a waste of time.
  • Version management may cause human error.
  • @xxx/xxx is a way to distinguish teams.
  • registry is the way for private teams who has own npm server.

Describe the solution you'd like

npx mili init npm:@xxx/xxx --registry xxxxx -v 1.2.3

Cannot find module 'mustache'

Describe the bug
throw error Cannot find module 'mustache', when run mili init.

To Reproduce
Steps to reproduce the behavior:

  1. run npx mili init https://github.com/Val-istar-Guo/mili-template.git

Expected behavior
Init project

Platform (please complete the following information):

  • Device: Mac
  • Environment: nodejs
  • Version: 1.0.0

Additional context
The 'mustache' should be in dependencies but in devDependencies.

Expose the mili lifecycle hooks to the template

Is your feature request related to a problem? Please describe.
I want to run yarn after mili upgrade and mili update

Describe the solution you'd like
Expose the mili lifecycle hooks to the template. So that template could set do what after upgrade or update.

Need Solution

  • What hooks should be included?
    add afterInit, afterUpdate, afterUpgrade first.
  • How do templates register hooks?
    like config.hooks.afterInit

Add correction command

Is your feature request related to a problem? Please describe.
I want to correct my modified file that should not modified use the current template version.

Describe the solution you'd like
add a new command mili correct

Add handler to get html comment area

Is your feature request related to a problem? Please describe.
Allow custom partial readme content.

Describe the solution you'd like
add hander extractHtmlCommentArea(String: commentStart, String: commentEnd)

feat: Use function directly at hooks

Is your feature request related to a problem? Please describe.
Only a sigle shell command is very inflexible. If you want to run multiple shell commands or javascript scripts, you must create a file and run it through commands(./path_to_shell.sh or node path_to_file).And, some javascript developers may not good at writing shell scripts.

Describe the solution you'd like
The hook can be set to a javascript function.

Describe alternatives you've considered
Write the script in a file. Then run it in hook.

feat: Add the option to upgrade all subprojects with milirc

Is your feature request related to a problem? Please describe.
We need upgrade multiple projects at the same time, especially when using lerna

Describe the solution you'd like

Add the option -R. When run npx mili upgrade -R at the folder, all the sub-folder with .milirc will be upgrade.

feat: Auto create dir

Is your feature request related to a problem? Please describe.
It is not must to mkdir manually.

Describe the solution you'd like

  1. New option: npx mili init -c xxx -n xxxx
  2. --cwd path option will auto mkdir when path not existed

Add a command to clean cache

Is your feature request related to a problem? Please describe.
I want remove template repository cache

Describe the solution you'd like
Add a command mili clean

Add the comment that mark the file upgrade type

Is your feature request related to a problem? Please describe.
I'm always do not know which file is free to change after i init a project

Describe the solution you'd like
Add a comment that mark the file upgrade type at the file begins

feat: support replace effect function to another

Is your feature request related to a problem? Please describe.
Replace inquirer and file system when use mili programmatically. So that make mili could be integrated into the graphical interface or website.

bug: relative path will be saved as absolute path in .milirc

Describe the bug

Relative template path will be saved as absolute path in .milirc. Therefore mili cannot find template path at another computer.

To Reproduce
Steps to reproduce the behavior:

  1. Run npx mili init relative_template_path
  2. push repo and clone to another computer
  3. template has the same relative path at another computer
  4. Run npx mili upgrade
  5. See Error that cannot find template

Support github template

Is your feature request related to a problem? Please describe.
Each project template should has a uniform issue template, pull request template, and code guidelines.Without repeating work.

Describe the solution you'd like
add issue template, pull request template and code guidelines to each project template

Template Support CI

Is your feature request related to a problem? Please describe.
Need for continuous integration through CI

Describe the solution you'd like
Travis CI is very good

Describe alternatives you've considered
none

Additional context
none

feat: Ensure folder clean rather than repo clean

Is your feature request related to a problem? Please describe.

Check the folder is clean rather than the repo clean. Because mili may be used to initialize a folder in the repository instead of the entire repository. --force isn't need while there is no pending files under the folder

Pify???

Try const { promisify } = require('util')

And option to control template version

Is your feature request related to a problem? Please describe.
I want to initialize the project with a specific version of the template.

Describe the solution you'd like
add -tv, --template-version options

docs: English guide docs

Is the document missing? Please describe.

My English is relatively poor, and it is difficult to translate Chinese guides into English. If anyone likes this tool and wants more people to recognize it. I hope to get your help to translate the guide into English.

Please leave a message under issue if you want help me do it.

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.