xiangjsoncraft 2.0.3 → 2.0.5
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/LICENSE +21 -201
- package/README.md +6 -3
- package/package.json +21 -10
- package/bin/create.js +0 -223
- package/rollup.config.js +0 -17
- package/template/config.json +0 -234
- package/template/index.html +0 -53
package/LICENSE
CHANGED
|
@@ -1,201 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dong Xiang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# XiangJsonCraft 2.0.
|
|
1
|
+
# XiangJsonCraft 2.0.4
|
|
2
2
|
|
|
3
3
|
**Write JSON, Get a Website.** | 零CSS、零JS、纯JSON驱动的轻量前端框架
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
由董翔开发的一款从「JSON渲染工具」升级而来的完整前端微框架,无需编写任何CSS、JS代码,仅通过编辑JSON配置文件,即可快速构建美观、响应式、带交互的完整网页,大幅降低前端开发门槛,非前端开发者也能轻松上手。
|
|
6
6
|
|
|
7
7
|
## 📢 重大升级说明(从 1.x → 2.0.0)
|
|
8
8
|
|
|
@@ -455,4 +455,7 @@ MIT License - 详见项目根目录 `LICENSE` 文件,可自由使用、修改
|
|
|
455
455
|
## ✨ 框架口号
|
|
456
456
|
|
|
457
457
|
**Write JSON, Get a Website.** | 只写 JSON,就能得到一个完整网站。
|
|
458
|
-
|
|
458
|
+
|
|
459
|
+
## 注意事项
|
|
460
|
+
- live-server依赖存在部分老旧包警告,仅影响开发阶段,不影响框架核心渲染;
|
|
461
|
+
- 生产环境建议使用npm run start:clean或替换为 vite/nginx。
|
package/package.json
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xiangjsoncraft",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "XiangJsonCraft 2.0
|
|
3
|
+
"version": "2.0.5",
|
|
4
|
+
"description": "XiangJsonCraft 2.0 - 纯JSON驱动的轻量级前端框架",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"author": "董翔 <3631247406@qq.com>",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"test": "echo \"XiangJsonCraft
|
|
9
|
-
"build": "rollup -c rollup.config.js"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"xiangjsoncraft": "^2.0.2"
|
|
8
|
+
"build": "rollup -c rollup.config.js",
|
|
9
|
+
"test": "echo \"XiangJsonCraft 框架测试成功!\""
|
|
13
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"src",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"README.md",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {},
|
|
14
19
|
"devDependencies": {
|
|
15
|
-
"live-server": "^1.2.2",
|
|
16
20
|
"rollup": "^4.57.1"
|
|
17
21
|
},
|
|
18
|
-
"license": "MIT"
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/dxiangwiki/xiangjsoncraft.git"
|
|
26
|
+
},
|
|
27
|
+
"__npminstall_done": true,
|
|
28
|
+
"_from": "xiangjsoncraft@2.0.4",
|
|
29
|
+
"_resolved": "https://registry.npmjs.org/xiangjsoncraft/-/xiangjsoncraft-2.0.4.tgz"
|
|
19
30
|
}
|
package/bin/create.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
import inquirer from 'inquirer';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import ora from 'ora';
|
|
8
|
-
|
|
9
|
-
// 解决 ESModule __dirname 问题
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const __dirname = path.dirname(__filename);
|
|
12
|
-
|
|
13
|
-
// 框架根目录
|
|
14
|
-
const frameworkRoot = path.resolve(__dirname, '..');
|
|
15
|
-
// 模板目录
|
|
16
|
-
const templateDir = path.join(frameworkRoot, 'template');
|
|
17
|
-
|
|
18
|
-
// 欢迎信息
|
|
19
|
-
console.log(chalk.blue(`
|
|
20
|
-
┌─────────────────────────────────┐
|
|
21
|
-
│ XiangJsonCraft 2.0.1 │
|
|
22
|
-
│ Write JSON, Get a Website │
|
|
23
|
-
└─────────────────────────────────┘
|
|
24
|
-
`));
|
|
25
|
-
|
|
26
|
-
// 第一步:获取项目名称(从命令行参数)
|
|
27
|
-
const args = process.argv.slice(2);
|
|
28
|
-
let projectName = args[0] || 'xiangjsoncraft-app';
|
|
29
|
-
|
|
30
|
-
// 第二步:确认创建项目
|
|
31
|
-
const confirmAnswers = await inquirer.prompt([
|
|
32
|
-
{
|
|
33
|
-
type: 'confirm',
|
|
34
|
-
name: 'confirmCreate',
|
|
35
|
-
message: `是否要创建项目「${projectName}」?`,
|
|
36
|
-
default: true
|
|
37
|
-
}
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
|
-
if (!confirmAnswers.confirmCreate) {
|
|
41
|
-
console.log(chalk.yellow('✅ 项目创建已取消'));
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 第三步:选择模板(仅保留基础模板,确保核心功能)
|
|
46
|
-
const templateAnswers = await inquirer.prompt([
|
|
47
|
-
{
|
|
48
|
-
type: 'list',
|
|
49
|
-
name: 'template',
|
|
50
|
-
message: '请选择项目模板:',
|
|
51
|
-
choices: [
|
|
52
|
-
{ name: '基础模板(快速上手)', value: 'basic' }
|
|
53
|
-
],
|
|
54
|
-
default: 'basic'
|
|
55
|
-
}
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
|
-
// 第四步:创建项目
|
|
59
|
-
const spinner = ora('正在创建项目...').start();
|
|
60
|
-
try {
|
|
61
|
-
// 项目目标目录
|
|
62
|
-
const projectDir = path.resolve(process.cwd(), projectName);
|
|
63
|
-
|
|
64
|
-
// 检查目录是否已存在
|
|
65
|
-
if (fs.existsSync(projectDir)) {
|
|
66
|
-
spinner.fail(chalk.red('❌ 项目目录已存在,请删除后重试'));
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 1. 创建项目目录
|
|
71
|
-
fs.ensureDirSync(projectDir);
|
|
72
|
-
|
|
73
|
-
// 2. 生成 package.json(修复本地路径依赖问题)
|
|
74
|
-
// 生成 package.json(核心:删除本地路径,改用 npm 版本)
|
|
75
|
-
const packageJson = {
|
|
76
|
-
"name": projectName,
|
|
77
|
-
"version": "1.0.0",
|
|
78
|
-
"description": "XiangJsonCraft 项目",
|
|
79
|
-
"type": "module",
|
|
80
|
-
"scripts": {
|
|
81
|
-
"start": "npx serve .",
|
|
82
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
83
|
-
},
|
|
84
|
-
"dependencies": {
|
|
85
|
-
|
|
86
|
-
"xiangjsoncraft": "^2.0.1"
|
|
87
|
-
},
|
|
88
|
-
"license": "MIT"
|
|
89
|
-
};
|
|
90
|
-
fs.writeJsonSync(path.join(projectDir, 'package.json'), packageJson, { spaces: 2 });
|
|
91
|
-
|
|
92
|
-
// 3. 生成核心文件(解决空壳问题)
|
|
93
|
-
// 3.1 生成 index.html(核心入口)
|
|
94
|
-
const indexHtml = `<!DOCTYPE html>
|
|
95
|
-
<html lang="zh-CN">
|
|
96
|
-
<head>
|
|
97
|
-
<meta charset="UTF-8">
|
|
98
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
99
|
-
<title>${projectName} - XiangJsonCraft 2.0</title>
|
|
100
|
-
<!-- 引入框架核心 -->
|
|
101
|
-
<script src="./node_modules/xiangjsoncraft/dist/xiangjsoncraft.umd.js"></script>
|
|
102
|
-
</head>
|
|
103
|
-
<body>
|
|
104
|
-
<div id="app"></div>
|
|
105
|
-
<!-- 引入配置文件 -->
|
|
106
|
-
<script type="module">
|
|
107
|
-
import config from './config.json' assert { type: 'json' };
|
|
108
|
-
// 渲染 JSON 配置
|
|
109
|
-
window.XiangJsonCraft.render(config, document.getElementById('app'));
|
|
110
|
-
</script>
|
|
111
|
-
</body>
|
|
112
|
-
</html>`;
|
|
113
|
-
fs.writeFileSync(path.join(projectDir, 'index.html'), indexHtml);
|
|
114
|
-
|
|
115
|
-
// 3.2 生成 config.json(核心配置文件)
|
|
116
|
-
const configJson = {
|
|
117
|
-
"framework": "XiangJsonCraft 2.0.1",
|
|
118
|
-
"styles": {
|
|
119
|
-
"body": {
|
|
120
|
-
"backgroundColor": "#f0f4f8",
|
|
121
|
-
"minHeight": "100vh",
|
|
122
|
-
"margin": "0",
|
|
123
|
-
"padding": "20px",
|
|
124
|
-
"fontFamily": "Arial, sans-serif"
|
|
125
|
-
},
|
|
126
|
-
"#app": {
|
|
127
|
-
"maxWidth": "1200px",
|
|
128
|
-
"margin": "0 auto"
|
|
129
|
-
},
|
|
130
|
-
".app-title": {
|
|
131
|
-
"fontSize": "2rem",
|
|
132
|
-
"color": "#2d3748",
|
|
133
|
-
"textAlign": "center",
|
|
134
|
-
"marginBottom": "40px"
|
|
135
|
-
},
|
|
136
|
-
".app-desc": {
|
|
137
|
-
"fontSize": "1.2rem",
|
|
138
|
-
"color": "#4a5568",
|
|
139
|
-
"textAlign": "center"
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
"content": {
|
|
143
|
-
".app-title": {
|
|
144
|
-
"value": "欢迎使用 XiangJsonCraft 2.0.1",
|
|
145
|
-
"isHtml": false
|
|
146
|
-
},
|
|
147
|
-
".app-desc": {
|
|
148
|
-
"value": "零CSS零JS、纯JSON驱动的轻量前端框架",
|
|
149
|
-
"isHtml": false
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
fs.writeJsonSync(path.join(projectDir, 'config.json'), configJson, { spaces: 2 });
|
|
154
|
-
|
|
155
|
-
// 3.3 生成 README.md(使用说明)
|
|
156
|
-
const readmeMd = `# ${projectName}
|
|
157
|
-
基于 XiangJsonCraft 2.0.1 的项目
|
|
158
|
-
|
|
159
|
-
## 快速开始
|
|
160
|
-
1. 安装依赖:
|
|
161
|
-
npm install
|
|
162
|
-
|
|
163
|
-
2. 启动开发服务器:
|
|
164
|
-
npm run start
|
|
165
|
-
|
|
166
|
-
3. 自定义项目:
|
|
167
|
-
修改 config.json 文件(所有样式/内容/交互都在这里配置)
|
|
168
|
-
|
|
169
|
-
## 核心特性
|
|
170
|
-
- 纯 JSON 驱动,无需编写 CSS/JS
|
|
171
|
-
- 响应式布局,适配所有设备
|
|
172
|
-
- 实时热更新,修改配置立即生效
|
|
173
|
-
- 零配置部署,直接上传文件即可发布
|
|
174
|
-
`;
|
|
175
|
-
fs.writeFileSync(path.join(projectDir, 'README.md'), readmeMd);
|
|
176
|
-
|
|
177
|
-
spinner.succeed(chalk.green(`✅ 项目「${projectName}」创建成功!`));
|
|
178
|
-
|
|
179
|
-
// 第五步:安装依赖提示
|
|
180
|
-
const installAnswers = await inquirer.prompt([
|
|
181
|
-
{
|
|
182
|
-
type: 'confirm',
|
|
183
|
-
name: 'confirmInstall',
|
|
184
|
-
message: '是否立即安装项目依赖?',
|
|
185
|
-
default: true
|
|
186
|
-
}
|
|
187
|
-
]);
|
|
188
|
-
|
|
189
|
-
if (installAnswers.confirmInstall) {
|
|
190
|
-
const installSpinner = ora('正在安装依赖...').start();
|
|
191
|
-
try {
|
|
192
|
-
// 切换到项目目录执行安装
|
|
193
|
-
const { execSync } = await import('child_process');
|
|
194
|
-
execSync('npm install --legacy-peer-deps', {
|
|
195
|
-
cwd: projectDir,
|
|
196
|
-
stdio: 'ignore'
|
|
197
|
-
});
|
|
198
|
-
installSpinner.succeed(chalk.green('✅ 依赖安装成功!'));
|
|
199
|
-
} catch (err) {
|
|
200
|
-
installSpinner.fail(chalk.yellow('⚠️ 依赖安装失败,请手动进入项目目录执行 npm install --legacy-peer-deps'));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// 输出使用指南
|
|
205
|
-
console.log(chalk.cyan(`
|
|
206
|
-
使用指南
|
|
207
|
-
1. 进入项目目录:
|
|
208
|
-
cd ${projectName}
|
|
209
|
-
2. 启动开发服务器:
|
|
210
|
-
npm run start
|
|
211
|
-
3. 自定义项目:
|
|
212
|
-
修改 config.json 文件(所有样式/内容/交互都在这里配置)
|
|
213
|
-
4. 部署上线:
|
|
214
|
-
直接将项目文件上传到服务器即可,无需打包
|
|
215
|
-
|
|
216
|
-
📚 官方文档:https://github.com/dxiangwiki/xiangjsoncraft
|
|
217
|
-
💡 提示:必须使用本地服务器运行,不能直接打开HTML文件!
|
|
218
|
-
`));
|
|
219
|
-
|
|
220
|
-
} catch (err) {
|
|
221
|
-
spinner.fail(chalk.red(`❌ 项目创建失败:${err.message}`));
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
package/rollup.config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import terser from '@rollup/plugin-terser';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
input: 'src/renderJson.js', // 你的核心渲染文件
|
|
5
|
-
output: {
|
|
6
|
-
file: 'dist/xiangjsoncraft.umd.js',
|
|
7
|
-
format: 'umd', // UMD 格式兼容浏览器/Node.js
|
|
8
|
-
name: 'XiangJsonCraft', // 全局变量名,对应 window.XiangJsonCraft
|
|
9
|
-
globals: {},
|
|
10
|
-
// ✅ 确保打包后的代码兼容低版本浏览器
|
|
11
|
-
compact: true,
|
|
12
|
-
sourcemap: false
|
|
13
|
-
},
|
|
14
|
-
plugins: [
|
|
15
|
-
terser() // 压缩但不改变语法
|
|
16
|
-
]
|
|
17
|
-
};
|
package/template/config.json
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"styles": {
|
|
3
|
-
"*": {
|
|
4
|
-
"margin": "0",
|
|
5
|
-
"padding": "0",
|
|
6
|
-
"boxSizing": "border-box",
|
|
7
|
-
"fontFamily": "'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif"
|
|
8
|
-
},
|
|
9
|
-
"body": {
|
|
10
|
-
"backgroundColor": "#f0f4f8",
|
|
11
|
-
"color": "#334e68",
|
|
12
|
-
"lineHeight": "1.6",
|
|
13
|
-
"transition": "backgroundColor 0.5s ease",
|
|
14
|
-
"minHeight": "100vh"
|
|
15
|
-
},
|
|
16
|
-
".welcome-container": {
|
|
17
|
-
"maxWidth": "1200px",
|
|
18
|
-
"margin": "0 auto",
|
|
19
|
-
"padding": "20px"
|
|
20
|
-
},
|
|
21
|
-
".welcome-header": {
|
|
22
|
-
"textAlign": "center",
|
|
23
|
-
"padding": "60px 20px",
|
|
24
|
-
"marginBottom": "40px",
|
|
25
|
-
"borderRadius": "12px",
|
|
26
|
-
"background": "linear-gradient(135deg, #4299e1, #63b3ed)",
|
|
27
|
-
"color": "white",
|
|
28
|
-
"boxShadow": "0 10px 25px -5px rgba(66, 153, 225, 0.3)",
|
|
29
|
-
"transition": "transform 0.5s ease, boxShadow 0.5s ease"
|
|
30
|
-
},
|
|
31
|
-
".welcome-header:hover": {
|
|
32
|
-
"transform": "translateY(-5px)",
|
|
33
|
-
"boxShadow": "0 15px 30px -8px rgba(66, 153, 225, 0.4)"
|
|
34
|
-
},
|
|
35
|
-
".logo-container": {
|
|
36
|
-
"marginBottom": "30px"
|
|
37
|
-
},
|
|
38
|
-
".logo": {
|
|
39
|
-
"width": "120px",
|
|
40
|
-
"height": "120px",
|
|
41
|
-
"margin": "0 auto",
|
|
42
|
-
"backgroundColor": "white",
|
|
43
|
-
"borderRadius": "50%",
|
|
44
|
-
"display": "flex",
|
|
45
|
-
"alignItems": "center",
|
|
46
|
-
"justifyContent": "center",
|
|
47
|
-
"fontSize": "48px",
|
|
48
|
-
"color": "#4299e1",
|
|
49
|
-
"boxShadow": "0 4px 12px rgba(0, 0, 0, 0.1)"
|
|
50
|
-
},
|
|
51
|
-
".logo::after": {
|
|
52
|
-
"content": "'J'",
|
|
53
|
-
"fontWeight": "bold"
|
|
54
|
-
},
|
|
55
|
-
".main-title": {
|
|
56
|
-
"fontSize": "2.5rem",
|
|
57
|
-
"marginBottom": "15px",
|
|
58
|
-
"textShadow": "0 2px 4px rgba(0, 0, 0, 0.1)"
|
|
59
|
-
},
|
|
60
|
-
"@media (maxWidth: 768px)": {
|
|
61
|
-
".main-title": {
|
|
62
|
-
"fontSize": "2rem"
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
".subtitle": {
|
|
66
|
-
"fontSize": "1.1rem",
|
|
67
|
-
"opacity": "0.9",
|
|
68
|
-
"maxWidth": "600px",
|
|
69
|
-
"margin": "0 auto"
|
|
70
|
-
},
|
|
71
|
-
".features-section": {
|
|
72
|
-
"display": "grid",
|
|
73
|
-
"gridTemplateColumns": "repeat(auto-fit, minmax(300px, 1fr))",
|
|
74
|
-
"gap": "30px",
|
|
75
|
-
"marginBottom": "60px"
|
|
76
|
-
},
|
|
77
|
-
".feature-card": {
|
|
78
|
-
"backgroundColor": "white",
|
|
79
|
-
"borderRadius": "12px",
|
|
80
|
-
"padding": "30px",
|
|
81
|
-
"boxShadow": "0 4px 12px rgba(0, 0, 0, 0.05)",
|
|
82
|
-
"transition": "transform 0.3s ease, boxShadow 0.3s ease"
|
|
83
|
-
},
|
|
84
|
-
".feature-card:hover": {
|
|
85
|
-
"transform": "translateY(-8px)",
|
|
86
|
-
"boxShadow": "0 12px 20px rgba(0, 0, 0, 0.08)"
|
|
87
|
-
},
|
|
88
|
-
".feature-icon": {
|
|
89
|
-
"width": "60px",
|
|
90
|
-
"height": "60px",
|
|
91
|
-
"borderRadius": "12px",
|
|
92
|
-
"backgroundColor": "#ebf8ff",
|
|
93
|
-
"color": "#4299e1",
|
|
94
|
-
"display": "flex",
|
|
95
|
-
"alignItems": "center",
|
|
96
|
-
"justifyContent": "center",
|
|
97
|
-
"fontSize": "24px",
|
|
98
|
-
"marginBottom": "20px"
|
|
99
|
-
},
|
|
100
|
-
".feature-title": {
|
|
101
|
-
"fontSize": "1.3rem",
|
|
102
|
-
"marginBottom": "15px",
|
|
103
|
-
"color": "#2d3748"
|
|
104
|
-
},
|
|
105
|
-
".feature-description": {
|
|
106
|
-
"color": "#718096",
|
|
107
|
-
"lineHeight": "1.7"
|
|
108
|
-
},
|
|
109
|
-
".action-section": {
|
|
110
|
-
"textAlign": "center",
|
|
111
|
-
"marginBottom": "80px"
|
|
112
|
-
},
|
|
113
|
-
".primary-button": {
|
|
114
|
-
"backgroundColor": "#4299e1",
|
|
115
|
-
"color": "white",
|
|
116
|
-
"border": "none",
|
|
117
|
-
"borderRadius": "8px",
|
|
118
|
-
"padding": "14px 32px",
|
|
119
|
-
"fontSize": "1rem",
|
|
120
|
-
"fontWeight": "600",
|
|
121
|
-
"cursor": "pointer",
|
|
122
|
-
"transition": "all 0.3s ease",
|
|
123
|
-
"boxShadow": "0 4px 6px rgba(66, 153, 225, 0.2)"
|
|
124
|
-
},
|
|
125
|
-
".primary-button:hover": {
|
|
126
|
-
"backgroundColor": "#3182ce",
|
|
127
|
-
"transform": "translateY(-2px)",
|
|
128
|
-
"boxShadow": "0 6px 10px rgba(66, 153, 225, 0.3)"
|
|
129
|
-
},
|
|
130
|
-
".additional-info": {
|
|
131
|
-
"marginTop": "15px",
|
|
132
|
-
"color": "#718096",
|
|
133
|
-
"fontSize": "0.95rem"
|
|
134
|
-
},
|
|
135
|
-
".page-footer": {
|
|
136
|
-
"textAlign": "center",
|
|
137
|
-
"paddingTop": "30px",
|
|
138
|
-
"borderTop": "1px solid #e2e8f0",
|
|
139
|
-
"color": "#718096"
|
|
140
|
-
},
|
|
141
|
-
".copyright": {
|
|
142
|
-
"marginBottom": "15px",
|
|
143
|
-
"fontSize": "0.9rem"
|
|
144
|
-
},
|
|
145
|
-
".social-links": {
|
|
146
|
-
"display": "flex",
|
|
147
|
-
"justifyContent": "center",
|
|
148
|
-
"gap": "15px"
|
|
149
|
-
},
|
|
150
|
-
".social-icon": {
|
|
151
|
-
"color": "#718096",
|
|
152
|
-
"fontSize": "1.2rem",
|
|
153
|
-
"transition": "color 0.3s ease"
|
|
154
|
-
},
|
|
155
|
-
".social-icon:hover": {
|
|
156
|
-
"color": "#4299e1"
|
|
157
|
-
},
|
|
158
|
-
"body:not(.loaded) .welcome-header": {
|
|
159
|
-
"opacity": "0",
|
|
160
|
-
"transform": "translateY(20px)"
|
|
161
|
-
},
|
|
162
|
-
"body.loaded .welcome-header": {
|
|
163
|
-
"opacity": "1",
|
|
164
|
-
"transform": "translateY(0)",
|
|
165
|
-
"transition": "opacity 0.8s ease, transform 0.8s ease"
|
|
166
|
-
},
|
|
167
|
-
"body:not(.loaded) .feature-card": {
|
|
168
|
-
"opacity": "0",
|
|
169
|
-
"transform": "scale(0.95)"
|
|
170
|
-
},
|
|
171
|
-
"body.loaded .feature-card": {
|
|
172
|
-
"opacity": "1",
|
|
173
|
-
"transform": "scale(1)",
|
|
174
|
-
"transition": "opacity 0.6s ease, transform 0.6s ease"
|
|
175
|
-
},
|
|
176
|
-
"body.loaded .feature-card:nth-child(1)": {
|
|
177
|
-
"transitionDelay": "0.2s"
|
|
178
|
-
},
|
|
179
|
-
"body.loaded .feature-card:nth-child(2)": {
|
|
180
|
-
"transitionDelay": "0.4s"
|
|
181
|
-
},
|
|
182
|
-
"body.loaded .feature-card:nth-child(3)": {
|
|
183
|
-
"transitionDelay": "0.6s"
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
"content": {
|
|
187
|
-
".main-title": "Welcome to xiangjsoncraft",
|
|
188
|
-
".subtitle": "Create beautiful web pages with simple JSON configuration",
|
|
189
|
-
".primary-button": "Get Started",
|
|
190
|
-
".additional-info": "Join thousands of developers using our JSON configuration system",
|
|
191
|
-
".copyright": "© 2025 Dong Xiang. All rights reserved."
|
|
192
|
-
},
|
|
193
|
-
"features": {
|
|
194
|
-
"selectorPrefix": "#feature",
|
|
195
|
-
"items": [
|
|
196
|
-
{
|
|
197
|
-
"iconClass": "fas fa-code",
|
|
198
|
-
"title": "Simple Configuration",
|
|
199
|
-
"description": "Define your entire page style and content with easy-to-understand JSON"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
"iconClass": "fas fa-paint-brush",
|
|
203
|
-
"title": "Beautiful Designs",
|
|
204
|
-
"description": "Create stunning interfaces without writing complex CSS code"
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
"iconClass": "fas fa-mobile-alt",
|
|
208
|
-
"title": "Responsive by Default",
|
|
209
|
-
"description": "Your pages will look great on all devices with built-in responsiveness"
|
|
210
|
-
}
|
|
211
|
-
]
|
|
212
|
-
},
|
|
213
|
-
"icons": {
|
|
214
|
-
"selector": ".social-links",
|
|
215
|
-
"items": [
|
|
216
|
-
{
|
|
217
|
-
"class": "fab fa-github",
|
|
218
|
-
"url": "#"
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
"class": "fab fa-twitter",
|
|
222
|
-
"url": "#"
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
"class": "fab fa-linkedin",
|
|
226
|
-
"url": "#"
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
"class": "fab fa-instagram",
|
|
230
|
-
"url": "#"
|
|
231
|
-
}
|
|
232
|
-
]
|
|
233
|
-
}
|
|
234
|
-
}
|
package/template/index.html
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>Welcome Page</title>
|
|
8
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
9
|
-
<style id="dynamic-styles"></style>
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<body>
|
|
13
|
-
<div class="welcome-container">
|
|
14
|
-
<header class="welcome-header">
|
|
15
|
-
<div class="logo-container">
|
|
16
|
-
<div class="logo"></div>
|
|
17
|
-
</div>
|
|
18
|
-
<h1 class="main-title"></h1>
|
|
19
|
-
<p class="subtitle"></p>
|
|
20
|
-
</header>
|
|
21
|
-
|
|
22
|
-
<main class="features-section">
|
|
23
|
-
<div class="feature-card" id="feature-1"></div>
|
|
24
|
-
<div class="feature-card" id="feature-2"></div>
|
|
25
|
-
<div class="feature-card" id="feature-3"></div>
|
|
26
|
-
</main>
|
|
27
|
-
|
|
28
|
-
<section class="action-section">
|
|
29
|
-
<a href="https://www.npmjs.com/package/xiangjsoncraft">
|
|
30
|
-
<button class="primary-button"></button>
|
|
31
|
-
</a>
|
|
32
|
-
<p class="additional-info"></p>
|
|
33
|
-
</section>
|
|
34
|
-
|
|
35
|
-
<footer class="page-footer">
|
|
36
|
-
<p class="copyright"></p>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class="social-links">
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
</footer>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<script type="module">
|
|
47
|
-
import { renderJsonStyles } from './renderJson.js';
|
|
48
|
-
// 页面加载完成后渲染
|
|
49
|
-
window.addEventListener('DOMContentLoaded', renderJsonStyles);
|
|
50
|
-
</script>
|
|
51
|
-
</body>
|
|
52
|
-
|
|
53
|
-
</html>
|