66 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-03-18 11:12:50 +01:00
'use strict';
/**
* Module dependencies
*/
// Node.js core.
const fs = require('fs');
const path = require('path');
// Public node modules.
const _ = require('lodash');
/**
* Expose main package JSON of the application
* with basic info, dependencies, etc.
*/
module.exports = scope => {
2016-03-18 11:12:50 +01:00
const cliPkg = scope.strapiPackageJSON || {};
// To determine the Strapi dependency to inject
// in the newly created `package.json`.
const frameworkPkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', '..', 'strapi', 'package.json'))) || {};
2016-07-05 11:10:01 +02:00
2016-03-18 11:12:50 +01:00
// Finally, return the JSON.
return _.merge(scope.appPackageJSON || {}, {
'name': scope.name,
'private': true,
'version': '0.1.0',
'description': 'A Strapi application.',
'dependencies': {
'strapi': getDependencyVersion(cliPkg, 'strapi'),
2016-07-12 11:15:01 +02:00
'strapi-mongoose': getDependencyVersion(cliPkg, 'strapi-mongoose')
2016-03-18 11:12:50 +01:00
},
'main': './server.js',
'scripts': {
'start': 'node server.js',
'strapi': 'node_modules/strapi/bin/strapi.js' // Allow to use `npm run strapi` CLI
2016-03-18 11:12:50 +01:00
},
'author': {
'name': scope.author || 'A Strapi developer',
'email': scope.email || '',
'url': scope.website || ''
},
'maintainers': [{
'name': scope.author || 'A Strapi developer',
'email': scope.email || '',
'url': scope.website || ''
}],
'engines': {
'node': '>= 4.0.0',
'npm': '>= 3.0.0'
},
'license': scope.license || 'MIT'
});
};
/**
* Get dependencies version
*/
function getDependencyVersion(packageJSON, module) {
return module === packageJSON.name ? packageJSON.version : packageJSON.dependencies && packageJSON.dependencies[module];
2016-03-18 11:12:50 +01:00
}