sveld 0.40.6 → 0.41.0
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 +4 -2
- package/browser.js +1 -1
- package/{chunk-a5y3ysxx.js → chunk-29ptmasm.js} +1 -1
- package/{chunk-9fmhgf46.js → chunk-h308tz7m.js} +8 -8
- package/{chunk-jw5zhqjv.js → chunk-qbdh04vs.js} +1 -1
- package/{chunk-0e70e5s3.js → chunk-zmd679kg.js} +6 -6
- package/cli-entry.js +23 -11
- package/index.d.ts +9 -7
- package/index.js +1 -1
- package/package.json +1 -1
package/cli-entry.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import{I,te,r,Bt,Ee,Se,W,L,H,J,K,Oe,Me,Fe}from"./chunk-
|
|
1
|
+
import{I,te,r,Bt,Ee,Se,W,L,H,J,K,Oe,Me,Fe}from"./chunk-h308tz7m.js";import{existsSync as w}from"node:fs";import{join as R}from"node:path";var h="src/index.js",S={SUCCESS:0,PROBLEMS:1,USAGE_OR_FAILURE:2},j=1;function C(t){return t.some((n,a)=>n==="--format=json"||n==="--format"&&t[a+1]==="json")}var O=`Usage: sveld [options]
|
|
2
2
|
|
|
3
3
|
Generate TypeScript definitions and component documentation for a Svelte
|
|
4
4
|
library. With no flags, only TypeScript definitions are generated for the
|
|
5
5
|
entry resolved from package.json#svelte.
|
|
6
6
|
|
|
7
|
-
--entry, --config, --cache, --check,
|
|
8
|
-
value as --flag=value or as a separate --flag
|
|
7
|
+
--entry, --config, --cache, --check, --types-format, --format, and
|
|
8
|
+
--check-level accept their value as --flag=value or as a separate --flag
|
|
9
|
+
value argument.
|
|
9
10
|
|
|
10
11
|
Options:
|
|
11
12
|
--entry=<path> Entry point to uncompiled Svelte source (default: package.json "svelte" field)
|
|
@@ -20,19 +21,30 @@ Options:
|
|
|
20
21
|
--cache[=<path>] Persist parsed output and skip re-parsing unchanged files (on by default, default path: node_modules/.cache/sveld/parse-cache.json; pass --cache=false to disable)
|
|
21
22
|
--check-examples[=syntax] Check @example blocks: TS/JS against the TypeScript program, svelte/html markup against svelte-ast; --check-examples=syntax runs only the markup path and never loads TypeScript
|
|
22
23
|
--report-diagnostics Print unresolved-type diagnostics to stderr
|
|
23
|
-
--strict[=errors] Exit with code
|
|
24
|
+
--strict[=errors] Exit with code 1 when diagnostics exist (implies --report-diagnostics); --strict=errors only fails on error-severity diagnostics
|
|
24
25
|
--types-format=<format> ".d.ts" output format: "class" (default) or "component" (Svelte 5 Component<...>)
|
|
25
26
|
--types-index-types Sets typesOptions.indexTypes; also re-exports generated types from index.d.ts (pass --types-index-types=false to disable)
|
|
26
|
-
--check[=<path>] Diff the parsed API against a committed snapshot; exit
|
|
27
|
+
--check[=<path>] Diff the parsed API against a committed snapshot; exit 1 on a breaking change (default path: COMPONENT_API.json)
|
|
27
28
|
--check-level=<major|minor|patch> Minimum bump --check fails the run on (default: major)
|
|
28
29
|
--format=<text|json|github> Output format for the --check report and the diagnostics summary (default: text); github also prints each diagnostic as a GitHub Actions annotation
|
|
29
30
|
-h, --help Print this help message and exit
|
|
30
31
|
-v, --version Print the installed sveld version and exit
|
|
31
32
|
|
|
32
33
|
Exit codes:
|
|
33
|
-
0
|
|
34
|
-
1
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
0 done
|
|
35
|
+
1 problems found: a component that failed to parse, a breaking API
|
|
36
|
+
change under --check, diagnostics under --strict, or a --check
|
|
37
|
+
snapshot from another schemaVersion
|
|
38
|
+
2 called wrong, or couldn't finish: an unknown flag or bad value, a
|
|
39
|
+
missing entry, config file or --check snapshot, an unresolvable
|
|
40
|
+
re-export or path alias, or an unrecoverable error
|
|
41
|
+
|
|
42
|
+
For agents and scripts:
|
|
43
|
+
Run with --format=json and read stdout. --check prints its report as
|
|
44
|
+
one object ({ kind: "check-report", schemaVersion, bump, changes });
|
|
45
|
+
--report-diagnostics and --strict print { kind: "diagnostics",
|
|
46
|
+
schemaVersion, diagnostics } on stderr. An exit 2 prints
|
|
47
|
+
{ schemaVersion, ok: false, error: { kind, message } } on stdout, where
|
|
48
|
+
kind is usage, config, entry, unresolved-module or failure.
|
|
49
|
+
`,A=["help","version","glob","types","json","markdown","quiet","stdout","strict","report-diagnostics","check-examples","fail-fast","entry","config","cache","check","check-level","types-format","types-index-types","format"],x=new Map([["-h","--help"],["-v","--version"],["-q","--quiet"]]),P=/[A-Z]/g,T=new Set(["glob","types","json","markdown","quiet","stdout","strict","report-diagnostics","check-examples","fail-fast","types-index-types"]),_=new Set(["entry","config","cache","check","types-format","format","check-level"]),F=new Set(["entry","config","types-format","format","check-level"]);function G(t){let n=t.replace(P,(a)=>`-${a.toLowerCase()}`);return I(n,A)}function U(t,n){let a=t.indexOf("="),e=a===-1?t.slice(2):t.slice(2,a),s=a===-1?!0:t.slice(a+1),i=!1;if(a===-1&&_.has(e)){if(n!==void 0&&!n.startsWith("--")&&!x.has(n))s=n,i=!0;else if(F.has(e))return{result:{kind:"usage-error",message:`sveld: --${e} requires a value (pass --${e}=<value> or --${e} <value>).`},consumedNext:!1,flag:e}}return{result:q(e,s,t),consumedNext:i,flag:e}}function u(t){return t}function q(t,n,a){let e=(l)=>({kind:"option",option:l}),s=n===!0||n==="true",i=typeof n==="string"?n:void 0;switch(t){case"help":return{kind:"help"};case"version":return{kind:"version"};case"glob":case"types":case"json":case"markdown":case"quiet":return e({[t]:s});case"stdout":if(s)return e({stdout:!0});if(n==="false")return e({stdout:!1});return{kind:"usage-error",message:`sveld: --stdout does not take a value; got "${n}".`};case"strict":if(s)return e({strict:!0});if(n==="false")return e({strict:!1});return e({strict:u(n)});case"report-diagnostics":return e({reportDiagnostics:s});case"check-examples":if(s)return e({checkExamples:!0});if(n==="false")return e({checkExamples:!1});return e({checkExamples:u(n)});case"fail-fast":return e({failFast:s});case"entry":return e(i===void 0?{}:{entry:i});case"config":return e(i===void 0?{}:{config:i});case"cache":if(n==="false")return e({cache:!1});return e({cache:i??!0});case"check":if(n==="false")return e({check:!1});return e({check:i??!0});case"types-format":return e(i===void 0?{}:{typesOptions:{format:u(i)}});case"types-index-types":return e({typesOptions:{indexTypes:s}});case"format":return e(i===void 0?{}:{format:u(i)});case"check-level":return e(i===void 0?{}:{checkLevel:u(i)});default:return{kind:"unknown",arg:a,suggestion:G(t)}}}function N(t){let n={},a=!1;for(let e=0;e<t.length;e++){let s=x.get(t[e])??t[e];if(!s.startsWith("--"))return{kind:"unknown",arg:s,positionalHint:a?!0:void 0};let{result:i,consumedNext:l,flag:o}=U(s,t[e+1]);if(i.kind!=="option")return i;if(n=L(n,i.option),a=T.has(o),l)e++}return{kind:"options",options:n}}function d(t,n){return t!==void 0&&!n.includes(t)}async function V(t){let n=t.argv.slice(2),a=C(n),e=(c,g="usage")=>{if(a){let E={schemaVersion:j,ok:!1,error:{kind:g,message:c}};t.stdout.write(`${JSON.stringify(E,null,2)}
|
|
50
|
+
`)}else console.error(c);t.exitCode=S.USAGE_OR_FAILURE},s=N(n);if(s.kind==="help"){console.log(O);return}if(s.kind==="version"){console.log(Bt.version);return}if(s.kind==="usage-error")return e(s.message);if(s.kind==="unknown"){let c=`sveld: unknown flag "${s.arg}".`;if(s.suggestion)c+=` Did you mean "--${s.suggestion}"?`;if(s.positionalHint)c+=" Values are passed as --flag=value or --flag value.";let g="Run sveld --help for a list of available flags.";if(a)return e(`${c} ${g}`);return console.error(c),e(g)}let i=s.options,l;try{l=await W(i.config,t.cwd(),!0)}catch(c){return e(c instanceof Error?c.message:String(c),"config")}let o=L(l,i);if(a=o.format==="json",H(o),o.stdout){if([o.json,o.markdown].filter(Boolean).length!==1)return e("sveld: --stdout requires exactly one of --json or --markdown.");if(o.types===!0)return e("sveld: --stdout cannot be combined with --types; type definitions span multiple files.");if(o.check)return e("sveld: --stdout cannot be combined with --check; both write their document to stdout.")}if(d(o.format,["text","json","github"]))return e(`sveld: --format must be "text", "json", or "github"; got "${o.format}".`);if(d(o.strict,[!0,!1,"errors"]))return e(`sveld: --strict must be "errors" when given a value; got "${o.strict}".`);if(d(o.checkLevel,["major","minor","patch"]))return e(`sveld: --check-level must be "major", "minor", or "patch"; got "${o.checkLevel}".`);if(d(o.checkExamples,[!0,!1,"syntax"]))return e(`sveld: --check-examples must be "syntax" when given a value; got "${o.checkExamples}".`);let k=o.typesOptions?.format;if(d(k,["class","component"]))return e(`sveld: --types-format must be "class" or "component"; got "${k}".`);J(o.quiet===!0);let f=Oe(o.entry),p;if(f.entry!==null)p=f.entry;else if(!f.configured&&w(R(t.cwd(),h)))console.error(`sveld: no entry point configured; using "${h}". Set package.json#svelte (or pass --entry) to silence this.`),p=te(r(h));else return e(`sveld: ${f.message}`,"entry");let y;try{y=await Me(p,o,o.stdout===!0)}catch(c){if(c instanceof K)return e(`sveld: ${c.message}`,"unresolved-module");return e(c instanceof Error?c.message:String(c),"failure")}let{result:b,check:m}=y,{exitCode:v}=Fe(b,m,o,p);if(m)if(o.format==="json")t.stdout.write(Se(m));else console.log(Ee(m));if(v!==S.SUCCESS)t.exitCode=v}export{V as cli};
|
package/index.d.ts
CHANGED
|
@@ -1053,15 +1053,17 @@ export interface SveldResult {
|
|
|
1053
1053
|
*/
|
|
1054
1054
|
document: ComponentApiDocument;
|
|
1055
1055
|
/**
|
|
1056
|
-
* Suggested process exit code for this run,
|
|
1057
|
-
*
|
|
1058
|
-
* `process.exitCode` itself; assign this value
|
|
1059
|
-
* process to exit non-zero.
|
|
1060
|
-
*/
|
|
1061
|
-
exitCode:
|
|
1056
|
+
* Suggested process exit code for this run, as the CLI exits: `0` done,
|
|
1057
|
+
* `1` problems found, `2` the run couldn't do what it was asked.
|
|
1058
|
+
* `sveld()` never mutates `process.exitCode` itself; assign this value
|
|
1059
|
+
* yourself if you want the process to exit non-zero.
|
|
1060
|
+
*/
|
|
1061
|
+
exitCode: 0 | 1 | 2;
|
|
1062
|
+
/** Why `exitCode` isn't `0`, each reason that applied, in this order. */
|
|
1063
|
+
failures: SveldFailure[];
|
|
1062
1064
|
}
|
|
1063
1065
|
|
|
1064
|
-
type
|
|
1066
|
+
export type SveldFailure = "missing-snapshot" | "outdated-snapshot" | "parse-error" | "breaking-change" | "diagnostics";
|
|
1065
1067
|
|
|
1066
1068
|
export interface SveldOptions extends Omit<SveldRuntimeOptions, "config"> {
|
|
1067
1069
|
/**
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{X,Ve,y,jt,Le,Ee,Vt,Se,Ut,Gt,Jt}from"./chunk-
|
|
1
|
+
import{X,Ve,y,jt,Le,Ee,Vt,Se,Ut,Gt,Jt}from"./chunk-h308tz7m.js";import{re}from"./chunk-zmd679kg.js";export{Vt as CHECK_REPORT_SCHEMA_VERSION,re as ComponentParser,Ve as DIAGNOSTICS_SCHEMA_VERSION,X as DIAGNOSTIC_CODES,y as buildComponentApiDocument,Gt as default,Ut as defineConfig,jt as diffApiDocuments,Ee as formatCheckReport,Se as formatCheckReportJson,Le as runCheck,Jt as sveld};
|