Skip to content

Commit

Permalink
Fixed issues of this version
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Santos committed Jan 6, 2021
1 parent e65f0c9 commit c0915b5
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 105 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jspm_packages
# Custom Ignore settings
*.js
!gulpfile.js
!font.js
*.map
*.d.ts
test-results.xml
Expand Down
90 changes: 12 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ npm i -g yo

To start using this generator, it is advisable to have it installed globally (-g setting in NPM).
```
npm i -g @criticalmanufacturing/generator-iot
npm i -g @criticalmanufacturing/generator-iot@72x
```
> **Note** Starting from 7.2.0, each combination of Critical Manufacturing MES version (Major + Minor) will have a dedicated generator to make it easier to keep compatibility.
>
> For versions 7.2.0, 7.2.1, 7.2.2, ..., 7.2.\*, use the tag `72x` (`npm i -g @criticalmanufacturing/generator-iot@72x`)
>
> For versions 8.0.0, 8.0.1, 8.0.2, ..., 8.0.\*, use the tag `80x` (`npm i -g @criticalmanufacturing/generator-iot@80x`)
# Apps

To see at any time, the list of available apps, open a terminal window and run:
```
yo @criticalmanufacturing/iot
Expand All @@ -26,16 +33,6 @@ For both multiple and single choice, use the cursor (Up/Down) to move between th

All questions are considered answered when the Enter key is pressed.

## Config
The `Connect IoT` architecture require a configuration file with definitions and instruction mandatory. This App helps creating it.

On the location where you want to store the configs, open a terminal window and run:

```
yo @criticalmanufacturing/iot:config
```
Answer all questions and the file will be created and can be used immediately.

## tasksPackage
Use this app to create a new custom package structure help you getting started. Of course, you still need to implement the tasks and converters (there are also apps to help you)

Expand Down Expand Up @@ -126,70 +123,7 @@ If you are extending this package, it is easier to have it linked locally. Run t
<!-- C:\Users\jpsantos\AppData\Roaming\npm\node_modules\@criticalmanufacturing\generator-iot -> N:\COMMON\EI\Business\Scaffolding\generator-iot -->

# Version History
**Next**
- History will be maintained in the Github page for now on

**1.4.4**
- Removed Chokidar dependency from driver
- Removed Dev dependency from driver package.json
- Added gulpfile.js into driver
- Fixed compiler errors in driver
- Added missing entries in config (monitorApplication, SecurityPortal)

**1.4.3**
- Added gulp + codelyzer as devDependencies for taskPackage

**1.4.2**
- Added fonts section in taskPackage metadata

**1.4.1**
- Updated template driver for ssl implementation

**1.4.0**
- Updated dependencies versions for driver package
- Updated dependencies versions for tasks packages
- Fix driver source code to support new version of typescript
- Add entityName command parameter in driver
- Add commandParameter extension file in driver
- Add settings in tasksPackage to suppress generated files from VSCode

**1.3.1**
- Removed invalid entries from .gitignore file
- removed tgz file from previous package
- removed development entry from .npmrc

**1.3.0**
- Fixed missing entries in task settings code behind
- Fixed typos in task
- Updated gulpfile.js in tasksPackage
- Fixed dependencies in taskPackage
- Added template .less file in tasks
- Added missing comments in task designer file

**1.2.3**
- Several fixes and cleanup on the driver template

**1.2.2**
- Added missing gulpfile.js file back into tasksPackage template

**1.2.1**
- Added componentId to driver app command line

**1.2.0**
- Updated driver app

**1.1.0**
- Added tasksPackage app
- Added task app
- Small bug fixes

**1.0.2**
- Updated driver template

**1.0.1**
- Fixed template generation of the driver with hidden files included
- Added missing IoT datatype Boolean
- Added test example for converter

**1.0.0**
- First version
History is maintained in the Github page

https://github.com/criticalmanufacturing/generator-iot/releases

6 changes: 3 additions & 3 deletions generators/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class GeneratorApp extends ConnectIoTGenerator {

this.log(this.usage()); // .help() show all command line parameters
this.log("");
this.log(chalk.cyan("Setup apps:"));
this.log(" " + chalk.yellow("config") + " -> Create a configuration file to use with Automation Manager");
this.log("");
// this.log(chalk.cyan("Setup apps:"));
// this.log(" " + chalk.yellow("config") + " -> Create a configuration file to use with Automation Manager");
// this.log("");
this.log(chalk.cyan("Development apps:"));
this.log(" " + chalk.yellow("tasksPackage") + " -> Create a new basic package code for custom Tasks/Converters");
this.log(" " + chalk.yellow("task") + " -> Create the skeleton for a Task");
Expand Down
11 changes: 8 additions & 3 deletions generators/driver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ class DriverConfig extends ConnectIoTGenerator {
["_iot_.gitattributes", ".gitattributes"],
["_iot_.gitignore", ".gitignore"],
["_iot_.npmignore", ".npmignore"],
["_iot_.npmrc", ".npmrc"]
["_iot_.npmrc", ".npmrc"],
["_iot_.connect_iot_package_done", ".connect_iot_package_done"],
]);
filesWithRename.forEach((value, key) => {
this.fs.copyTpl(this.templatePath(key), this.destinationPath(this.values.directory, value), this.values);
});

let files: string[] = ["package.json", "README.md", "tsconfig.json", "tslint.json", "gulpfile.js"];
let files: string[] = ["package.json", "README.md", "tsconfig.json", "tslint.json", "gulpfile.js", "packConfig.json"];
files.forEach((template) => {
this.fs.copyTpl(this.templatePath(template), this.destinationPath(this.values.directory, template), this.values);
});

// Visual Studio settings
files = ["settings.json"];
files = ["settings.json", "launch.json"];
files.forEach((template) => {
this.fs.copyTpl(this.templatePath("_iot_.vscode", template), this.destinationPath(this.values.directory, ".vscode", template), this.values);
});
Expand Down Expand Up @@ -77,7 +78,11 @@ class DriverConfig extends ConnectIoTGenerator {
}

end() {
this.log("");
this.log("");
this.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
this.log("For this version, it is recommended to run the command 'npm dedupe' after installing the npm packages.");
this.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
}

Expand Down
Empty file.
1 change: 0 additions & 1 deletion generators/driver/templates/_iot_.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ jspm_packages
*.d.ts
test-results.xml
coverage/
.connect_iot_package_done
3 changes: 2 additions & 1 deletion generators/driver/templates/_iot_.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ test
coverage
tsconfig.json
tslint.json
.git*
.git*
.connect_iot_package_done
3 changes: 1 addition & 2 deletions generators/driver/templates/_iot_.npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
registry = "http://cmf-nuget:4873/"
//cmf-nuget:4873/:_authToken="csNoanwPNA0SGF/V/Q+CRJWzHc/lRymCeBWSRGDZ+kY="
registry = "http://<YOUR_LOCAL_NPM>:4873/"
24 changes: 24 additions & 0 deletions generators/driver/templates/_iot_.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Driver (<%= identifier %>)",
"program": "${workspaceRoot}/src/index.js",
"args": [
"--dev",
"--id=<EnterDriverInstanceId>",
"--mp=<EnterMonitorPort>",
"--config=<EnterConfigPath>/config.json"
],
// "preLaunchTask": "manager-build",
"cwd": "${workspaceRoot}",
"outFiles": [],
"outputCapture": "std"
}
]
}
18 changes: 18 additions & 0 deletions generators/driver/templates/packConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "Component",

"postActions": [
{ "type": "DeleteFile", "source": "${Temp}/completion.sh.hbs" },
{ "type": "DeleteDirectory", "source": "${Temp}/src" },
{ "type": "DeleteDirectory", "source": "${Temp}/build" },
{ "type": "DeleteDirectory", "source": "${Temp}/locales" },
{ "type": "DeleteDirectory", "source": "${Temp}/addonsHandler" }
],

"information": [
"Add other instructions in the postActions section",
"according to the result of the pack process of your",
"driver. There is no 'right' recipe. It will always",
"depend on the modules you are using."
]
}
7 changes: 6 additions & 1 deletion generators/driver/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
"vs:buildAndTest": "npm run build && npm run vs:test",
"vs:test": "node node_modules/istanbul/lib/cli cover node_modules/mocha/bin/_mocha --report cobertura --report lcov test/*.js test/**/*.js -- --timeout 30000 --exit --reporter mocha-junit-reporter --reporter-options mochaFile=./test/test-results.xml",
"pretest": "npm run build",
"watch": "npm run build -- -w | node node_modules/mocha/bin/mocha --timeout 30000 --exit --reporter min -w test/*.test.js test/**/*.test.js"
"watch": "npm run build -- -w | node node_modules/mocha/bin/mocha --timeout 30000 --exit --reporter min -w test/*.test.js test/**/*.test.js",

"postinstall": "if exist node_modules\\vinyl-fs\\node_modules\\graceful-fs ren node_modules\\vinyl-fs\\node_modules\\graceful-fs DoNotUse-graceful-fs_incompatible_with_node12"
},
"keywords": [
"CMF",
"IoT",
"Agent"
],
"devDependencies": {
"@criticalmanufacturing/dev-tasks": "dev-72x",
"@types/chai": "^4.1.7",
"@types/chai-spies": "^1.0.0",
"@types/core-js": "^2.5.0",
Expand All @@ -31,6 +34,8 @@
"@types/uuid": "^3.4.4",
"@types/yargs": "^13.0.0",
"chai": "^4.2.0",
"graceful-fs": "4.2.3",
"gulp": "3.9.1",
"chai-spies": "^1.0.0",
"istanbul": "^0.4.5",
"mocha": "^6.1.3",
Expand Down
9 changes: 5 additions & 4 deletions generators/driver/templates/src/driverImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CommunicationState, PropertyValuePair } from "@criticalmanufacturing/co
import { Property, EventOccurrence, PropertyValue, Command, Event as EquipmentEvent, DeviceDriverBase, CommandParameter } from "@criticalmanufacturing/connect-iot-driver";
import { <%= identifier %>CommunicationSettings, <%= identifierCamel %>DefaultCommunicationSettings, validateCommunicationParameters } from "./communicationSettings";
import { validateProperties, validateEvents, validateEventProperties, validateCommands, validateCommandParameters } from "./extendedData/index";
import { Utils } from "@criticalmanufacturing/connect-iot-common";
import { TYPES } from "./types";

@injectable()
Expand Down Expand Up @@ -174,8 +175,8 @@ export class <%= identifier %>DeviceDriver extends DeviceDriverBase {
// Fill results and check if the trigger properties have been the cause of the event occurrence
if (values) {
for (let eventProperty of event.properties) {
if (values.hasOwnProperty(eventProperty.deviceId)) {
let value: any = (<any>values)[eventProperty.deviceId];
if (values.has(eventProperty.deviceId)) {
let value: any = values.get(eventProperty.deviceId);

let propertyValue: PropertyValue = {
propertyName: eventProperty.name,
Expand Down Expand Up @@ -214,8 +215,8 @@ export class <%= identifier %>DeviceDriver extends DeviceDriverBase {
if (raw == null)
return(undefined);

// Convert the value
// ...
// Convert the value (this is an example)
raw = Utils.convertValueToType(raw, toType);

// return same thing (could not convert it?)
return(raw);
Expand Down
5 changes: 3 additions & 2 deletions generators/driver/templates/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if (yargs.argv) {
pid: process.pid,
componentId: yargs.argv.componentId || "Driver<%= identifier %>",
entityName: yargs.argv.entityName,
managerId: yargs.argv.managerId,
});

// Parse and validate configuration
Expand Down Expand Up @@ -83,10 +84,10 @@ if (yargs.argv) {
}
}).then(() => {
logger.info(`<%= identifier %> Driver process started with success`);
}).catch((error) => {
}).catch((error: Error) => {
logger.error(`<%= identifier %> Driver process failed to start!`);
logger.error(error.message);
logger.error(error.stack);
logger.error(error.stack || "<UnknownCallStack>");

const internalLogger: any = (<any>(logger))._winston;
internalLogger.on("finish", () => {
Expand Down
4 changes: 2 additions & 2 deletions generators/driver/templates/src/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { <%= identifier %>DeviceDriver } from "./driverImplementation";

const container = new Container();
container.parent = driverContainer;
container.parent.bind<Container>(TYPES.Injector).toConstantValue(container);
container.parent?.bind<Container>(TYPES.Injector).toConstantValue(container);

// Must place in parent otherwise the driver(common) will not find this
container.parent.bind<DeviceDriver>(COMMUNICATION_TYPES.Device.Driver).to(<%= identifier %>DeviceDriver).inSingletonScope();
container.parent?.bind<DeviceDriver>(COMMUNICATION_TYPES.Device.Driver).to(<%= identifier %>DeviceDriver).inSingletonScope();

export { container };
2 changes: 1 addition & 1 deletion generators/fontgen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GeneratorFontGen extends ConnectIoTGenerator {
super(args, opts);

if (!this.fs.exists(this.destinationPath("font.js"))) {
this.env.error(new Error(`Unable to find 'font.js' file. Make sure you are running the command from the location where you have the fonts (SVGs + font.js metadata file)`));
this.env.error(new Error(`Unable to find 'font.js' file in the current directory. Make sure you are running the command from the location where you have the fonts (SVGs + font.js metadata file)`));
}
}

Expand Down
9 changes: 7 additions & 2 deletions generators/tasksPackage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class GeneratorTasksPackage extends ConnectIoTGenerator {
directory: "controller-engine-custom-tasks",
packageName: "@criticalmanufacturing/connect-iot-controller-engine-custom-tasks",
packageVersion: "7.2.0",
identifier: "MyTasksPackage",
identifierLower: ""
};

constructor(args: any, opts: any) {
Expand All @@ -17,6 +19,8 @@ class GeneratorTasksPackage extends ConnectIoTGenerator {
this.values.directory = await this.askScalar("What is the identifier (directory name)?", ValueType.Text, this.values.directory);
this.values.packageName = await this.askScalar("What is the full package name?", ValueType.Text, this.values.packageName);
this.values.packageVersion = await this.askScalar("What is the package version?", ValueType.Text, this.values.packageVersion);
this.values.identifier = await this.askScalar("What is the package identifier (Do not enter spaces)?", ValueType.Text, this.values.identifier);
this.values.identifierLower = this.values.identifier.trim().toLocaleLowerCase();
}

/** Copy all files to destination directory with the settings defined in the previous step */
Expand All @@ -26,13 +30,14 @@ class GeneratorTasksPackage extends ConnectIoTGenerator {
["_iot_.gitattributes", ".gitattributes"],
["_iot_.gitignore", ".gitignore"],
["_iot_.npmignore", ".npmignore"],
["_iot_.npmrc", ".npmrc"]
["_iot_.npmrc", ".npmrc"],
["_iot_.connect_iot_package_done", ".connect_iot_package_done"],
]);
filesWithRename.forEach((value, key) => {
this.fs.copyTpl(this.templatePath(key), this.destinationPath(this.values.directory, value), this.values);
});

let files: string[] = ["package.json", "README.md", "tsconfig.json", "tslint.json", "gulpfile.js"];
let files: string[] = ["package.json", "README.md", "tsconfig.json", "tslint.json", "gulpfile.js", "packConfig.json"];
files.forEach((template) => {
this.fs.copyTpl(this.templatePath(template), this.destinationPath(this.values.directory, template), this.values);
});
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion generators/tasksPackage/templates/_iot_.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ coverage/

test/e2e/obj/
test/**/bin
.connect_iot_package_done

!font/**/*.css
!font/svg/font.js
4 changes: 3 additions & 1 deletion generators/tasksPackage/templates/_iot_.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ coverage
tsconfig.json
tslint.json
.git*
font/svg
font/svg
.connect_iot_package_done
packConfig.json
10 changes: 10 additions & 0 deletions generators/tasksPackage/templates/font/svg/font.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fontDef = {
"font": {
"fontname": "<%= identifierLower %>tasksiot",
"fullname": "<%= identifier %> Tasks IoT",
"familyname": "<%= identifier %> Tasks IoT",
"version": 0.1,
"prefix": "<%= identifierLower %>-tasks-connect-iot"
}
}
module.exports = fontDef;
Loading

0 comments on commit c0915b5

Please sign in to comment.