@farris/cli 2.2.0-beta.1 → 2.2.0

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 (112) hide show
  1. package/bin/index.js +1 -1
  2. package/lib/commands/build-components.js +48 -48
  3. package/lib/commands/build-components.js.map +1 -1
  4. package/lib/commands/build-css.js +38 -38
  5. package/lib/commands/build-css.js.map +1 -1
  6. package/lib/commands/build-lib.js +25 -25
  7. package/lib/commands/build.js +14 -15
  8. package/lib/commands/build.js.map +1 -1
  9. package/lib/commands/create-app-options.js +75 -0
  10. package/lib/commands/create-app-options.js.map +1 -0
  11. package/lib/commands/create-app.js +123 -54
  12. package/lib/commands/create-app.js.map +1 -1
  13. package/lib/commands/dev-serve.js +18 -18
  14. package/lib/commands/extract-i18n.js +74 -74
  15. package/lib/commands/extract-i18n.js.map +1 -1
  16. package/lib/commands/generate/api.js +188 -0
  17. package/lib/commands/generate/api.js.map +1 -0
  18. package/lib/commands/generate/common.js +101 -0
  19. package/lib/commands/generate/common.js.map +1 -0
  20. package/lib/commands/generate/component.js +164 -0
  21. package/lib/commands/generate/component.js.map +1 -0
  22. package/lib/commands/generate/view.js +198 -0
  23. package/lib/commands/generate/view.js.map +1 -0
  24. package/lib/commands/preview-serve.js +16 -16
  25. package/lib/commands/workspace/add-app.js +181 -0
  26. package/lib/commands/workspace/add-app.js.map +1 -0
  27. package/lib/commands/workspace/create.js +380 -0
  28. package/lib/commands/workspace/create.js.map +1 -0
  29. package/lib/commands/workspace/inspect.js +31 -0
  30. package/lib/commands/workspace/inspect.js.map +1 -0
  31. package/lib/commands/workspace/verify.js +39 -0
  32. package/lib/commands/workspace/verify.js.map +1 -0
  33. package/lib/common/component-file-name.js +3 -3
  34. package/lib/common/constant.js +64 -22
  35. package/lib/common/constant.js.map +1 -1
  36. package/lib/common/generate-app.js +54 -51
  37. package/lib/common/generate-app.js.map +1 -1
  38. package/lib/common/get-dependencies.js +9 -9
  39. package/lib/common/get-farris-config.js +25 -25
  40. package/lib/common/get-farris-config.js.map +1 -1
  41. package/lib/common/get-version.js +6 -6
  42. package/lib/common/get-vite-config.js +106 -49
  43. package/lib/common/get-vite-config.js.map +1 -1
  44. package/lib/common/lib-package-exports.js +20 -20
  45. package/lib/common/list-lib-components.js +23 -23
  46. package/lib/common/list-lib-components.js.map +1 -1
  47. package/lib/common/output.js +95 -0
  48. package/lib/common/output.js.map +1 -0
  49. package/lib/common/project-package-name.js +5 -0
  50. package/lib/common/project-package-name.js.map +1 -0
  51. package/lib/common/safety.js +172 -0
  52. package/lib/common/safety.js.map +1 -0
  53. package/lib/common/template-manifest.js +16 -16
  54. package/lib/common/template-manifest.js.map +1 -1
  55. package/lib/common/template-renderer.js +115 -0
  56. package/lib/common/template-renderer.js.map +1 -0
  57. package/lib/common/transaction.js +84 -0
  58. package/lib/common/transaction.js.map +1 -0
  59. package/lib/common/verifier.js +151 -0
  60. package/lib/common/verifier.js.map +1 -0
  61. package/lib/config/vite-app.js +13 -13
  62. package/lib/config/vite-common.js +20 -20
  63. package/lib/config/vite-common.js.map +1 -1
  64. package/lib/config/vite-component.js +32 -32
  65. package/lib/config/vite-component.js.map +1 -1
  66. package/lib/config/vite-lib.js +26 -26
  67. package/lib/index.js +185 -87
  68. package/lib/index.js.map +1 -1
  69. package/lib/plugins/create-component-style.js +44 -44
  70. package/lib/plugins/create-package-json.js +48 -48
  71. package/lib/plugins/create-package-json.js.map +1 -1
  72. package/lib/plugins/dts.js +8 -8
  73. package/lib/plugins/html-system.js +9 -9
  74. package/lib/plugins/replace.js +17 -17
  75. package/lib/plugins/systemjs-bundle.js +15 -15
  76. package/lib/plugins/systemjs-bundle.js.map +1 -1
  77. package/package.json +12 -9
  78. package/templates/lib/.gitlab-ci.yml +85 -0
  79. package/templates/lib/README.md +1 -15
  80. package/templates/lib/components/button/button.spec.ts +8 -0
  81. package/templates/lib/index.html +12 -0
  82. package/templates/lib/package.json +6 -1
  83. package/templates/lib/src/App.vue +7 -0
  84. package/templates/lib/src/main.ts +4 -0
  85. package/templates/lib/vitest.config.ts +9 -0
  86. package/templates/mobile/.gitlab-ci.yml +88 -0
  87. package/templates/mobile/package.json +5 -1
  88. package/templates/mobile/project.json +4 -0
  89. package/templates/mobile/src/components/TheButton.spec.ts +8 -0
  90. package/templates/mobile/vitest.config.ts +9 -0
  91. package/templates/web/.gitlab-ci.yml +88 -0
  92. package/templates/web/package.json +5 -1
  93. package/templates/web/project.json +4 -0
  94. package/templates/web/src/components/TheButton.spec.ts +8 -0
  95. package/templates/web/vitest.config.ts +9 -0
  96. package/templates/workspace/app/farris.config.mjs +13 -0
  97. package/templates/workspace/app/index.html +12 -0
  98. package/templates/workspace/app/package.json +22 -0
  99. package/templates/workspace/app/src/App.tsx +11 -0
  100. package/templates/workspace/app/src/locales/index.ts +5 -0
  101. package/templates/workspace/app/src/locales/zh-CN.json +1 -0
  102. package/templates/workspace/app/src/main.ts +12 -0
  103. package/templates/workspace/app/src/router/index.ts +16 -0
  104. package/templates/workspace/app/src/styles/index.css +0 -0
  105. package/templates/workspace/app/src/styles/index.scss +0 -0
  106. package/templates/workspace/app/src/views/home/composables/use-home.ts +7 -0
  107. package/templates/workspace/app/src/views/home/home.component.tsx +15 -0
  108. package/templates/workspace/app/src/views/home/index.ts +4 -0
  109. package/templates/workspace/app/tsconfig.json +21 -0
  110. package/templates/workspace/root/README.md +28 -0
  111. package/templates/workspace/root/package.json +13 -0
  112. package/templates/workspace/root/pnpm-workspace.yaml +12 -0
@@ -0,0 +1,88 @@
1
+ image: registry.inspures.com/public/docker.io/library/node:22
2
+
3
+ variables:
4
+ PROJECT_ROOT: "."
5
+ NPM_REGISTRY: "https://repos.iec.io/repository/npm-igix/"
6
+ NPM_RELEASE_REGISTRY: "https://repos.iec.io/repository/npm-igix-release/"
7
+
8
+ stages:
9
+ - pre
10
+ - build
11
+ - publish
12
+ - publishproject
13
+
14
+ pre-job:
15
+ stage: pre
16
+ tags:
17
+ - environment:cloud
18
+ script:
19
+ - export commit_author=$(git log -1 --pretty=format:%an)
20
+ - export commit_email=$(git log -1 --pretty=format:%ce)
21
+
22
+ build-job:
23
+ stage: build
24
+ tags:
25
+ - environment:cloud
26
+ before_script:
27
+ - |
28
+ if [ -z "${ARTIFACTS_REPO_USERNAME}" ] || [ -z "${ARTIFACTS_REPO_PASSWORD}" ]; then
29
+ echo "ARTIFACTS_REPO_USERNAME or ARTIFACTS_REPO_PASSWORD is empty on ${CI_COMMIT_REF_NAME}."
30
+ echo "If these GitLab CI/CD variables are Protected, they are not available on unprotected branches."
31
+ exit 1
32
+ fi
33
+ - if [ ! -f .npmrc ]; then wget -O - https://repos.iec.io/gitlab-ci/template/experimental/script/npmrc | sh; fi
34
+ - echo _auth=$(echo -n ${ARTIFACTS_REPO_USERNAME}:${ARTIFACTS_REPO_PASSWORD} | base64) >> .npmrc
35
+ - echo always-auth=true >> .npmrc
36
+ - sed -i "s#registry=.*#registry=$NPM_REGISTRY#g" $CI_PROJECT_DIR/.npmrc
37
+ - cp .npmrc ~/
38
+ - npm config fix
39
+ script:
40
+ - npm i --no-package-lock
41
+ - npm test
42
+ - npm run build
43
+ artifacts:
44
+ expire_in: '5days'
45
+ name: 'dist'
46
+ paths:
47
+ - $CI_PROJECT_DIR/dist
48
+
49
+ publish-one:
50
+ stage: publish
51
+ tags:
52
+ - environment:cloud
53
+ only:
54
+ refs:
55
+ - cicd
56
+ changes:
57
+ - packages/**/package.json
58
+ script:
59
+ - echo "skip publish-one, app package is private"
60
+
61
+ publish-project:
62
+ stage: publishproject
63
+ tags:
64
+ - environment:cloud
65
+ only:
66
+ refs:
67
+ - cicd
68
+ changes:
69
+ - project.json
70
+ before_script:
71
+ - |
72
+ if [ -z "${ARTIFACTS_REPO_USERNAME}" ] || [ -z "${ARTIFACTS_REPO_PASSWORD}" ]; then
73
+ echo "ARTIFACTS_REPO_USERNAME or ARTIFACTS_REPO_PASSWORD is empty on ${CI_COMMIT_REF_NAME}."
74
+ echo "If these GitLab CI/CD variables are Protected, they are not available on unprotected branches."
75
+ exit 1
76
+ fi
77
+ - if [ ! -f .npmrc ]; then wget -O - https://repos.iec.io/gitlab-ci/template/experimental/script/npmrc | sh; fi
78
+ - echo _auth=$(echo -n ${ARTIFACTS_REPO_USERNAME}:${ARTIFACTS_REPO_PASSWORD} | base64) >> .npmrc
79
+ - echo always-auth=true >> .npmrc
80
+ - sed -i "s#registry=.*#registry=$NPM_RELEASE_REGISTRY#g" $CI_PROJECT_DIR/.npmrc
81
+ - cp .npmrc ~/
82
+ - npm config fix
83
+ script:
84
+ - npm config set //repos.iec.io/repository/npm-igix-release/:_auth=$(echo -n ${ARTIFACTS_REPO_USERNAME}:${ARTIFACTS_REPO_PASSWORD} | base64)
85
+ - cp ./project.json ./dist
86
+ - cd ./dist
87
+ - mv ./project.json ./package.json
88
+ - npm publish
@@ -9,6 +9,8 @@
9
9
  "preview": "farris-cli preview",
10
10
  "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
11
11
  "format": "prettier --write src/",
12
+ "test": "vitest run",
13
+ "test:watch": "vitest",
12
14
  "changeset": "changeset",
13
15
  "version": "changeset version"
14
16
  },
@@ -24,9 +26,11 @@
24
26
  "@vue/eslint-config-prettier": "^9.0.0",
25
27
  "@vue/eslint-config-typescript": "^13.0.0",
26
28
  "@vue/tsconfig": "^0.5.1",
29
+ "@vitejs/plugin-vue": "^4.0.0",
27
30
  "eslint": "^8.57.0",
28
31
  "eslint-plugin-vue": "^9.23.0",
29
32
  "prettier": "^3.2.5",
30
- "typescript": "~5.4.0"
33
+ "typescript": "~5.4.0",
34
+ "vitest": "^1.6.1"
31
35
  }
32
36
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "<%= projectPackageName %>",
3
+ "version": "0.0.0"
4
+ }
@@ -0,0 +1,8 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import TheButton from './TheButton.vue';
3
+
4
+ describe('TheButton', () => {
5
+ it('exports a component', () => {
6
+ expect(TheButton).toBeTruthy();
7
+ });
8
+ });
@@ -0,0 +1,9 @@
1
+ import vue from '@vitejs/plugin-vue';
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({
5
+ plugins: [vue()],
6
+ test: {
7
+ include: ['src/**/*.spec.ts']
8
+ }
9
+ });
@@ -0,0 +1,13 @@
1
+ import { fileURLToPath, URL } from 'node:url';
2
+
3
+ export default {
4
+ base: '<%= base %>',
5
+ routerMode: '<%= routerMode %>',
6
+ format: '<%= format %>',
7
+ minify: true,
8
+ externalDependencies: false,
9
+ alias: [
10
+ { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) }
11
+ ],
12
+ viteConfig: {}
13
+ };
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title><%= title %></title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "<%= appName %>",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "farris-cli dev",
8
+ "build": "farris-cli build",
9
+ "preview": "farris-cli preview",
10
+ "typecheck": "vue-tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "@farris/ui-vue": "catalog:",
14
+ "vue": "catalog:"<%= routerDependency %>
15
+ },
16
+ "devDependencies": {
17
+ "@farris/cli": "catalog:",
18
+ "typescript": "catalog:",
19
+ "vite": "catalog:",
20
+ "vue-tsc": "catalog:"<%= sassDevDependency %>
21
+ }
22
+ }
@@ -0,0 +1,11 @@
1
+ import { defineComponent } from 'vue';<%= appRouterImport %>
2
+
3
+ export default defineComponent({
4
+ name: 'App',
5
+ setup() {
6
+ return () => (
7
+ <%= appTemplateBody %>
8
+ );
9
+ }
10
+ });
11
+
@@ -0,0 +1,5 @@
1
+ import zhCN from './zh-CN.json';
2
+
3
+ export const localResources = {
4
+ 'zh-CN': zhCN
5
+ };
@@ -0,0 +1,12 @@
1
+ import { createApp } from 'vue';
2
+ import FarrisUI from '@farris/ui-vue';
3
+ import '@farris/ui-vue/index.css';<%= styleImport %><%= routerImport %>
4
+ import { localResources } from './locales';
5
+ import App from './App';
6
+
7
+ const app = createApp(App);
8
+
9
+ app.use(FarrisUI, { basePath: '', locale: 'zh-CN', localResources });<%= routerUse %>
10
+
11
+ app.mount('#app');
12
+
@@ -0,0 +1,16 @@
1
+ import { createRouter, <%= routerHistoryFunction %>, type RouteRecordRaw } from 'vue-router';
2
+
3
+ export const routes: RouteRecordRaw[] = [
4
+ {
5
+ path: '/',
6
+ name: 'Home',
7
+ component: () => import('../views/home')
8
+ },
9
+ ];
10
+
11
+ const router = createRouter({
12
+ history: <%= routerHistoryCall %>,
13
+ routes
14
+ });
15
+
16
+ export default router;
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ export function useHome() {
2
+ const title = '<%= title %>';
3
+
4
+ return {
5
+ title
6
+ };
7
+ }
@@ -0,0 +1,15 @@
1
+ import { defineComponent } from 'vue';
2
+ import { useHome } from './composables/use-home';
3
+
4
+ export default defineComponent({
5
+ name: 'HomeView',
6
+ setup() {
7
+ const { title } = useHome();
8
+
9
+ return () => (
10
+ <div class="f-page-home">
11
+ <h2>{title}</h2>
12
+ </div>
13
+ );
14
+ }
15
+ });
@@ -0,0 +1,4 @@
1
+ import HomeComponent from './home.component';
2
+
3
+ export { HomeComponent };
4
+ export default HomeComponent;
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "Node",
7
+ "strict": true,
8
+ "jsx": "preserve",
9
+ "jsxImportSource": "vue",
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "esModuleInterop": true,
13
+ "lib": ["ESNext", "DOM"],
14
+ "skipLibCheck": true,
15
+ "types": ["vite/client"],
16
+ "paths": {
17
+ "@/*": ["./src/*"]
18
+ }
19
+ },
20
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
21
+ }
@@ -0,0 +1,28 @@
1
+ # <%= title %>
2
+
3
+ 基于 Farris Vue 的前端工程 Workspace。
4
+
5
+ ## 目录结构
6
+
7
+ ```text
8
+ ├── packages/
9
+ │ └── <%= appDir %>/ # 应用源码
10
+ ├── pnpm-workspace.yaml # pnpm workspace 配置及 Catalog 依赖版本
11
+ └── package.json # 根工程脚本
12
+ ```
13
+
14
+ ## 快速上手
15
+
16
+ ```bash
17
+ # 安装依赖
18
+ pnpm install
19
+
20
+ # 启动开发服务器
21
+ pnpm --filter "<%= appName %>" dev
22
+
23
+ # 执行全量类型检查
24
+ pnpm typecheck
25
+
26
+ # 构建生产产物
27
+ pnpm build
28
+ ```
@@ -0,0 +1,13 @@
1
+ {
2
+ "private": true,
3
+ "packageManager": "pnpm@<%= pnpmVersion %>",
4
+ "engines": {
5
+ "node": "^18.0.0 || >=20.0.0",
6
+ "pnpm": ">=9.0.0 <10.0.0"
7
+ },
8
+ "scripts": {
9
+ "build": "pnpm --recursive --if-present run build",
10
+ "dev": "pnpm --recursive --if-present run dev",
11
+ "typecheck": "pnpm --recursive --if-present run typecheck"
12
+ }
13
+ }
@@ -0,0 +1,12 @@
1
+ packages:
2
+ - "packages/*"
3
+
4
+ catalog:
5
+ "@farris/ui-vue": "<%= farrisUiVueVersion %>"
6
+ "@farris/cli": "<%= farrisCliVersion %>"
7
+ "typescript": "<%= typescriptVersion %>"
8
+ "vite": "<%= viteVersion %>"
9
+ "vue": "<%= vueVersion %>"
10
+ "vue-router": "<%= vueRouterVersion %>"
11
+ "vue-tsc": "<%= vueTscVersion %>"
12
+ "sass": "<%= sassVersion %>"