@leiyi-works/dsh-session-tmpdir 0.10.3 → 0.10.4
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 +21 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -850,6 +850,20 @@ const STRONG_TARGET_KEYS = new Set([
|
|
|
850
850
|
])
|
|
851
851
|
/** "Looks like a file name" hint used only for strongly-named destination arguments. */
|
|
852
852
|
const FILE_EXTENSION_PATTERN = /\.[A-Za-z0-9]{1,8}$/
|
|
853
|
+
/**
|
|
854
|
+
* v0.10.4: npm 包规格(`@scope/name@1.2.3`、`name@1.2.3`)不是文件路径。
|
|
855
|
+
* 它们以 `.数字` 结尾(如 `@1.8.4`),会被“强目标参数 + 扩展名”兜底误判成路径。
|
|
856
|
+
*/
|
|
857
|
+
const PACKAGE_SPEC_PATTERN = /^(?:@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*(?:@[\w.^~><*|=-]+)?$/i
|
|
858
|
+
|
|
859
|
+
/** True when the value is an npm package spec (optionally pinned to a version). */
|
|
860
|
+
export function looksLikePackageSpec(value) {
|
|
861
|
+
if (typeof value !== 'string') return false
|
|
862
|
+
const text = value.trim()
|
|
863
|
+
if (!text || text.length > 256) return false
|
|
864
|
+
if (!text.includes('@') && !/^@[^/]+\//.test(text)) return false
|
|
865
|
+
return PACKAGE_SPEC_PATTERN.test(text)
|
|
866
|
+
}
|
|
853
867
|
|
|
854
868
|
/**
|
|
855
869
|
* True when a string value looks like a filesystem path. Enum-like values
|
|
@@ -896,7 +910,13 @@ export function collectPathTargets(args, options = {}) {
|
|
|
896
910
|
if (typeof value !== 'string' || !value.trim()) return
|
|
897
911
|
const text = value.trim()
|
|
898
912
|
if (looksLikePathValue(text)) out.push(text)
|
|
899
|
-
else if (
|
|
913
|
+
else if (
|
|
914
|
+
STRONG_TARGET_KEYS.has(key.toLowerCase()) &&
|
|
915
|
+
FILE_EXTENSION_PATTERN.test(text) &&
|
|
916
|
+
!looksLikePackageSpec(text)
|
|
917
|
+
) {
|
|
918
|
+
out.push(text)
|
|
919
|
+
}
|
|
900
920
|
}
|
|
901
921
|
for (const [key, value] of Object.entries(args)) {
|
|
902
922
|
if (!PATH_ARG_PATTERN.test(key)) continue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leiyi-works/dsh-session-tmpdir",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Per-session task temp folder with a long-term write guard. v0.9 (方案3): creating a new file outside _tmp requires the user's approval (per file by default, per directory with mode=dir), overwriting an existing file is allowed without asking, every write channel is guarded (write/edit, shell including ffmpeg/pandoc/Export-*/IO APIs, publish copies, code runtimes, unknown tools), and the persisted whitelist is shown in a left-sidebar panel「临时目录」 where entries can be removed. Every session also gets _tmp/<session title>/ in its working directory, cleaned 7 days after the session is deleted; the same tick reclaims the attachment store.",
|
|
6
6
|
"exports": {
|