diff --git a/.eslintrc.js b/.eslintrc.js index 241adca8e57..b584e0b742f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -68,7 +68,8 @@ module.exports = { "@webpack-cli/migrate", "@webpack-cli/utils", "@webpack-cli/generate-loader", - "@webpack-cli/generate-plugin" + "@webpack-cli/generate-plugin", + "@webpack-cli/webpack-scaffold" ] } ], @@ -84,7 +85,8 @@ module.exports = { "@webpack-cli/migrate", "@webpack-cli/utils", "@webpack-cli/generate-loader", - "@webpack-cli/generate-plugin" + "@webpack-cli/generate-plugin", + "@webpack-cli/webpack-scaffold" ] } ], @@ -96,7 +98,8 @@ module.exports = { "@webpack-cli/generators", "@webpack-cli/utils", "@webpack-cli/generate-loader", - "@webpack-cli/generate-plugin" + "@webpack-cli/generate-plugin", + "@webpack-cli/webpack-scaffold" ] } ], diff --git a/README.md b/README.md index c992aa7f746..4fb2949712b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The `migrate` feature eases the transition from [version 1](http://webpack.githu The `init` feature allows users to get started with webpack, fast. Through scaffolding, people can create their own configuration in order to faster initialize new projects for various of use cases. -`webpack-cli init webpack-addons-` +`webpack-cli init webpack-scaffold-` [Read more about scaffolding](SCAFFOLDING.md) diff --git a/SCAFFOLDING.md b/SCAFFOLDING.md index 267ca4bfd32..8887cd6910f 100644 --- a/SCAFFOLDING.md +++ b/SCAFFOLDING.md @@ -8,16 +8,16 @@ Before writing a `webpack-cli` scaffold, think about what you're trying to achie `webpack-cli` offers an experience that is interactive and you can prompt users for questions (like, "What is your entry point?") to help customize the output accordingly. -## webpack-addons +## webpack-scaffold -[`webpack-addons`](https://github.com/webpack-contrib/webpack-addons) is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself. +`webpack-scaffold` is a utility suite for creating addons. It contains functions that could be of use for creating an addon yourself. -## webpack-addons-yourpackage +## webpack-scaffold-yourpackage -In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `addon`, please read [How do I compose a -webpack-addon?](https://github.com/ev1stensberg/webpack-addons-demo). +In order for `webpack-cli` to compile your package, it must be available on npm or on your local filesystem. If you are curious about how you can create your very own `scaffold`, please read [How do I compose a +webpack-addon?](https://github.com/ev1stensberg/webpack-scaffold-demo). -If the package is on npm, its name must have a prefix of `webpack-addons`. +If the package is on npm, its name must have a prefix of `webpack-scaffold`. If the package is on your local filesystem, it can be named whatever you want. Pass the path to the package. diff --git a/packages/generators/add-generator.js b/packages/generators/add-generator.js index c4bff57f25f..89e7690da57 100644 --- a/packages/generators/add-generator.js +++ b/packages/generators/add-generator.js @@ -1,9 +1,9 @@ const Generator = require("yeoman-generator"); const glob = require("glob-all"); const path = require("path"); -const Confirm = require("webpack-addons").Confirm; -const List = require("webpack-addons").List; -const Input = require("webpack-addons").Input; +const Confirm = require("@webpack-cli/webpack-scaffold").Confirm; +const List = require("@webpack-cli/webpack-scaffold").List; +const Input = require("@webpack-cli/webpack-scaffold").Input; const webpackSchema = require("webpack/schemas/WebpackOptions"); const webpackDevServerSchema = require("webpack-dev-server/lib/optionsSchema.json"); diff --git a/packages/generators/init-generator.js b/packages/generators/init-generator.js index 0b72a979a98..0f45e919f65 100644 --- a/packages/generators/init-generator.js +++ b/packages/generators/init-generator.js @@ -4,9 +4,9 @@ const Generator = require("yeoman-generator"); const chalk = require("chalk"); const logSymbols = require("log-symbols"); -const Input = require("webpack-addons").Input; -const Confirm = require("webpack-addons").Confirm; -const List = require("webpack-addons").List; +const Input = require("@webpack-cli/webpack-scaffold").Input; +const Confirm = require("@webpack-cli/webpack-scaffold").Confirm; +const List = require("@webpack-cli/webpack-scaffold").List; const getPackageManager = require("@webpack-cli/utils/package-manager") .getPackageManager; diff --git a/packages/generators/package.json b/packages/generators/package.json index c0bc9a13245..93daea9f47d 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -15,7 +15,8 @@ "webpack-addons": "^1.1.5", "webpack-dev-server": "^3.1.4", "yeoman-generator": "^2.0.5", - "@webpack-cli/utils": "0.0.1" + "@webpack-cli/utils": "0.0.1", + "@webpack-cli/webpack-scaffold": "0.0.1" }, "peerDependencies": { "webpack": "^4.0.0" diff --git a/packages/generators/utils/entry.js b/packages/generators/utils/entry.js index cac29aab446..2da6f5bd2a5 100644 --- a/packages/generators/utils/entry.js +++ b/packages/generators/utils/entry.js @@ -1,6 +1,6 @@ "use strict"; -const InputValidate = require("webpack-addons").InputValidate; +const InputValidate = require("@webpack-cli/webpack-scaffold").InputValidate; const validate = require("./validate"); /** diff --git a/packages/serve/index.js b/packages/serve/index.js index 0d18c7ed8af..16f4ff89a4a 100644 --- a/packages/serve/index.js +++ b/packages/serve/index.js @@ -4,7 +4,7 @@ const inquirer = require("inquirer"); const path = require("path"); const chalk = require("chalk"); const spawn = require("cross-spawn"); -const List = require("webpack-addons").List; +const List = require("@webpack-cli/webpack-scaffold").List; const processPromise = require("@webpack-cli/utils/resolve-packages") .processPromise; diff --git a/packages/serve/package.json b/packages/serve/package.json index 68929ffa448..d66f205b52a 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -10,6 +10,6 @@ "chalk": "^2.4.1", "cross-spawn": "^6.0.5", "inquirer": "^5.2.0", - "webpack-addons": "^1.1.5" + "@webpack-cli/webpack-scaffold": "^0.0.1" } } diff --git a/packages/utils/is-local-path.test.js b/packages/utils/is-local-path.test.js index 32acbaf8384..c2be9ebc1a1 100644 --- a/packages/utils/is-local-path.test.js +++ b/packages/utils/is-local-path.test.js @@ -15,7 +15,7 @@ describe("is-local-path", () => { }); it("returns false for npm packages names", () => { - expect(isLocalPath("webpack-addons-ylvis")).toBe(false); + expect(isLocalPath("webpack-scaffold-ylvis")).toBe(false); }); it("returns false for scoped npm package names", () => { diff --git a/packages/utils/npm-exists.test.js b/packages/utils/npm-exists.test.js index 5329b720ead..5f465ab8df8 100644 --- a/packages/utils/npm-exists.test.js +++ b/packages/utils/npm-exists.test.js @@ -3,13 +3,13 @@ const exists = require("./npm-exists"); describe("npm-exists", () => { it("should successfully existence of a published module", () => { - exists("webpack-addons-ylvis").then(status => { + exists("webpack-scaffold-ylvis").then(status => { expect(status).toBe(true); }); }); it("should return false for the existence of a fake module", () => { - exists("webpack-addons-noop").then(status => { + exists("webpack-scaffold-noop").then(status => { expect(status).toBe(false); }); }); diff --git a/packages/utils/npm-packages-exists.js b/packages/utils/npm-packages-exists.js index fccc1c25e7a..d42e2d9ec43 100644 --- a/packages/utils/npm-packages-exists.js +++ b/packages/utils/npm-packages-exists.js @@ -4,7 +4,7 @@ const isLocalPath = require("./is-local-path"); const npmExists = require("./npm-exists"); const resolvePackages = require("./resolve-packages").resolvePackages; -const WEBPACK_ADDON_PREFIX = "webpack-addons"; +const WEBPACK_ADDON_PREFIX = "webpack-scaffold"; /** * diff --git a/packages/utils/npm-packages-exists.test.js b/packages/utils/npm-packages-exists.test.js index 784f700502e..3944047524e 100644 --- a/packages/utils/npm-packages-exists.test.js +++ b/packages/utils/npm-packages-exists.test.js @@ -23,13 +23,13 @@ describe("npmPackagesExists", () => { test("resolves packages when they are available on npm", done => { require("./npm-exists").mockImplementation(() => Promise.resolve(true)); - npmPackagesExists(["webpack-addons-foobar"]); + npmPackagesExists(["webpack-scaffold-foobar"]); setTimeout(() => { expect( mockResolvePackages.mock.calls[ mockResolvePackages.mock.calls.length - 1 ][0] - ).toEqual(["webpack-addons-foobar"]); + ).toEqual(["webpack-scaffold-foobar"]); done(); }, 10); }); diff --git a/packages/utils/resolve-packages.test.js b/packages/utils/resolve-packages.test.js index ec3e49e989e..7442c4f70c1 100644 --- a/packages/utils/resolve-packages.test.js +++ b/packages/utils/resolve-packages.test.js @@ -44,9 +44,9 @@ describe("resolve-packages", () => { }); it("should resolve a location of a published module", () => { - moduleLoc = getLoc(["webpack-addons-ylvis"]); + moduleLoc = getLoc(["webpack-scaffold-ylvis"]); expect(moduleLoc).toEqual([ - path.normalize("../../node_modules/webpack-addons-ylvis") + path.normalize("../../node_modules/webpack-scaffold-ylvis") ]); }); @@ -61,10 +61,10 @@ describe("resolve-packages", () => { * we validate each package on each run, we can catch and build the questions in init gradually * while we get one filepath at the time. If not, this is a workaround. */ - moduleLoc = getLoc(["webpack-addons-ylvis", "webpack-addons-noop"]); + moduleLoc = getLoc(["webpack-scaffold-ylvis", "webpack-scaffold-noop"]); expect(moduleLoc).toEqual([ - path.normalize("../../node_modules/webpack-addons-ylvis"), - path.normalize("../../node_modules/webpack-addons-noop") + path.normalize("../../node_modules/webpack-scaffold-ylvis"), + path.normalize("../../node_modules/webpack-scaffold-noop") ]); }); }); diff --git a/packages/webpack-scaffold/README.md b/packages/webpack-scaffold/README.md index b3285a55baf..74596d8f2af 100755 --- a/packages/webpack-scaffold/README.md +++ b/packages/webpack-scaffold/README.md @@ -1,8 +1,6 @@ -# webpack-addons +# webpack-scaffold -[![Build Status](https://travis-ci.org/webpack-contrib/webpack-addons.svg?branch=master)](https://travis-ci.org/webpack-contrib/webpack-addons) - -This is the utility suite for creating a webpack `addon`. It contains utility functions to assist with inquirer prompting and scaffolding. +This is the utility suite for creating a webpack `scaffold`. It contains utility functions to assist with inquirer prompting and scaffolding. # API @@ -25,7 +23,7 @@ Param: `String` Generally used when dealing with an entry point as an arrow function. ```js -const createArrowFunction = require('webpack-addons').createArrowFunction; +const createArrowFunction = require('@webpack-cli/webpack-scaffold').createArrowFunction; this.configuration.myScaffold.webpackOptions.entry = createArrowFunction('app.js') // entry: () => 'app.js' @@ -37,7 +35,7 @@ Param: `String` Used when creating a function that returns a single value. ```js -const createRegularFunction = require('webpack-addons').createRegularFunction; +const createRegularFunction = require('@webpack-cli/webpack-scaffold').createRegularFunction; this.configuration.myScaffold.webpackOptions.entry = createRegularFunction('app.js') // entry: function() { return 'app.js' } @@ -49,7 +47,7 @@ Param: `Array` | `String` Used to create an dynamic entry point. ```js -const createDynamicPromise = require('webpack-addons').createDynamicPromise; +const createDynamicPromise = require('@webpack-cli/webpack-scaffold').createDynamicPromise; this.confguration.myScaffold.webpackOptions.entry = createDynamicPromise('app.js') // entry: () => new Promise((resolve) => resolve('app.js')) @@ -65,7 +63,7 @@ Param: `String` Used to create an [assetFilterFunction](https://webpack.js.org/configuration/performance/#performance-assetfilter) ```js -const createAssetFilterFunction = require('webpack-addons').createAssetFilterFunction; +const createAssetFilterFunction = require('@webpack-cli/webpack-scaffold').createAssetFilterFunction; this.configuration.myScaffold.webpackOptions.performance.assetFilter = createAssetFilterFunction('js') // assetFilter: function (assetFilename) { return assetFilename.endsWith('.js'); } @@ -78,7 +76,7 @@ Param: `String` Used to create an [general function from Externals](https://webpack.js.org/configuration/externals/#function) ```js -const createExternalFunction = require('webpack-addons').createExternalFunction; +const createExternalFunction = require('@webpack-cli/webpack-scaffold').createExternalFunction; this.configuration.myScaffold.webpackOptions.externals = [createExternalFunction('^yourregex$')] /* @@ -92,24 +90,6 @@ externals: [ */ ``` -## createCommonsChunkPlugin - -Param: `String` - -Used to create a general [`CommonsChunkPlugin`](https://webpack.js.org/plugins/commons-chunk-plugin/). - -```js -const createCommonsChunkPlugin = require('webpack-addons').createCommonsChunkPlugin; - -this.configuration.myScaffold.webpackOptions.plugins = [createCommonsChunkPlugin('vendor')] -/* -plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', - filename: 'vendor-[hash].min.js', - }) -*/ -``` ## createRequire @@ -118,7 +98,7 @@ Param: `String` Used to create a module in `topScope` ```js -const createRequire = require('webpack-addons').createRequire; +const createRequire = require('@webpack-cli/webpack-scaffold').createRequire; this.configuration.myScaffold.topScope = [createRequire('webpack')] // const webpack = require('webpack') diff --git a/packages/webpack-scaffold/__tests__/__snapshots__/index.test.js.snap b/packages/webpack-scaffold/__tests__/__snapshots__/index.test.js.snap index a2fbe7529e8..afd57eac245 100755 --- a/packages/webpack-scaffold/__tests__/__snapshots__/index.test.js.snap +++ b/packages/webpack-scaffold/__tests__/__snapshots__/index.test.js.snap @@ -17,8 +17,6 @@ exports[`utils createAssetFilterFunction should stringify an assetFilterFunction }" `; -exports[`utils createCommonsChunkPlugin should stringify an commonChunksPlugin 1`] = `"new webpack.optimize.CommonsChunkPlugin({name:'vendor',filename:'vendor-[hash].min.js'})"`; - exports[`utils createDynamicPromise should stringify an array 1`] = `"() => new Promise((resolve) => resolve(['app.js','index.js']))"`; exports[`utils createDynamicPromise should stringify an single value 1`] = `"() => new Promise((resolve) => resolve('app.js'))"`; diff --git a/packages/webpack-scaffold/__tests__/index.test.js b/packages/webpack-scaffold/__tests__/index.test.js index 6ad35c7588b..3c3e2981449 100755 --- a/packages/webpack-scaffold/__tests__/index.test.js +++ b/packages/webpack-scaffold/__tests__/index.test.js @@ -40,11 +40,6 @@ describe("utils", () => { expect(utils.createExternalFunction("js")).toMatchSnapshot(); }); }); - describe("createCommonsChunkPlugin", () => { - it("should stringify an commonChunksPlugin", () => { - expect(utils.createCommonsChunkPlugin("vendor")).toMatchSnapshot(); - }); - }); describe("createRequire", () => { it("should stringify an require statement", () => { expect(utils.createRequire("webpack")).toMatchSnapshot(); diff --git a/packages/webpack-scaffold/index.js b/packages/webpack-scaffold/index.js index bb68ce54b3f..e5ff557ec4c 100755 --- a/packages/webpack-scaffold/index.js +++ b/packages/webpack-scaffold/index.js @@ -42,10 +42,6 @@ function parseValue(regexp) { return jscodeshift(regexp); } -function createCommonsChunkPlugin(value) { - return `new webpack.optimize.CommonsChunkPlugin({name:'${value}',filename:'${value}-[hash].min.js'})`; -} - function createRequire(val) { return `const ${val} = require('${val}');`; } @@ -109,7 +105,6 @@ module.exports = { createAssetFilterFunction, createExternalFunction, parseValue, - createCommonsChunkPlugin, createRequire, List, RawList, diff --git a/packages/webpack-scaffold/package-lock.json b/packages/webpack-scaffold/package-lock.json index 8a7107c4a57..d33d81a3ab2 100644 --- a/packages/webpack-scaffold/package-lock.json +++ b/packages/webpack-scaffold/package-lock.json @@ -1,5 +1,5 @@ { - "name": "webpack-scaffold", + "name": "@webpack-cli/webpack-scaffold", "version": "0.0.1", "lockfileVersion": 1, "requires": true,