@machineblocks/cli 0.0.0-stage → 0.1.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.
Files changed (47) hide show
  1. package/blocks/com/machineblocks/bml/cli/Library.bml +52 -0
  2. package/blocks/com/machineblocks/bml/cli/README.bml +31 -0
  3. package/blocks/com/machineblocks/bml/cli/documentation/Commands.bml +106 -0
  4. package/blocks/com/machineblocks/bml/cli/documentation/Configuration.bml +54 -0
  5. package/blocks/com/machineblocks/bml/cli/documentation/DualCliModel.bml +51 -0
  6. package/blocks/com/machineblocks/bml/cli/documentation/Installation.bml +52 -0
  7. package/blocks/com/machineblocks/bml/cli/documentation/Introduction.bml +39 -0
  8. package/blocks/com/machineblocks/bml/cli/documentation/Responsibilities.bml +50 -0
  9. package/blocks/com/machineblocks/bml/cli/documentation/TargetBootstrap.bml +45 -0
  10. package/dist/args.d.ts +28 -0
  11. package/dist/args.d.ts.map +1 -0
  12. package/dist/args.js +139 -0
  13. package/dist/args.js.map +1 -0
  14. package/dist/cli.d.ts +3 -0
  15. package/dist/cli.d.ts.map +1 -0
  16. package/dist/cli.js +9 -0
  17. package/dist/cli.js.map +1 -0
  18. package/dist/compile-command.d.ts +7 -0
  19. package/dist/compile-command.d.ts.map +1 -0
  20. package/dist/compile-command.js +213 -0
  21. package/dist/compile-command.js.map +1 -0
  22. package/dist/execute.d.ts +4 -0
  23. package/dist/execute.d.ts.map +1 -0
  24. package/dist/execute.js +22 -0
  25. package/dist/execute.js.map +1 -0
  26. package/dist/help.d.ts +4 -0
  27. package/dist/help.d.ts.map +1 -0
  28. package/dist/help.js +39 -0
  29. package/dist/help.js.map +1 -0
  30. package/dist/index.d.ts +2 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +2 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/init-command.d.ts +4 -0
  35. package/dist/init-command.d.ts.map +1 -0
  36. package/dist/init-command.js +121 -0
  37. package/dist/init-command.js.map +1 -0
  38. package/dist/output-gate.d.ts +11 -0
  39. package/dist/output-gate.d.ts.map +1 -0
  40. package/dist/output-gate.js +76 -0
  41. package/dist/output-gate.js.map +1 -0
  42. package/dist/validate-command.d.ts +4 -0
  43. package/dist/validate-command.d.ts.map +1 -0
  44. package/dist/validate-command.js +47 -0
  45. package/dist/validate-command.js.map +1 -0
  46. package/package.json +45 -4
  47. package/README.md +0 -3
@@ -0,0 +1,52 @@
1
+ <!--MachineBlocks CLI Library
2
+ FQN: com.machineblocks.bml.cli.Library-->
3
+ <mbcli:Library xmlns="http://blockml.org/bml"
4
+ xmlns:blockml="org.blockml.bml"
5
+ xmlns:core="org.blockml.bml.core"
6
+ xmlns:ucli="org.blockml.bml.cli"
7
+ xmlns:render="com.machineblocks.bml.target.render"
8
+ xmlns:mbcli="com.machineblocks.bml.cli">
9
+
10
+ <baseType>
11
+ core:BlockLibrary
12
+ </baseType>
13
+ <is>
14
+ The MachineBlocks host CLI library catalog
15
+ </is>
16
+ <version>
17
+ 0.1.1
18
+ </version>
19
+ <documentation>
20
+ Publishable host-CLI library (com.machineblocks.bml.cli.Library).
21
+ Thin layer over @blockml/cli that registers the MachineBlocks SCAD target
22
+ and supplies MachineBlocks defaults. Recommended entry for MachineBlocks
23
+ users who want BML rendered to SCAD.
24
+
25
+ Membership is the file tree under this Library.bml.
26
+ </documentation>
27
+ <references>
28
+ <see type="mbcli:README" relation="ReadFirst" />
29
+ </references>
30
+ <language>
31
+ <blockml:language.English />
32
+ </language>
33
+ <properties>
34
+ <description override="true">
35
+ <value>MachineBlocks host CLI library</value>
36
+ </description>
37
+ </properties>
38
+ <aggregations>
39
+ <readMe override="true">
40
+ <composition>
41
+ <mbcli:README />
42
+ </composition>
43
+ </readMe>
44
+ <dependencies override="true">
45
+ <composition>
46
+ <blockml:Library />
47
+ <ucli:Library />
48
+ <render:Library />
49
+ </composition>
50
+ </dependencies>
51
+ </aggregations>
52
+ </mbcli:Library>
@@ -0,0 +1,31 @@
1
+ <!--MachineBlocks CLI — README
2
+ FQN: com.machineblocks.bml.cli.README-->
3
+ <mbcli:README xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:mbcli="com.machineblocks.bml.cli"
6
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
7
+
8
+ <baseType>
9
+ core:ReadMe
10
+ </baseType>
11
+ <is>
12
+ Reading entry for the MachineBlocks host CLI library
13
+ </is>
14
+ <documentation>
15
+ @machineblocks/cli is the command MachineBlocks users run. It is not a second
16
+ compiler. It calls the same @blockml/cli and @blockml/compiler packages, with
17
+ the SCAD target already registered and with paths that match a MachineBlocks
18
+ project.
19
+
20
+ People who have not used BlockML can render .bml files to .scad without
21
+ learning toolchain target names, blockdoc, or xsd. People who want the full
22
+ toolchain still use the blockml command from @blockml/cli.
23
+
24
+ Start at com.machineblocks.bml.cli.documentation.Introduction.
25
+ </documentation>
26
+ <references>
27
+ <see type="clidoc:Introduction" relation="ReadFirst" />
28
+ <see type="clidoc:DualCliModel" relation="SeeAlso" />
29
+ <see type="clidoc:Commands" relation="SeeAlso" />
30
+ </references>
31
+ </mbcli:README>
@@ -0,0 +1,106 @@
1
+ <!--CLI Documentation — Commands
2
+ FQN: com.machineblocks.bml.cli.documentation.Commands-->
3
+ <clidoc:Commands xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
6
+
7
+ <baseType>
8
+ core:Documentation
9
+ </baseType>
10
+ <is>
11
+ User-facing commands for a MachineBlocks project
12
+ </is>
13
+ <documentation><![CDATA[
14
+ The host exposes a short command set. validate matches blockml validate.
15
+ compile takes a BlockML type selector, not a file path and not --out.
16
+
17
+ machineblocks validate [file]
18
+ - Same project validate as blockml validate.
19
+ - Exit 0 success, 1 diagnostics, 2 config or usage.
20
+ - Does not register the SCAD target and does not write SCAD.
21
+ - A file argument validates that file. --all validates the reachable corpus.
22
+ file and --all together exit 2.
23
+
24
+ machineblocks compile <source-selector>
25
+ - Compiles with target machineblocks-v3-scad.
26
+ - The selector is one BlockML type selector: an exact block FQN, a package
27
+ selector ending in .*, or a recursive selector ending in .**.
28
+ Resolution is scanTypes from the BlockML framework. This host does not
29
+ define a second selector language.
30
+ - --source-package <FQN> is the source package root for an explicit mapping.
31
+ - --target-package <FQN> is the target package root. It is not a directory
32
+ and not the FQN of one output file.
33
+ - --help shows this command.
34
+ - There is no --out and no --all. The output root is the configured srcDir
35
+ (default blocks).
36
+ - A selector only chooses blocks. It does not by itself choose the target
37
+ package, except that a package selector (a final .* or .** segment)
38
+ supplies the source root when --target-package is set and
39
+ --source-package is omitted. An exact block FQN does not supply a source
40
+ root.
41
+ - --source-package without --target-package exits 2 with
42
+ MB_SOURCE_PACKAGE_ALONE.
43
+ - --target-package without a derivable source root exits 2 with
44
+ MB_SOURCE_PACKAGE_REQUIRED.
45
+ - A missing selector, an unknown flag, or a selector scanTypes rejects
46
+ exits 2.
47
+ - Types whose baseType chain is neither com.machineblocks.bml.core.Block
48
+ nor com.machineblocks.bml.core.Set are skipped. If none remain, the host
49
+ exits 1 with MB_SELECTOR_EMPTY and the selector text.
50
+ - Mapping failures, collisions, and paths that leave srcDir or would
51
+ overwrite a .bml file exit 1. No output file is written unless every
52
+ selected block has a target FQN and a legal path, and every compile
53
+ succeeded.
54
+ - Exit 0 writes the SCAD or preset JSON files and a sibling .map when the
55
+ target attached a source map.
56
+
57
+ Host diagnostic codes:
58
+
59
+ - MB_SOURCE_PACKAGE_ALONE — --source-package without --target-package.
60
+ - MB_SOURCE_PACKAGE_REQUIRED — --target-package and the source root is not
61
+ determined. The message names --source-package.
62
+ - MB_SELECTOR_EMPTY — the selector matched no Block or Set.
63
+ - MB_TARGET_COLLISION — two selected blocks share a target FQN or output path.
64
+ - MB_OUTPUT_ESCAPES_SRC — a resolved path is outside srcDir.
65
+ - MB_OUTPUT_OVERWRITES_BML — a resolved path is an existing .bml file.
66
+
67
+ Mapping codes MB_TARGET_PACKAGE_UNDETERMINED, MB_TARGET_PACKAGE_AMBIGUOUS,
68
+ and MB_SOURCE_OUTSIDE_ROOT are defined with the manifestation rules.
69
+
70
+ machineblocks init <package-fqn> [--src dir] [--install]
71
+ - Scaffolds a BlockML project by calling initProject from @blockml/cli,
72
+ then records the MachineBlocks profile. It does not spawn blockml init.
73
+ - --src changes the source directory (default blocks). --install runs
74
+ npm install after the profile is recorded. Without --install, init
75
+ does not install.
76
+ - The profile adds @machineblocks/cli to devDependencies when that package
77
+ is absent from dependencies and devDependencies. The range is the caret
78
+ range of this host. An existing dependencies entry stays put.
79
+ - The project Library.bml gains a dependencies composition child
80
+ com.machineblocks.bml.Library. An existing child is left in place.
81
+ Existing files are not replaced.
82
+ - A package FQN without a bml segment still exits 0 and warns. Compile
83
+ maps a bml segment to scad.
84
+ - Exit codes match initProject: 0 success, 1 write or install failure,
85
+ 2 usage or an invalid package FQN.
86
+ - --help shows this command.
87
+
88
+ machineblocks --help
89
+ - Lists these commands.
90
+ - Points advanced users to blockml --help for search, inspect, graph,
91
+ transform, and new.
92
+
93
+ Not in this host surface (still available via blockml if that package
94
+ is installed): watch, search, inspect, graph, transform, new, xsd
95
+ toggle, thumbnail generation.
96
+
97
+ Per-target matrix entry this host satisfies:
98
+
99
+ machineblocks-v3-scad — document target; selected by type selector;
100
+ written under srcDir; registered by @machineblocks/cli, not by @blockml/cli.
101
+
102
+ ]]></documentation>
103
+ <references>
104
+ <see type="clidoc:Configuration" relation="ReadNext" />
105
+ </references>
106
+ </clidoc:Commands>
@@ -0,0 +1,54 @@
1
+ <!--CLI Documentation — Configuration
2
+ FQN: com.machineblocks.bml.cli.documentation.Configuration-->
3
+ <clidoc:Configuration xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
6
+
7
+ <baseType>
8
+ core:Documentation
9
+ </baseType>
10
+ <is>
11
+ MachineBlocks defaults and blockml.config.json fields this host reads
12
+ </is>
13
+ <documentation>
14
+ The host reads blockml.config.json from the project root, the same file
15
+ @blockml/cli reads. It understands the universal keys and these MachineBlocks
16
+ keys. The universal CLI documents the MachineBlocks keys as unread in its V1;
17
+ this host is the reader.
18
+
19
+ Universal keys this host honours:
20
+
21
+ - srcDir — default blocks. Project BML sources, and the only compile output
22
+ root. Target FQNs are resolved to paths inside this directory. Compile
23
+ does not read outDir and does not accept --out.
24
+ - libraries — extra Library.bml seeds, appended to package.json blockml.library.
25
+ - targetOptions — opaque bag. Key machineblocks-v3-scad may carry
26
+ settingsFormat (pseudo-map or object). V1 emit is pseudo-map; object is
27
+ rejected with a diagnostic until the SCAD library accepts it.
28
+ - defaultTarget — this host treats machineblocks-v3-scad as the default even
29
+ when the key is omitted. If the key is set to another name, the host
30
+ reports that this command only compiles the SCAD target.
31
+
32
+ MachineBlocks keys:
33
+
34
+ - mbLibPath — root used to compute relative use/include paths to the SCAD
35
+ library (lib/block.scad, config/mb_config.scad, service .scad files).
36
+ Default: the installed @machineblocks/core package root.
37
+ - openscadPath — OpenSCAD executable for later thumbnail or preview commands.
38
+ Not required for compile.
39
+ - thumbsDir — output directory for later thumbnail generation.
40
+ - activeConfig — named config profile inside the SCAD library. Optional.
41
+ - bmlExtensions — extra filename suffixes treated as BML. Default .bml.
42
+
43
+ targets[] on the universal CLI defaults to ["blockdoc"] and must not be
44
+ required for this host. The host registers machineblocks-v3-scad itself.
45
+ Unknown toolchain target names are not an error here; they are ignored
46
+ because this command does not bootstrap them.
47
+
48
+ bom-cli.config.json renaming is not part of this package.
49
+
50
+ </documentation>
51
+ <references>
52
+ <see type="clidoc:TargetBootstrap" relation="ReadNext" />
53
+ </references>
54
+ </clidoc:Configuration>
@@ -0,0 +1,51 @@
1
+ <!--CLI Documentation — DualCliModel
2
+ FQN: com.machineblocks.bml.cli.documentation.DualCliModel-->
3
+ <clidoc:DualCliModel xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
6
+
7
+ <baseType>
8
+ core:Documentation
9
+ </baseType>
10
+ <is>
11
+ Universal CLI versus the MachineBlocks host
12
+ </is>
13
+ <documentation>
14
+ Two commands, one compiler.
15
+
16
+ @blockml/cli (command: blockml), library org.blockml.bml.cli.*:
17
+ - Universal toolchain: validate, compile blockdoc or xsd or fatblock, search,
18
+ graph, inspect, transform, new, init.
19
+ - Domain-agnostic. No MachineBlocks paths, no machineblocks-v3-scad built-in.
20
+ - Reads blockml.config.json targets[] for toolchain targets.
21
+ - Scope exclusions in that library list machineblocks-v3-scad registration
22
+ as out of scope on purpose.
23
+
24
+ @machineblocks/cli (this package), library com.machineblocks.bml.cli.*:
25
+ - Thin host. Recommended entry for MachineBlocks users.
26
+ - Registers machineblocks-v3-scad by constructing the render target with a
27
+ BlockRenderEngine.
28
+ - Same validate and compile facade underneath. Defaults differ.
29
+ - Does not reimplement parse, validate, or emit.
30
+ - init calls initProject from @blockml/cli, then adds devDependency
31
+ @machineblocks/cli and library dependency com.machineblocks.bml.Library.
32
+ The universal init stays domain-agnostic.
33
+
34
+ Interop: a later plugin load (targetPackages in blockml.config.json mapping
35
+ machineblocks-v3-scad to @machineblocks/render-target) may let the universal
36
+ CLI see the target. Product UX stays on this host either way. The universal
37
+ CLI must keep working for projects that never install MachineBlocks.
38
+
39
+ Ownership:
40
+ - This package owns the host bin, MachineBlocks defaults, and target registration.
41
+ - @blockml/compiler owns compileToOutput, CompileRequest, and the registry API.
42
+ - @machineblocks/render-target owns processors and SCAD emit.
43
+ - @blockml/block-render-engine owns strategy infrastructure.
44
+ - Thumbnail generation (OpenSCAD plus image tooling) is a host concern when
45
+ it is built; it is not part of @blockml/cli V1.
46
+
47
+ </documentation>
48
+ <references>
49
+ <see type="clidoc:Responsibilities" relation="ReadNext" />
50
+ </references>
51
+ </clidoc:DualCliModel>
@@ -0,0 +1,52 @@
1
+ <!--CLI Documentation — Installation
2
+ FQN: com.machineblocks.bml.cli.documentation.Installation-->
3
+ <clidoc:Installation xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
6
+
7
+ <baseType>
8
+ core:Documentation
9
+ </baseType>
10
+ <is>
11
+ How MachineBlocks users install the host
12
+ </is>
13
+ <documentation>
14
+ Consumer project (the usual path):
15
+
16
+ npx @machineblocks/cli init com.example.bml
17
+ npx machineblocks validate
18
+ npx machineblocks compile com.example.bml.bricks.MyBrick
19
+
20
+ init calls the universal project scaffold, then records @machineblocks/cli
21
+ as a devDependency and adds com.machineblocks.bml.Library to the project
22
+ library. Pass --install to run npm install after that profile is recorded.
23
+ Otherwise the next step is npm install. On a project that blockml init
24
+ already created, the same command adds only the missing profile and does
25
+ not replace existing files.
26
+
27
+ That install brings @machineblocks/render-target, @blockml/block-render-engine,
28
+ @machineblocks/core, and the BlockML compiler packages. init also records
29
+ @blockml/core and @blockml/cli. A bml segment in the package FQN lets
30
+ compile map the output package to scad.
31
+
32
+ From this monorepo while the bin is not published:
33
+
34
+ npm install
35
+ npx blockml validate
36
+
37
+ The second command checks these BML libraries. It is the toolchain CLI used
38
+ to develop this repo, not the MachineBlocks user command.
39
+
40
+ Requires Node.js 20 or newer.
41
+
42
+ Domain users should not be sent to npm link of the blockml monorepo. The
43
+ universal installation note that says "install @machineblocks/cli from the
44
+ MachineBlocks mono-repo" now means this package (@machineblocks/cli in the
45
+ machineblocks-renderer repository). @machineblocks/core remains the separate
46
+ domain library.
47
+
48
+ </documentation>
49
+ <references>
50
+ <see type="clidoc:Introduction" relation="SeeAlso" />
51
+ </references>
52
+ </clidoc:Installation>
@@ -0,0 +1,39 @@
1
+ <!--CLI Documentation — Introduction
2
+ FQN: com.machineblocks.bml.cli.documentation.Introduction-->
3
+ <clidoc:Introduction xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
6
+
7
+ <baseType>
8
+ core:Documentation
9
+ </baseType>
10
+ <is>
11
+ Purpose of the MachineBlocks host CLI
12
+ </is>
13
+ <documentation>
14
+ MachineBlocks users want BML turned into OpenSCAD that matches the V3 SCAD
15
+ library. They should not have to install the BlockML toolchain repository or
16
+ learn every compiler target.
17
+
18
+ This package is that simplified view:
19
+
20
+ - It depends on published @blockml/* packages (universal CLI and compiler).
21
+ - It depends on @machineblocks/render-target and therefore on
22
+ @blockml/block-render-engine and @machineblocks/core.
23
+ - It registers registry name machineblocks-v3-scad.
24
+ - It fills MachineBlocks defaults: where the SCAD library lives, where
25
+ OpenSCAD is, where .scad files are written.
26
+
27
+ The universal command remains blockml from @blockml/cli. That command must
28
+ not hardcode MachineBlocks. Product UX for this domain is this package.
29
+
30
+ Analogy: tsc is the language tool; a product CLI can wrap it. MachineBlocks
31
+ users install this CLI. They do not clone blockml.
32
+
33
+ V1 of this library is the contract. The bin follows these blocks.
34
+
35
+ </documentation>
36
+ <references>
37
+ <see type="clidoc:DualCliModel" relation="ReadNext" />
38
+ </references>
39
+ </clidoc:Introduction>
@@ -0,0 +1,50 @@
1
+ <!--CLI Documentation — Responsibilities
2
+ FQN: com.machineblocks.bml.cli.documentation.Responsibilities-->
3
+ <clidoc:Responsibilities xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
6
+
7
+ <baseType>
8
+ core:Documentation
9
+ </baseType>
10
+ <is>
11
+ What the host does and what it leaves to other packages
12
+ </is>
13
+ <documentation>
14
+ This host does:
15
+
16
+ - Bootstrap a TypeRegistry from @blockml/core (org.blockml.bml.*) plus
17
+ @machineblocks/core (com.machineblocks.bml.*), using the same project
18
+ bootstrap the universal CLI uses.
19
+ - Register the render target before compile. The universal bootstrapTargets
20
+ path is not used for this name. validate does not need the target registry;
21
+ compile does.
22
+ - Pass mbLibPath so generated SCAD can import lib/block.scad and
23
+ config/mb_config.scad from the installed @machineblocks/core (or an
24
+ override path).
25
+ - Default the compile target to machineblocks-v3-scad. The command does not
26
+ take a target name.
27
+ - Resolve the type selector with the framework scan, keep blocks whose
28
+ baseType chain includes Block or Set, and pass the resolved mapping
29
+ (automatic, or sourcePackage plus targetPackage) on targetOptions.
30
+ - Compute every target FQN and output path before writing. One failure
31
+ writes nothing.
32
+ - Write .scad files, preset JSON, and source maps under the configured
33
+ srcDir. The published writer does not enforce that root; this host checks
34
+ the resolved real paths, then calls it with cleaning disabled.
35
+
36
+ This host does not:
37
+
38
+ - Parse or validate with its own code.
39
+ - Register blockdoc, xsd, or fatblock. Users who need those run blockml.
40
+ - Hardcode MBOM property lists. Those stay in NativeBlock.bml.
41
+ - Ship the SCAD library. That is @machineblocks/core lib/ and blocks/.
42
+
43
+ Node.js 20 or newer. The host bin is Node-only. The render target and the
44
+ engine remain browser-capable; only this package may use Node file APIs.
45
+
46
+ </documentation>
47
+ <references>
48
+ <see type="clidoc:Commands" relation="ReadNext" />
49
+ </references>
50
+ </clidoc:Responsibilities>
@@ -0,0 +1,45 @@
1
+ <!--CLI Documentation — TargetBootstrap
2
+ FQN: com.machineblocks.bml.cli.documentation.TargetBootstrap-->
3
+ <clidoc:TargetBootstrap xmlns="http://blockml.org/bml"
4
+ xmlns:core="org.blockml.bml.core"
5
+ xmlns:clidoc="com.machineblocks.bml.cli.documentation">
6
+
7
+ <baseType>
8
+ core:Documentation
9
+ </baseType>
10
+ <is>
11
+ How the host registers machineblocks-v3-scad
12
+ </is>
13
+ <documentation>
14
+ Before compile, the host performs the equivalent of:
15
+
16
+ import { registerTarget } from "@blockml/compiler";
17
+ import { BlockRenderEngine } from "@blockml/block-render-engine";
18
+ import { MachineBlocksRenderTarget } from "@machineblocks/render-target";
19
+
20
+ registerTarget(new MachineBlocksRenderTarget(new BlockRenderEngine()));
21
+
22
+ The target name property is the string machineblocks-v3-scad.
23
+ Registration is idempotent for the process.
24
+
25
+ The universal CLI's bootstrapTargets loads blockdoc, xsd, and fatblock only.
26
+ It throws on an unknown name in targets[]. This host must not add
27
+ machineblocks-v3-scad to that built-in list inside @blockml/cli. It calls
28
+ registerTarget directly (or registerTargetFactory from the host API).
29
+
30
+ validate and inspect do not register the target.
31
+
32
+ Browser callers and tests that use the render target without this CLI call
33
+ registerTarget themselves with the same constructor pair.
34
+
35
+ CompileOptions passed into the compiler set outputBasePath to the real path
36
+ of srcDir. targetOptions["machineblocks-v3-scad"] carries mbLibPath,
37
+ settingsFormat when set, and, for an explicit mapping, sourcePackage and
38
+ targetPackage. Automatic mapping omits those two keys. activeConfig is
39
+ unused by compile.
40
+
41
+ </documentation>
42
+ <references>
43
+ <see type="clidoc:Installation" relation="ReadNext" />
44
+ </references>
45
+ </clidoc:TargetBootstrap>
package/dist/args.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export interface ValidateArgs {
2
+ command: "validate";
3
+ file?: string;
4
+ all: boolean;
5
+ }
6
+ export interface CompileArgs {
7
+ command: "compile";
8
+ selector: string;
9
+ sourcePackage?: string;
10
+ targetPackage?: string;
11
+ }
12
+ export interface InitArgs {
13
+ command: "init";
14
+ packageFqn: string;
15
+ srcDir?: string;
16
+ install: boolean;
17
+ }
18
+ export type HostCommand = {
19
+ command: "help";
20
+ topic?: "init";
21
+ } | ValidateArgs | CompileArgs | InitArgs | {
22
+ command: "usage";
23
+ message: string;
24
+ };
25
+ export declare function parseArgs(argv: readonly string[]): HostCommand;
26
+ /** A final .* or .** segment denotes a package. An exact type FQN does not. */
27
+ export declare function sourcePackageFromSelector(selector: string): string | undefined;
28
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACnC,YAAY,GACZ,WAAW,GACX,QAAQ,GACR;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,CAe9D;AAoHD,+EAA+E;AAC/E,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAO9E"}
package/dist/args.js ADDED
@@ -0,0 +1,139 @@
1
+ import { COMPILE_HELP, INIT_HELP } from "./help.js";
2
+ export function parseArgs(argv) {
3
+ if (argv.length === 0 || argv[0] === "--help" || argv[0] === "help") {
4
+ return { command: "help" };
5
+ }
6
+ const [command, ...rest] = argv;
7
+ if (command === "validate") {
8
+ return parseValidate(rest);
9
+ }
10
+ if (command === "compile") {
11
+ return parseCompile(rest);
12
+ }
13
+ if (command === "init") {
14
+ return parseInit(rest);
15
+ }
16
+ return { command: "usage", message: `Unknown command: ${command ?? ""}` };
17
+ }
18
+ function parseValidate(args) {
19
+ let file;
20
+ let all = false;
21
+ for (const arg of args) {
22
+ if (arg === "--help") {
23
+ return { command: "help" };
24
+ }
25
+ if (arg === "--all") {
26
+ all = true;
27
+ continue;
28
+ }
29
+ if (arg.startsWith("--")) {
30
+ return { command: "usage", message: `Unknown option: ${arg}` };
31
+ }
32
+ if (file !== undefined) {
33
+ return { command: "usage", message: "validate accepts one file." };
34
+ }
35
+ file = arg;
36
+ }
37
+ if (file !== undefined && all) {
38
+ return { command: "usage", message: "Specify either <file> or --all, not both." };
39
+ }
40
+ return file === undefined ? { command: "validate", all } : { command: "validate", all, file };
41
+ }
42
+ function parseCompile(args) {
43
+ if (args.includes("--help")) {
44
+ return { command: "help" };
45
+ }
46
+ let selector;
47
+ let sourcePackage;
48
+ let targetPackage;
49
+ for (let index = 0; index < args.length; index += 1) {
50
+ const arg = args[index];
51
+ if (arg === undefined) {
52
+ continue;
53
+ }
54
+ if (arg === "--source-package" || arg === "--target-package") {
55
+ const value = args[index + 1];
56
+ if (value === undefined || value.startsWith("--")) {
57
+ return { command: "usage", message: `${arg} requires a package FQN.` };
58
+ }
59
+ if (arg === "--source-package") {
60
+ sourcePackage = value;
61
+ }
62
+ else {
63
+ targetPackage = value;
64
+ }
65
+ index += 1;
66
+ continue;
67
+ }
68
+ if (arg.startsWith("--")) {
69
+ return { command: "usage", message: `Unknown option: ${arg}` };
70
+ }
71
+ if (selector !== undefined) {
72
+ return { command: "usage", message: "compile accepts one source selector." };
73
+ }
74
+ selector = arg;
75
+ }
76
+ if (selector === undefined) {
77
+ return { command: "usage", message: `compile requires a source selector.\n\n${COMPILE_HELP}` };
78
+ }
79
+ const parsed = { command: "compile", selector };
80
+ if (sourcePackage !== undefined) {
81
+ parsed.sourcePackage = sourcePackage;
82
+ }
83
+ if (targetPackage !== undefined) {
84
+ parsed.targetPackage = targetPackage;
85
+ }
86
+ return parsed;
87
+ }
88
+ function parseInit(args) {
89
+ if (args.includes("--help")) {
90
+ return { command: "help", topic: "init" };
91
+ }
92
+ let packageFqn;
93
+ let srcDir;
94
+ let install = false;
95
+ for (let index = 0; index < args.length; index += 1) {
96
+ const arg = args[index];
97
+ if (arg === undefined) {
98
+ continue;
99
+ }
100
+ if (arg === "--install") {
101
+ install = true;
102
+ continue;
103
+ }
104
+ if (arg === "--src") {
105
+ const value = args[index + 1];
106
+ if (value === undefined || value.startsWith("--")) {
107
+ return { command: "usage", message: "--src requires a directory." };
108
+ }
109
+ srcDir = value;
110
+ index += 1;
111
+ continue;
112
+ }
113
+ if (arg.startsWith("--")) {
114
+ return { command: "usage", message: `Unknown option: ${arg}` };
115
+ }
116
+ if (packageFqn !== undefined) {
117
+ return { command: "usage", message: "init accepts one package FQN." };
118
+ }
119
+ packageFqn = arg;
120
+ }
121
+ if (packageFqn === undefined) {
122
+ return { command: "usage", message: `init requires a package FQN.\n\n${INIT_HELP}` };
123
+ }
124
+ const parsed = { command: "init", packageFqn, install };
125
+ if (srcDir !== undefined) {
126
+ parsed.srcDir = srcDir;
127
+ }
128
+ return parsed;
129
+ }
130
+ /** A final .* or .** segment denotes a package. An exact type FQN does not. */
131
+ export function sourcePackageFromSelector(selector) {
132
+ const parts = selector.split(".");
133
+ const last = parts[parts.length - 1];
134
+ if ((last !== "*" && last !== "**") || parts.length < 2) {
135
+ return undefined;
136
+ }
137
+ return parts.slice(0, -1).join(".");
138
+ }
139
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AA6BpD,MAAM,UAAU,SAAS,CAAC,IAAuB;IAC/C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;QACpE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChC,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;QAC3B,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,EA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