Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: init create-webpack-app package [1] #4214

Merged
merged 84 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
f910fe3
feat: init new package and installed deps
maverox May 13, 2024
c175c9d
feat: add template directory from prototype
maverox May 13, 2024
12fbc20
build: typescript init
maverox May 15, 2024
92c2f19
build: set type: module in package.json
maverox May 15, 2024
488f3df
feat: change template to align more with generators package
maverox May 16, 2024
a17fa63
feat: add core logic to run generators and also add types
maverox May 16, 2024
bb6ca9f
chore: add scripts in package.json
maverox May 16, 2024
d5e9fc3
build: change module type to esm in package.json
maverox May 16, 2024
667d50d
feat: add entrypoint executable which wraps the generator cli
maverox May 16, 2024
8f89b98
chore: add ejs and @types/ejs as dependencies
maverox May 18, 2024
d2ca7f6
build: change emit module of tsc to esnext
maverox May 18, 2024
acf5fa5
feat: add ejs template rendering support
maverox May 18, 2024
df39698
feat: add entryPoint prompt
maverox May 18, 2024
93c2142
chore: remove unused code
maverox May 18, 2024
85b06bc
chore: change eslint and cspell silencer
maverox May 19, 2024
88acfd2
build: change plopfile.ts on reviews
maverox May 19, 2024
55e13ec
feat: change the templates
maverox May 19, 2024
897e00b
fix: fix missing comma in tsconfig
maverox May 19, 2024
f9cb74a
chore: change package.json on reviews
maverox May 19, 2024
b6baa6a
docs: change readme based on review
maverox May 19, 2024
d9a0856
fix: customACtionConfig support in plopfile.ts setGenerator config pr…
maverox May 27, 2024
d8ec7e1
feat: add npmInstall custom package
maverox Jun 1, 2024
4c59396
chore: remove redundant code
maverox Jun 1, 2024
04b5f90
fix: typo in prompt
maverox Jun 1, 2024
1bdf924
feat: add skip prompt functionality
maverox Jun 5, 2024
5e6a70b
chore: install commander and remove obsolete deps
maverox Jun 7, 2024
bb5e201
refactor: remove dynamic prompt and revert to previous state
maverox Jun 7, 2024
9bf21bf
feat: create commander cli and implement skip feat
maverox Jun 7, 2024
a295914
refactor: change prompt order to have genPath as first
maverox Jun 8, 2024
e6add83
refactor: change console output format for deps installation
maverox Jun 8, 2024
4ac8bf0
feat: change -s flag to -f|--force and make it default
maverox Jun 8, 2024
d1fb3e7
chore: add 'uzair' as a word for cspell
maverox Jun 8, 2024
2928772
test: create test suite for create-webpack-app package
maverox Jun 8, 2024
3f66230
Update packages/create-webpack-app/README.md
maverox Jun 15, 2024
769e095
Update packages/create-webpack-app/README.md
maverox Jun 15, 2024
cb309df
refactor: migrate cli logic to ts from js
maverox Jun 25, 2024
860e5c2
feat: add conditional file generation based on dynamic action function
maverox Jun 25, 2024
de92604
docs: change doc to align with its features
maverox Jun 25, 2024
b150fa8
feat: change dependency installation to be cross-compatible
maverox Jun 25, 2024
f3315f4
refactor: remove unused var
maverox Jun 25, 2024
19f59ea
feat: add types
maverox Jun 25, 2024
02f04cb
chore: enable eslint for package/create-webpack-app
maverox Jun 25, 2024
284ab14
chore: change module type and fix control flow for errors
maverox Jun 25, 2024
b80f340
feat: add logger utility module
maverox Jul 1, 2024
944bb33
refactor: refactor and implement logger
maverox Jul 1, 2024
b82f4be
feat: change stdio settings for pkgInstall action
maverox Jul 1, 2024
b4cca8f
fix: change conditional prompt to align with original logic
maverox Jul 1, 2024
e3ef415
test: implement test according to package
maverox Jul 1, 2024
0a42c64
fix: changed template package.json to improve compatibility with syntax
maverox Jul 1, 2024
f0196bd
chore: add peerDep webpack-cli and dep colorette
maverox Jul 1, 2024
8e9dfb6
feat: remove projectName and use path only
maverox Jul 4, 2024
ff53355
chore: remove "uzair" as word from cspell.json
maverox Jul 4, 2024
22873e8
chore: remove test/create-webpack-app from .eslintignore
maverox Jul 7, 2024
fdd61df
perf: change generator conditional flows and dependencies attached
maverox Jul 7, 2024
ea92e56
refactor: remove redundant code from test.utils and extend from utils…
maverox Jul 7, 2024
3fb7b98
test: update snapshots and test according to previous two commits
maverox Jul 7, 2024
2c5bfb3
feat: loader and plugin commands, more templates (#4225)
maverox Aug 25, 2024
a6e4b61
feat: modular and scalable refactor, --template flag and react templa…
maverox Aug 25, 2024
06fe8cf
fix: remove obsolete files after merge
maverox Aug 25, 2024
add60da
test: change vue tests according to change in default value of "cssType"
maverox Aug 25, 2024
e1664ff
fix: use more compatible splice than toSpliced method
maverox Aug 25, 2024
72c6efd
test: skip all but first test for loader suite
maverox Aug 26, 2024
dd7dff1
test: skip all tests for loader suite (modify previous commit)
maverox Aug 26, 2024
804638c
feat: improve react generator and template
maverox Sep 1, 2024
830239f
feat: improve vue generator and templates
maverox Sep 1, 2024
f6fffa8
feat: make cssType as CSS only instead of none for svelte and remove …
maverox Sep 1, 2024
572f42a
feat: remove redundant build:prod command from template package.json
maverox Sep 1, 2024
67682a1
test: modify test according to changes in previous commit and also re…
maverox Sep 1, 2024
403d12e
Feat: File generation and collision handler [6] (#4249)
maverox Sep 11, 2024
20073b9
fix: remove inconsistencies after merge
maverox Sep 13, 2024
390325e
feat: add fileGenerator improved version with better conflict resolution
maverox Sep 13, 2024
acd575a
fix: test discrepancy after merge
maverox Sep 17, 2024
838a6fa
fix: fix issue with plop.js prompt failure due to inquirer update
maverox Sep 17, 2024
5ba3f4f
Revert "fix: fix issue with plop.js prompt failure due to inquirer up…
maverox Sep 20, 2024
6697fa0
fix: failing prompts after update to inquirer v9.3.6
maverox Sep 20, 2024
b79e528
chore: remove obsolete comments
maverox Sep 20, 2024
e33e4cb
test: skip `create-webpack-app` suites for node ver. lower than 18
maverox Sep 21, 2024
1cfccdd
ci: fix failing CI on windows due to unnormalized paths in logs
maverox Sep 21, 2024
28c6a83
chore: fix lint
snitin315 Oct 2, 2024
6092fb1
Merge remote-tracking branch 'origin/master' into gsoc/create-webpack…
snitin315 Oct 2, 2024
e714995
chore: refactor nodeVersion util
snitin315 Oct 2, 2024
cd8ab15
chore: fix tests
snitin315 Oct 2, 2024
01cb7a4
Merge remote-tracking branch 'origin/master' into gsoc/create-webpack…
snitin315 Oct 3, 2024
cc36af2
Merge remote-tracking branch 'origin/master' into gsoc/create-webpack…
snitin315 Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ module.exports = {
"node/no-unsupported-features/es-syntax": "off",
},
},
{
files: ["**/packages/create-webpack-app/**/*.js"],
parserOptions: {
sourceType: "module",
},
},
],
};
41 changes: 41 additions & 0 deletions packages/create-webpack-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<div>
<a href="https://github.com/webpack/webpack-cli">
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
</div>

# create-webpack-app CLI

## About

- `create-webpack-app` is a cli tool that enables developers to scaffold a new webpack project quickly. It provides developers with a flexible set of commands to increase speed when setting up a custom webpack project. webpack CLI addresses these needs by providing tools to improve the setup of custom webpack configuration.
- It also supports several front-end frameworks and libraries like React, Angular, Vue, Svelte, etc.
- Webpack Loader and Plugin scaffolding is also supported.

## Supported arguments and commands

### Usage

```bash
npx create-webpack-app [command] [options]
```

### CLI options

**To generate default template**

```bash
npx create-webpack-app
```

**To generate with default answers**

```bash
npx create-webpack-app -f, --force
```

**To scaffold in a specified path**

```bash
npx create-webpack-app [generation-path]
```
4 changes: 4 additions & 0 deletions packages/create-webpack-app/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

//eslint-disable-next-line
import * as cli from "../lib/index.js";
56 changes: 56 additions & 0 deletions packages/create-webpack-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "create-webpack-app",
"version": "1.0.0",
"description": "CLI for scaffolding webpack projects using default config, framework templates, loader or plugins templates",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/webpack-cli/create-webpack-app.git"
},
"homepage": "https://github.com/webpack/webpack-cli/tree/master/packages/create-webpack-app",
"bugs": "https://github.com/webpack/webpack-cli/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"bin": {
"create-webpack-app": "./bin/cli.js"
},
"type": "module",
"main": "./lib/index.js",
"scripts": {
"build": "tsc --build",
"watch": "tsc --watch"
},
"engines": {
"node": ">=18.12.0"
},
"keywords": [
"webpack",
"cli",
"scaffolding",
"module",
"bundler",
"web",
"frameworks"
],
"files": [
"bin",
"lib",
"!**/*__tests__"
],
"peerDependencies": {
"webpack-cli": "^5.x.x"
},
"dependencies": {
"colorette": "^2.0.20",
"commander": "^12.1.0",
"cross-spawn": "^7.0.3",
"ejs": "^3.1.10",
"node-plop": "^0.32.0"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.6",
"@types/ejs": "^3.1.5"
}
}
1 change: 1 addition & 0 deletions packages/create-webpack-app/src/generators/default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// refactored generator will be written here shortly
80 changes: 80 additions & 0 deletions packages/create-webpack-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Cspell:ignore plopfile, plopfile.js
import { Command } from "commander";
import { resolve, dirname } from "path";
import nodePlop from "node-plop";
import { fileURLToPath } from "url";

// eslint-disable-next-line node/no-missing-import
import { onSuccessHandler, onFailureHandler, logger } from "./utils/logger.js";

const __dirname = dirname(fileURLToPath(import.meta.url));

const program = new Command();
const plop = await nodePlop(resolve(__dirname, "./plopfile.js"));
const defaultValues = {
init: {
projectPath: process.cwd(),
langType: "none",
devServer: true,
htmlWebpackPlugin: true,
workboxWebpackPlugin: true,
cssType: "none",
isCSS: false,
isPostCSS: false,
extractPlugin: "No",
packageManager: "npm",
},
};

program
.version("1.0.0", "-v, --version")
.usage("[command] [options]")
.helpOption("-h, --help", "Display help for command")
.description("A CLI tool to generate a Webpack project");

program
.command("init", { isDefault: true })
.aliases(["i", "n", "c", "create", "new"])
.description("Initialize a new Webpack project")
.argument("[projectPath]", "Path to create the project")
.option("-f, --force", "Skip the prompt and use the default values", false)
.action(async function (projectPath, opts) {
const { force } = opts;
const initGenerator = plop.getGenerator("init");
const byPassValues: Array<string> = [];

if (projectPath) byPassValues.push(projectPath);
try {
if (force) {
logger.warn("Skipping the prompt and using the default values");

logger.info("Initializing a new Webpack project");
await initGenerator.runActions(
{
...defaultValues.init,
projectPath: byPassValues[0]
? resolve(process.cwd(), byPassValues[0])
: defaultValues.init.projectPath,
},
{
onSuccess: onSuccessHandler,
onFailure: onFailureHandler,
},
);
} else {
const answers = await initGenerator.runPrompts(byPassValues);

logger.info("Initializing a new Webpack project");
await initGenerator.runActions(answers, {
onSuccess: onSuccessHandler,
onFailure: onFailureHandler,
});
}
logger.success("Project has been initialised with webpack!");
} catch (error) {
logger.error(`Failed to initialize the project with webpack!\n ${error}`);
process.exit(2);
}
});

program.parse();
Loading
Loading