@ostack.tech/ui-kform-scaffolder 0.3.1 → 0.3.3
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/dist/ostack-ui-kform-scaffolder.js +46 -21
- package/dist/ostack-ui-kform-scaffolder.js.map +1 -1
- package/dist/types/configs/DefaultLocaleConfig.d.ts +1 -0
- package/dist/types/configs/SerializationFormatConfig.d.ts +1 -0
- package/dist/types/scaffolding/ScaffoldingData.d.ts +12 -0
- package/dist/types/scaffolding/scaffolders/scaffoldApi.d.ts +3 -0
- package/dist/types/scaffolding/scaffolders/scaffoldViteProject.d.ts +2 -0
- package/dist/webapp/assets/{index-BgTBiQUD.js → index-nQgQbr1y.js} +121 -99
- package/dist/webapp/index.html +1 -1
- package/package.json +1 -1
- package/dist/types/scaffolding/templates/react-app/src/api/reportError.d.ts +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useConfig, UseTableValuesSerializerConfig as UseTableValuesSerializerConfig$1, addEjsTemplateFile,
|
|
2
|
+
import { useConfig, UseTableValuesSerializerConfig as UseTableValuesSerializerConfig$1, addEjsTemplateFile, joinPaths, tsFile, code, anySchematicKind as anySchematicKind$1, bigDecimalSchematicKind as bigDecimalSchematicKind$1, bigIntegerSchematicKind as bigIntegerSchematicKind$1, booleanSchematicKind as booleanSchematicKind$1, byteSchematicKind as byteSchematicKind$1, classSchematicKind as classSchematicKind$1, doubleSchematicKind as doubleSchematicKind$1, enumSchematicKind as enumSchematicKind$1, fileSchematicKind as fileSchematicKind$1, floatSchematicKind as floatSchematicKind$1, intSchematicKind as intSchematicKind$1, ListableBuilderWithoutKindSelect, createSchematic, listSchematicKind, localDateSchematicKind as localDateSchematicKind$1, longSchematicKind as longSchematicKind$1, shortSchematicKind as shortSchematicKind$1, stringSchematicKind as stringSchematicKind$1, tableSchematicKind as tableSchematicKind$1, annotate, addTemplateFile, SchematicBuilder as SchematicBuilder$1, configScaffolder, scaffoldSchemas, scaffoldModels, scaffoldValidator } from "@ostack.tech/kform-scaffolder";
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import { capitalCase, camelCase, kebabCase, constantCase, sentenceCase, pascalCase } from "change-case";
|
|
5
|
+
const DEFAULT_LOCALE = "en-US";
|
|
5
6
|
const LOCALES = JSON.parse('["en-GB","en-US","fr","pt"]');
|
|
6
7
|
function DefaultLocaleConfig({
|
|
7
|
-
defaultValue =
|
|
8
|
+
defaultValue = DEFAULT_LOCALE,
|
|
8
9
|
disabled
|
|
9
10
|
}) {
|
|
10
11
|
const [config, setConfig] = useConfig("defaultLocale", defaultValue);
|
|
@@ -23,8 +24,9 @@ function DefaultLocaleConfig({
|
|
|
23
24
|
)
|
|
24
25
|
] });
|
|
25
26
|
}
|
|
27
|
+
const DEFAULT_SERIALIZATION_FORMAT = "json";
|
|
26
28
|
function SerializationFormatConfig({
|
|
27
|
-
defaultValue =
|
|
29
|
+
defaultValue = DEFAULT_SERIALIZATION_FORMAT,
|
|
28
30
|
disabled
|
|
29
31
|
}) {
|
|
30
32
|
const [useTableValuesSerializerConfig, setUseTableValuesSerializerConfig] = useConfig("useTableValuesSerializer", false);
|
|
@@ -61,7 +63,10 @@ function SerializationFormatConfig({
|
|
|
61
63
|
function UseTableValuesSerializerConfig({
|
|
62
64
|
disabled
|
|
63
65
|
}) {
|
|
64
|
-
const [serializationFormatConfig] = useConfig(
|
|
66
|
+
const [serializationFormatConfig] = useConfig(
|
|
67
|
+
"serializationFormat",
|
|
68
|
+
DEFAULT_SERIALIZATION_FORMAT
|
|
69
|
+
);
|
|
65
70
|
return /* @__PURE__ */ jsx(
|
|
66
71
|
UseTableValuesSerializerConfig$1,
|
|
67
72
|
{
|
|
@@ -88,17 +93,25 @@ function scaffoldActions(schematic, data) {
|
|
|
88
93
|
addEjsTemplateFile(data, "actions/Submit.tsx", submitTsxEjs, ejsData);
|
|
89
94
|
addEjsTemplateFile(data, "actions/Validate.tsx", validateTsxEjs, ejsData);
|
|
90
95
|
}
|
|
91
|
-
const
|
|
92
|
-
const
|
|
96
|
+
const apiFetchTsEjs = 'const API_BASE_URL = new URL("<%= apiBasePath %>", window.location.origin);\n\n/**\n * Wrapper around `fetch` for accessing the API.\n *\n * Configuration common to all API requests should be set here.\n */\nexport function apiFetch(url: string | URL, init?: RequestInit) {\n return fetch(new URL(url, API_BASE_URL), init);\n}\n';
|
|
97
|
+
const reportErrorTsEjs = 'import type { ErrorReport } from "@ostack.tech/ui";\nimport { apiFetch } from "./apiFetch.ts";\n\nconst REPORT_ERROR_API_ENDPOINT = "<%= reportErrorApiEndpoint %>";\n\nexport async function reportError(error: ErrorReport) {\n await apiFetch(REPORT_ERROR_API_ENDPOINT, {\n method: "POST",\n headers: { "Content-Type": "application/json" },\n body: JSON.stringify(error, null, import.meta.env.DEV ? 2 : 0),\n });\n}\n';
|
|
98
|
+
const submitTsEjs = 'import { LocatedValidationWarning } from "@ostack.tech/kform";\nimport {\n decode<%= formClass %>SubmitResponseFromString,\n encode<%= formClass %>ToString,\n <%= formClass %>,\n} from "<%= kmpModuleName %>";\nimport { apiFetch } from "./apiFetch.ts";\n\nconst SUBMIT_API_ENDPOINT = "<%= submitApiEndpoint %>";\n\nexport async function submit(\n <%= formVar %>: <%= formClass %>,\n acceptedWarnings?: LocatedValidationWarning[],\n) {\n const params = new URLSearchParams();\n if (acceptedWarnings?.length) {\n const acceptedWarningCodes = new Set(acceptedWarnings.map((w) => w.code));\n params.set("acceptedWarnings", Array.from(acceptedWarningCodes).join());\n }\n\n const response = await apiFetch(`${SUBMIT_API_ENDPOINT}?${params}`, {\n method: "POST",\n headers: { "Content-Type": "<%= serializationMimeType %>" },\n body: encode<%= formClass %>ToString(<%= formVar %>, import.meta.env.DEV),\n });\n return decode<%= formClass %>SubmitResponseFromString(await response.text());\n}\n';
|
|
99
|
+
const DEFAULT_API_BASE_PATH = "/api/";
|
|
100
|
+
const DEFAULT_REPORT_ERROR_API_ENDPOINT = "report-error";
|
|
101
|
+
const DEFAULT_SUBMIT_API_ENDPOINT = "submit";
|
|
93
102
|
function scaffoldApi(schematic, data) {
|
|
94
103
|
const ejsData = {
|
|
95
104
|
kmpModuleName: data.kmpModuleName ?? `${kebabCase(schematic.name)}-shared`,
|
|
96
|
-
serializationFormat: data.serializationFormat ??
|
|
105
|
+
serializationFormat: data.serializationFormat ?? DEFAULT_SERIALIZATION_FORMAT,
|
|
97
106
|
serializationMimeType: `application/${data.serializationFormat}`,
|
|
98
107
|
formVar: camelCase(schematic.name),
|
|
99
|
-
formClass: schematic.name
|
|
108
|
+
formClass: schematic.name,
|
|
109
|
+
apiBasePath: data.apiBasePath ?? DEFAULT_API_BASE_PATH,
|
|
110
|
+
reportErrorApiEndpoint: data.reportErrorApiEndpoint ?? DEFAULT_REPORT_ERROR_API_ENDPOINT,
|
|
111
|
+
submitApiEndpoint: data.submitApiEndpoint ?? DEFAULT_SUBMIT_API_ENDPOINT
|
|
100
112
|
};
|
|
101
|
-
|
|
113
|
+
addEjsTemplateFile(data, "api/apiFetch.ts", apiFetchTsEjs, ejsData);
|
|
114
|
+
addEjsTemplateFile(data, "api/reportError.ts", reportErrorTsEjs, ejsData);
|
|
102
115
|
addEjsTemplateFile(data, "api/submit.ts", submitTsEjs, ejsData);
|
|
103
116
|
}
|
|
104
117
|
function scaffoldIssueMessages(schematic, data) {
|
|
@@ -754,7 +767,7 @@ function scaffoldAppComponent(schematic, data) {
|
|
|
754
767
|
scaffoldIssueMessages(schematic, data);
|
|
755
768
|
}
|
|
756
769
|
function scaffoldAppComponentFile(schematic, data) {
|
|
757
|
-
const localeVar = (data.defaultLocale ??
|
|
770
|
+
const localeVar = (data.defaultLocale ?? DEFAULT_LOCALE).replaceAll("-", "");
|
|
758
771
|
data.currentFile.imports.push(
|
|
759
772
|
{ moduleName: "@ostack.tech/kform", name: "ktMapToObject" },
|
|
760
773
|
{ moduleName: "@ostack.tech/ui-kform", name: "FormApp" },
|
|
@@ -763,7 +776,7 @@ function scaffoldAppComponentFile(schematic, data) {
|
|
|
763
776
|
{ moduleName: data.kmpModuleName, name: schematic.name },
|
|
764
777
|
{ moduleName: data.kmpModuleName, name: `${schematic.name}FormMode` },
|
|
765
778
|
{ moduleName: data.kmpModuleName, name: `${schematic.name}Schema` },
|
|
766
|
-
{ moduleName: `./api/reportError.ts`, name: "
|
|
779
|
+
{ moduleName: `./api/reportError.ts`, name: "reportError" },
|
|
767
780
|
{
|
|
768
781
|
moduleName: `./${schematic.name}Context.ts`,
|
|
769
782
|
name: `use${schematic.name}Context`
|
|
@@ -796,7 +809,7 @@ function scaffoldAppComponentFile(schematic, data) {
|
|
|
796
809
|
}
|
|
797
810
|
issueMessages={${constantCase(schematic.name)}_ISSUE_MESSAGES}
|
|
798
811
|
defaultLocale={${localeVar}}
|
|
799
|
-
|
|
812
|
+
reportError={reportError}
|
|
800
813
|
>
|
|
801
814
|
<${schematic.name}Layout />
|
|
802
815
|
</FormApp>
|
|
@@ -963,7 +976,7 @@ function scaffoldExternalContexts(schematic, data) {
|
|
|
963
976
|
);
|
|
964
977
|
}
|
|
965
978
|
const buildGradleKts = "allprojects {\n repositories { mavenCentral() }\n}\n";
|
|
966
|
-
const gradlePropertiesEjs = "group=<%=
|
|
979
|
+
const gradlePropertiesEjs = "group=<%= gradlePropertiesGroup %>\nversion=0.0.1\n\norg.gradle.caching=true\norg.gradle.configuration-cache=true\n";
|
|
967
980
|
const libsVersionsTomlEjs = '[versions]\n# Plugins\nkotlin = "2.2.20"\nnodeGradle = "7.1.0"\n# Libraries\nkotlinxCoroutines = "1.10.2"\nkform = "<%= kFormVersion %>"\n<%_ if (usesKotlinxDatetime) { -%>\nkotlinxDatetime = "0.7.1"\n<%_ } -%>\n<%_ if (serializationFormat === "json") { -%>\nkotlinxSerialization = "1.9.0"\n<%_ } -%>\n<%_ if (usesKtMath) { -%>\nktMath = "0.10.2"\n<%_ } -%>\nslf4j = "2.0.17"\n<%_ if (serializationFormat === "xml") { -%>\nxmlutil = "0.91.1"\n<%_ } -%>\n# Runtimes\njvmToolchain = "17"\nnodejs = "22.20.0"\n\n[libraries]\nkform = { module = "tech.ostack:kform", version.ref = "kform" }\nkform-jsBindings = { module = "tech.ostack:kform-js-bindings", version.ref = "kform" }\nkotlinxCoroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" }\n<%_ if (usesKotlinxDatetime) { -%>\nkotlinxDatetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }\n<%_ } -%>\n<%_ if (serializationFormat === "json") { -%>\nkotlinxSerialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" }\n<%_ } -%>\n<%_ if (usesKtMath) { -%>\nktMath = { module = "io.github.gciatto:kt-math", version.ref = "ktMath" }\n<%_ } -%>\nslf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }\n<%_ if (serializationFormat === "xml") { -%>\nxmlutil-serialization = { module = "io.github.pdvrieze.xmlutil:serialization", version.ref = "xmlutil" }\n<%_ } -%>\n\n[plugins]\nkotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }\nkotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }\nnodeGradle = { id = "com.github.node-gradle.node", version.ref = "nodeGradle" }\n';
|
|
968
981
|
const reactAppBuildGradleKtsEjs = 'import com.github.gradle.node.npm.task.NpmTask\n\nplugins {\n alias(libs.plugins.nodeGradle)\n base\n}\n\nval isCI = System.getenv("CI") !in arrayOf(null, "0", "false")\nnode {\n download = true\n version = libs.versions.nodejs.get()\n npmInstallCommand = if (isCI) "ci" else "install"\n}\n\nval sharedPackage = project(":shared").file("build/<%= formId %>-shared-$version.tgz")\n\nval npmInstallShared by tasks.registering(NpmTask::class) {\n group = "build"\n dependsOn(":shared:packJsPackage")\n npmCommand = listOf("install", "<%= formId %>-shared@file:$sharedPackage")\n\n inputs.file(sharedPackage)\n outputs.dir("node_modules/<%= formId %>-shared")\n}\n\ntasks.npmInstall {\n dependsOn(npmInstallShared)\n}\n\nval npmRunDev by tasks.registering(NpmTask::class) {\n group = "development"\n dependsOn(tasks.npmInstall)\n npmCommand = listOf("run", "dev")\n}\n\nprivate fun NpmTask.npmRunBuild(buildReason: String) {\n group = "build"\n dependsOn(tasks.npmInstall)\n npmCommand = listOf("run", "build")\n environment = mapOf("VITE_BUILD_REASON" to buildReason)\n\n inputs.dir("src")\n inputs.file(sharedPackage)\n inputs.file("index.html")\n inputs.file("package.json")\n inputs.file("tsconfig.json")\n inputs.file("tsconfig.app.json")\n inputs.file("tsconfig.node.json")\n inputs.file("vite.config.ts")\n outputs.dir("build/dist")\n}\n\nval npmRunBuild by tasks.registering(NpmTask::class) {\n npmRunBuild("production")\n}\n\nval npmRunBuildPreview by tasks.registering(NpmTask::class) {\n npmRunBuild("preview")\n}\n\nval npmRunPreview by tasks.registering(NpmTask::class) {\n group = "development"\n dependsOn(npmRunBuildPreview)\n npmCommand = listOf("run", "preview")\n}\n\nval npmRunLint by tasks.registering(NpmTask::class) {\n group = "verification"\n dependsOn(tasks.npmInstall)\n npmCommand = listOf("run", "lint")\n\n inputs.dir("src")\n inputs.file("eslint.config.js")\n inputs.file("package.json")\n inputs.file("tsconfig.json")\n inputs.file("tsconfig.app.json")\n inputs.file("tsconfig.node.json")\n outputs.upToDateWhen { true }\n}\n\ntasks.assemble {\n dependsOn(npmRunBuild)\n}\n';
|
|
969
982
|
const settingsGradleKtsEjs = 'plugins {\n id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"\n}\n\nrootProject.name = "<%= formId %>"\n\ninclude("shared", "react-app")\n';
|
|
@@ -971,11 +984,11 @@ const sharedBuildGradleKtsEjs = 'import com.github.gradle.node.npm.task.NpmTask\
|
|
|
971
984
|
const jsJodaTimeZoneKtEjs = 'package <%= filePackage %>\n\n// See: https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#note-about-time-zones-in-js\n@JsModule("@js-joda/timezone")\n@JsNonModule\nexternal object JsJodaTimeZoneModule\n\n@JsExport\nval jsJodaTz = JsJodaTimeZoneModule\n';
|
|
972
985
|
function scaffoldGradleProject(schematic, data) {
|
|
973
986
|
const ejsData = {
|
|
974
|
-
|
|
987
|
+
gradlePropertiesGroup: data.gradlePropertiesGroup ?? data.currentPackage,
|
|
975
988
|
filePackage: data.currentPackage,
|
|
976
989
|
formId: kebabCase(schematic.name),
|
|
977
990
|
formTitle: capitalCase(schematic.name),
|
|
978
|
-
kFormVersion: "0.31.
|
|
991
|
+
kFormVersion: "0.31.5",
|
|
979
992
|
serializationFormat: data.serializationFormat ?? "json",
|
|
980
993
|
usesKotlinxDatetime: usesKotlinxDatetime(schematic, data),
|
|
981
994
|
usesKtMath: usesKtMath(schematic)
|
|
@@ -1513,23 +1526,28 @@ const indexScss = '@use "@ostack.tech/ui/scss" as ostack-ui;\n@use "@ostack.tech
|
|
|
1513
1526
|
function scaffoldStyles(_schematic, data) {
|
|
1514
1527
|
addTemplateFile(data, "index.scss", indexScss);
|
|
1515
1528
|
}
|
|
1516
|
-
const eslintConfigJs = 'import js from "@eslint/js";\nimport { defineConfig, globalIgnores } from "eslint/config";\nimport reactHooks from "eslint-plugin-react-hooks";\nimport reactRefresh from "eslint-plugin-react-refresh";\nimport globals from "globals";\nimport tseslint from "typescript-eslint";\n\nexport default defineConfig([\n globalIgnores([".gradle", "build"]),\n {\n files: ["**/*.{ts,tsx}"],\n extends: [\n js.configs.recommended,\n tseslint.configs.recommended,\n reactHooks.configs
|
|
1529
|
+
const eslintConfigJs = 'import js from "@eslint/js";\nimport { defineConfig, globalIgnores } from "eslint/config";\nimport reactHooks from "eslint-plugin-react-hooks";\nimport reactRefresh from "eslint-plugin-react-refresh";\nimport globals from "globals";\nimport tseslint from "typescript-eslint";\n\nexport default defineConfig([\n globalIgnores([".gradle", "build"]),\n {\n files: ["**/*.{ts,tsx}"],\n extends: [\n js.configs.recommended,\n tseslint.configs.recommended,\n reactHooks.configs.flat.recommended,\n reactRefresh.configs.vite,\n ],\n languageOptions: {\n ecmaVersion: 2020,\n globals: globals.browser,\n },\n },\n]);\n';
|
|
1517
1530
|
const indexHtmlEjs = '<!doctype html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <link rel="icon" type="image/svg+xml" href="/vite.svg" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title><%= formTitle %></title>\n </head>\n <body>\n <div\n id="<%= formId %>-app-root"\n data-external-contexts="<%= externalContextsData %>"\n ></div>\n <script type="module" src="/src/main.tsx"><\/script>\n <script type="module">\n render<%= formClass %>App();\n <\/script>\n </body>\n</html>\n';
|
|
1518
1531
|
const packageJsonEjs = '{\n "name": "<%= formId %>-react-app",\n "private": true,\n "version": "0.0.0",\n "type": "module",\n "scripts": {\n "dev": "vite",\n "build": "tsc -b && vite build",\n "lint": "eslint .",\n "preview": "vite preview"\n },\n "dependencies": {\n "@fortawesome/fontawesome-svg-core": "<%= dependencyVersions["@fortawesome/fontawesome-svg-core"] %>",\n "@fortawesome/free-regular-svg-icons": "<%= dependencyVersions["@fortawesome/free-regular-svg-icons"] %>",\n "@fortawesome/free-solid-svg-icons": "<%= dependencyVersions["@fortawesome/free-solid-svg-icons"] %>",\n "@ostack.tech/kform-react": "~<%= kFormVersion %>",\n "@ostack.tech/ui": "~<%= ostackUiVersion %>",\n "@ostack.tech/ui-kform": "~<%= ostackUiVersion %>",\n "date-fns": "<%= dependencyVersions["date-fns"] %>",\n "<%= formId %>-shared": "file:../shared/build/<%= formId %>-shared-0.0.1.tgz",\n "react": "<%= dependencyVersions.react %>",\n "react-dom": "<%= dependencyVersions["react-dom"] %>",\n "react-router": "<%= dependencyVersions["react-router"] %>",\n "react-router-dom": "<%= dependencyVersions["react-router-dom"] %>"\n },\n "devDependencies": {\n "@eslint/js": "<%= dependencyVersions["@eslint/js"] %>",\n "@types/node": "<%= dependencyVersions["@types/node"] %>",\n "@types/ostack.tech__kform": "npm:@ostack.tech/kform@~<%= kFormVersion %>",\n "@types/react": "<%= dependencyVersions["@types/react"] %>",\n "@types/react-dom": "<%= dependencyVersions["@types/react-dom"] %>",\n "@vitejs/plugin-react-swc": "<%= dependencyVersions["@vitejs/plugin-react-swc"] %>",\n "eslint": "<%= dependencyVersions.eslint %>",\n "eslint-plugin-react-hooks": "<%= dependencyVersions["eslint-plugin-react-hooks"] %>",\n "eslint-plugin-react-refresh": "<%= dependencyVersions["eslint-plugin-react-refresh"] %>",\n "globals": "<%= dependencyVersions.globals %>",\n "sass-embedded": "<%= dependencyVersions["sass-embedded"] %>",\n "typescript": "<%= dependencyVersions.typescript %>",\n "typescript-eslint": "<%= dependencyVersions["typescript-eslint"] %>",\n "vite": "<%= dependencyVersions.vite %>"\n }\n}\n';
|
|
1519
1532
|
const viteSvg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>\n';
|
|
1520
1533
|
const tsConfigAppJson = '{\n "compilerOptions": {\n "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",\n "target": "ES2022",\n "useDefineForClassFields": true,\n "lib": ["ES2022", "DOM", "DOM.Iterable"],\n "module": "ESNext",\n "types": ["vite/client"],\n "skipLibCheck": true,\n\n /* Bundler mode */\n "moduleResolution": "bundler",\n "allowImportingTsExtensions": true,\n "verbatimModuleSyntax": true,\n "moduleDetection": "force",\n "noEmit": true,\n "jsx": "react-jsx",\n\n /* Linting */\n "strict": true,\n "noUnusedLocals": true,\n "noUnusedParameters": true,\n "erasableSyntaxOnly": true,\n "noFallthroughCasesInSwitch": true,\n "noUncheckedSideEffectImports": true\n },\n "include": ["src"]\n}\n';
|
|
1521
1534
|
const tsConfigJson = '{\n "files": [],\n "references": [\n { "path": "./tsconfig.app.json" },\n { "path": "./tsconfig.node.json" }\n ]\n}\n';
|
|
1522
1535
|
const tsConfigNodeJson = '{\n "compilerOptions": {\n "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",\n "target": "ES2023",\n "lib": ["ES2023"],\n "module": "ESNext",\n "types": ["node"],\n "skipLibCheck": true,\n\n /* Bundler mode */\n "moduleResolution": "bundler",\n "allowImportingTsExtensions": true,\n "verbatimModuleSyntax": true,\n "moduleDetection": "force",\n "noEmit": true,\n\n /* Linting */\n "strict": true,\n "noUnusedLocals": true,\n "noUnusedParameters": true,\n "erasableSyntaxOnly": true,\n "noFallthroughCasesInSwitch": true,\n "noUncheckedSideEffectImports": true\n },\n "include": ["vite.config.ts"]\n}\n';
|
|
1523
|
-
const viteConfigTsEjs = 'import { resolve } from "node:path";\n\nimport react from "@vitejs/plugin-react-swc";\nimport { defineConfig } from "vite";\n\n// https://vite.dev/config/\nexport default defineConfig({\n plugins: [react()],\n build: {\n outDir: "
|
|
1536
|
+
const viteConfigTsEjs = 'import { resolve } from "node:path";\n\nimport react from "@vitejs/plugin-react-swc";\nimport { defineConfig } from "vite";\n\n// https://vite.dev/config/\nexport default defineConfig({\n plugins: [react()],\n build: {\n outDir: "<%= viteConfigOutDir %>",\n rollupOptions: {\n input: {\n "<%= formId %>-app":\n process.env.VITE_BUILD_REASON === "preview"\n ? "index.html"\n : "src/main.tsx",\n },\n output: {\n // Output files without hashes, making it easier to serve them in the\n // server. However, the server is expected to somehow "version" them for\n // cache busting purposes.\n entryFileNames: "assets/[name].js",\n chunkFileNames: "assets/[name].js",\n assetFileNames: "assets/[name].[ext]",\n },\n },\n },\n resolve: {\n alias: [\n // Due to how Kotlin "bundles" dependencies, we need to use the\n // `@ostack.tech/kform` produced by the shared module.\n {\n find: "@ostack.tech/kform",\n replacement: resolve(\n import.meta.dirname,\n "node_modules/<%= formId %>-shared/ostack-kform.mjs",\n ),\n },\n ],\n },\n server: {\n proxy: { "<%= apiBasePath %>": "<%= viteConfigProxyTarget %>" },\n },\n});\n';
|
|
1537
|
+
const DEFAULT_VITE_CONFIG_OUT_DIR = "build/dist/";
|
|
1538
|
+
const DEFAULT_VITE_CONFIG_PROXY_TARGET = "http://127.0.0.1:8080/";
|
|
1524
1539
|
function scaffoldViteProject(schematic, data) {
|
|
1525
1540
|
const ejsData = {
|
|
1526
1541
|
formId: kebabCase(schematic.name),
|
|
1527
1542
|
formClass: schematic.name,
|
|
1528
1543
|
formTitle: capitalCase(schematic.name),
|
|
1529
|
-
ostackUiVersion: "0.3.
|
|
1530
|
-
kFormVersion: "0.31.
|
|
1531
|
-
dependencyVersions: JSON.parse('{"@eslint/js":"^9.38.0","@fortawesome/fontawesome-svg-core":"^7.1.0","@fortawesome/free-brands-svg-icons":"^7.1.0","@fortawesome/free-regular-svg-icons":"^7.1.0","@fortawesome/free-solid-svg-icons":"^7.1.0","@ostack.tech/kform":"~0.31.
|
|
1532
|
-
externalContextsData: data.serializationFormat === "json" ? "{}" : `<${schematic.name}ExternalContexts
|
|
1544
|
+
ostackUiVersion: "0.3.3",
|
|
1545
|
+
kFormVersion: "0.31.5",
|
|
1546
|
+
dependencyVersions: JSON.parse('{"@eslint/js":"^9.38.0","@fortawesome/fontawesome-svg-core":"^7.1.0","@fortawesome/free-brands-svg-icons":"^7.1.0","@fortawesome/free-regular-svg-icons":"^7.1.0","@fortawesome/free-solid-svg-icons":"^7.1.0","@ostack.tech/kform":"~0.31.5","@ostack.tech/kform-react":"~0.31.5","@ostack.tech/kform-scaffolder":"~0.31.5","@storybook/addon-docs":"^9.1.16","@storybook/addon-links":"^9.1.16","@storybook/react-vite":"^9.1.16","@types/node":"^22.18.13","@types/react":"^19.2.2","@types/react-dom":"^19.2.2","@vitejs/plugin-react-swc":"^4.2.0","change-case":"^5.4.4","cpy-cli":"^6.0.0","date-fns":"^4.1.0","eslint":"^9.38.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","eslint-plugin-react-hooks":"^7.0.1","eslint-plugin-react-refresh":"^0.4.24","eslint-plugin-simple-import-sort":"^12.1.1","eslint-plugin-storybook":"^9.1.16","globals":"^16.4.0","happy-dom":"^20.0.10","lint-staged":"^16.2.6","prettier":"^3.6.2","prettier-plugin-jsdoc":"^1.5.0","react":"^19.2.0","react-dom":"^19.2.0","react-router":"^7.9.5","react-router-dom":"^7.9.5","rimraf":"^6.0.1","sass-embedded":"^1.93.2","simple-git-hooks":"^2.13.1","storybook":"^9.1.16","terser":"^5.44.0","tslib":"^2.8.1","typescript":"~5.9.3","typescript-eslint":"^8.46.2","vite":"^7.1.12","vite-plugin-dts":"^4.5.4","vitest":"^4.0.5","zustand":"^5.0.8"}'),
|
|
1547
|
+
externalContextsData: data.serializationFormat === "json" ? "{}" : `<${schematic.name}ExternalContexts />`,
|
|
1548
|
+
apiBasePath: data.apiBasePath ?? DEFAULT_API_BASE_PATH,
|
|
1549
|
+
viteConfigOutDir: data.viteConfigOutDir ?? DEFAULT_VITE_CONFIG_OUT_DIR,
|
|
1550
|
+
viteConfigProxyTarget: data.viteConfigProxyTarget ?? DEFAULT_VITE_CONFIG_PROXY_TARGET
|
|
1533
1551
|
};
|
|
1534
1552
|
addEjsTemplateFile(data, "react-app/package.json", packageJsonEjs, ejsData);
|
|
1535
1553
|
addEjsTemplateFile(
|
|
@@ -1600,6 +1618,13 @@ function SchematicBuilder({
|
|
|
1600
1618
|
);
|
|
1601
1619
|
}
|
|
1602
1620
|
export {
|
|
1621
|
+
DEFAULT_API_BASE_PATH,
|
|
1622
|
+
DEFAULT_LOCALE,
|
|
1623
|
+
DEFAULT_REPORT_ERROR_API_ENDPOINT,
|
|
1624
|
+
DEFAULT_SERIALIZATION_FORMAT,
|
|
1625
|
+
DEFAULT_SUBMIT_API_ENDPOINT,
|
|
1626
|
+
DEFAULT_VITE_CONFIG_OUT_DIR,
|
|
1627
|
+
DEFAULT_VITE_CONFIG_PROXY_TARGET,
|
|
1603
1628
|
DefaultLocaleConfig,
|
|
1604
1629
|
LOCALES,
|
|
1605
1630
|
SchematicBuilder,
|