generator-ehrcraft-script 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +19 -2
- package/generators/app/index.js +90 -94
- package/generators/app/templates/README.md +34 -4
- package/generators/app/templates/gitignore +2 -0
- package/generators/app/templates/gulpfile.js/index.js +148 -139
- package/generators/app/templates/package.json +34 -60
- package/package.json +86 -87
- package/generators/app/templates/gulpfile.js/bundle.js +0 -62
- package/generators/app/templates/gulpfile.js/removeEhrCraftPackage.js +0 -28
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Bjørn Næss <bna@dips.no>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Bjørn Næss <bna@dips.no>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
# generator-ehrcraft-script
|
|
2
|
-
|
|
1
|
+
# generator-ehrcraft-script
|
|
2
|
+
|
|
3
|
+
## Version log
|
|
4
|
+
|
|
5
|
+
1.2.0 - simplified gulp and package dependencies
|
|
6
|
+
|
|
3
7
|
|
|
4
8
|
## Installation
|
|
5
9
|
|
|
@@ -7,6 +11,12 @@ First, install [Yeoman](http://yeoman.io) and generator-ehrcraft-script using [n
|
|
|
7
11
|
|
|
8
12
|
```bash
|
|
9
13
|
npm install -g yo
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Then install this generator
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
```bash
|
|
10
20
|
npm install -g generator-ehrcraft-script
|
|
11
21
|
```
|
|
12
22
|
|
|
@@ -16,6 +26,13 @@ Then generate your new project:
|
|
|
16
26
|
yo ehrcraft-script
|
|
17
27
|
```
|
|
18
28
|
|
|
29
|
+
## Development
|
|
30
|
+
If you want to test the generator during developement you might use npm link like this:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm link
|
|
34
|
+
```
|
|
35
|
+
|
|
19
36
|
## Getting To Know Yeoman
|
|
20
37
|
|
|
21
38
|
* Yeoman has a heart of gold.
|
package/generators/app/index.js
CHANGED
|
@@ -1,94 +1,90 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const Generator = require("yeoman-generator");
|
|
3
|
-
const chalk = require("chalk");
|
|
4
|
-
const yosay = require("yosay");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const _ = require("lodash");
|
|
7
|
-
|
|
8
|
-
module.exports = class extends Generator {
|
|
9
|
-
// eslint-disable-next-line no-useless-constructor
|
|
10
|
-
constructor(args,opts) {
|
|
11
|
-
super(args,opts);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
prompting() {
|
|
15
|
-
// Have Yeoman greet the user.
|
|
16
|
-
this.log(
|
|
17
|
-
yosay(`Welcome to ${chalk.red("generator-ehrcraft-script")} generator!`)
|
|
18
|
-
);
|
|
19
|
-
this.log(chalk.cyan("Enter some details about your new project"));
|
|
20
|
-
|
|
21
|
-
const prompts = [
|
|
22
|
-
{
|
|
23
|
-
type: "input",
|
|
24
|
-
name: "form_name",
|
|
25
|
-
message:
|
|
26
|
-
"The form name - will be written as <form_name>.js into the <form_scripts> folder",
|
|
27
|
-
default: this.appname
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
type: "input",
|
|
31
|
-
name: "form_scripts",
|
|
32
|
-
message: "The folder where the script should be placed",
|
|
33
|
-
default: "../../
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
return this.prompt(prompts).then(props => {
|
|
38
|
-
// To access props later use this.props.someAnswer;
|
|
39
|
-
this.props = props;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
writing() {
|
|
44
|
-
this.fs.copy(
|
|
45
|
-
this.templatePath("gulpfile.js"),
|
|
46
|
-
this.destinationPath("gulpfile.js")
|
|
47
|
-
);
|
|
48
|
-
this.fs.copyTpl(
|
|
49
|
-
this.templatePath("package.json"),
|
|
50
|
-
this.destinationPath("package.json"),
|
|
51
|
-
{ appname: _.kebabCase(path.basename(process.cwd())) }
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
this.fs.copyTpl(
|
|
55
|
-
this.templatePath("ehrcraft.config.yml"),
|
|
56
|
-
this.destinationPath("ehrcraft.config.yml"),
|
|
57
|
-
{
|
|
58
|
-
formname: this.props.form_name,
|
|
59
|
-
formscripts: this.props.form_scripts
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
this.fs.copy(
|
|
63
|
-
this.templatePath("tsconfig.json"),
|
|
64
|
-
this.destinationPath("tsconfig.json")
|
|
65
|
-
);
|
|
66
|
-
this.fs.copy(
|
|
67
|
-
this.templatePath("gitignore"),
|
|
68
|
-
this.destinationPath(".gitignore")
|
|
69
|
-
);
|
|
70
|
-
this.fs.copy(
|
|
71
|
-
this.templatePath("npmignore"),
|
|
72
|
-
this.destinationPath(".npmignore")
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
this.fs.copy(
|
|
76
|
-
this.templatePath("README.md"),
|
|
77
|
-
this.destinationPath("README.md")
|
|
78
|
-
);
|
|
79
|
-
/**
|
|
80
|
-
This.fs.copy(
|
|
81
|
-
this.templatePath("index.js"),
|
|
82
|
-
this.destinationPath("index.js")
|
|
83
|
-
); */
|
|
84
|
-
this.fs.copy(this.templatePath("src"),this.destinationPath("src"));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
install() {
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
yarn: false
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
const Generator = require("yeoman-generator");
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
const yosay = require("yosay");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const _ = require("lodash");
|
|
7
|
+
|
|
8
|
+
module.exports = class extends Generator {
|
|
9
|
+
// eslint-disable-next-line no-useless-constructor
|
|
10
|
+
constructor(args,opts) {
|
|
11
|
+
super(args,opts);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
prompting() {
|
|
15
|
+
// Have Yeoman greet the user.
|
|
16
|
+
this.log(
|
|
17
|
+
yosay(`Welcome to ${chalk.red("generator-ehrcraft-script")} generator!`)
|
|
18
|
+
);
|
|
19
|
+
this.log(chalk.cyan("Enter some details about your new project"));
|
|
20
|
+
|
|
21
|
+
const prompts = [
|
|
22
|
+
{
|
|
23
|
+
type: "input",
|
|
24
|
+
name: "form_name",
|
|
25
|
+
message:
|
|
26
|
+
"The form name - will be written as <form_name>.js into the <form_scripts> folder",
|
|
27
|
+
default: this.appname
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "input",
|
|
31
|
+
name: "form_scripts",
|
|
32
|
+
message: "The folder where the script should be placed",
|
|
33
|
+
default: "../../form-scripts"
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
return this.prompt(prompts).then(props => {
|
|
38
|
+
// To access props later use this.props.someAnswer;
|
|
39
|
+
this.props = props;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
writing() {
|
|
44
|
+
this.fs.copy(
|
|
45
|
+
this.templatePath("gulpfile.js"),
|
|
46
|
+
this.destinationPath("gulpfile.js")
|
|
47
|
+
);
|
|
48
|
+
this.fs.copyTpl(
|
|
49
|
+
this.templatePath("package.json"),
|
|
50
|
+
this.destinationPath("package.json"),
|
|
51
|
+
{ appname: _.kebabCase(path.basename(process.cwd())) }
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
this.fs.copyTpl(
|
|
55
|
+
this.templatePath("ehrcraft.config.yml"),
|
|
56
|
+
this.destinationPath("ehrcraft.config.yml"),
|
|
57
|
+
{
|
|
58
|
+
formname: this.props.form_name,
|
|
59
|
+
formscripts: this.props.form_scripts
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
this.fs.copy(
|
|
63
|
+
this.templatePath("tsconfig.json"),
|
|
64
|
+
this.destinationPath("tsconfig.json")
|
|
65
|
+
);
|
|
66
|
+
this.fs.copy(
|
|
67
|
+
this.templatePath("gitignore"),
|
|
68
|
+
this.destinationPath(".gitignore")
|
|
69
|
+
);
|
|
70
|
+
this.fs.copy(
|
|
71
|
+
this.templatePath("npmignore"),
|
|
72
|
+
this.destinationPath(".npmignore")
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
this.fs.copy(
|
|
76
|
+
this.templatePath("README.md"),
|
|
77
|
+
this.destinationPath("README.md")
|
|
78
|
+
);
|
|
79
|
+
/**
|
|
80
|
+
This.fs.copy(
|
|
81
|
+
this.templatePath("index.js"),
|
|
82
|
+
this.destinationPath("index.js")
|
|
83
|
+
); */
|
|
84
|
+
this.fs.copy(this.templatePath("src"),this.destinationPath("src"));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
install() {
|
|
88
|
+
this.spawnCommandSync("pnpm", ["install"]);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -17,13 +17,15 @@ DIPS has developed a typescript library with API for formscript. There are two v
|
|
|
17
17
|
|
|
18
18
|
DIPS Form Renderer support, currently, attribute names with lower and upper case. This might change and when DIPS Web Renderer support script it will only support lowercase. To be future proof you should upgrade. `v1` is still there for existing repos. They should be migrated into `v2` when changes are done on them.
|
|
19
19
|
|
|
20
|
+
> There are currently (as of september 2024 not implementations using v2 of the API)
|
|
21
|
+
|
|
20
22
|
### How to upgrade?
|
|
21
23
|
|
|
22
24
|
Update package.json file:
|
|
23
25
|
|
|
24
26
|
```json
|
|
25
27
|
"dependencies": {
|
|
26
|
-
"ehrcraft-form-api": "^2.
|
|
28
|
+
"ehrcraft-form-api": "^2.4.0",
|
|
27
29
|
}
|
|
28
30
|
```
|
|
29
31
|
|
|
@@ -34,7 +36,6 @@ Update package.json file:
|
|
|
34
36
|
|
|
35
37
|
```cmd
|
|
36
38
|
npm install gulp-cli -g
|
|
37
|
-
|
|
38
39
|
```
|
|
39
40
|
|
|
40
41
|
## Get started
|
|
@@ -43,9 +44,7 @@ Install the dependencies with npm. This is done by the following commands. Note
|
|
|
43
44
|
|
|
44
45
|
```cmd
|
|
45
46
|
npm update
|
|
46
|
-
|
|
47
47
|
npm update -D
|
|
48
|
-
|
|
49
48
|
```
|
|
50
49
|
|
|
51
50
|
## Code and build
|
|
@@ -61,3 +60,34 @@ When you change the source code it will be automatically compiled and copied int
|
|
|
61
60
|
## Need support?
|
|
62
61
|
|
|
63
62
|
Contact Bifrost by DIPS on bifrost@dips.no.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## Using the LAB API
|
|
67
|
+
LAB API is introduced by Arena 24.1. Older version will not have it. This is a case where a feature toggle may be needed. Here we will give an example on how to set this up:
|
|
68
|
+
|
|
69
|
+
### First change the boot in gulpfile
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const boot = 'var labapi = typeof lab === "undefined" || lab === null? undefined: lab ; main(api,labapi);';
|
|
73
|
+
```
|
|
74
|
+
This snippet will check if lab is present in the context or not. If not present it will define variable `labapi`as undefined.
|
|
75
|
+
|
|
76
|
+
### Use the labapi
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
/**
|
|
80
|
+
* Main function invoked from container (defined by build script)
|
|
81
|
+
* @param api
|
|
82
|
+
* @param lab
|
|
83
|
+
*/
|
|
84
|
+
export function main(api: API, lab: Lab | undefined) {
|
|
85
|
+
if (lab) {
|
|
86
|
+
// the labapi is defined and you can use it in your business logic
|
|
87
|
+
mainWithLab(api, lab);
|
|
88
|
+
} else {
|
|
89
|
+
// main us undefined - you are in an older DIPS Arena with no lab API present
|
|
90
|
+
mainWithNoLab(api);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
@@ -1,167 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// Gulp is the library/tool to automate slow, repetitive workflows and compose them into efficient build pipelines.
|
|
2
|
+
const gulp = require("gulp");
|
|
3
|
+
const { series, watch } = require('gulp');
|
|
4
|
+
const inject = require('gulp-inject-string');
|
|
5
|
+
// used to minify javascript
|
|
6
|
+
const terser = require('gulp-terser');
|
|
7
|
+
// used to compile typescript source code
|
|
8
|
+
const ts = require('gulp-typescript');
|
|
9
|
+
// used to rename files in the pipes of compilation, budle, renaming, etc.
|
|
10
|
+
const rename = require('gulp-rename');
|
|
11
|
+
// used to bundle the generated javascript code to one file
|
|
12
|
+
const browserify = require('browserify');
|
|
13
|
+
|
|
14
|
+
// used for the pipes working with the files. vinyl is a meta-defintion of a file.
|
|
15
|
+
// See: https://github.com/gulpjs/vinyl
|
|
16
|
+
const source = require('vinyl-source-stream');
|
|
17
|
+
const buffer = require('vinyl-buffer');
|
|
18
|
+
const through = require('through');
|
|
19
|
+
|
|
20
|
+
/* Used for configuration */
|
|
8
21
|
const YAML = require('yaml');
|
|
22
|
+
/* Used to read configuration */
|
|
9
23
|
const fs = require('fs');
|
|
10
|
-
const { watch,series,parallel } = require('gulp');
|
|
11
|
-
const del = require('del');
|
|
12
|
-
var through = require('through');
|
|
13
|
-
var log = require('gulplog');
|
|
14
|
-
let uglify = require('gulp-uglify-es').default;
|
|
15
|
-
var source = require('vinyl-source-stream');
|
|
16
|
-
var buffer = require('vinyl-buffer');
|
|
17
|
-
var bundler = require('./bundle');
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
var transformEhrCraftPackage = require('./removeEhrCraftPackage');
|
|
25
|
+
const full_deploy_series = series(compile, injectBootStrapLine, bundle, minify, deploy);
|
|
21
26
|
|
|
22
27
|
|
|
23
|
-
function getFolderAndName() {
|
|
24
|
-
const file = fs.readFileSync('./ehrcraft.config.yml','utf8');
|
|
25
|
-
let n = YAML.parse(file);
|
|
26
|
-
return n;
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//ehrcraft_form_api_1.
|
|
33
|
-
function compress() {
|
|
34
|
-
return gulp.src('./build/js/*.js')
|
|
35
|
-
.pipe(uglify(/* options */))
|
|
36
|
-
.pipe(gulp.dest('./build/dist'))
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
28
|
|
|
41
29
|
/**
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
function compile() {
|
|
45
|
-
return gulp.src('src/**/*.ts')
|
|
46
|
-
.pipe(ts({
|
|
47
|
-
target: "es3",
|
|
48
|
-
noImplicitAny: true,
|
|
49
|
-
module: "commonjs",
|
|
50
|
-
outDir: "ehrcraft"
|
|
51
|
-
}))
|
|
52
|
-
.pipe(babel({
|
|
53
|
-
presets: ["@babel/typescript"],
|
|
54
|
-
plugins: ["@babel/proposal-class-properties",
|
|
55
|
-
"@babel/proposal-object-rest-spread"]
|
|
56
|
-
}))
|
|
57
|
-
.pipe(gulp.dest('./build'))
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Dette er trikset som gjør at FormRenderer starter scriptet vårt ved lasting.
|
|
63
|
-
* Ved å kalle funksjonen main(api) i index.js
|
|
64
|
-
*
|
|
65
|
-
* NOTE:
|
|
30
|
+
* Defines the injected function call to main.
|
|
31
|
+
* * NOTE:
|
|
66
32
|
* Change or modify this if you need ctx and/or http for your script
|
|
67
33
|
* i.e.
|
|
68
34
|
* main(api, ctx, http)
|
|
69
35
|
* main(api, ctx)
|
|
36
|
+
*
|
|
37
|
+
* Since version 2.3.x there is support for terminology search and system configuration - they are exposed as "terminology" and "config".
|
|
38
|
+
* main(api,ctx,terminology, config)
|
|
39
|
+
*
|
|
40
|
+
* Since version 2.4.x support for LAB was added. Exposed as lab
|
|
41
|
+
* const boot = 'var labapi = typeof lab === "undefined" || lab === null? undefined: lab ; main(api,labapi);';
|
|
42
|
+
*
|
|
43
|
+
* NOTE:
|
|
44
|
+
* If you want to use api2, the second generation of script api delivered with DIPS Arena 22.2, add the following:
|
|
45
|
+
*
|
|
46
|
+
* main(api2)
|
|
70
47
|
*
|
|
71
48
|
* Then you have to changes the export function main(......) in index.ts as well
|
|
72
49
|
*/
|
|
73
|
-
|
|
74
|
-
let boot = "main(api);";
|
|
75
|
-
return gulp.src("./build/index.js")
|
|
76
|
-
.pipe(inject.append(boot))
|
|
77
|
-
.pipe(gulp.dest("./build"));
|
|
78
|
-
|
|
79
|
-
};
|
|
50
|
+
const boot = 'main(api,ctx,terminology,config);';
|
|
80
51
|
|
|
81
52
|
/**
|
|
82
|
-
*
|
|
53
|
+
* Task to compile source as typescript
|
|
54
|
+
* @param {*} cb
|
|
55
|
+
* @returns
|
|
83
56
|
*/
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
removeEhrCraftFormRequire2,
|
|
95
|
-
removeEhrCraftPackage2
|
|
96
|
-
]
|
|
97
|
-
}).bundle();
|
|
98
|
-
|
|
99
|
-
})).pipe(gulp.dest('./build/js'));
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
function bundle(cb) {
|
|
103
|
-
return browserify('./build/index.js')
|
|
104
|
-
//.transform(bundler.removeEhrCraftPackage)
|
|
105
|
-
.transform(transformEhrCraftPackage)
|
|
106
|
-
.bundle()
|
|
107
|
-
.pipe(source('index.js'))
|
|
108
|
-
.pipe(buffer())
|
|
109
|
-
.pipe(gulp.dest('./build/bundle'));
|
|
57
|
+
function compile(cb) {
|
|
58
|
+
return gulp.src('src/**/*.ts')
|
|
59
|
+
.pipe(ts({
|
|
60
|
+
target: "es5",
|
|
61
|
+
noImplicitAny: true,
|
|
62
|
+
removeComments: false,
|
|
63
|
+
module: "commonjs"
|
|
64
|
+
}))
|
|
65
|
+
|
|
66
|
+
.pipe(gulp.dest('./dist'))
|
|
110
67
|
}
|
|
111
|
-
|
|
112
|
-
function olderbundle(cb) {
|
|
113
|
-
bundler.bundleScript("./build/index.js","./build/bundle.js")
|
|
114
|
-
.then(result => {
|
|
115
|
-
console.log("Bundled finsihed");
|
|
116
|
-
cb();
|
|
117
|
-
}).catch(error => {
|
|
118
|
-
console.error("Error bundling");
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
68
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
69
|
+
* Task to inject the call to main method
|
|
70
|
+
* See boot variable above.
|
|
71
|
+
*
|
|
72
|
+
* @returns
|
|
127
73
|
*/
|
|
128
|
-
function
|
|
129
|
-
let n = getFolderAndName();
|
|
130
|
-
let formScriptsFolder = n.form_scripts;
|
|
131
|
-
let formName = n.form_name;
|
|
132
|
-
console.log("Deploy to folder " + formScriptsFolder + ", file: " + formName + ".js");
|
|
133
|
-
if (formScriptsFolder && formName) {
|
|
134
|
-
return gulp.src('./build/bundle/index.js')
|
|
135
|
-
.pipe(rename(formName + ".js"))
|
|
136
|
-
.pipe(gulp.dest(formScriptsFolder));
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
cb();
|
|
140
|
-
}
|
|
74
|
+
function injectBootStrapLine(cb) {
|
|
141
75
|
|
|
142
|
-
|
|
76
|
+
return gulp.src("./dist/index.js")
|
|
77
|
+
.pipe(inject.append(boot))
|
|
78
|
+
.pipe(inject.append(`console.log("Script kompilert dato: ${new Date().toISOString()}");`))
|
|
79
|
+
.pipe(gulp.dest("./dist"));
|
|
143
80
|
|
|
144
|
-
|
|
145
|
-
return del('./build');
|
|
81
|
+
};
|
|
146
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Task to minify the generated javascript.
|
|
85
|
+
* This task is optional. The idea is to reduce the size of the generated javascript.
|
|
86
|
+
* @param {*} cb
|
|
87
|
+
* @returns
|
|
88
|
+
*/
|
|
89
|
+
function minify(cb) {
|
|
90
|
+
return gulp.src("./build/app.js")
|
|
91
|
+
.pipe(terser())
|
|
92
|
+
.pipe(gulp.dest("./build"));
|
|
147
93
|
}
|
|
148
94
|
|
|
149
|
-
|
|
150
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Task to bundle all compiled javascript files into a single bundle.
|
|
97
|
+
* Will also remove package names from the EHR Craft API.
|
|
98
|
+
* @param {*} cb
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
function bundle(cb) {
|
|
102
|
+
var b = browserify({
|
|
103
|
+
entries: './dist/index.js',
|
|
104
|
+
debug: false,
|
|
105
|
+
transform: [removeEhrCraftPackage]
|
|
106
|
+
});
|
|
107
|
+
return b.bundle()
|
|
108
|
+
.pipe(source('app.js'))
|
|
109
|
+
.pipe(buffer())
|
|
110
|
+
.pipe(gulp.dest('./build'));
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
function removeEhrCraftPackage(file) {
|
|
114
|
+
var data = '';
|
|
115
|
+
var stream = through(write, end);
|
|
116
|
+
return stream;
|
|
117
|
+
|
|
118
|
+
function write(buf) {
|
|
119
|
+
data += buf.toString('utf8')
|
|
120
|
+
.replace(/(var ehrcraft_form_api_1)/gm, "// Kommentert ut av byggescript")
|
|
121
|
+
.replace(/(ehrcraft_form_api_1\.)/gm, "");
|
|
122
|
+
;
|
|
123
|
+
}
|
|
124
|
+
function end() {
|
|
125
|
+
process(file, data, function (result) {
|
|
126
|
+
stream.queue(result);
|
|
127
|
+
stream.queue(null);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function process(file, data, callback) {
|
|
131
|
+
//console.log(`Processing file ${file}`)
|
|
132
|
+
callback(data);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
151
136
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Task to deploy the bundled javascript file to form script folder of EHR Craft.
|
|
139
|
+
* Uses the configuration defined un ehrcraft.config.yml
|
|
140
|
+
* @param {*} cb
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
function deploy(cb) {
|
|
144
|
+
const ehrCraftConfig = loadEhrCraftConfigAsYaml();
|
|
145
|
+
const formScriptsFolder = ehrCraftConfig.form_scripts;
|
|
146
|
+
const formName = ehrCraftConfig.form_name;
|
|
147
|
+
console.log("Deploy to folder " + formScriptsFolder + ", file: " + formName + ".js");
|
|
148
|
+
if (formScriptsFolder && formName) {
|
|
149
|
+
return gulp
|
|
150
|
+
.src('./build/app.js')
|
|
151
|
+
.pipe(rename(formName + ".js"))
|
|
152
|
+
.pipe(gulp.dest(formScriptsFolder));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
cb();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function loadEhrCraftConfigAsYaml() {
|
|
159
|
+
const file = fs.readFileSync('./ehrcraft.config.yml', 'utf8');
|
|
160
|
+
let n = YAML.parse(file);
|
|
161
|
+
return n;
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Task to watch for changes in typescript and start the full serie of compile, bundle, deploy
|
|
167
|
+
* @param {*} cb
|
|
168
|
+
*/
|
|
169
|
+
function watchForChanges(cb) {
|
|
170
|
+
watch('./src/**/*.ts', full_deploy_series);
|
|
171
|
+
cb();
|
|
162
172
|
}
|
|
163
173
|
|
|
164
|
-
exports.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
//
|
|
174
|
+
exports.default = watchForChanges;
|
|
175
|
+
exports.deploy = full_deploy_series;
|
|
176
|
+
exports.bundle = series(compile, bundle)
|
|
@@ -1,60 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "<%= appname %>",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "<%= appname %>",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "ts-mocha test/**/*.spec.ts"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"openEHR",
|
|
11
|
-
"<%= appname %>",
|
|
12
|
-
"BIFROST",
|
|
13
|
-
"Arena"
|
|
14
|
-
],
|
|
15
|
-
"author": "Bjørn Næss <bna@dips.no>",
|
|
16
|
-
"license": "ISC",
|
|
17
|
-
"devDependencies": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"gulp-buffer": "0.0.2",
|
|
36
|
-
"gulp-concat": "^2.6.1",
|
|
37
|
-
"gulp-copy": "^4.0.1",
|
|
38
|
-
"gulp-inject-string": "^1.1.2",
|
|
39
|
-
"gulp-rename": "^2.0.0",
|
|
40
|
-
"gulp-tap": "^2.0.0",
|
|
41
|
-
"gulp-typescript": "^5.0.1",
|
|
42
|
-
"gulp-uglify": "^3.0.2",
|
|
43
|
-
"gulp-uglify-es": "^2.0.0",
|
|
44
|
-
"gulp-watch": "^5.0.1",
|
|
45
|
-
"gulplog": "^1.0.0",
|
|
46
|
-
"mocha": "^8.0.0",
|
|
47
|
-
"nyc": "^15.0.0",
|
|
48
|
-
"ts-mocha": "^8.0.0",
|
|
49
|
-
"ts-mockito": "^2.5.0",
|
|
50
|
-
"ts-node": "^9.1.1",
|
|
51
|
-
"typescript": "^4.0.0",
|
|
52
|
-
"vinyl-buffer": "^1.0.1",
|
|
53
|
-
"vinyl-source-stream": "^2.0.0",
|
|
54
|
-
"voca": "^1.4.0"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"ehrcraft-form-api": "^2",
|
|
58
|
-
"yaml": "^1.7.2"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= appname %>",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "<%= appname %>",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "ts-mocha test/**/*.spec.ts"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"openEHR",
|
|
11
|
+
"<%= appname %>",
|
|
12
|
+
"BIFROST",
|
|
13
|
+
"Arena"
|
|
14
|
+
],
|
|
15
|
+
"author": "Bjørn Næss <bna@dips.no>",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"browserify": "^17.0.0",
|
|
19
|
+
"ehrcraft-form-api": "^2.6.0",
|
|
20
|
+
"gulp": "^4.0.0",
|
|
21
|
+
"gulp-inject-string": "^1.1.2",
|
|
22
|
+
"gulp-rename": "^2.0.0",
|
|
23
|
+
"gulp-terser": "^2.1.0",
|
|
24
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
|
25
|
+
"mocha": "^10.2.0",
|
|
26
|
+
"through": "^2.3.8",
|
|
27
|
+
"ts-mocha": "^10.0.0",
|
|
28
|
+
"typescript": "^4.9.5",
|
|
29
|
+
"vinyl-buffer": "^1.0.1",
|
|
30
|
+
"vinyl-source-stream": "^2.0.0",
|
|
31
|
+
"yaml": "^2.2.1"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {}
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,87 +1,86 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "generator-ehrcraft-script",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "A code generator for DIPS Forms typescript",
|
|
5
|
-
"homepage": "https://dev.azure.com/dips/DIPS%20Configured%20Products/_git/generator-ehrcraft-script",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "Bjørn Næss",
|
|
8
|
-
"email": "bna@dips.no",
|
|
9
|
-
"url": "https://dev.azure.com/dips/DIPS%20Configured%20Products/_git/generator-ehrcraft-script"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"generators"
|
|
13
|
-
],
|
|
14
|
-
"main": "generators/index.js",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"",
|
|
17
|
-
"yeoman-generator"
|
|
18
|
-
],
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@types/chai": "^4.
|
|
21
|
-
"@types/mocha": "^
|
|
22
|
-
"chai": "^4.
|
|
23
|
-
"coveralls": "^3.
|
|
24
|
-
"ehrcraft-form-api": "^
|
|
25
|
-
"eslint": "^
|
|
26
|
-
"eslint-config-prettier": "^
|
|
27
|
-
"eslint-plugin-prettier": "^
|
|
28
|
-
"husky": "^4.
|
|
29
|
-
"jest": "^
|
|
30
|
-
"lint-staged": "^
|
|
31
|
-
"mocha": "^
|
|
32
|
-
"prettier": "^2.
|
|
33
|
-
"ts-mockito": "^2.6.1",
|
|
34
|
-
"yeoman-assert": "^3.1.
|
|
35
|
-
"yeoman-test": "^
|
|
36
|
-
},
|
|
37
|
-
"engines": {
|
|
38
|
-
"npm": ">= 4.0.0"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"chalk": "^4.
|
|
42
|
-
"loadash": "^1.0.0",
|
|
43
|
-
"lodash": "^4.17.
|
|
44
|
-
"yeoman-generator": "^
|
|
45
|
-
"yosay": "^2.0.
|
|
46
|
-
},
|
|
47
|
-
"jest": {
|
|
48
|
-
"testEnvironment": "node"
|
|
49
|
-
},
|
|
50
|
-
"lint-staged": {
|
|
51
|
-
"*.js": [
|
|
52
|
-
"eslint --fix",
|
|
53
|
-
"git add"
|
|
54
|
-
],
|
|
55
|
-
"*.json": [
|
|
56
|
-
"prettier --write",
|
|
57
|
-
"git add"
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
"husky": {
|
|
61
|
-
"hooks": {
|
|
62
|
-
"pre-commit": "lint-staged"
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"eslintConfig": {
|
|
66
|
-
"extends": [
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "generator-ehrcraft-script",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "A code generator for DIPS Forms typescript",
|
|
5
|
+
"homepage": "https://dev.azure.com/dips/DIPS%20Configured%20Products/_git/generator-ehrcraft-script",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Bjørn Næss",
|
|
8
|
+
"email": "bna@dips.no",
|
|
9
|
+
"url": "https://dev.azure.com/dips/DIPS%20Configured%20Products/_git/generator-ehrcraft-script"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"generators"
|
|
13
|
+
],
|
|
14
|
+
"main": "generators/index.js",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"",
|
|
17
|
+
"yeoman-generator"
|
|
18
|
+
],
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/chai": "^4.3.4",
|
|
21
|
+
"@types/mocha": "^10.0.1",
|
|
22
|
+
"chai": "^4.3.7",
|
|
23
|
+
"coveralls": "^3.1.1",
|
|
24
|
+
"ehrcraft-form-api": "^2.3.4",
|
|
25
|
+
"eslint": "^8.31.0",
|
|
26
|
+
"eslint-config-prettier": "^8.6.0",
|
|
27
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
28
|
+
"husky": "^4.3.8",
|
|
29
|
+
"jest": "^29.3.1",
|
|
30
|
+
"lint-staged": "^13.1.0",
|
|
31
|
+
"mocha": "^10.2.0",
|
|
32
|
+
"prettier": "^2.8.2",
|
|
33
|
+
"ts-mockito": "^2.6.1",
|
|
34
|
+
"yeoman-assert": "^3.1.1",
|
|
35
|
+
"yeoman-test": "^7.2.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"npm": ">= 4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"chalk": "^4.1.2",
|
|
42
|
+
"loadash": "^1.0.0",
|
|
43
|
+
"lodash": "^4.17.21",
|
|
44
|
+
"yeoman-generator": "^5.7.0",
|
|
45
|
+
"yosay": "^2.0.2"
|
|
46
|
+
},
|
|
47
|
+
"jest": {
|
|
48
|
+
"testEnvironment": "node"
|
|
49
|
+
},
|
|
50
|
+
"lint-staged": {
|
|
51
|
+
"*.js": [
|
|
52
|
+
"eslint --fix",
|
|
53
|
+
"git add"
|
|
54
|
+
],
|
|
55
|
+
"*.json": [
|
|
56
|
+
"prettier --write",
|
|
57
|
+
"git add"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"husky": {
|
|
61
|
+
"hooks": {
|
|
62
|
+
"pre-commit": "lint-staged"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"eslintConfig": {
|
|
66
|
+
"extends": [
|
|
67
|
+
"eslint:recommended"
|
|
68
|
+
],
|
|
69
|
+
"env": {
|
|
70
|
+
"jest": true,
|
|
71
|
+
"node": true
|
|
72
|
+
},
|
|
73
|
+
"rules": {
|
|
74
|
+
"prettier/prettier": "error"
|
|
75
|
+
},
|
|
76
|
+
"plugins": [
|
|
77
|
+
"prettier"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"pretest": "eslint .",
|
|
82
|
+
"test": "jest"
|
|
83
|
+
},
|
|
84
|
+
"repository": "ehrforce/generator-ehrcraft-script",
|
|
85
|
+
"license": "MIT"
|
|
86
|
+
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
var browserify = require('browserify');
|
|
2
|
-
var through = require('through');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Denne fila er ikke i bruk - ligger her fordi den ble brukt for å teste ut funksjonene som brukes for å fjerne ehrcraft spesifikke forhold
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const regexptest = function () {
|
|
10
|
-
var data = '';
|
|
11
|
-
return through(write,end);
|
|
12
|
-
function write(buf) {
|
|
13
|
-
data += buf.toString('utf8').replace(/(ehrcraft_form_api_1\.)/gm,"");
|
|
14
|
-
}
|
|
15
|
-
function end() {
|
|
16
|
-
this.queue(data);
|
|
17
|
-
this.queue(null);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const removerequire = function () {
|
|
21
|
-
var data = '';
|
|
22
|
-
return through(write,end);
|
|
23
|
-
function write(buf) {
|
|
24
|
-
data += buf.toString('utf8').replace(/(var ehrcraft_form_api_1)/gm,"// Kommentert ut av byggescript");
|
|
25
|
-
}
|
|
26
|
-
function end() {
|
|
27
|
-
this.queue(data);
|
|
28
|
-
this.queue(null);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @param {string} inFile - the js file to bundle
|
|
36
|
-
* @param {string} outFile - the bundled js file to write to
|
|
37
|
-
*/
|
|
38
|
-
const bundleFile = function (inFile,outFile) {
|
|
39
|
-
return new Promise((resolve,reject) => {
|
|
40
|
-
try {
|
|
41
|
-
var b = browserify();
|
|
42
|
-
b.add(inFile);
|
|
43
|
-
b.transform(regexptest);
|
|
44
|
-
b.transform(removerequire);
|
|
45
|
-
b.bundle()
|
|
46
|
-
.pipe(fs.createWriteStream(outFile));
|
|
47
|
-
resolve("OK");
|
|
48
|
-
} catch (error) {
|
|
49
|
-
reject(err);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
exports.bundleScript = bundleFile;
|
|
60
|
-
exports.removeEhrCraftPackage = this.removeEhrCraftPackage;
|
|
61
|
-
exports.removeEhrCraftRequire = this.removeEhrCraftRequire;
|
|
62
|
-
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var through = require('through');
|
|
2
|
-
var path = require('path');
|
|
3
|
-
function process(file,data,callback) {
|
|
4
|
-
//console.log(`Processing file ${file}`)
|
|
5
|
-
callback(data);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
function transform(file) {
|
|
9
|
-
var data = '',stream = through(write,end);
|
|
10
|
-
|
|
11
|
-
return stream;
|
|
12
|
-
|
|
13
|
-
function write(buf) {
|
|
14
|
-
//data += buf;
|
|
15
|
-
data += buf.toString('utf8')
|
|
16
|
-
.replace(/(var ehrcraft_form_api_1)/gm,"// Kommentert ut av byggescript")
|
|
17
|
-
.replace(/(ehrcraft_form_api_1\.)/gm,"");
|
|
18
|
-
;
|
|
19
|
-
}
|
|
20
|
-
function end() {
|
|
21
|
-
process(file,data,function (result) {
|
|
22
|
-
stream.queue(result);
|
|
23
|
-
stream.queue(null);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return through();
|
|
27
|
-
}
|
|
28
|
-
module.exports = transform;
|