@typecad/cuttlefish 1.0.0-alpha.13 → 1.0.0-alpha.14
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/assets/editor-extensions/typecad-debug/README.md +142 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
- package/assets/editor-extensions/typecad-debug/package.json +76 -0
- package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
- package/assets/editor-extensions/typecad-ui/README.md +52 -0
- package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
- package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
- package/assets/editor-extensions/typecad-ui/icon.png +0 -0
- package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
- package/assets/editor-extensions/typecad-ui/package.json +54 -0
- package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
- package/dist/api/config.d.ts +8 -1
- package/dist/api/shared/framework-manifest.d.ts +61 -504
- package/dist/cli.js +17 -6
- package/dist/config-loader.js +3 -1
- package/dist/config-schema.d.ts +17 -223
- package/dist/config-schema.js +1 -0
- package/dist/contract/contract-parser.d.ts +9 -127
- package/dist/create/board-checklist.js +1 -1
- package/dist/create/board-codegen.js +4 -4
- package/dist/create/board-spec.d.ts +74 -530
- package/dist/create/editor-integration.d.ts +30 -0
- package/dist/create/editor-integration.js +218 -0
- package/dist/create/eslint-rules-template.d.ts +2 -2
- package/dist/create/framework-catalog.d.ts +8 -0
- package/dist/create/framework-catalog.js +28 -5
- package/dist/create/index.d.ts +7 -6
- package/dist/create/index.js +5 -4
- package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +4 -4
- package/dist/create/{init-scaffold.js → scaffold.js} +33 -2
- package/dist/create/templates.d.ts +29 -0
- package/dist/create/{init-templates.js → templates.js} +15 -0
- package/dist/create/wizard.d.ts +8 -0
- package/dist/create/{init-wizard.js → wizard.js} +11 -4
- package/dist/emit/emitters/setup.js +22 -0
- package/dist/ir/build-ir.js +24 -3
- package/dist/library/catalog.d.ts +35 -0
- package/dist/library/catalog.js +67 -0
- package/dist/library/cli.d.ts +2 -0
- package/dist/library/cli.js +168 -0
- package/dist/library/init.d.ts +25 -0
- package/dist/library/init.js +397 -0
- package/dist/library/install.d.ts +9 -0
- package/dist/library/install.js +80 -0
- package/dist/library/registry-search.d.ts +34 -0
- package/dist/library/registry-search.js +50 -0
- package/dist/library/validate.d.ts +17 -0
- package/dist/library/validate.js +175 -0
- package/dist/library-packages.d.ts +95 -0
- package/dist/library-packages.js +275 -0
- package/dist/orchestrator/graph-builder.js +16 -0
- package/dist/preview/client.js +17 -3
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/transpile.js +55 -0
- package/dist/types.d.ts +19 -0
- package/dist/utils/cli.d.ts +2 -2
- package/dist/utils/cli.js +68 -3
- package/package.json +16 -8
- package/dist/create/init-templates.d.ts +0 -28
- package/dist/create/init-wizard.d.ts +0 -8
package/dist/ir/build-ir.js
CHANGED
|
@@ -8,7 +8,7 @@ import { buildFunctionReturnTypeMap } from "./type-resolution.js";
|
|
|
8
8
|
import { resolveBoardConstants, tryResolveBoardDefFile } from "./board-resolver.js";
|
|
9
9
|
import { analyzePeripheralUsage, createEmptyPeripheralUsage } from "./peripheral-usage.js";
|
|
10
10
|
import { runProgramValidations } from "./validation-orchestrator.js";
|
|
11
|
-
import { registerFieldMap, hoistedNestedFunctions, hoistedNestedClasses, hoistedNestedEnums, hoistedNestedInterfaces, hoistedNestedTypeAliases, activeNamespaceNames, activeEnumNames, activeStringEnumNames, peripheralAliasMap, pinAliasMap, mcuPinReverseMap, topLevelClassNames, topLevelInterfaceNames, classTypeNames, topLevelClasses, requiredIncludes, resetBuildState, getCurrentBoardConstants, setCurrentBoardConstants, contextStorage, CompilationContext, registeredCallbacks, getContext, discriminatedUnionVariantNames, restParamFunctions, topLevelAliasReceivers } from "./build-ir-state.js";
|
|
11
|
+
import { registerFieldMap, hoistedNestedFunctions, hoistedNestedClasses, hoistedNestedEnums, hoistedNestedInterfaces, hoistedNestedTypeAliases, activeNamespaceNames, activeEnumNames, activeStringEnumNames, peripheralAliasMap, pinAliasMap, mcuPinForwardMap, mcuPinReverseMap, topLevelClassNames, topLevelInterfaceNames, classTypeNames, topLevelClasses, requiredIncludes, resetBuildState, getCurrentBoardConstants, setCurrentBoardConstants, contextStorage, CompilationContext, registeredCallbacks, getContext, discriminatedUnionVariantNames, restParamFunctions, topLevelAliasReceivers } from "./build-ir-state.js";
|
|
12
12
|
import { pinShadowVarName, takeShadowDeclarations, resetPinStateTracking, markShadowUpdatingOps } from "./pin-state-tracking.js";
|
|
13
13
|
import { collectPointerVars, expressionStatementToIR, lowerStatement, variableStatementToIR, prescanArrayUsage, lowerStatementList } from "./statement-to-ir.js";
|
|
14
14
|
import { registerUIModuleImport, registerElementValue } from "./transformers/ui-call-resolver.js";
|
|
@@ -497,10 +497,31 @@ export function buildProgramIR(fileName, sourceText, boardPackage, prebuiltClass
|
|
|
497
497
|
halInstances.set(name, { className: "Pin", fieldValues: fields });
|
|
498
498
|
continue;
|
|
499
499
|
}
|
|
500
|
-
// A-pins: A0
|
|
500
|
+
// A-pins: A0, A1, … → resolve through the board manifest's analog
|
|
501
|
+
// pin list first (A-ordered on every board package: A<n> →
|
|
502
|
+
// pins.analog[n] → the MCU port name → pin number). Only when the
|
|
503
|
+
// list is absent (bare Arduino-style boards) fall back to the
|
|
504
|
+
// analogOffset convention (A0 = 14) — on port-named boards that
|
|
505
|
+
// fallback resolves A1 to a random GPIO (Black Pill PA15, a
|
|
506
|
+
// non-analog pin, was the first to surface it via a capability
|
|
507
|
+
// error).
|
|
501
508
|
const aMatch = name.match(/^A(\d+)$/);
|
|
502
509
|
if (aMatch) {
|
|
503
|
-
|
|
510
|
+
let pinNum;
|
|
511
|
+
// The flattener stores the manifest's analog pin list as a
|
|
512
|
+
// comma-joined string under `pins.analog`.
|
|
513
|
+
const analogList = boardConstants.get("pins.analog");
|
|
514
|
+
if (typeof analogList === "string") {
|
|
515
|
+
const analogName = analogList.split(",")[parseInt(aMatch[1], 10)];
|
|
516
|
+
if (analogName) {
|
|
517
|
+
const byName = mcuPinForwardMap.get(analogName);
|
|
518
|
+
if (byName !== undefined)
|
|
519
|
+
pinNum = String(byName);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (pinNum === undefined) {
|
|
523
|
+
pinNum = String(analogOffset + parseInt(aMatch[1]));
|
|
524
|
+
}
|
|
504
525
|
const fields = new Map([["_pin", pinNum]]);
|
|
505
526
|
const portName = mcuPinReverseMap.get(pinNum);
|
|
506
527
|
if (portName)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The one keyword every cuttlefish library package must carry. */
|
|
2
|
+
export declare const LIBRARY_MARKER_KEYWORD = "cuttlefish-library";
|
|
3
|
+
/** Prefix for category keywords (`cuttlefish-<id>`). */
|
|
4
|
+
export declare const CATEGORY_KEYWORD_PREFIX = "cuttlefish-";
|
|
5
|
+
export interface LibraryCategory {
|
|
6
|
+
/** Stable id used in --category flags, keywords, and docs. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Human label for prompts and tables. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** One-line scope description. */
|
|
11
|
+
description: string;
|
|
12
|
+
/** Example parts the category covers (prompt/README guidance). */
|
|
13
|
+
examples: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The category taxonomy. Shared by search (query building + result shaping),
|
|
17
|
+
* init (scaffold choices + keywords), validate (keyword consistency), and the
|
|
18
|
+
* website's Library Packages page (rendered from the same list).
|
|
19
|
+
*/
|
|
20
|
+
export declare const LIBRARY_CATEGORIES: readonly LibraryCategory[];
|
|
21
|
+
/** Look up a category by id (case-insensitive). */
|
|
22
|
+
export declare function libraryCategory(id: string): LibraryCategory | undefined;
|
|
23
|
+
/** The npm keyword for a category (`cuttlefish-<id>`). */
|
|
24
|
+
export declare function categoryKeyword(id: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Derive the category of an npm search result from its keywords. A package may
|
|
27
|
+
* carry several category keywords; the first match in taxonomy order wins so
|
|
28
|
+
* results are stable.
|
|
29
|
+
*/
|
|
30
|
+
export declare function categoryFromKeywords(keywords: readonly string[] | undefined): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* The keywords a library package should carry: the marker plus its category
|
|
33
|
+
* keyword. Used by `library init` and checked by `library validate`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function requiredLibraryKeywords(categoryId: string): string[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Cuttlefish library catalog — the category taxonomy and npm keyword
|
|
3
|
+
// conventions behind `cuttlefish library search/init/validate`.
|
|
4
|
+
//
|
|
5
|
+
// The catalog has no registry service: npm keywords ARE the catalog. Every
|
|
6
|
+
// library package carries the marker keyword LIBRARY_MARKER_KEYWORD plus one
|
|
7
|
+
// category keyword (e.g. 'cuttlefish-led'). npm's search endpoint ANDs
|
|
8
|
+
// `keywords:` terms, so queries compose:
|
|
9
|
+
//
|
|
10
|
+
// keywords:cuttlefish-library → every library
|
|
11
|
+
// keywords:cuttlefish-library keywords:cuttlefish-led → the led category
|
|
12
|
+
// keywords:cuttlefish-library ws2812 → free-text within libraries
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
/** The one keyword every cuttlefish library package must carry. */
|
|
15
|
+
export const LIBRARY_MARKER_KEYWORD = "cuttlefish-library";
|
|
16
|
+
/** Prefix for category keywords (`cuttlefish-<id>`). */
|
|
17
|
+
export const CATEGORY_KEYWORD_PREFIX = "cuttlefish-";
|
|
18
|
+
/**
|
|
19
|
+
* The category taxonomy. Shared by search (query building + result shaping),
|
|
20
|
+
* init (scaffold choices + keywords), validate (keyword consistency), and the
|
|
21
|
+
* website's Library Packages page (rendered from the same list).
|
|
22
|
+
*/
|
|
23
|
+
export const LIBRARY_CATEGORIES = [
|
|
24
|
+
{ id: "led", label: "LEDs", description: "LEDs, addressable strips, LED drivers", examples: "WS2812-class pixels, LED drivers, bar graphs" },
|
|
25
|
+
{ id: "display", label: "Displays", description: "Panels and panel drivers", examples: "TFT, OLED, e-ink" },
|
|
26
|
+
{ id: "sensor", label: "Sensors", description: "Measurement parts", examples: "environmental, motion, IMU, light, distance" },
|
|
27
|
+
{ id: "actuator", label: "Actuators", description: "Things that move or switch", examples: "motors, servos, steppers, relays" },
|
|
28
|
+
{ id: "comms", label: "Communications", description: "Radios and networking beyond built-in WiFi/BLE", examples: "LoRa, GSM, satellite, CAN add-ons" },
|
|
29
|
+
{ id: "storage", label: "Storage", description: "Persistent storage parts", examples: "SD cards, flash chips, FRAM" },
|
|
30
|
+
{ id: "audio", label: "Audio", description: "Sound input and output", examples: "microphones, amplifiers, codecs" },
|
|
31
|
+
{ id: "power", label: "Power", description: "Power management and monitoring", examples: "PMICs, battery gauges, chargers" },
|
|
32
|
+
{ id: "input", label: "Input", description: "Add-on human input", examples: "keypads, rotary encoders, add-on touch" },
|
|
33
|
+
{ id: "io", label: "I/O Expanders", description: "Extra I/O and simple drivers", examples: "port expanders, matrix drivers, 7-segment" },
|
|
34
|
+
{ id: "timing", label: "Timing", description: "Clocks and time sources", examples: "RTCs, precision clocks, GPS time" },
|
|
35
|
+
{ id: "utility", label: "Utility", description: "Pure-code helpers with no hardware of their own", examples: "formats, algorithms, protocol codecs" },
|
|
36
|
+
];
|
|
37
|
+
/** Look up a category by id (case-insensitive). */
|
|
38
|
+
export function libraryCategory(id) {
|
|
39
|
+
const lower = id.toLowerCase();
|
|
40
|
+
return LIBRARY_CATEGORIES.find((c) => c.id === lower);
|
|
41
|
+
}
|
|
42
|
+
/** The npm keyword for a category (`cuttlefish-<id>`). */
|
|
43
|
+
export function categoryKeyword(id) {
|
|
44
|
+
return `${CATEGORY_KEYWORD_PREFIX}${id.toLowerCase()}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Derive the category of an npm search result from its keywords. A package may
|
|
48
|
+
* carry several category keywords; the first match in taxonomy order wins so
|
|
49
|
+
* results are stable.
|
|
50
|
+
*/
|
|
51
|
+
export function categoryFromKeywords(keywords) {
|
|
52
|
+
if (!keywords || keywords.length === 0)
|
|
53
|
+
return null;
|
|
54
|
+
const set = new Set(keywords.map((k) => k.toLowerCase()));
|
|
55
|
+
for (const category of LIBRARY_CATEGORIES) {
|
|
56
|
+
if (set.has(categoryKeyword(category.id)))
|
|
57
|
+
return category.id;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The keywords a library package should carry: the marker plus its category
|
|
63
|
+
* keyword. Used by `library init` and checked by `library validate`.
|
|
64
|
+
*/
|
|
65
|
+
export function requiredLibraryKeywords(categoryId) {
|
|
66
|
+
return [LIBRARY_MARKER_KEYWORD, categoryKeyword(categoryId)];
|
|
67
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// `cuttlefish library <subcommand>` — CLI glue for the library manager.
|
|
3
|
+
// Subcommands: search, install, init, validate. The catalog modules own the
|
|
4
|
+
// logic; this module owns argument interpretation and presentation.
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { LIBRARY_CATEGORIES, libraryCategory } from "./catalog.js";
|
|
9
|
+
import { searchLibraryPackages } from "./registry-search.js";
|
|
10
|
+
import { findProjectPackageJson, installedDependencyVersion, npmInstall } from "./install.js";
|
|
11
|
+
import { runLibraryInit } from "./init.js";
|
|
12
|
+
import { validateLibraryPackage, printValidationReport } from "./validate.js";
|
|
13
|
+
function requireCategory(category, command) {
|
|
14
|
+
if (category === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
if (!libraryCategory(category)) {
|
|
17
|
+
throw new Error(`Unknown category '${category}' for 'library ${command}'. Known categories: ` +
|
|
18
|
+
LIBRARY_CATEGORIES.map((c) => c.id).join(", ") +
|
|
19
|
+
".");
|
|
20
|
+
}
|
|
21
|
+
return category.toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
function stripVersionPrefix(v) {
|
|
24
|
+
return v.replace(/^[^0-9]*/, "");
|
|
25
|
+
}
|
|
26
|
+
async function runSearch(options) {
|
|
27
|
+
const category = requireCategory(options.category, "search");
|
|
28
|
+
const text = options.positionals.join(" ");
|
|
29
|
+
let results;
|
|
30
|
+
try {
|
|
31
|
+
results = await searchLibraryPackages(text || undefined, category);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
throw new Error(`Failed to search npm: ${e instanceof Error ? e.message : String(e)}`);
|
|
35
|
+
}
|
|
36
|
+
if (options.json) {
|
|
37
|
+
const pkgPath = findProjectPackageJson();
|
|
38
|
+
console.log(JSON.stringify(results.map((r) => ({
|
|
39
|
+
name: r.name,
|
|
40
|
+
version: r.version,
|
|
41
|
+
description: r.description,
|
|
42
|
+
category: r.category,
|
|
43
|
+
npmUrl: r.npmUrl,
|
|
44
|
+
installed: pkgPath ? installedDependencyVersion(pkgPath, r.name) !== undefined : false,
|
|
45
|
+
})), null, 2));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const header = category
|
|
49
|
+
? `cuttlefish libraries — category: ${libraryCategory(category).label}`
|
|
50
|
+
: "cuttlefish libraries";
|
|
51
|
+
console.log(chalk.green("+") + " " + chalk.white.bold(header) + chalk.gray(` (npm keyword: cuttlefish-library${category ? ` + cuttlefish-${category}` : ""})`));
|
|
52
|
+
console.log();
|
|
53
|
+
if (results.length === 0) {
|
|
54
|
+
console.log(chalk.yellow("No matching library packages on npm yet."));
|
|
55
|
+
console.log(` Scaffold the first one: ${chalk.cyan("cuttlefish library init")}`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const pkgPath = findProjectPackageJson();
|
|
59
|
+
for (const r of results) {
|
|
60
|
+
const cat = r.category ? libraryCategory(r.category) : undefined;
|
|
61
|
+
const installedSpec = pkgPath ? installedDependencyVersion(pkgPath, r.name) : undefined;
|
|
62
|
+
const state = installedSpec
|
|
63
|
+
? stripVersionPrefix(installedSpec) === r.version
|
|
64
|
+
? chalk.gray(" (installed)")
|
|
65
|
+
: chalk.yellow(` (installed v${stripVersionPrefix(installedSpec)}, latest v${r.version})`)
|
|
66
|
+
: "";
|
|
67
|
+
console.log(` ${chalk.white.bold(r.name)} ${chalk.dim(`v${r.version}`)}${state}`);
|
|
68
|
+
if (cat) {
|
|
69
|
+
console.log(` ${chalk.cyan(`[${cat.label}]`)} ${r.description ?? ""}`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log(` ${r.description ?? ""}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
console.log();
|
|
76
|
+
console.log(chalk.gray(` Install with: cuttlefish library install <name>`));
|
|
77
|
+
}
|
|
78
|
+
function runInstall(options) {
|
|
79
|
+
const names = options.positionals;
|
|
80
|
+
if (names.length === 0) {
|
|
81
|
+
throw new Error("Usage: cuttlefish library install <package...>");
|
|
82
|
+
}
|
|
83
|
+
const pkgPath = findProjectPackageJson();
|
|
84
|
+
if (!pkgPath) {
|
|
85
|
+
throw new Error("No package.json found in this directory or any parent — run inside a cuttlefish project.");
|
|
86
|
+
}
|
|
87
|
+
const pkgDir = path.dirname(pkgPath);
|
|
88
|
+
if (options.json) {
|
|
89
|
+
const before = Object.fromEntries(names.map((n) => [n, installedDependencyVersion(pkgPath, n) ?? null]));
|
|
90
|
+
try {
|
|
91
|
+
npmInstall(names, pkgDir);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
const err = e;
|
|
95
|
+
const detail = err.stderr?.toString().trim() || (e instanceof Error ? e.message : String(e));
|
|
96
|
+
throw new Error(`Failed to install packages: ${detail}`);
|
|
97
|
+
}
|
|
98
|
+
console.log(JSON.stringify({ installed: names, projectRoot: pkgDir, previous: before }, null, 2));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
console.log(chalk.green("+") + ` Installing ${names.join(", ")}...`);
|
|
102
|
+
try {
|
|
103
|
+
npmInstall(names, pkgDir);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
const err = e;
|
|
107
|
+
const detail = err.stderr?.toString().trim() || (e instanceof Error ? e.message : String(e));
|
|
108
|
+
throw new Error(`Failed to install packages: ${detail}`);
|
|
109
|
+
}
|
|
110
|
+
for (const name of names) {
|
|
111
|
+
console.log(chalk.green("+") + ` ${name}`);
|
|
112
|
+
console.log(chalk.gray(` https://www.npmjs.com/package/${name}`));
|
|
113
|
+
}
|
|
114
|
+
console.log(chalk.green("✔") + " Done");
|
|
115
|
+
}
|
|
116
|
+
async function runInit(options) {
|
|
117
|
+
if (options.category !== undefined) {
|
|
118
|
+
requireCategory(options.category, "init");
|
|
119
|
+
}
|
|
120
|
+
await runLibraryInit({
|
|
121
|
+
name: options.positionals[0],
|
|
122
|
+
framework: options.framework,
|
|
123
|
+
category: options.category,
|
|
124
|
+
targets: options.targets,
|
|
125
|
+
dir: options.dir,
|
|
126
|
+
yes: options.yes,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function runValidate(options) {
|
|
130
|
+
const dir = options.positionals[0] ?? process.cwd();
|
|
131
|
+
const report = validateLibraryPackage(dir);
|
|
132
|
+
if (options.json) {
|
|
133
|
+
console.log(JSON.stringify({
|
|
134
|
+
valid: report.valid,
|
|
135
|
+
dir: report.dir,
|
|
136
|
+
errors: report.errors,
|
|
137
|
+
warnings: report.warnings,
|
|
138
|
+
autosarFindings: report.autosarFindings,
|
|
139
|
+
}, null, 2));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
console.log(chalk.white.bold(`cuttlefish library validate`) + chalk.gray(` ${report.dir}`));
|
|
143
|
+
console.log();
|
|
144
|
+
const code = printValidationReport(report);
|
|
145
|
+
if (code !== 0) {
|
|
146
|
+
process.exitCode = code;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (!report.valid && options.json) {
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
export async function runLibraryCommand(options) {
|
|
154
|
+
switch (options.subcommand) {
|
|
155
|
+
case "search":
|
|
156
|
+
await runSearch(options);
|
|
157
|
+
return;
|
|
158
|
+
case "install":
|
|
159
|
+
runInstall(options);
|
|
160
|
+
return;
|
|
161
|
+
case "init":
|
|
162
|
+
await runInit(options);
|
|
163
|
+
return;
|
|
164
|
+
case "validate":
|
|
165
|
+
runValidate(options);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface LibraryInitOptions {
|
|
2
|
+
/** Full package name (e.g. '@acme/esp32-led-ring' or 'my-lib'). */
|
|
3
|
+
name?: string;
|
|
4
|
+
/** Framework id from FRAMEWORK_CATALOG ('zephyr', 'arduino', ...). */
|
|
5
|
+
framework?: string;
|
|
6
|
+
/** Category id from LIBRARY_CATEGORIES. */
|
|
7
|
+
category?: string;
|
|
8
|
+
/** Comma-separated board-target prefixes (e.g. 'esp32s3_devkitc'). */
|
|
9
|
+
targets?: string;
|
|
10
|
+
/** Directory to scaffold into (default: ./<package basename>). */
|
|
11
|
+
dir?: string;
|
|
12
|
+
/** Skip prompts; take defaults for anything not provided by flags. */
|
|
13
|
+
yes?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface LibraryInitResult {
|
|
16
|
+
packageDir: string;
|
|
17
|
+
packageName: string;
|
|
18
|
+
/** The library id (slug of the package basename). */
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
/** Slug of a package basename: lowercase, runs of non-alphanumerics → '-'. */
|
|
22
|
+
export declare function libraryIdFromPackageName(packageName: string): string;
|
|
23
|
+
/** '__tc_my_lib' for id 'my-lib' — a valid C++ identifier prefix. */
|
|
24
|
+
export declare function tokenBaseFromId(id: string): string;
|
|
25
|
+
export declare function runLibraryInit(options: LibraryInitOptions): Promise<LibraryInitResult>;
|