specdx 0.1.0-alpha.1 → 0.1.0-alpha.3
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/dist/chunk-ADUPKQBA.js +260 -0
- package/dist/chunk-ADUPKQBA.js.map +1 -0
- package/dist/chunk-KQKWPO7Y.js +203 -0
- package/dist/chunk-KQKWPO7Y.js.map +1 -0
- package/dist/graph-XJSNQ7B7.js +44 -0
- package/dist/graph-XJSNQ7B7.js.map +1 -0
- package/dist/index.js +873 -2
- package/dist/index.js.map +1 -1
- package/dist/lint-BOQDKP7A.js +326 -0
- package/dist/lint-BOQDKP7A.js.map +1 -0
- package/dist/main.js +132 -9
- package/dist/main.js.map +1 -1
- package/dist/validate-FFNJWR6V.js +32 -0
- package/dist/validate-FFNJWR6V.js.map +1 -0
- package/package.json +16 -6
- package/dist/commands/graph.d.ts +0 -19
- package/dist/commands/graph.d.ts.map +0 -1
- package/dist/commands/graph.js +0 -36
- package/dist/commands/graph.js.map +0 -1
- package/dist/commands/init.d.ts +0 -26
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -116
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/init.test.d.ts +0 -2
- package/dist/commands/init.test.d.ts.map +0 -1
- package/dist/commands/init.test.js +0 -42
- package/dist/commands/init.test.js.map +0 -1
- package/dist/commands/lint.d.ts +0 -39
- package/dist/commands/lint.d.ts.map +0 -1
- package/dist/commands/lint.js +0 -66
- package/dist/commands/lint.js.map +0 -1
- package/dist/commands/lint.test.d.ts +0 -2
- package/dist/commands/lint.test.d.ts.map +0 -1
- package/dist/commands/lint.test.js +0 -61
- package/dist/commands/lint.test.js.map +0 -1
- package/dist/commands/validate.d.ts +0 -19
- package/dist/commands/validate.d.ts.map +0 -1
- package/dist/commands/validate.js +0 -25
- package/dist/commands/validate.js.map +0 -1
- package/dist/formatters/github.d.ts +0 -3
- package/dist/formatters/github.d.ts.map +0 -1
- package/dist/formatters/github.js +0 -10
- package/dist/formatters/github.js.map +0 -1
- package/dist/formatters/json.d.ts +0 -3
- package/dist/formatters/json.d.ts.map +0 -1
- package/dist/formatters/json.js +0 -4
- package/dist/formatters/json.js.map +0 -1
- package/dist/formatters/pretty.d.ts +0 -3
- package/dist/formatters/pretty.d.ts.map +0 -1
- package/dist/formatters/pretty.js +0 -11
- package/dist/formatters/pretty.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/main.d.ts +0 -3
- package/dist/main.d.ts.map +0 -1
- package/dist/shared-args.d.ts +0 -18
- package/dist/shared-args.d.ts.map +0 -1
- package/dist/shared-args.js +0 -10
- package/dist/shared-args.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,14 +1,137 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import {
|
|
3
|
+
REQUIRED_SECTIONS
|
|
4
|
+
} from "./chunk-KQKWPO7Y.js";
|
|
5
|
+
|
|
6
|
+
// src/main.ts
|
|
7
|
+
import { defineCommand as defineCommand2, runMain } from "citty";
|
|
8
|
+
|
|
9
|
+
// src/commands/init.ts
|
|
10
|
+
import { defineCommand } from "citty";
|
|
11
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
12
|
+
import { join } from "path";
|
|
13
|
+
var TEMPLATE_SPECS = {
|
|
14
|
+
lightweight: [
|
|
15
|
+
{ filename: "prd.md", type: "prd" },
|
|
16
|
+
{ filename: "technical-design.md", type: "technical-design" }
|
|
17
|
+
],
|
|
18
|
+
bmad: [
|
|
19
|
+
{ filename: "prd.md", type: "prd" },
|
|
20
|
+
{ filename: "technical-design.md", type: "technical-design" },
|
|
21
|
+
{ filename: "test-plan.md", type: "test-plan" }
|
|
22
|
+
],
|
|
23
|
+
"api-first": [
|
|
24
|
+
{ filename: "technical-design.md", type: "technical-design" },
|
|
25
|
+
{ filename: "api-contract.md", type: "api-contract" },
|
|
26
|
+
{ filename: "test-plan.md", type: "test-plan" }
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
var TEMPLATE_EXTRA_DIRS = {
|
|
30
|
+
lightweight: [],
|
|
31
|
+
bmad: ["specs/stories", "specs/adr"],
|
|
32
|
+
"api-first": []
|
|
33
|
+
};
|
|
34
|
+
function specIdFromFilename(filename) {
|
|
35
|
+
return filename.replace(/\.md$/, "");
|
|
36
|
+
}
|
|
37
|
+
function specTitleFromType(type) {
|
|
38
|
+
return type.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
39
|
+
}
|
|
40
|
+
function buildSpecFile(filename, type, projectName, today) {
|
|
41
|
+
const id = specIdFromFilename(filename);
|
|
42
|
+
const title = `${specTitleFromType(type)} \u2014 ${projectName}`;
|
|
43
|
+
const sections = REQUIRED_SECTIONS[type];
|
|
44
|
+
const frontmatter = [
|
|
45
|
+
"---",
|
|
46
|
+
`id: ${id}`,
|
|
47
|
+
`type: ${type}`,
|
|
48
|
+
`title: "${title}"`,
|
|
49
|
+
`status: draft`,
|
|
50
|
+
`version: "0.1"`,
|
|
51
|
+
`created: "${today}"`,
|
|
52
|
+
`authors: ["author"]`,
|
|
53
|
+
"---"
|
|
54
|
+
].join("\n");
|
|
55
|
+
const body = sections.map((section) => `
|
|
56
|
+
## ${section}
|
|
57
|
+
|
|
58
|
+
<!-- placeholder -->`).join("\n");
|
|
59
|
+
return `${frontmatter}
|
|
60
|
+
${body}
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
function buildConfigYaml(projectName, specs) {
|
|
64
|
+
const specEntries = specs.map(({ filename, type }) => {
|
|
65
|
+
const key = specIdFromFilename(filename);
|
|
66
|
+
return ` ${key}:
|
|
67
|
+
path: specs/${filename}
|
|
68
|
+
type: ${type}`;
|
|
69
|
+
}).join("\n");
|
|
70
|
+
return [`version: "1.0"`, `project:`, ` name: "${projectName}"`, `specs:`, specEntries].join("\n") + "\n";
|
|
71
|
+
}
|
|
72
|
+
async function scaffoldProject({
|
|
73
|
+
projectName,
|
|
74
|
+
template,
|
|
75
|
+
targetDir
|
|
76
|
+
}) {
|
|
77
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
78
|
+
const specsDir = join(targetDir, "specs");
|
|
79
|
+
await mkdir(specsDir, { recursive: true });
|
|
80
|
+
for (const extraDir of TEMPLATE_EXTRA_DIRS[template]) {
|
|
81
|
+
await mkdir(join(targetDir, extraDir), { recursive: true });
|
|
82
|
+
}
|
|
83
|
+
const specs = TEMPLATE_SPECS[template];
|
|
84
|
+
for (const { filename, type } of specs) {
|
|
85
|
+
const content = buildSpecFile(filename, type, projectName, today);
|
|
86
|
+
await writeFile(join(specsDir, filename), content, "utf-8");
|
|
87
|
+
}
|
|
88
|
+
const configContent = buildConfigYaml(projectName, specs);
|
|
89
|
+
await writeFile(join(targetDir, "spec.config.yaml"), configContent, "utf-8");
|
|
90
|
+
}
|
|
91
|
+
var init_default = defineCommand({
|
|
92
|
+
meta: {
|
|
93
|
+
name: "init",
|
|
94
|
+
description: "Initialize a new SDX project with spec scaffolding"
|
|
95
|
+
},
|
|
96
|
+
args: {
|
|
97
|
+
name: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "Project name",
|
|
100
|
+
required: true
|
|
11
101
|
},
|
|
102
|
+
template: {
|
|
103
|
+
type: "string",
|
|
104
|
+
description: "Template to use (lightweight, bmad, api-first)",
|
|
105
|
+
default: "lightweight"
|
|
106
|
+
},
|
|
107
|
+
dir: {
|
|
108
|
+
type: "string",
|
|
109
|
+
description: "Target directory",
|
|
110
|
+
default: "."
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
async run({ args }) {
|
|
114
|
+
const { name, template, dir } = args;
|
|
115
|
+
const validTemplates = ["lightweight", "bmad", "api-first"];
|
|
116
|
+
if (!validTemplates.includes(template)) {
|
|
117
|
+
console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(", ")}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
console.log(`Scaffolding "${name}" with template "${template}" in ${dir}...`);
|
|
121
|
+
await scaffoldProject({ projectName: name, template, targetDir: dir });
|
|
122
|
+
console.log(`Done! Project "${name}" scaffolded successfully.`);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// src/main.ts
|
|
127
|
+
var main = defineCommand2({
|
|
128
|
+
meta: { name: "sdx", version: "0.0.0", description: "SDX \u2014 Spec Developer Experience" },
|
|
129
|
+
subCommands: {
|
|
130
|
+
init: init_default,
|
|
131
|
+
lint: () => import("./lint-BOQDKP7A.js").then((m) => m.default),
|
|
132
|
+
validate: () => import("./validate-FFNJWR6V.js").then((m) => m.default),
|
|
133
|
+
graph: () => import("./graph-XJSNQ7B7.js").then((m) => m.default)
|
|
134
|
+
}
|
|
12
135
|
});
|
|
13
136
|
runMain(main);
|
|
14
137
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/main.ts","../src/commands/init.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { defineCommand, runMain } from \"citty\";\nimport initCommand from \"./commands/init.js\";\n\nconst main = defineCommand({\n meta: { name: \"sdx\", version: \"0.0.0\", description: \"SDX — Spec Developer Experience\" },\n subCommands: {\n init: initCommand,\n lint: () => import(\"./commands/lint.js\").then((m) => m.default),\n validate: () => import(\"./commands/validate.js\").then((m) => m.default),\n graph: () => import(\"./commands/graph.js\").then((m) => m.default),\n },\n});\n\nrunMain(main);\n","import { defineCommand } from \"citty\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { REQUIRED_SECTIONS } from \"@sdx/schema\";\n\nexport type Template = \"lightweight\" | \"bmad\" | \"api-first\";\n\ninterface ScaffoldOptions {\n projectName: string;\n template: Template;\n targetDir: string;\n}\n\nconst TEMPLATE_SPECS: Record<\n Template,\n Array<{ filename: string; type: keyof typeof REQUIRED_SECTIONS }>\n> = {\n lightweight: [\n { filename: \"prd.md\", type: \"prd\" },\n { filename: \"technical-design.md\", type: \"technical-design\" },\n ],\n bmad: [\n { filename: \"prd.md\", type: \"prd\" },\n { filename: \"technical-design.md\", type: \"technical-design\" },\n { filename: \"test-plan.md\", type: \"test-plan\" },\n ],\n \"api-first\": [\n { filename: \"technical-design.md\", type: \"technical-design\" },\n { filename: \"api-contract.md\", type: \"api-contract\" },\n { filename: \"test-plan.md\", type: \"test-plan\" },\n ],\n};\n\nconst TEMPLATE_EXTRA_DIRS: Record<Template, string[]> = {\n lightweight: [],\n bmad: [\"specs/stories\", \"specs/adr\"],\n \"api-first\": [],\n};\n\nfunction specIdFromFilename(filename: string): string {\n return filename.replace(/\\.md$/, \"\");\n}\n\nfunction specTitleFromType(type: string): string {\n return type\n .split(\"-\")\n .map((w) => w.charAt(0).toUpperCase() + w.slice(1))\n .join(\" \");\n}\n\nfunction buildSpecFile(\n filename: string,\n type: keyof typeof REQUIRED_SECTIONS,\n projectName: string,\n today: string,\n): string {\n const id = specIdFromFilename(filename);\n const title = `${specTitleFromType(type)} — ${projectName}`;\n const sections = REQUIRED_SECTIONS[type];\n\n const frontmatter = [\n \"---\",\n `id: ${id}`,\n `type: ${type}`,\n `title: \"${title}\"`,\n `status: draft`,\n `version: \"0.1\"`,\n `created: \"${today}\"`,\n `authors: [\"author\"]`,\n \"---\",\n ].join(\"\\n\");\n\n const body = sections.map((section) => `\\n## ${section}\\n\\n<!-- placeholder -->`).join(\"\\n\");\n\n return `${frontmatter}\\n${body}\\n`;\n}\n\nfunction buildConfigYaml(\n projectName: string,\n specs: Array<{ filename: string; type: string }>,\n): string {\n const specEntries = specs\n .map(({ filename, type }) => {\n const key = specIdFromFilename(filename);\n return ` ${key}:\\n path: specs/${filename}\\n type: ${type}`;\n })\n .join(\"\\n\");\n\n return (\n [`version: \"1.0\"`, `project:`, ` name: \"${projectName}\"`, `specs:`, specEntries].join(\"\\n\") +\n \"\\n\"\n );\n}\n\nexport async function scaffoldProject({\n projectName,\n template,\n targetDir,\n}: ScaffoldOptions): Promise<void> {\n const today = new Date().toISOString().slice(0, 10);\n const specsDir = join(targetDir, \"specs\");\n\n // Create specs/ directory\n await mkdir(specsDir, { recursive: true });\n\n // Create extra template dirs (e.g., bmad needs stories/ and adr/)\n for (const extraDir of TEMPLATE_EXTRA_DIRS[template]) {\n await mkdir(join(targetDir, extraDir), { recursive: true });\n }\n\n const specs = TEMPLATE_SPECS[template];\n\n // Write spec files\n for (const { filename, type } of specs) {\n const content = buildSpecFile(filename, type, projectName, today);\n await writeFile(join(specsDir, filename), content, \"utf-8\");\n }\n\n // Write spec.config.yaml\n const configContent = buildConfigYaml(projectName, specs);\n await writeFile(join(targetDir, \"spec.config.yaml\"), configContent, \"utf-8\");\n}\n\nexport default defineCommand({\n meta: {\n name: \"init\",\n description: \"Initialize a new SDX project with spec scaffolding\",\n },\n args: {\n name: {\n type: \"string\",\n description: \"Project name\",\n required: true,\n },\n template: {\n type: \"string\",\n description: \"Template to use (lightweight, bmad, api-first)\",\n default: \"lightweight\",\n },\n dir: {\n type: \"string\",\n description: \"Target directory\",\n default: \".\",\n },\n },\n async run({ args }) {\n const { name, template, dir } = args;\n const validTemplates: Template[] = [\"lightweight\", \"bmad\", \"api-first\"];\n if (!validTemplates.includes(template as Template)) {\n console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(\", \")}`);\n process.exit(1);\n }\n console.log(`Scaffolding \"${name}\" with template \"${template}\" in ${dir}...`);\n await scaffoldProject({ projectName: name, template: template as Template, targetDir: dir });\n console.log(`Done! Project \"${name}\" scaffolded successfully.`);\n },\n});\n"],"mappings":";;;;;;AACA,SAAS,iBAAAA,gBAAe,eAAe;;;ACDvC,SAAS,qBAAqB;AAC9B,SAAS,OAAO,iBAAiB;AACjC,SA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|
+
import "./chunk-KQKWPO7Y.js";
|
|
7
|
+
|
|
8
|
+
// src/commands/validate.ts
|
|
9
|
+
import { defineCommand } from "citty";
|
|
10
|
+
var validate_default = defineCommand({
|
|
11
|
+
meta: { name: "validate", description: "Validate spec.config.yaml" },
|
|
12
|
+
args: { ...sharedArgs },
|
|
13
|
+
async run() {
|
|
14
|
+
try {
|
|
15
|
+
const config = await loadConfig(void 0, process.cwd());
|
|
16
|
+
console.log(` \u2713 Config valid. ${Object.keys(config.specs).length} specs defined.`);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
if (err instanceof ConfigError) {
|
|
19
|
+
console.error(` \u2717 Config invalid: ${err.message}`);
|
|
20
|
+
if (err.errors) {
|
|
21
|
+
for (const e of err.errors) console.error(` - ${JSON.stringify(e)}`);
|
|
22
|
+
}
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
validate_default as default
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=validate-FFNJWR6V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { loadConfig, ConfigError } from \"@sdx/core\";\nimport { sharedArgs } from \"../shared-args.js\";\n\nexport default defineCommand({\n meta: { name: \"validate\", description: \"Validate spec.config.yaml\" },\n args: { ...sharedArgs },\n async run() {\n try {\n const config = await loadConfig(undefined, process.cwd());\n console.log(` ✓ Config valid. ${Object.keys(config.specs).length} specs defined.`);\n } catch (err) {\n if (err instanceof ConfigError) {\n console.error(` ✗ Config invalid: ${err.message}`);\n if (err.errors) {\n for (const e of err.errors) console.error(` - ${JSON.stringify(e)}`);\n }\n process.exit(1);\n }\n throw err;\n }\n },\n});\n"],"mappings":";;;;;;;;AAAA,SAAS,qBAAqB;AAI9B,IAAO,mBAAQ,cAAc;AAAA,EAC3B,MAAM,EAAE,MAAM,YAAY,aAAa,4BAA4B;AAAA,EACnE,MAAM,EAAE,GAAG,WAAW;AAAA,EACtB,MAAM,MAAM;AACV,QAAI;AACF,YAAM,SAAS,MAAM,WAAW,QAAW,QAAQ,IAAI,CAAC;AACxD,cAAQ,IAAI,0BAAqB,OAAO,KAAK,OAAO,KAAK,EAAE,MAAM,iBAAiB;AAAA,IACpF,SAAS,KAAK;AACZ,UAAI,eAAe,aAAa;AAC9B,gBAAQ,MAAM,4BAAuB,IAAI,OAAO,EAAE;AAClD,YAAI,IAAI,QAAQ;AACd,qBAAW,KAAK,IAAI,OAAQ,SAAQ,MAAM,SAAS,KAAK,UAAU,CAAC,CAAC,EAAE;AAAA,QACxE;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specdx",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sdx": "./dist/main.js"
|
|
@@ -15,19 +15,29 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
18
|
+
"build": "tsup",
|
|
19
19
|
"typecheck": "tsc --build --noEmit",
|
|
20
20
|
"test": "vitest run",
|
|
21
21
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"@sdx/lint": "workspace:*",
|
|
24
|
+
"ajv": "^8.18.0",
|
|
25
|
+
"ajv-formats": "^3.0.1",
|
|
27
26
|
"citty": "^0.2.1",
|
|
28
|
-
"consola": "^3.4.0"
|
|
27
|
+
"consola": "^3.4.0",
|
|
28
|
+
"gray-matter": "^4.0.3",
|
|
29
|
+
"js-tiktoken": "^1.0.18",
|
|
30
|
+
"remark-parse": "^11.0.0",
|
|
31
|
+
"tinyglobby": "^0.2.12",
|
|
32
|
+
"unified": "^11.0.0",
|
|
33
|
+
"unist-util-visit": "^5.0.0",
|
|
34
|
+
"yaml": "^2.7.0"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
37
|
+
"@sdx/core": "workspace:*",
|
|
38
|
+
"@sdx/lint": "workspace:*",
|
|
39
|
+
"@sdx/schema": "workspace:*",
|
|
40
|
+
"tsup": "^8.5.1",
|
|
31
41
|
"typescript": "^5.7.0"
|
|
32
42
|
}
|
|
33
43
|
}
|
package/dist/commands/graph.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const _default: import("citty").CommandDef<{
|
|
2
|
-
readonly quiet: {
|
|
3
|
-
type: "boolean";
|
|
4
|
-
description: string;
|
|
5
|
-
alias: string[];
|
|
6
|
-
};
|
|
7
|
-
readonly verbose: {
|
|
8
|
-
type: "boolean";
|
|
9
|
-
description: string;
|
|
10
|
-
alias: string[];
|
|
11
|
-
};
|
|
12
|
-
readonly format: {
|
|
13
|
-
type: "string";
|
|
14
|
-
description: string;
|
|
15
|
-
default: string;
|
|
16
|
-
};
|
|
17
|
-
}>;
|
|
18
|
-
export default _default;
|
|
19
|
-
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/commands/graph.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA,wBA6BG"}
|
package/dist/commands/graph.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { loadConfig, buildGraph, GraphError } from "@sdx/core";
|
|
3
|
-
import { sharedArgs } from "../shared-args.js";
|
|
4
|
-
export default defineCommand({
|
|
5
|
-
meta: { name: "graph", description: "Print the spec dependency graph" },
|
|
6
|
-
args: { ...sharedArgs },
|
|
7
|
-
async run({ args }) {
|
|
8
|
-
const config = await loadConfig(undefined, process.cwd());
|
|
9
|
-
try {
|
|
10
|
-
const graph = buildGraph(config);
|
|
11
|
-
const sorted = graph.topologicalSort();
|
|
12
|
-
if (args.format === "dot") {
|
|
13
|
-
console.log("digraph specs {");
|
|
14
|
-
for (const edge of graph.edges)
|
|
15
|
-
console.log(` "${edge.from}" -> "${edge.to}";`);
|
|
16
|
-
console.log("}");
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
console.log("\n Spec Dependency Graph:\n");
|
|
20
|
-
for (const node of sorted) {
|
|
21
|
-
const downstream = graph.getDownstream(node);
|
|
22
|
-
const arrow = downstream.length > 0 ? ` → ${downstream.join(", ")}` : "";
|
|
23
|
-
console.log(` ${node}${arrow}`);
|
|
24
|
-
}
|
|
25
|
-
console.log("");
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
if (err instanceof GraphError) {
|
|
29
|
-
console.error(` ✗ ${err.message}`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
throw err;
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/commands/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,eAAe,aAAa,CAAC;IAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,iCAAiC,EAAE;IACvE,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE;IACvB,KAAK,CAAC,GAAG,CAAC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AC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
package/dist/commands/init.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type Template = "lightweight" | "bmad" | "api-first";
|
|
2
|
-
interface ScaffoldOptions {
|
|
3
|
-
projectName: string;
|
|
4
|
-
template: Template;
|
|
5
|
-
targetDir: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function scaffoldProject({ projectName, template, targetDir, }: ScaffoldOptions): Promise<void>;
|
|
8
|
-
declare const _default: import("citty").CommandDef<{
|
|
9
|
-
readonly name: {
|
|
10
|
-
readonly type: "string";
|
|
11
|
-
readonly description: "Project name";
|
|
12
|
-
readonly required: true;
|
|
13
|
-
};
|
|
14
|
-
readonly template: {
|
|
15
|
-
readonly type: "string";
|
|
16
|
-
readonly description: "Template to use (lightweight, bmad, api-first)";
|
|
17
|
-
readonly default: "lightweight";
|
|
18
|
-
};
|
|
19
|
-
readonly dir: {
|
|
20
|
-
readonly type: "string";
|
|
21
|
-
readonly description: "Target directory";
|
|
22
|
-
readonly default: ".";
|
|
23
|
-
};
|
|
24
|
-
}>;
|
|
25
|
-
export default _default;
|
|
26
|
-
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC;AAE5D,UAAU,eAAe;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAmFD,wBAAsB,eAAe,CAAC,EACpC,WAAW,EACX,QAAQ,EACR,SAAS,GACV,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBjC;;;;;;;;;;;;;;;;;;AAED,wBAiCG"}
|
package/dist/commands/init.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { REQUIRED_SECTIONS } from "@sdx/schema";
|
|
5
|
-
const TEMPLATE_SPECS = {
|
|
6
|
-
lightweight: [
|
|
7
|
-
{ filename: "prd.md", type: "prd" },
|
|
8
|
-
{ filename: "technical-design.md", type: "technical-design" },
|
|
9
|
-
],
|
|
10
|
-
bmad: [
|
|
11
|
-
{ filename: "prd.md", type: "prd" },
|
|
12
|
-
{ filename: "technical-design.md", type: "technical-design" },
|
|
13
|
-
{ filename: "test-plan.md", type: "test-plan" },
|
|
14
|
-
],
|
|
15
|
-
"api-first": [
|
|
16
|
-
{ filename: "technical-design.md", type: "technical-design" },
|
|
17
|
-
{ filename: "api-contract.md", type: "api-contract" },
|
|
18
|
-
{ filename: "test-plan.md", type: "test-plan" },
|
|
19
|
-
],
|
|
20
|
-
};
|
|
21
|
-
const TEMPLATE_EXTRA_DIRS = {
|
|
22
|
-
lightweight: [],
|
|
23
|
-
bmad: ["specs/stories", "specs/adr"],
|
|
24
|
-
"api-first": [],
|
|
25
|
-
};
|
|
26
|
-
function specIdFromFilename(filename) {
|
|
27
|
-
return filename.replace(/\.md$/, "");
|
|
28
|
-
}
|
|
29
|
-
function specTitleFromType(type) {
|
|
30
|
-
return type
|
|
31
|
-
.split("-")
|
|
32
|
-
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
33
|
-
.join(" ");
|
|
34
|
-
}
|
|
35
|
-
function buildSpecFile(filename, type, projectName, today) {
|
|
36
|
-
const id = specIdFromFilename(filename);
|
|
37
|
-
const title = `${specTitleFromType(type)} — ${projectName}`;
|
|
38
|
-
const sections = REQUIRED_SECTIONS[type];
|
|
39
|
-
const frontmatter = [
|
|
40
|
-
"---",
|
|
41
|
-
`id: ${id}`,
|
|
42
|
-
`type: ${type}`,
|
|
43
|
-
`title: "${title}"`,
|
|
44
|
-
`status: draft`,
|
|
45
|
-
`version: "0.1"`,
|
|
46
|
-
`created: ${today}`,
|
|
47
|
-
`authors: []`,
|
|
48
|
-
"---",
|
|
49
|
-
].join("\n");
|
|
50
|
-
const body = sections.map((section) => `\n## ${section}\n\n<!-- placeholder -->`).join("\n");
|
|
51
|
-
return `${frontmatter}\n${body}\n`;
|
|
52
|
-
}
|
|
53
|
-
function buildConfigYaml(projectName, specs) {
|
|
54
|
-
const specEntries = specs
|
|
55
|
-
.map(({ filename, type }) => {
|
|
56
|
-
const key = specIdFromFilename(filename);
|
|
57
|
-
return ` ${key}:\n path: specs/${filename}\n type: ${type}`;
|
|
58
|
-
})
|
|
59
|
-
.join("\n");
|
|
60
|
-
return ([`version: "1.0"`, `project:`, ` name: "${projectName}"`, `specs:`, specEntries].join("\n") +
|
|
61
|
-
"\n");
|
|
62
|
-
}
|
|
63
|
-
export async function scaffoldProject({ projectName, template, targetDir, }) {
|
|
64
|
-
const today = new Date().toISOString().slice(0, 10);
|
|
65
|
-
const specsDir = join(targetDir, "specs");
|
|
66
|
-
// Create specs/ directory
|
|
67
|
-
await mkdir(specsDir, { recursive: true });
|
|
68
|
-
// Create extra template dirs (e.g., bmad needs stories/ and adr/)
|
|
69
|
-
for (const extraDir of TEMPLATE_EXTRA_DIRS[template]) {
|
|
70
|
-
await mkdir(join(targetDir, extraDir), { recursive: true });
|
|
71
|
-
}
|
|
72
|
-
const specs = TEMPLATE_SPECS[template];
|
|
73
|
-
// Write spec files
|
|
74
|
-
for (const { filename, type } of specs) {
|
|
75
|
-
const content = buildSpecFile(filename, type, projectName, today);
|
|
76
|
-
await writeFile(join(specsDir, filename), content, "utf-8");
|
|
77
|
-
}
|
|
78
|
-
// Write spec.config.yaml
|
|
79
|
-
const configContent = buildConfigYaml(projectName, specs);
|
|
80
|
-
await writeFile(join(targetDir, "spec.config.yaml"), configContent, "utf-8");
|
|
81
|
-
}
|
|
82
|
-
export default defineCommand({
|
|
83
|
-
meta: {
|
|
84
|
-
name: "init",
|
|
85
|
-
description: "Initialize a new SDX project with spec scaffolding",
|
|
86
|
-
},
|
|
87
|
-
args: {
|
|
88
|
-
name: {
|
|
89
|
-
type: "string",
|
|
90
|
-
description: "Project name",
|
|
91
|
-
required: true,
|
|
92
|
-
},
|
|
93
|
-
template: {
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "Template to use (lightweight, bmad, api-first)",
|
|
96
|
-
default: "lightweight",
|
|
97
|
-
},
|
|
98
|
-
dir: {
|
|
99
|
-
type: "string",
|
|
100
|
-
description: "Target directory",
|
|
101
|
-
default: ".",
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
async run({ args }) {
|
|
105
|
-
const { name, template, dir } = args;
|
|
106
|
-
const validTemplates = ["lightweight", "bmad", "api-first"];
|
|
107
|
-
if (!validTemplates.includes(template)) {
|
|
108
|
-
console.error(`Unknown template: ${template}. Choose from: ${validTemplates.join(", ")}`);
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
console.log(`Scaffolding "${name}" with template "${template}" in ${dir}...`);
|
|
112
|
-
await scaffoldProject({ projectName: name, template: template, targetDir: dir });
|
|
113
|
-
console.log(`Done! Project "${name}" scaffolded successfully.`);
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
//# sourceMappingURL=init.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAUhD,MAAM,cAAc,GAGhB;IACF,WAAW,EAAE;QACX,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAA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E,kBAAkB;YAC/B,OAAO,EAAE,GAAG;SACb;KACF;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QAChB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QACrC,MAAM,cAAc,GAAe,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACxE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAoB,CAAC,EAAE,CAAC;YACnD,OAAO,CAAC,KAAK,CAAC,qBAAqB,QAAQ,kBAAkB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,oBAAoB,QAAQ,QAAQ,GAAG,KAAK,CAAC,CAAC;QAC9E,MAAM,eAAe,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAoB,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7F,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,4BAA4B,CAAC,CAAC;IAClE,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.test.d.ts","sourceRoot":"","sources":["../../src/commands/init.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { mkdtemp, rm, readFile, readdir } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { scaffoldProject } from "./init.js";
|
|
6
|
-
describe("scaffoldProject", () => {
|
|
7
|
-
let tempDir;
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
tempDir = await mkdtemp(join(tmpdir(), "sdx-test-"));
|
|
10
|
-
});
|
|
11
|
-
afterEach(async () => {
|
|
12
|
-
await rm(tempDir, { recursive: true });
|
|
13
|
-
});
|
|
14
|
-
it("scaffolds a lightweight project", async () => {
|
|
15
|
-
await scaffoldProject({
|
|
16
|
-
projectName: "test-project",
|
|
17
|
-
template: "lightweight",
|
|
18
|
-
targetDir: tempDir,
|
|
19
|
-
});
|
|
20
|
-
const config = await readFile(join(tempDir, "spec.config.yaml"), "utf-8");
|
|
21
|
-
expect(config).toContain("version:");
|
|
22
|
-
expect(config).toContain("test-project");
|
|
23
|
-
const files = await readdir(join(tempDir, "specs"));
|
|
24
|
-
expect(files).toContain("prd.md");
|
|
25
|
-
expect(files).toContain("technical-design.md");
|
|
26
|
-
});
|
|
27
|
-
it("scaffolds a bmad project", async () => {
|
|
28
|
-
await scaffoldProject({ projectName: "bmad-project", template: "bmad", targetDir: tempDir });
|
|
29
|
-
const config = await readFile(join(tempDir, "spec.config.yaml"), "utf-8");
|
|
30
|
-
expect(config).toContain("bmad-project");
|
|
31
|
-
});
|
|
32
|
-
it("scaffolds an api-first project", async () => {
|
|
33
|
-
await scaffoldProject({
|
|
34
|
-
projectName: "api-project",
|
|
35
|
-
template: "api-first",
|
|
36
|
-
targetDir: tempDir,
|
|
37
|
-
});
|
|
38
|
-
const files = await readdir(join(tempDir, "specs"));
|
|
39
|
-
expect(files).toContain("api-contract.md");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=init.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.test.js","sourceRoot":"","sources":["../../src/commands/init.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,IAAI,EAA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,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7F,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC,EAAE,OAAO,CAAC,CAAC;QAC1E,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,eAAe,CAAC;YACpB,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE,OAAO;SACnB,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/commands/lint.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { type LintResults } from "@sdx/lint";
|
|
2
|
-
export interface RunLintOptions {
|
|
3
|
-
configDir: string;
|
|
4
|
-
specPath?: string;
|
|
5
|
-
preset?: "minimal" | "recommended" | "strict";
|
|
6
|
-
}
|
|
7
|
-
export declare function runLint(options: RunLintOptions): Promise<LintResults>;
|
|
8
|
-
declare const _default: import("citty").CommandDef<{
|
|
9
|
-
readonly fix: {
|
|
10
|
-
readonly type: "boolean";
|
|
11
|
-
readonly description: "Auto-fix issues where possible";
|
|
12
|
-
};
|
|
13
|
-
readonly path: {
|
|
14
|
-
readonly type: "positional";
|
|
15
|
-
readonly description: "Lint a specific spec file";
|
|
16
|
-
readonly required: false;
|
|
17
|
-
};
|
|
18
|
-
readonly preset: {
|
|
19
|
-
readonly type: "string";
|
|
20
|
-
readonly description: "Lint preset (minimal, recommended, strict)";
|
|
21
|
-
};
|
|
22
|
-
readonly quiet: {
|
|
23
|
-
type: "boolean";
|
|
24
|
-
description: string;
|
|
25
|
-
alias: string[];
|
|
26
|
-
};
|
|
27
|
-
readonly verbose: {
|
|
28
|
-
type: "boolean";
|
|
29
|
-
description: string;
|
|
30
|
-
alias: string[];
|
|
31
|
-
};
|
|
32
|
-
readonly format: {
|
|
33
|
-
type: "string";
|
|
34
|
-
description: string;
|
|
35
|
-
default: string;
|
|
36
|
-
};
|
|
37
|
-
}>;
|
|
38
|
-
export default _default;
|
|
39
|
-
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/commands/lint.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAO1E,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC;CAC/C;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAoC3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,wBA2BG"}
|
package/dist/commands/lint.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { loadConfig, parseSpec, resolveGlob, buildGraph, createLogger } from "@sdx/core";
|
|
3
|
-
import { createLintEngine, getPreset } from "@sdx/lint";
|
|
4
|
-
import { sharedArgs } from "../shared-args.js";
|
|
5
|
-
import { formatPretty } from "../formatters/pretty.js";
|
|
6
|
-
import { formatJson } from "../formatters/json.js";
|
|
7
|
-
import { formatGithub } from "../formatters/github.js";
|
|
8
|
-
export async function runLint(options) {
|
|
9
|
-
const config = await loadConfig(undefined, options.configDir);
|
|
10
|
-
const preset = options.preset ?? config.lint?.extends ?? "recommended";
|
|
11
|
-
const rules = getPreset(preset);
|
|
12
|
-
const specs = [];
|
|
13
|
-
for (const [, entry] of Object.entries(config.specs)) {
|
|
14
|
-
const files = await resolveGlob(entry.path, options.configDir);
|
|
15
|
-
for (const file of files) {
|
|
16
|
-
if (options.specPath && !file.includes(options.specPath))
|
|
17
|
-
continue;
|
|
18
|
-
specs.push(await parseSpec(file));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
let graph;
|
|
22
|
-
let graphError;
|
|
23
|
-
try {
|
|
24
|
-
graph = buildGraph(config);
|
|
25
|
-
}
|
|
26
|
-
catch (err) {
|
|
27
|
-
graphError = err.message;
|
|
28
|
-
}
|
|
29
|
-
const engine = createLintEngine({ rules, config, graph });
|
|
30
|
-
const results = engine.lint(specs);
|
|
31
|
-
if (graphError) {
|
|
32
|
-
results.diagnostics.push({
|
|
33
|
-
ruleId: "structure/no-circular-deps",
|
|
34
|
-
severity: "error",
|
|
35
|
-
message: graphError,
|
|
36
|
-
filePath: "spec.config.yaml",
|
|
37
|
-
});
|
|
38
|
-
results.hasErrors = true;
|
|
39
|
-
}
|
|
40
|
-
return results;
|
|
41
|
-
}
|
|
42
|
-
export default defineCommand({
|
|
43
|
-
meta: { name: "lint", description: "Lint all specs in the suite" },
|
|
44
|
-
args: {
|
|
45
|
-
...sharedArgs,
|
|
46
|
-
fix: { type: "boolean", description: "Auto-fix issues where possible" },
|
|
47
|
-
path: { type: "positional", description: "Lint a specific spec file", required: false },
|
|
48
|
-
preset: { type: "string", description: "Lint preset (minimal, recommended, strict)" },
|
|
49
|
-
},
|
|
50
|
-
async run({ args }) {
|
|
51
|
-
const logger = createLogger({ quiet: args.quiet, verbose: args.verbose });
|
|
52
|
-
if (args.fix) {
|
|
53
|
-
logger.info("No auto-fixable issues supported yet.");
|
|
54
|
-
}
|
|
55
|
-
const results = await runLint({
|
|
56
|
-
configDir: process.cwd(),
|
|
57
|
-
specPath: args.path,
|
|
58
|
-
preset: args.preset,
|
|
59
|
-
});
|
|
60
|
-
const formatter = args.format === "json" ? formatJson : args.format === "github" ? formatGithub : formatPretty;
|
|
61
|
-
console.log(formatter(results.diagnostics));
|
|
62
|
-
if (results.hasErrors)
|
|
63
|
-
process.exit(1);
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=lint.js.map
|