Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996281
add-jdd-component.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
add-jdd-component.ts
View Options
import
{
resolve
}
from
"path"
;
import
_locreq
from
"locreq"
;
import
{
promises
as
fs
,
existsSync
}
from
"fs"
;
import
{
question
}
from
"./utils/question.js"
;
const
target_locreq
=
_locreq
(
process
.
cwd
());
import
{
jddComponentTemplate
}
from
"./templates/jdd-component.js"
;
import
{
generateComponents
}
from
"./generate-components.js"
;
import
{
toKebabCase
}
from
"js-convert-case"
;
export
async
function
addJDDComponent
()
:
Promise
<
void
>
{
const
component_name
=
await
question
(
"What's the name of the component? > "
,
(
s
:
string
)
=>
s
.
length
>
3
);
const
file_path
=
target_locreq
.
resolve
(
`src/back/jdd-components/
${
toKebabCase
(
component_name
)
}
/
${
toKebabCase
(
component_name
)
}
.jdd.tsx`
);
if
(
existsSync
(
file_path
))
{
// eslint-disable-next-line no-console
console
.
error
(
`ERROR: File
${
file_path
}
already exists.`
);
return
;
}
await
fs
.
mkdir
(
resolve
(
file_path
,
"../"
),
{
recursive
:
true
});
await
fs
.
writeFile
(
file_path
,
jddComponentTemplate
(
component_name
));
const
css_file_path
=
target_locreq
.
resolve
(
`src/back/jdd-components/
${
toKebabCase
(
component_name
)
}
/
${
toKebabCase
(
component_name
)
}
.css`
);
await
fs
.
writeFile
(
css_file_path
,
`.
${
toKebabCase
(
component_name
)
}
{
}`
);
// eslint-disable-next-line no-console
console
.
log
(
`Created
${
file_path
}
`
);
console
.
log
(
`Created
${
css_file_path
}
`
);
await
generateComponents
();
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (21 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557152
Default Alt Text
add-jdd-component.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment