@vc-shell/create-vc-app 2.0.0-alpha.16 → 2.0.0-alpha.17

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.test.d.ts +2 -0
  4. package/dist/commands/init.test.d.ts.map +1 -0
  5. package/dist/engine/codegen.d.ts.map +1 -1
  6. package/dist/engine/helpers.d.ts +1 -1
  7. package/dist/engine/helpers.d.ts.map +1 -1
  8. package/dist/engine/helpers.test.d.ts +2 -0
  9. package/dist/engine/helpers.test.d.ts.map +1 -0
  10. package/dist/engine/template.d.ts.map +1 -1
  11. package/dist/engine/template.test.d.ts +2 -0
  12. package/dist/engine/template.test.d.ts.map +1 -0
  13. package/dist/index.js +169 -165
  14. package/dist/output.d.ts.map +1 -1
  15. package/dist/templates/dynamic-module/_package.json.ejs +6 -6
  16. package/dist/templates/dynamic-module/src/modules/index.ts.ejs +8 -5
  17. package/dist/templates/dynamic-module/tsconfig.json +1 -1
  18. package/dist/templates/host-app/_package.json.ejs +7 -9
  19. package/dist/templates/host-app/src/main.ts.ejs +17 -15
  20. package/dist/templates/host-app/tsconfig.json +1 -0
  21. package/dist/templates/module/composables/useDetails.ts.ejs +41 -38
  22. package/dist/templates/module/index.ts.ejs +11 -8
  23. package/dist/templates/module/locales/en.json.ejs +33 -22
  24. package/dist/templates/module/pages/details.vue.ejs +10 -12
  25. package/dist/templates/module/pages/list.vue.ejs +11 -13
  26. package/dist/templates/sample-module/index.ts +11 -8
  27. package/dist/templates/sample-module/pages/details.vue +8 -4
  28. package/dist/templates/sample-module/pages/list.vue +103 -119
  29. package/dist/templates/standalone/_package.json.ejs +7 -9
  30. package/dist/templates/standalone/src/bootstrap.ts.ejs +5 -5
  31. package/dist/templates/standalone/src/main.ts.ejs +29 -23
  32. package/dist/templates/standalone/tsconfig.json +1 -0
  33. package/dist/types.d.ts +2 -2
  34. package/dist/types.d.ts.map +1 -1
  35. package/package.json +3 -2
  36. package/dist/templates/host-app/src/shims-vue.d.ts +0 -27
  37. package/dist/templates/host-app/src/vue-i18n.d.ts +0 -10
  38. package/dist/templates/standalone/src/shims-vue.d.ts +0 -27
  39. package/dist/templates/standalone/src/vue-i18n.d.ts +0 -10
@@ -22,8 +22,8 @@
22
22
  "@types/node": "^20.10.5",
23
23
  "@typescript-eslint/eslint-plugin": "^7.4.0",
24
24
  "@typescript-eslint/parser": "^7.4.0",
25
- "@vc-shell/api-client-generator": "^2.0.0-alpha.16",
26
- "@vc-shell/ts-config": "^2.0.0-alpha.16",
25
+ "@vc-shell/api-client-generator": "^2.0.0-alpha.17",
26
+ "@vc-shell/ts-config": "^2.0.0-alpha.17",
27
27
  "@vitejs/plugin-vue": "^5.2.3",
28
28
  "@vue/eslint-config-prettier": "^9.0.0",
29
29
  "@vue/eslint-config-typescript": "^13.0.0",
@@ -48,18 +48,16 @@
48
48
  "vite-plugin-checker": "^0.9.1",
49
49
  "vite-plugin-mkcert": "^1.17.1",
50
50
  "vue-eslint-parser": "^9.3.2",
51
- "vue-tsc": "^2.2.10"
51
+ "vue-tsc": "^3.2.5"
52
52
  },
53
53
  "dependencies": {
54
- "@vc-shell/config-generator": "^2.0.0-alpha.16",
55
- "@vc-shell/framework": "^2.0.0-alpha.16",
54
+ "@vc-shell/config-generator": "^2.0.0-alpha.17",
55
+ "@vc-shell/framework": "^2.0.0-alpha.17",
56
56
  "@vueuse/core": "^10.7.1",
57
57
  "@vueuse/integrations": "^10.7.1",
58
- "cross-spawn": "^7.0.3",
59
- "moment": "^2.30.1",
60
58
  "vee-validate": "^4.12.4",
61
- "vue": "^3.5.13",
62
- "vue-router": "^4.2.5"
59
+ "vue": "^3.5.30",
60
+ "vue-router": "^5.0.3"
63
61
  },
64
62
  "lint-staged": {
65
63
  "*.{js,ts,html,css}": "prettier --write '**/*.{ts,vue}'",
@@ -16,24 +16,26 @@ async function startApp() {
16
16
  console.log(e);
17
17
  }
18
18
 
19
- const app = createApp(RouterView)
20
- .use(VirtoShellFramework, {
21
- router,
22
- i18n: {
23
- locale: import.meta.env.APP_I18N_LOCALE,
24
- fallbackLocale: import.meta.env.APP_I18N_FALLBACK_LOCALE,
25
- },
19
+ const { currentLocale, setLocale } = useLanguages();
20
+
21
+ const app = createApp(RouterView);
22
+
23
+ app.use(VirtoShellFramework, {
24
+ router,
25
+ i18n: {
26
+ locale: import.meta.env.APP_I18N_LOCALE,
27
+ fallbackLocale: import.meta.env.APP_I18N_FALLBACK_LOCALE,
28
+ },
26
29
  <% if (aiAgent) { %>
27
- aiAgent: {
28
- config: {
29
- url: import.meta.env.APP_AI_AGENT_URL,
30
- },
30
+ aiAgent: {
31
+ config: {
32
+ url: import.meta.env.APP_AI_AGENT_URL,
31
33
  },
34
+ },
32
35
  <% } %>
33
- })
34
- .use(router);
36
+ });
35
37
 
36
- const { currentLocale, setLocale } = app.runWithContext(() => useLanguages());
38
+ app.use(router);
37
39
 
38
40
  bootstrap(app);
39
41
 
@@ -43,7 +45,7 @@ async function startApp() {
43
45
 
44
46
  setLocale(currentLocale.value);
45
47
 
46
- app.config.errorHandler = (err) => {
48
+ app.config.errorHandler = (err: unknown) => {
47
49
  notification.error((err as Error).toString(), {
48
50
  timeout: 5000,
49
51
  });
@@ -6,6 +6,7 @@
6
6
  "rootDir": "src",
7
7
  "types": [
8
8
  "vite/client",
9
+ "@vc-shell/framework/globals"
9
10
  ]
10
11
  },
11
12
  "include": [
@@ -1,38 +1,41 @@
1
- import { ref } from "vue";
2
- import { useAsync, useLoading } from "@vc-shell/framework";
3
-
4
- export default function use<%- ModuleNamePascalCase %>Details() {
5
- const item = ref<Record<string, unknown>>({});
6
-
7
- const { loading: itemLoading, action: fetchItem } = useAsync(async (id?: string) => {
8
- // TODO: Replace with real API call
9
- // const result = await apiClient.getById(id);
10
- // item.value = result;
11
- });
12
-
13
- const { loading: saveLoading, action: saveAction } = useAsync(async () => {
14
- // TODO: Replace with real API call
15
- // if (item.value.id) {
16
- // await apiClient.update(item.value);
17
- // } else {
18
- // await apiClient.create(item.value);
19
- // }
20
- });
21
-
22
- const loading = useLoading(itemLoading, saveLoading);
23
-
24
- async function getItem(id: string) {
25
- await fetchItem(id);
26
- }
27
-
28
- async function saveItem() {
29
- await saveAction();
30
- }
31
-
32
- return {
33
- item,
34
- loading,
35
- getItem,
36
- saveItem,
37
- };
38
- }
1
+ import { ref } from "vue";
2
+ import { useAsync, useLoading, useModificationTracker } from "@vc-shell/framework";
3
+
4
+ export default function use<%- ModuleNamePascalCase %>Details() {
5
+ const item = ref<Record<string, any>>({});
6
+ const { isModified, resetModificationState } = useModificationTracker(item);
7
+
8
+ const { loading: itemLoading, action: fetchItem } = useAsync(async (id?: string) => {
9
+ // TODO: Replace with real API call
10
+ // const result = await apiClient.getById(id);
11
+ // item.value = result;
12
+ });
13
+
14
+ const { loading: saveLoading, action: saveAction } = useAsync(async () => {
15
+ // TODO: Replace with real API call
16
+ // if (item.value.id) {
17
+ // await apiClient.update(item.value);
18
+ // } else {
19
+ // await apiClient.create(item.value);
20
+ // }
21
+ });
22
+
23
+ const loading = useLoading(itemLoading, saveLoading);
24
+
25
+ async function getItem(id: string) {
26
+ await fetchItem(id);
27
+ }
28
+
29
+ async function saveItem() {
30
+ await saveAction();
31
+ }
32
+
33
+ return {
34
+ item,
35
+ loading,
36
+ getItem,
37
+ saveItem,
38
+ isModified,
39
+ resetModificationState,
40
+ };
41
+ }
@@ -1,8 +1,11 @@
1
- import * as pages from "./pages";
2
- import * as locales from "./locales";
3
- import { createAppModule } from "@vc-shell/framework";
4
-
5
- export default createAppModule(pages, locales);
6
-
7
- export * from "./pages";
8
- export * from "./composables";
1
+ import * as blades from "./pages";
2
+ import * as locales from "./locales";
3
+ import { defineAppModule } from "@vc-shell/framework";
4
+
5
+ export default defineAppModule({
6
+ blades,
7
+ locales,
8
+ });
9
+
10
+ export * from "./pages";
11
+ export * from "./composables";
@@ -1,22 +1,33 @@
1
- {
2
- "<%- ModuleNameScreamingSnake %>": {
3
- "MENU": {
4
- "TITLE": "<%- ModuleNameSentenceCase %>"
5
- },
6
- "PAGES": {
7
- "LIST": {
8
- "TITLE": "<%- ModuleNameSentenceCase %>",
9
- "TOOLBAR": {
10
- "REFRESH": "Refresh",
11
- "ADD": "Add"
12
- }
13
- },
14
- "DETAILS": {
15
- "TITLE": "<%- ModuleNameSentenceCase %> Details"
16
- },
17
- "ALERTS": {
18
- "CLOSE_CONFIRMATION": "You have unsaved changes. Close anyway?"
19
- }
20
- }
21
- }
22
- }
1
+ {
2
+ "<%- ModuleNameScreamingSnake %>": {
3
+ "MENU": {
4
+ "TITLE": "<%- ModuleNameSentenceCase %>"
5
+ },
6
+ "PAGES": {
7
+ "LIST": {
8
+ "TITLE": "<%- ModuleNameSentenceCase %>",
9
+ "COLUMNS": {
10
+ "NAME": "Name",
11
+ "CREATED_DATE": "Created"
12
+ },
13
+ "TOOLBAR": {
14
+ "REFRESH": "Refresh",
15
+ "ADD": "Add"
16
+ }
17
+ },
18
+ "DETAILS": {
19
+ "TITLE": "<%- ModuleNameSentenceCase %> Details",
20
+ "TITLE_NEW": "New <%- ModuleNameSentenceCase %>",
21
+ "FIELDS": {
22
+ "NAME": "Name"
23
+ },
24
+ "TOOLBAR": {
25
+ "SAVE": "Save"
26
+ }
27
+ }
28
+ },
29
+ "ALERTS": {
30
+ "CLOSE_CONFIRMATION": "You have unsaved changes. Are you sure you want to close?"
31
+ }
32
+ }
33
+ }
@@ -10,7 +10,7 @@
10
10
  <!-- Add your form fields here -->
11
11
  <VcInput
12
12
  v-model="item.name"
13
- :label="'Name'"
13
+ :label="$t('<%- ModuleNameScreamingSnake %>.PAGES.DETAILS.FIELDS.NAME')"
14
14
  required
15
15
  />
16
16
  </VcForm>
@@ -32,29 +32,30 @@ import {
32
32
  } from "@vc-shell/framework";
33
33
  import { ref, computed, onMounted } from "vue";
34
34
  import use<%- ModuleNamePascalCase %>Details from "../composables/useDetails";
35
+ import { useI18n } from "vue-i18n";
35
36
 
36
- defineOptions({
37
+ defineBlade({
37
38
  url: "/<%- ModuleName %>-details",
38
39
  name: "<%- ModuleNamePascalCase %>Details",
39
40
  });
40
41
 
42
+ const { t } = useI18n({ useScope: "global" });
41
43
  const { param, closeSelf, callParent, onBeforeClose } = useBlade();
42
44
 
43
45
  const { showConfirmation } = usePopup();
44
46
 
45
- const { item, loading, getItem, saveItem } = use<%- ModuleNamePascalCase %>Details();
46
- const { isModified, resetModificationState } = useModificationTracker(item);
47
+ const { item, loading, getItem, saveItem, isModified, resetModificationState } = use<%- ModuleNamePascalCase %>Details();
47
48
 
48
49
  const title = computed(() => {
49
50
  return param.value
50
- ? String(item.value?.name || "<%- ModuleNameSentenceCase %> Details")
51
- : "New <%- ModuleNameSentenceCase %>";
51
+ ? String(item.value?.name || t("<%- ModuleNameScreamingSnake %>.PAGES.DETAILS.TITLE"))
52
+ : t("<%- ModuleNameScreamingSnake %>.PAGES.DETAILS.TITLE_NEW");
52
53
  });
53
54
 
54
55
  const bladeToolbar = ref<IBladeToolbar[]>([
55
56
  {
56
57
  id: "save",
57
- title: "Save",
58
+ title: t("<%- ModuleNameScreamingSnake %>.PAGES.DETAILS.TOOLBAR.SAVE"),
58
59
  icon: "lucide-save",
59
60
  disabled: computed(() => !isModified.value),
60
61
  async clickHandler() {
@@ -73,13 +74,10 @@ onMounted(async () => {
73
74
 
74
75
  onBeforeClose(async () => {
75
76
  if (isModified.value) {
76
- return await showConfirmation("You have unsaved changes. Are you sure you want to close?");
77
+ return !(await showConfirmation(t("<%- ModuleNameScreamingSnake %>.ALERTS.CLOSE_CONFIRMATION")));
77
78
  }
79
+ return false;
78
80
  });
79
81
 
80
82
  useBeforeUnload(computed(() => isModified.value));
81
-
82
- defineExpose({
83
- title,
84
- });
85
83
  </script>
@@ -16,8 +16,8 @@
16
16
  @pagination-click="(page: number) => { currentPage = page; getItems(); }"
17
17
  >
18
18
  <!-- Add your columns here -->
19
- <VcColumn id="name" :header="'Name'" sortable />
20
- <VcColumn id="createdDate" :header="'Created'" type="datetime" sortable />
19
+ <VcColumn id="name" :header="$t('<%- ModuleNameScreamingSnake %>.PAGES.LIST.COLUMNS.NAME')" sortable />
20
+ <VcColumn id="createdDate" :header="$t('<%- ModuleNameScreamingSnake %>.PAGES.LIST.COLUMNS.CREATED_DATE')" type="datetime" sortable />
21
21
  </VcDataTable>
22
22
  </VcBlade>
23
23
  </template>
@@ -30,11 +30,11 @@ import {
30
30
  useBlade,
31
31
  type IBladeToolbar,
32
32
  } from "@vc-shell/framework";
33
- import { ref, computed, markRaw } from "vue";
33
+ import { ref } from "vue";
34
34
  import use<%- ModuleNamePascalCase %>List from "../composables/useList";
35
- import Details from "./details.vue";
35
+ import { useI18n } from "vue-i18n";
36
36
 
37
- defineOptions({
37
+ defineBlade({
38
38
  url: "/<%- ModuleName %>",
39
39
  name: "<%- ModuleNamePascalCase %>List",
40
40
  isWorkspace: true,
@@ -45,7 +45,8 @@ defineOptions({
45
45
  },
46
46
  });
47
47
 
48
- const { openBlade } = useBlade();
48
+ const { t } = useI18n({ useScope: "global" });
49
+ const { openBlade, exposeToChildren } = useBlade();
49
50
 
50
51
  const {
51
52
  data,
@@ -59,13 +60,13 @@ const {
59
60
  const bladeToolbar = ref<IBladeToolbar[]>([
60
61
  {
61
62
  id: "refresh",
62
- title: "Refresh",
63
+ title: t("<%- ModuleNameScreamingSnake %>.PAGES.LIST.TOOLBAR.REFRESH"),
63
64
  icon: "lucide-refresh-cw",
64
65
  clickHandler: () => getItems(),
65
66
  },
66
67
  {
67
68
  id: "add",
68
- title: "Add",
69
+ title: t("<%- ModuleNameScreamingSnake %>.PAGES.LIST.TOOLBAR.ADD"),
69
70
  icon: "lucide-plus",
70
71
  clickHandler: () => openDetails(),
71
72
  },
@@ -73,7 +74,7 @@ const bladeToolbar = ref<IBladeToolbar[]>([
73
74
 
74
75
  function openDetails(item?: { id?: string }) {
75
76
  openBlade({
76
- blade: markRaw(Details),
77
+ name: "<%- ModuleNamePascalCase %>Details",
77
78
  param: item?.id,
78
79
  onClose() {
79
80
  getItems();
@@ -83,8 +84,5 @@ function openDetails(item?: { id?: string }) {
83
84
 
84
85
  getItems();
85
86
 
86
- defineExpose({
87
- title: computed(() => "<%- ModuleNameSentenceCase %>"),
88
- reload: getItems,
89
- });
87
+ exposeToChildren({ reload: getItems });
90
88
  </script>
@@ -1,8 +1,11 @@
1
- import * as pages from "./pages";
2
- import * as locales from "./locales";
3
- import { createAppModule } from "@vc-shell/framework";
4
-
5
- export default createAppModule(pages, locales);
6
-
7
- export * from "./pages";
8
- export * from "./composables";
1
+ import * as blades from "./pages";
2
+ import * as locales from "./locales";
3
+ import { defineAppModule } from "@vc-shell/framework";
4
+
5
+ export default defineAppModule({
6
+ blades,
7
+ locales,
8
+ });
9
+
10
+ export * from "./pages";
11
+ export * from "./composables";
@@ -132,9 +132,9 @@ import { Field, useForm } from "vee-validate";
132
132
  import { useI18n } from "vue-i18n";
133
133
  import * as _ from "lodash-es";
134
134
 
135
- defineOptions({
136
- url: "/sample-details",
135
+ defineBlade({
137
136
  name: "SampleDetails",
137
+ url: "/sample-details",
138
138
  });
139
139
 
140
140
  const { param, closeSelf, callParent, onBeforeClose } = useBlade();
@@ -197,11 +197,15 @@ onMounted(async () => {
197
197
 
198
198
  onBeforeClose(async () => {
199
199
  if (!isDisabled.value && isModified.value) {
200
- return await showConfirmation(t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION"));
200
+ return !(await showConfirmation(t("SAMPLE_APP.PAGES.ALERTS.CLOSE_CONFIRMATION")));
201
201
  }
202
+ return false;
202
203
  });
203
204
 
204
- useBeforeUnload(computed(() => !isDisabled.value && isModified.value));
205
205
 
206
206
 
207
+
208
+
209
+
210
+ useBeforeUnload(computed(() => !isDisabled.value && isModified.value));
207
211
  </script>