Skip to content

Update project creation: sort dependencies in package.json #1118

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

Merged
merged 2 commits into from
Dec 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 28 additions & 1 deletion meta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
const path = require('path');
const fs = require('fs');

function sortObject(object) {
// Based on https://github.com/yarnpkg/yarn/blob/v1.3.2/src/config.js#L79-L85
const sortedObject = {};
Object.keys(object).sort().forEach(item => {
sortedObject[item] = object[item];
});
return sortedObject;
}

module.exports = {
"helpers": {
"if_or": function (v1, v2, options) {
Expand Down Expand Up @@ -115,5 +127,20 @@ module.exports = {
"test/e2e/**/*": "e2e",
"src/router/**/*": "router"
},
"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"
"complete": function (data) {
const packageJsonFile = path.join(
data.inPlace ? "" : data.destDirName,
"package.json"
);
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile));
packageJson.devDependencies = sortObject(packageJson.devDependencies);
packageJson.dependencies = sortObject(packageJson.dependencies);
fs.writeFileSync(
packageJsonFile,
JSON.stringify(packageJson, null, 2) + "\n"
);

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`;
console.log("\n" + message.split(/\r?\n/g).map(line => " " + line).join("\n"));
}
};
36 changes: 17 additions & 19 deletions template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,8 @@
"vue-router": "^3.0.1"{{/router}}
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
{{#lint}}
"babel-eslint": "^7.1.1",
{{/lint}}
"babel-loader": "^7.1.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
{{#lint}}
"eslint": "^3.19.0",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
Expand All @@ -60,12 +48,6 @@
"eslint-plugin-import": "^2.7.0",
{{/if_eq}}
{{/lint}}
"eventsource-polyfill": "^0.9.6",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"webpack-bundle-analyzer": "^2.9.0",
{{#if_eq runner "jest"}}
"babel-jest": "^21.0.2",
"babel-plugin-dynamic-import-node": "^1.2.0",
Expand Down Expand Up @@ -93,13 +75,29 @@
"babel-plugin-istanbul": "^4.1.1",
"phantomjs-prebuilt": "^2.1.14",
{{/if_eq}}
"node-notifier": "^5.1.2",
{{#e2e}}
"chromedriver": "^2.27.2",
"cross-spawn": "^5.0.1",
"nightwatch": "^0.9.12",
"selenium-server": "^3.0.1",
{{/e2e}}
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-loader": "^7.1.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"eventsource-polyfill": "^0.9.6",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"webpack-bundle-analyzer": "^2.9.0",
"node-notifier": "^5.1.2",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"semver": "^5.3.0",
Expand Down