diff --git a/README.md b/README.md index 0afe9347c2e..8e5a30b157b 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ You will answer many questions when running the `init` so webpack CLI can provid With v3 of webpack CLI, we introduced scaffolding as an integral part of the CLI. Our goal is to simplify the creation of webpack configurations for different purposes. Additionally, sharing such solutions with the community is beneficial and with webpack webpack's we want to allow this. We provide `webpack-scaffold` as a utility suite for creating these scaffolds. It contains functions that could be of use for creating an scaffold yourself. -You can read more about [Scaffolding](./SCAFFOLDING.md) or check out the example project [How do I compose a webpack-scaffold?](https://github.com/evenstensberg/webpack-scaffold-demo). +You can read more about [Scaffolding](https://webpack.js.org/guides/scaffolding), learn [How to compose a webpack-scaffold?](https://webpack.js.org/contribute/writing-a-scaffold) or generate one with [webpack-scaffold-starter](https://github.com/rishabh3112/webpack-scaffold-starter). ## Contributing and Internal Documentation diff --git a/packages/add/README.md b/packages/add/README.md index 0cb1b45b86c..cc13015724b 100644 --- a/packages/add/README.md +++ b/packages/add/README.md @@ -1,5 +1,7 @@ # webpack-cli add +[![npm](https://img.shields.io/npm/dm/@webpack-cli/add.svg)](https://www.npmjs.com/package/@webpack-cli/add) + ## Description This package contains the logic to add new properties in a webpack configuration file. It will run a generator that prompts the user for questions of which property to add to their webpack configuration file. diff --git a/packages/generate-loader/README.md b/packages/generate-loader/README.md index 26a9100e432..ed7e47ae96a 100644 --- a/packages/generate-loader/README.md +++ b/packages/generate-loader/README.md @@ -1,5 +1,7 @@ # webpack-cli generate-loader +[![npm](https://img.shields.io/npm/dm/@webpack-cli/generate-loader.svg)](https://www.npmjs.com/package/@webpack-cli/generate-loader) + ## Description This package contains the logic to initiate new loader projects. @@ -24,4 +26,4 @@ generateLoader(); ### CLI (via `webpack-cli`) ```bash npx webpack-cli generate-loader -``` \ No newline at end of file +``` diff --git a/packages/generate-plugin/README.md b/packages/generate-plugin/README.md index df400763c1d..29662905a17 100644 --- a/packages/generate-plugin/README.md +++ b/packages/generate-plugin/README.md @@ -1,5 +1,7 @@ # webpack-cli generate-plugin +[![npm](https://img.shields.io/npm/dm/@webpack-cli/generate-plugin.svg)](https://www.npmjs.com/package/@webpack-cli/generate-plugin) + ## Description This package contains the logic to initiate new plugin projects. @@ -23,4 +25,4 @@ generatePlugin(); ### CLI (via `webpack-cli`) ```bash npx webpack-cli generate-plugin -``` \ No newline at end of file +``` diff --git a/packages/generators/README.md b/packages/generators/README.md index 921217257f9..5139dcf3c4b 100644 --- a/packages/generators/README.md +++ b/packages/generators/README.md @@ -1,5 +1,7 @@ # webpack-cli generators +[![npm](https://img.shields.io/npm/dm/@webpack-cli/generators.svg)](https://www.npmjs.com/package/@webpack-cli/generators) + ## Description This package contains all webpack-cli related yeoman generators. diff --git a/packages/info/README.md b/packages/info/README.md index a1944e21808..03dcd9bd8d1 100644 --- a/packages/info/README.md +++ b/packages/info/README.md @@ -1,5 +1,7 @@ # webpack-cli info +[![npm](https://img.shields.io/npm/dm/@webpack-cli/info.svg)](https://www.npmjs.com/package/@webpack-cli/info) + ## Description This pacakge returns a set of information related to the local enviroment. diff --git a/packages/init/README.md b/packages/init/README.md index d2eacb9caa1..465966be148 100644 --- a/packages/init/README.md +++ b/packages/init/README.md @@ -1,5 +1,7 @@ # webpack-cli init +[![npm](https://img.shields.io/npm/dm/@webpack-cli/init.svg)](https://www.npmjs.com/package/@webpack-cli/init) + ## Description This package contains the logic to create a new webpack configuration. diff --git a/packages/migrate/README.md b/packages/migrate/README.md index 38fad56a13d..68a8ae342a9 100644 --- a/packages/migrate/README.md +++ b/packages/migrate/README.md @@ -1,5 +1,7 @@ # webpack-cli migrate +[![npm](https://img.shields.io/npm/dm/@webpack-cli/migrate.svg)](https://www.npmjs.com/package/@webpack-cli/migrate) + ## Description This package contains the logic to migrate a project from one version to the other. @@ -25,4 +27,4 @@ migrate(null, null, inputPath, outputPath); ### CLI (via `webpack-cli`) ```bash npx webpack-cli migrate -``` \ No newline at end of file +``` diff --git a/packages/remove/README.md b/packages/remove/README.md index 6af72b205f4..9ec0202d772 100644 --- a/packages/remove/README.md +++ b/packages/remove/README.md @@ -1,5 +1,7 @@ # webpack-cli remove +[![npm](https://img.shields.io/npm/dm/@webpack-cli/remove.svg)](https://www.npmjs.com/package/@webpack-cli/remove) + ## Description This package contains the logic to remove properties of a webpack configuration file. It will run a generator that prompts the user for questions of which property to remove in their webpack configuration file. @@ -23,4 +25,4 @@ remove(); ### CLI (via `webpack-cli`) ```bash npx webpack-cli remove -``` \ No newline at end of file +``` diff --git a/packages/serve/README.md b/packages/serve/README.md index a6612b6f9be..aab9613599c 100644 --- a/packages/serve/README.md +++ b/packages/serve/README.md @@ -1,5 +1,7 @@ # webpack-cli serve +[![npm](https://img.shields.io/npm/dm/@webpack-cli/serve.svg)](https://www.npmjs.com/package/@webpack-cli/serve) + ## Description This package contains the logic to run webpack-serve without using webpack-serve directly. @@ -23,4 +25,4 @@ serve(); ### CLI (via `webpack-cli`) ```bash npx webpack-cli serve -``` \ No newline at end of file +``` diff --git a/packages/update/README.md b/packages/update/README.md index 16f38f42326..dd038a61038 100644 --- a/packages/update/README.md +++ b/packages/update/README.md @@ -1,5 +1,7 @@ # webpack-cli update +[![npm](https://img.shields.io/npm/dm/@webpack-cli/update.svg)](https://www.npmjs.com/package/@webpack-cli/update) + ## Description This package contains the logic to update properties in a webpack configuration file. It will run a generator that prompts the user for questions of which property to update in their webpack configuration file. @@ -23,4 +25,4 @@ update(); ### CLI (via `webpack-cli`) ```bash npx webpack-cli update -``` \ No newline at end of file +``` diff --git a/packages/utils/README.md b/packages/utils/README.md index 33bc3f771f6..2ea21274d09 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -1,5 +1,7 @@ # webpack-cli utils (WIP, not yet published) +[![npm](https://img.shields.io/npm/dm/@webpack-cli/utils.svg)](https://www.npmjs.com/package/@webpack-cli/utils) + ## Description This package contains the utilities used across the webpack-cli repositories. @@ -26,4 +28,4 @@ npm i -D webpack-cli @webpack-cli/utils ```js const utils = require("@webpack-cli/utils"); // API yet to be exposed -``` \ No newline at end of file +``` diff --git a/packages/utils/defineTest.ts b/packages/utils/defineTest.ts index b5b076cfa4b..a5ee041d26f 100644 --- a/packages/utils/defineTest.ts +++ b/packages/utils/defineTest.ts @@ -1,5 +1,6 @@ import * as fs from "fs"; import * as path from "path"; + import { IJSCodeshift, INode } from "./types/NodePath"; interface IModule { diff --git a/packages/utils/find-root.ts b/packages/utils/find-root.ts index 9e1baf5b1a6..0345da2db62 100644 --- a/packages/utils/find-root.ts +++ b/packages/utils/find-root.ts @@ -1,6 +1,12 @@ import * as findup from "findup-sync"; import * as path from "path"; +/** + * Returns the absolute path of the project directory + * Finds the package.json, by using findup-sync + * @returns {String} path of project directory + */ + export function findProjectRoot(): string { const rootFilePath = findup(`package.json`); const projectRoot = path.dirname(rootFilePath); diff --git a/packages/utils/scaffold.ts b/packages/utils/scaffold.ts index 7aa5ff7eb63..a3add9ee769 100644 --- a/packages/utils/scaffold.ts +++ b/packages/utils/scaffold.ts @@ -90,22 +90,16 @@ export default function runTransform(transformConfig: ITransformConfig, action: console.error(err.message ? err.message : err); }); }); - + let successMessage: string = `Congratulations! Your new webpack configuration file has been created!\n`; if (initActionNotDefined && transformConfig.config.item) { - process.stdout.write( - "\n" + - chalk.green( - `Congratulations! ${ - transformConfig.config.item - } has been ${action}ed!\n`, - ), - ); - } else { - process.stdout.write( - "\n" + - chalk.green( - "Congratulations! Your new webpack configuration file has been created!\n", - ), - ); + successMessage = `Congratulations! ${ + transformConfig.config.item + } has been ${action}ed!\n`; } + process.stdout.write( + "\n" + + chalk.green( + successMessage, + ), + ); } diff --git a/packages/webpack-scaffold/README.md b/packages/webpack-scaffold/README.md index 90453cc188b..fcd01de288f 100755 --- a/packages/webpack-scaffold/README.md +++ b/packages/webpack-scaffold/README.md @@ -1,5 +1,7 @@ # webpack-scaffold +[![npm](https://img.shields.io/npm/dm/@webpack-cli/webpack-scaffold.svg)](https://www.npmjs.com/package/@webpack-cli/webpack-scaffold) + This is the utility suite for creating a webpack `scaffold`, it contains utility functions to help you work with [Inquirer](https://github.com/SBoudrias/Inquirer.js/) prompting and scaffolding. # Installation @@ -9,15 +11,20 @@ npm i -D webpack-cli @webpack-cli/webpack-scaffold ``` # API - -1. [parseValue()](#parsevalue) -2. [createArrowFunction()](#createarrowfunction) -3. [createRegularFunction()](#createregularfunction) -4. [createDynamicPromise()](#createdynamicpromise) -5. [createAssetFilterFunction()](#createassetfilterfunction) -6. [createExternalFunction()](#createexternalfunction) -7. [createRequire()](#createrequire) -8. Inquirer: [List](#list), [RawList](#rawlist), [CheckList](#checklist), [Input](#input), [InputValidate](#inputvalidate), [Confirm](#confirm) +- [parseValue](#parsevalue) +- [createArrowFunction](#createarrowfunction) +- [createRegularFunction](#createregularfunction) +- [createDynamicPromise](#createdynamicpromise) +- [createAssetFilterFunction](#createassetfilterfunction) +- [createExternalFunction](#createexternalfunction) +- [createRequire](#createrequire) +- [Inquirer](#inquirer) + - [List](#list) + - [RawList](#rawlist) + - [CheckList](#checklist) + - [Input](#input) + - [InputValidate](#inputvalidate) + - [Confirm](#confirm) ## parseValue