Vue-cli: Let plugins add information to the Readme.md

Created on 28 Feb 2019  路  4Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

Plugins and presets often need to add long-lasting generic information into a project, for example, a preset would add in deployment or configuration details to be done by developers outside of the Vue CLI.

What does the proposed API look like?

api.extendReadme(MarkDownFormattedString)

The readme would then generate a section based on the plugin/preset that inserted the string so that it can be included in the generated readme.md

contribution welcome feature request

Most helpful comment

Now I'm using this method to solve it.

Writing the following code at API api.onCreateComplete

api.onCreateComplete(() => {
  process.env.VUE_CLI_SKIP_WRITE = true
})

Because the function writeFileTree of generating README.md use VUE_CLI_SKIP_WRITE to judge whether there is a need to do it.

All 4 comments

Running hook after the README.md is generated would give developers more control over the changes. It would be possible to change the file using something like readFileSync.

Any update on this? I wrote a carefully crafted README in my template months ago and only today discovered that it is completely ignored! Or at least overwritten later.

I tried manually writing to it using fs in onCreateComplete() but it didn't take effect like other files that I'm modifying in that hook. I see that it prints out "Generating README.md..." - is there a hook for after that runs?

I have a super hacky workaround but I don't like it:

setTimeout(() => {
  // Update README.md.
}, 10000);

So the current situation is this:

There is a utility function for generating the readme file. It requires the final version of the package.json data in order to inspect what kind of npm scripts there are. Then it looks up the script names in a dictionary of script descriptions to add that information to the readme.

In order for it to pickup on all the scripts defined by the official plugins (e.g. eslint, jest, etc) it is only called after all the generators have been called.

To make the readme editable by other plugins, the creation process would have to be split.

  1. Create a most basic readme file.
  2. Call the generators
  3. Add the script descriptions for official plugins by modifiying the readme.

As a further improvement, the script descriptions should be added directly by the generators of the official plugins. This way any preset and other plugins can override all of the readme content.

Now I'm using this method to solve it.

Writing the following code at API api.onCreateComplete

api.onCreateComplete(() => {
  process.env.VUE_CLI_SKIP_WRITE = true
})

Because the function writeFileTree of generating README.md use VUE_CLI_SKIP_WRITE to judge whether there is a need to do it.

Was this page helpful?
0 / 5 - 0 ratings