@botim/botim-cli 0.1.3 → 0.1.6

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 (106) hide show
  1. package/dist/cli.js +18 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/templates/react/.botim/app.json5 +12 -0
  4. package/dist/templates/react/.botim/ci/post-version.sh +7 -0
  5. package/dist/templates/react/.cursorrules +37 -0
  6. package/dist/templates/react/scripts/.gitkeep +0 -0
  7. package/dist/templates/react/src/assets/animation/.gitkeep +0 -0
  8. package/dist/templates/react/src/assets/fonts/.gitkeep +0 -0
  9. package/dist/templates/react/src/assets/images/.gitkeep +0 -0
  10. package/dist/templates/templates/react/.botim/app.json5 +12 -0
  11. package/dist/templates/templates/react/.botim/ci/post-version.sh +7 -0
  12. package/dist/templates/templates/react/.cursorrules +37 -0
  13. package/dist/templates/templates/react/README.md +48 -0
  14. package/dist/templates/templates/react/docs/code-patterns.md +139 -0
  15. package/dist/templates/templates/react/docs/core-rules.md +69 -0
  16. package/dist/templates/templates/react/docs/figma-workflow.md +81 -0
  17. package/dist/templates/templates/react/docs/validation.md +59 -0
  18. package/dist/templates/templates/react/eslint.config.ts +57 -0
  19. package/dist/templates/templates/react/index.html +12 -0
  20. package/dist/templates/templates/react/package-lock.json +12197 -0
  21. package/dist/templates/templates/react/package.json +102 -0
  22. package/dist/templates/templates/react/scripts/.gitkeep +0 -0
  23. package/dist/templates/templates/react/scripts/setup.sh +304 -0
  24. package/dist/templates/templates/react/src/api/http-client.ts +8 -0
  25. package/dist/templates/templates/react/src/api/modules/example.ts +12 -0
  26. package/dist/templates/templates/react/src/app.tsx +27 -0
  27. package/dist/templates/templates/react/src/assets/animation/.gitkeep +0 -0
  28. package/dist/templates/templates/react/src/assets/fonts/.gitkeep +0 -0
  29. package/dist/templates/templates/react/src/assets/images/.gitkeep +0 -0
  30. package/dist/templates/templates/react/src/components/not-found-content/index.ts +2 -0
  31. package/dist/templates/templates/react/src/components/not-found-content/not-found-content.tsx +24 -0
  32. package/dist/templates/templates/react/src/components/welcome-card/index.ts +1 -0
  33. package/dist/templates/templates/react/src/components/welcome-card/welcome-card.tsx +10 -0
  34. package/dist/templates/templates/react/src/hooks/use-document-title.ts +11 -0
  35. package/dist/templates/templates/react/src/i18n/index.ts +40 -0
  36. package/dist/templates/templates/react/src/i18n/languages/en.json +10 -0
  37. package/dist/templates/templates/react/src/main.tsx +27 -0
  38. package/dist/templates/templates/react/src/modules/common/README.md +7 -0
  39. package/dist/templates/templates/react/src/modules/common/constants.ts +3 -0
  40. package/dist/templates/templates/react/src/modules/core/README.md +7 -0
  41. package/dist/templates/templates/react/src/modules/core/api/error.ts +6 -0
  42. package/dist/templates/templates/react/src/modules/core/app-providers.tsx +18 -0
  43. package/dist/templates/templates/react/src/modules/core/index.ts +2 -0
  44. package/dist/templates/templates/react/src/pages/home/index.tsx +13 -0
  45. package/dist/templates/templates/react/src/pages/not-found/index.tsx +7 -0
  46. package/dist/templates/templates/react/src/routes.tsx +18 -0
  47. package/dist/templates/templates/react/src/stores/home-store.ts +11 -0
  48. package/dist/templates/templates/react/src/styles/font.css +1 -0
  49. package/dist/templates/templates/react/src/styles/global-style.tsx +27 -0
  50. package/dist/templates/templates/react/src/styles/tailwind.css +4 -0
  51. package/dist/templates/templates/react/src/styles/utility-classes.ts +13 -0
  52. package/dist/templates/templates/react/src/theme/index.tsx +24 -0
  53. package/dist/templates/templates/react/src/theme/types.ts +10 -0
  54. package/dist/templates/templates/react/src/types/global.d.ts +139 -0
  55. package/dist/templates/templates/react/src/types/shims-global.d.ts +97 -0
  56. package/dist/templates/templates/react/src/utils/currency.ts +6 -0
  57. package/dist/templates/templates/react/src/utils/date.ts +5 -0
  58. package/dist/templates/templates/react/src/utils/guard.ts +4 -0
  59. package/dist/templates/templates/react/src/vite-env.d.ts +1 -0
  60. package/dist/templates/templates/react/tsconfig.json +39 -0
  61. package/dist/templates/templates/react/tsconfig.node.json +11 -0
  62. package/dist/templates/templates/react/types/global.d.ts +131 -0
  63. package/dist/templates/templates/react/vite.config.ts +179 -0
  64. package/dist/templates/templates/vue/README.md +19 -0
  65. package/dist/templates/templates/vue/eslint.config.ts +44 -0
  66. package/dist/templates/templates/vue/index.html +12 -0
  67. package/dist/templates/templates/vue/package-lock.json +5774 -0
  68. package/dist/templates/templates/vue/package.json +39 -0
  69. package/dist/templates/templates/vue/src/api/http-client.ts +11 -0
  70. package/dist/templates/templates/vue/src/api/modules/example.ts +12 -0
  71. package/dist/templates/templates/vue/src/app.vue +23 -0
  72. package/dist/templates/templates/vue/src/components/card/index.vue +14 -0
  73. package/dist/templates/templates/vue/src/components/layout/index.ts +1 -0
  74. package/dist/templates/templates/vue/src/components/layout/page-layout.vue +43 -0
  75. package/dist/templates/templates/vue/src/components/layout/styles.ts +5 -0
  76. package/dist/templates/templates/vue/src/components/typography/heading.vue +21 -0
  77. package/dist/templates/templates/vue/src/components/typography/index.ts +1 -0
  78. package/dist/templates/templates/vue/src/hooks/use-document-title.ts +23 -0
  79. package/dist/templates/templates/vue/src/i18n/index.ts +31 -0
  80. package/dist/templates/templates/vue/src/i18n/languages/en.json +10 -0
  81. package/dist/templates/templates/vue/src/main.ts +12 -0
  82. package/dist/templates/templates/vue/src/modules/common/README.md +7 -0
  83. package/dist/templates/templates/vue/src/modules/common/constants.ts +3 -0
  84. package/dist/templates/templates/vue/src/modules/core/README.md +7 -0
  85. package/dist/templates/templates/vue/src/modules/core/api/error.ts +6 -0
  86. package/dist/templates/templates/vue/src/modules/core/app-providers.ts +17 -0
  87. package/dist/templates/templates/vue/src/modules/core/index.ts +2 -0
  88. package/dist/templates/templates/vue/src/pages/home/index.vue +28 -0
  89. package/dist/templates/templates/vue/src/pages/not-found/index.vue +13 -0
  90. package/dist/templates/templates/vue/src/routes.ts +19 -0
  91. package/dist/templates/templates/vue/src/stores/home-store.ts +12 -0
  92. package/dist/templates/templates/vue/src/styles/font.css +1 -0
  93. package/dist/templates/templates/vue/src/styles/global-style.ts +63 -0
  94. package/dist/templates/templates/vue/src/styles/utility-classes.ts +1 -0
  95. package/dist/templates/templates/vue/src/theme/index.ts +33 -0
  96. package/dist/templates/templates/vue/src/theme/types.ts +10 -0
  97. package/dist/templates/templates/vue/src/types/global.d.ts +9 -0
  98. package/dist/templates/templates/vue/src/utils/currency.ts +6 -0
  99. package/dist/templates/templates/vue/src/utils/date.ts +5 -0
  100. package/dist/templates/templates/vue/src/utils/guard.ts +4 -0
  101. package/dist/templates/templates/vue/src/vite-env.d.ts +1 -0
  102. package/dist/templates/templates/vue/tsconfig.json +36 -0
  103. package/dist/templates/templates/vue/tsconfig.node.json +9 -0
  104. package/dist/templates/templates/vue/types/global.d.ts +7 -0
  105. package/dist/templates/templates/vue/vite.config.ts +74 -0
  106. package/package.json +3 -2
@@ -0,0 +1,179 @@
1
+ import { reactImports } from '@botim/buckit2-resolver';
2
+ import botimMpPlugin from '@botim/unplugin-mp/vite';
3
+ import { ViteBotimSentry } from '@botim/unplugin-sentry';
4
+ import react from '@vitejs/plugin-react';
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import AutoImport from 'unplugin-auto-import/vite';
8
+ import type { PluginOption } from 'vite';
9
+ import { defineConfig, loadEnv } from 'vite';
10
+ import viteVConsole from 'vite-plugin-vconsole';
11
+
12
+ // Plugin to copy bridge chunk files to dist for preview mode
13
+ function copyBridgeChunks(): PluginOption {
14
+ return {
15
+ name: 'copy-bridge-chunks',
16
+ closeBundle() {
17
+ const bridgePath = path.resolve(__dirname, 'node_modules/@botim/bridge');
18
+ const distPath = path.resolve(__dirname, 'dist');
19
+ const chunkFiles = ['framework.b62c43e7.js', 'vendors~framework.f9fc3b9a.js'];
20
+
21
+ chunkFiles.forEach(file => {
22
+ const src = path.join(bridgePath, file);
23
+ const dest = path.join(distPath, file);
24
+
25
+ if (fs.existsSync(src)) {
26
+ fs.copyFileSync(src, dest);
27
+ console.log(`Copied ${file} to dist`);
28
+ }
29
+ });
30
+ }
31
+ };
32
+ }
33
+
34
+ let devServerProxyApi = {};
35
+
36
+ function setProxy(target: string, rewrite = {}): void {
37
+ devServerProxyApi = {
38
+ target,
39
+ ...rewrite
40
+ };
41
+ }
42
+
43
+ function setProxyByEnv(env: Record<string, string>): void {
44
+
45
+ if (process.env.isMock === 'true') {
46
+ const mockTarget = env.VITE_DEV_SERVER_PROXY_MOCK_TARGET;
47
+
48
+ if (mockTarget) {
49
+ setProxy(mockTarget, {
50
+ pathRewrite: {
51
+ '^/api': ''
52
+ }
53
+ });
54
+ } else
55
+ throw new Error('VITE_DEV_SERVER_PROXY_MOCK_TARGET is not set in .env.local file');
56
+ }
57
+ }
58
+
59
+ // https://vitejs.dev/config/
60
+ export default defineConfig(({ mode }) => {
61
+ const env = loadEnv(mode, process.cwd());
62
+
63
+ setProxyByEnv(env);
64
+
65
+ const plugins: PluginOption[] = [
66
+ react({
67
+ jsxImportSource: '@emotion/react',
68
+ babel: {
69
+ plugins: [
70
+ [
71
+ '@emotion/babel-plugin',
72
+ {
73
+ autoLabel: mode !== 'production' ? 'dev-only' : 'never',
74
+ labelFormat: '[local]',
75
+ sourceMap: mode !== 'production'
76
+ }
77
+ ]
78
+ ]
79
+ }
80
+ }),
81
+ AutoImport({
82
+ imports: reactImports as unknown as string[]
83
+ }),
84
+ botimMpPlugin({
85
+ root: __dirname,
86
+ configDir: '.botim',
87
+ distDir: 'dist',
88
+ apkDir: 'dist/publish/bridge',
89
+ legacy: false
90
+ }),
91
+ ...(mode !== 'production' ? [ viteVConsole({
92
+ entry: path.resolve('src/main.tsx'),
93
+ enabled: true,
94
+ config: {
95
+ maxLogNumber: 1000,
96
+ theme: 'dark'
97
+ }
98
+ }) as PluginOption ] : []),
99
+ copyBridgeChunks()
100
+ ];
101
+
102
+
103
+ return {
104
+ base: './',
105
+ plugins,
106
+ resolve: {
107
+ alias: {
108
+ '@': path.resolve(__dirname, './src'),
109
+ '@modules': path.resolve(__dirname, './src/modules'),
110
+ '@components': path.resolve(__dirname, './src/components'),
111
+ '@hooks': path.resolve(__dirname, './src/hooks'),
112
+ '@i18n': path.resolve(__dirname, './src/i18n'),
113
+ '@pages': path.resolve(__dirname, './src/pages'),
114
+ '@stores': path.resolve(__dirname, './src/stores'),
115
+ '@styles': path.resolve(__dirname, './src/styles'),
116
+ '@theme': path.resolve(__dirname, './src/theme'),
117
+ '@utils': path.resolve(__dirname, './src/utils')
118
+ }
119
+ },
120
+ server: {
121
+ port: 5173,
122
+ proxy: {
123
+ '^/(sgs|cgs)/api': {
124
+ target: 'https://uat.test2pay.com',
125
+ changeOrigin: true,
126
+ ...devServerProxyApi
127
+ }
128
+ }
129
+ },
130
+ build: {
131
+ sourcemap: true,
132
+ minify: true,
133
+ rollupOptions: {
134
+ output: {
135
+ chunkFileNames: 'js/[name]-[hash].js',
136
+ entryFileNames: 'js/[name]-[hash].js',
137
+ assetFileNames: (assetInfo) => {
138
+ const ext = assetInfo.names?.[0]?.split('.').pop();
139
+
140
+ if ([ 'png', 'jpg', 'jpeg', 'svg', 'gif', 'webp' ].includes(ext || ''))
141
+ return 'img/[name]-[hash][extname]';
142
+
143
+ if ([ 'woff', 'woff2', 'ttf', 'otf', 'eot' ].includes(ext || ''))
144
+ return 'fonts/[name]-[hash][extname]';
145
+
146
+ return 'assets/[name]-[hash][extname]';
147
+ },
148
+ manualChunks: (id) => {
149
+ // Vendor chunk for node_modules
150
+ if (id.includes('node_modules')) {
151
+
152
+ if (id.includes('lottie'))
153
+ return 'vendor-lottie';
154
+
155
+ if (id.includes('@sentry') || id.includes('sentry'))
156
+ return 'vendor-sentry';
157
+
158
+ if (id.includes('@botim'))
159
+ return 'vendor-botim';
160
+
161
+ if (id.includes('axios') || id.includes('crypto-js') || id.includes('dayjs') || id.includes('decimal'))
162
+ return 'vendor-utils';
163
+
164
+ return 'vendor';
165
+ }
166
+
167
+ // Pages can be split into separate chunks
168
+ if (id.includes('src/pages/')) {
169
+ const pagePath = id.split('src/pages/')[1];
170
+ const pageDir = pagePath.split('/')[0];
171
+
172
+ return `page-${pageDir}`;
173
+ }
174
+ }
175
+ }
176
+ }
177
+ }
178
+ };
179
+ });
@@ -0,0 +1,19 @@
1
+ # Vue SPA Template
2
+
3
+ A Vue 3 + TypeScript single-page application template mirroring the structure of the React counterpart. Includes opinionated tooling for routing, state management, internationalization, and global styling.
4
+
5
+ ## Getting started
6
+
7
+ ```bash
8
+ pnpm install
9
+ pnpm dev
10
+ ```
11
+
12
+ Key tooling:
13
+
14
+ - Vite 5 for development and build
15
+ - Vue Router for client-side navigation
16
+ - Pinia for lightweight state management
17
+ - Vue I18n for translations
18
+ - Vitest for unit testing
19
+ - ESLint (flat config) with Vue and TypeScript support
@@ -0,0 +1,44 @@
1
+ import js from '@eslint/js';
2
+ import eslintPluginVue from 'eslint-plugin-vue';
3
+ import eslintPluginImport from 'eslint-plugin-import';
4
+ import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default tseslint.config(
8
+ {
9
+ ignores: [
10
+ 'dist',
11
+ 'coverage'
12
+ ]
13
+ },
14
+ js.configs.recommended,
15
+ ...tseslint.configs.recommended,
16
+ eslintPluginVue.configs['flat/recommended'],
17
+ {
18
+ files: [ '**/*.ts', '**/*.vue' ],
19
+ languageOptions: {
20
+ parserOptions: {
21
+ ecmaVersion: 'latest',
22
+ sourceType: 'module',
23
+ extraFileExtensions: [ '.vue' ]
24
+ }
25
+ },
26
+ plugins: {
27
+ import: eslintPluginImport,
28
+ 'simple-import-sort': eslintPluginSimpleImportSort
29
+ },
30
+ settings: {
31
+ 'import/resolver': {
32
+ typescript: true,
33
+ node: {
34
+ extensions: [ '.js', '.jsx', '.ts', '.tsx', '.vue' ]
35
+ }
36
+ }
37
+ },
38
+ rules: {
39
+ 'import/order': 'off',
40
+ 'simple-import-sort/imports': 'error',
41
+ 'simple-import-sort/exports': 'error'
42
+ }
43
+ }
44
+ );
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Vue SPA Template</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>