Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabh3112 committed Jan 7, 2021
1 parent ec7d6cc commit a49ea8c
Show file tree
Hide file tree
Showing 8 changed files with 5,144 additions and 97 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@ function scaffold(answers) {

let index = fs.readFileSync(resolveTemplate("./index.js")).toString();
index = index.replace(/<name>/g, answers.name);
index = index.replace(/<description>/, answers.description);
index = index.replace(/<author>/, answers.author);
index = index.replace(/<description>/g, answers.description);
index = index.replace(/<author>/g, answers.author);

let readme = fs.readFileSync(resolveTemplate("./README.md")).toString();
readme = readme.replace(/<name>/g, answers.name);
readme = readme.replace(/<description>/g, answers.description);

fs.writeFileSync(resolveUser("./package.json"), JSON.stringify(packageJSON, null, 2));
fs.writeFileSync(resolveUser("./index.js"), index);
fs.writeFileSync(resolveUser("./README.md"), readme);
done();
}

Expand All @@ -98,7 +103,6 @@ function footer() {
* ${c.blue(`Create an issue:
https://github.com/webpack/webpack-cli`)}
* ${c.blue('Tweet us at @webpack')}
`
)
}
Expand Down
5,180 changes: 5,099 additions & 81 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"ansi-colors": "^3.2.4",
"inquirer": "^6.2.2"
},
"devDependencies": {},
"devDependencies": {
"@webpack-cli/generators": "^1.2.1",
"webpack-cli": "^4.3.1"
},
"bin": {
"webpack-scaffold": "./index.js"
},
Expand Down
7 changes: 7 additions & 0 deletions template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# webpack-scaffold-<name>

<description>


---
Created using [`webpack-scaffold-pwa`](https://github.com/rishabh3112/webpack-scaffold-starter)
25 changes: 14 additions & 11 deletions template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
const Generator = require('yeoman-generator');
const {
List,
RawList,
CheckList,
Input,
InputValidate,
Confirm
} = require("@webpack-cli/webpack-scaffold");
} = require("@webpack-cli/generators/lib/utils/scaffold-utils");

const {getPackageManager} = require("webpack-cli").utils;

module.exports = class WebpackGenerator extends Generator {
constructor(args, opts) {
super(args, opts);
this.dependences = ["webpack", "webpack-cli"];
opts.env.configuration = {
dev: {
topScope: [],
topScope: ["// genrated using webpack-scaffold-<name>"],
webpackOptions: {}
}
}
Expand All @@ -28,17 +29,19 @@ module.exports = class WebpackGenerator extends Generator {
const done = this.async();
console.log(
`
webpack-scaffold-<name>
-----------------------
<description>
webpack-scaffold-<name>
-----------------------
<description>
`);
this.prompt(Confirm("start", "Do you want to scaffold? "))
Confirm(this, "start", "Do you want to scaffold? ")
.then((answer) => {
if (answer.start) {
console.log("Let's start scaffolding!");
done();
} else {
console.log("Okay, Exiting...");
process.exit();
}
done(); // to end questioning
})
}
/**
Expand All @@ -47,14 +50,14 @@ module.exports = class WebpackGenerator extends Generator {
*/
writing() {
this.config.set('configuration', this.options.env.configuration);

}

/**
* install()
* @description install dependencies in user directory
*/
install() {
this.installDependencies();
const pkgManager = getPackageManager();
this.scheduleInstallTask(pkgManager, this.dependences);
}
};
2 changes: 1 addition & 1 deletion template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"yeoman-generator": "^3.2.0"
},
"devDependencies": {
"@webpack-cli/webpack-scaffold": "^0.1.5"
"@webpack-cli/generators": "^0.1.5"
},
"author": "",
"license": "MIT"
Expand Down
6 changes: 6 additions & 0 deletions test/scaffold/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "scaffold",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
6 changes: 6 additions & 0 deletions test/scaffolder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "scaffolder",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}

0 comments on commit a49ea8c

Please # to comment.