Skip to content

Commit

Permalink
chore(scaffold): fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg committed May 14, 2018
1 parent b2a7470 commit df8287d
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 72 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<package>`
`webpack-cli init webpack-scaffold-<package>`

[Read more about scaffolding](SCAFFOLDING.md)

Expand Down
12 changes: 6 additions & 6 deletions SCAFFOLDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 3 additions & 3 deletions packages/generators/add-generator.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
6 changes: 3 additions & 3 deletions packages/generators/init-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion packages/generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/generators/utils/entry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const InputValidate = require("webpack-addons").InputValidate;
const InputValidate = require("@webpack-cli/webpack-scaffold").InputValidate;
const validate = require("./validate");

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/serve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/serve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion packages/utils/is-local-path.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/npm-exists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/npm-packages-exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
*
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/npm-packages-exists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
10 changes: 5 additions & 5 deletions packages/utils/resolve-packages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
]);
});

Expand All @@ -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")
]);
});
});
36 changes: 8 additions & 28 deletions packages/webpack-scaffold/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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'
Expand All @@ -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' }
Expand All @@ -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'))
Expand All @@ -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'); }
Expand All @@ -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$')]
/*
Expand All @@ -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

Expand All @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'))"`;
Expand Down
5 changes: 0 additions & 5 deletions packages/webpack-scaffold/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions packages/webpack-scaffold/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}');`;
}
Expand Down Expand Up @@ -109,7 +105,6 @@ module.exports = {
createAssetFilterFunction,
createExternalFunction,
parseValue,
createCommonsChunkPlugin,
createRequire,
List,
RawList,
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-scaffold/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit df8287d

Please sign in to comment.