|
| 1 | +const path = require('path'); |
| 2 | +const fs = require('fs'); |
| 3 | + |
| 4 | +function sortObject(object) { |
| 5 | + // Based on https://github.com/yarnpkg/yarn/blob/v1.3.2/src/config.js#L79-L85 |
| 6 | + const sortedObject = {}; |
| 7 | + Object.keys(object).sort().forEach(item => { |
| 8 | + sortedObject[item] = object[item]; |
| 9 | + }); |
| 10 | + return sortedObject; |
| 11 | +} |
| 12 | + |
1 | 13 | module.exports = {
|
2 | 14 | "helpers": {
|
3 | 15 | "if_or": function (v1, v2, options) {
|
@@ -72,7 +84,7 @@ module.exports = {
|
72 | 84 | },
|
73 | 85 | "unit": {
|
74 | 86 | "type": "confirm",
|
75 |
| - "message": "Setup unit tests" |
| 87 | + "message": "Set up unit tests" |
76 | 88 | },
|
77 | 89 | "runner": {
|
78 | 90 | "when": "unit",
|
@@ -115,5 +127,20 @@ module.exports = {
|
115 | 127 | "test/e2e/**/*": "e2e",
|
116 | 128 | "src/router/**/*": "router"
|
117 | 129 | },
|
118 |
| - "completeMessage": "To get started:\n\n {{^inPlace}}cd {{destDirName}}\n {{/inPlace}}npm install\n npm run dev\n\nDocumentation can be found at https://vuejs-templates.github.io/webpack" |
| 130 | + "complete": function (data) { |
| 131 | + const packageJsonFile = path.join( |
| 132 | + data.inPlace ? "" : data.destDirName, |
| 133 | + "package.json" |
| 134 | + ); |
| 135 | + const packageJson = JSON.parse(fs.readFileSync(packageJsonFile)); |
| 136 | + packageJson.devDependencies = sortObject(packageJson.devDependencies); |
| 137 | + packageJson.dependencies = sortObject(packageJson.dependencies); |
| 138 | + fs.writeFileSync( |
| 139 | + packageJsonFile, |
| 140 | + JSON.stringify(packageJson, null, 2) + "\n" |
| 141 | + ); |
| 142 | + |
| 143 | + const message = `To get started:\n\n ${data.inPlace ? '' : `cd ${data.destDirName}\n `}npm install\n npm run dev\n\nDocumentation can be found at https://vuejs-templates.github.io/webpack`; |
| 144 | + console.log("\n" + message.split(/\r?\n/g).map(line => " " + line).join("\n")); |
| 145 | + } |
119 | 146 | };
|
0 commit comments