@farris/cli 2.0.0-beta.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/bin/index.js +0 -0
  2. package/package.json +5 -3
  3. package/templates/mobile/farris.config.mjs +23 -23
  4. package/templates/{lib → web}/farris.config.mjs +23 -34
  5. package/templates/{lib → web}/package.json +4 -4
  6. package/templates/web/src/App.vue +80 -0
  7. package/templates/web/src/components/TheButton.vue +3 -0
  8. package/templates/{lib → web}/src/main.ts +3 -2
  9. package/templates/web/src/router/index.ts +23 -0
  10. package/templates/web/src/views/AboutView.vue +15 -0
  11. package/templates/web/src/views/HomeView.vue +9 -0
  12. package/templates/{lib → web}/tsconfig.json +5 -5
  13. package/lib/commands/build-components.js +0 -36
  14. package/lib/commands/build-css.js +0 -11
  15. package/lib/commands/build-lib.js +0 -16
  16. package/lib/commands/build.js +0 -10
  17. package/lib/commands/create-app.js +0 -54
  18. package/lib/commands/dev-serve.js +0 -23
  19. package/lib/commands/preview-serve.js +0 -16
  20. package/lib/common/constant.js +0 -18
  21. package/lib/common/generate-app.js +0 -44
  22. package/lib/common/get-dependencies.js +0 -9
  23. package/lib/common/get-farris-config.js +0 -11
  24. package/lib/common/get-version.js +0 -6
  25. package/lib/common/get-vite-config.js +0 -38
  26. package/lib/config/vite-app.js +0 -14
  27. package/lib/config/vite-lib.js +0 -35
  28. package/lib/index.js +0 -54
  29. package/lib/plugins/dts.js +0 -8
  30. package/lib/plugins/gen-component-style.js +0 -43
  31. package/lib/plugins/html-system.js +0 -11
  32. package/lib/plugins/replace.js +0 -13
  33. package/templates/lib/packages/button/src/index.vue +0 -4
  34. package/templates/lib/packages/index.ts +0 -7
  35. package/templates/lib/src/App.vue +0 -5
  36. /package/templates/{lib → web}/.eslintrc.cjs +0 -0
  37. /package/templates/{lib → web}/.prettierrc.json +0 -0
  38. /package/templates/{lib → web}/index.html +0 -0
package/bin/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@farris/cli",
3
3
  "private": false,
4
- "version": "2.0.0-beta.7",
4
+ "version": "2.0.0",
5
5
  "type": "module",
6
6
  "typings": "lib/index.d.ts",
7
7
  "bin": {
@@ -18,17 +18,19 @@
18
18
  "templates",
19
19
  "bin.js"
20
20
  ],
21
+ "license": "MIT",
21
22
  "dependencies": {
22
23
  "@types/inquirer": "^9.0.7",
23
24
  "@vitejs/plugin-vue": "^4.0.0",
24
25
  "@vitejs/plugin-vue-jsx": "^3.0.0",
25
26
  "commander": "^9.4.0",
27
+ "esbuild": "^0.23.0",
26
28
  "esbuild-sass-plugin": "^3.3.1",
27
29
  "inquirer": "^9.3.0",
30
+ "ora": "^8.0.1",
28
31
  "typescript": "^4.6.4",
29
32
  "vite": "^4.4.1",
30
- "vite-plugin-dts": "^3.9.1",
31
- "vite-plugin-html": "^3.2.2"
33
+ "vite-plugin-dts": "^3.9.1"
32
34
  },
33
35
  "devDependencies": {
34
36
  "@types/inquirer": "^9.0.7",
@@ -1,24 +1,24 @@
1
- import { fileURLToPath, URL } from 'node:url';
2
-
3
- export default {
4
- format: "<%= format %>",
5
- // 输出目录 App模式默认值 './dist' Lib模式 './lib'
6
- // outDir: fileURLToPath(new URL('./dist', import.meta.url)),
7
- // 最小化 默认值 true
8
- minify: true,
9
- // 外部依赖排除项 默认值 { include: [], exclude: [] }
10
- // externals: {
11
- // include: [],
12
- // exclude: []
13
- // },
14
- // 是否排除 package.json 中 dependencies和 peerDependencies 依赖的包; App模式默认值 false Lib模式默认值 true
15
- externalDependencies: false,
16
- // 路径别名 默认值 null
17
- alias: [
18
- { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }
19
- ],
20
- // 插件 默认值 [vue(), vueJsx()] 不要重复添加
21
- // plugins: [],
22
- // viteConfig 配置项
23
- viteConfig: {}
1
+ import { fileURLToPath, URL } from 'node:url';
2
+
3
+ export default {
4
+ format: "<%= format %>",
5
+ // 输出目录 App模式默认值 './dist' Lib模式 './lib'
6
+ // outDir: fileURLToPath(new URL('./dist', import.meta.url)),
7
+ // 最小化 默认值 true
8
+ minify: true,
9
+ // 外部依赖排除项 默认值 { include: [], exclude: [] }
10
+ // externals: {
11
+ // include: [],
12
+ // exclude: []
13
+ // },
14
+ // 是否排除 package.json 中 dependencies和 peerDependencies 依赖的包; App模式默认值 false Lib模式默认值 true
15
+ externalDependencies: false,
16
+ // 路径别名 默认值 null
17
+ alias: [
18
+ { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }
19
+ ],
20
+ // 插件 默认值 [vue(), vueJsx()] 不要重复添加
21
+ // plugins: [],
22
+ // viteConfig 配置项
23
+ viteConfig: {}
24
24
  }
@@ -1,35 +1,24 @@
1
- import { fileURLToPath, URL } from 'node:url';
2
-
3
- export default {
4
- // 库模式配置
5
- lib: {
6
- // 入口 默认值 './src/main.ts'
7
- entry: './packages/index.ts',
8
- // 库名称
9
- name: "<%= name %>",
10
- // 输出文件名
11
- fileName: "index",
12
- // 输出文件格式 默认值 ["es", 'systemjs']
13
- formats: <%= formats %>,
14
- },
15
- // 输出目录 App模式默认值 './dist' Lib模式 './lib'
16
- // outDir: fileURLToPath(new URL('./dist', import.meta.url)),
17
- // 最小化 默认值 true
18
- minify: true,
19
- // 外部依赖排除项 默认值 { include: [], exclude: [] }
20
- // externals: {
21
- // include: [],
22
- // exclude: []
23
- // },
24
- // 是否排除 package.json 中 dependencies和 peerDependencies 依赖的包; App模式默认值 false Lib模式默认值 true
25
- externalDependencies: true,
26
- // 路径别名 默认值 null
27
- alias: [
28
- { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
29
- { find: '@packages', replacement: fileURLToPath(new URL('./packages', import.meta.url)) },
30
- ],
31
- // 插件 默认值 [vue(), vueJsx()] 不要重复添加
32
- // plugins: [],
33
- // viteConfig 配置项
34
- viteConfig: {}
1
+ import { fileURLToPath, URL } from 'node:url';
2
+
3
+ export default {
4
+ format: "<%= format %>",
5
+ // 输出目录 App模式默认值 './dist' Lib模式 './lib'
6
+ // outDir: fileURLToPath(new URL('./dist', import.meta.url)),
7
+ // 最小化 默认值 true
8
+ minify: true,
9
+ // 外部依赖排除项 默认值 { include: [], exclude: [] }
10
+ // externals: {
11
+ // include: [],
12
+ // exclude: []
13
+ // },
14
+ // 是否排除 package.json 中 dependencies和 peerDependencies 依赖的包; App模式默认值 false Lib模式默认值 true
15
+ externalDependencies: false,
16
+ // 路径别名 默认值 null
17
+ alias: [
18
+ { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }
19
+ ],
20
+ // 插件 默认值 [vue(), vueJsx()] 不要重复添加
21
+ // plugins: [],
22
+ // viteConfig 配置项
23
+ viteConfig: {}
35
24
  }
@@ -3,17 +3,17 @@
3
3
  "version": "0.0.0",
4
4
  "private": true,
5
5
  "type": "module",
6
- "main": "./dist/index.umd.js",
7
- "module": "./dist/index.js",
8
6
  "scripts": {
9
7
  "dev": "farris-cli dev",
10
- "build": "farris-cli build-lib",
8
+ "build": "farris-cli build",
11
9
  "preview": "farris-cli preview",
12
10
  "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
13
11
  "format": "prettier --write src/"
14
12
  },
15
13
  "dependencies": {
16
- "vue": "^3.4.29"
14
+ "@farris/ui-vue": "latest",
15
+ "vue": "^3.4.29",
16
+ "vue-router": "^4.3.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@farris/cli": "<%= cliVersion %>",
@@ -0,0 +1,80 @@
1
+ <script setup lang="ts">
2
+ import { RouterLink, RouterView } from 'vue-router'
3
+ </script>
4
+
5
+ <template>
6
+ <header>
7
+ <div class="wrapper">
8
+ <nav>
9
+ <RouterLink to="/">Home</RouterLink>
10
+ <RouterLink to="/about">About</RouterLink>
11
+ </nav>
12
+ </div>
13
+ </header>
14
+
15
+ <RouterView />
16
+ </template>
17
+
18
+ <style scoped>
19
+ header {
20
+ line-height: 1.5;
21
+ max-height: 100vh;
22
+ }
23
+
24
+ .logo {
25
+ display: block;
26
+ margin: 0 auto 2rem;
27
+ }
28
+
29
+ nav {
30
+ width: 100%;
31
+ font-size: 12px;
32
+ text-align: center;
33
+ margin-top: 2rem;
34
+ }
35
+
36
+ nav a.router-link-exact-active {
37
+ color: var(--color-text);
38
+ }
39
+
40
+ nav a.router-link-exact-active:hover {
41
+ background-color: transparent;
42
+ }
43
+
44
+ nav a {
45
+ display: inline-block;
46
+ padding: 0 1rem;
47
+ border-left: 1px solid var(--color-border);
48
+ }
49
+
50
+ nav a:first-of-type {
51
+ border: 0;
52
+ }
53
+
54
+ @media (min-width: 1024px) {
55
+ header {
56
+ display: flex;
57
+ place-items: center;
58
+ padding-right: calc(var(--section-gap) / 2);
59
+ }
60
+
61
+ .logo {
62
+ margin: 0 2rem 0 0;
63
+ }
64
+
65
+ header .wrapper {
66
+ display: flex;
67
+ place-items: flex-start;
68
+ flex-wrap: wrap;
69
+ }
70
+
71
+ nav {
72
+ text-align: left;
73
+ margin-left: -1rem;
74
+ font-size: 1rem;
75
+
76
+ padding: 1rem 0;
77
+ margin-top: 1rem;
78
+ }
79
+ }
80
+ </style>
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <f-button>按钮</f-button>
3
+ </template>
@@ -1,9 +1,10 @@
1
1
  import { createApp } from 'vue'
2
+ import FarrisVue from '@farris/ui-vue'
2
3
  import App from './App.vue'
3
- import componentsLib from "@packages/index";
4
+ import router from './router'
4
5
 
5
6
  const app = createApp(App)
6
7
 
7
- app.use(componentsLib)
8
+ app.use(router).use(FarrisVue)
8
9
 
9
10
  app.mount('#app')
@@ -0,0 +1,23 @@
1
+ import { createRouter, createWebHistory } from 'vue-router'
2
+ import HomeView from '../views/HomeView.vue'
3
+
4
+ const router = createRouter({
5
+ history: createWebHistory(import.meta.env.BASE_URL),
6
+ routes: [
7
+ {
8
+ path: '/',
9
+ name: 'home',
10
+ component: HomeView
11
+ },
12
+ {
13
+ path: '/about',
14
+ name: 'about',
15
+ // route level code-splitting
16
+ // this generates a separate chunk (About.[hash].js) for this route
17
+ // which is lazy-loaded when the route is visited.
18
+ component: () => import('../views/AboutView.vue')
19
+ }
20
+ ]
21
+ })
22
+
23
+ export default router
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <div class="about">
3
+ <h1>This is an about page</h1>
4
+ </div>
5
+ </template>
6
+
7
+ <style>
8
+ @media (min-width: 1024px) {
9
+ .about {
10
+ min-height: 100vh;
11
+ display: flex;
12
+ align-items: center;
13
+ }
14
+ }
15
+ </style>
@@ -0,0 +1,9 @@
1
+ <script setup lang="ts">
2
+ import TheButton from '../components/TheButton.vue'
3
+ </script>
4
+
5
+ <template>
6
+ <main>
7
+ <TheButton />
8
+ </main>
9
+ </template>
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "extends": "@vue/tsconfig/tsconfig.dom.json",
3
3
  "include": [
4
+ "env.d.ts",
4
5
  "src/**/*",
5
- "src/**/*.vue",
6
- "packages/**/*",
7
- "packages/**/*.vue",
6
+ "src/**/*.vue"
8
7
  ],
9
8
  "compilerOptions": {
10
9
  "composite": true,
11
10
  "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
12
11
  "baseUrl": ".",
13
12
  "paths": {
14
- "@/*": ["src/*"],
15
- "@packages/*": ["packages/*"],
13
+ "@/*": [
14
+ "./src/*"
15
+ ]
16
16
  }
17
17
  }
18
18
  }
@@ -1,36 +0,0 @@
1
- import { readdirSync, lstatSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { buildCommon } from "./build.js";
4
- import { CWD } from "../common/constant.js";
5
- import { replace } from "../plugins/replace.js";
6
- import { genComponentStyle } from "../plugins/gen-component-style.js";
7
- export async function buildComponents(options) {
8
- const components = readdirSync("./components").filter((name) => {
9
- const componentDir = resolve(CWD, `./components`, name);
10
- const isDir = lstatSync(componentDir).isDirectory();
11
- return isDir && readdirSync(componentDir).includes("index.ts");
12
- });
13
- components.forEach(async (component) => {
14
- const entry = resolve(CWD, `./components/${component}/index.ts`);
15
- const outDir = resolve(CWD, `./package/${component}`);
16
- const config = {
17
- publicDir: false,
18
- build: {
19
- lib: {
20
- entry
21
- },
22
- outDir
23
- },
24
- plugins: [genComponentStyle(), replace((format, args) => `..${args[1]}/index.${format}.js`)]
25
- };
26
- console.log(`build ${component} begin`);
27
- await buildCommon({ ...options, config, type: 'lib' });
28
- console.log(`build ${component} success`);
29
- // const cssEntry = `./components/${component}/src/${component}.scss`;
30
- // if(!existsSync(cssEntry)) {
31
- // return;
32
- // }
33
- // await buildCss({...options,entry: cssEntry, outfile: `./package/${component}/index.css` });
34
- });
35
- }
36
- ;
@@ -1,11 +0,0 @@
1
- import { build } from "esbuild";
2
- import { sassPlugin } from 'esbuild-sass-plugin';
3
- export async function buildCss(options) {
4
- const { entry, outfile } = options;
5
- await build({
6
- entryPoints: [entry],
7
- outfile,
8
- bundle: true,
9
- plugins: [sassPlugin()],
10
- });
11
- }
@@ -1,16 +0,0 @@
1
- import { buildCommon } from "./build.js";
2
- import { generateTypes } from "../plugins/dts.js";
3
- export async function buildLib(options) {
4
- const { dts = false } = options;
5
- const config = {
6
- publicDir: false,
7
- plugins: [
8
- dts && generateTypes("./components", "./package/types")
9
- ]
10
- };
11
- console.log(`build lib begin`);
12
- await buildCommon({ ...options, config, type: 'lib' });
13
- console.log(`build lib success`);
14
- // await buildCss({...options, entry: "./components/index.scss", outfile: "./package/index.css"});
15
- }
16
- ;
@@ -1,10 +0,0 @@
1
- import { build, mergeConfig, loadConfigFromFile } from 'vite';
2
- import { getViteConfig } from '../common/get-vite-config.js';
3
- export async function buildCommon(options) {
4
- const { configFile, config, type } = options;
5
- const viteConfig = await loadConfigFromFile({ command: 'build', mode: 'production' }, configFile);
6
- const defaultConfig = await getViteConfig(type);
7
- const libConfig = mergeConfig(mergeConfig(defaultConfig, viteConfig ? viteConfig.config : {}), config);
8
- await build(libConfig);
9
- }
10
- ;
@@ -1,54 +0,0 @@
1
- import { generateApp } from "../common/generate-app.js";
2
- import inquirer from "inquirer";
3
- const prompt = inquirer.createPromptModule();
4
- const questions = [
5
- {
6
- type: "input",
7
- name: "name",
8
- message: "What is your project name?",
9
- default: "my-project",
10
- },
11
- {
12
- type: "list",
13
- name: "type",
14
- message: "What type of project is this?",
15
- choices: ["app", "lib"],
16
- },
17
- {
18
- type: "list",
19
- name: "platform",
20
- message: "What platform of project is this?",
21
- choices: ["pc", "mobile"],
22
- when: (response) => {
23
- const { type } = response;
24
- return type === 'app';
25
- }
26
- },
27
- {
28
- type: "checkbox",
29
- name: "formats",
30
- message: "What output format of project is this?",
31
- choices: ["es", "umd", "systemjs"],
32
- default: ["es", "umd"],
33
- when: (response) => {
34
- const { type } = response;
35
- return type === 'lib';
36
- }
37
- },
38
- {
39
- type: "list",
40
- name: "format",
41
- message: "What output format of project is this?",
42
- choices: ["es", "umd", "systemjs"],
43
- default: ["es"],
44
- when: (response) => {
45
- const { type } = response;
46
- return type === 'app';
47
- }
48
- }
49
- ];
50
- export async function createApp() {
51
- const response = await prompt(questions);
52
- generateApp(response);
53
- }
54
- ;
@@ -1,23 +0,0 @@
1
- import { createServer, mergeConfig } from 'vite';
2
- import { getViteConfig } from '../common/get-vite-config.js';
3
- export const devServe = async (options) => {
4
- const { port = 1337, host = true } = options;
5
- const config = await getViteConfig();
6
- const devConfig = mergeConfig({
7
- configFile: false,
8
- mode: 'dev',
9
- define: {
10
- __VUE_OPTIONS_API__: 'true',
11
- __VUE_PROD_DEVTOOLS__: 'true',
12
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true'
13
- },
14
- server: {
15
- port,
16
- host,
17
- hmr: true
18
- }
19
- }, config);
20
- const server = await createServer(devConfig);
21
- await server.listen();
22
- server.printUrls();
23
- };
@@ -1,16 +0,0 @@
1
- import { preview, mergeConfig } from 'vite';
2
- import { getViteConfig } from '../common/get-vite-config.js';
3
- export const previewServe = async (options) => {
4
- const { port = 4137, host = true } = options;
5
- const config = await getViteConfig();
6
- const previewConfig = mergeConfig({
7
- configFile: false,
8
- preview: {
9
- port,
10
- host,
11
- open: true
12
- }
13
- }, config);
14
- const server = await preview(previewConfig);
15
- server.printUrls();
16
- };
@@ -1,18 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
3
- import { join, dirname } from 'node:path';
4
- function findRootDir(dir) {
5
- if (existsSync(join(dir, 'farris.config.js'))) {
6
- return dir;
7
- }
8
- const parentDir = dirname(dir);
9
- if (dir === parentDir) {
10
- return dir;
11
- }
12
- return findRootDir(parentDir);
13
- }
14
- export const getDirname = (url) => fileURLToPath(new URL('.', url));
15
- // Root paths
16
- export const CWD = process.cwd();
17
- export const ROOT = findRootDir(CWD);
18
- export const FAARIS_CONFIG_FILE = join(CWD, 'farris.config.mjs');
@@ -1,44 +0,0 @@
1
- import { resolve } from 'path';
2
- import { createRequire } from "node:module";
3
- import { CWD, getDirname } from './constant.js';
4
- import { getVersion } from "./get-version.js";
5
- const require = createRequire(import.meta.url);
6
- const { copySync, readFileSync, writeFileSync } = require("fs-extra");
7
- const Array2String = (arr) => {
8
- return `[${arr.reduce((acc, cur, index) => {
9
- acc = index === 1 ? "'" + acc + "'" : acc;
10
- acc += `,'${cur}'`;
11
- return acc;
12
- })}]`;
13
- };
14
- const copyTemplate = (template, target) => {
15
- const templatePath = resolve(getDirname(import.meta.url), '../../templates', template);
16
- const targetPath = resolve(CWD, target);
17
- console.log(templatePath, targetPath);
18
- copySync(templatePath, targetPath);
19
- };
20
- const replaceContent = (path, args) => {
21
- let content = readFileSync(path, 'utf-8');
22
- Object.keys(args).forEach((key) => {
23
- const regexp = new RegExp(`<%= ${key} %>`, 'g');
24
- const value = Array.isArray(args[key]) ? Array2String(args[key]) : args[key];
25
- content = content.replace(regexp, value);
26
- });
27
- writeFileSync(path, content);
28
- };
29
- export const generateApp = (options) => {
30
- const { name, type, formats, format, platform } = options;
31
- const template = type === 'lib' ? 'lib' : platform;
32
- copyTemplate(template, name);
33
- const replaceFiles = [
34
- 'package.json',
35
- 'farris.config.mjs',
36
- 'index.html'
37
- ];
38
- const cliVersion = getVersion();
39
- replaceFiles.forEach(replaceFile => {
40
- replaceContent(resolve(CWD, name, replaceFile), { name, formats, format, platform, cliVersion });
41
- });
42
- console.log(`cd ${name}`);
43
- console.log(`npm install or yarn`);
44
- };
@@ -1,9 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { resolve } from 'node:path';
3
- import { CWD } from "../common/constant.js";
4
- export const getDependencies = () => {
5
- const pkg = readFileSync(resolve(CWD, 'package.json'), 'utf-8');
6
- const packageJson = JSON.parse(pkg);
7
- const { dependencies, peerDependencies } = packageJson;
8
- return [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {})];
9
- };
@@ -1,11 +0,0 @@
1
- import { pathToFileURL } from 'node:url';
2
- import { FAARIS_CONFIG_FILE } from './constant.js';
3
- async function getFarrisConfigAsync() {
4
- try {
5
- return (await import(pathToFileURL(FAARIS_CONFIG_FILE).href)).default;
6
- }
7
- catch (err) {
8
- return {};
9
- }
10
- }
11
- export { getFarrisConfigAsync };
@@ -1,6 +0,0 @@
1
- import { createRequire } from 'node:module';
2
- const require = createRequire(import.meta.url);
3
- const packageJson = require('../../package.json');
4
- export const getVersion = () => {
5
- return packageJson.version;
6
- };
@@ -1,38 +0,0 @@
1
- import { mergeConfig } from 'vite';
2
- import { getFarrisConfigAsync } from './get-farris-config.js';
3
- import { getDependencies } from '../common/get-dependencies.js';
4
- const formatFarrisConfig = (farrisConfig, type) => {
5
- const { lib, format, minify = true, externals = { include: [], exclude: [] }, externalDependencies, plugins, alias } = farrisConfig;
6
- const dependencies = externalDependencies ? getDependencies() : [];
7
- let external = externals.include ? [...externals.include, ...dependencies] : dependencies;
8
- external = external.filter(item => !externals.exclude?.includes(item));
9
- format && (process.env.FARRIS_FORMAT = format);
10
- const viteConfig = {
11
- build: {
12
- minify,
13
- lib: type === 'lib' ? lib : undefined,
14
- rollupOptions: {
15
- output: {
16
- format
17
- },
18
- external
19
- }
20
- },
21
- plugins,
22
- resolve: {
23
- alias
24
- }
25
- };
26
- return viteConfig;
27
- };
28
- const formatViteConfig = async (type) => {
29
- const { viteConfig = {}, ...farrisConfig } = await getFarrisConfigAsync();
30
- const customViteConfig = formatFarrisConfig(farrisConfig, type);
31
- return mergeConfig(customViteConfig, viteConfig);
32
- };
33
- const getViteConfig = async (type = 'app') => {
34
- const viteConfig = await formatViteConfig(type);
35
- const { default: defaultViteConfig } = await import(`../config/vite-${type}.js`);
36
- return mergeConfig(defaultViteConfig, viteConfig);
37
- };
38
- export { getViteConfig };
@@ -1,14 +0,0 @@
1
- import vue from '@vitejs/plugin-vue';
2
- import vueJsx from '@vitejs/plugin-vue-jsx';
3
- import { CWD } from '../common/constant.js';
4
- import { htmlSystemPlugin } from '../plugins/html-system.js';
5
- export default {
6
- root: CWD,
7
- base: './',
8
- // logLevel: 'silent',
9
- plugins: [
10
- vue(),
11
- vueJsx(),
12
- process.env.FARRIS_FORMAT === 'systemjs' && htmlSystemPlugin()
13
- ]
14
- };
@@ -1,35 +0,0 @@
1
- import vue from '@vitejs/plugin-vue';
2
- import vueJsx from '@vitejs/plugin-vue-jsx';
3
- import { CWD } from '../common/constant.js';
4
- import { resolve } from "node:path";
5
- export default {
6
- root: CWD,
7
- base: './',
8
- logLevel: 'silent',
9
- plugins: [vue(), vueJsx()],
10
- build: {
11
- lib: {
12
- entry: resolve(CWD, `./src/main.ts`),
13
- fileName: "index",
14
- formats: ["es", "systemjs"],
15
- },
16
- outDir: resolve(CWD, `./lib`),
17
- rollupOptions: {
18
- external: [],
19
- output: {
20
- exports: "named",
21
- globals: (id) => {
22
- if (id.includes('@components')) {
23
- const name = id.split('/').pop() || '';
24
- return name.slice(0, 1).toUpperCase() + name.slice(1);
25
- }
26
- const map = {
27
- vue: "Vue",
28
- '@farris/mobile-ui-vue': 'FarrisVue'
29
- };
30
- return map[id];
31
- }
32
- }
33
- },
34
- }
35
- };
package/lib/index.js DELETED
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import { getVersion } from "./common/get-version.js";
4
- const program = new Command();
5
- program.version(`@farris/cli ${getVersion()}`);
6
- program
7
- .command('build')
8
- .description('构建')
9
- .option('-c --configFile [configFile]', 'config file path')
10
- .action(async (options) => {
11
- const { buildCommon } = await import('./commands/build.js');
12
- return buildCommon(options);
13
- });
14
- program
15
- .command('build-lib')
16
- .description('构建')
17
- .option('-c --configFile [configFile]', 'config file path')
18
- .option('-d --dts', 'dts')
19
- .action(async (options) => {
20
- const { buildLib } = await import('./commands/build-lib.js');
21
- return buildLib(options);
22
- });
23
- program
24
- .command('build-components')
25
- .description('构建')
26
- .option('-c --configFile [configFile]', 'config file path')
27
- .action(async (options) => {
28
- const { buildComponents } = await import('./commands/build-components.js');
29
- return buildComponents(options);
30
- });
31
- program
32
- .command('create-app')
33
- .description('新建 App 模板')
34
- .action(async () => {
35
- const { createApp } = await import('./commands/create-app.js');
36
- return createApp();
37
- });
38
- program
39
- .command('dev')
40
- .description('创建 Dev Server')
41
- .option('-p --port [port]', 'Server Port')
42
- .action(async (options) => {
43
- const { devServe } = await import('./commands/dev-serve.js');
44
- return devServe(options);
45
- });
46
- program
47
- .command('preview')
48
- .description('创建 Preview Server')
49
- .option('-p --port [port]', 'Server Port')
50
- .action(async (options) => {
51
- const { previewServe } = await import('./commands/preview-serve.js');
52
- return previewServe(options);
53
- });
54
- program.parse();
@@ -1,8 +0,0 @@
1
- import dts from "vite-plugin-dts";
2
- export function generateTypes(entry, outDir) {
3
- return dts({
4
- entryRoot: entry,
5
- outDir
6
- });
7
- }
8
- ;
@@ -1,43 +0,0 @@
1
- const NotStyleComponents = ['designer-canvas', 'dynamic-view', 'dynamic-resolver', 'common'];
2
- const getComponentStyle = (imports) => {
3
- const components = imports
4
- .filter(path => {
5
- return path.startsWith('@components/') && !NotStyleComponents.find(notStylecomponent => path.includes(notStylecomponent));
6
- })
7
- .filter((item, index, array) => {
8
- return array.indexOf(item) === index;
9
- })
10
- .map(name => {
11
- const paths = name.split('/');
12
- return {
13
- name: paths[1],
14
- path: `../${paths[1]}/index.css`
15
- };
16
- });
17
- components.push({
18
- name: 'components',
19
- path: `./index.css`
20
- });
21
- const template = `${components.map(component => {
22
- const { path } = component;
23
- return `import '${path}';`;
24
- }).join('\n')}
25
- `;
26
- return template;
27
- };
28
- export function genComponentStyle() {
29
- return {
30
- name: 'farris-gen-component-style',
31
- renderChunk(code, chunk) {
32
- const { imports } = chunk;
33
- const template = getComponentStyle(imports);
34
- this.emitFile({
35
- type: 'asset',
36
- fileName: 'style.js',
37
- source: template
38
- });
39
- return code;
40
- }
41
- };
42
- }
43
- ;
@@ -1,11 +0,0 @@
1
- export const htmlSystemPlugin = () => {
2
- return {
3
- name: 'html-transform-system',
4
- transformIndexHtml(html) {
5
- const regexp = /<script.*type="module".*src="(.*?)"><\/script>/;
6
- return html.replace(regexp, (str, p1) => `
7
- <script src="https://cdn.bootcdn.net/ajax/libs/systemjs/6.15.1/system.js"></script>
8
- <script >System.import("${p1}");</script>`);
9
- }
10
- };
11
- };
@@ -1,13 +0,0 @@
1
- export function replace(path) {
2
- return {
3
- name: 'farris-replace',
4
- renderChunk(code, chunk) {
5
- const fileNames = chunk.fileName.split('.');
6
- const format = fileNames[fileNames.length - 2];
7
- return code.replace(/@components(\/\w+)/g, (...args) => {
8
- return path(format, args);
9
- });
10
- }
11
- };
12
- }
13
- ;
@@ -1,4 +0,0 @@
1
- <template>
2
- <div>button</div>
3
- </template>
4
-
@@ -1,7 +0,0 @@
1
- import Button from './button/src/index.vue'
2
-
3
- export default {
4
- install: (app) => {
5
- app.component('AppButton', Button)
6
- }
7
- }
@@ -1,5 +0,0 @@
1
- <template>
2
- <div>App</div>
3
- <app-button></app-button>
4
- </template>
5
-
File without changes
File without changes
File without changes