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

Config path from package.json #1075

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const semver = require('semver');

module.exports = function(generator) {
const major = semver.major(process.version);
const envConfigDir = process.env['NODE_CONFIG_DIR'];
const configDirectory = envConfigDir ? p.join(envConfigDir) : 'config/';
const { props } = generator;
const lib = props.src;
const [ packager, version ] = props.packager.split('@');
Expand All @@ -22,7 +24,8 @@ module.exports = function(generator) {
bugs: {},
directories: {
lib,
test: 'test/'
test: 'test/',
config: configDirectory
},
engines: {
node: `^${major}.0.0`,
Expand Down
4 changes: 2 additions & 2 deletions packages/generator-feathers/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ module.exports = class AppGenerator extends Generator {
)

this.fs.writeJSON(
this.destinationPath('config', 'default.json'),
this.destinationPath(this.configDirectory, 'default.json'),
makeConfig.configDefault(this)
);

this.fs.writeJSON(
this.destinationPath('config', 'production.json'),
this.destinationPath(this.configDirectory, 'production.json'),
makeConfig.configProduction(this)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ module.exports = class AuthGenerator extends Generator {

this.conflicter.force = true;
this.fs.writeJSON(
this.destinationPath('config', 'default.json'),
this.destinationPath(this.configDirectory, 'default.json'),
config
);
}
Expand Down Expand Up @@ -167,7 +167,7 @@ module.exports = class AuthGenerator extends Generator {
dependencies.push(`@feathersjs/authentication-${strategy}`);
}
});

if(!this.fs.exists(this.destinationPath(this.libDirectory, 'services', context.kebabEntity, `${context.kebabEntity}.service.js`))) {
// Create the users service
this.composeWith(require.resolve('../service'), {
Expand Down
3 changes: 1 addition & 2 deletions packages/generator-feathers/generators/connection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ module.exports = class ConnectionGenerator extends Generator {

if (!config[database]) {
config[database] = configuration;

this.conflicter.force = true;
this.fs.writeJSON(
this.destinationPath('config', 'default.json'),
this.destinationPath(this.configDirectory, 'default.json'),
config
);
}
Expand Down
7 changes: 5 additions & 2 deletions packages/generator-feathers/lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class BaseGenerator extends Generator {
constructor(args, opts) {
super(args, opts);

const defaultConfig = this.destinationPath('config', 'default.json');
const defaultConfig = this.destinationPath(this.configDirectory, 'default.json');

this.generatorPkg = this.fs.readJSON(path.join(__dirname, '..', 'package.json'));
this.pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
Expand Down Expand Up @@ -53,8 +53,11 @@ module.exports = class BaseGenerator extends Generator {
return (this.pkg.directories && this.pkg.directories.test) || 'test';
}

get configDirectory() {
return (this.pkg && this.pkg.directories && this.pkg.directories.config) || 'config';
}
_packagerInstall(deps, options) {
const packager = this.pkg.engines && this.pkg.engines.yarn ?
const packager = this.pkg.engines && this.pkg.engines.yarn ?
'yarn' : 'npm';
const method = `${packager}Install`;
const isDev = options.saveDev;
Expand Down