Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bonita
bonita-ui-designer-sdk
Commits
4f29ff1f
Commit
4f29ff1f
authored
Apr 06, 2021
by
Jerome Cambon
Browse files
Test envirionment setup + first test + License in source files
parent
a2fb21f8
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
4f29ff1f
...
...
@@ -90,7 +90,7 @@ This is done with 'custom tags', which are JSDoc-like tags, and use the '-@tag'
The builder is using https://github.com/runem/web-component-analyzer.
See the section "How to document your components using JSDoc" from its documentation
for more details about adding information on the component (@element)
and
on its properties (@prop).
for more details about adding information on the component (@element)
,
on its properties (@prop)
and events (@fires)
.
<br><br>
#### Examples of property tags
...
...
custom-widget-builder/package-lock.json
View file @
4f29ff1f
This diff is collapsed.
Click to expand it.
custom-widget-builder/package.json
View file @
4f29ff1f
...
...
@@ -4,13 +4,29 @@
"description"
:
""
,
"author"
:
"poc-widget-builder"
,
"license"
:
"GPLv2"
,
"type"
:
"module"
,
"scripts"
:
{},
"scripts"
:
{
"typescript-compile"
:
"tsc --build tsconfig.json"
,
"test"
:
"jest 2>&1"
,
"test:dev"
:
"jest --watch"
},
"dependencies"
:
{
"@types/node"
:
"^14.14.35"
,
"jdenticon"
:
"^3.1.0"
,
"jsdoc"
:
"^3.6.6"
,
"typescript"
:
"^4.1.3"
,
"web-component-analyzer"
:
"^1.1.6"
},
"devDependencies"
:
{
"@types/jest"
:
"^26.0.22"
,
"jest"
:
"^26.6.3"
,
"ts-jest"
:
"^26.5.4"
},
"jest"
:
{
"verbose"
:
true
,
"roots"
:
[
"./test/"
],
"preset"
:
"ts-jest"
,
"testEnvironment"
:
"node"
}
}
custom-widget-builder/src/CustomTagHandler.ts
View file @
4f29ff1f
import
{
PropertyConstraint
}
from
"
./PropertyConstraint.js
"
;
/*
* Copyright © 2021 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
{
PropertyConstraint
}
from
"
./PropertyConstraint
"
;
export
class
CustomTagHandler
{
...
...
custom-widget-builder/src/CustomWidgetBuilder.ts
View file @
4f29ff1f
/*
* Copyright © 2021 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
{
analyzeText
,
AnalyzeTextResult
,
transformAnalyzerResult
}
from
"
web-component-analyzer
"
;
import
fs
from
"
fs
"
;
import
{
Propert
iesInfo
}
from
"
./Propert
iesInfo.js
"
;
import
{
Property
}
from
"
./Property.js
"
;
import
jdenticon
from
"
jdenticon/standalone
"
;
import
{
CustomTagHandler
}
from
"
./CustomTagHandler.js
"
;
import
{
PropertiesInfo
}
from
"
./PropertiesInfo
"
;
import
{
Propert
y
}
from
"
./Propert
y
"
;
import
{
CustomTagHandler
}
from
"
./CustomTagHandler
"
;
import
*
as
fs
from
"
fs
"
;
import
*
as
jdenticon
from
"
jdenticon/standalone
"
;
export
class
CustomWidgetBuilder
{
...
...
@@ -38,16 +56,14 @@ export class CustomWidgetBuilder {
private
createPropertiesFile
(
propertiesInfo
:
PropertiesInfo
)
{
//TODO replace console.log() by logging
let
output
=
JSON
.
stringify
(
propertiesInfo
,
null
,
2
)
console
.
log
(
output
);
// console.log(output);
if
(
!
fs
.
existsSync
(
this
.
outputDir
))
{
console
.
log
(
`ERROR: output directory does not exist:
${
this
.
outputDir
}
`
);
return
;
}
let
filePath
=
`
${
this
.
outputDir
}
/
${
propertiesInfo
.
id
}
.json`
;
fs
.
writeFile
(
filePath
,
output
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
`ERROR: Cannot write properties file
${
filePath
}
`
);
console
.
log
(
`[
${
err
.
message
}
]`
);
}
else
{
console
.
log
(
`
${
filePath
}
has been generated!`
);
}
});
fs
.
writeFileSync
(
filePath
,
output
);
console
.
log
(
`
${
filePath
}
has been generated!`
);
}
private
analyzeFile
():
string
{
...
...
custom-widget-builder/src/PropertiesInfo.ts
View file @
4f29ff1f
/*
* Copyright © 2021 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
{
Property
}
from
"
./Property
"
;
export
class
PropertiesInfo
{
...
...
custom-widget-builder/src/Property.ts
View file @
4f29ff1f
/*
* Copyright © 2021 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
{
PropertyConstraint
}
from
"
./PropertyConstraint
"
;
export
class
Property
{
...
...
custom-widget-builder/src/PropertyConstraint.ts
View file @
4f29ff1f
/*
* Copyright © 2021 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export
class
PropertyConstraint
{
public
min
:
string
|
undefined
;
public
max
:
string
|
undefined
;
...
...
custom-widget-builder/src/starter.ts
View file @
4f29ff1f
import
{
CustomWidgetBuilder
}
from
"
./CustomWidgetBuilder.js
"
;
/*
* Copyright © 2021 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
{
CustomWidgetBuilder
}
from
"
./CustomWidgetBuilder
"
;
let
wcFile
;
let
outputDir
;
...
...
custom-widget-builder/test/CustomWidgetBuilder.test.ts
0 → 100644
View file @
4f29ff1f
/*
* Copyright © 2019 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import
{
CustomWidgetBuilder
}
from
"
../src/CustomWidgetBuilder
"
;
import
*
as
os
from
"
os
"
;
const
fs
=
require
(
'
fs
'
);
describe
(
'
CustomWidgetBuilder
'
,
()
=>
{
test
(
'
should generate a correct json file when a simple web component is given as input
'
,
async
()
=>
{
let
builder
=
new
CustomWidgetBuilder
();
let
tempDir
=
fs
.
mkdtempSync
(
os
.
tmpdir
());
builder
.
generatePropertiesFile
(
"
test/resources/WcExample.ts
"
,
tempDir
);
let
generatedFile
=
tempDir
+
"
/WcExample.json
"
;
expect
(
fs
.
existsSync
(
generatedFile
)).
toBeTruthy
();
let
jsonProperties
=
JSON
.
parse
(
fs
.
readFileSync
(
generatedFile
,
'
utf8
'
));
expect
(
jsonProperties
.
id
).
toBe
(
"
wcExample
"
);
expect
(
jsonProperties
.
name
).
toBe
(
"
WcExample
"
);
expect
(
jsonProperties
.
template
).
toBe
(
"
@wcExample.tpl.html
"
);
expect
(
jsonProperties
.
description
.
length
).
toBeGreaterThan
(
0
);
expect
(
jsonProperties
.
order
).
toBe
(
"
1
"
);
expect
(
jsonProperties
.
icon
.
length
).
toBeGreaterThan
(
0
);
expect
(
jsonProperties
.
properties
.
length
).
toBe
(
2
);
});
});
custom-widget-builder/test/resources/WcExample.ts
View file @
4f29ff1f
...
...
@@ -20,7 +20,8 @@ export class WcExample extends LitElement {
/**
* -@bond variable
*/
@
property
({
type
:
Number
})
counter
=
5
;
@
property
({
type
:
Number
})
counter
=
5
;
__increment
()
{
this
.
counter
+=
1
;
...
...
custom-widget-builder/tsconfig.json
View file @
4f29ff1f
{
"compilerOptions"
:
{
/*
Basic
Options
*/
"target"
:
"es
next
"
/*
Specify
ECMAScript
target
version:
'ES
3
'
(default)
,
'ES
5
'
,
'ES
2015
'
,
'ES
2016
'
,
'ES
2017
'
,
'ES
2018
'
or
'ESNEXT'.
*/
,
"module"
:
"
esnext
"
/*
Specify
module
code
generation:
'none'
,
'commonjs'
,
'amd'
,
'system'
,
'umd'
,
'es
2015
'
,
or
'ESNext'.
*/
,
"lib"
:
[
"esnext"
],
/*
Specify
library
files
to
be
included
in
the
compilation.
*/
"target"
:
"es
6
"
/*
Specify
ECMAScript
target
version:
'ES
3
'
(default)
,
'ES
5
'
,
'ES
2015
'
,
'ES
2016
'
,
'ES
2017
'
,
'ES
2018
'
or
'ESNEXT'.
*/
,
"module"
:
"
commonjs
"
/*
Specify
module
code
generation:
'none'
,
'commonjs'
,
'amd'
,
'system'
,
'umd'
,
'es
2015
'
,
or
'ESNext'.
*/
,
//
"lib"
:
[
"esnext"
],
/*
Specify
library
files
to
be
included
in
the
compilation.
*/
//
"allowJs"
:
true
,
/*
Allow
javascript
files
to
be
compiled.
*/
//
"checkJs"
:
true
,
/*
Report
errors
in
.js
files.
*/
//
"jsx"
:
"preserve"
,
/*
Specify
JSX
code
generation:
'preserve'
,
'react-native'
,
or
'react'.
*/
...
...
@@ -45,8 +45,8 @@
//
"types"
:
[],
/*
Type
declaration
files
to
be
included
in
compilation.
*/
//
"allowSyntheticDefaultImports"
:
true
,
/*
Allow
default
imports
from
modules
with
no
default
export.
This
does
not
affect
code
emit
,
just
typechecking.
*/
"esModuleInterop"
:
true
,
/*
Enables
emit
interoperability
between
CommonJS
and
ES
Modules
via
creation
of
namespace
objects
for
all
imports.
Implies
'allowSyntheticDefaultImports'.
*/
"skipLibCheck"
:
true
,
"forceConsistentCasingInFileNames"
:
true
//
"skipLibCheck"
:
true
,
//
"forceConsistentCasingInFileNames"
:
true
//
"preserveSymlinks"
:
true
,
/*
Do
not
resolve
the
real
path
of
symlinks.
*/
/*
Source
Map
Options
*/
...
...
@@ -59,5 +59,5 @@
//
"experimentalDecorators"
:
true
,
/*
Enables
experimental
support
for
ES
7
decorators.
*/
//
"emitDecoratorMetadata"
:
true
,
/*
Enables
experimental
support
for
emitting
type
metadata
for
decorators.
*/
},
"exclude"
:
[
"test/
**
/*"
]
"exclude"
:
[
"test/
resources
/*"
]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment