-
-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Use prettier (#173) * build: Add webpack lint settings and style code with eslint --fix We now use the webpack eslint settings that make sense in the cli. Also use the new --fix of eslint to automatically beautify the code * Add additional .eslintrc to /bin to remove unrelated eslint errors * build: Add jest-cli as dev dependency * style: fix lintin errors and coding style according to webpack settings * build: update dependencies and add package-lock to repo * feat: Require quotes only in property names that require it * chore: Add again removed settings by merge conflict solving * tests: Fix failing test * chore: Use husky instead of pre-commit pre-commit package stopped working. See observing/pre-commit#113 husky also requires less boilerplate in the package.json * [Feature] Added support to Flow inside transformations (#174) * [FLOW] Implemented interfaces and flow types inside the transformations * [FLOW] first commit * Added flwo to two other files * Reviewed interfaces * Created different intefaces for expressions * Fixed rest of trasformations * More developments * Updated code after code review * Fixed failing tests * Removed yarn file * Applied linting * Updated packages * Applied lint style to the imports due to code review * docs: Documentation for migrate (#175) * initial draft of migrate documentation * formatting * formatting * added summary of migrate changes * maintain consistent usage of user through documentation * Feature/generate loader (#183) * Add template files for loader yeoman generator * Create yeoman generator for a webpack loader project * Add tests for loader-generator * Add `mkdirp` dependency for loader-generator * Add function to create yeoman env and run loader-generator * Add `generate-loader` command to webpack-cli * Copy loader templates from proper directory * Add template files for plugin generator * Create yeoman generator for webpack plugins * Add function to create yeoman env and run plugin generator * Add cli command to generate plugin * Register generate- commands in yargs * Add template files for loader examples and tests * Copy loader test and example template files in generator * Add template files for plugin examples and tests * Copy plugin test and example template files in generator * Refactor generator file copying, switch .includes with .indexOf in CLI arg parsing * Change `indexOf('foo') > -1` to `indexOf('foo') >= 0` * Factor out generator copy utilities into separate module * Rewrite generators using a function that returns a customized generator class * Fix linting errors * Remove //eslint-disable lines from template files * Add unit tests for CLI and add flow compilation (#186) * add unit tests for everything and flow compilation * add travis builds * add cli to signature & add ignore to trash code * port to jest * remove redundant cli command * Feature/generate loader (#183) * Add template files for loader yeoman generator * Create yeoman generator for a webpack loader project * Add tests for loader-generator * Add `mkdirp` dependency for loader-generator * Add function to create yeoman env and run loader-generator * Add `generate-loader` command to webpack-cli * Copy loader templates from proper directory * Add template files for plugin generator * Create yeoman generator for webpack plugins * Add function to create yeoman env and run plugin generator * Add cli command to generate plugin * Register generate- commands in yargs * Add template files for loader examples and tests * Copy loader test and example template files in generator * Add template files for plugin examples and tests * Copy plugin test and example template files in generator * Refactor generator file copying, switch .includes with .indexOf in CLI arg parsing * Change `indexOf('foo') > -1` to `indexOf('foo') >= 0` * Factor out generator copy utilities into separate module * Rewrite generators using a function that returns a customized generator class * Fix linting errors * Remove //eslint-disable lines from template files * add unit tests for everything and flow compilation * add travis builds * add cli to signature & add ignore to trash code * port to jest * remove redundant cli command * rebase against master * ast for devServer (#185) * feat: replace yarn backup w/ normal yarn (#160) * feat: replace yarn backup w/ normal yarn * upgrade npm & remove yarn * Use yarn if available (#189) * bump version to 1.3.4 * update package.json * 1.3.5 * prepublish -> postinstall * 1.3.6 * temp fix to prepublish issue * 1.3.7 * add propper post install * 1.3.8 * re-add manual build step * 1.3.9 * refactor * bump version * disable published pkg * add ignore patterns * add more ignore patterns for npm
- Loading branch information
1 parent
84b2c38
commit 2eb4953
Showing
177 changed files
with
6,890 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-3"] | ||
"presets": ["es2015", "stage-3", "flow"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
**/__testfixtures__/* | ||
coverage | ||
test | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[ignore] | ||
|
||
[include] | ||
|
||
[libs] | ||
flow-typed | ||
|
||
[options] | ||
module.system.node.resolve_dirname=./lib/ | ||
module.system.node.resolve_dirname=node_modules | ||
experimental.const_params=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,8 @@ yarn-error.log | |
# Jest Coverage | ||
coverage | ||
|
||
# Distribution Build | ||
dist | ||
|
||
# Test Compilation | ||
test/js/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
test | ||
coverage | ||
lib | ||
.travis.yml | ||
.eslintrc* | ||
.fitcommitjsrc.json | ||
.vscode | ||
.editorconfig | ||
.eslintignore | ||
__mocks__ | ||
__testfixtures__ | ||
*.test.js | ||
*.input.js | ||
types.js | ||
*.spec.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"use strict"; | ||
|
||
const yeoman = require("yeoman-environment"); | ||
const Generator = require("yeoman-generator"); | ||
const path = require("path"); | ||
const defaultGenerator = require("./yeoman/webpack-generator"); | ||
const WebpackAdapter = require("./yeoman/webpack-adapter"); | ||
const runTransform = require("./transformations/index"); | ||
|
||
/* | ||
* @function creator | ||
* | ||
* Runs yeoman and runs the transformations based on the object | ||
* built up from an author/user | ||
* | ||
* @param { String } options - An path to the given generator | ||
* @returns { Function } runTransform - Run transformations based on yeoman prompt | ||
*/ | ||
|
||
function creator(options) { | ||
let env = yeoman.createEnv("webpack", null, new WebpackAdapter()); | ||
const generatorName = options | ||
? replaceGeneratorName(path.basename(options[0])) | ||
: "webpack-default-generator"; | ||
if (options) { | ||
const WebpackGenerator = class extends Generator { | ||
initializing() { | ||
options.forEach(path => { | ||
return this.composeWith(require.resolve(path)); | ||
}); | ||
} | ||
}; | ||
env.registerStub(WebpackGenerator, generatorName); | ||
} else { | ||
env.registerStub(defaultGenerator, "webpack-default-generator"); | ||
} | ||
|
||
env.run(generatorName).on("end", () => { | ||
if (generatorName !== "webpack-default-generator") { | ||
//HACK / FIXME | ||
env = env.options.env; | ||
return runTransform(env.configuration); | ||
} else { | ||
return runTransform(env.getArgument("configuration")); | ||
} | ||
}); | ||
} | ||
|
||
/* | ||
* @function replaceGeneratorName | ||
* | ||
* Replaces the webpack-addons pattern with the end of the addons name merged | ||
* with 'generator' | ||
* | ||
* @param { String } name - name of the generator | ||
* @returns { String } name - replaced pattern of the name | ||
*/ | ||
|
||
function replaceGeneratorName(name) { | ||
return name.replace(/(webpack-addons)?([^:]+)(:.*)?/g, "generator$2"); | ||
} | ||
|
||
module.exports = { | ||
creator, | ||
replaceGeneratorName | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
|
||
const replaceGeneratorName = require("./index").replaceGeneratorName; | ||
|
||
describe("replaceGeneratorName", () => { | ||
it("should replace a pattern of an addon", () => { | ||
const generatorName = replaceGeneratorName("webpack-addons-thefox"); | ||
expect(generatorName).toEqual("generator-thefox"); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
dist/creator/transformations/context/__testfixtures__/context-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
dist/creator/transformations/context/__testfixtures__/context-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
dist/creator/transformations/context/__testfixtures__/context-2.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use strict"; | ||
|
||
const utils = require("../../../transformations/utils"); | ||
|
||
/* | ||
* | ||
* Transform for context. Finds the context property from yeoman and creates a | ||
* property based on what the user has given us. | ||
* | ||
* @param j — jscodeshift API | ||
* @param ast - jscodeshift API | ||
* @param { Object } webpackProperties - Object containing transformation rules | ||
* @returns ast - jscodeshift API | ||
*/ | ||
|
||
module.exports = function(j, ast, webpackProperties) { | ||
if (webpackProperties) { | ||
return ast | ||
.find(j.ObjectExpression) | ||
.filter(p => | ||
utils.isAssignment( | ||
j, | ||
p, | ||
utils.pushCreateProperty, | ||
"context", | ||
webpackProperties | ||
) | ||
); | ||
} else { | ||
return ast; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("../../../transformations/defineTest"); | ||
|
||
defineTest(__dirname, "context", "context-0", "path.resolve(__dirname, 'app')"); | ||
defineTest(__dirname, "context", "context-1", "'./some/fake/path'"); | ||
defineTest(__dirname, "context", "context-2", "contextVariable"); |
6 changes: 6 additions & 0 deletions
6
dist/creator/transformations/devServer/__testfixtures__/devServer-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
} |
6 changes: 6 additions & 0 deletions
6
dist/creator/transformations/devServer/__testfixtures__/devServer-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use strict"; | ||
|
||
const utils = require("../../../transformations/utils"); | ||
|
||
/* | ||
* | ||
* Transform for devServer. Finds the devServer property from yeoman and creates a | ||
* property based on what the user has given us. | ||
* | ||
* @param j — jscodeshift API | ||
* @param ast - jscodeshift API | ||
* @param { Object } webpackProperties - Object containing transformation rules | ||
* @returns ast - jscodeshift API | ||
*/ | ||
|
||
module.exports = function(j, ast, webpackProperties) { | ||
function createDevServerProperty(p) { | ||
utils.pushCreateProperty(j, p, "devServer", j.objectExpression([])); | ||
return utils.pushObjectKeys(j, p, webpackProperties, "devServer"); | ||
} | ||
if (webpackProperties && typeof webpackProperties === "object") { | ||
return ast | ||
.find(j.ObjectExpression) | ||
.filter(p => utils.isAssignment(null, p, createDevServerProperty)); | ||
} else if (webpackProperties && webpackProperties.length) { | ||
return ast | ||
.find(j.ObjectExpression) | ||
.filter(p => | ||
utils.isAssignment( | ||
j, | ||
p, | ||
utils.pushCreateProperty, | ||
"devServer", | ||
webpackProperties | ||
) | ||
); | ||
} else { | ||
return ast; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("../../../transformations/defineTest"); | ||
|
||
defineTest(__dirname, "devServer", "devServer-0", { | ||
contentBase: "path.join(__dirname, 'dist')", | ||
compress: true, | ||
port: 9000 | ||
}); | ||
defineTest(__dirname, "devServer", "devServer-1", "someVar"); |
6 changes: 6 additions & 0 deletions
6
dist/creator/transformations/devtool/__testfixtures__/devtool-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
dist/creator/transformations/devtool/__testfixtures__/devtool-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
entry: 'index.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use strict"; | ||
|
||
const utils = require("../../../transformations/utils"); | ||
|
||
/* | ||
* | ||
* Transform for devtool. Finds the devtool property from yeoman and creates a | ||
* property based on what the user has given us. | ||
* | ||
* @param j — jscodeshift API | ||
* @param ast - jscodeshift API | ||
* @param { Object } webpackProperties - Object containing transformation rules | ||
* @returns ast - jscodeshift API | ||
*/ | ||
|
||
module.exports = function(j, ast, webpackProperties) { | ||
if (webpackProperties) { | ||
return ast | ||
.find(j.ObjectExpression) | ||
.filter(p => | ||
utils.isAssignment( | ||
j, | ||
p, | ||
utils.pushCreateProperty, | ||
"devtool", | ||
webpackProperties | ||
) | ||
); | ||
} else { | ||
return ast; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("../../../transformations/defineTest"); | ||
|
||
defineTest(__dirname, "devtool", "devtool-0", "'source-map'"); | ||
defineTest(__dirname, "devtool", "devtool-0", "myVariable"); | ||
defineTest(__dirname, "devtool", "devtool-1", "'cheap-module-source-map'"); | ||
defineTest(__dirname, "devtool", "devtool-1", "false"); |
1 change: 1 addition & 0 deletions
1
dist/creator/transformations/entry/__testfixtures__/entry-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} |
Oops, something went wrong.