juice-email-cli 2.0.6 → 2.1.2

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/bin/juice.js CHANGED
@@ -12,6 +12,7 @@ program
12
12
  .version(pkg.version, '-v, --version')
13
13
  .option('-f, --file <path>', '输入 HTML 模板文件路径')
14
14
  .option('-c, --config <path>', '配置文件路径(不指定时自动查找输入文件同级目录)')
15
+ .option('--snippet <path>', '片段 HTML 文件路径:将片段内容插入模板 <tbody id="content"> 中,生成 3 个文件')
15
16
  .option('--install', '注册 Windows 右键菜单(需管理员权限)')
16
17
  .option('--uninstall', '取消 Windows 右键菜单注册(需管理员权限)')
17
18
  .addHelpText('before', `
@@ -24,18 +25,33 @@ program
24
25
  配置加载顺序(优先级从低到高):
25
26
  1. CLI 内置默认值(defaults/juice.yaml)
26
27
  2. 用户主目录 ~/juice.yaml(如果存在)
27
- 3. 优先配置(-c 指定 或 输入文件同级目录,二者互斥)
28
+ 3. 优先配置(-c 指定 或 输入文件同级目录)
28
29
 
29
- 使用示例:
30
+ 普通模式(-f 必选,直接处理单个 HTML):
30
31
  juice -f my-email.html
31
32
  juice -c project.yaml -f emails/welcome.html
33
+
34
+ 片段组装模式(--snippet + 模板拼接):
35
+ juice --snippet edm/elabscience/literature/snippet.html -f edm/elabscience/elabscience-template.html
36
+ juice --snippet edm/elabscience/literature/snippet.html (交互式选择模板)
37
+
38
+ 交互模式(全交互选择):
39
+ juice (逐步选择品牌、模板、片段、配置)
40
+
41
+ 右键菜单管理:
32
42
  juice --install (管理员权限,注册右键菜单)
33
43
  juice --uninstall (管理员权限,卸载右键菜单)
34
44
 
35
- 输出文件(与输入文件同目录):
45
+ 普通模式输出文件(与输入文件同目录):
36
46
  <name>.output.html CSS 内联 + 变量替换后的标准版
37
47
  <name>.minified.html 在标准版基础上压缩的精简版
38
48
 
49
+ 片段模式输出文件(当前工作目录):
50
+ <name>.raw.html 原始组装(Mustache 未渲染,无 CSS 内联)
51
+ <name>.html 已渲染(Mustache 变量已替换,无 CSS 内联)
52
+ <name>.output.html Juice CSS 内联后
53
+ <name>.minified.html 压缩版
54
+
39
55
  更多信息:https://gitee.com/siriussupreme/juice-cli
40
56
  `)
41
57
  .action(async (options) => {
@@ -51,21 +67,34 @@ program
51
67
  return;
52
68
  }
53
69
 
54
- // 支持右键菜单直接传文件路径(位置参数)
70
+ // --snippet 模式:片段组装
71
+ if (options.snippet) {
72
+ const { runSnippetMode } = require('../src/snippet');
73
+ await runSnippetMode({
74
+ snippet: options.snippet,
75
+ template: options.file,
76
+ config: options.config,
77
+ });
78
+ return;
79
+ }
80
+
81
+ // 普通模式:-f 指定文件
55
82
  let inputFile = options.file;
56
83
  if (!inputFile && program.args.length > 0) {
57
84
  inputFile = program.args[0];
58
85
  }
59
86
 
60
- if (!inputFile) {
61
- program.help();
62
- process.exit(1);
87
+ if (inputFile) {
88
+ await run({
89
+ file: inputFile,
90
+ config: options.config,
91
+ });
92
+ return;
63
93
  }
64
94
 
65
- await run({
66
- file: inputFile,
67
- config: options.config,
68
- });
95
+ // 全交互模式:无 --snippet,无 -f
96
+ const { runInteractiveMode } = require('../src/snippet');
97
+ await runInteractiveMode({ config: options.config });
69
98
  });
70
99
 
71
100
  program.allowUnknownOption(false);