@vc-shell/create-vc-app 1.0.174 → 1.0.176

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 (53) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/index.js +102 -55
  3. package/dist/templates/base/package.json +5 -5
  4. package/dist/templates/base/src/modules/mocks.ts +50 -0
  5. package/dist/templates/base/vite.config.mts +1 -10
  6. package/dist/templates/modules/classic-module/composables/useDetails/index.ts +20 -0
  7. package/dist/templates/modules/classic-module/composables/useList/index.ts +25 -0
  8. package/dist/templates/{variants/dynamic/src/modules → modules}/dynamic-module/composables/useDetails/index.ts +3 -30
  9. package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/composables/useList/index.ts +2 -39
  10. package/dist/templates/variants/both/src/main.ts +2 -3
  11. package/dist/templates/variants/classic/src/main.ts +2 -3
  12. package/dist/templates/variants/dynamic/src/main.ts +2 -3
  13. package/package.json +2 -2
  14. package/dist/templates/variants/both/src/modules/classic-module/composables/useDetails/index.ts +0 -54
  15. package/dist/templates/variants/both/src/modules/classic-module/composables/useList/index.ts +0 -58
  16. package/dist/templates/variants/both/src/modules/dynamic-module/composables/useDetails/index.ts +0 -83
  17. package/dist/templates/variants/classic/src/modules/classic-module/components/index.ts +0 -1
  18. package/dist/templates/variants/classic/src/modules/classic-module/composables/index.ts +0 -2
  19. package/dist/templates/variants/classic/src/modules/classic-module/composables/useDetails/index.ts +0 -54
  20. package/dist/templates/variants/classic/src/modules/classic-module/composables/useList/index.ts +0 -58
  21. package/dist/templates/variants/classic/src/modules/classic-module/index.ts +0 -9
  22. package/dist/templates/variants/classic/src/modules/classic-module/locales/en.json +0 -46
  23. package/dist/templates/variants/classic/src/modules/classic-module/locales/index.ts +0 -2
  24. package/dist/templates/variants/classic/src/modules/classic-module/pages/details.vue +0 -86
  25. package/dist/templates/variants/classic/src/modules/classic-module/pages/index.ts +0 -2
  26. package/dist/templates/variants/classic/src/modules/classic-module/pages/list.vue +0 -270
  27. package/dist/templates/variants/dynamic/src/modules/dynamic-module/components/DynamicItemsMobileGridView.vue +0 -39
  28. package/dist/templates/variants/dynamic/src/modules/dynamic-module/components/index.ts +0 -3
  29. package/dist/templates/variants/dynamic/src/modules/dynamic-module/composables/index.ts +0 -2
  30. package/dist/templates/variants/dynamic/src/modules/dynamic-module/composables/useList/index.ts +0 -85
  31. package/dist/templates/variants/dynamic/src/modules/dynamic-module/index.ts +0 -9
  32. package/dist/templates/variants/dynamic/src/modules/dynamic-module/locales/en.json +0 -49
  33. package/dist/templates/variants/dynamic/src/modules/dynamic-module/locales/index.ts +0 -2
  34. package/dist/templates/variants/dynamic/src/modules/dynamic-module/pages/details.ts +0 -39
  35. package/dist/templates/variants/dynamic/src/modules/dynamic-module/pages/index.ts +0 -4
  36. package/dist/templates/variants/dynamic/src/modules/dynamic-module/pages/list.ts +0 -65
  37. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/components/index.ts +0 -0
  38. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/composables/index.ts +0 -0
  39. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/index.ts +0 -0
  40. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/locales/en.json +0 -0
  41. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/locales/index.ts +0 -0
  42. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/pages/details.vue +0 -0
  43. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/pages/index.ts +0 -0
  44. /package/dist/templates/{variants/both/src/modules → modules}/classic-module/pages/list.vue +0 -0
  45. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/components/DynamicItemsMobileGridView.vue +0 -0
  46. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/components/index.ts +0 -0
  47. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/composables/index.ts +0 -0
  48. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/index.ts +0 -0
  49. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/locales/en.json +0 -0
  50. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/locales/index.ts +0 -0
  51. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/pages/details.ts +0 -0
  52. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/pages/index.ts +0 -0
  53. /package/dist/templates/{variants/both/src/modules → modules}/dynamic-module/pages/list.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## [1.0.176](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.175...v1.0.176) (2024-03-07)
2
+
3
+
4
+
5
+ ## [1.0.175](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.174...v1.0.175) (2024-03-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * **create-vc-app:** remove redundant and dupe code, decouple mocks, remove demo mode from configs ([2b3fd6b](https://github.com/VirtoCommerce/vc-shell/commit/2b3fd6b945c21b5a3f4a177a7e6a183662eb480d))
11
+
12
+
13
+
1
14
  ## [1.0.174](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.173...v1.0.174) (2024-03-06)
2
15
 
3
16
 
package/dist/index.js CHANGED
@@ -1,12 +1,46 @@
1
1
  #!/usr/bin/env node
2
- import k from "prompts";
3
- import N from "mri";
2
+ import $ from "prompts";
3
+ import x from "mri";
4
4
  import o from "chalk";
5
- import i from "node:path";
6
- import r from "node:fs";
7
- import { fileURLToPath as $ } from "node:url";
8
- import { cwd as x, argv as C, exit as F } from "node:process";
9
- const P = {
5
+ import s from "node:path";
6
+ import i from "node:fs";
7
+ import { fileURLToPath as C } from "node:url";
8
+ import { cwd as N, argv as D, exit as P } from "node:process";
9
+ const F = "@vc-shell/create-vc-app", z = "Application scaffolding", E = "1.0.176", M = "module", R = "./dist/index.js", A = [
10
+ "dist"
11
+ ], O = {
12
+ build: "vite build && yarn postbuild",
13
+ postbuild: "shx cp -R src/templates dist/"
14
+ }, V = {
15
+ "@types/prompts": "^2.4.4",
16
+ "@vc-shell/ts-config": "^1.0.176",
17
+ copyfiles: "^2.4.1",
18
+ "cross-env": "^7.0.3",
19
+ shx: "^0.3.4",
20
+ typescript: "^5.3.3"
21
+ }, J = {
22
+ chalk: "^2.4.2",
23
+ mri: "^1.2.0",
24
+ prompts: "^2.4.2",
25
+ tslib: "^2.5.3",
26
+ vite: "^5.0.11",
27
+ "vite-plugin-dts": "^3.6.4"
28
+ }, L = {
29
+ access: "public",
30
+ registry: "https://registry.npmjs.org/"
31
+ }, T = "yarn@4.0.2", I = {
32
+ name: F,
33
+ description: z,
34
+ version: E,
35
+ type: M,
36
+ bin: R,
37
+ files: A,
38
+ scripts: O,
39
+ devDependencies: V,
40
+ dependencies: J,
41
+ publishConfig: L,
42
+ packageManager: T
43
+ }, k = {
10
44
  _gitignore: ".gitignore",
11
45
  "_yarnrc.yml": ".yarnrc.yml",
12
46
  _browserslistrc: ".browserslistrc",
@@ -17,35 +51,35 @@ const P = {
17
51
  _prettierignore: ".prettierignore",
18
52
  _prettierrc: ".prettierrc",
19
53
  "_eslintrc.js": ".eslintrc.js",
20
- _github: "github",
54
+ _github: ".github",
21
55
  _husky: ".husky",
22
56
  _vscode: ".vscode",
23
57
  _yarn: ".yarn"
24
58
  };
25
- function h(t) {
59
+ function _(t) {
26
60
  return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t);
27
61
  }
28
- function d(t) {
62
+ function f(t) {
29
63
  return t.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
30
64
  }
31
- function z(t) {
32
- r.existsSync(t);
65
+ function U(t) {
66
+ i.existsSync(t);
33
67
  }
34
- function D(t) {
35
- const a = r.readdirSync(t);
36
- return a.length === 0 || a.length === 1 && a[0] === ".git";
68
+ function Y(t) {
69
+ const r = i.readdirSync(t);
70
+ return r.length === 0 || r.length === 1 && r[0] === ".git";
37
71
  }
38
- function _(t, a) {
39
- r.statSync(t).isDirectory() ? E(t, a) : r.copyFileSync(t, a);
72
+ function u(t, r) {
73
+ i.statSync(t).isDirectory() ? q(t, r) : i.copyFileSync(t, r);
40
74
  }
41
- function E(t, a) {
42
- r.mkdirSync(a, { recursive: !0 });
43
- for (const n of r.readdirSync(t)) {
44
- const m = i.resolve(t, n), c = i.resolve(a, n);
45
- _(m, c);
75
+ function q(t, r) {
76
+ i.mkdirSync(r, { recursive: !0 });
77
+ for (const n of i.readdirSync(t)) {
78
+ const y = s.resolve(t, n), m = s.resolve(r, n);
79
+ u(y, m);
46
80
  }
47
81
  }
48
- const O = [
82
+ const B = [
49
83
  {
50
84
  name: "classic",
51
85
  display: "Classic modules boilerplate"
@@ -58,29 +92,36 @@ const O = [
58
92
  name: "both",
59
93
  display: "Classic modules + Dynamic modules boilerplate"
60
94
  }
61
- ], R = {
95
+ ], G = {
62
96
  both: "variants/both",
63
97
  classic: "variants/classic",
64
98
  dynamic: "variants/dynamic"
99
+ }, H = {
100
+ both: ["classic-module", "dynamic-module"],
101
+ classic: ["classic-module"],
102
+ dynamic: ["dynamic-module"]
65
103
  };
66
- async function V() {
67
- const t = x();
68
- let n = N(C.slice(2))._[0];
69
- const m = n || "vc-app", c = () => n === "." ? i.basename(i.resolve()) : n;
70
- let f;
104
+ async function K() {
105
+ console.log(` ${o.bold(o.green(`
106
+ create-vc-app version: ${I.version}
107
+ `))}`);
108
+ const t = N();
109
+ let n = x(D.slice(2))._[0];
110
+ const y = n || "vc-app", m = () => n === "." ? s.basename(s.resolve()) : n;
111
+ let v;
71
112
  try {
72
- f = await k(
113
+ v = await $(
73
114
  [
74
115
  {
75
116
  name: "appName",
76
117
  type: n ? null : "text",
77
118
  message: o.reset("Project name:"),
78
- initial: m,
79
- onState: (e) => n = d(String(e.value).trim()) || m,
80
- format: (e) => d(String(e).trim())
119
+ initial: y,
120
+ onState: (e) => n = f(String(e.value).trim()) || y,
121
+ format: (e) => f(String(e).trim())
81
122
  },
82
123
  {
83
- type: () => !r.existsSync(n) || D(n) ? null : "confirm",
124
+ type: () => !i.existsSync(n) || Y(n) ? null : "confirm",
84
125
  name: "overwrite",
85
126
  message: () => (n === "." ? "Current directory" : `Target directory "${n}"`) + " is not empty. Remove existing files and continue?"
86
127
  },
@@ -94,16 +135,16 @@ async function V() {
94
135
  },
95
136
  {
96
137
  name: "packageName",
97
- type: () => h(c()) ? null : "text",
138
+ type: () => _(m()) ? null : "text",
98
139
  message: o.reset("Package name:"),
99
- initial: () => d(c()),
100
- validate: (e) => h(e) || "Invalid package.json name"
140
+ initial: () => f(m()),
141
+ validate: (e) => _(e) || "Invalid package.json name"
101
142
  },
102
143
  {
103
144
  type: "select",
104
145
  name: "variant",
105
146
  message: o.reset("Select module variant:"),
106
- choices: O.map((e) => ({
147
+ choices: B.map((e) => ({
107
148
  title: e.display,
108
149
  value: e.name
109
150
  }))
@@ -116,32 +157,38 @@ async function V() {
116
157
  }
117
158
  );
118
159
  } catch (e) {
119
- console.log(e.message), F(1);
160
+ console.log(e.message), P(1);
120
161
  }
121
- const { packageName: b, variant: j } = f, s = i.join(t, n);
122
- r.existsSync(s) ? z(s) : r.existsSync(s) || r.mkdirSync(s), console.log(`
123
- Scaffolding app in ${s}...`);
124
- const y = i.resolve($(import.meta.url), "..", "templates"), u = (e, l, p) => {
125
- const g = i.join(s, P[e] ?? e);
126
- p ? r.writeFileSync(g, p) : _(i.join(y, l, e), g);
127
- }, v = (e) => {
128
- const l = i.resolve(y, e), p = r.readdirSync(l);
129
- for (const g of p.filter((w) => w !== "package.json"))
130
- u(g, e);
162
+ const { packageName: w, variant: h } = v, c = s.join(t, n);
163
+ i.existsSync(c) ? U(c) : i.existsSync(c) || i.mkdirSync(c), console.log(`
164
+ Scaffolding app in ${c}...`);
165
+ const d = s.resolve(C(import.meta.url), "..", "templates"), b = (e, l, p) => {
166
+ const a = s.join(c, k[e] ?? e);
167
+ p ? i.writeFileSync(a, p) : u(s.join(d, l, e), a);
168
+ }, S = (e) => {
169
+ const l = s.resolve(d, e), p = i.readdirSync(l);
170
+ for (const a of p.filter((g) => g !== "package.json"))
171
+ b(a, e);
131
172
  };
132
- v("base"), v(R[j]);
133
- const S = JSON.parse(r.readFileSync(i.join(y, "./base/package.json"), "utf-8"));
134
- if (S.name = b || c(), u("package.json", "", JSON.stringify(S, null, 2) + `
173
+ S("base"), S(G[h]), H[h].forEach((e) => {
174
+ const l = s.resolve(d, `modules/${e}`), p = i.readdirSync(l);
175
+ for (const a of p.filter((g) => g !== "package.json")) {
176
+ const g = s.join(c, "src", "modules", e, k[a] ?? a);
177
+ u(s.join(d, `modules/${e}`, a), g);
178
+ }
179
+ });
180
+ const j = JSON.parse(i.readFileSync(s.join(d, "./base/package.json"), "utf-8"));
181
+ if (j.name = w || m(), b("package.json", "", JSON.stringify(j, null, 2) + `
135
182
  `), console.log(`
136
183
  Done. You can now run application:
137
- `), s !== t) {
138
- const e = i.relative(t, s);
184
+ `), c !== t) {
185
+ const e = s.relative(t, c);
139
186
  console.log(
140
187
  ` ${o.bold(o.green(`cd ${e.includes(" ") ? `"${e}"` : e}`))}`
141
188
  );
142
189
  }
143
190
  console.log(` ${o.bold(o.green("yarn"))}`), console.log(` ${o.bold(o.green("yarn serve"))}`);
144
191
  }
145
- V().catch((t) => {
192
+ K().catch((t) => {
146
193
  console.error(t);
147
194
  });
@@ -24,9 +24,9 @@
24
24
  "@types/node": "^20.10.5",
25
25
  "@typescript-eslint/eslint-plugin": "^6.16.0",
26
26
  "@typescript-eslint/parser": "^6.16.0",
27
- "@vc-shell/api-client-generator": "^1.0.174",
28
- "@vc-shell/release-config": "^1.0.174",
29
- "@vc-shell/ts-config": "^1.0.174",
27
+ "@vc-shell/api-client-generator": "^1.0.176",
28
+ "@vc-shell/release-config": "^1.0.176",
29
+ "@vc-shell/ts-config": "^1.0.176",
30
30
  "@vitejs/plugin-vue": "^5.0.3",
31
31
  "@vue/eslint-config-prettier": "^9.0.0",
32
32
  "@vue/eslint-config-typescript": "^12.0.0",
@@ -56,8 +56,8 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@fortawesome/fontawesome-free": "^5.15.3",
59
- "@vc-shell/config-generator": "^1.0.174",
60
- "@vc-shell/framework": "^1.0.174",
59
+ "@vc-shell/config-generator": "^1.0.176",
60
+ "@vc-shell/framework": "^1.0.176",
61
61
  "@vueuse/core": "^10.7.1",
62
62
  "@vueuse/integrations": "^10.7.1",
63
63
  "moment": "^2.30.1",
@@ -0,0 +1,50 @@
1
+ /* eslint-disable import/no-unresolved */
2
+ import img1 from "/assets/1.jpeg";
3
+ import img2 from "/assets/2.jpg";
4
+ import img3 from "/assets/3.jpg";
5
+
6
+ export interface MockedItem {
7
+ imgSrc: string;
8
+ name: string;
9
+ createdDate: Date;
10
+ id: string;
11
+ }
12
+
13
+ const mockedItems: MockedItem[] = [
14
+ {
15
+ imgSrc: img1,
16
+ name: "Item 1",
17
+ createdDate: new Date(),
18
+ id: "item-id-1",
19
+ },
20
+ {
21
+ imgSrc: img2,
22
+ name: "Item 2",
23
+ createdDate: new Date(),
24
+ id: "item-id-2",
25
+ },
26
+ {
27
+ imgSrc: img3,
28
+ name: "Item 3",
29
+ createdDate: new Date(),
30
+ id: "item-id-3",
31
+ },
32
+ ];
33
+
34
+ export function loadMockItemsList() {
35
+ return new Promise((resolve: (value: MockedItem[]) => void) => {
36
+ setTimeout(() => resolve(mockedItems), 1000);
37
+ }).then((res) => {
38
+ return { results: res, totalCount: res.length };
39
+ });
40
+ }
41
+
42
+ export function loadMockItem(args?: { id: string }) {
43
+ return new Promise((resolve: (value: MockedItem) => void) => {
44
+ setTimeout(() => {
45
+ const findMockedItem = mockedItems.find((x) => x.id === args?.id);
46
+
47
+ if (findMockedItem) resolve(findMockedItem);
48
+ }, 1000);
49
+ });
50
+ }
@@ -1,16 +1,7 @@
1
1
  import { getApplicationConfiguration } from "@vc-shell/config-generator";
2
2
  import { VitePWA } from "vite-plugin-pwa";
3
3
 
4
- // Remove it after you added APP_PLATFORM_URL to .env file. Demo mode works only with yarn serve
5
- const isDemo = !process.env.APP_PLATFORM_URL;
6
-
7
- const mode = process.env.APP_ENV as string;
8
-
9
4
  export default getApplicationConfiguration({
10
- define: {
11
- // Set demo mode
12
- __DEMO_MODE__: isDemo,
13
- },
14
5
  plugins: [
15
6
  VitePWA({
16
7
  includeAssets: ["favicon.ico", "apple-touch-icon.png"],
@@ -19,7 +10,7 @@ export default getApplicationConfiguration({
19
10
  short_name: "App",
20
11
  theme_color: "#319ED4",
21
12
  display: "fullscreen",
22
- start_url: "/",
13
+ start_url: "/apps/application",
23
14
  icons: [
24
15
  {
25
16
  src: "./img/icons/pwa-192x192.png",
@@ -0,0 +1,20 @@
1
+ import { Ref, computed, ref } from "vue";
2
+ import { useAsync, useLoading } from "@vc-shell/framework";
3
+ import { MockedItem, loadMockItem } from "../../../mocks";
4
+
5
+ export default () => {
6
+ const item = ref({}) as Ref<MockedItem>;
7
+
8
+ // Example mocked method for 'fetching' list data
9
+ const { loading: itemLoading, action: getItem } = useAsync<{ id: string }>(async (payload) => {
10
+ item.value = await loadMockItem(payload);
11
+ });
12
+
13
+ const loading = useLoading(itemLoading);
14
+
15
+ return {
16
+ item: computed(() => item.value),
17
+ loading: computed(() => loading.value),
18
+ getItem,
19
+ };
20
+ };
@@ -0,0 +1,25 @@
1
+ import { Ref, computed, ref } from "vue";
2
+ import { useAsync, useLoading } from "@vc-shell/framework";
3
+ import { type MockedItem, loadMockItemsList } from "../../../mocks";
4
+
5
+ export default () => {
6
+ const data = ref([]) as Ref<MockedItem[]>;
7
+ const dataRes = ref();
8
+
9
+ // Example mocked method for 'fetching' list data
10
+ const { loading: itemLoading, action: getItems } = useAsync(async (payload) => {
11
+ dataRes.value = await loadMockItemsList();
12
+ data.value = dataRes.value.results;
13
+ });
14
+
15
+ const loading = useLoading(itemLoading);
16
+
17
+ return {
18
+ data: computed(() => data.value),
19
+ loading: computed(() => loading.value),
20
+ totalCount: computed(() => dataRes.value?.totalCount),
21
+ pages: computed(() => Math.ceil(dataRes.value?.totalCount / 20)),
22
+ currentPage: 0 / Math.max(1, 20) + 1,
23
+ getItems,
24
+ };
25
+ };
@@ -1,9 +1,6 @@
1
- /* eslint-disable import/no-unresolved */
2
1
  import { computed, ref, Ref } from "vue";
3
- import img1 from "/assets/1.jpeg";
4
- import img2 from "/assets/2.jpg";
5
- import img3 from "/assets/3.jpg";
6
2
  import { DetailsBaseBladeScope, DynamicBladeForm, IBladeToolbar, useDetailsFactory } from "@vc-shell/framework";
3
+ import { loadMockItem, type MockedItem } from "../../../mocks";
7
4
 
8
5
  export interface DynamicItemScope extends DetailsBaseBladeScope {
9
6
  toolbarOverrides: {
@@ -16,33 +13,9 @@ export default (args: {
16
13
  emit: InstanceType<typeof DynamicBladeForm>["$emit"];
17
14
  mounted: Ref<boolean>;
18
15
  }) => {
19
- const factory = useDetailsFactory<{ imgSrc: string; name: string; createdDate: Date; id: string }>({
16
+ const factory = useDetailsFactory<MockedItem>({
20
17
  load: async (payload) => {
21
- return await new Promise((resolve) => {
22
- setTimeout(() => {
23
- const findMockedItem = [
24
- {
25
- imgSrc: img1,
26
- name: "Item 1",
27
- createdDate: new Date(),
28
- id: "item-id-1",
29
- },
30
- {
31
- imgSrc: img2,
32
- name: "Item 2",
33
- createdDate: new Date(),
34
- id: "item-id-2",
35
- },
36
- {
37
- imgSrc: img3,
38
- name: "Item 3",
39
- createdDate: new Date(),
40
- id: "item-id-3",
41
- },
42
- ].find((x) => x.id === payload?.id);
43
- resolve(findMockedItem);
44
- }, 1000);
45
- });
18
+ return await loadMockItem(payload);
46
19
  },
47
20
  saveChanges: () => {
48
21
  throw new Error("Function not implemented.");
@@ -1,16 +1,6 @@
1
- /* eslint-disable import/no-unresolved */
2
1
  import { computed, ref, Ref } from "vue";
3
- import img1 from "/assets/1.jpeg";
4
- import img2 from "/assets/2.jpg";
5
- import img3 from "/assets/3.jpg";
6
2
  import { DynamicBladeList, ListBaseBladeScope, useBladeNavigation, useListFactory } from "@vc-shell/framework";
7
-
8
- interface MockedItem {
9
- imgSrc: string;
10
- name: string;
11
- createdDate: Date;
12
- id: string;
13
- }
3
+ import { loadMockItemsList } from "../../../mocks";
14
4
 
15
5
  // eslint-disable-next-line @typescript-eslint/no-empty-interface
16
6
  export interface DynamicItemsScope extends ListBaseBladeScope {}
@@ -22,34 +12,7 @@ export default (args: {
22
12
  }) => {
23
13
  const factory = useListFactory({
24
14
  load: async () => {
25
- return await new Promise((resolve: (value: MockedItem[]) => void) => {
26
- setTimeout(
27
- () =>
28
- resolve([
29
- {
30
- imgSrc: img1,
31
- name: "Item 1",
32
- createdDate: new Date(),
33
- id: "item-id-1",
34
- },
35
- {
36
- imgSrc: img2,
37
- name: "Item 2",
38
- createdDate: new Date(),
39
- id: "item-id-2",
40
- },
41
- {
42
- imgSrc: img3,
43
- name: "Item 3",
44
- createdDate: new Date(),
45
- id: "item-id-3",
46
- },
47
- ]),
48
- 1000,
49
- );
50
- }).then((res) => {
51
- return { results: res, totalCount: res.length };
52
- });
15
+ return await loadMockItemsList();
53
16
  },
54
17
  remove: () => {
55
18
  throw new Error("Function not implemented.");
@@ -14,9 +14,8 @@ import "roboto-fontface/css/roboto/roboto-fontface.css";
14
14
  import "@vc-shell/framework/dist/index.css";
15
15
 
16
16
  async function startApp() {
17
- /** !!! uncomment these lines when adding APP_PLATFORM_URL in .env */
18
- // const { loadUser } = useUser();
19
- // await loadUser();
17
+ const { loadUser } = useUser();
18
+ await loadUser();
20
19
 
21
20
  const { currentLocale, setLocale } = useLanguages();
22
21
 
@@ -13,9 +13,8 @@ import "roboto-fontface/css/roboto/roboto-fontface.css";
13
13
  import "@vc-shell/framework/dist/index.css";
14
14
 
15
15
  async function startApp() {
16
- /** !!! uncomment these lines when adding APP_PLATFORM_URL in .env */
17
- // const { loadUser } = useUser();
18
- // await loadUser();
16
+ const { loadUser } = useUser();
17
+ await loadUser();
19
18
 
20
19
  const { currentLocale, setLocale } = useLanguages();
21
20
 
@@ -13,9 +13,8 @@ import "roboto-fontface/css/roboto/roboto-fontface.css";
13
13
  import "@vc-shell/framework/dist/index.css";
14
14
 
15
15
  async function startApp() {
16
- /** !!! uncomment these lines when adding APP_PLATFORM_URL in .env */
17
- // const { loadUser } = useUser();
18
- // await loadUser();
16
+ const { loadUser } = useUser();
17
+ await loadUser();
19
18
 
20
19
  const { currentLocale, setLocale } = useLanguages();
21
20
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vc-shell/create-vc-app",
3
3
  "description": "Application scaffolding",
4
- "version": "1.0.174",
4
+ "version": "1.0.176",
5
5
  "type": "module",
6
6
  "bin": "./dist/index.js",
7
7
  "files": [
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/prompts": "^2.4.4",
16
- "@vc-shell/ts-config": "^1.0.174",
16
+ "@vc-shell/ts-config": "^1.0.176",
17
17
  "copyfiles": "^2.4.1",
18
18
  "cross-env": "^7.0.3",
19
19
  "shx": "^0.3.4",
@@ -1,54 +0,0 @@
1
- /* eslint-disable import/no-unresolved */
2
- import { Ref, computed, ref } from "vue";
3
- import img1 from "/assets/1.jpeg";
4
- import img2 from "/assets/2.jpg";
5
- import img3 from "/assets/3.jpg";
6
- import { useAsync, useLoading } from "@vc-shell/framework";
7
-
8
- export default () => {
9
- const item = ref({}) as Ref<{
10
- imgSrc: string;
11
- name: string;
12
- createdDate: Date;
13
- id: string;
14
- }>;
15
-
16
- // Example mocked method for 'fetching' list data
17
- const { loading: itemLoading, action: getItem } = useAsync<{ id: string }>(async (payload) => {
18
- item.value = await new Promise((resolve) => {
19
- setTimeout(() => {
20
- const findMockedItem = [
21
- {
22
- imgSrc: img1,
23
- name: "Item 1",
24
- createdDate: new Date(),
25
- id: "item-id-1",
26
- },
27
- {
28
- imgSrc: img2,
29
- name: "Item 2",
30
- createdDate: new Date(),
31
- id: "item-id-2",
32
- },
33
- {
34
- imgSrc: img3,
35
- name: "Item 3",
36
- createdDate: new Date(),
37
- id: "item-id-3",
38
- },
39
- ].find((x) => x.id === payload?.id);
40
- if (findMockedItem) {
41
- resolve(findMockedItem);
42
- }
43
- }, 1000);
44
- });
45
- });
46
-
47
- const loading = useLoading(itemLoading);
48
-
49
- return {
50
- item: computed(() => item.value),
51
- loading: computed(() => loading.value),
52
- getItem,
53
- };
54
- };
@@ -1,58 +0,0 @@
1
- /* eslint-disable import/no-unresolved */
2
- import { Ref, computed, ref } from "vue";
3
- import img1 from "/assets/1.jpeg";
4
- import img2 from "/assets/2.jpg";
5
- import img3 from "/assets/3.jpg";
6
- import { useAsync, useLoading } from "@vc-shell/framework";
7
-
8
- export default () => {
9
- const data = ref([]) as Ref<
10
- {
11
- imgSrc: string;
12
- name: string;
13
- createdDate: Date;
14
- id: string;
15
- }[]
16
- >;
17
-
18
- // Example mocked method for 'fetching' list data
19
- const { loading: itemLoading, action: getItems } = useAsync(async (payload) => {
20
- data.value = await new Promise((resolve) => {
21
- setTimeout(
22
- () =>
23
- resolve([
24
- {
25
- imgSrc: img1,
26
- name: "Item 1",
27
- createdDate: new Date(),
28
- id: "item-id-1",
29
- },
30
- {
31
- imgSrc: img2,
32
- name: "Item 2",
33
- createdDate: new Date(),
34
- id: "item-id-2",
35
- },
36
- {
37
- imgSrc: img3,
38
- name: "Item 3",
39
- createdDate: new Date(),
40
- id: "item-id-3",
41
- },
42
- ]),
43
- 1000,
44
- );
45
- });
46
- });
47
-
48
- const loading = useLoading(itemLoading);
49
-
50
- return {
51
- data: computed(() => data.value),
52
- loading: computed(() => loading.value),
53
- totalCount: computed(() => data.value.length),
54
- pages: computed(() => Math.ceil(data.value.length / 20)),
55
- currentPage: 0 / Math.max(1, 20) + 1,
56
- getItems,
57
- };
58
- };