create-ui5-webapp
Advanced tools
Comparing version 1.0.6 to 1.0.7
module.exports = { | ||
controllerContent(componentName) { | ||
controllerContent(componentName, namespace) { | ||
return `sap.ui.define([ | ||
@@ -8,3 +8,3 @@ "sap/ui/core/mvc/Controller" | ||
var oController = Controller.extend("namespace.${componentName}.controller.app"); | ||
var oController = Controller.extend("${namespace}.${componentName}.controller.app"); | ||
@@ -30,4 +30,4 @@ /* | ||
</mvc:View>`, | ||
componentContent: | ||
`sap.ui.define([ | ||
componentContent(componentName, namespace) { | ||
return `sap.ui.define([ | ||
"sap/ui/core/UIComponent" | ||
@@ -40,3 +40,3 @@ ], function(UIComponent) { | ||
*/ | ||
var oComponent = UIComponent.extend("namespace.webapp.Component", { | ||
var oComponent = UIComponent.extend("${namespace}.${componentName}.Component", { | ||
metadata: { | ||
@@ -60,9 +60,10 @@ manifest: "json" | ||
});`, | ||
manifestContent: | ||
`{ | ||
});` | ||
}, | ||
manifestContent(componentName, namespace) { | ||
return `{ | ||
"_version": "1.5.0", | ||
"sap.app": { | ||
"_version": "1.0.0", | ||
"id": "namespace.webapp", | ||
"id": "${namespace}.${componentName}", | ||
"type": "component", | ||
@@ -93,3 +94,3 @@ "dataSources": { | ||
"_version": "1.0.0", | ||
"rootView": "namespace.webapp.view.app", | ||
"rootView": "${namespace}.${componentName}.view.app", | ||
"dependencies": { | ||
@@ -111,3 +112,3 @@ "minUI5Version": "1.48.5", | ||
"settings": { | ||
"bundleName": "namespace.webapp.i18n.i18n" | ||
"bundleName": "${namespace}.${componentName}.i18n.i18n" | ||
} | ||
@@ -123,3 +124,3 @@ }, | ||
"viewType": "XML", | ||
"viewPath": "namespace.webapp.view", | ||
"viewPath": "${namespace}.${componentName}.view", | ||
"controlAggregation": "pages", | ||
@@ -144,3 +145,4 @@ "controlId": "appContainer" | ||
}` | ||
} | ||
} | ||
95
index.js
@@ -7,14 +7,10 @@ const fs = require('fs'); | ||
let componentName = process.argv[2]; | ||
console.log("COMPONENTNAME: " + componentName); | ||
console.log("PROCESS.ARGV: " + process.argv); | ||
return componentName; | ||
} | ||
exports.getNameOfNamespace = () => { | ||
let namespace = process.argv[3]; | ||
return namespace; | ||
} | ||
// exports.findSecondArg = () => { | ||
// let arg = process.argv[3]; | ||
// console.log("secondArg: " + arg); | ||
// return arg; | ||
// } | ||
exports.createComponent = (componentName = "webapp") => { | ||
exports.createComponent = (componentName = "webapp", namespace = "namespace") => { | ||
fs.mkdirSync(componentName); // component's name | ||
@@ -24,3 +20,3 @@ | ||
fs.mkdirSync(componentName + "/controller"); | ||
fs.writeFile(componentName + "/controller/app.controller.js", fileContent.controllerContent(componentName), (err) => { | ||
fs.writeFile(componentName + "/controller/app.controller.js", fileContent.controllerContent(componentName, namespace), (err) => { | ||
if (err) throw err; | ||
@@ -55,3 +51,3 @@ console.log("app controller has been created"); | ||
// create Component.js | ||
fs.writeFile(componentName + "/Component.js", fileContent.componentContent, (err) => { | ||
fs.writeFile(componentName + "/Component.js", fileContent.componentContent(componentName, namespace), (err) => { | ||
if (err) throw err; | ||
@@ -62,3 +58,3 @@ console.log("Component.js file has been created"); | ||
// create manifest.json | ||
fs.writeFile(componentName + "/manifest.json", fileContent.manifestContent, (err) => { | ||
fs.writeFile(componentName + "/manifest.json", fileContent.manifestContent(componentName, namespace), (err) => { | ||
if (err) throw err; | ||
@@ -68,75 +64,2 @@ console.log("manifest.json file has been created"); | ||
} | ||
// const fs = require('fs'); | ||
// const fileContent = require('./fileContent'); | ||
// exports.findArg = () => { | ||
// let arg = process.argv[2]; | ||
// return arg; | ||
// } | ||
// exports.createComponent = (componentName = "webapp") => { | ||
// fs.mkdirSync(componentName); // component's name | ||
// // create controller folder and app controller | ||
// fs.mkdir(componentName + "/controller", (err) => { | ||
// if (err) throw err; | ||
// console.log("controller folder has been created"); | ||
// }); | ||
// fs.writeFile(componentName + "/controller/app.controller.js", fileContent.controllerContent, (err) => { | ||
// if (err) throw err; | ||
// console.log("app controller has been created"); | ||
// }); | ||
// // create css folder and style.css | ||
// fs.mkdir(componentName + "/css", (err) => { | ||
// if (err) throw err; | ||
// console.log("css folder has been created"); | ||
// }); | ||
// fs.writeFile(componentName + "/css/style.css", fileContent.CSSContent, (err) => { | ||
// if (err) throw err; | ||
// console.log("style.css file has been created"); | ||
// }); | ||
// // create i18n folder and i18n.properties file | ||
// fs.mkdir(componentName + "/i18n", (err) => { | ||
// if (err) throw err; | ||
// console.log("i18n folder has been created"); | ||
// }); | ||
// fs.writeFile(componentName + "/i18n/i18n.properties", fileContent.i18nContent, (err) => { | ||
// if (err) throw err; | ||
// console.log("i18n.properties file has been created"); | ||
// }); | ||
// // create test folder | ||
// fs.mkdir(componentName + "/test", (err) => { | ||
// if (err) throw err; | ||
// console.log("test folder has been created"); | ||
// }); | ||
// // create view folder and app view | ||
// fs.mkdir(componentName + "/view", (err) => { | ||
// if (err) throw err; | ||
// console.log("view folder has been created"); | ||
// }); | ||
// fs.writeFile(componentName + "/view/app.view.xml", fileContent.viewContent, (err) => { | ||
// if (err) throw err; | ||
// console.log("app view has been created"); | ||
// }); | ||
// // create Component.js | ||
// fs.writeFile(componentName + "/Component.js", fileContent.componentContent, (err) => { | ||
// if (err) throw err; | ||
// console.log("Component.js file has been created"); | ||
// }); | ||
// // create manifest.json | ||
// fs.writeFile(componentName + "/manifest.json", fileContent.manifestContent, (err) => { | ||
// if (err) throw err; | ||
// console.log("manifest.json file has been created"); | ||
// }); | ||
// } | ||
} |
{ | ||
"name": "create-ui5-webapp", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,4 +0,5 @@ | ||
const createUi5Webapp = require("create-ui5-webapp"); | ||
var createUi5Webapp = require("create-ui5-webapp"); | ||
let componentName = createUi5Webapp.getComponentName(); | ||
let namespace = createUi5Webapp.getNameOfNamespace(); | ||
createUi5Webapp.createComponent(componentName); | ||
createUi5Webapp.createComponent(componentName, namespace); |
6099
178