@gunshi/plugin-dryrun 0.37.3 → 1.0.0-beta.1

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 CHANGED
@@ -138,6 +138,12 @@ await writeOutputFile('dist/result.json', JSON.stringify({ ok: true }, null, 2))
138
138
  - Default: `'dryRun'`
139
139
  - Description: The command value key for the dry-run option. With Gunshi's default kebab-case option handling, `dryRun` maps to `--dry-run`.
140
140
 
141
+ The name belongs to this plugin. A command that declares an argument of its own under the same name takes the option away for that command: dry-run mode stays off there, whatever value the argument carries, and the plugin reports the collision on stderr. Give the option another name to avoid it:
142
+
143
+ ```js
144
+ dryrun({ name: 'pretend' })
145
+ ```
146
+
141
147
  ### `description`
142
148
 
143
149
  - Type: `string`
package/lib/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { Awaitable, PluginWithExtension } from "@gunshi/plugin";
2
-
3
2
  //#region src/index.d.ts
4
-
5
3
  /**
6
4
  * The unique identifier for dry-run plugin.
7
5
  */
package/lib/index.js CHANGED
@@ -62,7 +62,17 @@ function dryrun(options = {}) {
62
62
  optional: true
63
63
  }],
64
64
  extension(ctx) {
65
- const enabled = ctx.values[optionName] === true;
65
+ /**
66
+ * NOTE(kazupon): the option of this plugin is a global option, and an argument that the command
67
+ * declares under the same name replaces it (#745). The value under the name is then the
68
+ * command's, and reading it as this plugin's flag would either skip real work that nobody asked
69
+ * to skip, or run for real after the user asked for a dry run. The core says which global
70
+ * options are in effect; when it says nothing, as when a command context is built on its own,
71
+ * the option is taken to be in effect.
72
+ */
73
+ const inEffect = ctx.env.globalOptions?.has(optionName) ?? true;
74
+ if (!inEffect) console.warn(`The command "${ctx.name ?? ""}" declares an argument called "${optionName}", which replaces the global option of @gunshi/plugin-dryrun. Dry-run mode stays off for this command. Rename either of them, for example with \`dryrun({ name: '...' })\`.`);
75
+ const enabled = inEffect && ctx.values[optionName] === true;
66
76
  function resolveMessage(fn, message) {
67
77
  return message || fn.name || "anonymous";
68
78
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/plugin-dryrun",
3
3
  "description": "dry-run option plugin for gunshi",
4
- "version": "0.37.3",
4
+ "version": "1.0.0-beta.1",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -52,14 +52,14 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@gunshi/plugin": "0.37.3"
55
+ "@gunshi/plugin": "1.0.0-beta.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "deno": "^2.7.14",
59
59
  "jsr": "^0.14.3",
60
60
  "jsr-exports-lint": "^0.4.2",
61
61
  "publint": "^0.3.20",
62
- "tsdown": "0.21.0"
62
+ "tsdown": "0.22.14"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsdown",