@struggler/cli 1.0.11 → 1.0.12

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/index.js CHANGED
@@ -58,7 +58,7 @@ program.configureHelp({
58
58
  },
59
59
  })
60
60
 
61
- program.name("struggler-cli").description(locale.appDescription).version(packageJson.version, "-v, --version", locale.options.version).helpOption("-h, --help", locale.options.help).option("-c, --config <path>", locale.options.config, "./command/qiniu.json").option("--config-dir <path>", locale.options.configDir).option("-d, --dir <path>", locale.options.dir, "./dist").option("--dry-run", locale.options.dryRun).option("--concurrency <number>", locale.options.concurrency, "5").option("--exclude <pattern>", locale.options.exclude).option("--ignore-file <path>", locale.options.ignoreFile, ".strugglerignore").option("--manifest <path>", locale.options.manifest).option("--json", locale.options.json).option("--skip-init", locale.options.skipInit).option("--skip-refresh", locale.options.skipRefresh).option("--no-cache", locale.options.noCache).option("--lang <lang>", locale.options.lang, lang)
61
+ program.name("struggler-cli").description(locale.appDescription).version(packageJson.version, "-v, --version", locale.options.version).helpOption("-h, --help", locale.options.help).option("-c, --config <path>", locale.options.config, "./command/qiniu.json").option("--config-dir [path]", locale.options.configDir).option("-d, --dir <path>", locale.options.dir, "./dist").option("--dry-run", locale.options.dryRun).option("--concurrency <number>", locale.options.concurrency, "5").option("--exclude <pattern>", locale.options.exclude).option("--ignore-file <path>", locale.options.ignoreFile, ".strugglerignore").option("--manifest <path>", locale.options.manifest).option("--json", locale.options.json).option("--skip-init", locale.options.skipInit).option("--skip-refresh", locale.options.skipRefresh).option("--no-cache", locale.options.noCache).option("--lang <lang>", locale.options.lang, lang)
62
62
 
63
63
  program
64
64
  .command("init")
package/lib/config.js CHANGED
@@ -14,10 +14,22 @@ function getQiniuConfigPath(options = {}) {
14
14
  return resolveFromCwd(options.config || DEFAULT_QINIU_CONFIG);
15
15
  }
16
16
 
17
+ function resolveConfigDirOption(options = {}) {
18
+ const value = options.configDir;
19
+ if (value === true || value === '') {
20
+ return DEFAULT_META_DIR;
21
+ }
22
+ if (typeof value === 'string') {
23
+ return value;
24
+ }
25
+ return null;
26
+ }
27
+
17
28
  /** config.json / upload-cache.json 所在目录;优先级:CLI --config-dir > qiniu.json configDir > 与 qiniu 同目录 > ./command */
18
29
  function getMetaDir(options = {}) {
19
- if (options.configDir) {
20
- return resolveFromCwd(options.configDir);
30
+ const cliConfigDir = resolveConfigDirOption(options);
31
+ if (cliConfigDir) {
32
+ return resolveFromCwd(cliConfigDir);
21
33
  }
22
34
 
23
35
  const qiniuConfigPath = getQiniuConfigPath(options);
package/lib/i18n.js CHANGED
@@ -38,7 +38,7 @@ const LANGUAGES = {
38
38
  options: {
39
39
  version: '显示版本号。',
40
40
  config: '指定上传配置文件路径。',
41
- configDir: '指定 config.json、upload-cache.json 所在目录(默认与 -c 同目录,未传 -c 时为 ./command)。',
41
+ configDir: '指定 config.json、upload-cache.json 所在目录;可写 --config-dir ./command,单独写 --config-dir 时默认为 ./command',
42
42
  dir: '指定要上传的目录。',
43
43
  dryRun: '仅预览执行计划,不写文件也不调用七牛接口。',
44
44
  concurrency: '设置上传并发数。',
@@ -112,7 +112,7 @@ const LANGUAGES = {
112
112
  options: {
113
113
  version: 'Display the version number.',
114
114
  config: 'Specify the path to the upload configuration file.',
115
- configDir: 'Directory for config.json and upload-cache.json (default: same dir as -c, or ./command).',
115
+ configDir: 'Directory for config.json and upload-cache.json; use --config-dir ./command, or --config-dir alone for ./command.',
116
116
  dir: 'Specify the directory to upload.',
117
117
  dryRun: 'Preview actions without writing files or calling Qiniu APIs.',
118
118
  concurrency: 'Set upload concurrency.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@struggler/cli",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "CLI to Upload vite packaged files to Qiniu Cloud OSS.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -36,6 +36,18 @@ test('config-dir overrides default meta directory', () => {
36
36
  );
37
37
  });
38
38
 
39
+ test('config-dir flag without path defaults to ./command', () => {
40
+ const options = {
41
+ config: './test/command/qiniu.json',
42
+ configDir: true,
43
+ };
44
+
45
+ assert.equal(
46
+ getConfig(options),
47
+ `${process.cwd()}/command/config.json`
48
+ );
49
+ });
50
+
39
51
  test('deploy helpers normalize concurrency and build remote keys', () => {
40
52
  assert.equal(normalizeConcurrency('0'), 5);
41
53
  assert.equal(normalizeConcurrency('3'), 3);