@vef-framework/dev 1.0.122 → 1.0.124

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 (118) hide show
  1. package/bin/vef.js +1 -1
  2. package/cjs/cli.cjs +228 -0
  3. package/cjs/commitlint-config.cjs +14 -0
  4. package/cjs/config.cjs +82 -0
  5. package/cjs/constants.cjs +27 -0
  6. package/cjs/eslint-config.cjs +413 -0
  7. package/cjs/index.cjs +16 -0
  8. package/cjs/json/monaco.nls.json.cjs +7 -0
  9. package/cjs/json/monaco.theme.github-light.json.cjs +7 -0
  10. package/cjs/modules.d.cjs +4 -0
  11. package/cjs/plugin-app-config.cjs +37 -0
  12. package/cjs/plugin-conventional-config.cjs +116 -0
  13. package/cjs/plugin-eslint.cjs +23 -0
  14. package/cjs/plugin-html.cjs +85 -0
  15. package/cjs/plugin-icons.cjs +21 -0
  16. package/{lib → cjs}/plugin-initialization.cjs +26 -2
  17. package/cjs/plugin-injection.cjs +20 -0
  18. package/cjs/plugin-inspect.cjs +14 -0
  19. package/{lib → cjs}/plugin-monaco-nls.cjs +59 -2
  20. package/cjs/plugin-react-swc.cjs +13 -0
  21. package/cjs/plugin-router.cjs +47 -0
  22. package/cjs/plugin-stylelint.cjs +23 -0
  23. package/cjs/plugin-svgr.cjs +58 -0
  24. package/cjs/plugin-tailwind.cjs +11 -0
  25. package/cjs/plugin-tailwindcss.cjs +24 -0
  26. package/cjs/plugin-tsconfig-paths.cjs +13 -0
  27. package/cjs/plugin-visualizer.cjs +15 -0
  28. package/cjs/plugin-webfont.cjs +14 -0
  29. package/cjs/stylelint-config.cjs +67 -0
  30. package/cjs/tailwind-config.cjs +395 -0
  31. package/cjs/types.cjs +4 -0
  32. package/esm/cli.js +226 -0
  33. package/esm/commitlint-config.js +12 -0
  34. package/esm/config.js +80 -0
  35. package/esm/constants.js +15 -0
  36. package/esm/eslint-config.js +411 -0
  37. package/esm/index.js +8 -0
  38. package/esm/json/monaco.nls.json.js +3 -0
  39. package/esm/json/monaco.theme.github-light.json.js +3 -0
  40. package/esm/modules.d.js +2 -0
  41. package/esm/plugin-app-config.js +35 -0
  42. package/esm/plugin-conventional-config.js +114 -0
  43. package/esm/plugin-eslint.js +21 -0
  44. package/esm/plugin-html.js +83 -0
  45. package/esm/plugin-icons.js +18 -0
  46. package/{es → esm}/plugin-initialization.js +24 -2
  47. package/esm/plugin-injection.js +18 -0
  48. package/esm/plugin-inspect.js +12 -0
  49. package/{es → esm}/plugin-monaco-nls.js +56 -2
  50. package/esm/plugin-react-swc.js +11 -0
  51. package/esm/plugin-router.js +45 -0
  52. package/esm/plugin-stylelint.js +21 -0
  53. package/esm/plugin-svgr.js +56 -0
  54. package/esm/plugin-tailwind.js +9 -0
  55. package/esm/plugin-tailwindcss.js +22 -0
  56. package/esm/plugin-tsconfig-paths.js +11 -0
  57. package/esm/plugin-visualizer.js +13 -0
  58. package/esm/plugin-webfont.js +12 -0
  59. package/esm/stylelint-config.js +65 -0
  60. package/esm/tailwind-config.js +393 -0
  61. package/esm/types.js +2 -0
  62. package/package.json +19 -18
  63. package/template/_package.json +5 -5
  64. package/es/cli.js +0 -4
  65. package/es/commitlint-config.js +0 -1
  66. package/es/config.js +0 -1
  67. package/es/constants.js +0 -1
  68. package/es/eslint-config.js +0 -1
  69. package/es/index.js +0 -1
  70. package/es/json/monaco.nls.json.js +0 -15920
  71. package/es/json/monaco.theme.github-light.json.js +0 -349
  72. package/es/modules.d.js +0 -1
  73. package/es/plugin-app-config.js +0 -1
  74. package/es/plugin-conventional-config.js +0 -11
  75. package/es/plugin-eslint.js +0 -1
  76. package/es/plugin-html.js +0 -16
  77. package/es/plugin-icons.js +0 -1
  78. package/es/plugin-injection.js +0 -2
  79. package/es/plugin-inspect.js +0 -1
  80. package/es/plugin-react-swc.js +0 -1
  81. package/es/plugin-router.js +0 -10
  82. package/es/plugin-stylelint.js +0 -1
  83. package/es/plugin-svgr.js +0 -1
  84. package/es/plugin-tailwind.js +0 -1
  85. package/es/plugin-tailwindcss.js +0 -2
  86. package/es/plugin-tsconfig-paths.js +0 -1
  87. package/es/plugin-visualizer.js +0 -1
  88. package/es/plugin-webfont.js +0 -1
  89. package/es/stylelint-config.js +0 -1
  90. package/es/tailwind-config.js +0 -1
  91. package/lib/cli.cjs +0 -4
  92. package/lib/commitlint-config.cjs +0 -1
  93. package/lib/config.cjs +0 -1
  94. package/lib/constants.cjs +0 -1
  95. package/lib/eslint-config.cjs +0 -1
  96. package/lib/index.cjs +0 -1
  97. package/lib/json/monaco.nls.json.cjs +0 -15920
  98. package/lib/json/monaco.theme.github-light.json.cjs +0 -349
  99. package/lib/modules.d.cjs +0 -1
  100. package/lib/plugin-app-config.cjs +0 -1
  101. package/lib/plugin-conventional-config.cjs +0 -11
  102. package/lib/plugin-eslint.cjs +0 -1
  103. package/lib/plugin-html.cjs +0 -16
  104. package/lib/plugin-icons.cjs +0 -1
  105. package/lib/plugin-injection.cjs +0 -2
  106. package/lib/plugin-inspect.cjs +0 -1
  107. package/lib/plugin-react-swc.cjs +0 -1
  108. package/lib/plugin-router.cjs +0 -10
  109. package/lib/plugin-stylelint.cjs +0 -1
  110. package/lib/plugin-svgr.cjs +0 -1
  111. package/lib/plugin-tailwind.cjs +0 -1
  112. package/lib/plugin-tailwindcss.cjs +0 -2
  113. package/lib/plugin-tsconfig-paths.cjs +0 -1
  114. package/lib/plugin-visualizer.cjs +0 -1
  115. package/lib/plugin-webfont.cjs +0 -1
  116. package/lib/stylelint-config.cjs +0 -1
  117. package/lib/tailwind-config.cjs +0 -1
  118. package/lib/types.cjs +0 -1
package/esm/cli.js ADDED
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ import chalk from 'chalk';
3
+ import { program } from 'commander';
4
+ import consola from 'consola';
5
+ import { execa } from 'execa';
6
+ import fsExtra from 'fs-extra';
7
+ import { resolve } from 'node:path';
8
+ import process from 'node:process';
9
+ import ora from 'ora';
10
+ import prompts from 'prompts';
11
+ import { loadConfigFromFile, createServer, build, preview } from 'vite';
12
+
13
+ "use strict";
14
+ const {
15
+ exists,
16
+ readJsonSync,
17
+ writeFile,
18
+ readJson,
19
+ writeJson,
20
+ copy,
21
+ readFile,
22
+ move
23
+ } = fsExtra;
24
+ const currentDir = process.cwd();
25
+ function readPackageVersion() {
26
+ const packageJsonPath = resolve(import.meta.dirname, "../package.json");
27
+ const packageJson = readJsonSync(packageJsonPath, { encoding: "utf-8" });
28
+ return packageJson.version;
29
+ }
30
+ const frameworkVersion = readPackageVersion();
31
+ async function importHoistPatterns() {
32
+ const hoistedPatterns = (await import('../bin/hoist-patterns.js')).default;
33
+ return hoistedPatterns;
34
+ }
35
+ function resolveEnvMode(command, userMode) {
36
+ if (userMode) {
37
+ return userMode;
38
+ }
39
+ return command === "build" ? "production" : "development";
40
+ }
41
+ async function loadVefConfig(configPath, command, mode) {
42
+ const vefConfigPath = resolve(currentDir, configPath || "vef.config.ts");
43
+ if (!await exists(vefConfigPath)) {
44
+ consola.error(`Config file not found: ${vefConfigPath}, it is required for VEF Framework`);
45
+ throw new Error(`Config file not found: ${vefConfigPath}`);
46
+ }
47
+ const vefConfig = await loadConfigFromFile(
48
+ {
49
+ command,
50
+ mode
51
+ },
52
+ vefConfigPath
53
+ );
54
+ return vefConfig?.config ?? {};
55
+ }
56
+ function handleError(phase, error) {
57
+ consola.error(`Error during ${phase}:`, error);
58
+ process.exit(1);
59
+ }
60
+ program.name("vef").description(chalk.magenta("VEF Framework CLI")).addHelpText("before", chalk.blue("VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus.")).addHelpText("before", chalk.bgGreenBright(`Version: ${frameworkVersion}`)).version(frameworkVersion).option("--mode <mode>", "Specify running mode (will override default NODE_ENV)");
61
+ program.command("dev").description("Start dev server").option("-c, --config <file>", "Specify vef config file", "vef.config.ts").action(async (options) => {
62
+ try {
63
+ const mode = resolveEnvMode("serve", program.opts().mode);
64
+ process.env.NODE_ENV = mode;
65
+ process.env.VEF_FRAMEWORK_VERSION = frameworkVersion;
66
+ const config = await loadVefConfig(options.config, "serve", mode);
67
+ const server = await createServer({
68
+ ...config,
69
+ mode,
70
+ configFile: false,
71
+ logLevel: "info"
72
+ });
73
+ await server.listen();
74
+ server.printUrls();
75
+ server.bindCLIShortcuts({ print: true });
76
+ } catch (e) {
77
+ handleError("dev server startup", e);
78
+ }
79
+ });
80
+ program.command("build").description("Build for production").option("-c, --config <file>", "Specify vef config file", "vef.config.ts").action(async (options) => {
81
+ try {
82
+ const mode = resolveEnvMode("build", program.opts().mode);
83
+ process.env.NODE_ENV = mode;
84
+ process.env.VEF_FRAMEWORK_VERSION = frameworkVersion;
85
+ const config = await loadVefConfig(options.config, "build", mode);
86
+ await build({
87
+ ...config,
88
+ mode,
89
+ configFile: false,
90
+ logLevel: "info"
91
+ });
92
+ consola.success("Build completed successfully!");
93
+ } catch (e) {
94
+ handleError("build", e);
95
+ }
96
+ });
97
+ program.command("preview").description("Preview the build").option("-c, --config <file>", "Specify vef config file", "vef.config.ts").action(async (options) => {
98
+ try {
99
+ const mode = resolveEnvMode("build", program.opts().mode);
100
+ process.env.NODE_ENV = mode;
101
+ process.env.VEF_FRAMEWORK_VERSION = frameworkVersion;
102
+ const config = await loadVefConfig(options.config, "build", mode);
103
+ const server = await preview({
104
+ ...config,
105
+ mode,
106
+ configFile: false,
107
+ logLevel: "info"
108
+ });
109
+ server.printUrls();
110
+ server.bindCLIShortcuts({ print: true });
111
+ } catch (e) {
112
+ handleError("preview server startup", e);
113
+ }
114
+ });
115
+ program.command("prepare").description("Sets up the project for development mode").action(async () => {
116
+ if (!await exists(resolve(currentDir, ".husky"))) {
117
+ (await import('husky')).default();
118
+ consola.success("Successfully set up husky");
119
+ }
120
+ if (!await exists(resolve(currentDir, ".husky/pre-commit"))) {
121
+ await writeFile(
122
+ resolve(currentDir, ".husky/pre-commit"),
123
+ "pnpm dlx lint-staged"
124
+ );
125
+ consola.success("Successfully set up pre-commit hook");
126
+ }
127
+ if (!await exists(resolve(currentDir, ".husky/commit-msg"))) {
128
+ await writeFile(
129
+ resolve(currentDir, ".husky/commit-msg"),
130
+ "pnpm dlx commitlint --edit $1"
131
+ );
132
+ consola.success("Successfully set up commit-msg hook");
133
+ }
134
+ const packageJson = await readJson(resolve(currentDir, "package.json"), { encoding: "utf-8" });
135
+ const { scripts } = packageJson;
136
+ let changed = false;
137
+ if (!scripts.prepare) {
138
+ scripts.prepare = "vef prepare";
139
+ changed = true;
140
+ }
141
+ if (changed) {
142
+ await writeJson(
143
+ resolve(currentDir, "package.json"),
144
+ packageJson,
145
+ {
146
+ encoding: "utf-8",
147
+ spaces: 2
148
+ }
149
+ );
150
+ consola.success("Successfully set up prepare script and lint-staged");
151
+ }
152
+ });
153
+ program.command("install").description("Install the dependencies of the project").action(async () => {
154
+ const hoistedPatterns = await importHoistPatterns();
155
+ await execa({
156
+ cwd: currentDir,
157
+ stdio: "inherit"
158
+ })("pnpm", ["install", ...hoistedPatterns.flatMap((pattern) => ["--public-hoist-pattern", pattern])]);
159
+ });
160
+ program.command("update").description("Update the dependencies of the vef framework to latest version").action(async () => {
161
+ await execa({
162
+ cwd: currentDir,
163
+ stdio: "inherit"
164
+ })("pnpm", ["update", "@vef-framework/*"]);
165
+ });
166
+ program.command("init").description("Initialize an empty VEF project").action(async () => {
167
+ console.log(chalk.blue("Welcome to use the cli tool of VEF Framework\n"));
168
+ const result = await prompts([
169
+ {
170
+ type: "text",
171
+ name: "appName",
172
+ message: "What is the name of your app?",
173
+ validate: (value) => typeof value === "string" && value.trim().length > 0 ? true : "App name is required"
174
+ },
175
+ {
176
+ type: "text",
177
+ name: "appTitle",
178
+ message: "What is the title of your app?",
179
+ validate: (value) => typeof value === "string" && value.trim().length > 0 ? true : "App title is required"
180
+ }
181
+ ]);
182
+ const { appName, appTitle } = result;
183
+ await copy(resolve(import.meta.dirname, "../template"), resolve(currentDir, appName));
184
+ consola.success("Successfully copied template files");
185
+ await move(resolve(currentDir, appName, "_gitignore"), resolve(currentDir, appName, ".gitignore"));
186
+ await move(resolve(currentDir, appName, "_tsconfig.json"), resolve(currentDir, appName, "tsconfig.json"));
187
+ await move(resolve(currentDir, appName, "_package.json"), resolve(currentDir, appName, "package.json"));
188
+ const packageJson = await readJson(resolve(currentDir, appName, "package.json"), { encoding: "utf-8" });
189
+ packageJson.name = appName;
190
+ await writeJson(resolve(currentDir, appName, "package.json"), packageJson, {
191
+ encoding: "utf-8",
192
+ spaces: 2
193
+ });
194
+ consola.success("Successfully replaced name and title in package.json");
195
+ const envContent = await readFile(resolve(currentDir, appName, "env/.env"), { encoding: "utf-8" });
196
+ const replacedEnvContent = envContent.replace(/APP_NAME=.*$/m, `APP_NAME=${appName}`).replace(/APP_TITLE=.*$/m, `APP_TITLE=${appTitle}`);
197
+ await writeFile(resolve(currentDir, appName, "env/.env"), replacedEnvContent);
198
+ consola.success("Successfully replaced name and title in .env file");
199
+ const spinner = ora("Initializing git repository...").start();
200
+ try {
201
+ await execa`git --version`;
202
+ await execa({
203
+ cwd: resolve(currentDir, appName)
204
+ })`git init`;
205
+ spinner.succeed("Successfully initialized git repository");
206
+ } catch (e) {
207
+ spinner.fail("Failed to initialize git repository");
208
+ handleError("init", e);
209
+ }
210
+ spinner.start("Installing dependencies...");
211
+ try {
212
+ const hoistedPatterns = await importHoistPatterns();
213
+ await execa({
214
+ cwd: resolve(currentDir, appName)
215
+ })("pnpm", ["install", ...hoistedPatterns.flatMap((pattern) => ["--public-hoist-pattern", pattern])]);
216
+ spinner.succeed("Successfully installed dependencies");
217
+ } catch (e) {
218
+ spinner.fail("Failed to install dependencies");
219
+ handleError("init", e);
220
+ }
221
+ consola.success(chalk.green("\n🎉🎉🎉 VEF project created successfully !"));
222
+ console.log(chalk.blue("\n✨ Next steps:"));
223
+ console.log(chalk.cyan(` cd ${appName}`));
224
+ console.log(chalk.cyan(` pnpm dev`));
225
+ });
226
+ program.parse();
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ "use strict";
3
+ function defineCommitlintConfig() {
4
+ return {
5
+ extends: [
6
+ "@commitlint/config-conventional"
7
+ ],
8
+ formatter: "@commitlint/format"
9
+ };
10
+ }
11
+
12
+ export { defineCommitlintConfig };
package/esm/config.js ADDED
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ import consola from 'consola';
3
+ import fsExtra from 'fs-extra';
4
+ import { resolve } from 'node:path';
5
+ import { defineConfig as defineConfig$1, loadEnv } from 'vite';
6
+ import { ENV_DIR, ENV_BUILD_PREFIX } from './constants.js';
7
+ import { createAppConfigPlugin } from './plugin-app-config.js';
8
+ import { createConventionalConfigPlugin } from './plugin-conventional-config.js';
9
+ import { createEslintPlugin } from './plugin-eslint.js';
10
+ import { createHtmlPlugin } from './plugin-html.js';
11
+ import { createIconsPlugin } from './plugin-icons.js';
12
+ import { createInitializationPlugin } from './plugin-initialization.js';
13
+ import { createInjectionPlugin } from './plugin-injection.js';
14
+ import { createInspectPlugin } from './plugin-inspect.js';
15
+ import { createReactSwcPlugin } from './plugin-react-swc.js';
16
+ import { createRouterPlugin } from './plugin-router.js';
17
+ import { createStylelintPlugin } from './plugin-stylelint.js';
18
+ import { createSvgrPlugin } from './plugin-svgr.js';
19
+ import { createTailwindPlugin } from './plugin-tailwind.js';
20
+ import { createTailwindcssPlugin } from './plugin-tailwindcss.js';
21
+ import { createTsconfigPathsPlugin } from './plugin-tsconfig-paths.js';
22
+ import { createVisualizerPlugin } from './plugin-visualizer.js';
23
+ import { createWebfontPlugin } from './plugin-webfont.js';
24
+
25
+ "use strict";
26
+ const { readJson } = fsExtra;
27
+ function defineConfig({
28
+ projectDir,
29
+ proxies,
30
+ visualizer = false,
31
+ routerHistory = "browser",
32
+ autoCodeSplitting = true
33
+ }) {
34
+ return defineConfig$1(async ({ mode }) => {
35
+ const env = loadEnv(mode, ENV_DIR, ENV_BUILD_PREFIX);
36
+ if (Object.keys(env).length > 0) {
37
+ consola.info("Loaded environment variables:");
38
+ console.table(env);
39
+ }
40
+ const appVersion = await getAppVersion(projectDir);
41
+ return {
42
+ plugins: [
43
+ createInspectPlugin(),
44
+ createConventionalConfigPlugin({
45
+ appVersion,
46
+ projectDir,
47
+ basePublicPath: env.VEF_BUILD_BASE_PUBLIC_PATH,
48
+ outputDir: env.VEF_BUILD_OUTPUT_DIR,
49
+ serverPort: Number(env.VEF_BUILD_SERVER_PORT),
50
+ proxies
51
+ }),
52
+ createReactSwcPlugin(),
53
+ createTsconfigPathsPlugin(projectDir),
54
+ createHtmlPlugin(),
55
+ createTailwindPlugin(),
56
+ createTailwindcssPlugin(),
57
+ createInjectionPlugin(),
58
+ createAppConfigPlugin({
59
+ basePublicPath: env.VEF_BUILD_BASE_PUBLIC_PATH,
60
+ outputDir: env.VEF_BUILD_OUTPUT_DIR,
61
+ appName: env.VEF_APP_NAME
62
+ }),
63
+ createInitializationPlugin(),
64
+ createIconsPlugin(projectDir),
65
+ createSvgrPlugin(),
66
+ createWebfontPlugin(),
67
+ createRouterPlugin(projectDir, routerHistory, autoCodeSplitting),
68
+ createEslintPlugin(),
69
+ createStylelintPlugin(),
70
+ visualizer ? createVisualizerPlugin(projectDir) : void 0
71
+ ].filter(Boolean)
72
+ };
73
+ });
74
+ }
75
+ async function getAppVersion(projectDir) {
76
+ const packageJson = await readJson(resolve(projectDir, "package.json"), { encoding: "utf-8" });
77
+ return packageJson.version;
78
+ }
79
+
80
+ export { defineConfig };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ "use strict";
3
+ const PUBLIC_DIR = "public";
4
+ const ENV_DIR = "env";
5
+ const ASSETS_DIR = "assets";
6
+ const ENV_APP_PREFIX = "VEF_APP_";
7
+ const ENV_BUILD_PREFIX = "VEF_BUILD_";
8
+ const SRC_DIR = "src";
9
+ const DEFAULT_OUTPUT_DIR = "dist";
10
+ const DEFAULT_SERVER_PORT = 3833;
11
+ const DEFAULT_APP_NAME = "APP";
12
+ const PAGES_DIR = "pages";
13
+ const ROUTER_DIR = "router";
14
+
15
+ export { ASSETS_DIR, DEFAULT_APP_NAME, DEFAULT_OUTPUT_DIR, DEFAULT_SERVER_PORT, ENV_APP_PREFIX, ENV_BUILD_PREFIX, ENV_DIR, PAGES_DIR, PUBLIC_DIR, ROUTER_DIR, SRC_DIR };