Skip to content

Commit

Permalink
Fix CI/CD error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed May 7, 2024
1 parent 5a65518 commit 702e9ae
Show file tree
Hide file tree
Showing 27 changed files with 10,202 additions and 10,864 deletions.
Binary file added images/login-page-zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
FROM node:18.18.0 as build-stage
MAINTAINER WanSen AI<[email protected]>
WORKDIR app
WORKDIR /app

COPY . ./

# 设置 node 阿里镜像
RUN npm config set registry https://registry.npmmirror.com

ENV NODE_OPTIONS --max-old-space-size=16384

RUN npm install pnpm -g
RUN pnpm install --frozen-lockfile
RUN pnpm build:docker
RUN npm install pnpm -g && \
pnpm install --frozen-lockfile && \
pnpm build:docker

RUN echo "Build Success"

Expand Down
2 changes: 1 addition & 1 deletion web/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nginx:1.23.4-alpine
FROM nginx:stable-alpine3.17-slim

COPY dist/ /usr/share/nginx/html/
COPY ../deploy/default.conf /etc/nginx/conf.d/
Expand Down
23 changes: 11 additions & 12 deletions web/internal/stylelint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@
"stub": "pnpm unbuild --stub"
},
"devDependencies": {
"postcss": "^8.4.29",
"postcss-html": "^1.5.0",
"postcss": "^8.4.38",
"postcss-html": "^1.6.0",
"postcss-less": "^6.0.0",
"postcss-scss": "^4.0.7",
"prettier": "^2.8.8",
"stylelint": "^15.10.3",
"stylelint-config-property-sort-order-smacss": "^9.1.0",
"stylelint-config-recommended": "^12.0.0",
"stylelint-config-recommended-scss": "^11.0.0",
"postcss-scss": "^4.0.9",
"prettier": "^3.2.5",
"stylelint": "^16.4.0",
"stylelint-config-property-sort-order-smacss": "^10.0.0",
"stylelint-config-recommended-scss": "^14.0.0",
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^33.0.0",
"stylelint-config-standard-scss": "^9.0.0",
"stylelint-order": "^6.0.3",
"stylelint-prettier": "^3.0.0"
"stylelint-config-standard": "^36.0.0",
"stylelint-config-standard-scss": "^13.1.0",
"stylelint-order": "^6.0.4",
"stylelint-prettier": "^5.0.0"
}
}
5 changes: 2 additions & 3 deletions web/internal/ts-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"node-server.json"
],
"dependencies": {
"@types/node": "^18.17.12",
"unplugin-vue-define-options": "^1.3.17",
"vite": "^4.4.9"
"@types/node": "^20.12.7",
"vite": "^5.2.10"
}
}
35 changes: 17 additions & 18 deletions web/internal/vite-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,28 @@
"stub": "pnpm unbuild --stub"
},
"dependencies": {
"@ant-design/colors": "^7.0.0",
"vite": "^4.4.9"
"@ant-design/colors": "^7.0.2",
"vite": "^5.2.10"
},
"devDependencies": {
"@types/fs-extra": "^11.0.1",
"@vitejs/plugin-vue": "^4.3.4",
"@vitejs/plugin-vue-jsx": "^3.0.2",
"ant-design-vue": "^4.0.6",
"dayjs": "^1.11.9",
"dotenv": "^16.3.1",
"fs-extra": "^11.1.1",
"@types/fs-extra": "^11.0.4",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"ant-design-vue": "^4.2.1",
"dayjs": "^1.11.10",
"dotenv": "^16.4.5",
"fs-extra": "^11.2.0",
"less": "^4.2.0",
"picocolors": "^1.0.0",
"pkg-types": "^1.0.3",
"rollup-plugin-visualizer": "^5.9.2",
"sass": "^1.66.1",
"unocss": "^0.55.3",
"unplugin-vue-define-options": "^1.3.17",
"pkg-types": "^1.1.0",
"rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.75.0",
"unocss": "0.59.4",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-dts": "^2.3.0",
"vite-plugin-html": "^3.2.0",
"vite-plugin-mock": "^3.0.0",
"vite-plugin-purge-icons": "^0.9.2",
"vite-plugin-dts": "^3.9.0",
"vite-plugin-html": "^3.2.2",
"vite-plugin-mock": "^2.9.6",
"vite-plugin-purge-icons": "^0.10.0",
"vite-plugin-svg-icons": "^2.0.1"
}
}
22 changes: 8 additions & 14 deletions web/internal/vite-config/src/config/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) {
return defineConfig(async ({ command, mode }) => {
const root = process.cwd();
const isBuild = command === 'build';
const { VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_ENABLE_ANALYZE } = loadEnv(mode, root);
const { VITE_PUBLIC_PATH, VITE_USE_MOCK, VITE_BUILD_COMPRESS, VITE_ENABLE_ANALYZE } = loadEnv(
mode,
root,
);

const defineData = await createDefineData(root);
const plugins = await createPlugins({
Expand All @@ -33,24 +36,15 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) {
});

const pathResolve = (pathname: string) => resolve(root, '.', pathname);

const timestamp = new Date().getTime();
const applicationConfig: UserConfig = {
base: VITE_PUBLIC_PATH,
resolve: {
alias: [
{
find: 'vue-i18n',
replacement: 'vue-i18n/dist/vue-i18n.cjs.js',
},
// /@/xxxx => src/xxxx
{
find: /\/@\//,
replacement: pathResolve('src') + '/',
},
// /#/xxxx => types/xxxx
{
find: /\/#\//,
replacement: pathResolve('types') + '/',
},
// @/xxxx => src/xxxx
{
find: /@\//,
Expand All @@ -70,7 +64,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) {
rollupOptions: {
output: {
// 入口文件名
entryFileNames: 'assets/[name].js',
entryFileNames: `assets/entry/[name]-[hash]-${timestamp}.js`,
manualChunks: {
vue: ['vue', 'pinia', 'vue-router'],
antd: ['ant-design-vue', '@ant-design/icons-vue'],
Expand Down Expand Up @@ -112,4 +106,4 @@ async function createDefineData(root: string) {
}
}

export { defineApplicationConfig };
export { defineApplicationConfig };
28 changes: 2 additions & 26 deletions web/internal/vite-config/src/config/common.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import {
presetAttributify,
presetIcons,
presetTypography,
presetUno,
presetWebFonts,
transformerDirectives,
transformerVariantGroup,
} from 'unocss';
import UnoCSS from 'unocss/vite';
import { type UserConfig } from 'vite';

Expand All @@ -25,22 +16,7 @@ const commonConfig: (mode: string) => UserConfig = (mode) => ({
maxParallelFileOps: 3,
},
},
plugins: [
UnoCSS({
presets: [
presetUno(),
presetAttributify(),
presetIcons(),
presetTypography(),
presetWebFonts({
fonts: {
// ...
},
}),
],
transformers: [transformerDirectives(), transformerVariantGroup()],
}),
],
plugins: [UnoCSS()],
});

export { commonConfig };
export { commonConfig };
2 changes: 1 addition & 1 deletion web/internal/vite-config/src/config/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ function definePackageConfig(defineOptions: DefineOptions = {}) {
});
}

export { definePackageConfig };
export { definePackageConfig };
2 changes: 1 addition & 1 deletion web/internal/vite-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './config/application';
export * from './config/package';
export * from './config/package';
22 changes: 15 additions & 7 deletions web/internal/vite-config/src/plugins/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const GLOBAL_CONFIG_FILE_NAME = '_app.config.js';
const PLUGIN_NAME = 'app-config';

async function createAppConfigPlugin({
root,
isBuild,
}: {
root,
isBuild,
}: {
root: string;
isBuild: boolean;
}): Promise<PluginOption> {
Expand All @@ -27,8 +27,8 @@ async function createAppConfigPlugin({
return {
name: PLUGIN_NAME,
async configResolved(_config) {
let appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? '';
appTitle = appTitle.replace(/\s/g, '_').replace(/-/g, '_');
const appTitle = _config?.env?.VITE_GLOB_APP_TITLE ?? '';
// appTitle = appTitle.replace(/\s/g, '_').replace(/-/g, '_');
publicPath = _config.base;
source = await getConfigSource(appTitle);
},
Expand All @@ -37,7 +37,7 @@ async function createAppConfigPlugin({

const appConfigSrc = `${
publicPath || '/'
}${GLOBAL_CONFIG_FILE_NAME}?v=${version}-${createContentHash(source)}}`;
}${GLOBAL_CONFIG_FILE_NAME}?v=${version}-${createContentHash(source)}`;

return {
html,
Expand Down Expand Up @@ -74,7 +74,15 @@ async function createAppConfigPlugin({
* @param env
*/
const getVariableName = (title: string) => {
return `__PRODUCTION__${title || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '');
function strToHex(str: string) {
const result: string[] = [];
for (let i = 0; i < str.length; ++i) {
const hex = str.charCodeAt(i).toString(16);
result.push(('000' + hex).slice(-4));
}
return result.join('').toUpperCase();
}
return `__PRODUCTION__${strToHex(title) || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '');
};

async function getConfigSource(appTitle: string) {
Expand Down
52 changes: 26 additions & 26 deletions web/internal/vite-config/src/plugins/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ import type { PluginOption } from 'vite';
import compressPlugin from 'vite-plugin-compression';

export function configCompressPlugin({
compress,
deleteOriginFile = false,
}: {
compress: string;
deleteOriginFile?: boolean;
compress,
deleteOriginFile = false,
}: {
compress: string;
deleteOriginFile?: boolean;
}): PluginOption[] {
const compressList = compress.split(',');
const compressList = compress.split(',');

const plugins: PluginOption[] = [];
const plugins: PluginOption[] = [];

if (compressList.includes('gzip')) {
plugins.push(
compressPlugin({
ext: '.gz',
deleteOriginFile,
}),
);
}
if (compressList.includes('gzip')) {
plugins.push(
compressPlugin({
ext: '.gz',
deleteOriginFile,
}),
);
}

if (compressList.includes('brotli')) {
plugins.push(
compressPlugin({
ext: '.br',
algorithm: 'brotliCompress',
deleteOriginFile,
}),
);
}
return plugins;
}
if (compressList.includes('brotli')) {
plugins.push(
compressPlugin({
ext: '.br',
algorithm: 'brotliCompress',
deleteOriginFile,
}),
);
}
return plugins;
}
2 changes: 1 addition & 1 deletion web/internal/vite-config/src/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export function configHtmlPlugin({ isBuild }: { isBuild: boolean }) {
minify: isBuild,
});
return htmlPlugin;
}
}
12 changes: 5 additions & 7 deletions web/internal/vite-config/src/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
// @ts-ignore: type unless
import DefineOptions from 'unplugin-vue-define-options/vite';
import { type PluginOption } from 'vite';
import purgeIcons from 'vite-plugin-purge-icons';

Expand All @@ -21,7 +19,7 @@ interface Options {
}

async function createPlugins({ isBuild, root, enableMock, compress, enableAnalyze }: Options) {
const vitePlugins: (PluginOption | PluginOption[])[] = [vue(), vueJsx(), DefineOptions()];
const vitePlugins: (PluginOption | PluginOption[])[] = [vue(), vueJsx()];

const appConfigPlugin = await createAppConfigPlugin({ root, isBuild });
vitePlugins.push(appConfigPlugin);
Expand All @@ -39,9 +37,9 @@ async function createPlugins({ isBuild, root, enableMock, compress, enableAnalyz
if (isBuild) {
// rollup-plugin-gzip
vitePlugins.push(
configCompressPlugin({
compress,
}),
configCompressPlugin({
compress,
}),
);
}

Expand All @@ -58,4 +56,4 @@ async function createPlugins({ isBuild, root, enableMock, compress, enableAnalyz
return vitePlugins;
}

export { createPlugins };
export { createPlugins };
2 changes: 1 addition & 1 deletion web/internal/vite-config/src/plugins/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export function configMockPlugin({ isBuild }: { isBuild: boolean }) {
setupProdMockServer();
`,
});
}
}
2 changes: 1 addition & 1 deletion web/internal/vite-config/src/plugins/svgSprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export function configSvgIconsPlugin({ isBuild }: { isBuild: boolean }) {
svgoOptions: isBuild,
});
return svgIconsPlugin as PluginOption;
}
}
2 changes: 1 addition & 1 deletion web/internal/vite-config/src/plugins/visualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export function configVisualizerConfig() {
gzipSize: true,
brotliSize: true,
}) as PluginOption;
}
}
Loading

0 comments on commit 702e9ae

Please sign in to comment.