@greenpandastudios/aug-cli 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/bin/aug.mjs +3 -0
- package/docs/api/crypto.md +351 -0
- package/docs/api/io.md +207 -0
- package/docs/api/json.md +21 -0
- package/docs/api/memory.md +109 -0
- package/docs/api/time.md +54 -0
- package/docs/api/web.md +184 -0
- package/docs/assets/benchmarks/execution.svg +2978 -0
- package/docs/assets/benchmarks/http.svg +1674 -0
- package/docs/assets/benchmarks/improvements.svg +2315 -0
- package/docs/assets/benchmarks/memory.svg +1891 -0
- package/docs/benchmark-baseline.json +1087 -0
- package/docs/benchmark-results.json +91123 -0
- package/docs/benchmarks.json +38 -0
- package/docs/compatibility.md +42 -0
- package/docs/concurrency-implementation.md +18 -0
- package/docs/diagnostics.md +97 -0
- package/docs/docker.md +35 -0
- package/docs/example-projects.json +26 -0
- package/docs/examples/approved-design/counters.md +253 -0
- package/docs/examples/approved-design/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/approved-design/domain/app.md +165 -0
- package/docs/examples/approved-design/domain/export.md +83 -0
- package/docs/examples/approved-design/domain/models.md +80 -0
- package/docs/examples/approved-design/domain/numbers.md +248 -0
- package/docs/examples/approved-design/index.md +39 -0
- package/docs/examples/approved-design/main-yaml.md +24 -0
- package/docs/examples/approved-design/main.md +215 -0
- package/docs/examples/benchmark/index.md +33 -0
- package/docs/examples/benchmark/main-yaml.md +17 -0
- package/docs/examples/benchmark/main.md +117 -0
- package/docs/examples/cli-args/index.md +32 -0
- package/docs/examples/cli-args/main.md +107 -0
- package/docs/examples/collections/index.md +32 -0
- package/docs/examples/collections/main.md +118 -0
- package/docs/examples/collections-benchmark/index.md +34 -0
- package/docs/examples/collections-benchmark/main.md +115 -0
- package/docs/examples/cpu-benchmark/index.md +34 -0
- package/docs/examples/cpu-benchmark/main.md +90 -0
- package/docs/examples/developer-workflow/calculator.md +357 -0
- package/docs/examples/developer-workflow/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/developer-workflow/index.md +37 -0
- package/docs/examples/developer-workflow/logging/console.md +124 -0
- package/docs/examples/developer-workflow/logging/export.md +70 -0
- package/docs/examples/developer-workflow/logging/logger.md +111 -0
- package/docs/examples/developer-workflow/main.md +172 -0
- package/docs/examples/drop/index.md +33 -0
- package/docs/examples/drop/main.md +85 -0
- package/docs/examples/drop/resource.md +95 -0
- package/docs/examples/errors/errors.md +85 -0
- package/docs/examples/errors/index.md +33 -0
- package/docs/examples/errors/main.md +92 -0
- package/docs/examples/ffi/index.md +33 -0
- package/docs/examples/ffi/main.md +75 -0
- package/docs/examples/ffi/native.md +93 -0
- package/docs/examples/generic-di/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/generic-di/index.md +33 -0
- package/docs/examples/generic-di/main.md +111 -0
- package/docs/examples/generic-di/types.md +180 -0
- package/docs/examples/generics/index.md +33 -0
- package/docs/examples/generics/main.md +120 -0
- package/docs/examples/generics/types.md +189 -0
- package/docs/examples/hello/app/export.md +67 -0
- package/docs/examples/hello/app/greeter.md +190 -0
- package/docs/examples/hello/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/hello/index.md +37 -0
- package/docs/examples/hello/logging/console.md +121 -0
- package/docs/examples/hello/logging/export.md +71 -0
- package/docs/examples/hello/logging/logger.md +120 -0
- package/docs/examples/hello/main.md +115 -0
- package/docs/examples/http-benchmark/index.md +35 -0
- package/docs/examples/http-benchmark/main.md +79 -0
- package/docs/examples/http-benchmark/routes.md +88 -0
- package/docs/examples/index.md +60 -0
- package/docs/examples/interceptors/app.md +250 -0
- package/docs/examples/interceptors/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/interceptors/index.md +35 -0
- package/docs/examples/interceptors/interceptors.md +284 -0
- package/docs/examples/interceptors/logging.md +155 -0
- package/docs/examples/interceptors/main.md +162 -0
- package/docs/examples/json-benchmark/data.md +71 -0
- package/docs/examples/json-benchmark/dependencies/august/0.19.0/json/contracts.md +103 -0
- package/docs/examples/json-benchmark/index.md +35 -0
- package/docs/examples/json-benchmark/main.md +131 -0
- package/docs/examples/new-syntax/console.md +118 -0
- package/docs/examples/new-syntax/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/new-syntax/greeter.md +145 -0
- package/docs/examples/new-syntax/index.md +36 -0
- package/docs/examples/new-syntax/logger.md +111 -0
- package/docs/examples/new-syntax/main.md +135 -0
- package/docs/examples/new-syntax/math.md +79 -0
- package/docs/examples/oidc-login/client/contracts.md +151 -0
- package/docs/examples/oidc-login/client/endpoints.md +263 -0
- package/docs/examples/oidc-login/client/export.md +107 -0
- package/docs/examples/oidc-login/client/login.md +515 -0
- package/docs/examples/oidc-login/client/logout.md +249 -0
- package/docs/examples/oidc-login/client/protocol.md +595 -0
- package/docs/examples/oidc-login/client/session.md +297 -0
- package/docs/examples/oidc-login/client/views.md +144 -0
- package/docs/examples/oidc-login/common/export.md +115 -0
- package/docs/examples/oidc-login/common/headers.md +162 -0
- package/docs/examples/oidc-login/common/keys.md +336 -0
- package/docs/examples/oidc-login/common/settings.md +116 -0
- package/docs/examples/oidc-login/common/views.md +103 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/crypto/contracts.md +925 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/crypto/jose.md +434 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/json/contracts.md +103 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/memory/store.md +374 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/time/contracts.md +150 -0
- package/docs/examples/oidc-login/dependencies/august/0.19.0/web/contracts.md +532 -0
- package/docs/examples/oidc-login/index.md +57 -0
- package/docs/examples/oidc-login/main-yaml.md +28 -0
- package/docs/examples/oidc-login/main.md +283 -0
- package/docs/examples/oidc-login/provider/authorization.md +457 -0
- package/docs/examples/oidc-login/provider/contracts.md +267 -0
- package/docs/examples/oidc-login/provider/credentials.md +148 -0
- package/docs/examples/oidc-login/provider/discovery.md +215 -0
- package/docs/examples/oidc-login/provider/export.md +131 -0
- package/docs/examples/oidc-login/provider/token.md +364 -0
- package/docs/examples/oidc-login/provider/userinfo.md +228 -0
- package/docs/examples/oidc-login/provider/views.md +137 -0
- package/docs/examples/ownership/counter.md +140 -0
- package/docs/examples/ownership/index.md +33 -0
- package/docs/examples/ownership/main.md +90 -0
- package/docs/examples/ownership-transfer/dependencies/august/0.19.0/io/contracts.md +395 -0
- package/docs/examples/ownership-transfer/index.md +33 -0
- package/docs/examples/ownership-transfer/main.md +125 -0
- package/docs/examples/ownership-transfer/resource.md +150 -0
- package/docs/examples/packages-app/dependencies/packages/@example/aug-math/0.1.0/arithmetic.md +117 -0
- package/docs/examples/packages-app/index.md +34 -0
- package/docs/examples/packages-app/main-yaml.md +18 -0
- package/docs/examples/packages-app/main.md +80 -0
- package/docs/examples/packages-math/aug-package-json.md +24 -0
- package/docs/examples/packages-math/index.md +36 -0
- package/docs/examples/packages-math/package-json.md +25 -0
- package/docs/examples/packages-math/src/arithmetic.md +121 -0
- package/docs/examples/packages-math/src/export.md +63 -0
- package/docs/examples/startup-benchmark/index.md +34 -0
- package/docs/examples/startup-benchmark/main.md +68 -0
- package/docs/examples/visibility/counter.md +142 -0
- package/docs/examples/visibility/index.md +33 -0
- package/docs/examples/visibility/main.md +96 -0
- package/docs/examples.json +47 -0
- package/docs/getting-started.md +5 -0
- package/docs/grammar.md +136 -0
- package/docs/implementation-map.md +106 -0
- package/docs/index.md +46 -0
- package/docs/language-conformance.md +30 -0
- package/docs/language-constructs.md +1461 -0
- package/docs/language-design-audit.md +147 -0
- package/docs/maintaining-docs.md +43 -0
- package/docs/packages.md +184 -0
- package/docs/performance.md +535 -0
- package/docs/production-readiness.md +39 -0
- package/docs/reference.md +361 -0
- package/docs/release-review.md +23 -0
- package/docs/releasing.md +79 -0
- package/docs/roadmap.md +13 -0
- package/docs/specifications.md +86 -0
- package/docs/testing.md +120 -0
- package/docs/tooling.md +197 -0
- package/docs/web-implementation-plan.md +39 -0
- package/docs/web-library-gaps.md +27 -0
- package/docs/web.md +197 -0
- package/examples/approved-design/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/approved-design/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/approved-design/.aug-spec/manifest.json +14 -0
- package/examples/approved-design/counters.aug +22 -0
- package/examples/approved-design/counters.aug.md +177 -0
- package/examples/approved-design/domain/app.aug +12 -0
- package/examples/approved-design/domain/app.aug.md +97 -0
- package/examples/approved-design/domain/export.aug +5 -0
- package/examples/approved-design/domain/export.aug.md +25 -0
- package/examples/approved-design/domain/models.aug +2 -0
- package/examples/approved-design/domain/models.aug.md +30 -0
- package/examples/approved-design/domain/numbers.aug +29 -0
- package/examples/approved-design/domain/numbers.aug.md +141 -0
- package/examples/approved-design/main.aug +26 -0
- package/examples/approved-design/main.aug.md +108 -0
- package/examples/approved-design/main.yaml +8 -0
- package/examples/benchmark/.aug-spec/manifest.json +7 -0
- package/examples/benchmark/main.aug +17 -0
- package/examples/benchmark/main.aug.md +43 -0
- package/examples/benchmark/main.yaml +1 -0
- package/examples/cli-args/.aug-spec/manifest.json +7 -0
- package/examples/cli-args/main.aug +15 -0
- package/examples/cli-args/main.aug.md +38 -0
- package/examples/collections/.aug-spec/manifest.json +7 -0
- package/examples/collections/main.aug +18 -0
- package/examples/collections/main.aug.md +43 -0
- package/examples/developer-workflow/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/developer-workflow/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/developer-workflow/.aug-spec/manifest.json +13 -0
- package/examples/developer-workflow/calculator.aug +55 -0
- package/examples/developer-workflow/calculator.aug.md +228 -0
- package/examples/developer-workflow/logging/console.aug +8 -0
- package/examples/developer-workflow/logging/console.aug.md +67 -0
- package/examples/developer-workflow/logging/export.aug +2 -0
- package/examples/developer-workflow/logging/export.aug.md +19 -0
- package/examples/developer-workflow/logging/logger.aug +6 -0
- package/examples/developer-workflow/logging/logger.aug.md +57 -0
- package/examples/developer-workflow/main.aug +25 -0
- package/examples/developer-workflow/main.aug.md +79 -0
- package/examples/drop/.aug-spec/manifest.json +8 -0
- package/examples/drop/main.aug +3 -0
- package/examples/drop/main.aug.md +35 -0
- package/examples/drop/resource.aug +8 -0
- package/examples/drop/resource.aug.md +44 -0
- package/examples/errors/.aug-spec/manifest.json +8 -0
- package/examples/errors/errors.aug +6 -0
- package/examples/errors/errors.aug.md +33 -0
- package/examples/errors/main.aug +7 -0
- package/examples/errors/main.aug.md +36 -0
- package/examples/ffi/.aug-spec/manifest.json +8 -0
- package/examples/ffi/main.aug +2 -0
- package/examples/ffi/main.aug.md +27 -0
- package/examples/ffi/native.aug +6 -0
- package/examples/ffi/native.aug.md +43 -0
- package/examples/generic-di/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/generic-di/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/generic-di/.aug-spec/manifest.json +10 -0
- package/examples/generic-di/main.aug +9 -0
- package/examples/generic-di/main.aug.md +49 -0
- package/examples/generic-di/types.aug +17 -0
- package/examples/generic-di/types.aug.md +124 -0
- package/examples/generics/.aug-spec/manifest.json +8 -0
- package/examples/generics/main.aug +9 -0
- package/examples/generics/main.aug.md +58 -0
- package/examples/generics/types.aug +19 -0
- package/examples/generics/types.aug.md +132 -0
- package/examples/hello/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/hello/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/hello/.aug-spec/manifest.json +14 -0
- package/examples/hello/app/export.aug +1 -0
- package/examples/hello/app/export.aug.md +17 -0
- package/examples/hello/app/greeter.aug +22 -0
- package/examples/hello/app/greeter.aug.md +109 -0
- package/examples/hello/logging/console.aug +7 -0
- package/examples/hello/logging/console.aug.md +65 -0
- package/examples/hello/logging/export.aug +2 -0
- package/examples/hello/logging/export.aug.md +19 -0
- package/examples/hello/logging/logger.aug +9 -0
- package/examples/hello/logging/logger.aug.md +59 -0
- package/examples/hello/main.aug +9 -0
- package/examples/hello/main.aug.md +49 -0
- package/examples/interceptors/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/interceptors/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/interceptors/.aug-spec/manifest.json +12 -0
- package/examples/interceptors/app.aug +28 -0
- package/examples/interceptors/app.aug.md +162 -0
- package/examples/interceptors/interceptors.aug +40 -0
- package/examples/interceptors/interceptors.aug.md +180 -0
- package/examples/interceptors/logging.aug +12 -0
- package/examples/interceptors/logging.aug.md +96 -0
- package/examples/interceptors/main.aug +22 -0
- package/examples/interceptors/main.aug.md +76 -0
- package/examples/new-syntax/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/new-syntax/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/new-syntax/.aug-spec/manifest.json +13 -0
- package/examples/new-syntax/console.aug +7 -0
- package/examples/new-syntax/console.aug.md +63 -0
- package/examples/new-syntax/greeter.aug +10 -0
- package/examples/new-syntax/greeter.aug.md +89 -0
- package/examples/new-syntax/logger.aug +6 -0
- package/examples/new-syntax/logger.aug.md +57 -0
- package/examples/new-syntax/main.aug +12 -0
- package/examples/new-syntax/main.aug.md +64 -0
- package/examples/new-syntax/math.aug +3 -0
- package/examples/new-syntax/math.aug.md +29 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/contracts.aug +73 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/contracts.aug.md +791 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/jose.aug +68 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/crypto/jose.aug.md +266 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/json/contracts.aug +6 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/json/contracts.aug.md +55 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/memory/store.aug +45 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/memory/store.aug.md +250 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/time/contracts.aug +11 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/time/contracts.aug.md +96 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/web/contracts.aug +58 -0
- package/examples/oidc-login/.aug-spec/august/0.19.0/web/contracts.aug.md +420 -0
- package/examples/oidc-login/.aug-spec/manifest.json +40 -0
- package/examples/oidc-login/README.md +29 -0
- package/examples/oidc-login/client/contracts.aug +7 -0
- package/examples/oidc-login/client/contracts.aug.md +80 -0
- package/examples/oidc-login/client/endpoints.aug +21 -0
- package/examples/oidc-login/client/endpoints.aug.md +161 -0
- package/examples/oidc-login/client/export.aug +7 -0
- package/examples/oidc-login/client/export.aug.md +29 -0
- package/examples/oidc-login/client/login.aug +58 -0
- package/examples/oidc-login/client/login.aug.md +331 -0
- package/examples/oidc-login/client/logout.aug +18 -0
- package/examples/oidc-login/client/logout.aug.md +150 -0
- package/examples/oidc-login/client/protocol.aug +106 -0
- package/examples/oidc-login/client/protocol.aug.md +326 -0
- package/examples/oidc-login/client/session.aug +34 -0
- package/examples/oidc-login/client/session.aug.md +155 -0
- package/examples/oidc-login/client/views.aug +21 -0
- package/examples/oidc-login/client/views.aug.md +68 -0
- package/examples/oidc-login/common/export.aug +9 -0
- package/examples/oidc-login/common/export.aug.md +33 -0
- package/examples/oidc-login/common/headers.aug +11 -0
- package/examples/oidc-login/common/headers.aug.md +79 -0
- package/examples/oidc-login/common/keys.aug +37 -0
- package/examples/oidc-login/common/keys.aug.md +207 -0
- package/examples/oidc-login/common/settings.aug +4 -0
- package/examples/oidc-login/common/settings.aug.md +47 -0
- package/examples/oidc-login/common/views.aug +16 -0
- package/examples/oidc-login/common/views.aug.md +34 -0
- package/examples/oidc-login/main.aug +39 -0
- package/examples/oidc-login/main.aug.md +166 -0
- package/examples/oidc-login/main.yaml +12 -0
- package/examples/oidc-login/provider/authorization.aug +59 -0
- package/examples/oidc-login/provider/authorization.aug.md +264 -0
- package/examples/oidc-login/provider/contracts.aug +15 -0
- package/examples/oidc-login/provider/contracts.aug.md +193 -0
- package/examples/oidc-login/provider/credentials.aug +10 -0
- package/examples/oidc-login/provider/credentials.aug.md +64 -0
- package/examples/oidc-login/provider/discovery.aug +13 -0
- package/examples/oidc-login/provider/discovery.aug.md +133 -0
- package/examples/oidc-login/provider/export.aug +13 -0
- package/examples/oidc-login/provider/export.aug.md +41 -0
- package/examples/oidc-login/provider/token.aug +37 -0
- package/examples/oidc-login/provider/token.aug.md +223 -0
- package/examples/oidc-login/provider/userinfo.aug +26 -0
- package/examples/oidc-login/provider/userinfo.aug.md +104 -0
- package/examples/oidc-login/provider/views.aug +18 -0
- package/examples/oidc-login/provider/views.aug.md +63 -0
- package/examples/ownership/.aug-spec/manifest.json +8 -0
- package/examples/ownership/counter.aug +14 -0
- package/examples/ownership/counter.aug.md +85 -0
- package/examples/ownership/main.aug +4 -0
- package/examples/ownership/main.aug.md +38 -0
- package/examples/ownership-transfer/.aug-spec/august/0.19.0/io/contracts.aug +36 -0
- package/examples/ownership-transfer/.aug-spec/august/0.19.0/io/contracts.aug.md +316 -0
- package/examples/ownership-transfer/.aug-spec/manifest.json +10 -0
- package/examples/ownership-transfer/main.aug +9 -0
- package/examples/ownership-transfer/main.aug.md +63 -0
- package/examples/ownership-transfer/resource.aug +16 -0
- package/examples/ownership-transfer/resource.aug.md +89 -0
- package/examples/packages/README.md +15 -0
- package/examples/packages/app/.aug-spec/manifest.json +9 -0
- package/examples/packages/app/.aug-spec/packages/@example/aug-math/0.1.0/arithmetic.aug +9 -0
- package/examples/packages/app/.aug-spec/packages/@example/aug-math/0.1.0/arithmetic.aug.md +63 -0
- package/examples/packages/app/main.aug +2 -0
- package/examples/packages/app/main.aug.md +33 -0
- package/examples/packages/app/main.yaml +2 -0
- package/examples/packages/math/.aug-spec/manifest.json +8 -0
- package/examples/packages/math/README.md +3 -0
- package/examples/packages/math/aug-package.json +8 -0
- package/examples/packages/math/package.json +9 -0
- package/examples/packages/math/src/arithmetic.aug +8 -0
- package/examples/packages/math/src/arithmetic.aug.md +63 -0
- package/examples/packages/math/src/export.aug +1 -0
- package/examples/packages/math/src/export.aug.md +17 -0
- package/examples/visibility/.aug-spec/manifest.json +8 -0
- package/examples/visibility/counter.aug +14 -0
- package/examples/visibility/counter.aug.md +87 -0
- package/examples/visibility/main.aug +7 -0
- package/examples/visibility/main.aug.md +39 -0
- package/package.json +50 -0
- package/runtime/aug_crypto.c +121 -0
- package/runtime/aug_html.c +93 -0
- package/runtime/aug_http.c +829 -0
- package/runtime/aug_json.c +165 -0
- package/runtime/aug_runtime.c +792 -0
- package/runtime/aug_runtime.h +245 -0
- package/runtime/aug_tasks.c +172 -0
- package/runtime/aug_time.c +5 -0
- package/runtime/aug_values.c +80 -0
- package/scripts/bootstrap-native.mjs +121 -0
- package/scripts/native-dependencies.lock.json +65 -0
- package/scripts/native-home.mjs +11 -0
- package/src/actions.js +109 -0
- package/src/ast.js +19 -0
- package/src/builtins.js +93 -0
- package/src/checker.js +2896 -0
- package/src/cli.js +344 -0
- package/src/codegen.js +1159 -0
- package/src/config.js +149 -0
- package/src/continuation.js +110 -0
- package/src/di.js +24 -0
- package/src/documentation.js +27 -0
- package/src/editor.js +782 -0
- package/src/effects.js +29 -0
- package/src/fixes.js +222 -0
- package/src/formatter.js +296 -0
- package/src/freshness.js +154 -0
- package/src/help.js +212 -0
- package/src/html.js +27 -0
- package/src/http-policies.js +90 -0
- package/src/inference.js +16 -0
- package/src/interceptors.js +70 -0
- package/src/javadoc.js +67 -0
- package/src/lexer.js +199 -0
- package/src/libraries.js +31 -0
- package/src/lsp.js +180 -0
- package/src/native.js +144 -0
- package/src/navigation.js +162 -0
- package/src/openapi.js +220 -0
- package/src/ownership.js +232 -0
- package/src/package-manager.js +299 -0
- package/src/parser.js +1155 -0
- package/src/policies.js +130 -0
- package/src/project-init.js +19 -0
- package/src/project.js +292 -0
- package/src/schemas.js +62 -0
- package/src/semantic.js +255 -0
- package/src/spec.js +738 -0
- package/src/testing.js +186 -0
- package/src/types.js +10 -0
package/src/cli.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { existsSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join, relative, resolve } from 'node:path';
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { typeName } from "./ast.js";
|
|
5
|
+
import { checkProject } from "./checker.js";
|
|
6
|
+
import { generateC } from "./codegen.js";
|
|
7
|
+
import { diagnosticHelp } from "./help.js";
|
|
8
|
+
import { loadProject } from "./project.js";
|
|
9
|
+
import { definitionAt } from "./navigation.js";
|
|
10
|
+
import { checkUnitTests, discoverTests, mergeTestAnalysis, uniqueDiagnostics } from "./testing.js";
|
|
11
|
+
import { describe, SemanticWorkspace } from "./semantic.js";
|
|
12
|
+
import { formatFile, migrateFile } from "./formatter.js";
|
|
13
|
+
import { updateSpecs } from "./spec.js";
|
|
14
|
+
import { runLanguageServer } from "./lsp.js";
|
|
15
|
+
import { benchmark, compileNative, writeCoverage } from "./native.js";
|
|
16
|
+
import { generateOpenApi } from "./openapi.js";
|
|
17
|
+
import { initPackage, installPackages, preparePackage, packPackage } from "./package-manager.js";
|
|
18
|
+
import { initProject } from "./project-init.js";
|
|
19
|
+
function printDiagnostics(diagnostics, json, root) {
|
|
20
|
+
if (json) {
|
|
21
|
+
process.stdout.write(JSON.stringify(diagnostics.map(issue => ({ ...issue,
|
|
22
|
+
help: diagnosticHelp[issue.code] }))) + '\n');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
for (const issue of diagnostics) {
|
|
26
|
+
const file = issue.file.startsWith(root) ? issue.file.slice(root.length + 1) : issue.file;
|
|
27
|
+
process.stderr.write(`${file}:${issue.line}:${issue.column}: ${issue.code}: ${issue.message}\n`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function usage() {
|
|
31
|
+
process.stdout.write(`AugScript compiler\n\n` +
|
|
32
|
+
`Usage: aug <init|check|build|run|emit-c|test|openapi|format|migrate|spec|bench|explain|context|lsp|symbols|definition|complete|hover|fixes|semantic-tokens> [project directory] [options] [-- args]\n` +
|
|
33
|
+
`New application: aug init DIRECTORY\n` +
|
|
34
|
+
`Tests: aug test [project directory] [GROUP_NAME] [--group GROUP_NAME] [--list] [--coverage] [--json] [--timeout milliseconds]\n` +
|
|
35
|
+
`Format: aug format [project directory] [--file path] [--write]\n` +
|
|
36
|
+
`Specifications: aug spec [project directory] [--check] [--json]\n` +
|
|
37
|
+
`Migration: aug migrate [project directory] [--file path] [--write]\n` +
|
|
38
|
+
`Context: aug context [project directory] [--file path] [--name declaration] [--budget characters]\n` +
|
|
39
|
+
`Benchmark: aug bench [project directory] [--iterations 10] [--warmup 2] [--json] [-- args]\n` +
|
|
40
|
+
`Packages: aug package init DIRECTORY --name @owner/name; aug package pack DIRECTORY\n` +
|
|
41
|
+
`Dependencies: aug install [project directory] [--frozen] [--offline]\n` +
|
|
42
|
+
`Entry point: main.aug at the project root.\n`);
|
|
43
|
+
}
|
|
44
|
+
export async function main(argv) {
|
|
45
|
+
if (argv[0] === 'pack')
|
|
46
|
+
return main(['package', 'pack', ...argv.slice(1)]);
|
|
47
|
+
const command = argv[0];
|
|
48
|
+
if (command === '--version' || command === 'version') {
|
|
49
|
+
process.stdout.write(JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version + '\n');
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
if (!command || command === '--help' || command === 'help') {
|
|
53
|
+
usage();
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
if (command === 'init') {
|
|
57
|
+
if (argv.length !== 2 || !argv[1] || argv[1].startsWith('--')) {
|
|
58
|
+
process.stderr.write('Use aug init DIRECTORY\n');
|
|
59
|
+
return 2;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const root = initProject(argv[1]);
|
|
63
|
+
process.stdout.write(`Created August application in ${root}\nNext: cd ${argv[1]} && aug check . && aug test . && aug run .\n`);
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
process.stderr.write(error.message + '\n');
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (command === 'install' || command === 'package') {
|
|
72
|
+
try {
|
|
73
|
+
const root = resolve((command === 'install' ? argv[1] : argv[2]) && !(command === 'install' ? argv[1] : argv[2]).startsWith('--')
|
|
74
|
+
? (command === 'install' ? argv[1] : argv[2]) : process.cwd());
|
|
75
|
+
if (command === 'install') {
|
|
76
|
+
const lock = installPackages(root, argv.includes('--frozen'), argv.includes('--offline'));
|
|
77
|
+
process.stdout.write(`Installed ${lock.packages.length} August package(s); aug.lock.json is current.\n`);
|
|
78
|
+
}
|
|
79
|
+
else if (argv[1] === 'init') {
|
|
80
|
+
const name = argv[argv.indexOf('--name') + 1];
|
|
81
|
+
if (!argv.includes('--name') || !name)
|
|
82
|
+
throw new Error('Use aug package init DIRECTORY --name @owner/name');
|
|
83
|
+
initPackage(root, name);
|
|
84
|
+
process.stdout.write(`Created August library ${name} in ${root}\n`);
|
|
85
|
+
}
|
|
86
|
+
else if (argv[1] === 'pack') {
|
|
87
|
+
preparePackage(root);
|
|
88
|
+
const project = loadProject(root), checked = checkProject(project);
|
|
89
|
+
const tests = checkUnitTests(project, discoverTests(project).tests);
|
|
90
|
+
const diagnostics = uniqueDiagnostics([...checked.diagnostics, ...tests.flatMap(test => test.checked.diagnostics)]);
|
|
91
|
+
if (diagnostics.some(issue => issue.severity !== 'warning')) {
|
|
92
|
+
printDiagnostics(diagnostics, argv.includes('--json'), root);
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
mergeTestAnalysis(checked, tests);
|
|
96
|
+
updateSpecs(checked);
|
|
97
|
+
process.stdout.write(packPackage(root) + '\n');
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
throw new Error('Use aug package init or aug package pack');
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
process.stderr.write(error.message + '\n');
|
|
105
|
+
return 1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (command === 'lsp')
|
|
109
|
+
return runLanguageServer(resolve(argv[1] ?? process.cwd()));
|
|
110
|
+
if (!['check', 'build', 'run', 'emit-c', 'test', 'openapi', 'format', 'migrate', 'spec', 'bench', 'explain', 'context', 'symbols', 'definition',
|
|
111
|
+
'complete', 'hover', 'fixes', 'semantic-tokens'].includes(command)) {
|
|
112
|
+
process.stderr.write(`Unknown command ${command}\n`);
|
|
113
|
+
usage();
|
|
114
|
+
return 2;
|
|
115
|
+
}
|
|
116
|
+
const separator = argv.indexOf('--');
|
|
117
|
+
const options = separator >= 0 ? argv.slice(1, separator) : argv.slice(1);
|
|
118
|
+
const programArgs = separator >= 0 ? argv.slice(separator + 1) : [];
|
|
119
|
+
const json = options.includes('--json');
|
|
120
|
+
const outIndex = options.indexOf('--out');
|
|
121
|
+
const outputOption = outIndex >= 0 ? options[outIndex + 1] : undefined;
|
|
122
|
+
const stdinIndex = options.indexOf('--stdin-file');
|
|
123
|
+
const stdinFile = stdinIndex >= 0 ? options[stdinIndex + 1] : undefined;
|
|
124
|
+
const fileIndex = options.indexOf('--file');
|
|
125
|
+
const sourceFile = fileIndex >= 0 ? options[fileIndex + 1] : undefined;
|
|
126
|
+
const nameIndex = options.indexOf('--name');
|
|
127
|
+
const symbolName = nameIndex >= 0 ? options[nameIndex + 1] : undefined;
|
|
128
|
+
const offsetIndex = options.indexOf('--offset');
|
|
129
|
+
const offsetText = offsetIndex >= 0 ? options[offsetIndex + 1] : undefined;
|
|
130
|
+
const budgetIndex = options.indexOf('--budget');
|
|
131
|
+
const budget = budgetIndex >= 0 ? Number(options[budgetIndex + 1]) : undefined;
|
|
132
|
+
const baselineIndex = options.indexOf('--baseline');
|
|
133
|
+
const baselinePath = baselineIndex >= 0 ? options[baselineIndex + 1] : undefined;
|
|
134
|
+
const groupIndex = options.indexOf('--group');
|
|
135
|
+
const groupOption = groupIndex >= 0 ? options[groupIndex + 1] : undefined;
|
|
136
|
+
const caseIndices = options.flatMap((option, index) => option === '--case' ? [index] : []);
|
|
137
|
+
const caseNames = caseIndices.map(index => options[index + 1]);
|
|
138
|
+
const timeoutIndex = options.indexOf('--timeout');
|
|
139
|
+
const timeout = timeoutIndex >= 0 ? Number(options[timeoutIndex + 1]) : 10000;
|
|
140
|
+
const iterationsIndex = options.indexOf('--iterations'), warmupIndex = options.indexOf('--warmup');
|
|
141
|
+
const iterations = iterationsIndex >= 0 ? Number(options[iterationsIndex + 1]) : 10;
|
|
142
|
+
const warmup = warmupIndex >= 0 ? Number(options[warmupIndex + 1]) : 2;
|
|
143
|
+
const positionals = options.filter((arg, i) => !arg.startsWith('--') &&
|
|
144
|
+
(outIndex < 0 || i !== outIndex + 1) &&
|
|
145
|
+
(stdinIndex < 0 || i !== stdinIndex + 1) &&
|
|
146
|
+
(fileIndex < 0 || i !== fileIndex + 1) &&
|
|
147
|
+
(nameIndex < 0 || i !== nameIndex + 1) &&
|
|
148
|
+
(offsetIndex < 0 || i !== offsetIndex + 1) &&
|
|
149
|
+
(budgetIndex < 0 || i !== budgetIndex + 1) &&
|
|
150
|
+
(baselineIndex < 0 || i !== baselineIndex + 1) &&
|
|
151
|
+
(groupIndex < 0 || i !== groupIndex + 1) &&
|
|
152
|
+
!caseIndices.some(index => i === index + 1) &&
|
|
153
|
+
(timeoutIndex < 0 || i !== timeoutIndex + 1) &&
|
|
154
|
+
(iterationsIndex < 0 || i !== iterationsIndex + 1) && (warmupIndex < 0 || i !== warmupIndex + 1));
|
|
155
|
+
const firstIsDirectory = positionals[0] && existsSync(positionals[0]) && statSync(positionals[0]).isDirectory();
|
|
156
|
+
const projectArg = command === 'test' ? firstIsDirectory ? positionals[0] : undefined : positionals[0];
|
|
157
|
+
const group = groupOption ?? (command === 'test' ? positionals[firstIsDirectory ? 1 : 0] : undefined);
|
|
158
|
+
const root = resolve(projectArg ?? process.cwd());
|
|
159
|
+
try {
|
|
160
|
+
const overrides = stdinFile ? new Map([[resolve(stdinFile), readFileSync(0, 'utf8')]]) : undefined;
|
|
161
|
+
if (['complete', 'hover', 'fixes', 'semantic-tokens'].includes(command)) {
|
|
162
|
+
if (!sourceFile)
|
|
163
|
+
throw new Error(`${command} requires --file`);
|
|
164
|
+
const workspace = new SemanticWorkspace(root);
|
|
165
|
+
const document = workspace.document(sourceFile, overrides?.has(resolve(sourceFile)) ? { text: overrides.get(resolve(sourceFile)), version: 1 } : undefined);
|
|
166
|
+
const offset = Number(offsetText);
|
|
167
|
+
if (['complete', 'hover'].includes(command) && (offsetText === undefined || !Number.isInteger(offset) || offset < 0))
|
|
168
|
+
throw new Error(`${command} requires a nonnegative --offset`);
|
|
169
|
+
const result = command === 'complete' ? document.complete(offset) : command === 'hover' ? document.hover(offset) ?? null :
|
|
170
|
+
command === 'fixes' ? document.fixes() : document.tokens();
|
|
171
|
+
process.stdout.write(JSON.stringify(result) + '\n');
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
const project = loadProject(root, overrides);
|
|
175
|
+
if (project.library && ['build', 'run', 'bench', 'openapi'].includes(command))
|
|
176
|
+
throw new Error('This is an August library; use check, test, or package pack. Import its exports from an application with main.aug to run it.');
|
|
177
|
+
if (command === 'format' || command === 'migrate') {
|
|
178
|
+
const files = (sourceFile ? [project.files.get(resolve(sourceFile))].filter(file => !!file) : [...project.files.values()])
|
|
179
|
+
.filter(file => !file.builtin && !file.package);
|
|
180
|
+
if (!files.length)
|
|
181
|
+
throw new Error('No source files to format');
|
|
182
|
+
const formatted = files.map(file => ({ file: file.path, text: (command === 'migrate' ? migrateFile : formatFile)(project, file) }));
|
|
183
|
+
if (options.includes('--write'))
|
|
184
|
+
formatted.forEach(file => writeFileSync(file.file, file.text));
|
|
185
|
+
else
|
|
186
|
+
process.stdout.write(json ? JSON.stringify(formatted) + '\n' : formatted.map(file => file.text).join('\n'));
|
|
187
|
+
return 0;
|
|
188
|
+
}
|
|
189
|
+
const discovered = discoverTests(project);
|
|
190
|
+
if (command === 'test') {
|
|
191
|
+
if (groupIndex >= 0 && (!groupOption || groupOption.startsWith('--')))
|
|
192
|
+
throw new Error('--group needs a group name');
|
|
193
|
+
if (!Number.isInteger(timeout) || timeout < 1)
|
|
194
|
+
throw new Error('--timeout needs a positive number of milliseconds');
|
|
195
|
+
if (caseNames.some(name => !name || name.startsWith('--')))
|
|
196
|
+
throw new Error('--case needs a test id from --list');
|
|
197
|
+
const selected = discovered.tests.filter(unit => (group === undefined || unit.group.name === group) &&
|
|
198
|
+
(!caseNames.length || caseNames.includes(unit.id)));
|
|
199
|
+
const missingCase = caseNames.find(name => !discovered.tests.some(unit => unit.id === name));
|
|
200
|
+
if (missingCase)
|
|
201
|
+
throw new Error(`No test named ${missingCase}`);
|
|
202
|
+
const checks = checkUnitTests(project, selected);
|
|
203
|
+
const diagnostics = uniqueDiagnostics([...project.diagnostics, ...discovered.diagnostics,
|
|
204
|
+
...checks.flatMap(entry => entry.checked.diagnostics)]);
|
|
205
|
+
if (diagnostics.some(issue => issue.severity !== 'warning')) {
|
|
206
|
+
printDiagnostics(diagnostics, json, root);
|
|
207
|
+
return 1;
|
|
208
|
+
}
|
|
209
|
+
if (!selected.length)
|
|
210
|
+
throw new Error(group ? `No test group named ${group}` : 'No tests found in this project');
|
|
211
|
+
if (options.includes('--list')) {
|
|
212
|
+
process.stdout.write(json ? JSON.stringify(selected.map(unit => ({ id: unit.id, type: typeName(unit.suite.type), group: unit.group.name,
|
|
213
|
+
name: unit.test.name, row: unit.rowIndex, file: unit.file, line: unit.test.span.line }))) + '\n' :
|
|
214
|
+
selected.map(unit => unit.id).join('\n') + '\n');
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
const results = [];
|
|
218
|
+
const coverage = options.includes('--coverage'), reports = [];
|
|
219
|
+
for (const [index, { unit, checked: testChecked }] of checks.entries()) {
|
|
220
|
+
const native = compileNative(root, generateC(testChecked, { coverage }), { testIndex: index, checked: testChecked });
|
|
221
|
+
const report = join(root, '.aug-build', 'tests', `coverage-${index}.tsv`);
|
|
222
|
+
reports.push(report);
|
|
223
|
+
if (coverage)
|
|
224
|
+
rmSync(report, { force: true });
|
|
225
|
+
const run = native.status === 0 ? spawnSync(native.output, [], { encoding: 'utf8', cwd: root, timeout,
|
|
226
|
+
killSignal: 'SIGKILL', env: { ...process.env, AUG_COVERAGE_FILE: coverage ? report : '' } }) : undefined;
|
|
227
|
+
const result = { id: unit.id, group: unit.group.name, name: unit.test.name,
|
|
228
|
+
passed: native.status === 0 && run?.status === 0,
|
|
229
|
+
stdout: run?.stdout ?? '', stderr: native.error || (run?.error && 'code' in run.error && run.error.code === 'ETIMEDOUT' ?
|
|
230
|
+
`Test exceeded ${timeout}ms\n${run.stderr ?? ''}` : run?.error?.message || run?.stderr || '') };
|
|
231
|
+
results.push(result);
|
|
232
|
+
if (!json) {
|
|
233
|
+
process.stdout.write(`[${result.passed ? 'PASS' : 'FAIL'}] ${relative(root, unit.file)} › ${typeName(unit.suite.type)} › ${unit.group.name} › ${unit.test.name}\n`);
|
|
234
|
+
if (result.stdout)
|
|
235
|
+
process.stdout.write(result.stdout);
|
|
236
|
+
if (result.stderr)
|
|
237
|
+
process.stderr.write(result.stderr);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const passed = results.filter(result => result.passed).length;
|
|
241
|
+
const failed = results.length - passed;
|
|
242
|
+
const report = coverage ? writeCoverage(root, reports) : undefined;
|
|
243
|
+
process.stdout.write(json ? JSON.stringify({ passed, failed, tests: results, coverage: report }) + '\n' :
|
|
244
|
+
`${passed} passed, ${failed} failed\n` + (report ? `Coverage: ${report.covered}/${report.executable} statement lines (${report.percent.toFixed(1)}%); ${report.path}\n` : ''));
|
|
245
|
+
return failed ? 1 : 0;
|
|
246
|
+
}
|
|
247
|
+
const checked = checkProject(project);
|
|
248
|
+
const testChecks = checkUnitTests(project, discovered.tests);
|
|
249
|
+
checked.diagnostics = uniqueDiagnostics([...checked.diagnostics, ...discovered.diagnostics,
|
|
250
|
+
...testChecks.flatMap(entry => entry.checked.diagnostics)]);
|
|
251
|
+
mergeTestAnalysis(checked, testChecks);
|
|
252
|
+
if (command === 'openapi') {
|
|
253
|
+
const result = generateOpenApi(checked);
|
|
254
|
+
const diagnostics = uniqueDiagnostics([...checked.diagnostics, ...result.diagnostics]);
|
|
255
|
+
if (diagnostics.some(issue => issue.severity !== 'warning')) {
|
|
256
|
+
printDiagnostics(diagnostics, false, root);
|
|
257
|
+
return 1;
|
|
258
|
+
}
|
|
259
|
+
process.stdout.write(JSON.stringify(result.document, null, 2) + '\n');
|
|
260
|
+
return 0;
|
|
261
|
+
}
|
|
262
|
+
if (command === 'explain' || command === 'context') {
|
|
263
|
+
if (budget !== undefined && (!Number.isInteger(budget) || budget < 512 || budget > 100000))
|
|
264
|
+
throw new Error('--budget must be an integer from 512 to 100000');
|
|
265
|
+
const baseline = baselinePath ? JSON.parse(readFileSync(baselinePath, 'utf8')) : undefined;
|
|
266
|
+
const result = describe(checked, sourceFile ?? join(root, 'main.aug'), { name: symbolName, budget, context: command === 'context', baseline });
|
|
267
|
+
process.stdout.write(JSON.stringify(result, null, json ? undefined : 2) + '\n');
|
|
268
|
+
return 0;
|
|
269
|
+
}
|
|
270
|
+
if (command === 'definition') {
|
|
271
|
+
if (!sourceFile || (!symbolName && offsetText === undefined))
|
|
272
|
+
throw new Error('definition requires --file and --offset or --name');
|
|
273
|
+
const offset = Number(offsetText);
|
|
274
|
+
if (offsetText !== undefined && (!Number.isInteger(offset) || offset < 0))
|
|
275
|
+
throw new Error('definition requires a nonnegative --offset');
|
|
276
|
+
let found;
|
|
277
|
+
if (offsetText !== undefined)
|
|
278
|
+
found = definitionAt(project, sourceFile, offset);
|
|
279
|
+
else {
|
|
280
|
+
const def = project.scopes.get(resolve(sourceFile))?.get(symbolName);
|
|
281
|
+
found = def && { name: def.name, file: def.file, line: def.node.span.line,
|
|
282
|
+
column: def.node.span.column, kind: def.node.kind };
|
|
283
|
+
}
|
|
284
|
+
process.stdout.write(JSON.stringify(found ?? null) + '\n');
|
|
285
|
+
return found ? 0 : 1;
|
|
286
|
+
}
|
|
287
|
+
if (command === 'symbols') {
|
|
288
|
+
const symbols = [...project.definitions.values()].map(def => ({ name: def.name,
|
|
289
|
+
file: def.file, line: def.node.span.line, column: def.node.span.column,
|
|
290
|
+
kind: def.node.kind }));
|
|
291
|
+
process.stdout.write(JSON.stringify(symbols) + '\n');
|
|
292
|
+
return checked.diagnostics.some(issue => issue.severity !== 'warning') ? 1 : 0;
|
|
293
|
+
}
|
|
294
|
+
const hasErrors = checked.diagnostics.some(issue => issue.severity !== 'warning');
|
|
295
|
+
printDiagnostics(checked.diagnostics, json && (command === 'check' || command === 'spec' && hasErrors), root);
|
|
296
|
+
if (hasErrors)
|
|
297
|
+
return 1;
|
|
298
|
+
if (command === 'check') {
|
|
299
|
+
if (!json)
|
|
300
|
+
process.stdout.write('AugScript check passed\n');
|
|
301
|
+
return 0;
|
|
302
|
+
}
|
|
303
|
+
if (command === 'spec') {
|
|
304
|
+
const result = updateSpecs(checked, options.includes('--check'));
|
|
305
|
+
process.stdout.write(json ? JSON.stringify(result) + '\n' : result.stale.length ? 'Stale specifications:\n' + result.stale.map(file => ' ' + file).join('\n') + '\n' : `${result.files} specification artifact(s) ${options.includes('--check') ? 'are current' : 'generated'}.\n`);
|
|
306
|
+
return result.stale.length ? 1 : 0;
|
|
307
|
+
}
|
|
308
|
+
const generated = generateC(checked);
|
|
309
|
+
if (command === 'emit-c') {
|
|
310
|
+
process.stdout.write(generated);
|
|
311
|
+
return 0;
|
|
312
|
+
}
|
|
313
|
+
if (command === 'bench' && (!Number.isInteger(iterations) || iterations < 1 || iterations > 1000 ||
|
|
314
|
+
!Number.isInteger(warmup) || warmup < 0 || warmup > 100 || !Number.isInteger(timeout) || timeout < 1))
|
|
315
|
+
throw new Error('bench requires iterations 1–1000, warmup 0–100, and a positive timeout');
|
|
316
|
+
const native = compileNative(root, generated, { output: outputOption, release: command === 'bench' ? true : undefined, checked });
|
|
317
|
+
const output = native.output;
|
|
318
|
+
if (native.status !== 0) {
|
|
319
|
+
if (native.diagnostics.length)
|
|
320
|
+
printDiagnostics(native.diagnostics, json, root);
|
|
321
|
+
else
|
|
322
|
+
process.stderr.write(native.error + '\n');
|
|
323
|
+
return native.status;
|
|
324
|
+
}
|
|
325
|
+
updateSpecs(checked);
|
|
326
|
+
if (command === 'build') {
|
|
327
|
+
process.stdout.write(json ? JSON.stringify({ output, sourceMap: output + '.augmap.json' }) + '\n' : `${output}\n`);
|
|
328
|
+
return 0;
|
|
329
|
+
}
|
|
330
|
+
if (command === 'bench') {
|
|
331
|
+
const report = benchmark(output, root, iterations, warmup, programArgs, timeout);
|
|
332
|
+
process.stdout.write(json ? JSON.stringify(report) + '\n' : `Median ${report.median.toFixed(3)}ms; p95 ${report.p95.toFixed(3)}ms (${iterations} native runs, including process startup)\n`);
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
335
|
+
const run = spawnSync(output, programArgs, { stdio: 'inherit', cwd: root });
|
|
336
|
+
if (run.error)
|
|
337
|
+
throw run.error;
|
|
338
|
+
return run.status ?? 1;
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
342
|
+
return 1;
|
|
343
|
+
}
|
|
344
|
+
}
|