1- import fs from 'fs' ;
2- import handlebars from ' handlebars' ;
3- import mkdirp from ' mkdirp' ;
4- import { sprintf } from ' sprintf-js' ;
5- import urlapi from ' url' ;
1+ import fs from "fs" ;
2+ import handlebars from " handlebars" ;
3+ import mkdirp from " mkdirp" ;
4+ import { sprintf } from " sprintf-js" ;
5+ import urlapi from " url" ;
66
77export default class {
88 templates = { } ;
99
10- constructor ( { hydraPrefix, templateDirectory} ) {
10+ constructor ( { hydraPrefix, templateDirectory } ) {
1111 this . hydraPrefix = hydraPrefix ;
1212 this . templateDirectory = templateDirectory ;
1313
14- this . registerTemplates ( '' , [ ' _entrypoint.js' ] ) ;
14+ this . registerTemplates ( "" , [ " _entrypoint.js" ] ) ;
1515 }
1616
1717 registerTemplates ( basePath , paths ) {
1818 for ( let path of paths ) {
19- this . templates [ path ] = handlebars . compile ( fs . readFileSync ( `${ this . templateDirectory } /${ basePath } ${ path } ` ) . toString ( ) ) ;
19+ this . templates [ path ] = handlebars . compile (
20+ fs
21+ . readFileSync ( `${ this . templateDirectory } /${ basePath } ${ path } ` )
22+ . toString ( )
23+ ) ;
2024 }
2125 }
2226
@@ -31,7 +35,11 @@ export default class {
3135 }
3236
3337 createFileFromPattern ( pattern , dir , lc , context ) {
34- this . createFile ( sprintf ( pattern , 'foo' ) , sprintf ( `${ dir } /${ pattern } ` , lc ) , context ) ;
38+ this . createFile (
39+ sprintf ( pattern , "foo" ) ,
40+ sprintf ( `${ dir } /${ pattern } ` , lc ) ,
41+ context
42+ ) ;
3543 }
3644
3745 createFile ( template , dest , context = { } , warn = true ) {
@@ -46,41 +54,46 @@ export default class {
4654
4755 createEntrypoint ( apiEntry , dest ) {
4856 const url = urlapi . parse ( apiEntry ) ;
49- const { protocol, host, pathname} = url ;
50-
51- this . createFile ( '_entrypoint.js' , dest , { host : `${ protocol } //${ host } ` , path : pathname } , false ) ;
57+ const { protocol, host, pathname } = url ;
58+
59+ this . createFile (
60+ "_entrypoint.js" ,
61+ dest ,
62+ { host : `${ protocol } //${ host } ` , path : pathname } ,
63+ false
64+ ) ;
5265 }
5366
5467 getHtmlInputTypeFromField ( field ) {
5568 switch ( field . id ) {
56- case ' http://schema.org/email' :
57- return { type : ' email' } ;
69+ case " http://schema.org/email" :
70+ return { type : " email" } ;
5871
59- case ' http://schema.org/url' :
60- return { type : ' url' } ;
72+ case " http://schema.org/url" :
73+ return { type : " url" } ;
6174 }
6275
6376 switch ( field . range ) {
64- case ' http://www.w3.org/2001/XMLSchema#integer' :
65- return { type : ' number' } ;
77+ case " http://www.w3.org/2001/XMLSchema#integer" :
78+ return { type : " number" } ;
6679
67- case ' http://www.w3.org/2001/XMLSchema#decimal' :
68- return { type : ' number' , step : ' 0.1' } ;
80+ case " http://www.w3.org/2001/XMLSchema#decimal" :
81+ return { type : " number" , step : " 0.1" } ;
6982
70- case ' http://www.w3.org/2001/XMLSchema#boolean' :
71- return { type : ' checkbox' } ;
83+ case " http://www.w3.org/2001/XMLSchema#boolean" :
84+ return { type : " checkbox" } ;
7285
73- case ' http://www.w3.org/2001/XMLSchema#date' :
74- return { type : ' date' } ;
86+ case " http://www.w3.org/2001/XMLSchema#date" :
87+ return { type : " date" } ;
7588
76- case ' http://www.w3.org/2001/XMLSchema#time' :
77- return { type : ' time' } ;
89+ case " http://www.w3.org/2001/XMLSchema#time" :
90+ return { type : " time" } ;
7891
79- case ' http://www.w3.org/2001/XMLSchema#dateTime' :
80- return { type : ' dateTime' } ;
92+ case " http://www.w3.org/2001/XMLSchema#dateTime" :
93+ return { type : " dateTime" } ;
8194
8295 default :
83- return { type : ' text' } ;
96+ return { type : " text" } ;
8497 }
8598 }
8699
@@ -92,7 +105,7 @@ export default class {
92105 field . name = apiField . name ;
93106 field . description = apiField . description . replace ( / " / g, "'" ) ; // fix for Form placeholder description
94107
95- fields . push ( field )
108+ fields . push ( field ) ;
96109 }
97110
98111 return fields ;
0 commit comments