From 0952cc4ee773c445267f7646caae543f926bb368 Mon Sep 17 00:00:00 2001 From: Francisco Miguel Maciel Date: Thu, 26 Jul 2018 12:42:30 +0100 Subject: [PATCH 1/8] Alter initial scaffolding configuration to check the registry and suggest the channels --- generators/app/index.ts | 212 +++++++++++++++++++++++++++++--- generators/application/index.ts | 6 +- generators/html.ts | 15 +++ 3 files changed, 212 insertions(+), 21 deletions(-) diff --git a/generators/app/index.ts b/generators/app/index.ts index 02e3da7..794114f 100644 --- a/generators/app/index.ts +++ b/generators/app/index.ts @@ -1,7 +1,21 @@ import * as path from "path"; -import { HtmlGenerator } from "../html"; +import { HtmlGenerator , WebAppName } from "../html"; import { Answers } from "yeoman-generator"; +/** + * Interface the contains the address of a registry and the corresponding available channels + */ +interface RegistryChannels { + /** + * Address of the registry + */ + registry: string, + /** + * Available channels + */ + channels: string[] | null; +} + export = class extends HtmlGenerator { packagePrefix: string; @@ -24,29 +38,31 @@ export = class extends HtmlGenerator { { type : "input", name : "packagePrefix", - message : "Please specify the client's prefix (example: cmf) ", + message : "Please specify the client's prefix (example: customization) ", default : null, validate: (input: string, answers: Answers): boolean => { return typeof input === "string" && !!input && input !== "cmf"; }, store : true - }, - { - type : "input", - name : "registry", - message : "What is your npm registry endpoint? ", - store : true - }, - { - type : "input", - name : "channel", - message : "What is the channel you want to use?", - store : true } - ]).then((answers) => { - this.packagePrefix = answers.packagePrefix; - this.registry = answers.registry; - this.channel = answers.channel; + ]).then((prefixAnswers) => { + this.packagePrefix = prefixAnswers.packagePrefix; + // Get the registry endpoint + return this._promptForRegistry() + .then((registryChannels) => { + this.registry = registryChannels.registry; + let options: string[] | null = null; + // If there are channels, use them on the prompt for channel + if (registryChannels != null && registryChannels.channels != null) { + options = registryChannels.channels; + options.push("other"); + } + // Get the channel + return this._promptForChannel(options) + .then((channel) => { + this.channel = channel; + }); + }) }); } @@ -68,4 +84,164 @@ export = class extends HtmlGenerator { this.config.set("isRoot", true); this.config.save(); } + + /** + * Utility method to prompt the user for channel + * @param options Available channels from the user to choose from + * @returns String containing the chosen channel + */ + private _promptForChannel(options: string[] | null): Promise { + // Prompt for the user to select a channel from the list + if (options != null && options.length > 0) { + return this.prompt([ + { + type : "list", + name : "channel", + message : "What channel from the available channels do you want to use?", + choices : options + }, + ]).then((listAnswers) => { + if (listAnswers.channel === "other") { + return this._promptForChannel(null); + } else { + return listAnswers.channel; + } + }) + } else { + // Prompt for the user to input a channel + return this.prompt([ + { + type : "input", + name : "channel", + message : "What is the channel you want to use?", + validate: (input: string, answers: Answers): boolean => { + return typeof input === "string" && !!input; + }, + store: true + } + ]).then((channelAnswer) => { + return channelAnswer.channel; + }); + } + } + + /** + * Utility method to ask the user to supply a channel + * @returns Registry and channel, if any + */ + _promptForRegistry(): Promise { + return this.prompt([ + { + type : "input", + name : "registry", + message : "What is your npm registry endpoint? ", + validate: (input: string, answers: Answers): boolean => { + return typeof input === "string" && !!input; + }, + store : true + }, + ]).then((answers) => { + // Get the available channels and check that we can connect + const registryChannels = this._getChannelsFromRegistry(answers.registry); + if (registryChannels != null && registryChannels.channels != null && registryChannels.channels.length > 0) { + return registryChannels; + } else { + return this.prompt({ + type : "input", + name : "confirmSkip", + message : "Registry was not found, do you wish to continue anyway? (y/n)", + validate: (input: string, answers: Answers): boolean => { + return typeof input === "string" && !!input; + }, + store : false + }).then((confirmAnswers) => { + if (confirmAnswers.confirmSkip === "y" || confirmAnswers.confirmSkip === "yes" || confirmAnswers.confirmSkip === "Y" || confirmAnswers.confirmSkip === "YES") { + return { + registry: answers.registry, + channels: null + } + } else { + return this._promptForRegistry(); + } + }) + } + }); + } + + /** + * Retrieves the available channel by calling npm info for the given registry + * @param registry registry endpoint + * @returns Registry and available channels, if any + */ + private _getChannelsFromRegistry(registry: string): RegistryChannels { + try { + const result = this.spawnCommandSync("npm", ["info", WebAppName.MES, `--registry=${registry}`, `--fetch-retry-maxtimeout=10`, `--fetch-retry-mintimeout=5`, "--json"], {stdio: 'pipe'}); + if (result != null && result.stdout != null) { + const json = this._Utf8ArrayToStr(result.stdout) + if (json != null) { + const packageJson = JSON.parse(json); + if (packageJson != null && packageJson["dist-tags"] != null) { + const channels = Object.keys(packageJson["dist-tags"]); + return { + registry: registry, + channels: channels + } + } + } + } + } catch(e) { + return { + registry: registry, + channels: null + } + } + + return { + registry: registry, + channels: null + } + } + + + /* utf.js - UTF-8 <=> UTF-16 conversion + * + * http://www.onicos.com/staff/iz/amuse/javascript/expert/utf.txt + * Copyright (C) 1999 Masanao Izumo + * Version: 1.0 + * LastModified: Dec 25 1999 + * This library is free. You can redistribute it and/or modify it. + */ + private _Utf8ArrayToStr(array) { + var out, i, len, c; + var char2, char3; + + out = ""; + len = array.length; + i = 0; + while(i < len) { + c = array[i++]; + switch(c >> 4) + { + case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: + // 0xxxxxxx + out += String.fromCharCode(c); + break; + case 12: case 13: + // 110x xxxx 10xx xxxx + char2 = array[i++]; + out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); + break; + case 14: + // 1110 xxxx 10xx xxxx 10xx xxxx + char2 = array[i++]; + char3 = array[i++]; + out += String.fromCharCode(((c & 0x0F) << 12) | + ((char2 & 0x3F) << 6) | + ((char3 & 0x3F) << 0)); + break; + } + } + + return out; +} } diff --git a/generators/application/index.ts b/generators/application/index.ts index 15f9fb6..2922a6f 100644 --- a/generators/application/index.ts +++ b/generators/application/index.ts @@ -1,5 +1,5 @@ import * as path from "path"; -import { HtmlGenerator } from "../html"; +import { HtmlGenerator , WebAppName} from "../html"; import { Answers } from "yeoman-generator"; export = class extends HtmlGenerator { @@ -35,7 +35,7 @@ export = class extends HtmlGenerator { type : "list", name : "basePackage", message : "What is the base package you want to use?", - choices : ["cmf.core.web.internal", "cmf.mes.web.internal", "other"] + choices : [WebAppName.MES, WebAppName.Core , "other"] }, { type : "input", @@ -69,7 +69,7 @@ export = class extends HtmlGenerator { registry: this.ctx.__config.registry }); this.fs.copy(this.templatePath("web.config"), this.destinationPath("web.config")); - this.fs.copyTpl(this.templatePath("index.html"), this.destinationPath("index.html"), {isExtendingMes: this.basePackage === "cmf.mes.web.internal"}); + this.fs.copyTpl(this.templatePath("index.html"), this.destinationPath("index.html"), {isExtendingMes: this.basePackage === WebAppName.MES}); } install() { diff --git a/generators/html.ts b/generators/html.ts index e5c5d0f..18ef6b7 100644 --- a/generators/html.ts +++ b/generators/html.ts @@ -3,6 +3,21 @@ import * as fs from "fs"; import * as path from "path"; var contextBuilder = require('@criticalmanufacturing/dev-tasks/main.js'); +/** + * Possible names of the web app to customize + */ +export enum WebAppName +{ + /** + * Core web app name + */ + Core = "cmf.core.web.internal", + /** + * MES web app name + */ + MES = "cmf.mes.web.internal" +} + export class HtmlGenerator extends Generator { ctx: { From db9ab65e2295f5d6e566565cd6210af1181785d6 Mon Sep 17 00:00:00 2001 From: Francisco Miguel Maciel Date: Thu, 26 Jul 2018 13:30:13 +0100 Subject: [PATCH 2/8] Update package json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 21d3eb2..f262e79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@criticalmanufacturing/generator-html", - "version": "6.0.0", + "version": "6.0.1", "description": "CMF HTML GUI Scaffolding", "files": [ "generators/*.js", From 624176576c601706172aed3fafc34a0aa1c3b9de Mon Sep 17 00:00:00 2001 From: Francisco Miguel Maciel Date: Thu, 2 Aug 2018 18:32:26 +0100 Subject: [PATCH 3/8] Add manifest json to app generation --- generators/application/index.ts | 1 + generators/application/templates/index.html | 1 + .../application/templates/manifest.json | 21 +++++++++++++++++++ generators/html.ts | 4 ++-- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 generators/application/templates/manifest.json diff --git a/generators/application/index.ts b/generators/application/index.ts index 2922a6f..4a711aa 100644 --- a/generators/application/index.ts +++ b/generators/application/index.ts @@ -69,6 +69,7 @@ export = class extends HtmlGenerator { registry: this.ctx.__config.registry }); this.fs.copy(this.templatePath("web.config"), this.destinationPath("web.config")); + this.fs.copy(this.templatePath("manifest.json"), this.destinationPath("manifest.json")); this.fs.copyTpl(this.templatePath("index.html"), this.destinationPath("index.html"), {isExtendingMes: this.basePackage === WebAppName.MES}); } diff --git a/generators/application/templates/index.html b/generators/application/templates/index.html index 3b578c6..1af79e8 100644 --- a/generators/application/templates/index.html +++ b/generators/application/templates/index.html @@ -5,6 +5,7 @@ + diff --git a/generators/application/templates/manifest.json b/generators/application/templates/manifest.json new file mode 100644 index 0000000..aaa6867 --- /dev/null +++ b/generators/application/templates/manifest.json @@ -0,0 +1,21 @@ +{ + "background_color": "#007ac9", + "display": "standalone", + "icons": [ + { + "src": "/node_modules/cmf.style/assets/img/logoCMF_192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "/node_modules/cmf.style/assets/img/logoCMF_512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "name": "Critical Manufacturing", + "start_url": "/", + "short_name": "MES", + "theme_color": "#ffffff" + } + \ No newline at end of file diff --git a/generators/html.ts b/generators/html.ts index 18ef6b7..b02d9ca 100644 --- a/generators/html.ts +++ b/generators/html.ts @@ -11,11 +11,11 @@ export enum WebAppName /** * Core web app name */ - Core = "cmf.core.web.internal", + Core = "@criticalmanufacturing/core-ui-web", /** * MES web app name */ - MES = "cmf.mes.web.internal" + MES = "@criticalmanufacturing/mes-ui-web" } export class HtmlGenerator extends Generator { From 9b29395c43c4ce3db3886591cc06807b66edc67d Mon Sep 17 00:00:00 2001 From: Francisco Miguel Maciel Date: Mon, 6 Aug 2018 13:37:04 +0100 Subject: [PATCH 4/8] Alter package generator to include description --- generators/package/index.ts | 39 +++++++++++++++++-- .../package/templates/src/i18n/main.zh-CN.ts | 2 + .../package/templates/src/i18n/main.zh-TW.ts | 2 + 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 generators/package/templates/src/i18n/main.zh-CN.ts create mode 100644 generators/package/templates/src/i18n/main.zh-TW.ts diff --git a/generators/package/index.ts b/generators/package/index.ts index ee3c09b..95630c3 100644 --- a/generators/package/index.ts +++ b/generators/package/index.ts @@ -61,18 +61,20 @@ module.exports = class extends HtmlGenerator { } if (fs.existsSync(this.destinationPath(webAppFolder, "node_modules"))) { - const excludeFilter = (folder) => { return folder.startsWith("cmf") && ["cmf.taura", "cmf.core", "cmf.core.multicast.client", "cmf.mes", "cmf.lbos", "cmf.polyfill", "cmf.angular"].indexOf(folder) < 0 && !folder.startsWith("cmf.style") }; + const excludeFilter = (folder) => { return folder.startsWith("cmf") && ["cmf.taura", "cmf.core", "cmf.core.multicast.client", "cmf.mes", "cmf.polyfill", "cmf.angular", "cmf.instascan"].indexOf(folder) < 0 && !folder.startsWith("cmf.style") }; webAppPackages = new Set(fs.readdirSync(this.destinationPath(webAppFolder, "node_modules")).filter(excludeFilter)); } allPackages = (repositoryPackages).union(webAppPackages); + const packageNames: {name: string, checked: boolean}[] = Array.from(allPackages).filter((pkg) => !(pkg).startsWith(".")).sort().map((pkg) => {return {name: pkg, checked: pkg === "cmf.lbos" }}) + const choices = this._getAppPackageDescriptions(webAppFolder, packageNames); return this.prompt([{ type : 'checkbox', name : 'dependencies', message : `Select dependencies`, - choices: Array.from(allPackages).filter((pkg) => !(pkg).startsWith(".")).sort().map((pkg) => {return pkg}), - pageSize: 20, // We can set up the pageSize attribute but there’s a PR opened ATM to make the height match the terminal height. Soon this won’t be necessary + choices: choices, + pageSize: 18, // We can set up the pageSize attribute but there’s a PR opened ATM to make the height match the terminal height. Soon this won’t be necessary default : null, when : () => Array.from(allPackages).length > 0 }]).then((answers) => { @@ -143,6 +145,9 @@ module.exports = class extends HtmlGenerator { if (repository !== "CoreHTML" && repository !== "MESHTML" && Object.keys(packageJSONObject.optionalDependencies).some(function(dependency) {return dependency.startsWith("cmf.mes")})) { packageJSONObject.cmfLinkDependencies["cmf.mes"] = `${appLibsFolder}cmf.mes`; packageJSONObject.optionalDependencies["cmf.mes"] = this.ctx.__config.channel; + // Also depend on cmf.core as we are going to need it for typings + packageJSONObject.cmfLinkDependencies["cmf.core"] = `${appLibsFolder}cmf.core`; + packageJSONObject.optionalDependencies["cmf.core"] = this.ctx.__config.channel; extendingMES = true; } else { // Otherwise, we need to depend on cmf.core @@ -190,4 +195,32 @@ module.exports = class extends HtmlGenerator { this.destinationRoot(`src/packages/${this.options.packageName}`); this.spawnCommandSync("gulp", ["build"]); } + + /** + * Gets the description for each package in the packages array and returns an array with them + */ + _getAppPackageDescriptions(webAppFolder: string, packages: {name: string}[]): {name?: string, type?: string, line?: string}[] { + if (packages == null || packages.length === 0) { + return []; + } + const packagesWithDescription: any[] = []; + + packages.forEach((packageChoice) => { + // push the package into the choices + const packageInfo: any[] = []; + packageInfo.push(packageChoice); + const packageName = packageChoice.name; + const packageJsonPath = this.destinationPath(webAppFolder, "node_modules", packageName, "package.json"); + if (fs.existsSync(packageJsonPath)) { + const packageJSONObject = this.fs.readJSON(packageJsonPath); + if (packageJSONObject != null && packageJSONObject["description"] != null && packageJSONObject["description"] != "") { + packageInfo.push({type: "separator", line: ` ${packageJSONObject["description"]}`}); + packageInfo.push({type: "separator", line: " "}); + } + } + packagesWithDescription.push(...packageInfo); + }) + + return packagesWithDescription; + } } diff --git a/generators/package/templates/src/i18n/main.zh-CN.ts b/generators/package/templates/src/i18n/main.zh-CN.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/package/templates/src/i18n/main.zh-CN.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/package/templates/src/i18n/main.zh-TW.ts b/generators/package/templates/src/i18n/main.zh-TW.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/package/templates/src/i18n/main.zh-TW.ts @@ -0,0 +1,2 @@ +export default { +}; From e0a6d2c8635f3bbfb4d704f9df980b8dfd71a6c6 Mon Sep 17 00:00:00 2001 From: Francisco Miguel Maciel Date: Mon, 6 Aug 2018 16:03:22 +0100 Subject: [PATCH 5/8] Improve component, datasource, executuionview, converter and widget generation --- generators/component/index.ts | 2 +- generators/component/templates/component.ts | 25 +++----- .../templates/i18n/component.zh-CN.ts | 1 + .../templates/i18n/component.zh-TW.ts | 1 + generators/converter/index.ts | 17 +++++- generators/converter/templates/converter.ts | 6 +- generators/dataSource/index.ts | 15 ++++- generators/dataSource/templates/dataSource.ts | 13 ++-- .../templates/i18n/dataSource.de-DE.ts | 1 - .../templates/i18n/dataSource.default.ts | 2 +- .../templates/i18n/dataSource.pt-PT.ts | 1 - .../templates/i18n/dataSource.zh-CN.ts | 2 + .../templates/i18n/dataSource.zh-TW.ts | 2 + generators/executionView/index.ts | 18 +++++- .../executionView/templates/executionView.ts | 5 +- .../templates/i18n/executionView.de-DE.ts | 11 +--- .../templates/i18n/executionView.pt-PT.ts | 11 +--- .../templates/i18n/executionView.vi-VN.ts | 11 +--- .../templates/i18n/executionView.zh-CN.ts | 2 + .../templates/i18n/executionView.zh-TW.ts | 2 + generators/html.ts | 15 +++-- generators/package/templates/src/metadata.ts | 3 +- generators/widget/index.ts | 8 ++- .../widget/templates/i18n/widget.zh-CN.ts | 2 + .../widget/templates/i18n/widget.zh-TW.ts | 2 + generators/widget/templates/widget.ts | 26 +++----- generators/widget/templates/widgetSettings.ts | 19 +++--- generators/wizard/index.ts | 12 +++- .../wizard/templates/i18n/wizard.de-DE.ts | 11 +--- .../wizard/templates/i18n/wizard.pt-PT.ts | 11 +--- .../wizard/templates/i18n/wizard.vi-VN.ts | 11 +--- .../wizard/templates/i18n/wizard.zh-CN.ts | 2 + .../wizard/templates/i18n/wizard.zh-TW.ts | 2 + generators/wizard/templates/wizard.html | 2 +- generators/wizard/templates/wizard.ts | 61 ++++++++++++++++--- 35 files changed, 184 insertions(+), 151 deletions(-) create mode 100644 generators/component/templates/i18n/component.zh-CN.ts create mode 100644 generators/component/templates/i18n/component.zh-TW.ts create mode 100644 generators/dataSource/templates/i18n/dataSource.zh-CN.ts create mode 100644 generators/dataSource/templates/i18n/dataSource.zh-TW.ts create mode 100644 generators/executionView/templates/i18n/executionView.zh-CN.ts create mode 100644 generators/executionView/templates/i18n/executionView.zh-TW.ts create mode 100644 generators/widget/templates/i18n/widget.zh-CN.ts create mode 100644 generators/widget/templates/i18n/widget.zh-TW.ts create mode 100644 generators/wizard/templates/i18n/wizard.zh-CN.ts create mode 100644 generators/wizard/templates/i18n/wizard.zh-TW.ts diff --git a/generators/component/index.ts b/generators/component/index.ts index 89181ab..35c83e8 100644 --- a/generators/component/index.ts +++ b/generators/component/index.ts @@ -68,7 +68,7 @@ export = class extends HtmlGenerator { // This algorithm will make sure all situations are accounted. It will unshift the result instead of pushing as it would way more complicated to know where the array of literal end const metadataFile = this.destinationPath(`${sourcePackageFolder}/../${packageName}.metadata.ts`); const fileContent = this.fs.read(metadataFile); - const routeConfigSetting = { regex: /routeConfig[ ]{0,}:[\s\S]*?\[/, unshifter : () => {return `routeConfig: [\n{path: "${answers.url}", loadChildren: ` + "`${packageName}/src/components/" + `${this.options.componentName}/${this.options.componentName}#${this.componentClass}Module` + "`" + `, data: {title: "${this.componentClass}"}},\n`} }; + const routeConfigSetting = { regex: /routeConfig[ ]{0,}:[\s\S]*?\[/, unshifter : () => {return `routeConfig: [\n {\n path: "${answers.url}",\n loadChildren: ` + "`${packageName}/src/components/" + `${this.options.componentName}/${this.options.componentName}#${this.componentClass}Module` + "`" + `,\n data: {title: "${this.componentClass}"}\n },\n`} }; const routesSetting = { regex: /routes[ ]{0,}:[\s\S]*?\[/, unshifter: () => {return `routes: [\n{\n\n${routeConfigSetting.unshifter()}]\n}\n`} }; const flexSetting = { regex: /flex[ ]{0,}:[\s\S]*?\{/, unshifter: () => {return `flex: {\n${routesSetting.unshifter()}],\n`} }; const matchedSetting = [routeConfigSetting, routesSetting, flexSetting].find((setting) => fileContent.match(setting.regex) != null); diff --git a/generators/component/templates/component.ts b/generators/component/templates/component.ts index ee0fc78..1fc031b 100644 --- a/generators/component/templates/component.ts +++ b/generators/component/templates/component.ts @@ -42,14 +42,10 @@ import * as ng from "@angular/core"; * * Where and When to use it? * * ### Inputs - * (Provide a detailed list of the inputs here. Syntax for each input description: - * " * type [string, number, Object...] : name - description") Ex: * `string` : **name** - The name of this component * `number` : **value** - The value of this component * * ### Outputs - * (Provide a detailed list of the outputs here. Syntax for each output description: - * " * type [string, number, Object...] : name - description") Ex: * `string` : **onNameChange** - When the name of the component change, this output emits the new name * `number` : **onValueChange** - When the value of the component change, this output emits the new value * @@ -57,11 +53,11 @@ import * as ng from "@angular/core"; * To use the component, assume this HTML Template as an example: * * ```HTML - * <<%= component.selector %> [input]="myInputValue" (output)="myOutputValue">> + * <<%= component.selector %>>> * ``` * - * ### _NOTES_ (optional) - * (Provide additional notes here) + * ### _NOTES_ + * (optional, Provide additional notes here) * * @description * @@ -70,19 +66,16 @@ import * as ng from "@angular/core"; * ### Dependencies * * #### Components - * (Provide a detailed list of components that this component depends on) Ex: - * * ComponentA : `package` (Ex: `cmf.core.controls`) - * * ComponentB : `package` (Ex: `cmf.core.controls`) + * * ComponentA : `package` + * * ComponentB : `package` * * #### Services - * (Provide a detailed list of services that this component depends on) Ex: - * * ServiceA : `package` (Ex: `cmf.core.controls`) - * * ServiceB : `package` (Ex: `cmf.core.controls`) + * * ServiceA : `package` + * * ServiceB : `package` * * #### Directives - * (Provide a detailed list of directives that this component depends on) Ex: - * * DirectiveA : `package` (Ex: `cmf.core.controls`) - * * DirectiveB : `package` (Ex: `cmf.core.controls`) + * * DirectiveA : `package` + * * DirectiveB : `package` * */ @Component({ diff --git a/generators/component/templates/i18n/component.zh-CN.ts b/generators/component/templates/i18n/component.zh-CN.ts new file mode 100644 index 0000000..b511c97 --- /dev/null +++ b/generators/component/templates/i18n/component.zh-CN.ts @@ -0,0 +1 @@ +export default {}; diff --git a/generators/component/templates/i18n/component.zh-TW.ts b/generators/component/templates/i18n/component.zh-TW.ts new file mode 100644 index 0000000..b511c97 --- /dev/null +++ b/generators/component/templates/i18n/component.zh-TW.ts @@ -0,0 +1 @@ +export default {}; diff --git a/generators/converter/index.ts b/generators/converter/index.ts index 32994bf..96ce193 100644 --- a/generators/converter/index.ts +++ b/generators/converter/index.ts @@ -6,6 +6,9 @@ export = class extends HtmlGenerator { converterName: string } + packageFolder: string; + shouldInstall: boolean = false; + constructor(args, opts) { super(args, opts); this.argument('converterName', { type: String, required: true }); @@ -17,7 +20,7 @@ export = class extends HtmlGenerator { */ copyTemplates() { var copyAndParse = (packageName, sourcePackageFolder, packageFolder) => { - + this.packageFolder = packageFolder; this.copyTpl(sourcePackageFolder, "converter", this.options.converterName, { converter : { name: this.options.converterName, class : `${this.options.converterName.charAt(0).toUpperCase()}${this.options.converterName.slice(1)}`, @@ -28,9 +31,17 @@ export = class extends HtmlGenerator { [".ts"], null, false); const dependencies = ["cmf.core.dashboards", "cmf.core"]; - this.addPackageDependencies(packageFolder, dependencies, true); - } + this.shouldInstall = this.addPackageDependencies(packageFolder, dependencies, true); + } return this.copyAndParse("converters", copyAndParse); } + + install() { + this.destinationRoot(this.packageFolder); + if (this.shouldInstall) { + this.spawnCommandSync('gulp', ['install']); + } + this.spawnCommandSync('gulp', ['build']); + } } diff --git a/generators/converter/templates/converter.ts b/generators/converter/templates/converter.ts index 205dd99..68b9eca 100644 --- a/generators/converter/templates/converter.ts +++ b/generators/converter/templates/converter.ts @@ -1,8 +1,8 @@ /** Core */ import {Module, Generic} from "cmf.core/src/core"; /** Nested modules */ -<% if (!converter.isADashboardConverter) { %> import * as Converter from "cmf.core.dashboards/src/converters/converter/converter";<% } %> -<% if (converter.isADashboardConverter) { %> import * as Converter from "../converter/converter";<% } %> +<% if (!converter.isADashboardConverter) { %>import * as Converter from "cmf.core.dashboards/src/converters/converter/converter";<% } %> +<% if (converter.isADashboardConverter) { %>import * as Converter from "../converter/converter";<% } %> /** Angular */ import {PipeTransform, Pipe} from "@angular/core"; @@ -29,7 +29,7 @@ import {PipeTransform, Pipe} from "@angular/core"; pure: true }) export class <%= converter.class %> extends Generic implements PipeTransform { - transform(value: string, args: string[]): any { + transform(value: any, args: any[]): any { // Replace the next line with the code of your converter transform return value; } diff --git a/generators/dataSource/index.ts b/generators/dataSource/index.ts index d7514c0..3d4d242 100644 --- a/generators/dataSource/index.ts +++ b/generators/dataSource/index.ts @@ -6,6 +6,9 @@ export = class extends HtmlGenerator { dataSourceName: string } + packageFolder: string; + shouldInstall: boolean = false; + constructor(args, opts) { super(args, opts); this.argument('dataSourceName', { type: String, required: true }); @@ -17,7 +20,7 @@ export = class extends HtmlGenerator { */ copyTemplates() { var copyAndParse = (packageName, sourcePackageFolder, packageFolder) => { - + this.packageFolder = packageFolder; this.copyTpl(sourcePackageFolder, "dataSource", this.options.dataSourceName, {dataSource : { name: this.options.dataSourceName, class : `${this.options.dataSourceName.charAt(0).toUpperCase()}${this.options.dataSourceName.slice(1)}`, @@ -26,9 +29,17 @@ export = class extends HtmlGenerator { }, [".ts"], null, true); const dependencies = ["cmf.core.dashboards", "cmf.core"]; - this.addPackageDependencies(packageFolder, dependencies, true); + this.shouldInstall = this.addPackageDependencies(packageFolder, dependencies, true); } return this.copyAndParse("dataSources", copyAndParse); } + + install() { + this.destinationRoot(this.packageFolder); + if (this.shouldInstall) { + this.spawnCommandSync('gulp', ['install']); + } + this.spawnCommandSync('gulp', ['build']); + } } diff --git a/generators/dataSource/templates/dataSource.ts b/generators/dataSource/templates/dataSource.ts index 01056f3..31ef4a8 100644 --- a/generators/dataSource/templates/dataSource.ts +++ b/generators/dataSource/templates/dataSource.ts @@ -1,8 +1,8 @@ /** Core */ import * as Core from "cmf.core/src/core"; /** Nested modules */ -<% if (!dataSource.isADashboardDataSource) { %> import * as DataSource from "cmf.core.dashboards/src/dataSources/dataSource/dataSource";<% } %> -<% if (dataSource.isADashboardDataSource) { %> import * as DataSource from "../dataSource/dataSource";<% } %> +<% if (!dataSource.isADashboardDataSource) { %>import * as DataSource from "cmf.core.dashboards/src/dataSources/dataSource/dataSource";<% } %> +<% if (dataSource.isADashboardDataSource) { %>import * as DataSource from "../dataSource/dataSource";<% } %> /** i18n */ import i18n from "./i18n/<%= dataSource.name %>.default"; /** Angular */ @@ -26,16 +26,13 @@ import * as ng from "@angular/core"; * * Where and When to use it? * * ### DataSource Settings Inputs - * (Provide a detailed list of the DataSource properties configurable in settings. Syntax for list items: - * " * type [string, number, Object...] : name - description") + * * `string` : **value** _(default)_ - Settings Input description * * ### DataSource Inputs - * (Provide a detailed list of the DataSource inputs here. Syntax for list items: - * " * type [string, number, Object...] : name - description") + * * `string` : **value** _(default)_ - Input description * * ### DataSource Outputs - * (Provide a detailed list of the DataSource outputs here. Syntax for list items: - * " * type [string, number, Object...] : name - description") + * * `string` : **value** _(default)_ - Output description */ @DataSource.DataSource({ name: i18n.TITLE diff --git a/generators/dataSource/templates/i18n/dataSource.de-DE.ts b/generators/dataSource/templates/i18n/dataSource.de-DE.ts index 40d4f30..02a61be 100644 --- a/generators/dataSource/templates/i18n/dataSource.de-DE.ts +++ b/generators/dataSource/templates/i18n/dataSource.de-DE.ts @@ -1,3 +1,2 @@ export default { - TITLE: "Your DataSource title" }; diff --git a/generators/dataSource/templates/i18n/dataSource.default.ts b/generators/dataSource/templates/i18n/dataSource.default.ts index 40d4f30..b21dccd 100644 --- a/generators/dataSource/templates/i18n/dataSource.default.ts +++ b/generators/dataSource/templates/i18n/dataSource.default.ts @@ -1,3 +1,3 @@ export default { - TITLE: "Your DataSource title" + TITLE: "<%= dataSource.name %> title" }; diff --git a/generators/dataSource/templates/i18n/dataSource.pt-PT.ts b/generators/dataSource/templates/i18n/dataSource.pt-PT.ts index 40d4f30..02a61be 100644 --- a/generators/dataSource/templates/i18n/dataSource.pt-PT.ts +++ b/generators/dataSource/templates/i18n/dataSource.pt-PT.ts @@ -1,3 +1,2 @@ export default { - TITLE: "Your DataSource title" }; diff --git a/generators/dataSource/templates/i18n/dataSource.zh-CN.ts b/generators/dataSource/templates/i18n/dataSource.zh-CN.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/dataSource/templates/i18n/dataSource.zh-CN.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/dataSource/templates/i18n/dataSource.zh-TW.ts b/generators/dataSource/templates/i18n/dataSource.zh-TW.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/dataSource/templates/i18n/dataSource.zh-TW.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/executionView/index.ts b/generators/executionView/index.ts index 2e03786..6422556 100644 --- a/generators/executionView/index.ts +++ b/generators/executionView/index.ts @@ -1,6 +1,9 @@ import { HtmlGenerator } from "../html"; export = class extends HtmlGenerator { + packageFolder: string; + shouldInstall: boolean = false; + constructor(args, opts) { super(args, opts); this.argument('executionViewName', { type: String, required: true }); @@ -9,7 +12,8 @@ export = class extends HtmlGenerator { copyTemplates() { var copyAndParse = (packageName, sourcePackageFolder, packageFolder) => { - let executionViewClass = `ExecutionView${this.options.executionViewName.charAt(0).toUpperCase()}${this.options.executionViewName.slice(1)}`, + this.packageFolder = packageFolder; + let executionViewClass = `${this.options.executionViewName.charAt(0).toUpperCase()}${this.options.executionViewName.slice(1)}`, executionViewCamel = `${executionViewClass.charAt(0).toLowerCase()}${executionViewClass.slice(1)}`, executionView = { name: executionViewCamel, @@ -20,10 +24,18 @@ export = class extends HtmlGenerator { }; this.copyTpl(sourcePackageFolder, "executionView", executionViewCamel, {executionView}, null, null, true); - const dependencies = ["cmf.core.business.controls"]; + const dependencies = ["cmf.core.business.controls", "cmf.core.controls", "cmf.core", "cmf.lbos"]; dependencies.push(executionView.isExtendingMes ? "cmf.mes" : "cmf.core"); - this.addPackageDependencies(packageFolder, dependencies, true); + this.shouldInstall = this.addPackageDependencies(packageFolder, dependencies, true); } return this.copyAndParse("components", copyAndParse); } + + install() { + this.destinationRoot(this.packageFolder); + if (this.shouldInstall) { + this.spawnCommandSync('gulp', ['install']); + } + this.spawnCommandSync('gulp', ['build']); + } } diff --git a/generators/executionView/templates/executionView.ts b/generators/executionView/templates/executionView.ts index fe7b6ed..73b7854 100644 --- a/generators/executionView/templates/executionView.ts +++ b/generators/executionView/templates/executionView.ts @@ -1,13 +1,14 @@ /** Core */ import {Component, Module, CoreComponent} from "cmf.core/src/core"; import {Cmf} from "cmf.lbos"; -<% if (executionView.isExtendingMes) { %> +<% if (executionView.isExtendingMes) { %> /** Mes */ import {MesComponent} from "cmf.mes/src/mes"; <% } %> /** Nested modules */ import {TransactionExecutionViewModule, TransactionExecutionViewInterface, TransactionExecutionViewArgs} from "cmf.core.business.controls/src/directives/transactionExecutionView/transactionExecutionView"; +import { PageBag } from "cmf.core.controls/src/components/page/pageBag"; /** i18n */ import i18n from "./i18n/<%= executionView.name %>.default"; @@ -48,7 +49,7 @@ export class <%= executionView.class %> extends<% if (executionView.isExtendingM //#endregion - constructor(viewContainerRef: ng.ViewContainerRef) { + constructor(viewContainerRef: ng.ViewContainerRef, private _pageBag: PageBag) { super(viewContainerRef); } diff --git a/generators/executionView/templates/i18n/executionView.de-DE.ts b/generators/executionView/templates/i18n/executionView.de-DE.ts index 8728822..a7ccc30 100644 --- a/generators/executionView/templates/i18n/executionView.de-DE.ts +++ b/generators/executionView/templates/i18n/executionView.de-DE.ts @@ -1,11 +1,2 @@ -import i18nControls from "cmf.core.controls/src/i18n/main.default"; - -export default { - TITLE: "ExecutionView title", - ACTION: i18nControls.actions.SAVE_AND_CLOSE, - tabs: { - tab1: { - TITLE: "Tab 1 title" - } - } +export default { }; diff --git a/generators/executionView/templates/i18n/executionView.pt-PT.ts b/generators/executionView/templates/i18n/executionView.pt-PT.ts index 8728822..a7ccc30 100644 --- a/generators/executionView/templates/i18n/executionView.pt-PT.ts +++ b/generators/executionView/templates/i18n/executionView.pt-PT.ts @@ -1,11 +1,2 @@ -import i18nControls from "cmf.core.controls/src/i18n/main.default"; - -export default { - TITLE: "ExecutionView title", - ACTION: i18nControls.actions.SAVE_AND_CLOSE, - tabs: { - tab1: { - TITLE: "Tab 1 title" - } - } +export default { }; diff --git a/generators/executionView/templates/i18n/executionView.vi-VN.ts b/generators/executionView/templates/i18n/executionView.vi-VN.ts index 8728822..a7ccc30 100644 --- a/generators/executionView/templates/i18n/executionView.vi-VN.ts +++ b/generators/executionView/templates/i18n/executionView.vi-VN.ts @@ -1,11 +1,2 @@ -import i18nControls from "cmf.core.controls/src/i18n/main.default"; - -export default { - TITLE: "ExecutionView title", - ACTION: i18nControls.actions.SAVE_AND_CLOSE, - tabs: { - tab1: { - TITLE: "Tab 1 title" - } - } +export default { }; diff --git a/generators/executionView/templates/i18n/executionView.zh-CN.ts b/generators/executionView/templates/i18n/executionView.zh-CN.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/executionView/templates/i18n/executionView.zh-CN.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/executionView/templates/i18n/executionView.zh-TW.ts b/generators/executionView/templates/i18n/executionView.zh-TW.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/executionView/templates/i18n/executionView.zh-TW.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/html.ts b/generators/html.ts index b02d9ca..4d11b24 100644 --- a/generators/html.ts +++ b/generators/html.ts @@ -132,7 +132,7 @@ export class HtmlGenerator extends Generator { extraFiles = extraFiles || []; let templatesToParse = [...standardFiles.concat(extraFiles).map((extension) => { return { templateBefore: `${type}${extension}`, templateAfter: `${packageFolder}${name}/${name}${extension}`};}), - ...((is18nAvailable) ? ['default.ts', 'pt-PT.ts', 'de-DE.ts', 'vi-VN.ts'] : []).map((extension) => { + ...((is18nAvailable) ? ['default.ts', 'pt-PT.ts', 'de-DE.ts', 'vi-VN.ts', 'zh-CN.ts', 'zh-TW.ts'] : []).map((extension) => { return { templateBefore: `i18n/${type}.${extension}`, templateAfter: `${packageFolder}${name}/i18n/${name}.${extension}`};})]; templatesToParse.forEach((template) => { this.fs.copyTpl(this.templatePath(template.templateBefore), this.destinationPath(`${template.templateAfter}`), templateObject) @@ -162,8 +162,9 @@ export class HtmlGenerator extends Generator { * @param packagePath Package path * @param dependencies Dependencies list * @param shouldLink Should also add dependency to cmfLinkDependencies + * @returns true if the new dependencies were added */ - addPackageDependencies(packagePath: string, dependencies: string[], shouldLink?: boolean): void { + addPackageDependencies(packagePath: string, dependencies: string[], shouldLink?: boolean): boolean { const packageJSONPath = this.destinationPath(packagePath, "package.json"); const packageJSONObject = this.fs.readJSON(packageJSONPath); @@ -177,19 +178,23 @@ export class HtmlGenerator extends Generator { } // Insert the dependencies using channel + let newDependency = false; dependencies .filter(dependency => dependency !== packageJSONObject.name) // remove links to itself .forEach(dependency => { if (!(dependency in packageJSONObject.optionalDependencies)) { packageJSONObject.optionalDependencies[dependency] = this.ctx.__config.channel || "*"; + newDependency = true; } if (shouldLink && !(dependency in packageJSONObject.cmfLinkDependencies)) { packageJSONObject.cmfLinkDependencies[dependency] = dependency.startsWith(this.ctx.packagePrefix) ? `file:../${dependency}` : `file:../../apps/${this.ctx.packagePrefix}.web/node_modules/${dependency}`; + newDependency = true; } - }) - - this.fs.writeJSON(packageJSONPath, packageJSONObject); + }); + + this.fs.writeJSON(packageJSONPath, packageJSONObject); + return newDependency; } } diff --git a/generators/package/templates/src/metadata.ts b/generators/package/templates/src/metadata.ts index 6339547..f1d9dff 100644 --- a/generators/package/templates/src/metadata.ts +++ b/generators/package/templates/src/metadata.ts @@ -61,7 +61,8 @@ function applyConfig(packageName: string) { menuItems: [], entityTypes: [], routes: [{ - routeConfig: [] + routeConfig: [ + ] }] } }; diff --git a/generators/widget/index.ts b/generators/widget/index.ts index edbedc5..abe544d 100644 --- a/generators/widget/index.ts +++ b/generators/widget/index.ts @@ -7,6 +7,7 @@ export = class extends HtmlGenerator { } packageFolder: string; + shouldInstall: boolean = false; constructor(args, opts) { super(args, opts); @@ -31,9 +32,9 @@ export = class extends HtmlGenerator { this.copyTpl(sourcePackageFolder, "widget", this.options.widgetName, {widget}, null, ["Settings.ts", "Settings.html", "Settings.less"], true); - const dependencies = ["cmf.core.dashboards"]; + const dependencies = ["cmf.core","cmf.core.dashboards"]; dependencies.push(widget.isExtendingMes ? "cmf.mes" : "cmf.core"); - this.addPackageDependencies(packageFolder, dependencies, true); + this.shouldInstall = this.addPackageDependencies(packageFolder, dependencies, true); } return this.copyAndParse("widgets", copyAndParse); @@ -41,6 +42,9 @@ export = class extends HtmlGenerator { install() { this.destinationRoot(this.packageFolder); + if (this.shouldInstall) { + this.spawnCommandSync('gulp', ['install']); + } this.spawnCommandSync('gulp', ['build']); } }; \ No newline at end of file diff --git a/generators/widget/templates/i18n/widget.zh-CN.ts b/generators/widget/templates/i18n/widget.zh-CN.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/widget/templates/i18n/widget.zh-CN.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/widget/templates/i18n/widget.zh-TW.ts b/generators/widget/templates/i18n/widget.zh-TW.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/widget/templates/i18n/widget.zh-TW.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/widget/templates/widget.ts b/generators/widget/templates/widget.ts index a2a3052..9378d42 100644 --- a/generators/widget/templates/widget.ts +++ b/generators/widget/templates/widget.ts @@ -1,11 +1,11 @@ /** Core */ import {Component, Module, CoreComponent} from "cmf.core/src/core"; -<% if (widget.isExtendingMes) { %> +<% if (widget.isExtendingMes) { %> /** Mes */ import {MesComponent} from "cmf.mes/src/mes"; <% } %> /** Nested modules */ -<% if (!widget.isADashboardWidget) { %> import * as Widget from "cmf.core.dashboards/src/widgets/widget/widget";<% } %> +<% if (!widget.isADashboardWidget) { %>import * as Widget from "cmf.core.dashboards/src/widgets/widget/widget";<% } %> <% if (widget.isADashboardWidget) { %> import * as Widget from "../widget/widget";<% } %> import { <%= widget.class %>SettingsModule, <%= widget.class %>Settings } from "./<%= widget.name %>Settings"; /** i18n */ @@ -44,18 +44,15 @@ const outputs: Map = new Map = new Map extends Widget.WidgetGeneric implements ng.OnCh * @param viewContainerRef View Container Ref */ constructor(viewContainerRef: ng.ViewContainerRef) { - super(viewContainerRef); + super(viewContainerRef.element); } //#region Private methods diff --git a/generators/widget/templates/widgetSettings.ts b/generators/widget/templates/widgetSettings.ts index fa14072..6167457 100644 --- a/generators/widget/templates/widgetSettings.ts +++ b/generators/widget/templates/widgetSettings.ts @@ -1,6 +1,6 @@ /** Core */ import {Component, Module, CoreComponent} from "cmf.core/src/core"; -<% if (widget.isExtendingMes) { %> +<% if (widget.isExtendingMes) { %> /** Mes */ import {MesComponent} from "cmf.mes/src/mes"; <% } %> @@ -24,8 +24,6 @@ import * as ng from "@angular/core"; * * `string` : **name** _(default)_ - The name of the widget * * `string` : **description** _(default)_ - The description of the widget * * `string` : **iconClass** _(default)_ - The icon CSS class to change the widget icon - * (Provide a detailed list of the widget configurable options here. Syntax for list items: - * " * type [string, number, Object...] : name - description") * * @description * @@ -34,19 +32,16 @@ import * as ng from "@angular/core"; * ### Dependencies * * #### Components - * (Provide a detailed list of components that this component depends on) Ex: - * * ComponentA : `package` (Ex: `cmf.core.controls`) - * * ComponentB : `package` (Ex: `cmf.core.controls`) + * * ComponentA : `package` + * * ComponentB : `package` * * #### Services - * (Provide a detailed list of services that this component depends on) Ex: - * * ServiceA : `package` (Ex: `cmf.core.controls`) - * * ServiceB : `package` (Ex: `cmf.core.controls`) + * * ServiceA : `package` + * * ServiceB : `package` * * #### Directives - * (Provide a detailed list of directives that this component depends on) Ex: - * * DirectiveA : `package` (Ex: `cmf.core.controls`) - * * DirectiveB : `package` (Ex: `cmf.core.controls`) + * * DirectiveA : `package` + * * DirectiveB : `package` * */ @Component({ diff --git a/generators/wizard/index.ts b/generators/wizard/index.ts index 9202e35..7f96423 100644 --- a/generators/wizard/index.ts +++ b/generators/wizard/index.ts @@ -5,7 +5,7 @@ export = class extends HtmlGenerator { options: { wizardName: string } - + shouldInstall: boolean = false; packageFolder: string; constructor(args, opts) { @@ -17,6 +17,9 @@ export = class extends HtmlGenerator { copyTemplates() { var copyAndParse = (packageName, sourcePackageFolder, packageFolder) => { this.packageFolder = packageFolder; + if (this.options.wizardName.toLowerCase().startsWith("wizard")) { + this.options.wizardName = this.options.wizardName.slice(6); + } let wizardClass = `Wizard${this.options.wizardName.charAt(0).toUpperCase()}${this.options.wizardName.slice(1)}`, wizardCamel = `${wizardClass.charAt(0).toLowerCase()}${wizardClass.slice(1)}`, wizard = { @@ -28,9 +31,9 @@ export = class extends HtmlGenerator { }; this.copyTpl(sourcePackageFolder, "wizard", wizardCamel, {wizard}, null, null, true); - const dependencies = ["cmf.core.business.controls"]; + const dependencies = ["cmf.core", "cmf.core.business.controls", "cmf.core.controls", "cmf.lbos"]; dependencies.push(wizard.isExtendingMes ? "cmf.mes" : "cmf.core"); - this.addPackageDependencies(packageFolder, dependencies, true); + this.shouldInstall = this.addPackageDependencies(packageFolder, dependencies, true); } return this.copyAndParse("components", copyAndParse); @@ -38,6 +41,9 @@ export = class extends HtmlGenerator { install() { this.destinationRoot(this.packageFolder); + if (this.shouldInstall) { + this.spawnCommandSync('gulp', ['install']); + } this.spawnCommandSync('gulp', ['build']); } } diff --git a/generators/wizard/templates/i18n/wizard.de-DE.ts b/generators/wizard/templates/i18n/wizard.de-DE.ts index 9c8d191..a7ccc30 100644 --- a/generators/wizard/templates/i18n/wizard.de-DE.ts +++ b/generators/wizard/templates/i18n/wizard.de-DE.ts @@ -1,11 +1,2 @@ -import i18nControls from "cmf.core.controls/src/i18n/main.default"; - -export default { - TITLE: "Wizard title", - ACTION: i18nControls.actions.FINISH, - steps: { - step1: { - TITLE: "Step 1 title" - } - } +export default { }; diff --git a/generators/wizard/templates/i18n/wizard.pt-PT.ts b/generators/wizard/templates/i18n/wizard.pt-PT.ts index 9c8d191..a7ccc30 100644 --- a/generators/wizard/templates/i18n/wizard.pt-PT.ts +++ b/generators/wizard/templates/i18n/wizard.pt-PT.ts @@ -1,11 +1,2 @@ -import i18nControls from "cmf.core.controls/src/i18n/main.default"; - -export default { - TITLE: "Wizard title", - ACTION: i18nControls.actions.FINISH, - steps: { - step1: { - TITLE: "Step 1 title" - } - } +export default { }; diff --git a/generators/wizard/templates/i18n/wizard.vi-VN.ts b/generators/wizard/templates/i18n/wizard.vi-VN.ts index 9c8d191..a7ccc30 100644 --- a/generators/wizard/templates/i18n/wizard.vi-VN.ts +++ b/generators/wizard/templates/i18n/wizard.vi-VN.ts @@ -1,11 +1,2 @@ -import i18nControls from "cmf.core.controls/src/i18n/main.default"; - -export default { - TITLE: "Wizard title", - ACTION: i18nControls.actions.FINISH, - steps: { - step1: { - TITLE: "Step 1 title" - } - } +export default { }; diff --git a/generators/wizard/templates/i18n/wizard.zh-CN.ts b/generators/wizard/templates/i18n/wizard.zh-CN.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/wizard/templates/i18n/wizard.zh-CN.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/wizard/templates/i18n/wizard.zh-TW.ts b/generators/wizard/templates/i18n/wizard.zh-TW.ts new file mode 100644 index 0000000..02a61be --- /dev/null +++ b/generators/wizard/templates/i18n/wizard.zh-TW.ts @@ -0,0 +1,2 @@ +export default { +}; diff --git a/generators/wizard/templates/wizard.html b/generators/wizard/templates/wizard.html index fa7b2bf..03bf434 100644 --- a/generators/wizard/templates/wizard.html +++ b/generators/wizard/templates/wizard.html @@ -1,4 +1,4 @@ - + diff --git a/generators/wizard/templates/wizard.ts b/generators/wizard/templates/wizard.ts index 1854c38..4166f9b 100644 --- a/generators/wizard/templates/wizard.ts +++ b/generators/wizard/templates/wizard.ts @@ -1,13 +1,14 @@ /** Core */ import {Component, Module, CoreComponent} from "cmf.core/src/core"; import {Cmf} from "cmf.lbos"; -<% if (wizard.isExtendingMes) { %> +<% if (wizard.isExtendingMes) { %> /** Mes */ import {MesComponent} from "cmf.mes/src/mes"; <% } %> /** Nested modules */ import {TransactionWizardModule, TransactionWizardInterface, TransactionWizardArgs} from "cmf.core.business.controls/src/directives/transactionWizard/transactionWizard"; +import { PageBag } from "cmf.core.controls/src/components/page/pageBag"; /** i18n */ import i18n from "./i18n/<%= wizard.name %>.default"; @@ -15,19 +16,59 @@ import i18n from "./i18n/<%= wizard.name %>.default"; import * as ng from "@angular/core"; /** - * Please provide a meaningful description of this wizard component and how to use it + * @whatItDoes * - * ## Inputs - * * input: Description for Input + * Please provide a meaningful description of this component + * Try to answer these questions: + * * What is it? + * * What it does? + * * How does it behave with different sizes? + * * Does it retrieve data from any external source (server, local database, text file, etc...)? * - * ## Outputs - * * output: Description for output + * @howToUse * - * ## Example + * This component is used with the inputs and outputs mentioned below. * - * ```html - * + * Besides the description above, please complement it with a meaningful description of this component that answer these questions: + * * How to use it? + * * Where and When to use it? + * + * ### Inputs + * `string` : **name** - The name of this component + * `number` : **value** - The value of this component + * + * ### Outputs + * `string` : **onNameChange** - When the name of the component change, this output emits the new name + * `number` : **onValueChange** - When the value of the component change, this output emits the new value + * + * ### Example + * To use the component, assume this HTML Template as an example: + * + * ```HTML + * <<%= wizard.selector %>>> * ``` + * + * ### _NOTES_ + * (optional, Provide additional notes here) + * + * @description + * + * ## <%= wizard.class %> Component + * + * ### Dependencies + * + * #### Components + * * ComponentA : `package` + * * ComponentB : `package` + * + * #### Services + * * ServiceA : `package` + * * ServiceB : `package` + * + * #### Directives + * * DirectiveA : `package` + * * DirectiveB : `package` + * */ @Component({ moduleId: __moduleName, @@ -48,7 +89,7 @@ export class <%= wizard.class %> extends<% if (wizard.isExtendingMes) { %> MesCo //#endregion - constructor(viewContainerRef: ng.ViewContainerRef) { + constructor(viewContainerRef: ng.ViewContainerRef, private _pageBag: PageBag) { super(viewContainerRef); } From d222b28d8ee86f61161ba4aaecd263ad7e053c14 Mon Sep 17 00:00:00 2001 From: Francisco Miguel Maciel Date: Mon, 6 Aug 2018 16:51:53 +0100 Subject: [PATCH 6/8] Update package generation filter so that it works on CoreHTMl and MESHTML --- generators/package/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/package/index.ts b/generators/package/index.ts index 95630c3..e15eef0 100644 --- a/generators/package/index.ts +++ b/generators/package/index.ts @@ -61,7 +61,7 @@ module.exports = class extends HtmlGenerator { } if (fs.existsSync(this.destinationPath(webAppFolder, "node_modules"))) { - const excludeFilter = (folder) => { return folder.startsWith("cmf") && ["cmf.taura", "cmf.core", "cmf.core.multicast.client", "cmf.mes", "cmf.polyfill", "cmf.angular", "cmf.instascan"].indexOf(folder) < 0 && !folder.startsWith("cmf.style") }; + const excludeFilter = (folder) => { return folder.startsWith("cmf") && ["cmf.taura", "cmf.core", "cmf.core.multicast.client", "cmf.mes", "cmf.polyfill", "cmf.angular", "cmf.instascan", "cmf.core.examples", "cmf.mes.examples"].indexOf(folder) < 0 && !folder.startsWith("cmf.style") }; webAppPackages = new Set(fs.readdirSync(this.destinationPath(webAppFolder, "node_modules")).filter(excludeFilter)); } @@ -142,7 +142,7 @@ module.exports = class extends HtmlGenerator { let extendingMES: boolean = false; // We need one fallback at the end. If we are customizing, we can end up using ony packages from CORE and we need to customize on top of MES - if (repository !== "CoreHTML" && repository !== "MESHTML" && Object.keys(packageJSONObject.optionalDependencies).some(function(dependency) {return dependency.startsWith("cmf.mes")})) { + if (Object.keys(packageJSONObject.optionalDependencies).some(function(dependency) {return dependency.startsWith("cmf.mes")})) { packageJSONObject.cmfLinkDependencies["cmf.mes"] = `${appLibsFolder}cmf.mes`; packageJSONObject.optionalDependencies["cmf.mes"] = this.ctx.__config.channel; // Also depend on cmf.core as we are going to need it for typings From 6b5a99bab2fe94d89da4a5c7683af7e2f3c776c2 Mon Sep 17 00:00:00 2001 From: Francisco Maciel Date: Mon, 6 Aug 2018 17:44:13 +0100 Subject: [PATCH 7/8] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f262e79..7bb2fa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@criticalmanufacturing/generator-html", - "version": "6.0.1", + "version": "6.1.0, "description": "CMF HTML GUI Scaffolding", "files": [ "generators/*.js", From 464f0b1aef4eee67586bd540889e68fff17c3d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Silva?= Date: Mon, 6 Aug 2018 18:01:24 +0100 Subject: [PATCH 8/8] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7bb2fa1..fa17750 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@criticalmanufacturing/generator-html", - "version": "6.1.0, + "version": "6.1.0", "description": "CMF HTML GUI Scaffolding", "files": [ "generators/*.js",