@hydranium/cli 1.0.0-next.42 → 1.0.0-next.421
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 +125 -204
- package/bin/hydranium-cli.js +13 -0
- package/heap-analysis/heap/core/load.mjs +2 -2
- package/heap-analysis/heap/langium/langium.classifier.mjs +22 -11
- package/lib/cli-version.js.map +1 -1
- package/lib/cli.js +11 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands/analyze-heap-args.d.ts.map +1 -1
- package/lib/commands/analyze-heap-args.js +1 -2
- package/lib/commands/analyze-heap-args.js.map +1 -1
- package/lib/commands/analyze-heap.d.ts +3 -0
- package/lib/commands/analyze-heap.d.ts.map +1 -1
- package/lib/commands/analyze-heap.js +2 -1
- package/lib/commands/analyze-heap.js.map +1 -1
- package/lib/commands/ast-ground-truth-args.d.ts +3 -2
- package/lib/commands/ast-ground-truth-args.d.ts.map +1 -1
- package/lib/commands/ast-ground-truth-args.js +12 -10
- package/lib/commands/ast-ground-truth-args.js.map +1 -1
- package/lib/commands/ast-ground-truth-driver.js +4 -2
- package/lib/commands/ast-ground-truth-driver.js.map +1 -1
- package/lib/commands/ast-ground-truth.js +1 -1
- package/lib/commands/ast-ground-truth.js.map +1 -1
- package/lib/commands/check-skills-args.d.ts +11 -0
- package/lib/commands/check-skills-args.d.ts.map +1 -0
- package/lib/commands/check-skills-args.js +71 -0
- package/lib/commands/check-skills-args.js.map +1 -0
- package/lib/commands/client-session.d.ts +17 -0
- package/lib/commands/client-session.d.ts.map +1 -0
- package/lib/commands/client-session.js +27 -0
- package/lib/commands/client-session.js.map +1 -0
- package/lib/commands/create-args.d.ts +17 -0
- package/lib/commands/create-args.d.ts.map +1 -0
- package/lib/commands/create-args.js +53 -0
- package/lib/commands/create-args.js.map +1 -0
- package/lib/commands/create.d.ts +38 -0
- package/lib/commands/create.d.ts.map +1 -0
- package/lib/commands/create.js +43 -0
- package/lib/commands/create.js.map +1 -0
- package/lib/commands/delete-args.d.ts +17 -0
- package/lib/commands/delete-args.d.ts.map +1 -0
- package/lib/commands/delete-args.js +49 -0
- package/lib/commands/delete-args.js.map +1 -0
- package/lib/commands/delete.d.ts +30 -0
- package/lib/commands/delete.d.ts.map +1 -0
- package/lib/commands/delete.js +32 -0
- package/lib/commands/delete.js.map +1 -0
- package/lib/commands/generate-ast-builder.d.ts +1 -1
- package/lib/commands/generate-ast-builder.d.ts.map +1 -1
- package/lib/commands/generate-ast-builder.js +2 -11
- package/lib/commands/generate-ast-builder.js.map +1 -1
- package/lib/commands/generate-languages.d.ts +35 -0
- package/lib/commands/generate-languages.d.ts.map +1 -0
- package/lib/commands/generate-languages.js +105 -0
- package/lib/commands/generate-languages.js.map +1 -0
- package/lib/commands/generate-transfer-builder.d.ts +33 -0
- package/lib/commands/generate-transfer-builder.d.ts.map +1 -0
- package/lib/commands/generate-transfer-builder.js +86 -0
- package/lib/commands/generate-transfer-builder.js.map +1 -0
- package/lib/commands/generate-transfer-model-args.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-args.js +20 -5
- package/lib/commands/generate-transfer-model-args.js.map +1 -1
- package/lib/commands/generate-transfer-model-config.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model-config.js +8 -3
- package/lib/commands/generate-transfer-model-config.js.map +1 -1
- package/lib/commands/generate-transfer-model.d.ts +41 -9
- package/lib/commands/generate-transfer-model.d.ts.map +1 -1
- package/lib/commands/generate-transfer-model.js +225 -68
- package/lib/commands/generate-transfer-model.js.map +1 -1
- package/lib/commands/generated-module-path.d.ts +16 -0
- package/lib/commands/generated-module-path.d.ts.map +1 -0
- package/lib/commands/generated-module-path.js +21 -0
- package/lib/commands/generated-module-path.js.map +1 -0
- package/lib/commands/harness-args.d.ts +46 -43
- package/lib/commands/harness-args.d.ts.map +1 -1
- package/lib/commands/harness-args.js +170 -29
- package/lib/commands/harness-args.js.map +1 -1
- package/lib/commands/headless-harness.d.ts +37 -20
- package/lib/commands/headless-harness.d.ts.map +1 -1
- package/lib/commands/headless-harness.js +71 -19
- package/lib/commands/headless-harness.js.map +1 -1
- package/lib/commands/init-args.d.ts +5 -18
- package/lib/commands/init-args.d.ts.map +1 -1
- package/lib/commands/init-args.js +131 -35
- package/lib/commands/init-args.js.map +1 -1
- package/lib/commands/init-hosts.d.ts +24 -0
- package/lib/commands/init-hosts.d.ts.map +1 -0
- package/lib/commands/init-hosts.js +37 -0
- package/lib/commands/init-hosts.js.map +1 -0
- package/lib/commands/init-prompt.d.ts +3 -3
- package/lib/commands/init-prompt.d.ts.map +1 -1
- package/lib/commands/init-prompt.js +4 -5
- package/lib/commands/init-prompt.js.map +1 -1
- package/lib/commands/init-skills.d.ts +41 -0
- package/lib/commands/init-skills.d.ts.map +1 -0
- package/lib/commands/init-skills.js +110 -0
- package/lib/commands/init-skills.js.map +1 -0
- package/lib/commands/init-templates.d.ts +20 -14
- package/lib/commands/init-templates.d.ts.map +1 -1
- package/lib/commands/init-templates.js +3134 -763
- package/lib/commands/init-templates.js.map +1 -1
- package/lib/commands/init-wizard.d.ts +10 -0
- package/lib/commands/init-wizard.d.ts.map +1 -1
- package/lib/commands/init-wizard.js +76 -31
- package/lib/commands/init-wizard.js.map +1 -1
- package/lib/commands/init-workspace.d.ts +13 -11
- package/lib/commands/init-workspace.d.ts.map +1 -1
- package/lib/commands/init-workspace.js +21 -7
- package/lib/commands/init-workspace.js.map +1 -1
- package/lib/commands/init.d.ts +61 -24
- package/lib/commands/init.d.ts.map +1 -1
- package/lib/commands/init.js +244 -50
- package/lib/commands/init.js.map +1 -1
- package/lib/commands/kebab.d.ts +15 -0
- package/lib/commands/kebab.d.ts.map +1 -0
- package/lib/commands/kebab.js +17 -0
- package/lib/commands/kebab.js.map +1 -0
- package/lib/commands/lint-grammar-args.d.ts +3 -2
- package/lib/commands/lint-grammar-args.d.ts.map +1 -1
- package/lib/commands/lint-grammar-args.js +14 -11
- package/lib/commands/lint-grammar-args.js.map +1 -1
- package/lib/commands/lint-grammar-driver.js +2 -1
- package/lib/commands/lint-grammar-driver.js.map +1 -1
- package/lib/commands/lint-grammar-report.js.map +1 -1
- package/lib/commands/lint-grammar.js +1 -1
- package/lib/commands/lint-grammar.js.map +1 -1
- package/lib/commands/measure-memory-args.d.ts +3 -2
- package/lib/commands/measure-memory-args.d.ts.map +1 -1
- package/lib/commands/measure-memory-args.js +26 -14
- package/lib/commands/measure-memory-args.js.map +1 -1
- package/lib/commands/measure-memory-driver.js +5 -3
- package/lib/commands/measure-memory-driver.js.map +1 -1
- package/lib/commands/measure-memory.d.ts +1 -1
- package/lib/commands/measure-memory.d.ts.map +1 -1
- package/lib/commands/measure-memory.js +6 -3
- package/lib/commands/measure-memory.js.map +1 -1
- package/lib/commands/message-catalogue-args.d.ts +16 -0
- package/lib/commands/message-catalogue-args.d.ts.map +1 -0
- package/lib/commands/message-catalogue-args.js +53 -0
- package/lib/commands/message-catalogue-args.js.map +1 -0
- package/lib/commands/message-catalogue.d.ts +21 -0
- package/lib/commands/message-catalogue.d.ts.map +1 -0
- package/lib/commands/message-catalogue.js +48 -0
- package/lib/commands/message-catalogue.js.map +1 -0
- package/lib/commands/model-docs-args.d.ts +4 -3
- package/lib/commands/model-docs-args.d.ts.map +1 -1
- package/lib/commands/model-docs-args.js +13 -11
- package/lib/commands/model-docs-args.js.map +1 -1
- package/lib/commands/model-docs-driver.js +2 -1
- package/lib/commands/model-docs-driver.js.map +1 -1
- package/lib/commands/model-docs.js +1 -1
- package/lib/commands/model-docs.js.map +1 -1
- package/lib/commands/projects-args.d.ts.map +1 -1
- package/lib/commands/projects-args.js +5 -5
- package/lib/commands/projects-args.js.map +1 -1
- package/lib/commands/projects.d.ts +3 -4
- package/lib/commands/projects.d.ts.map +1 -1
- package/lib/commands/projects.js +2 -2
- package/lib/commands/projects.js.map +1 -1
- package/lib/commands/query-args.d.ts.map +1 -1
- package/lib/commands/query-args.js +6 -5
- package/lib/commands/query-args.js.map +1 -1
- package/lib/commands/query.d.ts +6 -5
- package/lib/commands/query.d.ts.map +1 -1
- package/lib/commands/query.js +5 -4
- package/lib/commands/query.js.map +1 -1
- package/lib/commands/reflect-args.d.ts +3 -2
- package/lib/commands/reflect-args.d.ts.map +1 -1
- package/lib/commands/reflect-args.js +14 -11
- package/lib/commands/reflect-args.js.map +1 -1
- package/lib/commands/reflect-driver.js +2 -1
- package/lib/commands/reflect-driver.js.map +1 -1
- package/lib/commands/reflect-report.js.map +1 -1
- package/lib/commands/reflect.js +1 -1
- package/lib/commands/reflect.js.map +1 -1
- package/lib/commands/save-args.d.ts.map +1 -1
- package/lib/commands/save-args.js +7 -4
- package/lib/commands/save-args.js.map +1 -1
- package/lib/commands/save.d.ts +8 -4
- package/lib/commands/save.d.ts.map +1 -1
- package/lib/commands/save.js +12 -23
- package/lib/commands/save.js.map +1 -1
- package/lib/commands/skills.d.ts +22 -0
- package/lib/commands/skills.d.ts.map +1 -0
- package/lib/commands/skills.js +129 -0
- package/lib/commands/skills.js.map +1 -0
- package/lib/commands/validate-args.d.ts +3 -2
- package/lib/commands/validate-args.d.ts.map +1 -1
- package/lib/commands/validate-args.js +14 -11
- package/lib/commands/validate-args.js.map +1 -1
- package/lib/commands/validate-driver.js +2 -1
- package/lib/commands/validate-driver.js.map +1 -1
- package/lib/commands/validate-report.js.map +1 -1
- package/lib/commands/validate.js +1 -1
- package/lib/commands/validate.js.map +1 -1
- package/lib/commands/watch-args.d.ts.map +1 -1
- package/lib/commands/watch-args.js +6 -4
- package/lib/commands/watch-args.js.map +1 -1
- package/lib/commands/watch.d.ts +3 -4
- package/lib/commands/watch.d.ts.map +1 -1
- package/lib/commands/watch.js +5 -2
- package/lib/commands/watch.js.map +1 -1
- package/lib/driver-heap.d.ts +52 -0
- package/lib/driver-heap.d.ts.map +1 -0
- package/lib/driver-heap.js +51 -0
- package/lib/driver-heap.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/log-level.d.ts +21 -11
- package/lib/log-level.d.ts.map +1 -1
- package/lib/log-level.js +25 -14
- package/lib/log-level.js.map +1 -1
- package/lib/spawn-data-server.d.ts +9 -4
- package/lib/spawn-data-server.d.ts.map +1 -1
- package/lib/spawn-data-server.js +5 -4
- package/lib/spawn-data-server.js.map +1 -1
- package/lib/stderr-connection-logger.d.ts +12 -0
- package/lib/stderr-connection-logger.d.ts.map +1 -0
- package/lib/stderr-connection-logger.js +16 -0
- package/lib/stderr-connection-logger.js.map +1 -0
- package/lib/testing/echo-server.js +9 -1
- package/lib/testing/echo-server.js.map +1 -1
- package/package.json +99 -41
- package/src/cli.ts +11 -2
- package/src/commands/analyze-heap-args.ts +1 -2
- package/src/commands/analyze-heap.ts +4 -1
- package/src/commands/ast-ground-truth-args.ts +16 -13
- package/src/commands/ast-ground-truth-driver.ts +4 -2
- package/src/commands/ast-ground-truth.ts +1 -1
- package/src/commands/check-skills-args.ts +70 -0
- package/src/commands/client-session.ts +33 -0
- package/src/commands/create-args.ts +68 -0
- package/src/commands/create.ts +83 -0
- package/src/commands/delete-args.ts +64 -0
- package/src/commands/delete.ts +61 -0
- package/src/commands/generate-ast-builder.ts +2 -12
- package/src/commands/generate-languages.ts +132 -0
- package/src/commands/generate-transfer-builder.ts +101 -0
- package/src/commands/generate-transfer-model-args.ts +20 -5
- package/src/commands/generate-transfer-model-config.ts +8 -3
- package/src/commands/generate-transfer-model.ts +297 -66
- package/src/commands/generated-module-path.ts +22 -0
- package/src/commands/harness-args.ts +163 -33
- package/src/commands/headless-harness.ts +89 -28
- package/src/commands/init-args.ts +135 -35
- package/src/commands/init-hosts.ts +51 -0
- package/src/commands/init-prompt.ts +5 -6
- package/src/commands/init-skills.ts +129 -0
- package/src/commands/init-templates.ts +3326 -785
- package/src/commands/init-wizard.ts +97 -32
- package/src/commands/init-workspace.ts +31 -16
- package/src/commands/init.ts +311 -65
- package/src/commands/kebab.ts +17 -0
- package/src/commands/lint-grammar-args.ts +18 -14
- package/src/commands/lint-grammar-driver.ts +2 -1
- package/src/commands/lint-grammar.ts +1 -1
- package/src/commands/measure-memory-args.ts +31 -17
- package/src/commands/measure-memory-driver.ts +5 -3
- package/src/commands/measure-memory.ts +6 -3
- package/src/commands/message-catalogue-args.ts +55 -0
- package/src/commands/message-catalogue.ts +56 -0
- package/src/commands/model-docs-args.ts +17 -14
- package/src/commands/model-docs-driver.ts +2 -1
- package/src/commands/model-docs.ts +1 -1
- package/src/commands/projects-args.ts +5 -4
- package/src/commands/projects.ts +4 -6
- package/src/commands/query-args.ts +6 -4
- package/src/commands/query.ts +9 -9
- package/src/commands/reflect-args.ts +18 -14
- package/src/commands/reflect-driver.ts +2 -1
- package/src/commands/reflect.ts +1 -1
- package/src/commands/save-args.ts +7 -3
- package/src/commands/save.ts +24 -27
- package/src/commands/skills.ts +146 -0
- package/src/commands/validate-args.ts +18 -14
- package/src/commands/validate-driver.ts +2 -1
- package/src/commands/validate.ts +1 -1
- package/src/commands/watch-args.ts +6 -3
- package/src/commands/watch.ts +7 -6
- package/src/driver-heap.ts +65 -0
- package/src/index.ts +3 -0
- package/src/log-level.ts +42 -14
- package/src/spawn-data-server.ts +17 -5
- package/src/stderr-connection-logger.ts +18 -0
- package/src/testing/echo-server.ts +11 -2
- package/templates/client/gitignore +3 -0
- package/templates/client/src/__GRAMMAR_ID__-diagram-module.ts +82 -0
- package/templates/editorconfig +15 -0
- package/templates/gitignore +1 -0
- package/templates/host-browser/esbuild.mjs +82 -0
- package/templates/host-browser/gitignore +4 -0
- package/templates/host-browser/hydranium-mark.svg +40 -0
- package/templates/host-browser/index.html +287 -0
- package/templates/host-browser/playwright.config.mts +24 -0
- package/templates/host-browser/src/data-status.ts +15 -0
- package/templates/host-browser/src/diagram-save.ts +60 -0
- package/templates/host-browser/src/diagram.ts +121 -0
- package/templates/host-browser/src/editor.ts +116 -0
- package/templates/host-browser/src/log.ts +14 -0
- package/templates/host-browser/src/monaco-editor-core-worker.d.ts +7 -0
- package/templates/host-browser/src/monaco-editor-worker.ts +10 -0
- package/templates/host-browser/src/posix-path-shim.ts +23 -0
- package/templates/host-browser/src/shown-file.ts +61 -0
- package/templates/host-browser/src/workspace.ts +5 -0
- package/templates/host-browser/tsconfig.e2e.json +16 -0
- package/templates/host-browser/tsconfig.page.json +16 -0
- package/templates/host-browser/tsconfig.worker.json +16 -0
- package/templates/host-theia-browser/esbuild.mjs +24 -0
- package/templates/host-theia-browser/gitignore +9 -0
- package/templates/host-theia-browser/playwright.config.mts +42 -0
- package/templates/host-theia-browser/start.mjs +50 -0
- package/templates/host-theia-browser/tsconfig.e2e.json +16 -0
- package/templates/host-theia-electron/esbuild.mjs +27 -0
- package/templates/host-theia-electron/gitignore +8 -0
- package/templates/host-theia-electron/playwright.config.mts +12 -0
- package/templates/host-theia-electron/start.mjs +47 -0
- package/templates/host-theia-electron/tsconfig.e2e.json +16 -0
- package/templates/host-vscode/esbuild.mjs +38 -0
- package/templates/host-vscode/gitignore +7 -0
- package/templates/host-vscode/playwright.config.mts +14 -0
- package/templates/host-vscode/src/__GRAMMAR_ID__-diagram-editor.ts +19 -0
- package/templates/host-vscode/src/show-model-command.ts +24 -0
- package/templates/host-vscode/src/webview/__GRAMMAR_ID__-diagram.ts +18 -0
- package/templates/host-vscode/src/webview/diagram.css +40 -0
- package/templates/host-vscode/start.mjs +22 -0
- package/templates/host-vscode/test/content-server.cjs +40 -0
- package/templates/host-vscode/test/install-vscode.mts +21 -0
- package/templates/host-vscode/test/virtual-documents.spec.mts +28 -0
- package/templates/host-vscode/test/vscode-version.mts +10 -0
- package/templates/host-vscode/tsconfig.e2e.json +17 -0
- package/templates/host-vscode/tsconfig.json +19 -0
- package/templates/host-vscode/tsconfig.webview.json +17 -0
- package/templates/oxlintrc.json +4 -0
- package/templates/protocol/gitignore +3 -0
- package/templates/protocol/src/__GRAMMAR_ID__-diagram-types.ts +47 -0
- package/templates/server/gitignore +6 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/create-node-operation-handler.ts +62 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/delete-operation-handler.ts +63 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/gmodel-factory.ts +144 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/state.ts +18 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/storage.ts +16 -0
- package/templates/server/src/glsp/__GRAMMAR_ID__/submission-handler.ts +24 -0
- package/templates/server/src/grammar/common.langium +12 -0
- package/templates/server/src/language-server/__GRAMMAR_ID__-semantic-tokens.ts +10 -0
- package/templates/server/src/language-server/__GRAMMAR_ID__-serializer.ts +53 -0
- package/templates/server/src/language-server/__GRAMMAR_ID__-validation.ts +30 -0
- package/templates/server/src/language-server/ast.ts +23 -0
- package/templates/server/src/node/services.ts +16 -0
- package/templates/server/test/__GRAMMAR_ID__-diagram.test.ts +403 -0
- package/templates/server/test/__GRAMMAR_ID__-semantic-tokens.test.ts +34 -0
- package/templates/server/test/tsconfig.json +4 -0
- package/templates/server/tsconfig.test.json +10 -0
- package/templates/server/vitest.config.ts +14 -0
- package/templates/theia/gitignore +3 -0
- package/templates/theia/src/browser/__GRAMMAR_ID__-diagram-frontend-module.ts +65 -0
- package/templates/theia/src/browser/__PROJECT_ID__-connection-preload-module.ts +15 -0
- package/templates/theia/src/browser/__PROJECT_ID__-data-connection.ts +15 -0
- package/templates/theia/src/browser/__PROJECT_ID__-data-port.ts +11 -0
- package/templates/theia/src/browser/__PROJECT_ID__-glsp-client-contribution.ts +13 -0
- package/templates/theia/src/browser/__PROJECT_ID__-show-model-command.ts +51 -0
- package/templates/theia/src/common/__PROJECT_ID__-glsp-contribution.ts +3 -0
- package/templates/theia/src/node/__PROJECT_ID__-connection-backend-module.ts +12 -0
- package/templates/theia/src/node/__PROJECT_ID__-data-backend-module.ts +15 -0
- package/templates/theia/src/node/__PROJECT_ID__-glsp-backend-module.ts +16 -0
- package/templates/theia/style/diagram.css +20 -0
- package/templates/theia/tsconfig.json +24 -0
- package/templates/vscode-servers/gitignore +4 -0
- package/templates/vscode-servers/tsconfig.json +19 -0
- package/templates/workspace/nodes.__EXTENSION__ +5 -0
- package/templates/workspace/references.__EXTENSION__ +2 -0
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
* posture rather than a packaging detail: the emission withholds publication
|
|
40
40
|
* AND declares itself UNLICENSED, so a default nobody was shown would settle
|
|
41
41
|
* the licence question by silence.
|
|
42
|
+
* - **installation**, which opts into network access and lifecycle scripts.
|
|
43
|
+
* Workspace members need parent-manifest edits first, so only standalone
|
|
44
|
+
* projects offer it, unless the caller already supplied `--install`.
|
|
42
45
|
*
|
|
43
46
|
* The **language id is deliberately not asked**, though it is the third of the
|
|
44
47
|
* three independent names: its derivation was settled and built separately
|
|
@@ -55,8 +58,10 @@
|
|
|
55
58
|
*/
|
|
56
59
|
|
|
57
60
|
import * as path from 'node:path';
|
|
58
|
-
import { DEFAULT_INIT_HEADS, INIT_HEADS, type InitHead, isNonEmptyDir,
|
|
59
|
-
import {
|
|
61
|
+
import { DEFAULT_INIT_HEADS, INIT_HEADS, type InitHead, initMembers, isNonEmptyDir, isUsableExtension, memberPlacements } from './init.js';
|
|
62
|
+
import { editingHeads, INIT_HOSTS, type InitHost } from './init-hosts.js';
|
|
63
|
+
import { kebab } from './kebab.js';
|
|
64
|
+
import { HEAD_CHOICES, InitWizardCancelled, type PromptPort } from './init-prompt.js';
|
|
60
65
|
import { type WorkspaceDetection } from './init-workspace.js';
|
|
61
66
|
|
|
62
67
|
/** One grammar as the wizard collected it. */
|
|
@@ -77,6 +82,8 @@ export interface InitAnswers {
|
|
|
77
82
|
readonly name: string;
|
|
78
83
|
/** The protocol heads to start. */
|
|
79
84
|
readonly heads: readonly InitHead[];
|
|
85
|
+
/** The host applications to emit around the server. */
|
|
86
|
+
readonly hosts: readonly InitHost[];
|
|
80
87
|
/** The grammars, in the order they were given. */
|
|
81
88
|
readonly grammars: readonly InitGrammarAnswer[];
|
|
82
89
|
/** Scaffold into a non-empty directory anyway. */
|
|
@@ -87,6 +94,10 @@ export interface InitAnswers {
|
|
|
87
94
|
readonly scope?: string;
|
|
88
95
|
/** Leave the package publishable, which the scaffold does not do by default. */
|
|
89
96
|
readonly public: boolean;
|
|
97
|
+
/** Run npm install after writing the scaffold. */
|
|
98
|
+
readonly install: boolean;
|
|
99
|
+
readonly skills?: string;
|
|
100
|
+
readonly agents?: string;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
/** PascalCase a directory name, splitting on any non-alphanumeric run. */
|
|
@@ -117,6 +128,9 @@ export function composeInitArgv(answers: InitAnswers): string[] {
|
|
|
117
128
|
if (answers.heads.join(',') !== DEFAULT_INIT_HEADS.join(',')) {
|
|
118
129
|
argv.push('--heads', answers.heads.join(','));
|
|
119
130
|
}
|
|
131
|
+
if (answers.hosts.length > 0) {
|
|
132
|
+
argv.push('--hosts', answers.hosts.join(','));
|
|
133
|
+
}
|
|
120
134
|
const several = answers.grammars.length > 1;
|
|
121
135
|
for (const grammar of answers.grammars) {
|
|
122
136
|
// A lone grammar named after the project, taking the derived extension, is
|
|
@@ -146,6 +160,12 @@ export function composeInitArgv(answers: InitAnswers): string[] {
|
|
|
146
160
|
if (answers.public) {
|
|
147
161
|
argv.push('--public');
|
|
148
162
|
}
|
|
163
|
+
if (answers.install) {
|
|
164
|
+
argv.push('--install');
|
|
165
|
+
}
|
|
166
|
+
if (answers.skills !== undefined && answers.agents !== undefined) {
|
|
167
|
+
argv.push('--skills', answers.skills, '--agents', answers.agents);
|
|
168
|
+
}
|
|
149
169
|
return argv;
|
|
150
170
|
}
|
|
151
171
|
|
|
@@ -158,13 +178,13 @@ export function formatCommand(argv: readonly string[]): string {
|
|
|
158
178
|
/** Validate a file extension, and reject one another grammar already claims. */
|
|
159
179
|
function extensionProblem(value: string, taken: ReadonlySet<string>): string | undefined {
|
|
160
180
|
const extension = value.replace(/^\./, '');
|
|
161
|
-
if (
|
|
181
|
+
if (!isUsableExtension(extension)) {
|
|
162
182
|
return `'${value}' is not a usable file extension.`;
|
|
163
183
|
}
|
|
164
184
|
// Checked here rather than left to the scaffolder so the answer is corrected
|
|
165
185
|
// while the grammar that owns it is still on screen. Langium routes documents
|
|
166
186
|
// to a language BY extension, so a duplicate is a silent mis-route.
|
|
167
|
-
return taken.has(extension) ? `'.${extension}' is already claimed by another grammar.` : undefined;
|
|
187
|
+
return taken.has(extension.toLowerCase()) ? `'.${extension}' is already claimed by another grammar.` : undefined;
|
|
168
188
|
}
|
|
169
189
|
|
|
170
190
|
/**
|
|
@@ -198,31 +218,42 @@ async function askGrammar(
|
|
|
198
218
|
return { name, extension: extension.replace(/^\./, ''), diagram: false };
|
|
199
219
|
}
|
|
200
220
|
|
|
221
|
+
/** Ask for the protocol head set, in composition order whatever order they were picked in. */
|
|
222
|
+
async function askHeads(prompt: PromptPort): Promise<InitHead[]> {
|
|
223
|
+
const chosen = await prompt.multiselect({ message: 'Protocol heads', choices: HEAD_CHOICES, initialValues: DEFAULT_INIT_HEADS });
|
|
224
|
+
return INIT_HEADS.filter(head => chosen.includes(head));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** What the wizard asks about each host. */
|
|
228
|
+
const HOST_QUESTIONS: Record<InitHost, string> = {
|
|
229
|
+
browser: 'Add a browser host (every head in a web worker, no backend)?',
|
|
230
|
+
vscode: 'Add a VS Code extension (the language client, Show Model with the data head, and a custom editor per diagram)?',
|
|
231
|
+
'theia-browser':
|
|
232
|
+
'Add a Theia browser application (the language client, Show Model with the data head, and a diagram editor per diagram)?',
|
|
233
|
+
'theia-electron': 'Add a Theia Electron application (the same as the Theia browser application, in a desktop window)?'
|
|
234
|
+
};
|
|
235
|
+
|
|
201
236
|
/**
|
|
202
|
-
* Ask for the
|
|
203
|
-
*
|
|
204
|
-
* `lsp` is not offered, it is stated: it owns the workspace, the build pipeline
|
|
205
|
-
* and the shared tier the other heads read through, so a project without it has
|
|
206
|
-
* nothing for them to serve. Presenting it as a checkbox would offer a choice
|
|
207
|
-
* the scaffolder then refuses.
|
|
237
|
+
* Ask for each host the head set can run, one yes/no each. A host none of
|
|
238
|
+
* whose editing heads is on is not offered: `init` would refuse it.
|
|
208
239
|
*/
|
|
209
|
-
async function
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return
|
|
240
|
+
async function askHosts(prompt: PromptPort, heads: readonly InitHead[]): Promise<InitHost[]> {
|
|
241
|
+
const hosts: InitHost[] = [];
|
|
242
|
+
for (const host of INIT_HOSTS.filter(candidate => editingHeads(candidate).some(head => heads.includes(head)))) {
|
|
243
|
+
if (await prompt.confirm({ message: HOST_QUESTIONS[host], initialValue: false })) {
|
|
244
|
+
hosts.push(host);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return hosts;
|
|
217
248
|
}
|
|
218
249
|
|
|
219
250
|
/**
|
|
220
251
|
* Mark the grammar a scaffolded diagram edits.
|
|
221
252
|
*
|
|
222
|
-
* Only a real question with `glsp` on AND several grammars:
|
|
223
|
-
*
|
|
224
|
-
* that answer already — so asking would offer a choice
|
|
225
|
-
* silently overrule.
|
|
253
|
+
* Only a real question with `glsp` on AND several grammars: the scaffolded
|
|
254
|
+
* diagram is typed over one grammar's model, and with a single grammar the
|
|
255
|
+
* scaffolder derives that answer already — so asking would offer a choice
|
|
256
|
+
* whose "no" it would silently overrule.
|
|
226
257
|
*/
|
|
227
258
|
async function askDiagramGrammar(
|
|
228
259
|
prompt: PromptPort,
|
|
@@ -263,15 +294,18 @@ async function confirmOccupiedTarget(prompt: PromptPort, targetDir: string, isOc
|
|
|
263
294
|
/** Ask the workspace questions, or answer them "no" when there is no workspace to join. */
|
|
264
295
|
async function askWorkspaceMembership(
|
|
265
296
|
prompt: PromptPort,
|
|
266
|
-
detection: WorkspaceDetection | undefined
|
|
297
|
+
detection: WorkspaceDetection | undefined,
|
|
298
|
+
heads: readonly InitHead[],
|
|
299
|
+
hosts: readonly InitHost[]
|
|
267
300
|
): Promise<{ monorepo: boolean; scope?: string }> {
|
|
268
301
|
if (detection === undefined) {
|
|
269
302
|
return { monorepo: false };
|
|
270
303
|
}
|
|
304
|
+
const uncovered = memberPlacements(detection, initMembers(heads, hosts)).filter(placement => placement.coveredBy === undefined);
|
|
271
305
|
const covered =
|
|
272
|
-
|
|
273
|
-
?
|
|
274
|
-
: `
|
|
306
|
+
uncovered.length === 0
|
|
307
|
+
? 'Its packages are already covered by the workspaces entries.'
|
|
308
|
+
: `The root manifest has no entry covering ${uncovered.map(placement => placement.path).join(', ')}, so ${uncovered.length === 1 ? 'one is' : 'they are'} printed for you to add.`;
|
|
275
309
|
// The placement is named, not just the root. The root alone reads as "this
|
|
276
310
|
// ran somewhere I did not ask for" whenever the command was issued from a
|
|
277
311
|
// different directory than the target, which is the normal case.
|
|
@@ -310,9 +344,11 @@ async function askWorkspaceMembership(
|
|
|
310
344
|
*/
|
|
311
345
|
async function askPackaging(
|
|
312
346
|
prompt: PromptPort,
|
|
313
|
-
detection: WorkspaceDetection | undefined
|
|
347
|
+
detection: WorkspaceDetection | undefined,
|
|
348
|
+
heads: readonly InitHead[],
|
|
349
|
+
hosts: readonly InitHost[]
|
|
314
350
|
): Promise<{ monorepo: boolean; scope?: string; public: boolean }> {
|
|
315
|
-
const membership = await askWorkspaceMembership(prompt, detection);
|
|
351
|
+
const membership = await askWorkspaceMembership(prompt, detection, heads, hosts);
|
|
316
352
|
const isPublic = await prompt.confirm({ message: 'Publishable to npm (the manifest says UNLICENSED)?', initialValue: false });
|
|
317
353
|
return { ...membership, public: isPublic };
|
|
318
354
|
}
|
|
@@ -327,7 +363,13 @@ async function askPackaging(
|
|
|
327
363
|
export async function runInitWizard(
|
|
328
364
|
prompt: PromptPort,
|
|
329
365
|
detect: (targetDir: string) => WorkspaceDetection | undefined,
|
|
330
|
-
options: {
|
|
366
|
+
options: {
|
|
367
|
+
readonly targetDir?: string;
|
|
368
|
+
readonly isOccupied?: (targetDir: string) => boolean;
|
|
369
|
+
readonly install?: boolean;
|
|
370
|
+
readonly skills?: string;
|
|
371
|
+
readonly agents?: string;
|
|
372
|
+
} = {}
|
|
331
373
|
): Promise<string[]> {
|
|
332
374
|
prompt.intro('Scaffold a Hydranium language project');
|
|
333
375
|
|
|
@@ -353,6 +395,7 @@ export async function runInitWizard(
|
|
|
353
395
|
});
|
|
354
396
|
|
|
355
397
|
const heads = await askHeads(prompt);
|
|
398
|
+
const hosts = await askHosts(prompt, heads);
|
|
356
399
|
|
|
357
400
|
// One grammar at a time, each with its own settings, then an explicit "add
|
|
358
401
|
// another" — so the single-grammar case costs two keystrokes and the
|
|
@@ -364,13 +407,35 @@ export async function runInitWizard(
|
|
|
364
407
|
const grammar = await askGrammar(prompt, grammars.length, grammars.length === 0 ? name : undefined, takenNames, takenExtensions);
|
|
365
408
|
grammars.push(grammar);
|
|
366
409
|
takenNames.add(grammar.name);
|
|
367
|
-
takenExtensions.add(grammar.extension);
|
|
410
|
+
takenExtensions.add(grammar.extension.toLowerCase());
|
|
368
411
|
} while (await prompt.confirm({ message: 'Add another grammar?', initialValue: false }));
|
|
369
412
|
|
|
370
413
|
const withDiagram = await askDiagramGrammar(prompt, heads, grammars);
|
|
371
|
-
const
|
|
414
|
+
const detection = detect(targetDir);
|
|
415
|
+
if (options.install && detection !== undefined) {
|
|
416
|
+
prompt.note('--install requires a standalone project; workspace membership is skipped.', 'Installation');
|
|
417
|
+
}
|
|
418
|
+
const packaging = await askPackaging(prompt, options.install ? undefined : detection, heads, hosts);
|
|
419
|
+
const install =
|
|
420
|
+
(options.install ?? false) ||
|
|
421
|
+
(!packaging.monorepo &&
|
|
422
|
+
(await prompt.confirm({
|
|
423
|
+
message: 'Install dependencies now (npm install)?',
|
|
424
|
+
initialValue: false
|
|
425
|
+
})));
|
|
372
426
|
|
|
373
|
-
const argv = composeInitArgv({
|
|
427
|
+
const argv = composeInitArgv({
|
|
428
|
+
targetDir,
|
|
429
|
+
name,
|
|
430
|
+
heads,
|
|
431
|
+
hosts,
|
|
432
|
+
grammars: withDiagram,
|
|
433
|
+
force,
|
|
434
|
+
install,
|
|
435
|
+
skills: options.skills,
|
|
436
|
+
agents: options.agents,
|
|
437
|
+
...packaging
|
|
438
|
+
});
|
|
374
439
|
// Echoed as the LAST thing before the scaffold runs, because it is the
|
|
375
440
|
// artefact the session produces: everything above is how it was reached.
|
|
376
441
|
prompt.outro(formatCommand(argv));
|
|
@@ -169,14 +169,6 @@ export interface WorkspaceDetection {
|
|
|
169
169
|
readonly workspaces: readonly string[];
|
|
170
170
|
/** POSIX path of the target relative to {@link rootDir}, e.g. `packages/foo`. */
|
|
171
171
|
readonly targetPath: string;
|
|
172
|
-
/**
|
|
173
|
-
* The `workspaces` glob already covering {@link targetPath}, if any.
|
|
174
|
-
*
|
|
175
|
-
* Absent means the root manifest needs a new entry — which is why this is
|
|
176
|
-
* computed per target rather than assumed: a `packages/*` glob covers a new
|
|
177
|
-
* package for free, while a repo that lists its examples one by one does not.
|
|
178
|
-
*/
|
|
179
|
-
readonly coveredBy?: string;
|
|
180
172
|
/** The npm scope the sibling packages agree on (`@acme`), when they agree. */
|
|
181
173
|
readonly scope?: string;
|
|
182
174
|
/**
|
|
@@ -186,10 +178,14 @@ export interface WorkspaceDetection {
|
|
|
186
178
|
readonly baseTsconfig?: string;
|
|
187
179
|
/** That tsconfig's `compilerOptions`, so the emitted one can drop what it inherits. */
|
|
188
180
|
readonly baseCompilerOptions?: Readonly<Record<string, JsonValue>>;
|
|
189
|
-
/** The root
|
|
181
|
+
/** The root formatter config's `printWidth`, so emitted sources wrap where the repo wraps. */
|
|
190
182
|
readonly printWidth?: number;
|
|
191
183
|
/** Filename of the root eslint config, when there is one. Absent means the repo does not lint. */
|
|
192
184
|
readonly eslintConfig?: string;
|
|
185
|
+
/** Filename of the root Oxlint config, when present. */
|
|
186
|
+
readonly oxlintConfig?: string;
|
|
187
|
+
/** The npm version the root's `packageManager` field declares, when it names npm. */
|
|
188
|
+
readonly packageManagerNpm?: string;
|
|
193
189
|
}
|
|
194
190
|
|
|
195
191
|
/**
|
|
@@ -339,7 +335,7 @@ export function findBaseTsconfig(
|
|
|
339
335
|
}
|
|
340
336
|
|
|
341
337
|
/**
|
|
342
|
-
* The repo's
|
|
338
|
+
* The repo's formatter `printWidth`, so the emitted sources wrap where the repo
|
|
343
339
|
* wraps instead of at the scaffold's own default.
|
|
344
340
|
*
|
|
345
341
|
* **Why this is worth detecting at all.** There is no width that is stable for
|
|
@@ -360,19 +356,21 @@ export function findBaseTsconfig(
|
|
|
360
356
|
* adopter's formatter rewraps on first commit. So a heuristic that is usually
|
|
361
357
|
* right strictly improves on no detection, and can break nothing.
|
|
362
358
|
*/
|
|
363
|
-
export function
|
|
359
|
+
export function findFormatterPrintWidth(rootDir: string, probe: WorkspaceProbe): number | undefined {
|
|
364
360
|
const manifest = probe.readJson(path.join(rootDir, 'package.json'));
|
|
365
361
|
if (isJsonObject(manifest) && isJsonObject(manifest.prettier) && typeof manifest.prettier.printWidth === 'number') {
|
|
366
362
|
return manifest.prettier.printWidth;
|
|
367
363
|
}
|
|
368
364
|
const present = probe.listFiles(rootDir);
|
|
369
|
-
for (const file of present.filter(name => name === '.prettierrc' || name === '.prettierrc.json')) {
|
|
365
|
+
for (const file of present.filter(name => name === '.oxfmtrc.json' || name === '.prettierrc' || name === '.prettierrc.json')) {
|
|
370
366
|
const parsed = probe.readJson(path.join(rootDir, file));
|
|
371
367
|
if (isJsonObject(parsed) && typeof parsed.printWidth === 'number') {
|
|
372
368
|
return parsed.printWidth;
|
|
373
369
|
}
|
|
374
370
|
}
|
|
375
|
-
for (const file of present.filter(name =>
|
|
371
|
+
for (const file of present.filter(name =>
|
|
372
|
+
/^(\.prettierrc\.[cm]?[jt]s|prettier\.config\.[cm]?[jt]s|oxfmt\.config\.[cm]?[jt]s)$/.test(name)
|
|
373
|
+
)) {
|
|
376
374
|
const width = /\bprintWidth\s*:\s*(\d+)/.exec(probe.readText(path.join(rootDir, file)) ?? '');
|
|
377
375
|
if (width) {
|
|
378
376
|
return Number(width[1]);
|
|
@@ -398,6 +396,22 @@ export function findEslintConfig(rootDir: string, probe: WorkspaceProbe): string
|
|
|
398
396
|
return probe.listFiles(rootDir).find(name => /^eslint\.config\.[cm]?[jt]s$/.test(name) || /^\.eslintrc(\..+)?$/.test(name));
|
|
399
397
|
}
|
|
400
398
|
|
|
399
|
+
/** Detect Oxlint without evaluating executable configuration files. */
|
|
400
|
+
export function findOxlintConfig(rootDir: string, probe: WorkspaceProbe): string | undefined {
|
|
401
|
+
return probe.listFiles(rootDir).find(name => /^(oxlint\.config\.[cm]?[jt]s|\.oxlintrc\.jsonc?)$/.test(name));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** The npm version the root's `packageManager` field declares (`npm@11.15.0` gives `11.15.0`), when it names npm. */
|
|
405
|
+
export function findPackageManagerNpm(rootDir: string, probe: WorkspaceProbe): string | undefined {
|
|
406
|
+
const manifest = probe.readJson(path.join(rootDir, 'package.json'));
|
|
407
|
+
return parseNpmVersion(isJsonObject(manifest) && typeof manifest.packageManager === 'string' ? manifest.packageManager : undefined);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** The npm version, prerelease included, of a `packageManager` field (`npm@…`) or a user agent (`npm/…`); undefined for another tool. */
|
|
411
|
+
export function parseNpmVersion(spec: string | undefined): string | undefined {
|
|
412
|
+
return /^npm[@/](\d+\.\d+\.\d+(?:-[\w.]+)?)/.exec(spec ?? '')?.[1];
|
|
413
|
+
}
|
|
414
|
+
|
|
401
415
|
/** POSIX-style relative path, which is what both `extends` and `--prefix` want on every platform. */
|
|
402
416
|
function posixRelative(from: string, to: string): string {
|
|
403
417
|
return path.relative(from, to).split(path.sep).join('/');
|
|
@@ -432,11 +446,12 @@ export function detectWorkspace(targetDir: string, probe: WorkspaceProbe): Works
|
|
|
432
446
|
rootDir,
|
|
433
447
|
workspaces,
|
|
434
448
|
targetPath,
|
|
435
|
-
coveredBy: workspaces.find(glob => workspaceGlobCovers(glob, targetPath)),
|
|
436
449
|
scope: inferPackageScope(rootDir, workspaces, probe),
|
|
437
450
|
baseTsconfig: base && posixRelative(absoluteTarget, path.join(rootDir, base.file)),
|
|
438
451
|
baseCompilerOptions: base?.compilerOptions,
|
|
439
|
-
printWidth:
|
|
440
|
-
eslintConfig: findEslintConfig(rootDir, probe)
|
|
452
|
+
printWidth: findFormatterPrintWidth(rootDir, probe),
|
|
453
|
+
eslintConfig: findEslintConfig(rootDir, probe),
|
|
454
|
+
oxlintConfig: findOxlintConfig(rootDir, probe),
|
|
455
|
+
packageManagerNpm: findPackageManagerNpm(rootDir, probe)
|
|
441
456
|
};
|
|
442
457
|
}
|