project-cfg
Advanced tools
Comparing version 0.0.5 to 0.0.7
@@ -12,3 +12,4 @@ module.exports = { | ||
'transform-decorators-legacy': 'babel-plugin-transform-decorators', | ||
'transform-class-properties': 'babel-plugin-transform-class-properties' | ||
'transform-class-properties': 'babel-plugin-transform-class-properties', | ||
'transform-runtime': 'babel-plugin-transform-runtime' | ||
}, | ||
@@ -15,0 +16,0 @@ WEBPACK: { |
@@ -7,3 +7,3 @@ /* | ||
* ## They are used by project-cfg to find the right positions to insert code ## | ||
* ## When you remove the comments project-cfg will not found the right positions ## | ||
* ## When you remove the comments project-cfg will not find the right positions ## | ||
* ## project-cfg will then probably override your changes. ## | ||
@@ -10,0 +10,0 @@ * ## ## |
@@ -7,3 +7,3 @@ /* | ||
* ## They are used by project-cfg to find the right positions to insert code ## | ||
* ## When you remove the comments project-cfg will not found the right positions ## | ||
* ## When you remove the comments project-cfg will not find the right positions ## | ||
* ## project-cfg will then probably override your changes. ## | ||
@@ -10,0 +10,0 @@ * ## ## |
@@ -1,7 +0,27 @@ | ||
const PackageEditor = require('./PackageEditor'); | ||
const BabelEditor = require('./BabelEditor'); | ||
const WebpackEditor = require('./WebpackEditor'); | ||
const path = require('path'); | ||
const FileHelper = require('../utils/FileHelper'); | ||
const CONFIG_PATH = path.join(process.cwd(), 'project.cfg'); | ||
const NpmLoader = require('./npm/NpmLoader'); | ||
const BabelLoader = require('./babel/BabelLoader'); | ||
const WebpackLoader = require('./webpack/WebpackLoader'); | ||
const NpmSaver = require('./npm/NpmSaver'); | ||
const BabelSaver = require('./babel/BabelSaver'); | ||
const WebpackSaver = require('./webpack/WebpackSaver'); | ||
module.exports = class ConfigEditor { | ||
static load() { | ||
constructor() { | ||
this.npmLoader = new NpmLoader(); | ||
this.babelLoader = new BabelLoader(); | ||
this.webpackLoader = new WebpackLoader(); | ||
this.npmSaver = new NpmSaver(); | ||
this.babelSaver = new BabelSaver(); | ||
this.webpackSaver = new WebpackSaver(); | ||
} | ||
load() { | ||
"use strict"; | ||
@@ -11,10 +31,11 @@ | ||
return PackageEditor.load().then((npm) => { | ||
return this.npmLoader.load().then((npm) => { | ||
output.npm = npm; | ||
return BabelEditor.load(); | ||
return this.babelLoader.load(); | ||
}).then((babeljs) => { | ||
return output.babel = BabelEditor.parse( babeljs ); | ||
return output.babel = babeljs; | ||
}).then(()=> { | ||
return WebpackEditor.load(); | ||
return this.webpackLoader.load(); | ||
}).then((webpack) => { | ||
@@ -30,8 +51,10 @@ return output.webpack = webpack; | ||
static save(config) { | ||
return PackageEditor.save(config.npm).then(() => { | ||
return BabelEditor.update( config.babel ); | ||
save(config) { | ||
return this.npmSaver.save(config.npm, config).then(() => { | ||
return this.babelSaver.save( config.babel, config ); | ||
}).then(() => { | ||
return WebpackEditor.update( config ); | ||
return this.webpackSaver.save( config.webpack, config ); | ||
}).then(() => { | ||
return FileHelper.save(CONFIG_PATH, JSON.stringify(config, null, "\t")); | ||
}).then(() => { | ||
return config; | ||
@@ -38,0 +61,0 @@ }); |
@@ -8,2 +8,4 @@ const path = require('path'); | ||
var configEditor = new ConfigEditor(); | ||
app.use(function(req, res, next) { | ||
@@ -17,3 +19,3 @@ "use strict"; | ||
if ('OPTIONS' == req.method) { | ||
res.send(200); | ||
res.sendStatus(200); | ||
} | ||
@@ -35,3 +37,3 @@ else { | ||
ConfigEditor.load().then((config)=> { | ||
configEditor.load().then((config)=> { | ||
"use strict"; | ||
@@ -63,9 +65,16 @@ | ||
ConfigEditor.load().then((npmConfig) => { | ||
configEditor.load().then((npmConfig) => { | ||
npmConfig.npm.name = Normalize.snakeCase(body.npm.name || ''); | ||
npmConfig.npm.author = body.npm.author || ''; | ||
npmConfig.npm.main = body.npm.main || ''; | ||
npmConfig.npm.version = body.npm.version || '1.0.0'; | ||
npmConfig.npm.keywords = body.npm.keywords || ''; | ||
npmConfig.npm.license = body.npm.license || ''; | ||
npmConfig.npm.homepage = body.npm.homepage || ''; | ||
npmConfig.npm.private = body.npm.private !== false; | ||
npmConfig.npm.description = body.npm.description || ''; | ||
npmConfig.npm.bugs = body.npm.bugs || ''; | ||
let useEs6 = false; | ||
@@ -85,3 +94,3 @@ if(body.babel.enabled && body.babel.es6enabled) useEs6 = true; | ||
return ConfigEditor.save(npmConfig); | ||
return configEditor.save(npmConfig); | ||
}).then((config) => { | ||
@@ -88,0 +97,0 @@ return Object.assign(output, config); |
{ | ||
"name": "project-cfg", | ||
"version": "0.0.5", | ||
"description": "A helper-package for generating project structures", | ||
"version": "0.0.7", | ||
"description": "A helper-package for generating project structures.", | ||
"bin": { | ||
@@ -12,2 +12,3 @@ "project-cfg": "bin/project-cfg.js" | ||
"start": "webpack -p --config ./webpack/build.babel.js && node bin/project-cfg.js", | ||
"start:nobuild": "node bin/project-cfg.js", | ||
"wp:start": "webpack-dev-server --config ./webpack/builddev.babel.js", | ||
@@ -21,3 +22,4 @@ "wp:build": "webpack -p --config ./webpack/build.babel.js" | ||
"keywords": [ | ||
"webpack" | ||
"webpack", | ||
"builder" | ||
], | ||
@@ -27,3 +29,4 @@ "author": "Michael Braun", | ||
"bugs": { | ||
"url": "https://gitlab.com/michaelsoftware/project-cfg/issues" | ||
"url": "https://gitlab.com/michaelsoftware/project-cfg/issues", | ||
"email": "michaelsoftware1997@gmail.com" | ||
}, | ||
@@ -37,15 +40,17 @@ "homepage": "https://gitlab.com/michaelsoftware/project-cfg#README", | ||
"devDependencies": { | ||
"babel-core": "^6.23.1", | ||
"babel-core": "^6.24.0", | ||
"babel-loader": "^6.4.0", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-env": "^1.2.1", | ||
"babel-preset-es2015": "^6.24.0", | ||
"babel-preset-stage-0": "^6.22.0", | ||
"css-loader": "^0.27.1", | ||
"css-loader": "^0.27.3", | ||
"html-webpack-plugin": "^2.28.0", | ||
"node-sass": "^4.5.0", | ||
"sass-loader": "^6.0.3", | ||
"style-loader": "^0.13.2", | ||
"style-loader": "^0.14.1", | ||
"webpack": "^2.2.1", | ||
"webpack-dev-server": "^2.4.1" | ||
} | ||
"webpack-dev-server": "^2.4.2" | ||
}, | ||
"private": false | ||
} |
@@ -25,3 +25,6 @@ import webpack from 'webpack'; | ||
use: ['babel-loader'], | ||
include: path.resolve(ROOT_PATH, 'src') | ||
include: [ | ||
path.resolve(ROOT_PATH, 'src'), | ||
path.resolve(ROOT_PATH, 'utils') | ||
] | ||
}, | ||
@@ -28,0 +31,0 @@ { |
@@ -23,3 +23,2 @@ /* | ||
//start entries | ||
'src/index.js' | ||
//end entries | ||
@@ -30,3 +29,2 @@ ], | ||
//start resolve | ||
'.js' | ||
//end resolve | ||
@@ -42,21 +40,2 @@ ] | ||
//start rules | ||
{ | ||
test: /.css$/, | ||
use: [{ | ||
loader: 'css-loader' | ||
},{ | ||
loader: 'style-loader' | ||
}], | ||
exclude: /node_modules/ | ||
},{ | ||
test: /.scss$/, | ||
use: [{ | ||
loader: 'css-loader' | ||
},{ | ||
loader: 'style-loader' | ||
},{ | ||
loader: 'sass-loader' | ||
}], | ||
exclude: /node_modules/ | ||
} | ||
//end rules | ||
@@ -63,0 +42,0 @@ ] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
605048
37
1033
13