Skip to content

Commit 72b245b

Browse files
authored
chore: node.js 18, storybook 7 and other dev dependencies upgrade (#665)
* fix: support 1.x if >2.x global installed * fix: fixate node version * chore: upgrade most dev dependencies * chore: upgrade yarn * chore: migrate yarn.lock * chore: upgrade storybook * fix: remove unneccessary script * chore: update yarn.lock * chore: upgrade tsconfig * fix: revert parameters * fix: graphql generation * fix: storybook build * fix: uncomment required code * fix: try to fix workflow * fix: locale in storybook * fix: line endingins * fix: import resolver ts config path for eslint * fix: revert back ci * fix: remove comment * fix: run yarn * fix: storybook preview setup * fix: attempt to fix CI * fix: ci * refactor: register ui kit from single place * fix: remove end of line from editorconfig * fix: remove irrelevant code * docs: add comments to codegen script * chore: revert back postcss * fix: move postcss to dev dependencies * fix: linting backward compatibility * fix: backward compatible module resolution * fix: workflow * fix: remove temporary rule * fix: review issues * fix: file names * chore: update readme
1 parent a8a0b18 commit 72b245b

28 files changed

+19103
-16801
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ root = true
33

44
[*]
55
charset = utf-8
6-
end_of_line = lf
76
indent_style = space
87
indent_size = 2
98
insert_final_newline = true

.eslintrc.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require('@rushstack/eslint-patch/modern-module-resolution')
2+
13
module.exports = {
24
root: true,
35
env: {
@@ -119,6 +121,7 @@ module.exports = {
119121
"vue/no-multiple-objects-in-class": "warn",
120122
"vue/no-required-prop-with-default": "warn",
121123
"vue/no-static-inline-styles": "warn",
124+
"vue/no-setup-props-destructure": "warn", // TODO: Remove (switch to error) after refactoring
122125
"vue/no-useless-v-bind": "warn",
123126
"vue/padding-line-between-blocks": "warn",
124127
// TODO: enable "vue/padding-line-between-tags": "warn",
@@ -160,11 +163,12 @@ module.exports = {
160163
},
161164
settings: {
162165
"import/parsers": {
163-
"@typescript-eslint/parser": [".ts", ".tsx"],
166+
"@typescript-eslint/parser": [".ts"],
164167
},
165168
"import/resolver": {
166169
typescript: {
167170
alwaysTryTypes: true,
171+
project: "./tsconfig.app.json",
168172
},
169173
node: true,
170174
},

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.github/workflows/main.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ jobs:
5151
with:
5252
fetch-depth: 0
5353

54-
- name: Install Node.js 16
55-
uses: actions/setup-node@v1
54+
- name: Install Node.js 18
55+
uses: actions/setup-node@v3
5656
with:
57-
node-version: '16.x'
57+
node-version: '18'
5858

5959
- name: Get Image Version
6060
uses: VirtoCommerce/vc-github-actions/get-image-version@master
@@ -83,6 +83,8 @@ jobs:
8383
uses: VirtoCommerce/vc-github-actions/build-vue-theme@master
8484
with:
8585
versionSuffix: ${{ env.VERSION_SUFFIX }}
86+
env:
87+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
8688

8789
- name: Publish
8890
if: ${{ github.ref == 'refs/heads/demo' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/master')}}

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ config/routes.json
5555

5656
dist-ssr
5757
*.local
58+
59+
# yarn
60+
.pnp.*
61+
.yarn/*
62+
!.yarn/patches
63+
!.yarn/plugins
64+
!.yarn/releases
65+
!.yarn/sdks
66+
!.yarn/versions

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
engine-strict=true
12
package-lock=false

.prettierrc

-3
This file was deleted.

.prettierrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"endOfLine": "auto"
4+
}

.storybook/main.ts

+24-27
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,54 @@
11
import { resolve } from "path";
2-
import graphql from "@rollup/plugin-graphql";
32
import { loadConfigFromFile, mergeConfig, splitVendorChunkPlugin } from "vite";
4-
import type { StorybookViteConfig } from "@storybook/builder-vite";
5-
import type { PropItem } from "react-docgen-typescript";
3+
import type { StorybookConfig } from "@storybook/vue3-vite";
64

7-
const storybookConfig: StorybookViteConfig = {
8-
stories: ["../client-app/**/*.stories.@(ts|tsx|mdx)"],
5+
const storybookConfig: StorybookConfig = {
6+
stories: ["../client-app/**/*.stories.ts"],
97
staticDirs: ["../client-app/public"],
108
addons: [
119
"@storybook/addon-links",
1210
"@storybook/addon-essentials",
1311
"@storybook/addon-a11y",
1412
"@storybook/addon-interactions",
1513
],
14+
framework: {
15+
name: "@storybook/vue3-vite",
16+
options: {},
17+
},
1618
typescript: {
1719
check: false,
18-
checkOptions: {},
19-
reactDocgen: "react-docgen-typescript",
20-
reactDocgenTypescriptOptions: {
21-
shouldExtractLiteralValuesFromEnum: true,
22-
propFilter: (prop: PropItem) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
23-
},
2420
},
25-
framework: "@storybook/vue3",
2621
core: {
27-
builder: "@storybook/builder-vite",
2822
disableTelemetry: true,
2923
},
30-
features: {
31-
// storyStoreV7: true, // NOTE: When enabled, `viewMode: "docs"` does not work.
32-
},
3324
async viteFinal(storybookViteConfig, options) {
3425
const isDevelopment = options.configType === "DEVELOPMENT";
3526
const { config } = (await loadConfigFromFile(
36-
isDevelopment ? { command: "serve", mode: "development" } : { command: "build", mode: "production" },
37-
resolve(__dirname, "../vite.config.ts")
27+
isDevelopment
28+
? {
29+
command: "serve",
30+
mode: "development",
31+
}
32+
: {
33+
command: "build",
34+
mode: "production",
35+
},
36+
resolve(__dirname, "../vite.config.ts"),
3837
))!;
39-
4038
return mergeConfig(storybookViteConfig, {
41-
plugins: [graphql(), splitVendorChunkPlugin()],
39+
envPrefix: config.envPrefix,
40+
plugins: [splitVendorChunkPlugin()],
41+
resolve: config.resolve,
42+
define: config.define,
4243
build: {
4344
cssCodeSplit: false,
4445
reportCompressedSize: false,
45-
rollupOptions: {
46-
external: [/\/static\/.*/],
47-
},
4846
},
49-
envPrefix: config.envPrefix,
50-
resolve: config.resolve,
51-
define: config.define,
5247
optimizeDeps: config.optimizeDeps,
5348
});
5449
},
50+
docs: {
51+
autodocs: true,
52+
},
5553
};
56-
5754
export default storybookConfig;

.storybook/preview.ts

+47-47
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { app } from "@storybook/vue3";
3-
import vueRouter from "storybook-vue3-router";
4-
import { createI18n } from "vue-i18n";
1+
import { setup } from "@storybook/vue3";
2+
import { vueRouter } from "storybook-vue3-router";
3+
import { useLanguages } from "../client-app/core/composables";
54
import { setGlobals } from "../client-app/core/globals";
6-
import * as UIKitComponents from "../client-app/ui-kit/components";
7-
import SettingsData from "../config/settings_data.json";
8-
import en from "../locales/en.json";
5+
import { configPlugin } from "../client-app/core/plugins";
6+
import { createI18n } from "../client-app/i18n";
7+
import { uiKit } from "../client-app/ui-kit";
8+
import type { IThemeConfig } from "../client-app/core/types";
99
import type { I18n } from "../client-app/i18n";
10-
11-
/* Project Styles */
10+
import type { Preview } from "@storybook/vue3";
11+
import type { App } from "vue";
1212
import "../client-app/assets/styles/main.scss";
1313

14-
const i18n: I18n = createI18n({
15-
legacy: false,
16-
locale: "en",
17-
messages: {
18-
en,
19-
},
20-
});
14+
const i18n: I18n = createI18n("en", "USD");
2115

2216
setGlobals({ i18n });
2317

24-
app.use(i18n);
25-
26-
/* Setting project CSS variables */
27-
const settings =
28-
typeof SettingsData.current === "string"
29-
? (<Record<string, any>>SettingsData).presets[SettingsData.current]
30-
: SettingsData.current;
31-
32-
Object.entries(settings)
33-
.filter(([key]) => /^color/.test(key))
34-
.forEach(([key, value]) => {
35-
document.documentElement.style.setProperty(`--${key.replace(/_/g, "-")}`, `${value}`);
36-
});
37-
38-
// Register UI Kit components
39-
Object.entries(UIKitComponents).forEach(([name, component]) => app.component(name, component));
40-
41-
export const parameters = {
42-
actions: { argTypesRegex: "^on[A-Z].*" },
43-
controls: {
44-
matchers: {
45-
color: /(background|color)$/i,
46-
date: /Date$/,
18+
async function configureThemeSettings(app: App) {
19+
const settings: IThemeConfig = await import("../config/settings_data.json");
20+
const themeSettings = settings.presets[settings.current as string];
21+
22+
app.use(configPlugin, themeSettings);
23+
}
24+
25+
async function configureI18N() {
26+
const { setLocale } = useLanguages();
27+
28+
await setLocale(i18n, "en");
29+
}
30+
31+
setup((app) => {
32+
configureThemeSettings(app);
33+
34+
configureI18N();
35+
app.use(i18n);
36+
37+
app.use(uiKit);
38+
});
39+
40+
const preview: Preview = {
41+
decorators: [vueRouter()],
42+
parameters: {
43+
actions: { argTypesRegex: "^on[A-Z].*" },
44+
controls: {
45+
matchers: {
46+
color: /(background|color)$/i,
47+
date: /Date$/,
48+
},
49+
expanded: true,
4750
},
48-
expanded: true,
49-
},
50-
options: {
51-
storySort: {
52-
order: ["*", "Components", ["Atoms", "Molecules", "Organisms", "Templates", "Pages"]],
51+
options: {
52+
storySort: {
53+
order: ["*", "Components", ["Atoms", "Molecules", "Organisms", "Templates", "Pages"]],
54+
},
5355
},
5456
},
55-
previewTabs: { "storybook/docs/panel": { index: -1 } },
56-
viewMode: "docs",
5757
};
5858

59-
export const decorators = [vueRouter()];
59+
export default preview;

.yarn/releases/yarn-3.6.1.cjs

+874
Large diffs are not rendered by default.

.yarnrc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-3.6.1.cjs

README.md

+29-20
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,35 @@ This theme is designed to be used as-is within actual **VC Storefront**. You can
112112
├── templates // Liquid templates, used in SSR and MPA. Each MPA page needs to have a liquid template here if you want SSR.
113113
| └──index.liquid // Entry point for SPA, providing container with necessary scripts and styles.
114114
|
115-
├── .browserslistrc // Browserslist config file to support actual versions of browsers.
116-
├── .commitlintrc.json // Config for Conventional commit hook.
117-
├── .editorconfig // Common editor settings to sync codestyle.
118-
├── .env // Envfile to define different Environment Variables.
119-
├── .eslintignore // Ignore some files from ESlint.
120-
├── .eslintrc // ESlint configuration file.
121-
├── .gitignore // Ignore some files from GIT.
122-
├── .graphqlconfig // Config file for JS GraphQL IntelliJ Plugin (https://plugins.jetbrains.com/plugin/8097-graphql).
123-
├── .prettierignore // Ignore some files from Prettier.
124-
├── .prettierrc // Config for Prettier.
125-
├── codegen.schema.ts // GraphQL configuration file to generate schema from your Virto Backoffice url.
126-
├── codegen.types.ts // GraphQL configuration file to generate types from your Virto Backoffice url.
127-
├── gulpfile.js // Artifact build script to product zip-file installable by VC Storefront.
128-
├── index.html // Vite Development entry point.
129-
├── package.json // NPM Package description.
130-
├── postcss.config.js // PostCSS configuration for Tailwind.
131-
├── README.md // This file.
132-
├── tailwind.config.js // TailwindCSS configuration file.
133-
├── tsconfig.json // TypeScript configuration file.
134-
└── vite.config.ts // Vite configuration file.
115+
├── .babelrc // Babel configuration for storybook
116+
├── .browserslistrc // Browserslist config file to support actual versions of browsers.
117+
├── .commitlintrc.json // Config for Conventional commit hook.
118+
├── .editorconfig // Common editor settings to sync codestyle.
119+
├── .env // Envfile to define different Environment Variables.
120+
├── .env.local // Local envfile to override Environment Variables.
121+
├── .eslintignore // Ignore some files from ESlint.
122+
├── .eslintrc.js // ESlint configuration file.
123+
├── .gitattributes // Set attributes to specified path in Git.
124+
├── .gitignore // Ignore some files from Git.
125+
├── .graphqlconfig // Config file for JS GraphQL IntelliJ Plugin (https://plugins.jetbrains.com/plugin/8097-graphql).
126+
├── .npmrc // Node.js package manager settings and Node.js restrictions
127+
├── .prettierignore // Ignore some files from Prettier.
128+
├── .prettierrc // Config for Prettier.
129+
├── .yarnrc // Yarn package manager configuration
130+
├── builder-preview.html // Page Builder entry point
131+
├── graphql-codegen.schema.config.ts // GraphQL configuration file to generate schema from your VirtoCommerce Storefront url.
132+
├── graphql-codegen.types.types.ts // GraphQL configuration file to generate types from your VirtoCommerce Storefront url.
133+
├── gulpfile.js // Artifact build script to product zip-file installable by VirtoCommerce Storefront.
134+
├── index.html // Vite Development entry point.
135+
├── package.json // NPM Package description.
136+
├── postcss.config.js // PostCSS configuration for Tailwind.
137+
├── README.md // This file.
138+
├── tailwind.config.js // TailwindCSS configuration file.
139+
├── tsconfig.app.json // Typescript configuration for application.
140+
├── tsconfig.json // Main TypeScript configuration file.
141+
├── tsconfig.node.json // Typescript configuration for Node.js.
142+
├── vite.config.ts // Vite configuration file.
143+
└── yarn.lock // Yarn dependencies lock file.
135144
```
136145

137146
## Getting started

client-app/app-runner.ts

+5-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import { vOnClickOutside } from "@vueuse/components";
21
import { createHead } from "@vueuse/head";
3-
import { maska } from "maska";
42
import { createApp } from "vue";
5-
import { setLocale as setLocaleForYup } from "yup";
63
import { useCurrency, useLanguages, useThemeContext } from "@/core/composables";
74
import { setGlobals } from "@/core/globals";
85
import { configPlugin, contextPlugin, permissionsPlugin } from "@/core/plugins";
@@ -12,11 +9,12 @@ import { createRouter } from "@/router";
129
import { useUser } from "@/shared/account";
1310
import ProductBlocks from "@/shared/catalog/components/product";
1411
import { templateBlocks } from "@/shared/static-content";
15-
import * as UIKitComponents from "@/ui-kit/components";
12+
import { uiKit } from "@/ui-kit";
1613
import App from "./App.vue";
1714
import type { Plugin } from "vue";
15+
import type { Router } from "vue-router";
1816

19-
export default async (getPlugins: (options: any) => { plugin: Plugin; options: any }[] = () => []) => {
17+
export default async (getPlugins: (options: { router: Router }) => { plugin: Plugin; options: any }[] = () => []) => {
2018
const appSelector = "#app";
2119
const appElement = document.querySelector<HTMLElement | SVGElement>(appSelector);
2220

@@ -59,16 +57,6 @@ export default async (getPlugins: (options: any) => { plugin: Plugin; options: a
5957
*/
6058
await setLocale(i18n, currentLocale.value);
6159

62-
setLocaleForYup({
63-
mixed: {
64-
required: i18n.global.t("common.messages.required_field"),
65-
},
66-
string: {
67-
email: i18n.global.t("common.messages.email_is_not_correct"),
68-
max: ({ max }) => i18n.global.t("common.messages.max_length", { max }),
69-
},
70-
});
71-
7260
/**
7361
* Create and mount application
7462
*/
@@ -86,17 +74,9 @@ export default async (getPlugins: (options: any) => { plugin: Plugin; options: a
8674
app.use(permissionsPlugin);
8775
app.use(contextPlugin, themeContext.value);
8876
app.use(configPlugin, themeContext.value!.settings);
77+
app.use(uiKit);
8978

90-
const plugins = getPlugins({ router });
91-
plugins.forEach(({ plugin, options }) => app.use(plugin, options));
92-
93-
// Directives
94-
app.directive("mask", maska);
95-
app.directive("onClickOutside", vOnClickOutside);
96-
97-
// Components
98-
// Register UI Kit components globally
99-
Object.entries(UIKitComponents).forEach(([name, component]) => app.component(name, component));
79+
getPlugins({ router }).forEach(({ plugin, options }) => app.use(plugin, options));
10080

10181
// Register Page builder components globally
10282
Object.entries(templateBlocks).forEach(([name, component]) => app.component(name, component));

0 commit comments

Comments
 (0)