@qingtian/qtcli 1.0.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.
- package/README.md +193 -0
- package/dist/bin/cli.js +11 -0
- package/dist/package.json +209 -0
- package/dist/qt.conf.js +101 -0
- package/dist/src/App.js +10 -0
- package/dist/src/commands/build.js +74 -0
- package/dist/src/commands/dev.js +68 -0
- package/dist/src/commands/index.js +83 -0
- package/dist/src/commands/init.js +128 -0
- package/dist/src/cores/context.js +123 -0
- package/dist/src/index.js +29 -0
- package/dist/src/processEnv/index.js +23 -0
- package/dist/src/processEnv/injector.js +39 -0
- package/dist/src/processEnv/loader.js +201 -0
- package/dist/src/processEnv/manager.js +122 -0
- package/dist/src/processEnv/types.js +2 -0
- package/dist/src/proxys/build/index.js +225 -0
- package/dist/src/proxys/dev/index.js +284 -0
- package/dist/src/proxys/init/index.js +90 -0
- package/dist/src/servers/server.js +46 -0
- package/dist/src/types/baseInterface.js +46 -0
- package/dist/src/types/contextModel.js +21 -0
- package/dist/src/utils/childProcess.js +134 -0
- package/dist/src/utils/env.js +56 -0
- package/dist/src/utils/fileUtils.js +121 -0
- package/dist/src/utils/format.js +23 -0
- package/dist/src/utils/formatOutput.js +242 -0
- package/dist/src/utils/logger.js +70 -0
- package/dist/src/utils/printer.js +148 -0
- package/dist/src/utils/sleep.js +11 -0
- package/dist/src/utils/url.js +42 -0
- package/dist/src/webpack/npm/es.js +127 -0
- package/dist/src/webpack/npm/index.js +100 -0
- package/dist/src/webpack/npm/lib.js +128 -0
- package/dist/src/webpack/npm/webpack.base.js +221 -0
- package/dist/src/webpack/npm/webpack.prod.js +76 -0
- package/dist/src/webpack/plugins/DonePlugin.js +14 -0
- package/dist/src/webpack/plugins/FileListPlugin.js +28 -0
- package/dist/src/webpack/plugins/InjectScriptPlugin.js +33 -0
- package/dist/src/webpack/web/index.js +130 -0
- package/dist/src/webpack/web/webpack.analy.js +10 -0
- package/dist/src/webpack/web/webpack.base.js +419 -0
- package/dist/src/webpack/web/webpack.dev.js +38 -0
- package/dist/src/webpack/web/webpack.prod.js +82 -0
- package/package.json +209 -0
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# QTCli
|
|
2
|
+
|
|
3
|
+
QTCli 是一款基于 Node.js 的前端工程化底座,提供了完整的项目构建、开发和部署解决方案。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🚀 快速创建和初始化项目
|
|
8
|
+
- 📦 内置 Webpack 构建配置
|
|
9
|
+
- 🔥 支持 React + TypeScript 开发
|
|
10
|
+
- 🎨 支持 Less、Sass、CSS Modules
|
|
11
|
+
- 📱 支持移动端适配
|
|
12
|
+
- 🔍 内置 ESLint、StyleLint 代码规范检查
|
|
13
|
+
- 🛠 支持自定义配置和插件扩展
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g qtcli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 使用方法
|
|
22
|
+
|
|
23
|
+
### 查看帮助
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
qtcli --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 初始化项目
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
qtcli init [options]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 开发模式
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
qtcli dev [options]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 构建项目
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
qtcli build [options]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 全局选项
|
|
48
|
+
|
|
49
|
+
- `-V, --version`: 显示版本号
|
|
50
|
+
- `-D, --debug`: 启用调试模式
|
|
51
|
+
- `-h, --help`: 显示帮助信息
|
|
52
|
+
|
|
53
|
+
## 项目结构
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
my-project/
|
|
57
|
+
├── src/ # 源代码目录
|
|
58
|
+
├── public/ # 静态资源目录
|
|
59
|
+
├── dist/ # 构建输出目录
|
|
60
|
+
└── qt.conf.js # 项目配置文件
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 配置说明
|
|
64
|
+
|
|
65
|
+
在项目根目录创建 `qt.conf.js` 文件进行自定义配置:
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
export default {
|
|
69
|
+
// 构建类型
|
|
70
|
+
buildType: 'WEB',
|
|
71
|
+
|
|
72
|
+
// 解决方案名称
|
|
73
|
+
solutionName: 'my-project',
|
|
74
|
+
|
|
75
|
+
// 构建模式
|
|
76
|
+
buildMode: {
|
|
77
|
+
development: 'DEVELOPMENT',
|
|
78
|
+
production: 'PRODUCTION',
|
|
79
|
+
test: 'TEST',
|
|
80
|
+
analyze: 'ANALYZE'
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// 项目配置
|
|
84
|
+
config: {
|
|
85
|
+
// HTML 注入配置
|
|
86
|
+
htmlInject: {
|
|
87
|
+
head: [
|
|
88
|
+
// meta 标签
|
|
89
|
+
{
|
|
90
|
+
tag: 'meta',
|
|
91
|
+
attrs: {
|
|
92
|
+
charset: 'utf-8'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
tag: 'meta',
|
|
97
|
+
attrs: {
|
|
98
|
+
name: 'viewport',
|
|
99
|
+
content: 'width=device-width, initial-scale=1'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
// link 标签
|
|
103
|
+
{
|
|
104
|
+
tag: 'link',
|
|
105
|
+
attrs: {
|
|
106
|
+
rel: 'stylesheet',
|
|
107
|
+
href: '/static/css/global.css'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
body: [
|
|
112
|
+
// body 中的 script
|
|
113
|
+
{
|
|
114
|
+
tag: 'script',
|
|
115
|
+
attrs: {
|
|
116
|
+
src: '/static/js/init.js'
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
// JavaScript 代码片段注入配置
|
|
123
|
+
jsInject: {
|
|
124
|
+
head: [
|
|
125
|
+
{
|
|
126
|
+
code: `window.APP_CONFIG = {
|
|
127
|
+
version: '1.0.0',
|
|
128
|
+
env: '${process.env.NODE_ENV}',
|
|
129
|
+
apiUrl: '${process.env.API_URL}'
|
|
130
|
+
};`
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
body: [
|
|
134
|
+
{
|
|
135
|
+
code: `document.addEventListener('DOMContentLoaded', function() {
|
|
136
|
+
console.log('DOM loaded');
|
|
137
|
+
});`
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
// 环境变量配置
|
|
143
|
+
env: {
|
|
144
|
+
development: {
|
|
145
|
+
NODE_ENV: 'development',
|
|
146
|
+
API_URL: 'http://dev-api.example.com'
|
|
147
|
+
},
|
|
148
|
+
production: {
|
|
149
|
+
NODE_ENV: 'production',
|
|
150
|
+
API_URL: 'http://api.example.com'
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
// webpack 配置
|
|
156
|
+
webpackConfig: {
|
|
157
|
+
// 开发服务器配置
|
|
158
|
+
devServer: {
|
|
159
|
+
port: 3000,
|
|
160
|
+
host: 'localhost'
|
|
161
|
+
},
|
|
162
|
+
// 解析配置
|
|
163
|
+
resolve: {
|
|
164
|
+
alias: {
|
|
165
|
+
'@components': './src/components',
|
|
166
|
+
'@utils': './src/utils'
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
// 模块规则
|
|
170
|
+
module: {
|
|
171
|
+
rules: []
|
|
172
|
+
},
|
|
173
|
+
// 插件配置
|
|
174
|
+
plugins: []
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 开发环境要求
|
|
180
|
+
|
|
181
|
+
- Node.js >= 14.0.0
|
|
182
|
+
- npm >= 6.0.0
|
|
183
|
+
|
|
184
|
+
## 作者
|
|
185
|
+
|
|
186
|
+
- yujie.guo - 初始作者
|
|
187
|
+
|
|
188
|
+
## 问题反馈
|
|
189
|
+
|
|
190
|
+
如果你遇到任何问题或有任何建议,请通过以下方式联系我们:
|
|
191
|
+
|
|
192
|
+
- 提交 Issue: [GitHub Issues](https://gitee.com/fengrengame/qtnode/issues)
|
|
193
|
+
- 邮件联系: 296963166@qq.com
|
package/dist/bin/cli.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
// 设置内存限制
|
|
8
|
+
var index_1 = __importDefault(require("../src/commands/index"));
|
|
9
|
+
process.env.NODE_OPTIONS = '--max-old-space-size=12192';
|
|
10
|
+
// 执行入口
|
|
11
|
+
(0, index_1.default)();
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qingtian/qtcli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "QTCli是一款基于node的前端工程化底座",
|
|
5
|
+
"homepage": "https://gitee.com/fengrengame/qtnode#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://gitee.com/fengrengame/qtnode/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://gitee.com/fengrengame/qtnode.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"author": "yujie.guo",
|
|
15
|
+
"type": "commonjs",
|
|
16
|
+
"main": "./dist/bin/cli.js",
|
|
17
|
+
"bin": {
|
|
18
|
+
"qtcli": "./dist/bin/cli.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"keywords": [
|
|
25
|
+
"cli",
|
|
26
|
+
"frontend",
|
|
27
|
+
"build-tool",
|
|
28
|
+
"webpack",
|
|
29
|
+
"react"
|
|
30
|
+
],
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "rimraf ./dist && tsc -p .",
|
|
36
|
+
"clean": "rimraf ./dist",
|
|
37
|
+
"f2elint-fix": "f2elint fix",
|
|
38
|
+
"f2elint-scan": "f2elint scan",
|
|
39
|
+
"lint": "eslint .",
|
|
40
|
+
"lint:fix": "eslint --fix .",
|
|
41
|
+
"prepare": "husky install",
|
|
42
|
+
"prepublishOnly": "npm run build",
|
|
43
|
+
"start": "node --max-old-space-size=8192 ./node_modules/.bin/ts-node ./bin/cli.ts"
|
|
44
|
+
},
|
|
45
|
+
"commitlint": {
|
|
46
|
+
"extends": [
|
|
47
|
+
"ali"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"lint-staged": {
|
|
51
|
+
"*.{cjs,cts,js,jsx,mjs,mts,ts,tsx,vue}": "eslint --fix",
|
|
52
|
+
"*.{css,less,scss}": "stylelint --fix",
|
|
53
|
+
"*.{cjs,css,cts,html,js,json,jsx,less,md,mjs,mts,scss,ts,tsx,vue,yaml,yml}": "prettier --write"
|
|
54
|
+
},
|
|
55
|
+
"eslintConfig": {
|
|
56
|
+
"extends": [
|
|
57
|
+
"ali/typescript/node"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"stylelint": {},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@babel/cli": "7.24.6",
|
|
63
|
+
"@babel/core": "^7.16.0",
|
|
64
|
+
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
65
|
+
"@babel/plugin-proposal-decorators": "7.18.2",
|
|
66
|
+
"@babel/plugin-proposal-object-rest-spread": "7.20.7",
|
|
67
|
+
"@babel/plugin-syntax-flow": "7.24.6",
|
|
68
|
+
"@babel/plugin-transform-block-scoping": "7.27.0",
|
|
69
|
+
"@babel/plugin-transform-flow-strip-types": "7.24.6",
|
|
70
|
+
"@babel/plugin-transform-runtime": "7.18.5",
|
|
71
|
+
"@babel/plugin-transform-typescript": "7.24.6",
|
|
72
|
+
"@babel/preset-env": "7.18.2",
|
|
73
|
+
"@babel/preset-react": "7.17.12",
|
|
74
|
+
"@babel/preset-typescript": "7.17.12",
|
|
75
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
|
|
76
|
+
"@svgr/webpack": "^5.5.0",
|
|
77
|
+
"@types/react": "18.0.12",
|
|
78
|
+
"@types/react-dom": "18.0.5",
|
|
79
|
+
"autoprefixer": "10.4.7",
|
|
80
|
+
"babel-jest": "^27.4.2",
|
|
81
|
+
"babel-loader": "^8.2.3",
|
|
82
|
+
"babel-plugin-import": "1.13.8",
|
|
83
|
+
"babel-plugin-named-asset-import": "^0.3.8",
|
|
84
|
+
"babel-preset-react-app": "^10.0.1",
|
|
85
|
+
"bfj": "^7.0.2",
|
|
86
|
+
"browserslist": "^4.18.1",
|
|
87
|
+
"camelcase": "^6.2.1",
|
|
88
|
+
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
89
|
+
"cli-progress": "3.12.0",
|
|
90
|
+
"colors": "1.4.0",
|
|
91
|
+
"commander": "12.1.0",
|
|
92
|
+
"commitlint-config-ali": "1.1.0",
|
|
93
|
+
"compressing": "1.10.0",
|
|
94
|
+
"compression-webpack-plugin": "10.0.0",
|
|
95
|
+
"copy-webpack-plugin": "11.0.0",
|
|
96
|
+
"core-js": "3.23.0",
|
|
97
|
+
"cross-env": "7.0.3",
|
|
98
|
+
"css-loader": "^6.5.1",
|
|
99
|
+
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
100
|
+
"dotenv": "^10.0.0",
|
|
101
|
+
"dotenv-expand": "^5.1.0",
|
|
102
|
+
"eslint": "^8.3.0",
|
|
103
|
+
"eslint-config-ali": "15.1.0",
|
|
104
|
+
"eslint-config-prettier": "9.1.0",
|
|
105
|
+
"eslint-config-react-app": "^7.0.1",
|
|
106
|
+
"eslint-plugin-prettier": "5.2.6",
|
|
107
|
+
"eslint-webpack-plugin": "^3.1.1",
|
|
108
|
+
"extract-zip": "2.0.1",
|
|
109
|
+
"file-loader": "^6.2.0",
|
|
110
|
+
"fs-extra": "^10.0.0",
|
|
111
|
+
"glob-all": "3.3.1",
|
|
112
|
+
"html-webpack-plugin": "^5.5.0",
|
|
113
|
+
"husky": "8.0.3",
|
|
114
|
+
"identity-obj-proxy": "^3.0.0",
|
|
115
|
+
"inquirer": "8.0.0",
|
|
116
|
+
"jest": "^27.4.3",
|
|
117
|
+
"jest-resolve": "^27.4.2",
|
|
118
|
+
"jest-watch-typeahead": "^1.0.0",
|
|
119
|
+
"less": "4.1.3",
|
|
120
|
+
"less-loader": "11.0.0",
|
|
121
|
+
"lint-staged": "15.5.1",
|
|
122
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
123
|
+
"postcss": "^8.4.38",
|
|
124
|
+
"postcss-flexbugs-fixes": "^5.0.2",
|
|
125
|
+
"postcss-loader": "^6.2.1",
|
|
126
|
+
"postcss-normalize": "^10.0.1",
|
|
127
|
+
"postcss-preset-env": "^7.0.1",
|
|
128
|
+
"prettier": "3.5.3",
|
|
129
|
+
"prettier-config-ali": "1.3.2",
|
|
130
|
+
"progress": "2.0.3",
|
|
131
|
+
"progress-bar-webpack-plugin": "2.1.0",
|
|
132
|
+
"prompts": "^2.4.2",
|
|
133
|
+
"purgecss-webpack-plugin": "4.1.3",
|
|
134
|
+
"react": "^18.2.0",
|
|
135
|
+
"react-app-polyfill": "^3.0.0",
|
|
136
|
+
"react-dev-utils": "^12.0.1",
|
|
137
|
+
"react-dom": "^18.2.0",
|
|
138
|
+
"react-refresh": "^0.11.0",
|
|
139
|
+
"resolve": "^1.20.0",
|
|
140
|
+
"resolve-url-loader": "^4.0.0",
|
|
141
|
+
"rimraf": "5.0.7",
|
|
142
|
+
"sass": "1.70.0",
|
|
143
|
+
"sass-loader": "^12.3.0",
|
|
144
|
+
"semver": "^7.3.5",
|
|
145
|
+
"source-map-loader": "^3.0.0",
|
|
146
|
+
"speed-measure-webpack-plugin": "1.5.0",
|
|
147
|
+
"style-loader": "^3.3.1",
|
|
148
|
+
"stylelint": "16.19.1",
|
|
149
|
+
"stylelint-config-ali": "2.1.2",
|
|
150
|
+
"stylelint-prettier": "5.0.3",
|
|
151
|
+
"tailwindcss": "^3.0.2",
|
|
152
|
+
"terser-webpack-plugin": "^5.2.5",
|
|
153
|
+
"thread-loader": "3.0.4",
|
|
154
|
+
"ts-node": "10.9.2",
|
|
155
|
+
"typescript": "4.7.3",
|
|
156
|
+
"unzip": "0.1.11",
|
|
157
|
+
"url-loader": "4.1.1",
|
|
158
|
+
"webpack": "^5.64.4",
|
|
159
|
+
"webpack-bundle-analyzer": "4.5.0",
|
|
160
|
+
"webpack-cli": "4.9.2",
|
|
161
|
+
"webpack-dev-server": "^4.6.0",
|
|
162
|
+
"webpack-manifest-plugin": "^4.0.2",
|
|
163
|
+
"webpack-merge": "5.8.0",
|
|
164
|
+
"workbox-webpack-plugin": "^6.4.1",
|
|
165
|
+
"yamljs": "0.3.0"
|
|
166
|
+
},
|
|
167
|
+
"devDependencies": {
|
|
168
|
+
"@commitlint/cli": "^19.8.0",
|
|
169
|
+
"@types/autoprefixer": "10.2.0",
|
|
170
|
+
"@types/cli-progress": "3.11.5",
|
|
171
|
+
"@types/colors": "1.2.1",
|
|
172
|
+
"@types/commander": "2.12.2",
|
|
173
|
+
"@types/compression-webpack-plugin": "9.1.1",
|
|
174
|
+
"@types/copy-webpack-plugin": "10.1.0",
|
|
175
|
+
"@types/css-minimizer-webpack-plugin": "3.2.1",
|
|
176
|
+
"@types/extract-zip": "2.0.1",
|
|
177
|
+
"@types/glob": "^8.1.0",
|
|
178
|
+
"@types/html-webpack-plugin": "3.2.9",
|
|
179
|
+
"@types/inquirer": "9.0.7",
|
|
180
|
+
"@types/less": "3.0.6",
|
|
181
|
+
"@types/mini-css-extract-plugin": "2.5.1",
|
|
182
|
+
"@types/node": "14.18.47",
|
|
183
|
+
"@types/progress": "2.0.7",
|
|
184
|
+
"@types/progress-bar-webpack-plugin": "2.1.5",
|
|
185
|
+
"@types/react": "19.1.2",
|
|
186
|
+
"@types/react-dom": "19.1.2",
|
|
187
|
+
"@types/react-refresh": "0.14.6",
|
|
188
|
+
"@types/rimraf": "4.0.5",
|
|
189
|
+
"@types/speed-measure-webpack-plugin": "1.3.6",
|
|
190
|
+
"@types/typescript": "2.0.0",
|
|
191
|
+
"@types/unzip": "0.1.4",
|
|
192
|
+
"@types/webpack": "5.28.5",
|
|
193
|
+
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
194
|
+
"@types/webpack-dev-server": "4.7.2",
|
|
195
|
+
"@types/webpack-merge": "5.0.0",
|
|
196
|
+
"@types/yamljs": "0.2.34",
|
|
197
|
+
"commitlint-config-ali": "^1.1.0",
|
|
198
|
+
"eslint": "^8.56.0",
|
|
199
|
+
"eslint-config-ali": "^15.1.0",
|
|
200
|
+
"eslint-config-prettier": "^9.1.0",
|
|
201
|
+
"eslint-plugin-prettier": "^5.3.1",
|
|
202
|
+
"html-webpack-tags-plugin": "^3.0.0",
|
|
203
|
+
"husky": "^8.0.3",
|
|
204
|
+
"lint-staged": "^15.5.1",
|
|
205
|
+
"prettier": "^3.5.3",
|
|
206
|
+
"prettier-config-ali": "^1.3.4"
|
|
207
|
+
},
|
|
208
|
+
"email": "296963166@qq.com"
|
|
209
|
+
}
|
package/dist/qt.conf.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
buildType: 'WEB',
|
|
5
|
+
solutionName: 'qtnode',
|
|
6
|
+
buildMode: {
|
|
7
|
+
development: 'DEVELOPMENT',
|
|
8
|
+
production: 'PRODUCTION',
|
|
9
|
+
test: 'TEST',
|
|
10
|
+
analyze: 'ANALYZE',
|
|
11
|
+
},
|
|
12
|
+
config: {
|
|
13
|
+
// HTML 注入配置
|
|
14
|
+
htmlInject: {
|
|
15
|
+
head: [
|
|
16
|
+
// meta 标签
|
|
17
|
+
{
|
|
18
|
+
tag: 'meta',
|
|
19
|
+
attrs: {
|
|
20
|
+
charset: 'utf-83',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
tag: 'meta',
|
|
25
|
+
attrs: {
|
|
26
|
+
name: 'viewport3333',
|
|
27
|
+
content: 'width=device-width, initial-scale=1',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
// link 标签
|
|
31
|
+
{
|
|
32
|
+
tag: 'link',
|
|
33
|
+
attrs: {
|
|
34
|
+
rel: 'stylesheet',
|
|
35
|
+
href: '/static/css/global333.css',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
// head 中的 script
|
|
39
|
+
{
|
|
40
|
+
tag: 'script',
|
|
41
|
+
attrs: {
|
|
42
|
+
src: '/static/js/vendor333.js',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
body: [
|
|
47
|
+
// body 中的 script
|
|
48
|
+
{
|
|
49
|
+
tag: 'script',
|
|
50
|
+
attrs: {
|
|
51
|
+
src: '/static/js/init333.js',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
// JavaScript 代码片段注入配置
|
|
57
|
+
jsInject: {
|
|
58
|
+
head: [
|
|
59
|
+
{
|
|
60
|
+
code: "window.APP_CONFIG = {\n version: '1.0.0',\n env: '".concat(process.env.NODE_ENV, "',\n apiUrl: '").concat(process.env.API_URL, "'\n };"),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
code: "window.initGlobalConfig = function() {\n console.log('Global config initialized');\n };",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
body: [
|
|
67
|
+
{
|
|
68
|
+
code: "document.addEventListener('DOMContentLoaded', function() {\n console.log('DOM loaded');\n window.initGlobalConfig();\n });",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
code: "(function() {\n console.log('App initialized');\n })();",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
// 环境变量配置
|
|
76
|
+
env: {
|
|
77
|
+
development: {
|
|
78
|
+
NODE_ENV: 'development',
|
|
79
|
+
API_URL: 'http://dev-api.example.com',
|
|
80
|
+
},
|
|
81
|
+
production: {
|
|
82
|
+
NODE_ENV: 'production',
|
|
83
|
+
API_URL: 'http://api.example.com',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
// webpack 配置
|
|
88
|
+
webpackConfig: {
|
|
89
|
+
devServer: {},
|
|
90
|
+
resolve: {
|
|
91
|
+
alias: {
|
|
92
|
+
'@components': './src/components',
|
|
93
|
+
'@utils': './src/utils',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
module: {
|
|
97
|
+
rules: [],
|
|
98
|
+
},
|
|
99
|
+
plugins: [],
|
|
100
|
+
},
|
|
101
|
+
};
|
package/dist/src/App.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var App = function () {
|
|
8
|
+
return react_1.default.createElement('div', null, react_1.default.createElement('h1', null, 'Hello from JSX2!'), react_1.default.createElement('p', null, 'This is a test component'));
|
|
9
|
+
};
|
|
10
|
+
exports.default = App;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (_) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
var commander_1 = __importDefault(require("commander"));
|
|
44
|
+
var context_1 = require("../cores/context");
|
|
45
|
+
var contextModel_1 = require("../types/contextModel");
|
|
46
|
+
var logger_1 = require("../utils/logger");
|
|
47
|
+
exports.default = (function () {
|
|
48
|
+
var heat = new commander_1.default.Command('build');
|
|
49
|
+
heat
|
|
50
|
+
.description('执行代码构建')
|
|
51
|
+
.option('-t, --target <type>', '构建类型:web、npm', 'web')
|
|
52
|
+
.option('--analy', '是否打包分享', false)
|
|
53
|
+
.option('-e, --env <type>', '构建环境:development、production', false)
|
|
54
|
+
.action(function (options, cmd) { return __awaiter(void 0, void 0, void 0, function () {
|
|
55
|
+
var cm;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
try {
|
|
58
|
+
cm = new contextModel_1.ContextModel();
|
|
59
|
+
cm.cmd = cmd.name();
|
|
60
|
+
cm.proxy = cmd.name();
|
|
61
|
+
cm.argsCmd = options;
|
|
62
|
+
(0, logger_1.logStart)();
|
|
63
|
+
new context_1.Context(cm).run();
|
|
64
|
+
// logSuccess('构建完成');
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error(error);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
});
|
|
72
|
+
}); });
|
|
73
|
+
return heat;
|
|
74
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (_) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
var commander_1 = __importDefault(require("commander"));
|
|
44
|
+
var context_1 = require("../cores/context");
|
|
45
|
+
var contextModel_1 = require("../types/contextModel");
|
|
46
|
+
var logger_1 = require("../utils/logger");
|
|
47
|
+
exports.default = (function () {
|
|
48
|
+
var heat = new commander_1.default.Command('dev');
|
|
49
|
+
heat
|
|
50
|
+
.description('开启本地调试服务器')
|
|
51
|
+
.option('--https [http]', '启用https', false)
|
|
52
|
+
.option('-p, --port <port>', '绑定端口', false)
|
|
53
|
+
.option('-d, --domain <host>', '绑定域名', 'localhost')
|
|
54
|
+
.option('-o, --open <open>', '自动打开浏览器', false)
|
|
55
|
+
.action(function (options, cmd) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var cm;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
cm = new contextModel_1.ContextModel();
|
|
59
|
+
cm.cmd = cmd.name();
|
|
60
|
+
cm.proxy = cmd.name();
|
|
61
|
+
cm.argsCmd = options;
|
|
62
|
+
(0, logger_1.logStart)();
|
|
63
|
+
new context_1.Context(cm).run();
|
|
64
|
+
return [2 /*return*/];
|
|
65
|
+
});
|
|
66
|
+
}); });
|
|
67
|
+
return heat;
|
|
68
|
+
});
|