Skip to content

Commit

Permalink
chore: post refactor CLI (#1237)
Browse files Browse the repository at this point in the history
* chore(cli): moved package under "webpack-cli" folder

* chore(webpack-cli): removed inquirer in favour of enquirer (more light)
  • Loading branch information
ematipico authored Feb 18, 2020
1 parent 358651e commit 6cc6a49
Show file tree
Hide file tree
Showing 38 changed files with 13,351 additions and 107 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ lerna-debug.log
# Yeoman file
.yo-rc.json

# Yarn lock file
yarn.lock

# source maps of docs
docs/**/*.map
junit.xml
Expand Down
45 changes: 0 additions & 45 deletions packages/cli/bin/cli.js

This file was deleted.

52 changes: 0 additions & 52 deletions packages/cli/package.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions packages/webpack-cli/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

'use strict';
require('v8-compile-cache');
const execa = require('execa');
const importLocal = require('import-local');
const logger = require('../lib/utils/logger');
const parseArgs = require('../lib/utils/parse-args');

// Prefer the local installation of webpack-cli
if (importLocal(__filename)) {
// return;
}
process.title = 'webpack';

const [, , ...rawArgs] = process.argv;
const { cliArgs, nodeArgs } = parseArgs(rawArgs);
const bootstrapPath = require.resolve('../lib/bootstrap');

execa('node', [...nodeArgs, bootstrapPath, ...cliArgs], { stdio: 'inherit' }).catch(e => {
process.exit(e.exitCode);
});
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { prompt } = require('inquirer');
const { prompt } = require('enquirer');
const chalk = require('chalk');
const logger = require('../utils/logger');
const execa = require('execa');
Expand Down Expand Up @@ -50,8 +50,7 @@ class ExternalCommand {
type: 'confirm',
name: 'installConfirm',
message: question,
default: 'Y',
choices: ['Yes', 'No', 'Y', 'N', 'y', 'n'],
initial: 'Y'
},
]);
if (installConfirm) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class WebpackCLI extends GroupHelper {
return commandArgs(...args);
}


getCoreFlags() {
return core;
}
Expand Down
49 changes: 49 additions & 0 deletions packages/webpack-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "webpack-cli",
"version": "4.0.0-beta.3",
"description": "CLI for webpack & friends",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/webpack/webpack-cli.git"
},
"bin": {
"webpack-cli": "./bin/cli.js"
},
"main": "./lib/webpack-cli.js",
"engines": {
"node": ">=10.13.0"
},
"keywords": [
"webpack",
"cli",
"scaffolding",
"module",
"bundler",
"web"
],
"files": [
"lib",
"bin/cli.js"
],
"dependencies": {
"ansi-escapes": "^4.2.1",
"chalk": "^3.0.0",
"cli-table3": "^0.5.1",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
"execa": "^3.2.0",
"import-local": "^3.0.2",
"enquirer": "^2.3.4",
"interpret": "^2.0.0",
"v8-compile-cache": "^2.1.0",
"webpack-log": "^3.0.1",
"webpack-merge": "^4.2.2"
},
"peerDependencies": {
"webpack": "^5.0.0-beta.12"
},
"devDependencies": {
"@webpack-cli/info": "1.0.1-alpha.0"
}
}
2 changes: 1 addition & 1 deletion test/info/info-help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const chalk = require('chalk');
const path = require('path');
const { run } = require('../utils/test-utils');
const { commands } = require('../../packages/cli/lib/utils/cli-flags');
const { commands } = require('../../packages/webpack-cli/lib/utils/cli-flags');

const runInfo = args => {
return run(path.resolve(__dirname), args, false);
Expand Down
2 changes: 1 addition & 1 deletion test/node/node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { stat } = require('fs');
const { resolve, sep } = require('path');
const { run, extractSummary } = require('../utils/test-utils');
const parseArgs = require('../../packages/cli/lib/utils/parse-args');
const parseArgs = require('../../packages/webpack-cli/lib/utils/parse-args');

describe('node flags', () => {
it('parseArgs helper must work correctly', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/utils/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const execa = require('execa');
const { sync: spawnSync } = execa;
const { Writable } = require('readable-stream');
const WEBPACK_PATH = path.resolve(__dirname, '../../packages/cli/bin/cli.js');
const WEBPACK_PATH = path.resolve(__dirname, '../../packages/webpack-cli/bin/cli.js');
const ENABLE_LOG_COMPILATION = process.env.ENABLE_PIPE || false;
/**
* Description
Expand Down
Loading

0 comments on commit 6cc6a49

Please sign in to comment.